[cfe-commits] r38638 - in /cfe/cfe/trunk/Lex: PPExpressions.cpp Preprocessor.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:23:25 PDT 2007
Author: sabre
Date: Wed Jul 11 11:23:25 2007
New Revision: 38638
URL: http://llvm.org/viewvc/llvm-project?rev=38638&view=rev
Log:
#ifdef X, #ifndef X, and #if defined(X) all mark X as used.
Modified:
cfe/cfe/trunk/Lex/PPExpressions.cpp
cfe/cfe/trunk/Lex/Preprocessor.cpp
Modified: cfe/cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/PPExpressions.cpp?rev=38638&r1=38637&r2=38638&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/cfe/trunk/Lex/PPExpressions.cpp Wed Jul 11 11:23:25 2007
@@ -19,6 +19,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/MacroInfo.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Basic/Diagnostic.h"
using namespace llvm;
@@ -98,6 +99,9 @@
// Otherwise, we got an identifier, is it defined to something?
Result = II->getMacroInfo() != 0;
+
+ // If there is a macro, mark it used.
+ if (Result) II->getMacroInfo()->setIsUsed(true);
// Consume identifier.
Lex(PeekTok);
Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=38638&r1=38637&r2=38638&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:23:25 2007
@@ -1390,8 +1390,13 @@
// Check to see if this is the last token on the #if[n]def line.
CheckEndOfDirective("#ifdef");
+ MacroInfo *MI = MacroNameTok.getIdentifierInfo()->getMacroInfo();
+
+ // If there is a macro, mark it used.
+ if (MI) MI->setIsUsed(true);
+
// Should we include the stuff contained by this directive?
- if (!MacroNameTok.getIdentifierInfo()->getMacroInfo() == isIfndef) {
+ if (!MI == isIfndef) {
// Yes, remember that we are inside a conditional, then lex the next token.
CurLexer->pushConditionalLevel(DirectiveTok.getLocation(), /*wasskip*/false,
/*foundnonskip*/true, /*foundelse*/false);
More information about the cfe-commits
mailing list