]> granicus.if.org Git - clang/commitdiff
Constify argument of Preprocessor::getMacroInfoHistory and propagate to
authorDmitri Gribenko <gribozavr@gmail.com>
Mon, 14 Jan 2013 00:36:42 +0000 (00:36 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Mon, 14 Jan 2013 00:36:42 +0000 (00:36 +0000)
callers, removing unneeded const_cast

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172372 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
include/clang/Sema/CodeCompleteConsumer.h
lib/Frontend/PrintPreprocessedOutput.cpp
lib/Lex/PPMacroExpansion.cpp
tools/libclang/CIndex.cpp
tools/libclang/CXCursor.cpp

index 8457cc5ad6af6b844e94f79edfcba7f0b1ea78a4..1789e81b0a216004c34084a1166206860dd7a779 100644 (file)
@@ -307,7 +307,7 @@ class Preprocessor : public RefCountedBase<Preprocessor> {
   /// Macros - For each IdentifierInfo that was associated with a macro, we
   /// keep a mapping to the history of all macro definitions and #undefs in
   /// the reverse order (the latest one is in the head of the list).
-  llvm::DenseMap<IdentifierInfo*, MacroInfo*> Macros;
+  llvm::DenseMap<const IdentifierInfo*, MacroInfo*> Macros;
   friend class ASTReader;
   
   /// \brief Macros that we want to warn because they are not used at the end
@@ -520,7 +520,7 @@ public:
   /// representing the most recent macro definition. One can iterate over all
   /// previous macro definitions from it. This method should only be called for
   /// identifiers that hadMacroDefinition().
-  MacroInfo *getMacroInfoHistory(IdentifierInfo *II) const;
+  MacroInfo *getMacroInfoHistory(const IdentifierInfo *II) const;
 
   /// \brief Specify a macro for this identifier.
   void setMacroInfo(IdentifierInfo *II, MacroInfo *MI);
@@ -537,7 +537,7 @@ public:
   /// history table. Currently defined macros have
   /// IdentifierInfo::hasMacroDefinition() set and an empty
   /// MacroInfo::getUndefLoc() at the head of the list.
-  typedef llvm::DenseMap<IdentifierInfo*,
+  typedef llvm::DenseMap<const IdentifierInfo *,
                          MacroInfo*>::const_iterator macro_iterator;
   macro_iterator macro_begin(bool IncludeExternalMacros = true) const;
   macro_iterator macro_end(bool IncludeExternalMacros = true) const;
index 2eb9170369c8f0430483e895f27cfd2bca165ce0..2a8da3260a57b30acbff80f6f29e402ec69e36e4 100644 (file)
@@ -661,7 +661,7 @@ public:
     CodeCompletionString *Pattern;
 
     /// \brief When Kind == RK_Macro, the identifier that refers to a macro.
-    IdentifierInfo *Macro;
+    const IdentifierInfo *Macro;
   };
 
   /// \brief The priority of this particular code-completion result.
@@ -728,7 +728,8 @@ public:
   }
 
   /// \brief Build a result that refers to a macro.
-  CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro)
+  CodeCompletionResult(const IdentifierInfo *Macro,
+                       unsigned Priority = CCP_Macro)
     : Declaration(0), Macro(Macro), Priority(Priority), StartParameter(0),
       Kind(RK_Macro), CursorKind(CXCursor_MacroDefinition),
       Availability(CXAvailability_Available), Hidden(false),
index 02da71bbbe85165e7e8e56c665692ac954633e0c..cc8d935b52f65409dd71b59b42c79ecb64be79d7 100644 (file)
@@ -565,7 +565,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
   }
 }
 
-typedef std::pair<IdentifierInfo*, MacroInfo*> id_macro_pair;
+typedef std::pair<const IdentifierInfo *, MacroInfo *> id_macro_pair;
 static int MacroIDCompare(const void* a, const void* b) {
   const id_macro_pair *LHS = static_cast<const id_macro_pair*>(a);
   const id_macro_pair *RHS = static_cast<const id_macro_pair*>(b);
index eb08977ee67cc6f0cb0651a2e26c590be81c98ac..c626b4d561a95634465014654bea85dcf1e7b2e3 100644 (file)
@@ -32,7 +32,7 @@
 #include <ctime>
 using namespace clang;
 
-MacroInfo *Preprocessor::getMacroInfoHistory(IdentifierInfo *II) const {
+MacroInfo *Preprocessor::getMacroInfoHistory(const IdentifierInfo *II) const {
   assert(II->hadMacroDefinition() && "Identifier has not been not a macro!");
 
   macro_iterator Pos = Macros.find(II);
index 3237d22d782d8538d99b26d07ed60a7a05296c89..33811d0fb7008cdad676382745468376cba05b1c 100644 (file)
@@ -6233,7 +6233,7 @@ MacroInfo *cxindex::getMacroInfo(const IdentifierInfo &II,
 
   ASTUnit *Unit = static_cast<ASTUnit *>(TU->TUData);
   Preprocessor &PP = Unit->getPreprocessor();
-  MacroInfo *MI = PP.getMacroInfoHistory(const_cast<IdentifierInfo*>(&II));
+  MacroInfo *MI = PP.getMacroInfoHistory(&II);
   while (MI) {
     if (MacroDefLoc == MI->getDefinitionLoc())
       return MI;
index f4faab313bbda5257dc158ad9cfdad251cadae25..7134dc4189242ff71e4bd443d47b4c458c9a0cc0 100644 (file)
@@ -1056,7 +1056,7 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
     const MacroDefinition *definition = getCursorMacroDefinition(cursor);
     const IdentifierInfo *MacroInfo = definition->getName();
     ASTUnit *unit = getCursorASTUnit(cursor);
-    CodeCompletionResult Result(const_cast<IdentifierInfo *>(MacroInfo));
+    CodeCompletionResult Result(MacroInfo);
     CodeCompletionString *String
       = Result.CreateCodeCompletionString(unit->getASTContext(),
                                           unit->getPreprocessor(),