[PATCH] Warn on malformed header guards
Richard Trieu
rtrieu at google.com
Thu May 30 20:25:10 PDT 2013
Check that when a header starts with an #ifndef, the next #define has the same macro name. There's two exceptions, one is that the #define is an actual macro, the other is that the macro is defined later in the file.
// Warn here since x != y
#ifndef x
#define y
#endif
// Don't warn since y is defined to something
#ifndef x
#define y 2
#endif
// Dont warn since x is defined later
#ifndef x
#define y
#define x
#endif
http://llvm-reviews.chandlerc.com/D898
Files:
test/Lexer/header.cpp
test/Lexer/Inputs/bad-header-guard.h
test/Lexer/Inputs/good-header-guard.h
test/Lexer/Inputs/different-define.h
test/Lexer/Inputs/no-define.h
test/Lexer/Inputs/out-of-order-define.h
test/Lexer/Inputs/multiple.h
include/clang/Lex/Preprocessor.h
include/clang/Lex/HeaderSearch.h
include/clang/Lex/MultipleIncludeOpt.h
include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/PPLexerChange.cpp
lib/Lex/PPDirectives.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D898.1.patch
Type: text/x-patch
Size: 12849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130530/fb682303/attachment.bin>
More information about the cfe-commits
mailing list