[cfe-commits] r67777 - in /cfe/trunk: include/clang/Analysis/PathDiagnostic.h lib/Analysis/PathDiagnostic.cpp
Ted Kremenek
kremenek at apple.com
Thu Mar 26 14:48:17 PDT 2009
Author: kremenek
Date: Thu Mar 26 16:48:17 2009
New Revision: 67777
URL: http://llvm.org/viewvc/llvm-project?rev=67777&view=rev
Log:
Implement PathDiagnosticLocation::asRange() and PathDiagnosticLocation::asStmt().
Modified:
cfe/trunk/include/clang/Analysis/PathDiagnostic.h
cfe/trunk/lib/Analysis/PathDiagnostic.cpp
Modified: cfe/trunk/include/clang/Analysis/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathDiagnostic.h?rev=67777&r1=67776&r2=67777&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Thu Mar 26 16:48:17 2009
@@ -67,7 +67,7 @@
FullSourceLoc asLocation() const;
SourceRange asRange() const;
- const Stmt *asStmt() const;
+ const Stmt *asStmt() const { return S ? S : 0; }
};
class PathDiagnostic {
Modified: cfe/trunk/lib/Analysis/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PathDiagnostic.cpp?rev=67777&r1=67776&r2=67777&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/Analysis/PathDiagnostic.cpp Thu Mar 26 16:48:17 2009
@@ -152,3 +152,18 @@
return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(SM));
}
+
+SourceRange PathDiagnosticLocation::asRange() const {
+ // Note that we want a 'switch' here so that the compiler can warn us in
+ // case we add more cases.
+ switch (K) {
+ case SingleLoc:
+ case Range:
+ break;
+ case Statement:
+ return S->getSourceRange();
+ }
+
+ return R;
+}
+
More information about the cfe-commits
mailing list