[cfe-commits] r147420 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/Sema/SemaDeclObjC.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp
Douglas Gregor
dgregor at apple.com
Sun Jan 1 17:18:17 PST 2012
Author: dgregor
Date: Sun Jan 1 19:18:16 2012
New Revision: 147420
URL: http://llvm.org/viewvc/llvm-project?rev=147420&view=rev
Log:
Move ObjCProtocolDecl::EndLoc into its DefinitionData, and give
ObjCProtocolDecl proper source-range information.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=147420&r1=147419&r2=147420&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Jan 1 19:18:16 2012
@@ -1071,14 +1071,15 @@
// \brief The declaration that defines this protocol.
ObjCProtocolDecl *Definition;
- /// Referenced protocols
+ /// \brief Referenced protocols
ObjCProtocolList ReferencedProtocols;
+
+ /// \brief Marks the '>' or identifier.
+ SourceLocation EndLoc;
};
DefinitionData *Data;
- SourceLocation EndLoc; // marks the '>' or identifier.
-
DefinitionData &data() const {
assert(Data && "Objective-C protocol has no definition!");
return *Data;
@@ -1181,10 +1182,21 @@
/// \brief Starts the definition of this Objective-C protocol.
void startDefinition();
- // Location information, modeled after the Stmt API.
- SourceLocation getLocStart() const { return getAtStartLoc(); } // '@'protocol
- SourceLocation getLocEnd() const { return EndLoc; }
- void setLocEnd(SourceLocation LE) { EndLoc = LE; }
+ virtual SourceRange getSourceRange() const {
+ if (isThisDeclarationADefinition())
+ return ObjCContainerDecl::getSourceRange();
+
+ return SourceRange(getAtStartLoc(), getLocation());
+ }
+
+ SourceLocation getEndOfDefinitionLoc() const {
+ if (!hasDefinition())
+ return getLocation();
+
+ return data().EndLoc;
+ }
+
+ void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; }
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=147420&r1=147419&r2=147420&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Jan 1 19:18:16 2012
@@ -615,7 +615,7 @@
/// Check then save referenced protocols.
PDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,
ProtoLocs, Context);
- PDecl->setLocEnd(EndProtoLoc);
+ PDecl->setEndOfDefinitionLoc(EndProtoLoc);
}
CheckObjCDeclScope(PDecl);
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=147420&r1=147419&r2=147420&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sun Jan 1 19:18:16 2012
@@ -764,7 +764,6 @@
RedeclarableResult Redecl = VisitRedeclarable(PD);
VisitObjCContainerDecl(PD);
- PD->setLocEnd(ReadSourceLocation(Record, Idx));
// Determine whether we need to merge this declaration with another @protocol
// with the same name.
@@ -822,6 +821,8 @@
PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
Reader.getContext());
+ PD->setEndOfDefinitionLoc(ReadSourceLocation(Record, Idx));
+
// Note that we have deserialized a definition.
Reader.PendingDefinitions.insert(PD);
} else if (Def && Def->Data) {
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=147420&r1=147419&r2=147420&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sun Jan 1 19:18:16 2012
@@ -518,7 +518,6 @@
void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
VisitRedeclarable(D);
VisitObjCContainerDecl(D);
- Writer.AddSourceLocation(D->getLocEnd(), Record);
ObjCProtocolDecl *Def = D->getDefinition();
Writer.AddDeclRef(Def, Record);
@@ -532,6 +531,7 @@
PLEnd = D->protocol_loc_end();
PL != PLEnd; ++PL)
Writer.AddSourceLocation(*PL, Record);
+ Writer.AddSourceLocation(D->getEndOfDefinitionLoc(), Record);
}
Code = serialization::DECL_OBJC_PROTOCOL;
More information about the cfe-commits
mailing list