diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-21 11:25:45 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-21 11:25:45 +0000 |
commit | ba5df6dea5194099a740ed09c48c3080a14210b6 (patch) | |
tree | ceecde064f020db8e8dea8e1acff1839a7b5d229 /clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | |
parent | 4b159228389a982b7305bd876dadf5137b41708d (diff) | |
download | bcm5719-llvm-ba5df6dea5194099a740ed09c48c3080a14210b6.tar.gz bcm5719-llvm-ba5df6dea5194099a740ed09c48c3080a14210b6.zip |
[clang-tidy] Reword the "code outside header guard" warning.
The check doesn't really know if the code it is warning about came before
or after the header guard, so phrase it more neutral instead of complaining
about code before the header guard. The location for the warning is still
not optimal, but I don't think fixing that is worth the effort, the
preprocessor doesn't give us a better location.
Differential Revision: https://reviews.llvm.org/D30191
llvm-svn: 295715
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp index acd63d3b0ad..f89362d88cd 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -223,9 +223,10 @@ public: std::string CPPVar = Check->getHeaderGuard(FileName); std::string CPPVarUnder = CPPVar + '_'; // Allow a trailing underscore. - // If there is a header guard macro but it's not in the topmost position - // emit a plain warning without fix-its. This often happens when the guard - // macro is preceeded by includes. + // If there's a macro with a name that follows the header guard convention + // but was not recognized by the preprocessor as a header guard there must + // be code outside of the guarded area. Emit a plain warning without + // fix-its. // FIXME: Can we move it into the right spot? bool SeenMacro = false; for (const auto &MacroEntry : Macros) { @@ -233,9 +234,8 @@ public: SourceLocation DefineLoc = MacroEntry.first.getLocation(); if ((Name == CPPVar || Name == CPPVarUnder) && SM.isWrittenInSameFile(StartLoc, DefineLoc)) { - Check->diag( - DefineLoc, - "Header guard after code/includes. Consider moving it up."); + Check->diag(DefineLoc, "code/includes outside of area guarded by " + "header guard; consider moving it"); SeenMacro = true; break; } |