summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-10-17 00:20:19 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-10-17 00:20:19 +0000
commit1444bb9fc8ff56ae7dc2f9f22fa3518f91dc8d1f (patch)
tree55d7e48eace738256a8fde191acbca84ff7b3514 /clang/lib/CodeGen/CodeGenModule.h
parent3514242a660c2a8cd7165ad1831a7c35d8ab9898 (diff)
downloadbcm5719-llvm-1444bb9fc8ff56ae7dc2f9f22fa3518f91dc8d1f.tar.gz
bcm5719-llvm-1444bb9fc8ff56ae7dc2f9f22fa3518f91dc8d1f.zip
SanitizerBlacklist: blacklist functions by their source location.
This commit changes the way we blacklist functions in ASan, TSan, MSan and UBSan. We used to treat function as "blacklisted" and turned off instrumentation in it in two cases: 1) Function is explicitly blacklisted by its mangled name. This part is not changed. 2) Function is located in llvm::Module, whose identifier is contained in the list of blacklisted sources. This is completely wrong, as llvm::Module may not correspond to the actual source file function is defined in. Also, function can be defined in a header, in which case user had to blacklist the .cpp file this header was #include'd into, not the header itself. Such functions could cause other problems - for instance, if the header was included in multiple source files, compiled separately and linked into a single executable, we could end up with both instrumented and non-instrumented version of the same function participating in the same link. After this change we will make blacklisting decision based on the SourceLocation of a function definition. If a function is not explicitly defined in the source file, (for example, the function is compiler-generated and responsible for initialization/destruction of a global variable), then it will be blacklisted if the corresponding global variable is defined in blacklisted source file, and will be instrumented otherwise. After this commit, the active users of blacklist files may have to revisit them. This is a backwards-incompatible change, but I don't think it's possible or makes sense to support the old incorrect behavior. I plan to make similar change for blacklisting GlobalVariables (which is ASan-specific). llvm-svn: 219997
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index a63b799baa7..546e59309e0 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -686,9 +686,10 @@ public:
CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
llvm::GlobalValue::LinkageTypes Linkage);
- llvm::Function *CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty,
- const Twine &name,
- bool TLS = false);
+ llvm::Function *
+ CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name,
+ SourceLocation Loc = SourceLocation(),
+ bool TLS = false);
/// Return the address space of the underlying global variable for D, as
/// determined by its declaration. Normally this is the same as the address
@@ -1045,9 +1046,7 @@ public:
/// annotations are emitted during finalization of the LLVM code.
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
- const SanitizerBlacklist &getSanitizerBlacklist() const {
- return Context.getSanitizerBlacklist();
- }
+ bool isInSanitizerBlacklist(llvm::Function *Fn, SourceLocation Loc) const;
SanitizerMetadata *getSanitizerMetadata() {
return SanitizerMD.get();
OpenPOWER on IntegriCloud