Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-09-01 Thread Aleksei Sidorin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280360: [analyzer] Add more FileIDs to PlistDiagnostic map 
to avoid assertion (authored by a.sidorin).

Changed prior to commit:
  https://reviews.llvm.org/D22090?vs=68987&id=69993#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22090

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  
cfe/trunk/test/Analysis/diagnostics/Inputs/include/plist-diagnostics-include-check-macro.def
  
cfe/trunk/test/Analysis/diagnostics/Inputs/include/plist-diagnostics-include-check-macro.h
  cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,40 +297,42 @@
 SM = &Diags.front()->path.front()->getLocation().getManager();
 
 
-  for (std::vector::iterator DI = Diags.begin(),
-   DE = Diags.end(); DI != DE; ++DI) {
+  auto AddPieceFID = [&FM, &Fids, SM](const PathDiagnosticPiece *Piece)->void {
+AddFID(FM, Fids, *SM, Piece->getLocation().asLocation());
+ArrayRef Ranges = Piece->getRanges();
+for (const SourceRange &Range : Ranges) {
+  AddFID(FM, Fids, *SM, Range.getBegin());
+  AddFID(FM, Fids, *SM, Range.getEnd());
+}
+  };
 
-const PathDiagnostic *D = *DI;
+  for (const PathDiagnostic *D : Diags) {
 
 SmallVector WorkList;
 WorkList.push_back(&D->path);
 
 while (!WorkList.empty()) {
-  const PathPieces &path = *WorkList.pop_back_val();
-
-  for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E;
-   ++I) {
-const PathDiagnosticPiece *piece = I->get();
-AddFID(FM, Fids, *SM, piece->getLocation().asLocation());
-ArrayRef Ranges = piece->getRanges();
-for (ArrayRef::iterator I = Ranges.begin(),
- E = Ranges.end(); I != E; ++I) {
-  AddFID(FM, Fids, *SM, I->getBegin());
-  AddFID(FM, Fids, *SM, I->getEnd());
-}
+  const PathPieces &Path = *WorkList.pop_back_val();
 
-if (const PathDiagnosticCallPiece *call =
-dyn_cast(piece)) {
-  IntrusiveRefCntPtr
-callEnterWithin = call->getCallEnterWithinCallerEvent();
-  if (callEnterWithin)
-AddFID(FM, Fids, *SM, callEnterWithin->getLocation().asLocation());
+  for (const auto &Iter : Path) {
+const PathDiagnosticPiece *Piece = Iter.get();
+AddPieceFID(Piece);
+
+if (const PathDiagnosticCallPiece *Call =
+dyn_cast(Piece)) {
+  if (IntrusiveRefCntPtr
+  CallEnterWithin = Call->getCallEnterWithinCallerEvent())
+AddPieceFID(CallEnterWithin.get());
+
+  if (IntrusiveRefCntPtr
+  CallEnterEvent = Call->getCallEnterEvent())
+AddPieceFID(CallEnterEvent.get());
 
-  WorkList.push_back(&call->path);
+  WorkList.push_back(&Call->path);
 }
-else if (const PathDiagnosticMacroPiece *macro =
- dyn_cast(piece)) {
-  WorkList.push_back(¯o->subPieces);
+else if (const PathDiagnosticMacroPiece *Macro =
+ dyn_cast(Piece)) {
+  WorkList.push_back(&Macro->subPieces);
 }
   }
 }
Index: cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
===
--- cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
+++ cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -analyzer-output=plist-multi-file %s -o %t.plist
+// RUN: FileCheck --input-file=%t.plist %s
+
+#include "Inputs/include/plist-diagnostics-include-check-macro.h"
+
+void foo() {
+  PlistCheckMacro()
+#define PLIST_DEF_MACRO .run();
+#include "Inputs/include/plist-diagnostics-include-check-macro.def"
+}
+
+// CHECK:   diagnostics
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line7
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line1
+// CHECK-NEXT:  col15
+// CHECK-NEXT:  file2
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Calling 'PlistCheckMacro::run'
+// 

Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-08-23 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thanks!


https://reviews.llvm.org/D22090



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-08-23 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 68987.
a.sidorin added a comment.

Add plist output; give test files meaningful names.


https://reviews.llvm.org/D22090

Files:
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  
test/Analysis/diagnostics/Inputs/include/plist-diagnostics-include-check-macro.def
  
test/Analysis/diagnostics/Inputs/include/plist-diagnostics-include-check-macro.h
  test/Analysis/diagnostics/plist-diagnostics-include-check.cpp

Index: test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
===
--- /dev/null
+++ test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -analyzer-output=plist-multi-file %s -o %t.plist
+// RUN: FileCheck --input-file=%t.plist %s
+
+#include "Inputs/include/plist-diagnostics-include-check-macro.h"
+
+void foo() {
+  PlistCheckMacro()
+#define PLIST_DEF_MACRO .run();
+#include "Inputs/include/plist-diagnostics-include-check-macro.def"
+}
+
+// CHECK:   diagnostics
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line7
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line1
+// CHECK-NEXT:  col15
+// CHECK-NEXT:  file2
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Calling 'PlistCheckMacro::run'
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Calling 'PlistCheckMacro::run'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line6
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth1
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Entered call from 'foo'
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Entered call from 'foo'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line6
+// CHECK-NEXT:col3
+// CHECK-NEXT:file1
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line6
+// CHECK-NEXT:col6
+// CHECK-NEXT:file1
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line7
+// CHECK-NEXT:col5
+// CHECK-NEXT:file1
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line7
+// CHECK-NEXT:col32
+// CHECK-NEXT:file1
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line7
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col5
+// CHECK-NEXT:  file1
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col34
+// CHECK-NEXT:  file1
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth1
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  REACHABLE
+// CHECK-NEXT:  message
+// CHECK-NEXT:  REACHABLE
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:descriptionREACHABLE
+// CHECK-NEXT:categorydebug
+// CHECK-NEXT:typeChecking analyzer assumptions
+// CHECK-NEXT:check_namedebug.ExprInspection
+// CHECK-NEXT:
+// CHECK-NEXT:issue_hash_content_of_line_in_context93b4eab05b21c892c8e31723e5af3f59
+// CHECK-NEXT:   issue_context_kindC++ method
+// CHECK-NEXT:   issue_contextrun
+// CHECK-NEXT:   issue_hash_function_offset1
+// CHECK-NEXT:   location
+// CHECK-NEXT:   
+// CHECK-NEXT:line7
+// CHECK-NEXT:col5
+// CHECK-NEXT:file1
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:  
Index: test/Analysis/diagnostics/Inputs/include/plist-diagnostics-include-check-macro.h
===
--- /dev/null
+++ test/Analysis/diagnostics/Inputs/include/p

Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-07-30 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

https://reviews.llvm.org/D22090



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/diagnostics/Inputs/include/Something.h:1
@@ +1,2 @@
+void clang_analyzer_warnIfReached();
+

Please, choose better file names. Every test that adds something cannot add a 
header called something:) It won't scale.


Comment at: test/Analysis/diagnostics/plist-diagnostics-include-check.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection 
-analyzer-output=plist-multi-file -o plist.xml %s
+

Please, check that output is produced. Search for other tests with 
-analyzer-poutput=plist-multi-file for examples.


https://reviews.llvm.org/D22090



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits