[clang-tidy] make readability-simplify-bool-expr completely ignore macros
llvm-svn: 319325
This commit is contained in:
parent
95e0c5fc6c
commit
ac4fe48caa
|
@ -62,10 +62,7 @@ const char SimplifyConditionalReturnDiagnostic[] =
|
|||
const CXXBoolLiteralExpr *getBoolLiteral(const MatchFinder::MatchResult &Result,
|
||||
StringRef Id) {
|
||||
const auto *Literal = Result.Nodes.getNodeAs<CXXBoolLiteralExpr>(Id);
|
||||
return (Literal &&
|
||||
Result.SourceManager->isMacroBodyExpansion(Literal->getLocStart()))
|
||||
? nullptr
|
||||
: Literal;
|
||||
return (Literal && Literal->getLocStart().isMacroID()) ? nullptr : Literal;
|
||||
}
|
||||
|
||||
internal::Matcher<Stmt> returnsBool(bool Value, StringRef Id = "ignored") {
|
||||
|
|
|
@ -281,6 +281,8 @@ static constexpr bool truthy() {
|
|||
}
|
||||
|
||||
#define HAS_XYZ_FEATURE true
|
||||
#define M1(what) M2(true, what)
|
||||
#define M2(condition, what) if (condition) what
|
||||
|
||||
void macros_and_constexprs(int i = 0) {
|
||||
bool b = (i == 1);
|
||||
|
@ -295,9 +297,15 @@ void macros_and_constexprs(int i = 0) {
|
|||
// inline the macro first.
|
||||
i = 3;
|
||||
}
|
||||
if (HAS_XYZ_FEATURE) {
|
||||
i = 5;
|
||||
}
|
||||
i = 4;
|
||||
M1(i = 7);
|
||||
}
|
||||
|
||||
#undef HAS_XYZ_FEATURE
|
||||
|
||||
bool conditional_return_statements(int i) {
|
||||
if (i == 0) return true; else return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue