summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-10-20 16:22:49 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-10-20 16:22:49 +0000
commitafd639501d240551911b4054d0cefaac51566bf9 (patch)
treeec3b43ac188ee86cf157f7871da1eed9dde279d0 /clang/lib/Serialization
parentbb40ea42e3d0017178fde4e5bdaac01d78a8c13f (diff)
downloadbcm5719-llvm-afd639501d240551911b4054d0cefaac51566bf9.tar.gz
bcm5719-llvm-afd639501d240551911b4054d0cefaac51566bf9.zip
Minor optimization; Try to iterator over redeclarations only when necessary.
llvm-svn: 116930
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 38672a65366..af7043b2708 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -769,15 +769,14 @@ void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
// We need to allocate the DefinitionData struct ahead of VisitRecordDecl
// so that the other CXXRecordDecls can get a pointer even when the owner
// is still initializing.
- bool OwnsDefinitionData = false;
enum DataOwnership { Data_NoDefData, Data_Owner, Data_NotOwner };
- switch ((DataOwnership)Record[Idx++]) {
+ DataOwnership DefOwnership = (DataOwnership)Record[Idx++];
+ switch (DefOwnership) {
default:
assert(0 && "Out of sync with ASTDeclWriter or messed up reading");
case Data_NoDefData:
break;
case Data_Owner:
- OwnsDefinitionData = true;
D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D);
break;
case Data_NotOwner:
@@ -788,11 +787,11 @@ void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
VisitRecordDecl(D);
- if (D->DefinitionData) {
- // Synchronize the DefinitionData pointer among all redeclarations.
- // This synchronization ends up being done multiple times but it's necessary
- // because a chained PCH may introduce a definition that earlier
- // redeclarations in another PCH have no information about.
+ // Spread the DefinitionData pointer if it's the definition (it may have
+ // come from a chained PCH and earlier redeclarations don't know it), or
+ // if it just acquired a pointer that it's not supposed to have (a definition
+ // from a chained PCH updated it).
+ if (D->DefinitionData && DefOwnership != Data_NotOwner) {
llvm::SmallPtrSet<CXXRecordDecl *, 16> PrevRedecls;
PrevRedecls.insert(D);
CXXRecordDecl *Redecl = cast<CXXRecordDecl>(D->RedeclLink.getNext());
@@ -806,7 +805,7 @@ void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
}
}
- if (OwnsDefinitionData) {
+ if (DefOwnership == Data_Owner) {
assert(D->DefinitionData);
struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData;
OpenPOWER on IntegriCloud