[cfe-commits] r63925 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/PPLexerChange.cpp

Chris Lattner sabre at nondot.org
Thu Feb 5 22:26:43 PST 2009


Author: lattner
Date: Fri Feb  6 00:26:42 2009
New Revision: 63925

URL: http://llvm.org/viewvc/llvm-project?rev=63925&view=rev
Log:
add interface for walking macro table.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=63925&r1=63924&r2=63925&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Feb  6 00:26:42 2009
@@ -247,6 +247,15 @@
   ///
   void setMacroInfo(IdentifierInfo *II, MacroInfo *MI);
   
+  /// macro_iterator/macro_begin/macro_end - This allows you to walk the current
+  /// state of the macro table.  This visits every currently-defined macro.
+  typedef llvm::DenseMap<IdentifierInfo*, 
+                         MacroInfo*>::const_iterator macro_iterator;
+  macro_iterator macro_begin() const { return Macros.begin(); }
+  macro_iterator macro_end() const { return Macros.end(); }
+  
+  
+  
   const std::string &getPredefines() const { return Predefines; }
   /// setPredefines - Set the predefines for this Preprocessor.  These
   /// predefines are automatically injected when parsing the main file.

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=63925&r1=63924&r2=63925&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri Feb  6 00:26:42 2009
@@ -238,11 +238,9 @@
   // This is the end of the top-level file.  If the diag::pp_macro_not_used
   // diagnostic is enabled, look for macros that have not been used.
   if (Diags.getDiagnosticLevel(diag::pp_macro_not_used) != Diagnostic::Ignored){
-    for (llvm::DenseMap<IdentifierInfo*, MacroInfo*>::iterator I =
-         Macros.begin(), E = Macros.end(); I != E; ++I) {
+    for (macro_iterator I = macro_begin(), E = macro_end(); I != E; ++I)
       if (!I->second->isUsed())
         Diag(I->second->getDefinitionLoc(), diag::pp_macro_not_used);
-    }
   }
   return true;
 }





More information about the cfe-commits mailing list