mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 19:24:21 +00:00
Add a method in ASTMutationListener for the last use of Decl's [is/set]ChangedSinceDeserialization
and remove them. llvm-svn: 144466
This commit is contained in:
parent
b97a4025ff
commit
0ca3a8b6ef
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user