[asan] enable asan only for the functions that have Attribute::AddressSafety
llvm-svn: 148846
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 6ee9550..3f06815 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -608,6 +608,7 @@
bool AddressSanitizer::handleFunction(Module &M, Function &F) {
if (BL->isIn(F)) return false;
if (&F == AsanCtorFunction) return false;
+ if (!F.hasFnAttr(Attribute::AddressSafety)) return false;
if (!ClDebugFunc.empty() && ClDebugFunc != F.getName())
return false;