[cfe-commits] r68292 - in /cfe/trunk: include/clang/Analysis/PathDiagnostic.h lib/Frontend/PlistDiagnostics.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 1 22:13:25 PDT 2009
Author: kremenek
Date: Thu Apr 2 00:13:24 2009
New Revision: 68292
URL: http://llvm.org/viewvc/llvm-project?rev=68292&view=rev
Log:
Hack: Add 'PathDiagnostic::flattenLocations()'. Because PlistDiagnosticClient
can use a PathLocation after any reference Stmts are reclaimed,
flattenLocation() converts those references to statements to source ranges.
Modified:
cfe/trunk/include/clang/Analysis/PathDiagnostic.h
cfe/trunk/lib/Frontend/PlistDiagnostics.cpp
Modified: cfe/trunk/include/clang/Analysis/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathDiagnostic.h?rev=68292&r1=68291&r2=68292&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Thu Apr 2 00:13:24 2009
@@ -101,6 +101,14 @@
*this = PathDiagnosticLocation();
}
+ void flatten() {
+ if (K == Statement) {
+ R = asRange();
+ K = Range;
+ S = 0;
+ }
+ }
+
const SourceManager& getManager() const { assert(isValid()); return *SM; }
};
@@ -114,6 +122,11 @@
const PathDiagnosticLocation &getStart() const { return Start; }
const PathDiagnosticLocation &getEnd() const { return End; }
+
+ void flatten() {
+ Start.flatten();
+ End.flatten();
+ }
};
//===----------------------------------------------------------------------===//
@@ -154,6 +167,7 @@
DisplayHint getDisplayHint() const { return Hint; }
virtual PathDiagnosticLocation getLocation() const = 0;
+ virtual void flattenLocations() = 0;
Kind getKind() const { return kind; }
@@ -208,6 +222,7 @@
}
PathDiagnosticLocation getLocation() const { return Pos; }
+ virtual void flattenLocations() { Pos.flatten(); }
};
class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
@@ -266,12 +281,18 @@
void push_back(const PathDiagnosticLocationPair &X) { LPairs.push_back(X); }
- virtual PathDiagnosticLocation getLocation() const { return getStartLocation(); }
+ virtual PathDiagnosticLocation getLocation() const {
+ return getStartLocation();
+ }
typedef std::vector<PathDiagnosticLocationPair>::iterator iterator;
iterator begin() { return LPairs.begin(); }
iterator end() { return LPairs.end(); }
+ virtual void flattenLocations() {
+ for (iterator I=begin(), E=end(); I!=E; ++I) I->flatten();
+ }
+
typedef std::vector<PathDiagnosticLocationPair>::const_iterator
const_iterator;
const_iterator begin() const { return LPairs.begin(); }
@@ -298,6 +319,11 @@
iterator begin() { return SubPieces.begin(); }
iterator end() { return SubPieces.end(); }
+ virtual void flattenLocations() {
+ PathDiagnosticSpotPiece::flattenLocations();
+ for (iterator I=begin(), E=end(); I!=E; ++I) (*I)->flattenLocations();
+ }
+
typedef std::vector<PathDiagnosticPiece*>::const_iterator const_iterator;
const_iterator begin() const { return SubPieces.begin(); }
const_iterator end() const { return SubPieces.end(); }
@@ -434,6 +460,10 @@
const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
+
+ void flattenLocations() {
+ for (iterator I = begin(), E = end(); I != E; ++I) I->flattenLocations();
+ }
};
Modified: cfe/trunk/lib/Frontend/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PlistDiagnostics.cpp?rev=68292&r1=68291&r2=68292&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/Frontend/PlistDiagnostics.cpp Thu Apr 2 00:13:24 2009
@@ -267,6 +267,10 @@
return;
}
+ // We need to flatten the locations (convert Stmt* to locations) because
+ // the referenced statements may be freed by the time the diagnostics
+ // are emitted.
+ const_cast<PathDiagnostic*>(D)->flattenLocations();
BatchedDiags.push_back(D);
}
More information about the cfe-commits
mailing list