From dcd7bb022a304de69161fe990b12e6341313a69e Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Sat, 17 Jan 2015 00:56:10 +0000 Subject: [PATCH] Clean up a string comparison with StringRef. Suggestion by David Majnemer. llvm-svn: 226359 --- clang/lib/Basic/Diagnostic.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 83228ad..6750438 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -633,7 +633,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, // When the diagnostic string is only "%0", the entire string is being given // by an outside source. Remove unprintable characters from this string // and skip all the other string processing. - if (DiagEnd - DiagStr == 2 && DiagStr[0] == '%' && DiagStr[1] == '0' && + if (DiagEnd - DiagStr == 2 && + StringRef(DiagStr, DiagEnd - DiagStr).equals("%0") && getArgKind(0) == DiagnosticsEngine::ak_std_string) { const std::string &S = getArgStdStr(0); for (char c : S) { -- 2.7.4