From: Alexey Samsonov Date: Wed, 22 Oct 2014 18:26:07 +0000 (+0000) Subject: SanitizerBlacklist: Use spelling location for blacklisting purposes. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa7a8569bba1927648b876d96a874c61e18444ef;p=platform%2Fupstream%2Fllvm.git 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. llvm-svn: 220403 --- diff --git a/clang/lib/Basic/SanitizerBlacklist.cpp b/clang/lib/Basic/SanitizerBlacklist.cpp index 9b2cdfd..c894129 100644 --- a/clang/lib/Basic/SanitizerBlacklist.cpp +++ b/clang/lib/Basic/SanitizerBlacklist.cpp @@ -40,6 +40,7 @@ bool SanitizerBlacklist::isBlacklistedFile(StringRef FileName, 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); } diff --git a/clang/test/CodeGen/address-safety-attr.cpp b/clang/test/CodeGen/address-safety-attr.cpp index ee368f1..0d585c7 100644 --- a/clang/test/CodeGen/address-safety-attr.cpp +++ b/clang/test/CodeGen/address-safety-attr.cpp @@ -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]]