[clang-tools-extra] r257176 - [clang-tidy] Use proper capitalization and punctuation for diagnostic messages.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 8 07:21:40 PST 2016
Author: alexfh
Date: Fri Jan 8 09:21:40 2016
New Revision: 257176
URL: http://llvm.org/viewvc/llvm-project?rev=257176&view=rev
Log:
[clang-tidy] Use proper capitalization and punctuation for diagnostic messages.
Use diagnostic parameters where possible instead of string concatenation.
Modified:
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-namespaces.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Fri Jan 8 09:21:40 2016
@@ -112,10 +112,10 @@ void AvoidCStyleCastsCheck::check(const
SM, Result.Context->getLangOpts());
auto diag_builder =
- diag(CastExpr->getLocStart(), "C-style casts are discouraged. %0");
+ diag(CastExpr->getLocStart(), "C-style casts are discouraged; use %0");
auto ReplaceWithCast = [&](StringRef CastType) {
- diag_builder << ("Use " + CastType).str();
+ diag_builder << CastType;
const Expr *SubExpr = CastExpr->getSubExprAsWritten()->IgnoreImpCasts();
std::string CastText = (CastType + "<" + DestTypeString + ">").str();
@@ -166,7 +166,7 @@ void AvoidCStyleCastsCheck::check(const
break;
}
- diag_builder << "Use static_cast/const_cast/reinterpret_cast";
+ diag_builder << "static_cast/const_cast/reinterpret_cast";
}
} // namespace readability
Modified: clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp Fri Jan 8 09:21:40 2016
@@ -40,9 +40,9 @@ void StringReferenceMemberCheck::registe
void
StringReferenceMemberCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Member = Result.Nodes.getNodeAs<FieldDecl>("member");
- diag(Member->getLocStart(), "const string& members are dangerous. It is much "
+ diag(Member->getLocStart(), "const string& members are dangerous; it is much "
"better to use alternatives, such as pointers or "
- "simple constants.");
+ "simple constants");
}
} // namespace runtime
Modified: clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp Fri Jan 8 09:21:40 2016
@@ -41,7 +41,7 @@ UnnamedNamespaceInHeaderCheck::check(con
StringRef FileName = SM->getPresumedLoc(Loc).getFilename();
if (FileName.endswith(".h") || FileName.endswith(".hh") ||
FileName.endswith(".hpp") || FileName.endswith(".hxx"))
- diag(Loc, "do not use unnamed namespaces in header files.");
+ diag(Loc, "do not use unnamed namespaces in header files");
}
} // namespace build
Modified: clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp Fri Jan 8 09:21:40 2016
@@ -34,8 +34,8 @@ UsingNamespaceDirectiveCheck::check(cons
if (U->isImplicit() || !Loc.isValid())
return;
- diag(Loc, "do not use namespace using-directives. Use using-declarations "
- "instead.");
+ diag(Loc, "do not use namespace using-directives; "
+ "use using-declarations instead");
// TODO: We could suggest a list of using directives replacing the using
// namespace directive.
}
Modified: clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp Fri Jan 8 09:21:40 2016
@@ -111,7 +111,7 @@ void AssertSideEffectCheck::check(const
if (AssertMacroName.empty())
return;
- diag(Loc, "found " + AssertMacroName.str() + "() with side effect");
+ diag(Loc, "found %0() with side effect") << AssertMacroName;
}
} // namespace tidy
Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp Fri Jan 8 09:21:40 2016
@@ -122,7 +122,7 @@ void RedundantSmartptrGetCheck::check(co
*Result.SourceManager, Result.Context->getLangOpts());
// Replace foo->get() with *foo, and foo.get() with foo.
std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str();
- diag(GetCall->getLocStart(), "Redundant get() call on smart pointer.")
+ diag(GetCall->getLocStart(), "redundant get() call on smart pointer")
<< FixItHint::CreateReplacement(GetCall->getSourceRange(), Replacement);
}
Modified: clang-tools-extra/trunk/test/clang-tidy/google-namespaces.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-namespaces.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-namespaces.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-namespaces.cpp Fri Jan 8 09:21:40 2016
@@ -1,8 +1,8 @@
// RUN: clang-tidy %s -checks='-*,google-build-namespaces,google-build-using-namespace' -header-filter='.*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
#include "Inputs/google-namespaces.h"
-// CHECK: warning: do not use unnamed namespaces in header files.
+// CHECK: warning: do not use unnamed namespaces in header files [google-build-namespaces]
using namespace spaaaace;
-// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives. Use using-declarations instead.
+// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
using spaaaace::core; // no-warning
Modified: clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp Fri Jan 8 09:21:40 2016
@@ -28,63 +28,63 @@ void f(int a, double b, const char *cpc,
// CHECK-FIXES: {{^}} t1;
char *pc = (char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged. Use const_cast [google-readability-casting]
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use const_cast [google-readability-casting]
// CHECK-FIXES: char *pc = const_cast<char*>(cpc);
char *pc2 = (char*)(cpc + 33);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}. Use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast {{.*}}
// CHECK-FIXES: char *pc2 = const_cast<char*>(cpc + 33);
const char &crc = *cpc;
char &rc = (char&)crc;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}}. Use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}}; use const_cast {{.*}}
// CHECK-FIXES: char &rc = const_cast<char&>(crc);
char &rc2 = (char&)*cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}. Use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast {{.*}}
// CHECK-FIXES: char &rc2 = const_cast<char&>(*cpc);
char ** const* const* ppcpcpc;
char ****ppppc = (char****)ppcpcpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: {{.*}}. Use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: {{.*}}; use const_cast {{.*}}
// CHECK-FIXES: char ****ppppc = const_cast<char****>(ppcpcpc);
char ***pppc = (char***)*(ppcpcpc);
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: {{.*}}. Use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: {{.*}}; use const_cast {{.*}}
// CHECK-FIXES: char ***pppc = const_cast<char***>(*(ppcpcpc));
char ***pppc2 = (char***)(*ppcpcpc);
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}}. Use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}}; use const_cast {{.*}}
// CHECK-FIXES: char ***pppc2 = const_cast<char***>(*ppcpcpc);
char *pc5 = (char*)(const char*)(cpv);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}. Use const_cast {{.*}}
- // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: {{.*}}. Use reinterpret_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: {{.*}}; use reinterpret_cast {{.*}}
// CHECK-FIXES: char *pc5 = const_cast<char*>(reinterpret_cast<const char*>(cpv));
int b1 = (int)b;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}. Use static_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}; use static_cast {{.*}}
// CHECK-FIXES: int b1 = static_cast<int>(b);
Y *pB = (Y*)pX;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}. Use static_cast/const_cast/reinterpret_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast {{.*}}
Y &rB = (Y&)*pX;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}. Use static_cast/const_cast/reinterpret_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast {{.*}}
const char *pc3 = (const char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}. Use reinterpret_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}; use reinterpret_cast {{.*}}
// CHECK-FIXES: const char *pc3 = reinterpret_cast<const char*>(cpv);
char *pc4 = (char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}. Use static_cast/const_cast/reinterpret_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast {{.*}}
// CHECK-FIXES: char *pc4 = (char*)cpv;
b1 = (int)Enum1;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}. Use static_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}}
// CHECK-FIXES: b1 = static_cast<int>(Enum1);
Enum e = (Enum)b1;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}. Use static_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}; use static_cast {{.*}}
// CHECK-FIXES: Enum e = static_cast<Enum>(b1);
// CHECK-MESSAGES-NOT: warning:
@@ -99,7 +99,7 @@ void f(int a, double b, const char *cpc,
template <typename T>
void template_function(T t, int n) {
int i = (int)t;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}. Use static_cast/const_cast/reinterpret_cast {{.*}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast {{.*}}
// CHECK-FIXES: int i = (int)t;
int j = (int)n;
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant cast to the same type
@@ -110,7 +110,7 @@ template <typename T>
struct TemplateStruct {
void f(T t, int n) {
int k = (int)t;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}}. Use static_cast/const_cast/reinterpret_cast
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast
// CHECK-FIXES: int k = (int)t;
int l = (int)n;
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant cast to the same type
Modified: clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp Fri Jan 8 09:21:40 2016
@@ -12,7 +12,7 @@ class string {};
struct A {
const std::string &s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. [google-runtime-member-string-references]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous; it is much better to use alternatives, such as pointers or simple constants [google-runtime-member-string-references]
};
struct B {
@@ -28,14 +28,14 @@ struct D {
D();
const T &s;
const std::string &s2;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous
};
D<std::string> d;
struct AA {
const string &s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous
};
struct BB {
Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=257176&r1=257175&r2=257176&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Fri Jan 8 09:21:40 2016
@@ -48,56 +48,56 @@ void Positive() {
BarPtr u;
// CHECK-FIXES: BarPtr u;
BarPtr().get()->Do();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer. [readability-redundant-smartptr-get]
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant get() call on smart pointer [readability-redundant-smartptr-get]
// CHECK-MESSAGES: BarPtr().get()->Do();
// CHECK-FIXES: BarPtr()->Do();
u.get()->ConstDo();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant get() call
// CHECK-MESSAGES: u.get()->ConstDo();
// CHECK-FIXES: u->ConstDo();
Bar& b = *BarPtr().get();
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
// CHECK-MESSAGES: Bar& b = *BarPtr().get();
// CHECK-FIXES: Bar& b = *BarPtr();
Bar& b2 = *std::unique_ptr<Bar>().get();
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant get() call
// CHECK-MESSAGES: Bar& b2 = *std::unique_ptr<Bar>().get();
// CHECK-FIXES: Bar& b2 = *std::unique_ptr<Bar>();
(*BarPtr().get()).ConstDo();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant get() call
// CHECK-MESSAGES: (*BarPtr().get()).ConstDo();
// CHECK-FIXES: (*BarPtr()).ConstDo();
(*std::unique_ptr<Bar>().get()).ConstDo();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant get() call
// CHECK-MESSAGES: (*std::unique_ptr<Bar>().get()).ConstDo();
// CHECK-FIXES: (*std::unique_ptr<Bar>()).ConstDo();
std::unique_ptr<Bar>* up;
(*up->get()).Do();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant get() call
// CHECK-MESSAGES: (*up->get()).Do();
// CHECK-FIXES: (**up).Do();
int_ptr ip;
int i = *ip.get();
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant get() call
// CHECK-MESSAGES: int i = *ip.get();
// CHECK-FIXES: int i = *ip;
std::unique_ptr<int> uu;
std::shared_ptr<double> *ss;
bool bb = uu.get() == nullptr;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
// CHECK-MESSAGES: uu.get() == nullptr;
// CHECK-FIXES: bool bb = uu == nullptr;
bb = nullptr != ss->get();
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: Redundant get() call on smart pointer.
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: redundant get() call
// CHECK-MESSAGES: nullptr != ss->get();
// CHECK-FIXES: bb = nullptr != *ss;
}
More information about the cfe-commits
mailing list