aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-12 21:07:52 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-12 21:07:52 +0000
commit1a43415b28e60e0e421ef60e254126acec7ab462 (patch)
treef769966940b9b1bae473ce1bcca74691ed22784f
parentad834d534e9a5db3d3baa09593775f83ceaff1f2 (diff)
Add a method in ASTMutationListener for the last use of Decl's [is/set]ChangedSinceDeserialization
and remove them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144466 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTMutationListener.h3
-rw-r--r--include/clang/AST/DeclBase.h20
-rw-r--r--include/clang/Serialization/ASTWriter.h3
-rw-r--r--lib/Sema/SemaDeclObjC.cpp7
-rw-r--r--lib/Serialization/ASTWriter.cpp16
5 files changed, 19 insertions, 30 deletions
diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h
index 7f5cbd1b01..03b658cd47 100644
--- a/include/clang/AST/ASTMutationListener.h
+++ b/include/clang/AST/ASTMutationListener.h
@@ -64,6 +64,9 @@ public:
/// \brief A objc interface or protocol forward reference was completed.
virtual void CompletedObjCForwardRef(const ObjCContainerDecl *D) {}
+
+ /// \brief The attributes list of a declaration was updated.
+ virtual void UpdatedAttributeList(const Decl *D) {}
};
} // end namespace clang
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index db0cf95842..b11570fe2d 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -253,9 +253,6 @@ protected:
/// \brief Whether this declaration was loaded from an AST file.
unsigned FromASTFile : 1;
- /// ChangedAfterLoad - if this declaration has changed since being loaded
- unsigned ChangedAfterLoad : 1;
-
/// \brief Whether this declaration is private to the module in which it was
/// defined.
unsigned ModulePrivate : 1;
@@ -285,7 +282,7 @@ protected:
: NextDeclInContext(0), DeclCtx(DC),
Loc(L), DeclKind(DK), InvalidDecl(0),
HasAttrs(false), Implicit(false), Used(false), Referenced(false),
- Access(AS_none), FromASTFile(0), ChangedAfterLoad(false),
+ Access(AS_none), FromASTFile(0),
ModulePrivate(0),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
@@ -296,7 +293,7 @@ protected:
Decl(Kind DK, EmptyShell Empty)
: NextDeclInContext(0), DeclKind(DK), InvalidDecl(0),
HasAttrs(false), Implicit(false), Used(false), Referenced(false),
- Access(AS_none), FromASTFile(0), ChangedAfterLoad(false),
+ Access(AS_none), FromASTFile(0),
ModulePrivate(0),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
@@ -505,19 +502,6 @@ public:
/// a precompiled header or module) rather than having been parsed.
bool isFromASTFile() const { return FromASTFile; }
- /// \brief Query whether this declaration was changed in a significant way
- /// since being loaded from an AST file.
- ///
- /// In an epic violation of layering, what is "significant" is entirely
- /// up to the serialization system, but implemented in AST and Sema.
- bool isChangedSinceDeserialization() const { return ChangedAfterLoad; }
-
- /// \brief Mark this declaration as having changed since deserialization, or
- /// reset the flag.
- void setChangedSinceDeserialization(bool Changed) {
- ChangedAfterLoad = Changed;
- }
-
unsigned getIdentifierNamespace() const {
return IdentifierNamespace;
}
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h
index bff14ec716..2fc75c2272 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -587,8 +587,6 @@ public:
void RewriteDecl(const Decl *D) {
DeclsToRewrite.insert(D);
- // Reset the flag, so that we don't add this decl multiple times.
- const_cast<Decl *>(D)->setChangedSinceDeserialization(false);
}
bool isRewritten(const Decl *D) const {
@@ -669,6 +667,7 @@ public:
virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
const ObjCInterfaceDecl *IFD);
virtual void CompletedObjCForwardRef(const ObjCContainerDecl *D);
+ virtual void UpdatedAttributeList(const Decl *D);
};
/// \brief AST and semantic-analysis consumer that generates a
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 3d1f5bd064..592d7c231e 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -21,6 +21,7 @@
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
+#include "clang/AST/ASTMutationListener.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Sema/DeclSpec.h"
#include "llvm/ADT/DenseSet.h"
@@ -701,8 +702,10 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
}
if (attrList) {
ProcessDeclAttributeList(TUScope, PDecl, attrList);
- if (!isNew)
- PDecl->setChangedSinceDeserialization(true);
+ if (!isNew) {
+ if (ASTMutationListener *L = Context.getASTMutationListener())
+ L->UpdatedAttributeList(PDecl);
+ }
}
Protocols.push_back(PDecl);
ProtoLocs.push_back(IdentList[i].second);
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index a98c4cc82b..3618c4b4be 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -2960,8 +2960,6 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
I != E; ++I) {
if (!(*I)->isFromASTFile())
NewGlobalDecls.push_back(std::make_pair((*I)->getKind(), GetDeclRef(*I)));
- else if ((*I)->isChangedSinceDeserialization())
- (void)GetDeclRef(*I); // Make sure it's written, but don't record it.
}
llvm::BitCodeAbbrev *Abv = new llvm::BitCodeAbbrev();
@@ -3454,12 +3452,6 @@ DeclID ASTWriter::GetDeclRef(const Decl *D) {
// enqueue it in the list of declarations to emit.
ID = NextDeclID++;
DeclTypesToEmit.push(const_cast<Decl *>(D));
- } else if (ID < FirstDeclID && D->isChangedSinceDeserialization()) {
- // We don't add it to the replacement collection here, because we don't
- // have the offset yet.
- DeclTypesToEmit.push(const_cast<Decl *>(D));
- // Reset the flag, so that we don't add this decl multiple times.
- const_cast<Decl *>(D)->setChangedSinceDeserialization(false);
}
return ID;
@@ -4135,3 +4127,11 @@ void ASTWriter::CompletedObjCForwardRef(const ObjCContainerDecl *D) {
RewriteDecl(D);
}
+
+void ASTWriter::UpdatedAttributeList(const Decl *D) {
+ assert(!WritingAST && "Already writing the AST!");
+ if (!D->isFromASTFile())
+ return; // Declaration not imported from PCH.
+
+ RewriteDecl(D);
+}