From a7551b34adf847777de976fdaa3a3432448eea3b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 18 May 2017 14:25:38 +0200 Subject: Rewrite in macro arguments Change-Id: I6ae619edac26fe06d1f86f139b7cf71ce31146d4 --- compilerplugins/clang/comparisonwithconstant.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compilerplugins/clang/comparisonwithconstant.cxx b/compilerplugins/clang/comparisonwithconstant.cxx index b55a73e05c17..1c7daf5c3c4f 100644 --- a/compilerplugins/clang/comparisonwithconstant.cxx +++ b/compilerplugins/clang/comparisonwithconstant.cxx @@ -150,6 +150,11 @@ std::string ComparisonWithConstant::getExprAsString(SourceRange range) } SourceRange ComparisonWithConstant::ignoreMacroExpansions(SourceRange range) { + while (compiler.getSourceManager().isMacroArgExpansion(range.getBegin())) { + range.setBegin( + compiler.getSourceManager().getImmediateMacroCallerLoc( + range.getBegin())); + } if (range.getBegin().isMacroID()) { SourceLocation loc; if (Lexer::isAtStartOfMacroExpansion( @@ -159,6 +164,11 @@ SourceRange ComparisonWithConstant::ignoreMacroExpansions(SourceRange range) { range.setBegin(loc); } } + while (compiler.getSourceManager().isMacroArgExpansion(range.getEnd())) { + range.setEnd( + compiler.getSourceManager().getImmediateMacroCallerLoc( + range.getEnd())); + } if (range.getEnd().isMacroID()) { SourceLocation loc; if (Lexer::isAtEndOfMacroExpansion( -- cgit