[PATCH] D109158: [clang][deps] Test diagnostic options are being respected

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 2 07:52:40 PDT 2021


jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch tests code in D108976 <https://reviews.llvm.org/D108976>. This split is necessary to avoid temporary regression.

Depends on D108974 <https://reviews.llvm.org/D108974>,


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109158

Files:
  clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
  clang/test/ClangScanDeps/Inputs/diagnostics/mod.h
  clang/test/ClangScanDeps/Inputs/diagnostics/module.modulemap
  clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
  clang/test/ClangScanDeps/diagnostics.c


Index: clang/test/ClangScanDeps/diagnostics.c
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/diagnostics.c
@@ -0,0 +1,50 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/diagnostics/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/diagnostics/cdb.json.template > %t/cdb.json
+// RUN: echo -%t > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full 2>&1 >> %t/result.json
+// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s
+
+// Check that the '-Wno-error=invalid-ios-deployment-target' option is being
+// respected and invalid arguments like '-target i386-apple-ios14.0-simulator'
+// do not result in an error.
+
+// CHECK-NOT:  error:
+// CHECK:      -[[PREFIX:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT:     {
+// CHECK-NEXT:       "clang-module-deps": [],
+// CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:       "command-line": [
+// CHECK-NEXT:         "-cc1"
+// CHECK:            ],
+// CHECK-NEXT:       "context-hash": "[[HASH_MOD:.*]]",
+// CHECK-NEXT:       "file-deps": [
+// CHECK-NEXT:         "[[PREFIX]]/mod.h"
+// CHECK-NEXT:         "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT:       ],
+// CHECK-NEXT:       "name": "mod"
+// CHECK-NEXT:     }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT:     {
+// CHECK-NEXT:       "clang-context-hash": "[[HASH_TU:.*]],
+// CHECK-NEXT:       "clang-module-deps": [
+// CHECK-NEXT:         {
+// CHECK-NEXT:           "context-hash": "[[HASH_MOD]]",
+// CHECK-NEXT:           "module-name": "mod"
+// CHECK-NEXT:         }
+// CHECK-NEXT:       ],
+// CHECK-NEXT:       "command-line": [
+// CHECK-NEXT:         "-fno-implicit-modules"
+// CHECK-NEXT:         "-fno-implicit-module-maps"
+// CHECK-NEXT:       ],
+// CHECK-NEXT:       "file-deps": [
+// CHECK-NEXT:         "[[PREFIX]]/tu.c"
+// CHECK-NEXT:       ],
+// CHECK-NEXT:       "input-file": "[[PREFIX]]/tu.c"
+// CHECK-NEXT:     }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
@@ -0,0 +1 @@
+#include "mod.h"
Index: clang/test/ClangScanDeps/Inputs/diagnostics/module.modulemap
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/module.modulemap
@@ -0,0 +1 @@
+module mod { header "mod.h" }
Index: clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
@@ -0,0 +1,7 @@
+[
+  {
+    "directory": "DIR",
+    "command": "clang -c DIR/tu.c -fmodules -target i386-apple-ios14.0-simulator -Wno-error=invalid-ios-deployment-target -o DIR/tu.o",
+    "file": "DIR/tu.c"
+  }
+]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109158.370271.patch
Type: text/x-patch
Size: 3033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210902/66d31656/attachment.bin>


More information about the cfe-commits mailing list