diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-08-29 18:53:26 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-08-29 18:53:26 +0000 |
commit | e90195c09b20d3d49c346ee6bc0f62e505cc5573 (patch) | |
tree | e1cc5942fb81eddecb5769115b08455213daaa8d /clang/lib/Analysis | |
parent | 759548b5a69902f662cc5c7ad1a98b74bc027860 (diff) | |
download | bcm5719-llvm-e90195c09b20d3d49c346ee6bc0f62e505cc5573.tar.gz bcm5719-llvm-e90195c09b20d3d49c346ee6bc0f62e505cc5573.zip |
unique_ptrify the result of CFG::buildCFG/CFGBuilder::buildCFG
llvm-svn: 216755
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/AnalysisDeclContext.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 13 |
2 files changed, 9 insertions, 11 deletions
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 5733236f91b..dd154f457a6 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -189,8 +189,7 @@ CFG *AnalysisDeclContext::getCFG() { return getUnoptimizedCFG(); if (!builtCFG) { - cfg.reset(CFG::buildCFG(D, getBody(), - &D->getASTContext(), cfgBuildOptions)); + cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), cfgBuildOptions); // Even when the cfg is not successfully built, we don't // want to try building it again. builtCFG = true; @@ -208,8 +207,8 @@ CFG *AnalysisDeclContext::getUnoptimizedCFG() { if (!builtCompleteCFG) { SaveAndRestore<bool> NotPrune(cfgBuildOptions.PruneTriviallyFalseEdges, false); - completeCFG.reset(CFG::buildCFG(D, getBody(), &D->getASTContext(), - cfgBuildOptions)); + completeCFG = + CFG::buildCFG(D, getBody(), &D->getASTContext(), cfgBuildOptions); // Even when the cfg is not successfully built, we don't // want to try building it again. builtCompleteCFG = true; diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 4a0d4e8e467..d9073aa63b1 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -349,7 +349,7 @@ public: cachedEntry(nullptr), lastLookup(nullptr) {} // buildCFG - Used by external clients to construct the CFG. - CFG* buildCFG(const Decl *D, Stmt *Statement); + std::unique_ptr<CFG> buildCFG(const Decl *D, Stmt *Statement); bool alwaysAdd(const Stmt *stmt); @@ -971,7 +971,7 @@ static const VariableArrayType *FindVA(const Type *t) { /// body (compound statement). The ownership of the returned CFG is /// transferred to the caller. If CFG construction fails, this method returns /// NULL. -CFG* CFGBuilder::buildCFG(const Decl *D, Stmt *Statement) { +std::unique_ptr<CFG> CFGBuilder::buildCFG(const Decl *D, Stmt *Statement) { assert(cfg.get()); if (!Statement) return nullptr; @@ -1043,7 +1043,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D, Stmt *Statement) { // Create an empty entry block that has no predecessors. cfg->setEntry(createBlock()); - return cfg.release(); + return std::move(cfg); } /// createBlock - Used to lazily create blocks that are connected @@ -3775,10 +3775,9 @@ CFGBlock *CFG::createBlock() { return &back(); } -/// buildCFG - Constructs a CFG from an AST. Ownership of the returned -/// CFG is returned to the caller. -CFG* CFG::buildCFG(const Decl *D, Stmt *Statement, ASTContext *C, - const BuildOptions &BO) { +/// buildCFG - Constructs a CFG from an AST. +std::unique_ptr<CFG> CFG::buildCFG(const Decl *D, Stmt *Statement, + ASTContext *C, const BuildOptions &BO) { CFGBuilder Builder(C, BO); return Builder.buildCFG(D, Statement); } |