xref: /llvm-project/clang/test/ClangScanDeps/modules-implied-args.c (revision cf73d3f07b5b0ff83a852dfdf8857500e86f9952)
1 // Check that we get canonical round-trippable command-lines, in particular
2 // for the options modified for modules.
3 
4 // RUN: rm -rf %t
5 // RUN: split-file %s %t
6 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
7 
8 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -round-trip-args > %t/result.json
9 // RUN: cat %t/result.json  | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,NEGATIVE
10 
11 // -ffast-math implies -menable-no-infs, -menable-no-nans, and -mreassociate;
12 // those options are modified by resetNonModularOptions.
13 
14 // NEGATIVE-NOT: "-menable-no-infs"
15 // NEGATIVE-NOT: "-menable-no-nans"
16 // NEGATIVE-NOT: "-mreassociate"
17 
18 // CHECK:      "modules": [
19 // CHECK-NEXT:   {
20 // CHECK:          "clang-module-deps": []
21 // CHECK:          "command-line": [
22 // CHECK:            "-ffast-math"
23 // CHECK:          ]
24 // CHECK:          "name": "Mod"
25 // CHECK:        }
26 // CHECK-NEXT: ]
27 // CHECK:      "translation-units": [
28 // CHECK-NEXT:   {
29 // CHECK-NEXT:     "commands": [
30 // CHECK:            {
31 // CHECK:              "command-line": [
32 // CHECK:                "-ffast-math"
33 // CHECK:              ]
34 
35 //--- cdb.json.template
36 [{
37   "file": "DIR/tu.c",
38   "directory": "DIR",
39   "command": "clang -fsyntax-only DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -ffast-math"
40 }]
41 
42 //--- module.modulemap
43 module Mod { header "mod.h" }
44 //--- mod.h
45 //--- tu.c
46 #include "mod.h"
47