diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-08-21 00:31:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-08-21 00:31:54 +0000 |
commit | a5d82000f7b173a0a5ce34dc8c09a03f98d9e439 (patch) | |
tree | 9fb6219cbbff742d0b9e3fd84532dacf96091d50 /lib | |
parent | d1571acc700b652a52c766e36a6c688d9bf6f3a1 (diff) |
Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use DeclaratorInfo to get this information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Decl.cpp | 25 | ||||
-rw-r--r-- | lib/AST/DeclTemplate.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/PCHReaderDecl.cpp | 7 | ||||
-rw-r--r-- | lib/Frontend/PCHWriterDecl.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 27 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 |
9 files changed, 37 insertions, 46 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index b41fae86b9..fc19e61a09 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -140,11 +140,9 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, DeclarationName N, QualType T, DeclaratorInfo *DInfo, StorageClass S, bool isInline, - bool hasWrittenPrototype, - SourceLocation TypeSpecStartLoc) { + bool hasWrittenPrototype) { FunctionDecl *New - = new (C) FunctionDecl(Function, DC, L, N, T, DInfo, S, isInline, - TypeSpecStartLoc); + = new (C) FunctionDecl(Function, DC, L, N, T, DInfo, S, isInline); New->HasWrittenPrototype = hasWrittenPrototype; return New; } @@ -155,9 +153,8 @@ BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { FieldDecl *FieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, - DeclaratorInfo *DInfo, Expr *BW, - bool Mutable, SourceLocation TSSL) { - return new (C) FieldDecl(Decl::Field, DC, L, Id, T, DInfo, BW, Mutable, TSSL); + DeclaratorInfo *DInfo, Expr *BW, bool Mutable) { + return new (C) FieldDecl(Decl::Field, DC, L, Id, T, DInfo, BW, Mutable); } bool FieldDecl::isAnonymousStructOrUnion() const { @@ -317,13 +314,23 @@ NamedDecl *NamedDecl::getUnderlyingDecl() { } //===----------------------------------------------------------------------===// +// DeclaratorDecl Implementation +//===----------------------------------------------------------------------===// + +SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const { + if (DeclInfo) + return DeclInfo->getTypeLoc().getTypeSpecRange().getBegin(); + return SourceLocation(); +} + +//===----------------------------------------------------------------------===// // VarDecl Implementation //===----------------------------------------------------------------------===// VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, - StorageClass S, SourceLocation TypeSpecStartLoc) { - return new (C) VarDecl(Var, DC, L, Id, T, DInfo, S, TypeSpecStartLoc); + StorageClass S) { + return new (C) VarDecl(Var, DC, L, Id, T, DInfo, S); } void VarDecl::Destroy(ASTContext& C) { diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index c132749f40..08e53eb088 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -236,10 +236,8 @@ NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, - DeclaratorInfo *DInfo, - SourceLocation TypeSpecStartLoc) { - return new (C) NonTypeTemplateParmDecl(DC, L, D, P, Id, T, DInfo, - TypeSpecStartLoc); + DeclaratorInfo *DInfo) { + return new (C) NonTypeTemplateParmDecl(DC, L, D, P, Id, T, DInfo); } SourceLocation NonTypeTemplateParmDecl::getDefaultArgumentLoc() const { diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index ad414b783b..dad433f628 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -694,8 +694,7 @@ uint64_t BlockFunction::getBlockOffset(const BlockDeclRefExpr *BDRE) { llvm::APInt(32, Pad), ArrayType::Normal, 0); ValueDecl *PadDecl = VarDecl::Create(getContext(), 0, SourceLocation(), - 0, QualType(PadTy), 0, VarDecl::None, - SourceLocation()); + 0, QualType(PadTy), 0, VarDecl::None); Expr *E; E = new (getContext()) DeclRefExpr(PadDecl, PadDecl->getType(), SourceLocation(), false, false); diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 32e364af37..1e5233e2c4 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -231,7 +231,6 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FD->setHasInheritedPrototype(Record[Idx++]); FD->setHasWrittenPrototype(Record[Idx++]); FD->setDeleted(Record[Idx++]); - FD->setTypeSpecStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); // FIXME: C++ TemplateOrInstantiation unsigned NumParams = Record[Idx++]; @@ -405,7 +404,6 @@ void PCHDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) { VisitDeclaratorDecl(FD); FD->setMutable(Record[Idx++]); - FD->setTypeSpecStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); if (Record[Idx++]) FD->setBitWidth(Reader.ReadDeclExpr()); } @@ -418,7 +416,6 @@ void PCHDeclReader::VisitVarDecl(VarDecl *VD) { VD->setDeclaredInCondition(Record[Idx++]); VD->setPreviousDeclaration( cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); - VD->setTypeSpecStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); if (Record[Idx++]) VD->setInit(*Reader.getContext(), Reader.ReadDeclExpr()); } @@ -741,11 +738,11 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) { break; case pch::DECL_FIELD: D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0, - false, SourceLocation()); + false); break; case pch::DECL_VAR: D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, - VarDecl::None, SourceLocation()); + VarDecl::None); break; case pch::DECL_IMPLICIT_PARAM: diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 4af13a012a..c605148e2b 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -229,7 +229,6 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) { Record.push_back(D->hasInheritedPrototype()); Record.push_back(D->hasWrittenPrototype()); Record.push_back(D->isDeleted()); - Writer.AddSourceLocation(D->getTypeSpecStartLoc(), Record); Writer.AddSourceLocation(D->getLocEnd(), Record); // FIXME: C++ TemplateOrInstantiation Record.push_back(D->param_size()); @@ -395,7 +394,6 @@ void PCHDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { void PCHDeclWriter::VisitFieldDecl(FieldDecl *D) { VisitDeclaratorDecl(D); Record.push_back(D->isMutable()); - Writer.AddSourceLocation(D->getTypeSpecStartLoc(), Record); Record.push_back(D->getBitWidth()? 1 : 0); if (D->getBitWidth()) Writer.AddStmt(D->getBitWidth()); @@ -409,7 +407,6 @@ void PCHDeclWriter::VisitVarDecl(VarDecl *D) { Record.push_back(D->hasCXXDirectInitializer()); Record.push_back(D->isDeclaredInCondition()); Writer.AddDeclRef(D->getPreviousDeclaration(), Record); - Writer.AddSourceLocation(D->getTypeSpecStartLoc(), Record); Record.push_back(D->getInit()? 1 : 0); if (D->getInit()) Writer.AddStmt(D->getInit()); @@ -524,7 +521,6 @@ void PCHWriter::WriteDeclsBlockAbbrevs() { Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer Abv->Add(BitCodeAbbrevOp(0)); // isDeclaredInCondition Abv->Add(BitCodeAbbrevOp(0)); // PrevDecl - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeSpecStartLoc Abv->Add(BitCodeAbbrevOp(0)); // HasInit // ParmVarDecl Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 060b4f436a..153d5ab82b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1509,9 +1509,10 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, Record->getLocation(), /*IdentifierInfo=*/0, - Context.getTypeDeclType(Record), /*DInfo=*/0, - /*BitWidth=*/0, /*Mutable=*/false, - DS.getSourceRange().getBegin()); + Context.getTypeDeclType(Record), + // FIXME: Type source info. + /*DInfo=*/0, + /*BitWidth=*/0, /*Mutable=*/false); Anon->setAccess(AS_public); if (getLangOptions().CPlusPlus) FieldCollector->Add(cast<FieldDecl>(Anon)); @@ -1536,8 +1537,10 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Anon = VarDecl::Create(Context, Owner, Record->getLocation(), /*IdentifierInfo=*/0, - Context.getTypeDeclType(Record), /*DInfo=*/0, - SC, DS.getSourceRange().getBegin()); + Context.getTypeDeclType(Record), + // FIXME: Type source info. + /*DInfo=*/0, + SC); } Anon->setImplicit(); @@ -2151,9 +2154,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, } NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(), - II, R, DInfo, SC, - // FIXME: Move to DeclGroup... - D.getDeclSpec().getSourceRange().getBegin()); + II, R, DInfo, SC); if (D.isInvalidType()) NewVD->setInvalidDecl(); @@ -2459,9 +2460,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // code path. NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(), Name, R, DInfo, SC, isInline, - /*hasPrototype=*/true, - // FIXME: Move to DeclGroup... - D.getDeclSpec().getSourceRange().getBegin()); + /*hasPrototype=*/true); D.setInvalidType(); } } else if (D.getKind() == Declarator::DK_Conversion) { @@ -2510,9 +2509,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(), - Name, R, DInfo, SC, isInline, HasPrototype, - // FIXME: Move to DeclGroup... - D.getDeclSpec().getSourceRange().getBegin()); + Name, R, DInfo, SC, isInline, HasPrototype); } if (D.isInvalidType()) @@ -4546,7 +4543,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, } FieldDecl *NewFD = FieldDecl::Create(Context, Record, Loc, II, T, DInfo, - BitWidth, Mutable, TSSL); + BitWidth, Mutable); if (InvalidDecl) NewFD->setInvalidDecl(); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 2edfea1172..15d32b08a7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3279,8 +3279,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType, // FIXME: Need to check for abstract classes. VarDecl *ExDecl = VarDecl::Create(Context, CurContext, Loc, - Name, ExDeclType, DInfo, VarDecl::None, - Range.getBegin()); + Name, ExDeclType, DInfo, VarDecl::None); if (Invalid) ExDecl->setInvalidDecl(); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7c3f7ecaab..7540dff44a 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -676,8 +676,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, QualType FnType = Context.getFunctionType(Return, &Argument, 1, false, 0); FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name, - FnType, /*DInfo=*/0, FunctionDecl::None, false, true, - SourceLocation()); + FnType, /*DInfo=*/0, FunctionDecl::None, false, true); Alloc->setImplicit(); ParmVarDecl *Param = ParmVarDecl::Create(Context, Alloc, SourceLocation(), 0, Argument, /*DInfo=*/0, diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 8d75ac463a..078c32b439 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -125,7 +125,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { VarDecl *Var = VarDecl::Create(SemaRef.Context, Owner, D->getLocation(), D->getIdentifier(), T, D->getDeclaratorInfo(), - D->getStorageClass(),D->getTypeSpecStartLoc()); + D->getStorageClass()); Var->setThreadSpecified(D->isThreadSpecified()); Var->setCXXDirectInitializer(D->hasCXXDirectInitializer()); Var->setDeclaredInCondition(D->isDeclaredInCondition()); @@ -416,8 +416,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) { FunctionDecl::Create(SemaRef.Context, Owner, D->getLocation(), D->getDeclName(), T, D->getDeclaratorInfo(), D->getStorageClass(), - D->isInline(), D->hasWrittenPrototype(), - D->getTypeSpecStartLoc()); + D->isInline(), D->hasWrittenPrototype()); } // Attach the parameters |