Author: alexfh Date: Wed Nov 29 09:16:09 2017 New Revision: 319325 URL: http://llvm.org/viewvc/llvm-project?rev=319325&view=rev Log: [clang-tidy] make readability-simplify-bool-expr completely ignore macros
Modified: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=319325&r1=319324&r2=319325&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp Wed Nov 29 09:16:09 2017 @@ -62,10 +62,7 @@ const char SimplifyConditionalReturnDiag 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") { Modified: clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp?rev=319325&r1=319324&r2=319325&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp Wed Nov 29 09:16:09 2017 @@ -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; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits