r206503 - Making some public members into private members. This also introduces a bit more const-correctness, and now uses some range-based for loops. No functional changes intended.
Aaron Ballman
aaron at aaronballman.com
Thu Apr 17 14:44:08 PDT 2014
Author: aaronballman
Date: Thu Apr 17 16:44:08 2014
New Revision: 206503
URL: http://llvm.org/viewvc/llvm-project?rev=206503&view=rev
Log:
Making some public members into private members. This also introduces a bit more const-correctness, and now uses some range-based for loops. No functional changes intended.
Modified:
cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
cfe/trunk/lib/Analysis/ThreadSafety.cpp
Modified: cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h?rev=206503&r1=206502&r2=206503&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h Thu Apr 17 16:44:08 2014
@@ -76,14 +76,18 @@ private:
BlockOrderTy BlockOrder;
public:
- typedef std::vector<const CFGBlock*>::reverse_iterator iterator;
+ typedef std::vector<const CFGBlock *>::reverse_iterator iterator;
+ typedef std::vector<const CFGBlock *>::const_reverse_iterator const_iterator;
PostOrderCFGView(const CFG *cfg);
iterator begin() { return Blocks.rbegin(); }
iterator end() { return Blocks.rend(); }
- bool empty() { return begin() == end(); }
+ const_iterator begin() const { return Blocks.rbegin(); }
+ const_iterator end() const { return Blocks.rend(); }
+
+ bool empty() const { return begin() == end(); }
struct BlockOrderCompare;
friend struct BlockOrderCompare;
Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h?rev=206503&r1=206502&r2=206503&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h Thu Apr 17 16:44:08 2014
@@ -84,8 +84,7 @@ class CFGVisitor {
// Walks the clang CFG, and invokes methods on a given CFGVisitor.
class CFGWalker {
public:
- CFGWalker() :
- CFGraph(nullptr), FDecl(nullptr), ACtx(nullptr), SortedGraph(nullptr) {}
+ CFGWalker() : CFGraph(nullptr), ACtx(nullptr), SortedGraph(nullptr) {}
// Initialize the CFGWalker. This setup only needs to be done once, even
// if there are multiple passes over the CFG.
@@ -95,8 +94,8 @@ public:
if (!CFGraph)
return false;
- FDecl = dyn_cast_or_null<NamedDecl>(AC.getDecl());
- if (!FDecl) // ignore anonymous functions
+ // Ignore anonymous functions.
+ if (!dyn_cast_or_null<NamedDecl>(AC.getDecl()))
return false;
SortedGraph = AC.getAnalysis<PostOrderCFGView>();
@@ -111,7 +110,7 @@ public:
void walk(Visitor &V) {
PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
- V.enterCFG(CFGraph, FDecl, &CFGraph->getEntry());
+ V.enterCFG(CFGraph, getDecl(), &CFGraph->getEntry());
for (const auto *CurrBlock : *SortedGraph) {
VisitedBlocks.insert(CurrBlock);
@@ -181,9 +180,15 @@ public:
V.exitCFG(&CFGraph->getExit());
}
-public: // TODO: make these private.
+ const CFG *getGraph() const { return CFGraph; }
+ CFG *getGraph() { return CFGraph; }
+
+ const NamedDecl *getDecl() const { return cast<NamedDecl>(ACtx->getDecl()); }
+
+ const PostOrderCFGView *getSortedGraph() const { return SortedGraph; }
+
+private:
CFG *CFGraph;
- const NamedDecl *FDecl;
AnalysisDeclContext *ACtx;
PostOrderCFGView *SortedGraph;
};
Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=206503&r1=206502&r2=206503&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Thu Apr 17 16:44:08 2014
@@ -1069,8 +1069,8 @@ public:
}
/// Builds the variable map.
- void traverseCFG(CFG *CFGraph, PostOrderCFGView *SortedGraph,
- std::vector<CFGBlockInfo> &BlockInfo);
+ void traverseCFG(CFG *CFGraph, const PostOrderCFGView *SortedGraph,
+ std::vector<CFGBlockInfo> &BlockInfo);
protected:
// Get the current context index
@@ -1289,15 +1289,13 @@ void LocalVariableMap::intersectBackEdge
// ... { y -> y1 | x3 = 2, x2 = 1, ... }
//
void LocalVariableMap::traverseCFG(CFG *CFGraph,
- PostOrderCFGView *SortedGraph,
+ const PostOrderCFGView *SortedGraph,
std::vector<CFGBlockInfo> &BlockInfo) {
PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
CtxIndices.resize(CFGraph->getNumBlockIDs());
- for (PostOrderCFGView::iterator I = SortedGraph->begin(),
- E = SortedGraph->end(); I!= E; ++I) {
- const CFGBlock *CurrBlock = *I;
+ for (const auto *CurrBlock : *SortedGraph) {
int CurrBlockID = CurrBlock->getBlockID();
CFGBlockInfo *CurrBlockInfo = &BlockInfo[CurrBlockID];
@@ -1376,11 +1374,9 @@ void LocalVariableMap::traverseCFG(CFG *
/// Find the appropriate source locations to use when producing diagnostics for
/// each block in the CFG.
static void findBlockLocations(CFG *CFGraph,
- PostOrderCFGView *SortedGraph,
+ const PostOrderCFGView *SortedGraph,
std::vector<CFGBlockInfo> &BlockInfo) {
- for (PostOrderCFGView::iterator I = SortedGraph->begin(),
- E = SortedGraph->end(); I!= E; ++I) {
- const CFGBlock *CurrBlock = *I;
+ for (const auto *CurrBlock : *SortedGraph) {
CFGBlockInfo *CurrBlockInfo = &BlockInfo[CurrBlock->getBlockID()];
// Find the source location of the last statement in the block, if the
@@ -2374,8 +2370,8 @@ void ThreadSafetyAnalyzer::runAnalysis(A
// AC.dumpCFG(true);
// threadSafety::printSCFG(walker);
- CFG *CFGraph = walker.CFGraph;
- const NamedDecl *D = walker.FDecl;
+ CFG *CFGraph = walker.getGraph();
+ const NamedDecl *D = walker.getDecl();
if (D->hasAttr<NoThreadSafetyAnalysisAttr>())
return;
@@ -2395,7 +2391,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A
// We need to explore the CFG via a "topological" ordering.
// That way, we will be guaranteed to have information about required
// predecessor locksets when exploring a new block.
- PostOrderCFGView *SortedGraph = walker.SortedGraph;
+ const PostOrderCFGView *SortedGraph = walker.getSortedGraph();
PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
// Mark entry block as reachable
@@ -2465,9 +2461,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A
CapDiagKind);
}
- for (PostOrderCFGView::iterator I = SortedGraph->begin(),
- E = SortedGraph->end(); I!= E; ++I) {
- const CFGBlock *CurrBlock = *I;
+ for (const auto *CurrBlock : *SortedGraph) {
int CurrBlockID = CurrBlock->getBlockID();
CFGBlockInfo *CurrBlockInfo = &BlockInfo[CurrBlockID];
More information about the cfe-commits
mailing list