brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.6 KiB · 9489563 Raw
113 lines · c
1// RUN: rm -rf %t && mkdir %t2// RUN: cp -r %S/Inputs/modules-context-hash/* %t3 4// Check that the scanner reports the same module as distinct dependencies when5// a single translation unit gets compiled with multiple command-lines that6// produce different **strict** context hashes.7 8// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_a.json.template > %t/cdb_a.json9// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_b.json.template > %t/cdb_b.json10// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_b2.json.template > %t/cdb_b2.json11 12// We run separate scans. The context hash for "a" and "b" can differ between13// systems. If we'd scan both Clang invocations in a single run, the order of JSON14// entities would be non-deterministic. To prevent this, run the scans separately15// and verify that the context hashes differ with a single FileCheck invocation.16//17// RUN: clang-scan-deps -compilation-database %t/cdb_a.json -format experimental-full -j 1 >  %t/result_a.json18// RUN: clang-scan-deps -compilation-database %t/cdb_b.json -format experimental-full -j 1 > %t/result_b.json19// RUN: clang-scan-deps -compilation-database %t/cdb_b2.json -format experimental-full -j 1 > %t/result_b2.json20// RUN: cat %t/result_a.json %t/result_b.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK21// RUN: cat %t/result_b.json %t/result_b2.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=FLAG_ONLY22 23// CHECK:      {24// CHECK-NEXT:   "modules": [25// CHECK-NEXT:     {26// CHECK-NEXT:       "clang-module-deps": [],27// CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/module.modulemap",28// CHECK-NEXT:       "command-line": [29// CHECK-NEXT:         "-cc1"30// CHECK:              "-emit-module"31// CHECK:              "-I"32// CHECK:              "[[PREFIX]]/a"33// CHECK:              "-fmodule-name=mod"34// CHECK:            ],35// CHECK-NEXT:       "context-hash": "[[HASH_MOD_A:.*]]",36// CHECK-NEXT:       "file-deps": [37// CHECK-NEXT:         "[[PREFIX]]/module.modulemap",38// CHECK-NEXT:         "[[PREFIX]]/mod.h",39// CHECK-NEXT:         "[[PREFIX]]/a/dep.h"40// CHECK-NEXT:       ],41// CHECK-NEXT:       "link-libraries": [],42// CHECK-NEXT:       "name": "mod"43// CHECK-NEXT:     }44// CHECK-NEXT:   ],45// CHECK-NEXT:   "translation-units": [46// CHECK-NEXT:     {47// CHECK:            "clang-context-hash": "{{.*}}",48// CHECK-NEXT:       "clang-module-deps": [49// CHECK-NEXT:         {50// CHECK-NEXT:           "context-hash": "[[HASH_MOD_A]]",51// CHECK-NEXT:           "module-name": "mod"52// CHECK-NEXT:         }53// CHECK-NEXT:       ],54// CHECK-NEXT:       "command-line": [55// CHECK:            ],56// CHECK:            "file-deps": [57// CHECK-NEXT:         "[[PREFIX]]/tu.c"58// CHECK-NEXT:       ],59// CHECK-NEXT:       "input-file": "[[PREFIX]]/tu.c"60// CHECK-NEXT:     }61 62// CHECK:       "modules": [63// CHECK-NEXT:     {64// CHECK-NEXT:       "clang-module-deps": [],65// CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/module.modulemap",66// CHECK-NEXT:       "command-line": [67// CHECK-NEXT:         "-cc1"68// CHECK:              "-emit-module"69// CHECK:              "-I"70// CHECK:              "[[PREFIX]]/b"71// CHECK:              "-fmodule-name=mod"72// CHECK:            ],73// CHECK-NOT:        "context-hash": "[[HASH_MOD_A]]",74// CHECK:            "file-deps": [75// CHECK-NEXT:         "[[PREFIX]]/module.modulemap",76// CHECK-NEXT:         "[[PREFIX]]/mod.h",77// CHECK-NEXT:         "[[PREFIX]]/b/dep.h"78// CHECK-NEXT:       ],79// CHECK-NEXT:       "link-libraries": [],80// CHECK-NEXT:       "name": "mod"81// CHECK-NEXT:     }82// CHECK-NEXT:   ],83// CHECK-NEXT:   "translation-units": [84// CHECK-NEXT:     {85// CHECK:            "clang-context-hash": "{{.*}}",86// CHECK-NEXT:       "clang-module-deps": [87// CHECK-NEXT:         {88// CHECK-NOT:            "context-hash": "[[HASH_MOD_A]]",89// CHECK:                "module-name": "mod"90// CHECK-NEXT:         }91// CHECK-NEXT:       ],92// CHECK-NEXT:       "command-line": [93// CHECK:            ],94// CHECK:            "file-deps": [95// CHECK-NEXT:         "[[PREFIX]]/tu.c"96// CHECK-NEXT:       ],97// CHECK-NEXT:       "input-file": "[[PREFIX]]/tu.c"98// CHECK-NEXT:     }99 100// B and B2 only differ by -fapplication-extension101 102// FLAG_ONLY:       "modules": [103// FLAG_ONLY-NEXT:     {104// FLAG_ONLY:            "context-hash": "[[HASH_MOD_B1:.*]]"105// FLAG_ONLY-NOT:        "-fapplication-extension"106 107// FLAG_ONLY:       "modules": [108// FLAG_ONLY-NEXT:     {109// FLAG_ONLY-NOT:        "context-hash": "[[HASH_MOD_B1]]"110// FLAG_ONLY:            "-fapplication-extension"111// FLAG_ONLY:       "translation-units": [112// FLAG_ONLY-NOT:        "context-hash": "[[HASH_MOD_B1]]"113