summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2024-11-04 16:00:22 -0800
committerGitHub <noreply@github.com>2024-11-04 16:00:22 -0800
commit21d25d2bcd74a311ddfea970c028e0b8d5ea129f (patch)
treec932364fed5245f1b2d60e3a9795482e4f93cd40 /clang/lib/CodeGen/CGExpr.cpp
parent2c95fb923308302a02096c7181498437345b14f9 (diff)
[ubsan] Suppression by type for `-fsanitize=enum` (#114754)
Similar to #107332.
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index e90e8da3e9f1..3388a6df466d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1941,6 +1941,10 @@ bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
cast<llvm::IntegerType>(Value->getType())->getBitWidth() == 1)
return false;
+ if (NeedsEnumCheck &&
+ getContext().isTypeIgnoredBySanitizer(SanitizerKind::Enum, Ty))
+ return false;
+
llvm::APInt Min, End;
if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool))
return true;