aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclSerialization.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-17 14:58:09 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-17 14:58:09 +0000
commit2e1cd4264d363ca869bf37ef160902f211d21b8c (patch)
treeb4e6314529ad811be3463a668f8b4e515f66fbcc /lib/AST/DeclSerialization.cpp
parentb8abbdc90f902a2c09c566193b900c2c45a46672 (diff)
Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of languages. DeclarationName is used in NamedDecl to store the name of the declaration (naturally), and ObjCMethodDecl is now a NamedDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclSerialization.cpp')
-rw-r--r--lib/AST/DeclSerialization.cpp54
1 files changed, 50 insertions, 4 deletions
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index 3df942e8f1..5137b720c5 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -129,12 +129,58 @@ void DeclContext::ReadOutRec(Deserializer& D, ASTContext& C) {
void NamedDecl::EmitInRec(Serializer& S) const {
Decl::EmitInRec(S);
- S.EmitPtr(getIdentifier()); // From NamedDecl.
+ S.EmitInt(Name.getNameKind());
+
+ switch (Name.getNameKind()) {
+ case DeclarationName::Identifier:
+ S.EmitPtr(Name.getAsIdentifierInfo());
+ break;
+
+ case DeclarationName::ObjCZeroArgSelector:
+ case DeclarationName::ObjCOneArgSelector:
+ case DeclarationName::ObjCMultiArgSelector:
+ Name.getObjCSelector().Emit(S);
+ break;
+
+ case DeclarationName::CXXConstructorName:
+ case DeclarationName::CXXDestructorName:
+ case DeclarationName::CXXConversionFunctionName:
+ Name.getCXXNameType().Emit(S);
+ break;
+ }
}
void NamedDecl::ReadInRec(Deserializer& D, ASTContext& C) {
Decl::ReadInRec(D, C);
- D.ReadPtr(Identifier); // From NamedDecl.
+
+ DeclarationName::NameKind Kind
+ = static_cast<DeclarationName::NameKind>(D.ReadInt());
+ switch (Kind) {
+ case DeclarationName::Identifier: {
+ IdentifierInfo *Identifier;
+ D.ReadPtr(Identifier);
+ Name = Identifier;
+ break;
+ }
+
+ case DeclarationName::ObjCZeroArgSelector:
+ case DeclarationName::ObjCOneArgSelector:
+ case DeclarationName::ObjCMultiArgSelector:
+ Name = Selector::ReadVal(D);
+ break;
+
+ case DeclarationName::CXXConstructorName:
+ Name = C.DeclarationNames.getCXXConstructorName(QualType::ReadVal(D));
+ break;
+
+ case DeclarationName::CXXDestructorName:
+ Name = C.DeclarationNames.getCXXDestructorName(QualType::ReadVal(D));
+ break;
+
+ case DeclarationName::CXXConversionFunctionName:
+ Name = C.DeclarationNames.getCXXConversionFunctionName(QualType::ReadVal(D));
+ break;
+ }
}
//===----------------------------------------------------------------------===//
@@ -434,7 +480,7 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
void *Mem = C.getAllocator().Allocate<FunctionDecl>();
FunctionDecl* decl = new (Mem)
- FunctionDecl(Function, 0, SourceLocation(), NULL,
+ FunctionDecl(Function, 0, SourceLocation(), DeclarationName(),
QualType(), SClass, IsInline, 0);
decl->ValueDecl::ReadInRec(D, C);
@@ -495,7 +541,7 @@ OverloadedFunctionDecl *
OverloadedFunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
void *Mem = C.getAllocator().Allocate<OverloadedFunctionDecl>();
OverloadedFunctionDecl* decl = new (Mem)
- OverloadedFunctionDecl(0, NULL);
+ OverloadedFunctionDecl(0, DeclarationName());
decl->NamedDecl::ReadInRec(D, C);