[cfe-commits] r110912 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp lib/Frontend/PCHReaderDecl.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp
Abramo Bagnara
abramo.bagnara at gmail.com
Thu Aug 12 04:46:04 PDT 2010
Author: abramo
Date: Thu Aug 12 06:46:03 2010
New Revision: 110912
URL: http://llvm.org/viewvc/llvm-project?rev=110912&view=rev
Log:
Added locations and type source info for DeclarationName inside UsingDecl.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=110912&r1=110911&r2=110912&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 12 06:46:03 2010
@@ -1999,6 +1999,10 @@
/// \brief Target nested name specifier.
NestedNameSpecifier* TargetNestedName;
+ /// DNLoc - Provides source/type location info for the
+ /// declaration name embedded in the ValueDecl base class.
+ DeclarationNameLoc DNLoc;
+
/// \brief The collection of shadow declarations associated with
/// this using declaration. This set can change as a class is
/// processed.
@@ -2007,34 +2011,31 @@
// \brief Has 'typename' keyword.
bool IsTypeName;
- UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR,
+ UsingDecl(DeclContext *DC, SourceRange NNR,
SourceLocation UL, NestedNameSpecifier* TargetNNS,
- DeclarationName Name, bool IsTypeNameArg)
- : NamedDecl(Using, DC, L, Name),
+ const DeclarationNameInfo &NameInfo, bool IsTypeNameArg)
+ : NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
NestedNameRange(NNR), UsingLocation(UL), TargetNestedName(TargetNNS),
- IsTypeName(IsTypeNameArg) {
+ DNLoc(NameInfo.getInfo()), IsTypeName(IsTypeNameArg) {
}
public:
- // FIXME: Should be const?
/// \brief Returns the source range that covers the nested-name-specifier
/// preceding the namespace name.
- SourceRange getNestedNameRange() { return NestedNameRange; }
+ SourceRange getNestedNameRange() const { return NestedNameRange; }
/// \brief Set the source range of the nested-name-specifier.
void setNestedNameRange(SourceRange R) { NestedNameRange = R; }
- // FIXME; Should be const?
// FIXME: Naming is inconsistent with other get*Loc functions.
/// \brief Returns the source location of the "using" keyword.
- SourceLocation getUsingLocation() { return UsingLocation; }
+ SourceLocation getUsingLocation() const { return UsingLocation; }
/// \brief Set the source location of the 'using' keyword.
void setUsingLocation(SourceLocation L) { UsingLocation = L; }
-
/// \brief Get the target nested name declaration.
- NestedNameSpecifier* getTargetNestedNameDecl() {
+ NestedNameSpecifier* getTargetNestedNameDecl() const {
return TargetNestedName;
}
@@ -2043,6 +2044,10 @@
TargetNestedName = NNS;
}
+ DeclarationNameInfo getNameInfo() const {
+ return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
+ }
+
/// \brief Return true if the using declaration has 'typename'.
bool isTypeName() const { return IsTypeName; }
@@ -2073,8 +2078,10 @@
}
static UsingDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation IdentL, SourceRange NNR, SourceLocation UsingL,
- NestedNameSpecifier* TargetNNS, DeclarationName Name, bool IsTypeNameArg);
+ SourceRange NNR, SourceLocation UsingL,
+ NestedNameSpecifier* TargetNNS,
+ const DeclarationNameInfo &NameInfo,
+ bool IsTypeNameArg);
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const UsingDecl *D) { return true; }
@@ -2102,14 +2109,18 @@
NestedNameSpecifier *TargetNestedNameSpecifier;
+ /// DNLoc - Provides source/type location info for the
+ /// declaration name embedded in the ValueDecl base class.
+ DeclarationNameLoc DNLoc;
+
UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty,
SourceLocation UsingLoc, SourceRange TargetNNR,
NestedNameSpecifier *TargetNNS,
- SourceLocation TargetNameLoc,
- DeclarationName TargetName)
- : ValueDecl(UnresolvedUsingValue, DC, TargetNameLoc, TargetName, Ty),
- TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc),
- TargetNestedNameSpecifier(TargetNNS)
+ const DeclarationNameInfo &NameInfo)
+ : ValueDecl(UnresolvedUsingValue, DC,
+ NameInfo.getLoc(), NameInfo.getName(), Ty),
+ TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc),
+ TargetNestedNameSpecifier(TargetNNS), DNLoc(NameInfo.getInfo())
{ }
public:
@@ -2122,7 +2133,7 @@
void setTargetNestedNameRange(SourceRange R) { TargetNestedNameRange = R; }
/// \brief Get target nested name declaration.
- NestedNameSpecifier* getTargetNestedNameSpecifier() {
+ NestedNameSpecifier* getTargetNestedNameSpecifier() const {
return TargetNestedNameSpecifier;
}
@@ -2137,10 +2148,14 @@
/// \brief Set the source location of the 'using' keyword.
void setUsingLoc(SourceLocation L) { UsingLocation = L; }
+ DeclarationNameInfo getNameInfo() const {
+ return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
+ }
+
static UnresolvedUsingValueDecl *
Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc,
SourceRange TargetNNR, NestedNameSpecifier *TargetNNS,
- SourceLocation TargetNameLoc, DeclarationName TargetName);
+ const DeclarationNameInfo &NameInfo);
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const UnresolvedUsingValueDecl *D) { return true; }
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=110912&r1=110911&r2=110912&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Aug 12 06:46:03 2010
@@ -1010,10 +1010,11 @@
}
UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, SourceRange NNR, SourceLocation UL,
- NestedNameSpecifier* TargetNNS, DeclarationName Name,
- bool IsTypeNameArg) {
- return new (C) UsingDecl(DC, L, NNR, UL, TargetNNS, Name, IsTypeNameArg);
+ SourceRange NNR, SourceLocation UL,
+ NestedNameSpecifier* TargetNNS,
+ const DeclarationNameInfo &NameInfo,
+ bool IsTypeNameArg) {
+ return new (C) UsingDecl(DC, NNR, UL, TargetNNS, NameInfo, IsTypeNameArg);
}
UnresolvedUsingValueDecl *
@@ -1021,11 +1022,9 @@
SourceLocation UsingLoc,
SourceRange TargetNNR,
NestedNameSpecifier *TargetNNS,
- SourceLocation TargetNameLoc,
- DeclarationName TargetName) {
+ const DeclarationNameInfo &NameInfo) {
return new (C) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc,
- TargetNNR, TargetNNS,
- TargetNameLoc, TargetName);
+ TargetNNR, TargetNNS, NameInfo);
}
UnresolvedUsingTypenameDecl *
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=110912&r1=110911&r2=110912&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Thu Aug 12 06:46:03 2010
@@ -626,6 +626,7 @@
D->setUsingLocation(Reader.ReadSourceLocation(Record, Idx));
D->setNestedNameRange(Reader.ReadSourceRange(Record, Idx));
D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx));
+ // FIXME: read the DNLoc component.
// FIXME: It would probably be more efficient to read these into a vector
// and then re-cosntruct the shadow decl set over that vector since it
@@ -668,6 +669,7 @@
D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx));
D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx));
D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx));
+ // FIXME: read the DNLoc component.
}
void PCHDeclReader::VisitUnresolvedUsingTypenameDecl(
@@ -1378,8 +1380,8 @@
SourceLocation(), 0);
break;
case pch::DECL_USING:
- D = UsingDecl::Create(*Context, 0, SourceLocation(), SourceRange(),
- SourceLocation(), 0, DeclarationName(), false);
+ D = UsingDecl::Create(*Context, 0, SourceRange(), SourceLocation(),
+ 0, DeclarationNameInfo(), false);
break;
case pch::DECL_USING_SHADOW:
D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0);
@@ -1391,8 +1393,8 @@
break;
case pch::DECL_UNRESOLVED_USING_VALUE:
D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(),
- SourceRange(), 0, SourceLocation(),
- DeclarationName());
+ SourceRange(), 0,
+ DeclarationNameInfo());
break;
case pch::DECL_UNRESOLVED_USING_TYPENAME:
D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(),
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=110912&r1=110911&r2=110912&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Aug 12 06:46:03 2010
@@ -2248,8 +2248,7 @@
NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
SourceLocation UsingLoc,
CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- DeclarationName Name,
+ const DeclarationNameInfo &NameInfo,
AttributeList *AttrList,
bool IsInstantiation,
bool IsTypeName,
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=110912&r1=110911&r2=110912&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Aug 12 06:46:03 2010
@@ -3476,8 +3476,9 @@
<< SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc);
return DeclPtrTy();
}
-
- DeclarationName TargetName = GetNameFromUnqualifiedId(Name).getName();
+
+ DeclarationNameInfo TargetNameInfo = GetNameFromUnqualifiedId(Name);
+ DeclarationName TargetName = TargetNameInfo.getName();
if (!TargetName)
return DeclPtrTy();
@@ -3493,8 +3494,7 @@
}
NamedDecl *UD = BuildUsingDeclaration(S, AS, UsingLoc, SS,
- Name.getSourceRange().getBegin(),
- TargetName, AttrList,
+ TargetNameInfo, AttrList,
/* IsInstantiation */ false,
IsTypeName, TypenameLoc);
if (UD)
@@ -3743,13 +3743,13 @@
NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
SourceLocation UsingLoc,
CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- DeclarationName Name,
+ const DeclarationNameInfo &NameInfo,
AttributeList *AttrList,
bool IsInstantiation,
bool IsTypeName,
SourceLocation TypenameLoc) {
assert(!SS.isInvalid() && "Invalid CXXScopeSpec.");
+ SourceLocation IdentLoc = NameInfo.getLoc();
assert(IdentLoc.isValid() && "Invalid TargetName location.");
// FIXME: We ignore attributes for now.
@@ -3761,7 +3761,7 @@
}
// Do the redeclaration lookup in the current scope.
- LookupResult Previous(*this, Name, IdentLoc, LookupUsingDeclName,
+ LookupResult Previous(*this, NameInfo, LookupUsingDeclName,
ForRedeclaration);
Previous.setHideTags(false);
if (S) {
@@ -3800,15 +3800,15 @@
D = UnresolvedUsingTypenameDecl::Create(Context, CurContext,
UsingLoc, TypenameLoc,
SS.getRange(), NNS,
- IdentLoc, Name);
+ IdentLoc, NameInfo.getName());
} else {
D = UnresolvedUsingValueDecl::Create(Context, CurContext,
- UsingLoc, SS.getRange(), NNS,
- IdentLoc, Name);
+ UsingLoc, SS.getRange(),
+ NNS, NameInfo);
}
} else {
- D = UsingDecl::Create(Context, CurContext, IdentLoc,
- SS.getRange(), UsingLoc, NNS, Name,
+ D = UsingDecl::Create(Context, CurContext,
+ SS.getRange(), UsingLoc, NNS, NameInfo,
IsTypeName);
}
D->setAccess(AS);
@@ -3824,7 +3824,7 @@
// Look up the target name.
- LookupResult R(*this, Name, IdentLoc, LookupOrdinaryName);
+ LookupResult R(*this, NameInfo, LookupOrdinaryName);
// Unlike most lookups, we don't always want to hide tag
// declarations: tag names are visible through the using declaration
@@ -3837,7 +3837,7 @@
if (R.empty()) {
Diag(IdentLoc, diag::err_no_member)
- << Name << LookupContext << SS.getRange();
+ << NameInfo.getName() << LookupContext << SS.getRange();
UD->setInvalidDecl();
return UD;
}
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=110912&r1=110911&r2=110912&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Aug 12 06:46:03 2010
@@ -1544,22 +1544,22 @@
Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
// The nested name specifier is non-dependent, so no transformation
- // is required.
+ // is required. The same holds for the name info.
+ DeclarationNameInfo NameInfo = D->getNameInfo();
// We only need to do redeclaration lookups if we're in a class
// scope (in fact, it's not really even possible in non-class
// scopes).
bool CheckRedeclaration = Owner->isRecord();
- LookupResult Prev(SemaRef, D->getDeclName(), D->getLocation(),
- Sema::LookupUsingDeclName, Sema::ForRedeclaration);
+ LookupResult Prev(SemaRef, NameInfo, Sema::LookupUsingDeclName,
+ Sema::ForRedeclaration);
UsingDecl *NewUD = UsingDecl::Create(SemaRef.Context, Owner,
- D->getLocation(),
D->getNestedNameRange(),
D->getUsingLocation(),
D->getTargetNestedNameDecl(),
- D->getDeclName(),
+ NameInfo,
D->isTypeName());
CXXScopeSpec SS;
@@ -1635,10 +1635,12 @@
SS.setRange(D->getTargetNestedNameRange());
SS.setScopeRep(NNS);
+ // Since NameInfo refers to a typename, it cannot be a C++ special name.
+ // Hence, no tranformation is required for it.
+ DeclarationNameInfo NameInfo(D->getDeclName(), D->getLocation());
NamedDecl *UD =
SemaRef.BuildUsingDeclaration(/*Scope*/ 0, D->getAccess(),
- D->getUsingLoc(), SS, D->getLocation(),
- D->getDeclName(), 0,
+ D->getUsingLoc(), SS, NameInfo, 0,
/*instantiation*/ true,
/*typename*/ true, D->getTypenameLoc());
if (UD)
@@ -1660,10 +1662,12 @@
SS.setRange(D->getTargetNestedNameRange());
SS.setScopeRep(NNS);
+ DeclarationNameInfo NameInfo
+ = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
+
NamedDecl *UD =
SemaRef.BuildUsingDeclaration(/*Scope*/ 0, D->getAccess(),
- D->getUsingLoc(), SS, D->getLocation(),
- D->getDeclName(), 0,
+ D->getUsingLoc(), SS, NameInfo, 0,
/*instantiation*/ true,
/*typename*/ false, SourceLocation());
if (UD)
More information about the cfe-commits
mailing list