[clang-tools-extra] r271896 - [clang-tidy] Do not try to suggest a fix if the parameter is partially in a macro.

Samuel Benzaquen via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 6 07:21:11 PDT 2016


Author: sbenza
Date: Mon Jun  6 09:21:11 2016
New Revision: 271896

URL: http://llvm.org/viewvc/llvm-project?rev=271896&view=rev
Log:
[clang-tidy] Do not try to suggest a fix if the parameter is partially in a macro.

It is not easy to tell where to do the suggestion and whether the
suggestion will be correct.

Modified:
    clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp?rev=271896&r1=271895&r2=271896&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp Mon Jun  6 09:21:11 2016
@@ -88,6 +88,12 @@ void AvoidConstParamsInDecls::check(cons
     Diag << Param;
   }
 
+  if (Param->getLocStart().isMacroID() != Param->getLocEnd().isMacroID()) {
+    // Do not offer a suggestion if the part of the variable declaration comes
+    // from a macro.
+    return;
+  }
+
   CharSourceRange FileRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(getTypeRange(*Param)),
       *Result.SourceManager, Result.Context->getLangOpts());




More information about the cfe-commits mailing list