cjdb created this revision.
cjdb added reviewers: aaron.ballman, shafik, erichkeane.
Herald added a project: All.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Including headers used to fire an assertion; now they report a
diagnostic similarly to unstructured diagnostics.

Depends on D145178 <https://reviews.llvm.org/D145178>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145201

Files:
  clang/test/Frontend/sarif-diagnostics.cpp
  clang/test/Frontend/sarif-diagnostics.hpp

Index: clang/test/Frontend/sarif-diagnostics.hpp
===================================================================
--- /dev/null
+++ clang/test/Frontend/sarif-diagnostics.hpp
@@ -0,0 +1 @@
+Test test;
Index: clang/test/Frontend/sarif-diagnostics.cpp
===================================================================
--- clang/test/Frontend/sarif-diagnostics.cpp
+++ clang/test/Frontend/sarif-diagnostics.cpp
@@ -27,6 +27,8 @@
     x + y;
 }
 
+#include "sarif-diagnostics.hpp"
+
 // RUN: %clang -fsyntax-only -Wall -Wextra -fdiagnostics-format=sarif-stderr %s > %t.txt 2>&1 || true
 // RUN: FileCheck -dump-input=always %s --input-file=%t.txt --check-prefixes=STDERR,SARIF
 
@@ -40,7 +42,18 @@
 // SARIF:           "length":{{[0-9]+}},
 // SARIF:           "location":{
 // SARIF:             "index":0,
-// SARIF:             "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:             "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
+// SARIF:           },
+// SARIF:           "mimeType":"text/plain",
+// SARIF:           "roles":[
+// SARIF:             "resultFile"
+// SARIF:           ]
+// SARIF:         },
+// SARIF:         {
+// SARIF:           "length":{{[0-9]+}},
+// SARIF:           "location":{
+// SARIF:             "index":1,
+// SARIF:             "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.hpp}}"
 // SARIF:           },
 // SARIF:           "mimeType":"text/plain",
 // SARIF:           "roles":[
@@ -57,7 +70,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":1,
@@ -80,7 +93,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":11,
@@ -103,7 +116,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":17,
@@ -126,7 +139,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+/test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":5,
@@ -149,7 +162,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":3,
@@ -172,7 +185,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":10,
@@ -195,7 +208,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":{{"file://[^"]+clang/test/Frontend/sarif-diagnostics.cpp"}}
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":12,
@@ -218,7 +231,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":1,
@@ -241,7 +254,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":6,
@@ -255,7 +268,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":10,
@@ -269,7 +282,7 @@
 // SARIF:               "physicalLocation":{
 // SARIF:                 "artifactLocation":{
 // SARIF:                   "index":0,
-// SARIF:                   "uri":{{"file://[^"]+/clang/test/Frontend/sarif-diagnostics.cpp"}}
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
 // SARIF:                 },
 // SARIF:                 "region":{
 // SARIF:                   "endColumn":7,
@@ -284,6 +297,52 @@
 // SARIF:           },
 // SARIF:           "ruleId":"4567",
 // SARIF:           "ruleIndex":8
+// SARIF:         },
+// SARIF:         {
+// SARIF:           "level":"note",
+// SARIF:           "locations":[
+// SARIF:             {
+// SARIF:               "physicalLocation":{
+// SARIF:                 "artifactLocation":{
+// SARIF:                   "index":0,
+// SARIF:                   "uri":"file://{{[^"]+test/Frontend/sarif-diagnostics.cpp}}"
+// SARIF:                 },
+// SARIF:                 "region":{
+// SARIF:                   "endColumn":10,
+// SARIF:                   "startColumn":10,
+// SARIF:                   "startLine":30
+// SARIF:                 }
+// SARIF:               }
+// SARIF:             }
+// SARIF:           ],
+// SARIF:           "message":{
+// SARIF:             "text":"in file included from {{[^"]+test/Frontend/sarif-diagnostics.cpp:30:}}\n"
+// SARIF:           },
+// SARIF:           "ruleId":"-1",
+// SARIF:           "ruleIndex":9
+// SARIF:         },
+// SARIF:         {
+// SARIF:           "level":"error",
+// SARIF:           "locations":[
+// SARIF:             {
+// SARIF:               "physicalLocation":{
+// SARIF:                 "artifactLocation":{
+// SARIF:                   "index":1,
+// SARIF:                   "uri":"file:///{{[^"]+/test/Frontend/sarif-diagnostics.hpp}}"
+// SARIF:                 },
+// SARIF:                 "region":{
+// SARIF:                   "endColumn":1,
+// SARIF:                   "startColumn":1,
+// SARIF:                   "startLine":1
+// SARIF:                 }
+// SARIF:               }
+// SARIF:             }
+// SARIF:           ],
+// SARIF:           "message":{
+// SARIF:             "text":"unknown type name 'Test'"
+// SARIF:           },
+// SARIF:           "ruleId":"4657",
+// SARIF:           "ruleIndex":10
 // SARIF:         }
 // SARIF:       ],
 // SARIF:       "tool":{
@@ -400,6 +459,30 @@
 // SARIF:               },
 // SARIF:               "id":"4567",
 // SARIF:               "name":""
+// SARIF:             },
+// SARIF:             {
+// SARIF:               "defaultConfiguration":{
+// SARIF:                 "enabled":true,
+// SARIF:                 "level":"note",
+// SARIF:                 "rank":-1
+// SARIF:               },
+// SARIF:               "fullDescription":{
+// SARIF:                 "text":""
+// SARIF:               },
+// SARIF:               "id":"-1",
+// SARIF:               "name":""
+// SARIF:             },
+// SARIF:             {
+// SARIF:               "defaultConfiguration":{
+// SARIF:                 "enabled":true,
+// SARIF:                 "level":"error",
+// SARIF:                 "rank":50
+// SARIF:               },
+// SARIF:               "fullDescription":{
+// SARIF:                 "text":""
+// SARIF:               },
+// SARIF:               "id":"4657",
+// SARIF:               "name":""
 // SARIF:             }
 // SARIF:           ],
 // SARIF:           "version":"17.0.0"
@@ -409,4 +492,4 @@
 // SARIF:   ],
 // SARIF:   "version":"2.1.0"
 // SARIF: }
-// STDERR: 2 warnings and 6 errors generated.
+// STDERR: 2 warnings and 7 errors generated.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to