[PATCH] D21815: [clang-tidy] Add 'included from' details to warning message.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 4 03:36:23 PDT 2016
alexfh added inline comments.
================
Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.cpp:49
@@ -48,1 +48,3 @@
+namespace {
+std::string getIncludeFromMessage(SourceLocation DeclLoc,
----------------
Static functions are preferred in LLVM. http://llvm.org/docs/CodingStandards.html#anonymous-namespaces
"make anonymous namespaces as small as possible, and only use them for class declarations. "
================
Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.cpp:96
@@ -74,2 +95,3 @@
diag(D->getLocStart(),
- "using declarations in the global namespace in headers are prohibited");
+ "using declarations in the global namespace in headers are prohibited%0")
+ << IncludeMessage;
----------------
It's more common to present this kind of additional information as notes. As a bonus, the location of the note can point to the #include directive, which will make the whole diagnostic more useful.
Also, we might want to figure out why clang-tidy doesn't print "in file included from ..." itself, as clang does (but until then we can have this hand-rolled implementation).
http://reviews.llvm.org/D21815
More information about the cfe-commits
mailing list