]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix disappearing notes in DanglingInternalBufferChecker tests
authorReka Kovacs <rekanikolett@gmail.com>
Thu, 19 Jul 2018 15:44:46 +0000 (15:44 +0000)
committerReka Kovacs <rekanikolett@gmail.com>
Thu, 19 Jul 2018 15:44:46 +0000 (15:44 +0000)
Correct a mistake of the exact same kind I am writing this checker for.

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

lib/StaticAnalyzer/Checkers/MallocChecker.cpp

index 9049fa324be36d0d7adb98ce1f63b66dc13412a0..5dcd9b3863a80b696852d00d16ebd0cdbb58cee4 100644 (file)
@@ -2901,6 +2901,9 @@ std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(
   // Find out if this is an interesting point and what is the kind.
   const char *Msg = nullptr;
   StackHintGeneratorForSymbol *StackHint = nullptr;
+  SmallString<256> Buf;
+  llvm::raw_svector_ostream OS(Buf);
+  
   if (Mode == Normal) {
     if (isAllocated(RS, RSPrev, S)) {
       Msg = "Memory is allocated";
@@ -2917,8 +2920,6 @@ std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(
           Msg = "Memory is released";
           break;
         case AF_InternalBuffer: {
-          SmallString<256> Buf;
-          llvm::raw_svector_ostream OS(Buf);
           OS << "Inner pointer invalidated by call to ";
           if (N->getLocation().getKind() == ProgramPoint::PostImplicitCallKind) {
             OS << "destructor";