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
This commit is contained in:
Alexey Samsonov 2014-10-22 18:26:07 +00:00
parent 64313c94ae
commit fa7a8569bb
2 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -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]]