[clang-tools-extra] r200139 - Prospective build fix for unsafe usage of getCustomDiagID()

Alp Toker alp at nuanti.com
Sat Jan 25 22:58:01 PST 2014


Author: alp
Date: Sun Jan 26 00:58:01 2014
New Revision: 200139

URL: http://llvm.org/viewvc/llvm-project?rev=200139&view=rev
Log:
Prospective build fix for unsafe usage of getCustomDiagID()

This now requires a compile-time constant string so let's build proper
diagnostic IDs and pass through the inputs as arguments.

Tracks clang changes in r200132.

Modified:
    clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=200139&r1=200138&r2=200139&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Sun Jan 26 00:58:01 2014
@@ -251,10 +251,10 @@ static void reportDiagnostic(const Clang
     Loc = Loc.getLocWithOffset(Message.FileOffset);
   }
   if (CheckName.empty())
-    Diags.Report(Loc, Diags.getCustomDiagID(Level, Message.Message));
+    Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0")) << Message.Message;
   else
-    Diags.Report(Loc, Diags.getCustomDiagID(Level, (Message.Message + " [" +
-                                                    CheckName + "]").str()));
+    Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
+        << Message.Message << CheckName;
 }
 
 void handleErrors(SmallVectorImpl<ClangTidyError> &Errors, bool Fix) {





More information about the cfe-commits mailing list