-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[NoSanitizeList][NFI] Add containsPrefix to remove duplicated logics. #142027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3b8af2c
3ad28ed
b4871cc
30a74a5
d8ac491
fa05c6e
86ae647
ffd687a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,18 +27,29 @@ NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths, | |
|
||
NoSanitizeList::~NoSanitizeList() = default; | ||
|
||
bool NoSanitizeList::containsPrefix(SanitizerMask Mask, StringRef Prefix, | ||
StringRef Name, StringRef Category) const { | ||
std::pair<unsigned, unsigned> NoSan = | ||
SSCL->inSectionBlame(Mask, Prefix, Name, Category); | ||
if (NoSan == llvm::SpecialCaseList::NotFound) | ||
return false; | ||
std::pair<unsigned, unsigned> San = | ||
SSCL->inSectionBlame(Mask, Prefix, Name, "sanitize"); | ||
// The statement evaluates to true under the following conditions: | ||
qinkunbao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// 1. The string "prefix:*=sanitize" is absent. | ||
// 2. If "prefix:*=sanitize" is present, its (File Index, Line Number) is less | ||
// than that of "prefix:*". | ||
return San == llvm::SpecialCaseList::NotFound || NoSan > San; | ||
qinkunbao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName, | ||
StringRef Category) const { | ||
return SSCL->inSection(Mask, "global", GlobalName, Category); | ||
} | ||
|
||
bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName, | ||
StringRef Category) const { | ||
auto NoSan = SSCL->inSectionBlame(Mask, "type", MangledTypeName, Category); | ||
if (NoSan == llvm::SpecialCaseList::NotFound) | ||
return false; | ||
auto San = SSCL->inSectionBlame(Mask, "type", MangledTypeName, "sanitize"); | ||
return San == llvm::SpecialCaseList::NotFound || NoSan > San; | ||
return containsPrefix(Mask, "type", MangledTypeName, Category); | ||
} | ||
|
||
bool NoSanitizeList::containsFunction(SanitizerMask Mask, | ||
|
@@ -48,11 +59,7 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask, | |
|
||
bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName, | ||
StringRef Category) const { | ||
auto NoSan = SSCL->inSectionBlame(Mask, "src", FileName, Category); | ||
if (NoSan == llvm::SpecialCaseList::NotFound) | ||
return false; | ||
auto San = SSCL->inSectionBlame(Mask, "src", FileName, "sanitize"); | ||
return San == llvm::SpecialCaseList::NotFound || NoSan > San; | ||
return containsPrefix(Mask, "src", FileName, Category); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update all other cases in the next patch Fell free to have a single trivial test per prefix, e.g. just check that makes a difference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I plan to update one prefix one PR. Do you think will it be a good idea to update all other cases in one PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a preference, change is trivial per prefix. |
||
} | ||
|
||
bool NoSanitizeList::containsMainFile(SanitizerMask Mask, StringRef FileName, | ||
|
Uh oh!
There was an error while loading. Please reload this page.