]> granicus.if.org Git - clang/commitdiff
add interface for walking macro table.
authorChris Lattner <sabre@nondot.org>
Fri, 6 Feb 2009 06:26:42 +0000 (06:26 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 Feb 2009 06:26:42 +0000 (06:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63925 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
lib/Lex/PPLexerChange.cpp

index 4e57069385d08bc1095fb7e25e0cb1980a53290a..94a7ef45b39c0b3453c03b4f6a9e235867bbb032 100644 (file)
@@ -247,6 +247,15 @@ public:
   ///
   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.
index 3e02fbd63892c7363ec4addffac9679e5797d97f..244281fde692c2f46e353199aa1d6f07789ff745 100644 (file)
@@ -238,11 +238,9 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
   // 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;
 }