[clang] 2ddd332 - [analyzer] Fix scan-build and exploded-graph-rewriter tests on Windows.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 10:33:47 PDT 2020


Author: Artem Dergachev
Date: 2020-04-06T20:33:37+03:00
New Revision: 2ddd3325c4d7ab47b62a9fe72a0d1c1d8ec7f9d7

URL: https://github.com/llvm/llvm-project/commit/2ddd3325c4d7ab47b62a9fe72a0d1c1d8ec7f9d7
DIFF: https://github.com/llvm/llvm-project/commit/2ddd3325c4d7ab47b62a9fe72a0d1c1d8ec7f9d7.diff

LOG: [analyzer] Fix scan-build and exploded-graph-rewriter tests on Windows.

Detect script locations in a more straightforward way: we don't need to
search for them because we know exactly where they are anyway.

Fix a file path escaping issue in exploded-graph-rewriter with Windows
backslashes in the path.

'REQUIRES: shell' remains in scan-build tests for now, so that to
observe the buildbot reaction on removing it in a cleaner experiment.

Patch by Denys Petrov!

Differential Revision: https://reviews.llvm.org/D76768

Added: 
    

Modified: 
    clang/include/clang/Basic/JsonSupport.h
    clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
    clang/test/Analysis/exploded-graph-rewriter/checker_messages_diff.dot
    clang/test/Analysis/exploded-graph-rewriter/constraints.dot
    clang/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
    clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
    clang/test/Analysis/exploded-graph-rewriter/edge.dot
    clang/test/Analysis/exploded-graph-rewriter/empty.dot
    clang/test/Analysis/exploded-graph-rewriter/environment.dot
    clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
    clang/test/Analysis/exploded-graph-rewriter/escapes.c
    clang/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
    clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
    clang/test/Analysis/exploded-graph-rewriter/macros.c
    clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
    clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
    clang/test/Analysis/exploded-graph-rewriter/program_points.dot
    clang/test/Analysis/exploded-graph-rewriter/store.dot
    clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
    clang/test/Analysis/exploded-graph-rewriter/topology.dot
    clang/test/Analysis/exploded-graph-rewriter/trimmers.dot
    clang/test/Analysis/scan-build/exclude_directories.test
    clang/test/Analysis/scan-build/help.test
    clang/test/Analysis/scan-build/html_output.test
    clang/test/Analysis/scan-build/plist_html_output.test
    clang/test/Analysis/scan-build/plist_output.test

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/JsonSupport.h b/clang/include/clang/Basic/JsonSupport.h
index bbcc747e6847..1b118b45a049 100644
--- a/clang/include/clang/Basic/JsonSupport.h
+++ b/clang/include/clang/Basic/JsonSupport.h
@@ -97,9 +97,13 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc,
     // The macro expansion and spelling pos is identical for file locs.
     if (AddBraces)
       Out << "{ ";
+    std::string filename(PLoc.getFilename());
+#ifdef _WIN32 // Handle windows-specific path delimiters.
+    std::replace(filename.begin(), filename.end(), '\\', '/');
+#endif
     Out << "\"line\": " << PLoc.getLine()
         << ", \"column\": " << PLoc.getColumn()
-        << ", \"file\": \"" << PLoc.getFilename() << "\"";
+        << ", \"file\": \"" << filename << "\"";
     if (AddBraces)
       Out << " }";
     return;

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot b/clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
index 2d054a8d48bd..860bdcd62053 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // CHECK: <b>Checker State: </b>
 // CHECK-SAME: <td align="left"><i>alpha.core.FooChecker</i>:</td>
 // CHECK-SAME: <td align="left">Foo stuff:</td>

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/checker_messages_
diff .dot b/clang/test/Analysis/exploded-graph-rewriter/checker_messages_
diff .dot
index 898f79600b8a..401bf6ae8c3a 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/checker_messages_
diff .dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/checker_messages_
diff .dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 Node0x1 [shape=record,label=
  "{
     { "state_id": 2,

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/constraints.dot b/clang/test/Analysis/exploded-graph-rewriter/constraints.dot
index f5ebcf1a606e..d8f64d7518cf 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/constraints.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/constraints.dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // CHECK: <tr><td align="left"><b>Ranges: </b></td></tr>
 // CHECK-SAME: <tr><td align="left"><table border="0">
 // CHECK-SAME:   <tr>

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/constraints_
diff .dot b/clang/test/Analysis/exploded-graph-rewriter/constraints_
diff .dot
index 53a87aa66755..221d3702cf70 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/constraints_
diff .dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/constraints_
diff .dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 Node0x1 [shape=record,label=
  "{
     {

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp b/clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
index a92c10776913..25583e6de738 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
+++ b/clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
@@ -5,9 +5,6 @@
 // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 struct S {};
 
 void test() {

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/edge.dot b/clang/test/Analysis/exploded-graph-rewriter/edge.dot
index 43d6e3b8faf1..4492dd88c46e 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/edge.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/edge.dot
@@ -1,9 +1,6 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s -check-prefix=LIGHT
 // RUN: %exploded_graph_rewriter --dark %s | FileCheck %s -check-prefixes=DARK
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 Node0x1 [shape=record,label=
  "{{ "state_id": 0, "program_state": null, "program_points": [
     {

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/empty.dot b/clang/test/Analysis/exploded-graph-rewriter/empty.dot
index 7f67e9cfed8a..1ef068cb8654 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/empty.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/empty.dot
@@ -2,9 +2,6 @@
 // RUN: %exploded_graph_rewriter --dark %s | FileCheck %s \
 // RUN:                                         -check-prefixes=CHECK,DARK
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 digraph "Exploded Graph" {
   label="Exploded Graph";
 }

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/environment.dot b/clang/test/Analysis/exploded-graph-rewriter/environment.dot
index 7b8fc05d3bb4..c7caedae560d 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/environment.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/environment.dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // CHECK: <b>Expressions: </b>
 // CHECK-SAME: <table border="0">
 // CHECK-SAME:   <tr>

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/environment_
diff .dot b/clang/test/Analysis/exploded-graph-rewriter/environment_
diff .dot
index 05e8d4eef50f..3e8f13bbf6c8 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/environment_
diff .dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/environment_
diff .dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // No 
diff s on the first node, nothing to check.
 Node0x1 [shape=record,label=
  "{

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/escapes.c b/clang/test/Analysis/exploded-graph-rewriter/escapes.c
index e0f8c5047ce1..563f1223a3dc 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/escapes.c
+++ b/clang/test/Analysis/exploded-graph-rewriter/escapes.c
@@ -5,9 +5,6 @@
 // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 void escapes() {
   // CHECK: <td align="left"><b>Store: </b> <font color="gray">(0x{{[0-9a-f]*}})</font></td>
   // CHECK-SAME: <td align="left">foo</td><td align="left">0</td>

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp b/clang/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
index 96df69f8577a..aa28a1d872e8 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
+++ b/clang/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
@@ -5,9 +5,6 @@
 // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 struct A {
   A() {}
 };

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg b/clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
index 87ce52cc53e0..9786932aa5a1 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
+++ b/clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
@@ -9,10 +9,9 @@ config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 
 config.substitutions.append(('%exploded_graph_rewriter',
                              '\'%s\' %s --dump-dot-only' % (
-                                 config.python_executable,
-                                 lit.util.which('exploded-graph-rewriter.py',
-                                                os.path.join(
-                                                    config.clang_src_dir,
-                                                    'utils', 'analyzer')))))
+                                config.python_executable,
+                                os.path.join(
+                                    config.clang_src_dir,
+                                    'utils', 'analyzer', 'exploded-graph-rewriter.py'))))
 
 config.suffixes.add('.dot')

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/macros.c b/clang/test/Analysis/exploded-graph-rewriter/macros.c
index 4dcbda95d225..39a6dc70ac2f 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/macros.c
+++ b/clang/test/Analysis/exploded-graph-rewriter/macros.c
@@ -1,3 +1,11 @@
+#define NULL 0
+void *foo() {
+  return NULL;
+}
+
+// The code above shall go first, because check tags below are sensetive to the line numbers on which the code is placed.
+// You can change lines below in the way you need.
+
 // FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
 // RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
 // RUN:                     -analyzer-checker=core \
@@ -5,14 +13,7 @@
 // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
-// CHECK: macros.c:<b>17</b>:<b>10</b>
+// CHECK: macros.c:<b>3</b>:<b>10</b>
 // CHECK-SAME: <font color="royalblue1">
-// CHECK-SAME:   (<i>spelling at </i> macros.c:<b>15</b>:<b>14</b>)
+// CHECK-SAME:   (<i>spelling at </i> macros.c:<b>1</b>:<b>14</b>)
 // CHECK-SAME: </font>
-#define NULL 0
-void *foo() {
-  return NULL;
-}

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/node_labels.dot b/clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
index 89d5070deedc..03a4a52c1bd3 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
@@ -7,9 +7,6 @@
 // RUN: %exploded_graph_rewriter %s --gray --dark \
 // RUN:     | FileCheck %s -check-prefixes CHECK,DARK,GRAY
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // LIGHT: Node0x1 [shape=record,label=<
 // DARK:  Node0x1 [shape=record,color="white",fontcolor="gray80",label=<
 // CHECK-SAME:   <tr>

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp b/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
index e4d256247f98..69cec5834c73 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
+++ b/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
@@ -6,9 +6,6 @@
 // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 struct S {
   S() {}
 };

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/program_points.dot b/clang/test/Analysis/exploded-graph-rewriter/program_points.dot
index bee48d0f49f8..d4ba5ee77627 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/program_points.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/program_points.dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // CHECK: <b>Program points:</b>
 // CHECK-SAME: <table border="0" align="left" width="0">
 // CHECK-SAME:   <tr>

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/store.dot b/clang/test/Analysis/exploded-graph-rewriter/store.dot
index c92901cbd7a3..febc36ebe698 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/store.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/store.dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // CHECK: <b>Store: </b>
 // CHECK-SAME: <font color="gray">(0x2)</font>
 // CHECK-SAME: <table border="0">

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/store_
diff .dot b/clang/test/Analysis/exploded-graph-rewriter/store_
diff .dot
index 8dd5fb44cd74..6ea65ff8539f 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/store_
diff .dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/store_
diff .dot
@@ -1,8 +1,5 @@
 // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 Node0x1 [shape=record,label=
  "{
     { "node_id": 1,

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/topology.dot b/clang/test/Analysis/exploded-graph-rewriter/topology.dot
index b85115ebeac7..85e6d5b37ab9 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/topology.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/topology.dot
@@ -3,9 +3,6 @@
 // RUN: %exploded_graph_rewriter -t %s \
 // RUN:     | FileCheck -check-prefixes=TOPOLOGY %s
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 // NORMAL: Program point
 // TOPOLOGY-NOT: Program point
 // NORMAL: Checker State

diff  --git a/clang/test/Analysis/exploded-graph-rewriter/trimmers.dot b/clang/test/Analysis/exploded-graph-rewriter/trimmers.dot
index df6270d0ef1e..457792fcf964 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/trimmers.dot
+++ b/clang/test/Analysis/exploded-graph-rewriter/trimmers.dot
@@ -13,9 +13,6 @@
 // RUN: %exploded_graph_rewriter --to 4 -s %s \
 // RUN:     | FileCheck %s -check-prefixes=ONE,TWO,NOTHREE,FOUR
 
-// FIXME: Substitution doesn't seem to work on Windows.
-// UNSUPPORTED: system-windows
-
 Node0x1 [shape=record,label=
  "{{ "state_id": 0, "program_state": null, "program_points": [
        {

diff  --git a/clang/test/Analysis/scan-build/exclude_directories.test b/clang/test/Analysis/scan-build/exclude_directories.test
index 60ea0aa002af..c161e51b6d26 100644
--- a/clang/test/Analysis/scan-build/exclude_directories.test
+++ b/clang/test/Analysis/scan-build/exclude_directories.test
@@ -1,9 +1,6 @@
 // FIXME: Actually, "perl".
 REQUIRES: shell
 
-// FIXME: Should ideally work on Windows.
-UNSUPPORTED: system-windows
-
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
 RUN: %scan-build -o %t.output_dir %clang -S \
 RUN:     %S/Inputs/multidirectory_project/directory1/file1.c \

diff  --git a/clang/test/Analysis/scan-build/help.test b/clang/test/Analysis/scan-build/help.test
index 556a4a74e82b..61915d326094 100644
--- a/clang/test/Analysis/scan-build/help.test
+++ b/clang/test/Analysis/scan-build/help.test
@@ -1,9 +1,6 @@
 // FIXME: Actually, "perl".
 REQUIRES: shell
 
-// FIXME: Should ideally work on Windows.
-UNSUPPORTED: system-windows
-
 RUN: %scan-build -h | FileCheck %s
 RUN: %scan-build --help | FileCheck %s
 

diff  --git a/clang/test/Analysis/scan-build/html_output.test b/clang/test/Analysis/scan-build/html_output.test
index b080b5f6a9c0..eed2051d4df6 100644
--- a/clang/test/Analysis/scan-build/html_output.test
+++ b/clang/test/Analysis/scan-build/html_output.test
@@ -1,9 +1,6 @@
 // FIXME: Actually, "perl".
 REQUIRES: shell
 
-// FIXME: Should ideally work on Windows.
-UNSUPPORTED: system-windows
-
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
 RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
 RUN:     | FileCheck %s -check-prefix CHECK-STDOUT

diff  --git a/clang/test/Analysis/scan-build/plist_html_output.test b/clang/test/Analysis/scan-build/plist_html_output.test
index 97997c243663..c07891e35fbf 100644
--- a/clang/test/Analysis/scan-build/plist_html_output.test
+++ b/clang/test/Analysis/scan-build/plist_html_output.test
@@ -1,9 +1,6 @@
 // FIXME: Actually, "perl".
 REQUIRES: shell
 
-// FIXME: Should ideally work on Windows.
-UNSUPPORTED: system-windows
-
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
 RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
 RUN:     | FileCheck %s -check-prefix CHECK-STDOUT

diff  --git a/clang/test/Analysis/scan-build/plist_output.test b/clang/test/Analysis/scan-build/plist_output.test
index 2e14ba698bfc..0112e84630ed 100644
--- a/clang/test/Analysis/scan-build/plist_output.test
+++ b/clang/test/Analysis/scan-build/plist_output.test
@@ -1,9 +1,6 @@
 // FIXME: Actually, "perl".
 REQUIRES: shell
 
-// FIXME: Should ideally work on Windows.
-UNSUPPORTED: system-windows
-
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
 RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
 RUN:     | FileCheck %s -check-prefix CHECK-STDOUT


        


More information about the cfe-commits mailing list