From 7e24e82a70a2c681f4291a3397bcd1e1005f251a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 28 Mar 2009 06:33:19 +0000 Subject: [PATCH] rename some methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67923 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Stmt.h | 8 ++-- lib/AST/CFG.cpp | 61 ++++++++++++++-------------- lib/Analysis/GRExprEngine.cpp | 2 +- lib/Analysis/LiveVariables.cpp | 2 +- lib/Analysis/UninitializedValues.cpp | 2 +- lib/CodeGen/CGObjC.cpp | 2 +- lib/Sema/SemaStmt.cpp | 4 +- tools/clang-cc/RewriteObjC.cpp | 2 +- 8 files changed, 41 insertions(+), 42 deletions(-) diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 5d1c6dc207..79b4a2956e 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -235,14 +235,14 @@ public: virtual void Destroy(ASTContext& Ctx); - /// hasSolitaryDecl - This method returns true if this DeclStmt refers + /// isSingleDecl - This method returns true if this DeclStmt refers /// to a single Decl. - bool hasSolitaryDecl() const { + bool isSingleDecl() const { return DG.isSingleDecl(); } - const Decl* getSolitaryDecl() const { return DG.getSingleDecl(); } - Decl *getSolitaryDecl() { return DG.getSingleDecl(); } + const Decl *getSingleDecl() const { return DG.getSingleDecl(); } + Decl *getSingleDecl() { return DG.getSingleDecl(); } SourceLocation getStartLoc() const { return StartLoc; } SourceLocation getEndLoc() const { return EndLoc; } diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index 3bfac7fbdc..297758316a 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -358,41 +358,40 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* Terminator, bool AlwaysAddStmt = false) { case Stmt::DeclStmtClass: { DeclStmt *DS = cast(Terminator); - if (DS->hasSolitaryDecl()) { + if (DS->isSingleDecl()) { Block->appendStmt(Terminator); - return WalkAST_VisitDeclSubExpr(DS->getSolitaryDecl()); + return WalkAST_VisitDeclSubExpr(DS->getSingleDecl()); } - else { - typedef llvm::SmallVector BufTy; - BufTy Buf; - CFGBlock* B = 0; - - // FIXME: Add a reverse iterator for DeclStmt to avoid this - // extra copy. - for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE=DS->decl_end(); - DI != DE; ++DI) - Buf.push_back(*DI); + + typedef llvm::SmallVector BufTy; + BufTy Buf; + CFGBlock* B = 0; + + // FIXME: Add a reverse iterator for DeclStmt to avoid this + // extra copy. + for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE=DS->decl_end(); + DI != DE; ++DI) + Buf.push_back(*DI); + + for (BufTy::reverse_iterator I=Buf.rbegin(), E=Buf.rend(); I!=E; ++I) { + // Get the alignment of the new DeclStmt, padding out to >=8 bytes. + unsigned A = llvm::AlignOf::Alignment < 8 + ? 8 : llvm::AlignOf::Alignment; - for (BufTy::reverse_iterator I=Buf.rbegin(), E=Buf.rend(); I!=E; ++I) { - // Get the alignment of the new DeclStmt, padding out to >=8 bytes. - unsigned A = llvm::AlignOf::Alignment < 8 - ? 8 : llvm::AlignOf::Alignment; - - // Allocate the DeclStmt using the BumpPtrAllocator. It will - // get automatically freed with the CFG. - DeclGroupRef DG(*I); - Decl* D = *I; - void* Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A); - - DeclStmt* DS = new (Mem) DeclStmt(DG, D->getLocation(), - GetEndLoc(D)); - - // Append the fake DeclStmt to block. - Block->appendStmt(DS); - B = WalkAST_VisitDeclSubExpr(D); - } - return B; + // Allocate the DeclStmt using the BumpPtrAllocator. It will + // get automatically freed with the CFG. + DeclGroupRef DG(*I); + Decl* D = *I; + void* Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A); + + DeclStmt* DS = new (Mem) DeclStmt(DG, D->getLocation(), + GetEndLoc(D)); + + // Append the fake DeclStmt to block. + Block->appendStmt(DS); + B = WalkAST_VisitDeclSubExpr(D); } + return B; } case Stmt::AddrLabelExprClass: { diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 70e6647c27..8241d13a0b 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1534,7 +1534,7 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, SVal ElementV; if (DeclStmt* DS = dyn_cast(elem)) { - VarDecl* ElemD = cast(DS->getSolitaryDecl()); + VarDecl* ElemD = cast(DS->getSingleDecl()); assert (ElemD->getInit() == 0); ElementV = getStateManager().GetLValue(GetState(Pred), ElemD); VisitObjCForCollectionStmtAux(S, Pred, Dst, ElementV); diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 23f6f461aa..b8b0aaca18 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -194,7 +194,7 @@ TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) { VarDecl* VD = 0; if (DeclStmt* DS = dyn_cast(Element)) - VD = cast(DS->getSolitaryDecl()); + VD = cast(DS->getSingleDecl()); else { Expr* ElemExpr = cast(Element)->IgnoreParens(); if ((DR = dyn_cast(ElemExpr))) diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 9ff99f1fa1..014ea8255e 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -193,7 +193,7 @@ TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) { VarDecl* VD = 0; if (DeclStmt* DS = dyn_cast(Element)) - VD = cast(DS->getSolitaryDecl()); + VD = cast(DS->getSingleDecl()); else { Expr* ElemExpr = cast(Element)->IgnoreParens(); diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index de63f51b33..2467a8290a 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -436,7 +436,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ if (const DeclStmt *SD = dyn_cast(S.getElement())) { EmitStmt(SD); assert(HaveInsertPoint() && "DeclStmt destroyed insert point!"); - const Decl* D = SD->getSolitaryDecl(); + const Decl* D = SD->getSingleDecl(); ElementTy = cast(D)->getType(); DeclAddress = LocalDeclMap[D]; } else { diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index bbcc71d6e4..4082d485b8 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -627,11 +627,11 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, if (First) { QualType FirstType; if (DeclStmt *DS = dyn_cast(First)) { - if (!DS->hasSolitaryDecl()) + if (!DS->isSingleDecl()) return StmtError(Diag((*DS->decl_begin())->getLocation(), diag::err_toomany_element_decls)); - Decl *D = DS->getSolitaryDecl(); + Decl *D = DS->getSingleDecl(); FirstType = cast(D)->getType(); // C99 6.8.5p3: The declaration part of a 'for' statement shall only // declare identifiers for objects having storage class 'auto' or diff --git a/tools/clang-cc/RewriteObjC.cpp b/tools/clang-cc/RewriteObjC.cpp index ee2334ba8b..e0267ec2d0 100644 --- a/tools/clang-cc/RewriteObjC.cpp +++ b/tools/clang-cc/RewriteObjC.cpp @@ -1306,7 +1306,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S, buf = "\n{\n\t"; if (DeclStmt *DS = dyn_cast(S->getElement())) { // type elem; - NamedDecl* D = cast(DS->getSolitaryDecl()); + NamedDecl* D = cast(DS->getSingleDecl()); QualType ElementType = cast(D)->getType(); elementTypeAsString = ElementType.getAsString(); buf += elementTypeAsString; -- 2.40.0