[PATCH] Warn on malformed header guards

Richard Smith richard at metafoo.co.uk
Fri Jun 7 14:31:57 PDT 2013



================
Comment at: include/clang/Lex/MultipleIncludeOpt.h:37
@@ -34,1 +36,3 @@
 
+  bool AfterIFNDEF;
+
----------------
We capitalize this as Ifndef elsewhere in the Lexer; maybe fix throughout this class? A comment on this variable would be useful.

================
Comment at: include/clang/Lex/Preprocessor.h:1447
@@ -1446,3 +1446,3 @@
   // Macro handling.
-  void HandleDefineDirective(Token &Tok);
+  void HandleDefineDirective(Token &Tok, bool AfterIFNDEF);
   void HandleUndefDirective(Token &Tok);
----------------
AfterIFNDEF here needs a better name, ImmediatelyAfterHeaderGuard or similar?

================
Comment at: lib/Lex/PPLexerChange.cpp:251-253
@@ +250,5 @@
+              CurPPLexer->MIOpt.GetDefinedMacro()) {
+          if (!ControllingMacro->hasMacroDefinition() &&
+              DefinedMacro != ControllingMacro) {
+            if (HeaderInfo.FirstTimeLexingFile(FE)) {
+              // Emit a warning for a bad header guard.
----------------
Maybe fold these two 'if's together?


http://llvm-reviews.chandlerc.com/D898



More information about the cfe-commits mailing list