aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Serialization
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-02-20 00:54:57 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-02-20 00:54:57 +0000
commit9818a1d443e97677dd3422305de9cc2b1fb2a8c1 (patch)
treef6b547c4fcc33ff4bae563473287cddfeff4e21c /include/clang/Serialization
parent206f49966f66ad7cbfe3d37c14fa7e6e7410f3be (diff)
[preprocessor] Split the MacroInfo class into two separate concepts, MacroInfo class
for the data specific to a macro definition (e.g. what the tokens are), and MacroDirective class which encapsulates the changes to the "macro namespace" (e.g. the location where the macro name became active, the location where it was undefined, etc.) (A MacroDirective always points to a MacroInfo object.) Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but splitting the concepts allows us to better model the effect of modules to the macro namespace (also as a bonus it allows better modeling of push_macro/pop_macro #pragmas). Modules can have their own macro history, separate from the local (current translation unit) macro history; MacroDirectives will be used to model the macro history (changes to macro namespace). For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created to indicate that "FOO" became active at the import location. Module "A" itself will contain another MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives will point to the same MacroInfo object. Introducing the separation of macro concepts is the first part towards better modeling of module macros. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175585 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r--include/clang/Serialization/ASTDeserializationListener.h4
-rw-r--r--include/clang/Serialization/ASTReader.h21
-rw-r--r--include/clang/Serialization/ASTWriter.h14
3 files changed, 20 insertions, 19 deletions
diff --git a/include/clang/Serialization/ASTDeserializationListener.h b/include/clang/Serialization/ASTDeserializationListener.h
index 0218129fb6..b54f791994 100644
--- a/include/clang/Serialization/ASTDeserializationListener.h
+++ b/include/clang/Serialization/ASTDeserializationListener.h
@@ -23,7 +23,7 @@ class Decl;
class ASTReader;
class QualType;
class MacroDefinition;
-class MacroInfo;
+class MacroDirective;
class Module;
class ASTDeserializationListener {
@@ -39,7 +39,7 @@ public:
virtual void IdentifierRead(serialization::IdentID ID,
IdentifierInfo *II) { }
/// \brief A macro was read from the AST file.
- virtual void MacroRead(serialization::MacroID ID, MacroInfo *MI) { }
+ virtual void MacroRead(serialization::MacroID ID, MacroDirective *MD) { }
/// \brief A type was deserialized from the AST file. The ID here has the
/// qualifier bits already removed, and T is guaranteed to be locally
/// unqualified.
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index b8943e7347..68f7720771 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -71,6 +71,7 @@ class CXXCtorInitializer;
class GlobalModuleIndex;
class GotoStmt;
class MacroDefinition;
+class MacroDirective;
class NamedDecl;
class OpaqueValueExpr;
class Preprocessor;
@@ -426,7 +427,7 @@ private:
/// If the pointer at index I is non-NULL, then it refers to the
/// MacroInfo for the identifier with ID=I+1 that has already
/// been loaded.
- std::vector<MacroInfo *> MacrosLoaded;
+ std::vector<MacroDirective *> MacrosLoaded;
typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
GlobalMacroMapType;
@@ -473,7 +474,7 @@ private:
union {
Decl *D;
- MacroInfo *MI;
+ MacroDirective *MD;
};
IdentifierInfo *Id;
@@ -481,11 +482,11 @@ private:
public:
HiddenName(Decl *D) : Kind(Declaration), Loc(), D(D), Id() { }
- HiddenName(IdentifierInfo *II, MacroInfo *MI)
- : Kind(MacroVisibility), Loc(), MI(MI), Id(II) { }
+ HiddenName(IdentifierInfo *II, MacroDirective *MD)
+ : Kind(MacroVisibility), Loc(), MD(MD), Id(II) { }
- HiddenName(IdentifierInfo *II, MacroInfo *MI, SourceLocation Loc)
- : Kind(MacroUndef), Loc(Loc.getRawEncoding()), MI(MI), Id(II) { }
+ HiddenName(IdentifierInfo *II, MacroDirective *MD, SourceLocation Loc)
+ : Kind(MacroUndef), Loc(Loc.getRawEncoding()), MD(MD), Id(II) { }
NameKind getKind() const { return Kind; }
@@ -494,10 +495,10 @@ private:
return D;
}
- std::pair<IdentifierInfo *, MacroInfo *> getMacro() const {
+ std::pair<IdentifierInfo *, MacroDirective *> getMacro() const {
assert((getKind() == MacroUndef || getKind() == MacroVisibility)
&& "Hidden name is not a macro!");
- return std::make_pair(Id, MI);
+ return std::make_pair(Id, MD);
}
SourceLocation getMacroUndefLoc() const {
@@ -1604,7 +1605,7 @@ public:
unsigned LocalID);
/// \brief Retrieve the macro with the given ID.
- MacroInfo *getMacro(serialization::MacroID ID, MacroInfo *Hint = 0);
+ MacroDirective *getMacro(serialization::MacroID ID, MacroDirective *Hint = 0);
/// \brief Retrieve the global macro ID corresponding to the given local
/// ID within the given module file.
@@ -1763,7 +1764,7 @@ public:
Expr *ReadSubExpr();
/// \brief Reads the macro record located at the given offset.
- void ReadMacroRecord(ModuleFile &F, uint64_t Offset, MacroInfo *Hint = 0);
+ void ReadMacroRecord(ModuleFile &F, uint64_t Offset, MacroDirective *Hint = 0);
/// \brief Determine the global preprocessed entity ID that corresponds to
/// the given local ID within the given module.
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h
index d632ba5c6e..b966ae1228 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -53,7 +53,7 @@ class MacroDefinition;
class OpaqueValueExpr;
class OpenCLOptions;
class ASTReader;
-class MacroInfo;
+class MacroDirective;
class Module;
class PreprocessedEntity;
class PreprocessingRecord;
@@ -230,7 +230,7 @@ private:
serialization::MacroID NextMacroID;
/// \brief Map that provides the ID numbers of each macro.
- llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs;
+ llvm::DenseMap<MacroDirective *, serialization::MacroID> MacroIDs;
/// @name FlushStmt Caches
/// @{
@@ -267,7 +267,7 @@ private:
/// table, indexed by the Selector ID (-1).
std::vector<uint32_t> SelectorOffsets;
- typedef llvm::MapVector<MacroInfo *, MacroUpdate> MacroUpdatesMap;
+ typedef llvm::MapVector<MacroDirective *, MacroUpdate> MacroUpdatesMap;
/// \brief Updates to macro definitions that were loaded from an AST file.
MacroUpdatesMap MacroUpdates;
@@ -510,7 +510,7 @@ public:
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record);
/// \brief Emit a reference to a macro.
- void addMacroRef(MacroInfo *MI, RecordDataImpl &Record);
+ void addMacroRef(MacroDirective *MI, RecordDataImpl &Record);
/// \brief Emit a Selector (which is a smart pointer reference).
void AddSelectorRef(Selector, RecordDataImpl &Record);
@@ -530,7 +530,7 @@ public:
serialization::IdentID getIdentifierRef(const IdentifierInfo *II);
/// \brief Get the unique number used to refer to the given macro.
- serialization::MacroID getMacroRef(MacroInfo *MI);
+ serialization::MacroID getMacroRef(MacroDirective *MI);
/// \brief Emit a reference to a type.
void AddTypeRef(QualType T, RecordDataImpl &Record);
@@ -693,7 +693,7 @@ public:
// ASTDeserializationListener implementation
void ReaderInitialized(ASTReader *Reader);
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II);
- void MacroRead(serialization::MacroID ID, MacroInfo *MI);
+ void MacroRead(serialization::MacroID ID, MacroDirective *MI);
void TypeRead(serialization::TypeIdx Idx, QualType T);
void SelectorRead(serialization::SelectorID ID, Selector Sel);
void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
@@ -701,7 +701,7 @@ public:
void ModuleRead(serialization::SubmoduleID ID, Module *Mod);
// PPMutationListener implementation.
- virtual void UndefinedMacro(MacroInfo *MI);
+ virtual void UndefinedMacro(MacroDirective *MD);
// ASTMutationListener implementation.
virtual void CompletedTagDefinition(const TagDecl *D);