@@ -27,18 +27,29 @@ NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths,
2727
2828NoSanitizeList::~NoSanitizeList () = default ;
2929
30+ bool NoSanitizeList::containsPrefix (SanitizerMask Mask, StringRef Prefix,
31+ StringRef Name, StringRef Category) const {
32+ std::pair<unsigned , unsigned > NoSan =
33+ SSCL->inSectionBlame (Mask, Prefix, Name, Category);
34+ if (NoSan == llvm::SpecialCaseList::NotFound)
35+ return false ;
36+ std::pair<unsigned , unsigned > San =
37+ SSCL->inSectionBlame (Mask, Prefix, Name, " sanitize" );
38+ // The statement evaluates to true under the following conditions:
39+ // 1. The string "prefix:*=sanitize" is absent.
40+ // 2. If "prefix:*=sanitize" is present, its (File Index, Line Number) is less
41+ // than that of "prefix:*".
42+ return San == llvm::SpecialCaseList::NotFound || NoSan > San;
43+ }
44+
3045bool NoSanitizeList::containsGlobal (SanitizerMask Mask, StringRef GlobalName,
3146 StringRef Category) const {
3247 return SSCL->inSection (Mask, " global" , GlobalName, Category);
3348}
3449
3550bool NoSanitizeList::containsType (SanitizerMask Mask, StringRef MangledTypeName,
3651 StringRef Category) const {
37- auto NoSan = SSCL->inSectionBlame (Mask, " type" , MangledTypeName, Category);
38- if (NoSan == llvm::SpecialCaseList::NotFound)
39- return false ;
40- auto San = SSCL->inSectionBlame (Mask, " type" , MangledTypeName, " sanitize" );
41- return San == llvm::SpecialCaseList::NotFound || NoSan > San;
52+ return containsPrefix (Mask, " type" , MangledTypeName, Category);
4253}
4354
4455bool NoSanitizeList::containsFunction (SanitizerMask Mask,
@@ -48,11 +59,7 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask,
4859
4960bool NoSanitizeList::containsFile (SanitizerMask Mask, StringRef FileName,
5061 StringRef Category) const {
51- auto NoSan = SSCL->inSectionBlame (Mask, " src" , FileName, Category);
52- if (NoSan == llvm::SpecialCaseList::NotFound)
53- return false ;
54- auto San = SSCL->inSectionBlame (Mask, " src" , FileName, " sanitize" );
55- return San == llvm::SpecialCaseList::NotFound || NoSan > San;
62+ return containsPrefix (Mask, " src" , FileName, Category);
5663}
5764
5865bool NoSanitizeList::containsMainFile (SanitizerMask Mask, StringRef FileName,
0 commit comments