diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-04-29 23:12:59 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-04-29 23:12:59 +0000 |
commit | ed866e73bab7733f5226f84c52edefe23d694b2f (patch) | |
tree | 1fd6e17ad86eadf1cda4d272c692d249291d8865 /lib/StaticAnalyzer/Core/PathDiagnostic.cpp | |
parent | 7651e53997e20f1e627ffce25ce613f79c48e3e3 (diff) |
Revert "[analyzer] Change PathPieces to be a wrapper around an ilist of (through indirection) PathDiagnosticPieces."
Jordan rightly pointed out that we can do the same with std::list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180746 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index e2228aa13b..03513106ec 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -28,11 +28,11 @@ using namespace clang; using namespace ento; bool PathDiagnosticMacroPiece::containsEvent() const { - for (PathPieces::iterator I = subPieces.begin(), E = subPieces.end(); + for (PathPieces::const_iterator I = subPieces.begin(), E = subPieces.end(); I!=E; ++I) { if (isa<PathDiagnosticEventPiece>(*I)) return true; - if (PathDiagnosticMacroPiece *MP = dyn_cast<PathDiagnosticMacroPiece>(&*I)) + if (PathDiagnosticMacroPiece *MP = dyn_cast<PathDiagnosticMacroPiece>(*I)) if (MP->containsEvent()) return true; } @@ -59,21 +59,13 @@ PathDiagnosticCallPiece::~PathDiagnosticCallPiece() {} PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {} PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {} -PathPieces &PathPieces::operator=(const PathPieces & X) { - clear(); - for (llvm::ilist<Node>::const_iterator I = X.L.begin(), E = X.L.end(); - I != E; ++I) { - L.push_back(new Node(&*(I->Data))); - } - return *this; -} PathPieces::~PathPieces() {} void PathPieces::flattenTo(PathPieces &Primary, PathPieces &Current, bool ShouldFlattenMacros) const { - for (PathPieces::iterator I = begin(), E = end(); I != E; ++I) { - PathDiagnosticPiece *Piece = &*I; + for (PathPieces::const_iterator I = begin(), E = end(); I != E; ++I) { + PathDiagnosticPiece *Piece = I->getPtr(); switch (Piece->getKind()) { case PathDiagnosticPiece::Call: { @@ -153,7 +145,7 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) { if (!supportsCrossFileDiagnostics()) { // Verify that the entire path is from the same FileID. FileID FID; - const SourceManager &SMgr = D->path.begin()->getLocation().getManager(); + const SourceManager &SMgr = (*D->path.begin())->getLocation().getManager(); SmallVector<const PathPieces *, 5> WorkList; WorkList.push_back(&D->path); @@ -161,9 +153,9 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) { const PathPieces &path = *WorkList.back(); WorkList.pop_back(); - for (PathPieces::iterator I = path.begin(), E = path.end(); + for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E; ++I) { - const PathDiagnosticPiece *piece = &*I; + const PathDiagnosticPiece *piece = I->getPtr(); FullSourceLoc L = piece->getLocation().asLocation().getExpansionLoc(); if (FID.isInvalid()) { @@ -306,11 +298,11 @@ static Optional<bool> comparePath(const PathPieces &X, const PathPieces &Y) { if (X.size() != Y.size()) return X.size() < Y.size(); - PathPieces::iterator X_I = X.begin(), X_end = X.end(); - PathPieces::iterator Y_I = Y.begin(), Y_end = Y.end(); + PathPieces::const_iterator X_I = X.begin(), X_end = X.end(); + PathPieces::const_iterator Y_I = Y.begin(), Y_end = Y.end(); for ( ; X_I != X_end && Y_I != Y_end; ++X_I, ++Y_I) { - Optional<bool> b = comparePiece(*X_I, *Y_I); + Optional<bool> b = comparePiece(**X_I, **Y_I); if (b.hasValue()) return b.getValue(); } @@ -962,9 +954,9 @@ PathDiagnosticCallPiece::getCallExitEvent() const { } static void compute_path_size(const PathPieces &pieces, unsigned &size) { - for (PathPieces::iterator it = pieces.begin(), + for (PathPieces::const_iterator it = pieces.begin(), et = pieces.end(); it != et; ++it) { - const PathDiagnosticPiece *piece = &*it; + const PathDiagnosticPiece *piece = it->getPtr(); if (const PathDiagnosticCallPiece *cp = dyn_cast<PathDiagnosticCallPiece>(piece)) { compute_path_size(cp->path, size); @@ -1006,9 +998,9 @@ void PathDiagnosticPiece::Profile(llvm::FoldingSetNodeID &ID) const { void PathDiagnosticCallPiece::Profile(llvm::FoldingSetNodeID &ID) const { PathDiagnosticPiece::Profile(ID); - for (PathPieces::iterator it = path.begin(), + for (PathPieces::const_iterator it = path.begin(), et = path.end(); it != et; ++it) { - ID.Add(*it); + ID.Add(**it); } } @@ -1025,9 +1017,9 @@ void PathDiagnosticControlFlowPiece::Profile(llvm::FoldingSetNodeID &ID) const { void PathDiagnosticMacroPiece::Profile(llvm::FoldingSetNodeID &ID) const { PathDiagnosticSpotPiece::Profile(ID); - for (PathPieces::iterator I = subPieces.begin(), E = subPieces.end(); + for (PathPieces::const_iterator I = subPieces.begin(), E = subPieces.end(); I != E; ++I) - ID.Add(*I); + ID.Add(**I); } void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const { @@ -1039,8 +1031,8 @@ void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const { void PathDiagnostic::FullProfile(llvm::FoldingSetNodeID &ID) const { Profile(ID); - for (PathPieces::iterator I = path.begin(), E = path.end(); I != E; ++I) - ID.Add(*I); + for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E; ++I) + ID.Add(**I); for (meta_iterator I = meta_begin(), E = meta_end(); I != E; ++I) ID.AddString(*I); } |