]> granicus.if.org Git - clang/commitdiff
Fix regression: initialize 'size' for PathDiagnostic to 0.
authorTed Kremenek <kremenek@apple.com>
Fri, 6 Mar 2009 07:53:30 +0000 (07:53 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 6 Mar 2009 07:53:30 +0000 (07:53 +0000)
Add some assertions along the way...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66265 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathDiagnostic.h
lib/Analysis/PathDiagnostic.cpp

index 702879c3dd0b36157b5b318440ff6a9f6879d761..a387910860b064d22686099e87a85ede53913395 100644 (file)
@@ -37,8 +37,12 @@ private:
   const DisplayHint Hint;
   std::vector<SourceRange> ranges;
   
-public:
+  // Do not implement:
+  PathDiagnosticPiece();
+  PathDiagnosticPiece(const PathDiagnosticPiece &P);
+  PathDiagnosticPiece& operator=(const PathDiagnosticPiece &P);
   
+public:
   PathDiagnosticPiece(FullSourceLoc pos, const std::string& s,
                       Kind k = Event,
                       DisplayHint hint = Above);
@@ -98,10 +102,10 @@ class PathDiagnostic {
   std::string Desc;
   std::string Category;
   std::vector<std::string> OtherDesc;
-
+  
 public:  
-  PathDiagnostic() : Size(0) {}
-
+  PathDiagnostic();
+  
   PathDiagnostic(const char* bugtype, const char* desc, const char* category);
   
   PathDiagnostic(const std::string& bugtype, const std::string& desc, 
index c078b6d0f2ebf7049614e87219a944c4e414deda..468b6c89f2bc5f76475a36e979786d8d14a4da9e 100644 (file)
@@ -36,12 +36,20 @@ static inline size_t GetNumCharsToLastNonPeriod(const std::string &s) {
 PathDiagnosticPiece::PathDiagnosticPiece(FullSourceLoc pos,
                                          const std::string& s,
                                          Kind k, DisplayHint hint)
-  : Pos(pos), str(s, 0, GetNumCharsToLastNonPeriod(s)), kind(k), Hint(hint) {}
+  : Pos(pos), str(s, 0, GetNumCharsToLastNonPeriod(s)), kind(k), Hint(hint) {
+    assert(Pos.isValid() &&
+           "PathDiagnosticPiece's must have a valid location.");
+}
 
 PathDiagnosticPiece::PathDiagnosticPiece(FullSourceLoc pos,
                                          const char* s, Kind k,
                                          DisplayHint hint)
-  : Pos(pos), str(s, GetNumCharsToLastNonPeriod(s)), kind(k), Hint(hint) {}
+  : Pos(pos), str(s, GetNumCharsToLastNonPeriod(s)), kind(k), Hint(hint) {
+  assert(Pos.isValid() &&
+         "PathDiagnosticPiece's must have a valid location.");
+}
+
+PathDiagnostic::PathDiagnostic() : Size(0) {}
 
 PathDiagnostic::~PathDiagnostic() {
   for (iterator I = begin(), E = end(); I != E; ++I) delete &*I;
@@ -50,14 +58,16 @@ PathDiagnostic::~PathDiagnostic() {
 
 PathDiagnostic::PathDiagnostic(const char* bugtype, const char* desc,
                                const char* category)
-  : BugType(bugtype, GetNumCharsToLastNonPeriod(bugtype)),
+  : Size(0),
+    BugType(bugtype, GetNumCharsToLastNonPeriod(bugtype)),
     Desc(desc, GetNumCharsToLastNonPeriod(desc)),
     Category(category, GetNumCharsToLastNonPeriod(category)) {}
 
 PathDiagnostic::PathDiagnostic(const std::string& bugtype,
                                const std::string& desc, 
                                const std::string& category)
-  : BugType(bugtype, 0, GetNumCharsToLastNonPeriod(bugtype)),
+  : Size(0),
+    BugType(bugtype, 0, GetNumCharsToLastNonPeriod(bugtype)),
     Desc(desc, 0, GetNumCharsToLastNonPeriod(desc)),
     Category(category, 0, GetNumCharsToLastNonPeriod(category)) {}