Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema interfaces.
DeclaratorDecl contains a DeclaratorInfo* to keep type source info.
Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl.
EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo.
Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79392 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 9230531..7383636 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -420,8 +420,9 @@
DeclarationName Entity);
QualType BuildBlockPointerType(QualType T, unsigned Quals,
SourceLocation Loc, DeclarationName Entity);
- QualType GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip = 0,
- TagDecl **OwnedDecl = 0);
+ QualType GetTypeForDeclarator(Declarator &D, Scope *S,
+ DeclaratorInfo **DInfo = 0,
+ unsigned Skip = 0, TagDecl **OwnedDecl = 0);
DeclarationName GetNameForDeclarator(Declarator &D);
bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range);
bool CheckDistantExceptionSpec(QualType T);
@@ -473,16 +474,18 @@
Scope *S);
void DiagnoseFunctionSpecifiers(Declarator& D);
NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, Decl* PrevDecl,
- bool &Redeclaration);
+ QualType R, DeclaratorInfo *DInfo,
+ Decl* PrevDecl, bool &Redeclaration);
NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, NamedDecl* PrevDecl,
+ QualType R, DeclaratorInfo *DInfo,
+ NamedDecl* PrevDecl,
MultiTemplateParamsArg TemplateParamLists,
bool &Redeclaration);
void CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
bool &Redeclaration);
NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, NamedDecl* PrevDecl,
+ QualType R, DeclaratorInfo *DInfo,
+ NamedDecl* PrevDecl,
MultiTemplateParamsArg TemplateParamLists,
bool IsFunctionDefinition,
bool &Redeclaration);
@@ -571,7 +574,8 @@
Declarator &D, Expr *BitfieldWidth,
AccessSpecifier AS);
- FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
+ FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
+ DeclaratorInfo *DInfo,
RecordDecl *Record, SourceLocation Loc,
bool Mutable, Expr *BitfieldWidth,
SourceLocation TSSL,
@@ -1402,6 +1406,7 @@
StmtArg SynchBody);
VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
+ DeclaratorInfo *DInfo,
IdentifierInfo *Name,
SourceLocation Loc,
SourceRange Range);
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 2d36059..1f2689c 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -480,7 +480,7 @@
FunctionDecl *New = FunctionDecl::Create(Context,
Context.getTranslationUnitDecl(),
- Loc, II, R,
+ Loc, II, R, /*DInfo=*/0,
FunctionDecl::Extern, false,
/*hasPrototype=*/true);
New->setImplicit();
@@ -491,7 +491,8 @@
llvm::SmallVector<ParmVarDecl*, 16> Params;
for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i)
Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0,
- FT->getArgType(i), VarDecl::None, 0));
+ FT->getArgType(i), /*DInfo=*/0,
+ VarDecl::None, 0));
New->setParams(Context, Params.data(), Params.size());
}
@@ -790,8 +791,8 @@
ParamType != ParamEnd; ++ParamType) {
ParmVarDecl *Param = ParmVarDecl::Create(Context, New,
SourceLocation(), 0,
- *ParamType, VarDecl::None,
- 0);
+ *ParamType, /*DInfo=*/0,
+ VarDecl::None, 0);
Param->setImplicit();
Params.push_back(Param);
}
@@ -1492,7 +1493,7 @@
if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
Anon = FieldDecl::Create(Context, OwningClass, Record->getLocation(),
/*IdentifierInfo=*/0,
- Context.getTypeDeclType(Record),
+ Context.getTypeDeclType(Record), /*DInfo=*/0,
/*BitWidth=*/0, /*Mutable=*/false,
DS.getSourceRange().getBegin());
Anon->setAccess(AS_public);
@@ -1519,7 +1520,7 @@
Anon = VarDecl::Create(Context, Owner, Record->getLocation(),
/*IdentifierInfo=*/0,
- Context.getTypeDeclType(Record),
+ Context.getTypeDeclType(Record), /*DInfo=*/0,
SC, DS.getSourceRange().getBegin());
}
Anon->setImplicit();
@@ -1664,7 +1665,8 @@
NamedDecl *PrevDecl;
NamedDecl *New;
- QualType R = GetTypeForDeclarator(D, S);
+ DeclaratorInfo *DInfo = 0;
+ QualType R = GetTypeForDeclarator(D, S, &DInfo);
// See if this is a redefinition of a variable in the same scope.
if (D.getCXXScopeSpec().isInvalid()) {
@@ -1764,13 +1766,13 @@
return DeclPtrTy();
}
- New = ActOnTypedefDeclarator(S, D, DC, R, PrevDecl, Redeclaration);
+ New = ActOnTypedefDeclarator(S, D, DC, R, DInfo, PrevDecl, Redeclaration);
} else if (R->isFunctionType()) {
- New = ActOnFunctionDeclarator(S, D, DC, R, PrevDecl,
+ New = ActOnFunctionDeclarator(S, D, DC, R, DInfo, PrevDecl,
move(TemplateParamLists),
IsFunctionDefinition, Redeclaration);
} else {
- New = ActOnVariableDeclarator(S, D, DC, R, PrevDecl,
+ New = ActOnVariableDeclarator(S, D, DC, R, DInfo, PrevDecl,
move(TemplateParamLists),
Redeclaration);
}
@@ -1886,7 +1888,8 @@
NamedDecl*
Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, Decl* PrevDecl, bool &Redeclaration) {
+ QualType R, DeclaratorInfo *DInfo,
+ Decl* PrevDecl, bool &Redeclaration) {
// Typedef declarators cannot be qualified (C++ [dcl.meaning]p1).
if (D.getCXXScopeSpec().isSet()) {
Diag(D.getIdentifierLoc(), diag::err_qualified_typedef_declarator)
@@ -2028,7 +2031,8 @@
NamedDecl*
Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R,NamedDecl* PrevDecl,
+ QualType R, DeclaratorInfo *DInfo,
+ NamedDecl* PrevDecl,
MultiTemplateParamsArg TemplateParamLists,
bool &Redeclaration) {
DeclarationName Name = GetNameForDeclarator(D);
@@ -2130,7 +2134,7 @@
}
NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
- II, R, SC,
+ II, R, DInfo, SC,
// FIXME: Move to DeclGroup...
D.getDeclSpec().getSourceRange().getBegin());
@@ -2323,7 +2327,8 @@
NamedDecl*
Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, NamedDecl* PrevDecl,
+ QualType R, DeclaratorInfo *DInfo,
+ NamedDecl* PrevDecl,
MultiTemplateParamsArg TemplateParamLists,
bool IsFunctionDefinition, bool &Redeclaration) {
assert(R.getTypePtr()->isFunctionType());
@@ -2401,7 +2406,7 @@
isInline |= IsFunctionDefinition;
NewFD = FriendFunctionDecl::Create(Context, DC,
- D.getIdentifierLoc(), Name, R,
+ D.getIdentifierLoc(), Name, R, DInfo,
isInline,
D.getDeclSpec().getFriendSpecLoc());
@@ -2415,7 +2420,7 @@
// Create the new declaration
NewFD = CXXConstructorDecl::Create(Context,
cast<CXXRecordDecl>(DC),
- D.getIdentifierLoc(), Name, R,
+ D.getIdentifierLoc(), Name, R, DInfo,
isExplicit, isInline,
/*isImplicitlyDeclared=*/false);
} else if (D.getKind() == Declarator::DK_Destructor) {
@@ -2436,7 +2441,7 @@
// Create a FunctionDecl to satisfy the function definition parsing
// code path.
NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(),
- Name, R, SC, isInline,
+ Name, R, DInfo, SC, isInline,
/*hasPrototype=*/true,
// FIXME: Move to DeclGroup...
D.getDeclSpec().getSourceRange().getBegin());
@@ -2451,7 +2456,7 @@
CheckConversionDeclarator(D, R, SC);
NewFD = CXXConversionDecl::Create(Context, cast<CXXRecordDecl>(DC),
- D.getIdentifierLoc(), Name, R,
+ D.getIdentifierLoc(), Name, R, DInfo,
isInline, isExplicit);
isVirtualOkay = true;
@@ -2470,7 +2475,7 @@
// This is a C++ method declaration.
NewFD = CXXMethodDecl::Create(Context, cast<CXXRecordDecl>(DC),
- D.getIdentifierLoc(), Name, R,
+ D.getIdentifierLoc(), Name, R, DInfo,
(SC == FunctionDecl::Static), isInline);
isVirtualOkay = (SC != FunctionDecl::Static);
@@ -2488,7 +2493,7 @@
NewFD = FunctionDecl::Create(Context, DC,
D.getIdentifierLoc(),
- Name, R, SC, isInline, HasPrototype,
+ Name, R, DInfo, SC, isInline, HasPrototype,
// FIXME: Move to DeclGroup...
D.getDeclSpec().getSourceRange().getBegin());
}
@@ -2640,7 +2645,8 @@
AE = FT->arg_type_end(); AI != AE; ++AI) {
ParmVarDecl *Param = ParmVarDecl::Create(Context, DC,
SourceLocation(), 0,
- *AI, VarDecl::None, 0);
+ *AI, /*DInfo=*/0,
+ VarDecl::None, 0);
Param->setImplicit();
Params.push_back(Param);
}
@@ -3380,8 +3386,10 @@
if (getLangOptions().CPlusPlus)
CheckExtraCXXDefaultArguments(D);
+ DeclaratorInfo *DInfo = 0;
TagDecl *OwnedDecl = 0;
- QualType parmDeclType = GetTypeForDeclarator(D, S, /*Skip=*/0, &OwnedDecl);
+ QualType parmDeclType = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0,
+ &OwnedDecl);
if (getLangOptions().CPlusPlus && OwnedDecl && OwnedDecl->isDefinition()) {
// C++ [dcl.fct]p6:
@@ -3426,11 +3434,11 @@
if (T == parmDeclType) // parameter type did not need adjustment
New = ParmVarDecl::Create(Context, CurContext,
D.getIdentifierLoc(), II,
- parmDeclType, StorageClass,
+ parmDeclType, DInfo, StorageClass,
0);
else // keep track of both the adjusted and unadjusted types
New = OriginalParmVarDecl::Create(Context, CurContext,
- D.getIdentifierLoc(), II, T,
+ D.getIdentifierLoc(), II, T, DInfo,
parmDeclType, StorageClass, 0);
if (D.isInvalidType())
@@ -4421,7 +4429,8 @@
SourceLocation Loc = DeclStart;
if (II) Loc = D.getIdentifierLoc();
- QualType T = GetTypeForDeclarator(D, S);
+ DeclaratorInfo *DInfo = 0;
+ QualType T = GetTypeForDeclarator(D, S, &DInfo);
if (getLangOptions().CPlusPlus)
CheckExtraCXXDefaultArguments(D);
@@ -4446,7 +4455,7 @@
= (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_mutable);
SourceLocation TSSL = D.getSourceRange().getBegin();
FieldDecl *NewFD
- = CheckFieldDecl(II, T, Record, Loc, Mutable, BitWidth, TSSL,
+ = CheckFieldDecl(II, T, DInfo, Record, Loc, Mutable, BitWidth, TSSL,
AS, PrevDecl, &D);
if (NewFD->isInvalidDecl() && PrevDecl) {
// Don't introduce NewFD into scope; there's already something
@@ -4469,7 +4478,8 @@
/// \returns a new FieldDecl.
///
/// \todo The Declarator argument is a hack. It will be removed once
-FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
+FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
+ DeclaratorInfo *DInfo,
RecordDecl *Record, SourceLocation Loc,
bool Mutable, Expr *BitWidth,
SourceLocation TSSL,
@@ -4518,8 +4528,8 @@
ZeroWidth = false;
}
- FieldDecl *NewFD = FieldDecl::Create(Context, Record, Loc, II, T, BitWidth,
- Mutable, TSSL);
+ FieldDecl *NewFD = FieldDecl::Create(Context, Record, Loc, II, T, DInfo,
+ BitWidth, Mutable, TSSL);
if (InvalidDecl)
NewFD->setInvalidDecl();
@@ -4763,7 +4773,8 @@
// FIXME: Unnamed fields can be handled in various different ways, for
// example, unnamed unions inject all members into the struct namespace!
- QualType T = GetTypeForDeclarator(D, S);
+ DeclaratorInfo *DInfo = 0;
+ QualType T = GetTypeForDeclarator(D, S, &DInfo);
if (BitWidth) {
// 6.7.2.1p3, 6.7.2.1p4
@@ -4805,8 +4816,8 @@
// Construct the decl.
ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context,
- EnclosingContext, Loc, II, T,ac,
- (Expr *)BitfieldWidth);
+ EnclosingContext, Loc, II, T,
+ DInfo, ac, (Expr *)BitfieldWidth);
if (II) {
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 76b99bb..a840e6f 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1863,11 +1863,12 @@
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
NewD = FunctionDecl::Create(FD->getASTContext(), FD->getDeclContext(),
FD->getLocation(), DeclarationName(II),
- FD->getType());
+ FD->getType(), FD->getDeclaratorInfo());
} else if (VarDecl *VD = dyn_cast<VarDecl>(ND)) {
NewD = VarDecl::Create(VD->getASTContext(), VD->getDeclContext(),
VD->getLocation(), II,
- VD->getType(), VD->getStorageClass());
+ VD->getType(), VD->getDeclaratorInfo(),
+ VD->getStorageClass());
}
return NewD;
}
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 2de3484..9c4c2ab 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1296,6 +1296,7 @@
ClassDecl->getLocation(), Name,
Context.getFunctionType(Context.VoidTy,
0, 0, false, 0),
+ /*DInfo=*/0,
/*isExplicit=*/false,
/*isInline=*/true,
/*isImplicitlyDeclared=*/true);
@@ -1367,6 +1368,7 @@
Context.getFunctionType(Context.VoidTy,
&ArgType, 1,
false, 0),
+ /*DInfo=*/0,
/*isExplicit=*/false,
/*isInline=*/true,
/*isImplicitlyDeclared=*/true);
@@ -1378,7 +1380,8 @@
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor,
ClassDecl->getLocation(),
/*IdentifierInfo=*/0,
- ArgType, VarDecl::None, 0);
+ ArgType, /*DInfo=*/0,
+ VarDecl::None, 0);
CopyConstructor->setParams(Context, &FromParam, 1);
ClassDecl->addDecl(CopyConstructor);
}
@@ -1449,7 +1452,7 @@
CXXMethodDecl::Create(Context, ClassDecl, ClassDecl->getLocation(), Name,
Context.getFunctionType(RetType, &ArgType, 1,
false, 0),
- /*isStatic=*/false, /*isInline=*/true);
+ /*DInfo=*/0, /*isStatic=*/false, /*isInline=*/true);
CopyAssignment->setAccess(AS_public);
CopyAssignment->setImplicit();
CopyAssignment->setTrivial(ClassDecl->hasTrivialCopyAssignment());
@@ -1459,7 +1462,8 @@
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment,
ClassDecl->getLocation(),
/*IdentifierInfo=*/0,
- ArgType, VarDecl::None, 0);
+ ArgType, /*DInfo=*/0,
+ VarDecl::None, 0);
CopyAssignment->setParams(Context, &FromParam, 1);
// Don't call addedAssignmentOperator. There is no way to distinguish an
@@ -3217,6 +3221,7 @@
/// occurs within a C++ catch clause, returning the newly-created
/// variable.
VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
+ DeclaratorInfo *DInfo,
IdentifierInfo *Name,
SourceLocation Loc,
SourceRange Range) {
@@ -3266,7 +3271,7 @@
// FIXME: Need to check for abstract classes.
VarDecl *ExDecl = VarDecl::Create(Context, CurContext, Loc,
- Name, ExDeclType, VarDecl::None,
+ Name, ExDeclType, DInfo, VarDecl::None,
Range.getBegin());
if (Invalid)
@@ -3278,7 +3283,8 @@
/// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
/// handler.
Sema::DeclPtrTy Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
- QualType ExDeclType = GetTypeForDeclarator(D, S);
+ DeclaratorInfo *DInfo = 0;
+ QualType ExDeclType = GetTypeForDeclarator(D, S, &DInfo);
bool Invalid = D.isInvalidType();
IdentifierInfo *II = D.getIdentifier();
@@ -3298,7 +3304,7 @@
Invalid = true;
}
- VarDecl *ExDecl = BuildExceptionDeclaration(S, ExDeclType,
+ VarDecl *ExDecl = BuildExceptionDeclaration(S, ExDeclType, DInfo,
D.getIdentifier(),
D.getIdentifierLoc(),
D.getDeclSpec().getSourceRange());
@@ -3456,7 +3462,8 @@
assert(D);
SourceLocation Loc = D->getIdentifierLoc();
- QualType T = GetTypeForDeclarator(*D, S);
+ DeclaratorInfo *DInfo = 0;
+ QualType T = GetTypeForDeclarator(*D, S, &DInfo);
// C++ [class.friend]p1
// A friend of a class is a function or class....
@@ -3583,7 +3590,7 @@
}
}
- NamedDecl *ND = ActOnFunctionDeclarator(S, *D, DC, T,
+ NamedDecl *ND = ActOnFunctionDeclarator(S, *D, DC, T, DInfo,
/* PrevDecl = */ FD,
MultiTemplateParamsArg(*this),
IsDefinition,
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 7f7bcd2..8a19b64 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1431,6 +1431,7 @@
property->getLocation(),
property->getIdentifier(),
property->getType(),
+ /*DInfo=*/0,
VarDecl::None,
0);
SetterMethod->setMethodParams(Context, &Argument, 1);
@@ -1705,11 +1706,13 @@
if (ArgType == UnpromotedArgType)
Param = ParmVarDecl::Create(Context, ObjCMethod, ArgInfo[i].NameLoc,
ArgInfo[i].Name, ArgType,
+ /*DInfo=*/0, //FIXME: Pass info here.
VarDecl::None, 0);
else
Param = OriginalParmVarDecl::Create(Context, ObjCMethod,
ArgInfo[i].NameLoc,
ArgInfo[i].Name, ArgType,
+ /*DInfo=*/0, //FIXME: Pass info here.
UnpromotedArgType,
VarDecl::None, 0);
@@ -2079,7 +2082,7 @@
assert(EnclosingContext &&
"null DeclContext for synthesized ivar - ActOnPropertyImplDecl");
Ivar = ObjCIvarDecl::Create(Context, EnclosingContext, PropertyLoc,
- PropertyIvar, PropType,
+ PropertyIvar, PropType, /*Dinfo=*/0,
ObjCIvarDecl::Public,
(Expr *)0);
Ivar->setLexicalDeclContext(IDecl);
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 0a5a2a6..2705d99 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -302,7 +302,9 @@
Skip = 1;
}
- QualType AllocType = GetTypeForDeclarator(D, /*Scope=*/0, Skip);
+ //FIXME: Store DeclaratorInfo in CXXNew expression.
+ DeclaratorInfo *DInfo = 0;
+ QualType AllocType = GetTypeForDeclarator(D, /*Scope=*/0, &DInfo, Skip);
if (D.isInvalidType())
return ExprError();
@@ -668,11 +670,12 @@
QualType FnType = Context.getFunctionType(Return, &Argument, 1, false, 0);
FunctionDecl *Alloc =
FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name,
- FnType, FunctionDecl::None, false, true,
+ FnType, /*DInfo=*/0, FunctionDecl::None, false, true,
SourceLocation());
Alloc->setImplicit();
ParmVarDecl *Param = ParmVarDecl::Create(Context, Alloc, SourceLocation(),
- 0, Argument, VarDecl::None, 0);
+ 0, Argument, /*DInfo=*/0,
+ VarDecl::None, 0);
Alloc->setParams(Context, &Param, 1);
// FIXME: Also add this declaration to the IdentifierResolver, but
@@ -778,8 +781,10 @@
assert(D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef &&
"Parser allowed 'typedef' as storage class of condition decl.");
+ // FIXME: Store DeclaratorInfo in the expression.
+ DeclaratorInfo *DInfo = 0;
TagDecl *OwnedTag = 0;
- QualType Ty = GetTypeForDeclarator(D, S, /*Skip=*/0, &OwnedTag);
+ QualType Ty = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0, &OwnedTag);
if (Ty->isFunctionType()) { // The declarator shall not specify a function...
// We exit without creating a CXXConditionDeclExpr because a FunctionDecl
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 2e36731..c9281c9 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -289,7 +289,8 @@
Sema::DeclPtrTy Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
unsigned Depth,
unsigned Position) {
- QualType T = GetTypeForDeclarator(D, S);
+ DeclaratorInfo *DInfo = 0;
+ QualType T = GetTypeForDeclarator(D, S, &DInfo);
assert(S->isTemplateParamScope() &&
"Non-type template parameter not in template parameter scope!");
@@ -311,7 +312,7 @@
NonTypeTemplateParmDecl *Param
= NonTypeTemplateParmDecl::Create(Context, CurContext, D.getIdentifierLoc(),
- Depth, Position, ParamName, T);
+ Depth, Position, ParamName, T, DInfo);
if (Invalid)
Param->setInvalidDecl();
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index b216ec1..30d7b6a 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -119,8 +119,8 @@
// Build the instantiated declaration
VarDecl *Var = VarDecl::Create(SemaRef.Context, Owner,
D->getLocation(), D->getIdentifier(),
- T, D->getStorageClass(),
- D->getTypeSpecStartLoc());
+ T, D->getDeclaratorInfo(),
+ D->getStorageClass(),D->getTypeSpecStartLoc());
Var->setThreadSpecified(D->isThreadSpecified());
Var->setCXXDirectInitializer(D->hasCXXDirectInitializer());
Var->setDeclaredInCondition(D->isDeclaredInCondition());
@@ -199,6 +199,7 @@
}
FieldDecl *Field = SemaRef.CheckFieldDecl(D->getDeclName(), T,
+ D->getDeclaratorInfo(),
cast<RecordDecl>(Owner),
D->getLocation(),
D->isMutable(),
@@ -380,13 +381,14 @@
Function =
FriendFunctionDecl::Create(SemaRef.Context, DC, D->getLocation(),
- D->getDeclName(), T, D->isInline(),
- FFD->getFriendLoc());
+ D->getDeclName(), T, D->getDeclaratorInfo(),
+ D->isInline(), FFD->getFriendLoc());
Function->setLexicalDeclContext(Owner);
} else {
Function =
FunctionDecl::Create(SemaRef.Context, Owner, D->getLocation(),
- D->getDeclName(), T, D->getStorageClass(),
+ D->getDeclName(), T, D->getDeclaratorInfo(),
+ D->getStorageClass(),
D->isInline(), D->hasWrittenPrototype(),
D->getTypeSpecStartLoc());
}
@@ -440,8 +442,8 @@
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
CXXMethodDecl *Method
= CXXMethodDecl::Create(SemaRef.Context, Record, D->getLocation(),
- D->getDeclName(), T, D->isStatic(),
- D->isInline());
+ D->getDeclName(), T, D->getDeclaratorInfo(),
+ D->isStatic(), D->isInline());
Method->setInstantiationOfMemberFunction(D);
// If we are instantiating a member function defined
@@ -494,8 +496,8 @@
SemaRef.Context.getCanonicalType(ClassTy));
CXXConstructorDecl *Constructor
= CXXConstructorDecl::Create(SemaRef.Context, Record, D->getLocation(),
- Name, T, D->isExplicit(), D->isInline(),
- false);
+ Name, T, D->getDeclaratorInfo(),
+ D->isExplicit(), D->isInline(), false);
Constructor->setInstantiationOfMemberFunction(D);
// Attach the parameters
@@ -576,7 +578,8 @@
= CXXConversionDecl::Create(SemaRef.Context, Record,
D->getLocation(),
SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(ConvTy),
- T, D->isInline(), D->isExplicit());
+ T, D->getDeclaratorInfo(),
+ D->isInline(), D->isExplicit());
Conversion->setInstantiationOfMemberFunction(D);
if (InitMethodInstantiation(Conversion, D))
Conversion->setInvalidDecl();
@@ -612,12 +615,13 @@
ParmVarDecl *Param = 0;
if (T == OrigT)
Param = ParmVarDecl::Create(SemaRef.Context, Owner, D->getLocation(),
- D->getIdentifier(), T, D->getStorageClass(),
- 0);
+ D->getIdentifier(), T, D->getDeclaratorInfo(),
+ D->getStorageClass(), 0);
else
Param = OriginalParmVarDecl::Create(SemaRef.Context, Owner,
D->getLocation(), D->getIdentifier(),
- T, OrigT, D->getStorageClass(), 0);
+ T, D->getDeclaratorInfo(), OrigT,
+ D->getStorageClass(), 0);
// Note: we don't try to instantiate function parameters until after
// we've instantiated the function's type. Therefore, we don't have
diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp
index b42b84d..17e0014 100644
--- a/lib/Sema/SemaTemplateInstantiateStmt.cpp
+++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp
@@ -337,6 +337,7 @@
return SemaRef.StmtError();
Var = SemaRef.BuildExceptionDeclaration(0, T,
+ ExceptionDecl->getDeclaratorInfo(),
ExceptionDecl->getIdentifier(),
ExceptionDecl->getLocation(),
/*FIXME: Inaccurate*/
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 6ba23a9..fdc1a7e 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -783,7 +783,8 @@
/// If OwnedDecl is non-NULL, and this declarator's decl-specifier-seq
/// owns the declaration of a type (e.g., the definition of a struct
/// type), then *OwnedDecl will receive the owned declaration.
-QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip,
+QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
+ DeclaratorInfo **DInfo, unsigned Skip,
TagDecl **OwnedDecl) {
bool OmittedReturnType = false;
@@ -1416,8 +1417,9 @@
// the parser.
assert(D.getIdentifier() == 0 && "Type name should have no identifier!");
+ DeclaratorInfo *DInfo = 0;
TagDecl *OwnedTag = 0;
- QualType T = GetTypeForDeclarator(D, S, /*Skip=*/0, &OwnedTag);
+ QualType T = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0, &OwnedTag);
if (D.isInvalidType())
return true;
@@ -1434,6 +1436,7 @@
<< Context.getTypeDeclType(OwnedTag);
}
+ //FIXME: Also pass DeclaratorInfo.
return T.getAsOpaquePtr();
}