eugenis created this revision. eugenis added reviewers: pcc, vlad.tsyrklevich.
Fixes PR37898. https://reviews.llvm.org/D48454 Files: clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/cfi-check-fail2.c Index: clang/test/CodeGen/cfi-check-fail2.c =================================================================== --- clang/test/CodeGen/cfi-check-fail2.c +++ clang/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: clang/lib/CodeGen/CGExpr.cpp =================================================================== --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3120,11 +3120,16 @@ SanitizerMask Mask = CheckKindMaskPair.second; llvm::Value *Cond = Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind)); - if (CGM.getLangOpts().Sanitize.has(Mask)) + if (CGM.getLangOpts().Sanitize.has(Mask)) { + // This sanitizer may have been disabled in blacklist. This function does + // not have a source location, but "src:*" would still apply. Enable it + // back. + SanOpts.Mask |= Mask; EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {}, {Data, Addr, ValidVtable}); - else + } else { EmitTrapCheck(Cond); + } } FinishFunction();
Index: clang/test/CodeGen/cfi-check-fail2.c =================================================================== --- clang/test/CodeGen/cfi-check-fail2.c +++ clang/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: clang/lib/CodeGen/CGExpr.cpp =================================================================== --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3120,11 +3120,16 @@ SanitizerMask Mask = CheckKindMaskPair.second; llvm::Value *Cond = Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind)); - if (CGM.getLangOpts().Sanitize.has(Mask)) + if (CGM.getLangOpts().Sanitize.has(Mask)) { + // This sanitizer may have been disabled in blacklist. This function does + // not have a source location, but "src:*" would still apply. Enable it + // back. + SanOpts.Mask |= Mask; EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {}, {Data, Addr, ValidVtable}); - else + } else { EmitTrapCheck(Cond); + } } FinishFunction();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits