[cfe-commits] r126943 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp lib/Sema/SemaDeclCXX.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/Index/recursive-cxx-member-calls.cpp
Abramo Bagnara
abramo.bagnara at gmail.com
Thu Mar 3 06:52:38 PST 2011
Author: abramo
Date: Thu Mar 3 08:52:38 2011
New Revision: 126943
URL: http://llvm.org/viewvc/llvm-project?rev=126943&view=rev
Log:
Fixed end source location for LinkageSpecDecl.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Index/recursive-cxx-member-calls.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=126943&r1=126942&r2=126943&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Mar 3 08:52:38 2011
@@ -1711,18 +1711,21 @@
/// Language - The language for this linkage specification.
LanguageIDs Language;
- /// HadBraces - Whether this linkage specification had curly braces or not.
- bool HadBraces : 1;
+ /// LBraceLoc - The source location for the left brace (if valid).
+ SourceLocation LBraceLoc;
+ /// RBraceLoc - The source location for the right brace (if valid).
+ SourceLocation RBraceLoc;
LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang,
- bool Braces)
- : Decl(LinkageSpec, DC, L),
- DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { }
+ SourceLocation LBLoc, SourceLocation RBLoc)
+ : Decl(LinkageSpec, DC, L), DeclContext(LinkageSpec),
+ Language(lang), LBraceLoc(LBLoc), RBraceLoc(RBLoc) { }
public:
static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, LanguageIDs Lang,
- bool Braces);
+ SourceLocation LBraceLoc,
+ SourceLocation RBraceLoc = SourceLocation());
/// \brief Return the language specified by this linkage specification.
LanguageIDs getLanguage() const { return Language; }
@@ -1732,11 +1735,23 @@
/// \brief Determines whether this linkage specification had braces in
/// its syntactic form.
- bool hasBraces() const { return HadBraces; }
+ bool hasBraces() const { return RBraceLoc.isValid(); }
+ SourceLocation getLBraceLoc() const { return LBraceLoc; }
+ SourceLocation getRBraceLoc() const { return RBraceLoc; }
+ void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
+ void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
+
+ SourceLocation getLocEnd() const {
+ if (hasBraces())
+ return getRBraceLoc();
+ // No braces: get the end location of the (only) declaration in context
+ // (if present).
+ return decls_empty() ? getLocation() : decls_begin()->getLocEnd();
+ }
- /// \brief Set whether this linkage specification has braces in its
- /// syntactic form.
- void setHasBraces(bool B) { HadBraces = B; }
+ SourceRange getSourceRange() const {
+ return SourceRange(getLocation(), getLocEnd());
+ }
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const LinkageSpecDecl *D) { return true; }
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=126943&r1=126942&r2=126943&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Mar 3 08:52:38 2011
@@ -1270,8 +1270,10 @@
LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
DeclContext *DC,
SourceLocation L,
- LanguageIDs Lang, bool Braces) {
- return new (C) LinkageSpecDecl(DC, L, Lang, Braces);
+ LanguageIDs Lang,
+ SourceLocation LBraceLoc,
+ SourceLocation RBraceLoc) {
+ return new (C) LinkageSpecDecl(DC, L, Lang, LBraceLoc, RBraceLoc);
}
UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC,
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=126943&r1=126942&r2=126943&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Mar 3 08:52:38 2011
@@ -6576,7 +6576,7 @@
LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
LangLoc, Language,
- LBraceLoc.isValid());
+ LBraceLoc);
CurContext->addDecl(D);
PushDeclContext(S, D);
return D;
@@ -6587,10 +6587,15 @@
/// valid, it's the position of the closing '}' brace in a linkage
/// specification that uses braces.
Decl *Sema::ActOnFinishLinkageSpecification(Scope *S,
- Decl *LinkageSpec,
- SourceLocation RBraceLoc) {
- if (LinkageSpec)
+ Decl *LinkageSpec,
+ SourceLocation RBraceLoc) {
+ if (LinkageSpec) {
+ if (RBraceLoc.isValid()) {
+ LinkageSpecDecl* LSDecl = cast<LinkageSpecDecl>(LinkageSpec);
+ LSDecl->setRBraceLoc(RBraceLoc);
+ }
PopDeclContext();
+ }
return LinkageSpec;
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=126943&r1=126942&r2=126943&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Mar 3 08:52:38 2011
@@ -721,7 +721,8 @@
void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
VisitDecl(D);
D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]);
- D->setHasBraces(Record[Idx++]);
+ D->setLBraceLoc(ReadSourceLocation(Record, Idx));
+ D->setRBraceLoc(ReadSourceLocation(Record, Idx));
}
void ASTDeclReader::VisitLabelDecl(LabelDecl *D) {
@@ -1418,7 +1419,7 @@
case DECL_LINKAGE_SPEC:
D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(),
(LinkageSpecDecl::LanguageIDs)0,
- false);
+ SourceLocation(), SourceLocation());
break;
case DECL_LABEL:
D = LabelDecl::Create(*Context, 0, SourceLocation(), 0);
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=126943&r1=126942&r2=126943&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Mar 3 08:52:38 2011
@@ -646,10 +646,9 @@
void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
VisitDecl(D);
- // FIXME: It might be nice to serialize the brace locations for this
- // declaration, which don't seem to be readily available in the AST.
Record.push_back(D->getLanguage());
- Record.push_back(D->hasBraces());
+ Writer.AddSourceLocation(D->getLBraceLoc(), Record);
+ Writer.AddSourceLocation(D->getRBraceLoc(), Record);
Code = serialization::DECL_LINKAGE_SPEC;
}
Modified: cfe/trunk/test/Index/recursive-cxx-member-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/recursive-cxx-member-calls.cpp?rev=126943&r1=126942&r2=126943&view=diff
==============================================================================
--- cfe/trunk/test/Index/recursive-cxx-member-calls.cpp (original)
+++ cfe/trunk/test/Index/recursive-cxx-member-calls.cpp Thu Mar 3 08:52:38 2011
@@ -1532,7 +1532,7 @@
// CHECK: 4:20: TemplateTypeParameter=_T1:4:20 (Definition) Extent=[4:20 - 4:23]
// CHECK: 4:31: TemplateTypeParameter=_T2:4:31 (Definition) Extent=[4:31 - 4:34]
// CHECK: 4:55: FieldDecl=second:4:55 (Definition) Extent=[4:55 - 4:61]
-// CHECK: 6:8: UnexposedDecl=:6:8 (Definition) Extent=[6:8 - 6:11]
+// CHECK: 6:8: UnexposedDecl=:6:8 (Definition) Extent=[6:8 - 9:2]
// CHECK: 7:7: FunctionDecl=memcmp:7:7 Extent=[7:7 - 7:49]
// CHECK: 7:26: ParmDecl=:7:26 (Definition) Extent=[7:20 - 7:27]
// CHECK: 7:40: ParmDecl=:7:40 (Definition) Extent=[7:34 - 7:41]
More information about the cfe-commits
mailing list