r220403 - SanitizerBlacklist: Use spelling location for blacklisting purposes.

Alexey Samsonov vonosmas at gmail.com
Wed Oct 22 11:26:07 PDT 2014


Author: samsonov
Date: Wed Oct 22 13:26:07 2014
New Revision: 220403

URL: http://llvm.org/viewvc/llvm-project?rev=220403&view=rev
Log:
SanitizerBlacklist: Use spelling location for blacklisting purposes.

When SanitizerBlacklist decides if the SourceLocation is blacklisted,
we need to first turn it into a SpellingLoc before fetching the filename
and scanning "src:" entries. Otherwise we will fail to fecth the
correct filename for function definitions coming from macro expansion.

Modified:
    cfe/trunk/lib/Basic/SanitizerBlacklist.cpp
    cfe/trunk/test/CodeGen/address-safety-attr.cpp

Modified: cfe/trunk/lib/Basic/SanitizerBlacklist.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SanitizerBlacklist.cpp?rev=220403&r1=220402&r2=220403&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SanitizerBlacklist.cpp (original)
+++ cfe/trunk/lib/Basic/SanitizerBlacklist.cpp Wed Oct 22 13:26:07 2014
@@ -40,6 +40,7 @@ bool SanitizerBlacklist::isBlacklistedFi
 
 bool SanitizerBlacklist::isBlacklistedLocation(SourceLocation Loc,
                                                StringRef Category) const {
-  return !Loc.isInvalid() && isBlacklistedFile(SM.getFilename(Loc), Category);
+  return !Loc.isInvalid() &&
+         isBlacklistedFile(SM.getFilename(SM.getSpellingLoc(Loc)), Category);
 }
 

Modified: cfe/trunk/test/CodeGen/address-safety-attr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-safety-attr.cpp?rev=220403&r1=220402&r2=220403&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/address-safety-attr.cpp (original)
+++ cfe/trunk/test/CodeGen/address-safety-attr.cpp Wed Oct 22 13:26:07 2014
@@ -64,6 +64,15 @@ int AddressSafetyOk(int *a) { return *a;
 // ASAN:  BlacklistedFunction{{.*}}) [[WITH]]
 int BlacklistedFunction(int *a) { return *a; }
 
+#define GENERATE_FUNC(name) \
+    int name(int *a) { return *a; }
+
+// WITHOUT: GeneratedFunction{{.*}}) [[NOATTR]]
+// BLFILE:  GeneratedFunction{{.*}}) [[NOATTR]]
+// BLFUNC:  GeneratedFunction{{.*}}) [[WITH]]
+// ASAN:    GeneratedFunction{{.*}}) [[WITH]]
+GENERATE_FUNC(GeneratedFunction)
+
 // WITHOUT:  TemplateAddressSafetyOk{{.*}}) [[NOATTR]]
 // BLFILE:  TemplateAddressSafetyOk{{.*}}) [[NOATTR]]
 // BLFUNC:  TemplateAddressSafetyOk{{.*}}) [[WITH]]





More information about the cfe-commits mailing list