Skip to content

Commit

Permalink
[clang][deps] Test diagnostic options are being respected
Browse files Browse the repository at this point in the history
This patch tests code in D108976. This split is necessary to avoid temporary regression.

Depends on D108974,

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D109158
  • Loading branch information
jansvoboda11 committed Sep 10, 2021
1 parent 993f60a commit 7afabc2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
@@ -0,0 +1,7 @@
[
{
"directory": "DIR",
"command": "clang -c DIR/tu.c -fmodules -target i386-apple-ios14.0-simulator -o DIR/tu.o",
"file": "DIR/tu.c"
}
]
Empty file.
@@ -0,0 +1 @@
module mod { header "mod.h" }
1 change: 1 addition & 0 deletions llvm/clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
@@ -0,0 +1 @@
#include "mod.h"
49 changes: 49 additions & 0 deletions llvm/clang/test/ClangScanDeps/diagnostics.c
@@ -0,0 +1,49 @@
// 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 scanner injects '-Wno-error' option and invalid command-line
// arguments like '-target i386-apple-ios14.0-simulator' do not result in 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: }

0 comments on commit 7afabc2

Please sign in to comment.