brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.5 KiB · 16f053f Raw
126 lines · c
1// Some command-line arguments used for compiling translation units are not2// compatible with the semantics of modules or are likely to differ between3// identical modules discovered from different translation units. This test4// checks such arguments are removed from the command-lines: '-include',5// '-dwarf-debug-flag' and '-main-file-name'. Similarly, several arguments6// such as '-fmodules-cache-path=' are only relevant for implicit modules, and7// are removed to better-canonicalize the compilation.8 9// RUN: rm -rf %t && mkdir %t10// RUN: cp %S/Inputs/removed-args/* %t11// RUN: touch %t/build-session12// RUN: touch %t/tu.proftext13// RUN: llvm-profdata merge %t/tu.proftext -o %t/tu.profdata14 15// RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > %t/cdb.json16// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json17// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t18//19// CHECK:      {20// CHECK-NEXT:   "modules": [21// CHECK-NEXT:     {22// CHECK-NEXT:       "clang-module-deps": [],23// CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/module.modulemap",24// CHECK-NEXT:       "command-line": [25// CHECK-NEXT:         "-cc1"26// CHECK-NOT:          "-fdebug-compilation-dir="27// CHECK-NOT:          "-fcoverage-compilation-dir="28// CHECK-NOT:          "-coverage-notes-file29// CHECK-NOT:          "-coverage-data-file30// CHECK-NOT:          "-fprofile-instrument-use-path31// CHECK-NOT:          "-dwarf-debug-flags"32// CHECK-NOT:          "-main-file-name"33// CHECK-NOT:          "-include"34// CHECK-NOT:          "-fmodules-cache-path=35// CHECK-NOT:          "-fmodules-validate-once-per-build-session"36// CHECK-NOT:          "-fbuild-session-timestamp=37// CHECK-NOT:          "-fmodules-prune-interval=38// CHECK-NOT:          "-fmodules-prune-after=39// CHECK:            ],40// CHECK-NEXT:       "context-hash": "[[HASH_MOD_HEADER:.*]]",41// CHECK-NEXT:       "file-deps": [42// CHECK-NEXT:         "[[PREFIX]]/module.modulemap",43// CHECK-NEXT:         "[[PREFIX]]/mod_header.h"44// CHECK-NEXT:       ],45// CHECK-NEXT:       "link-libraries": [],46// CHECK-NEXT:       "name": "ModHeader"47// CHECK-NEXT:     },48// CHECK-NEXT:     {49// CHECK-NEXT:       "clang-module-deps": [],50// CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/module.modulemap",51// CHECK-NEXT:       "command-line": [52// CHECK-NEXT:         "-cc1"53// CHECK-NOT:          "-fdebug-compilation-dir=54// CHECK-NOT:          "-fcoverage-compilation-dir=55// CHECK-NOT:          "-coverage-notes-file56// CHECK-NOT:          "-coverage-data-file57// CHECK-NOT:          "-fprofile-instrument-use-path58// CHECK-NOT:          "-dwarf-debug-flags"59// CHECK-NOT:          "-main-file-name"60// CHECK-NOT:          "-include"61// CHECK-NOT:          "-fmodules-cache-path=62// CHECK-NOT:          "-fmodules-validate-once-per-build-session"63// CHECK-NOT:          "-fbuild-session-timestamp=64// CHECK-NOT:          "-fmodules-prune-interval=65// CHECK-NOT:          "-fmodules-prune-after=66// CHECK:            ],67// CHECK-NEXT:       "context-hash": "[[HASH_MOD_TU:.*]]",68// CHECK-NEXT:       "file-deps": [69// CHECK-NEXT:         "[[PREFIX]]/module.modulemap",70// CHECK-NEXT:         "[[PREFIX]]/mod_tu.h"71// CHECK-NEXT:       ],72// CHECK-NEXT:       "link-libraries": [],73// CHECK-NEXT:       "name": "ModTU"74// CHECK-NEXT:     }75// CHECK-NEXT:   ],76// CHECK-NEXT:   "translation-units": [77// CHECK-NEXT:     {78// CHECK:            "clang-context-hash": "[[HASH_TU:.*]]",79// CHECK-NEXT:       "clang-module-deps": [80// CHECK-NEXT:         {81// CHECK-NEXT:           "context-hash": "[[HASH_MOD_HEADER]]",82// CHECK-NEXT:           "module-name": "ModHeader"83// CHECK-NEXT:         },84// CHECK-NEXT:         {85// CHECK-NEXT:           "context-hash": "[[HASH_MOD_TU]]",86// CHECK-NEXT:           "module-name": "ModTU"87// CHECK-NEXT:         }88// CHECK-NEXT:       ]89// CHECK-NEXT:       "command-line": [90// CHECK-NEXT:         "-cc1",91// CHECK-NOT:          "-fmodules-cache-path=92// CHECK-NOT:          "-fmodules-validate-once-per-build-session"93// CHECK-NOT:          "-fbuild-session-timestamp=94// CHECK-NOT:          "-fbuild-session-file=95// CHECK-NOT:          "-fmodules-prune-interval=96// CHECK-NOT:          "-fmodules-prune-after=97// CHECK:            ],98 99// Check for removed args for PCH invocations.100 101// RUN: split-file %s %t102// RUN: sed "s|DIR|%/t|g" %t/cdb-pch.json.template > %t/cdb-pch.json103// RUN: clang-scan-deps -compilation-database %t/cdb-pch.json -format experimental-full > %t/result-pch.json104// RUN: cat %t/result-pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=PCH105//106// PCH-NOT:          "-fdebug-compilation-dir="107// PCH-NOT:          "-fcoverage-compilation-dir="108// PCH-NOT:          "-coverage-notes-file109// PCH-NOT:          "-coverage-data-file110// PCH-NOT:          "-fprofile-instrument-use-path111// PCH-NOT:          "-include"112// PCH-NOT:          "-fmodules-cache-path=113// PCH-NOT:          "-fmodules-validate-once-per-build-session"114// PCH-NOT:          "-fbuild-session-timestamp=115// PCH-NOT:          "-fmodules-prune-interval=116// PCH-NOT:          "-fmodules-prune-after=117 118//--- cdb-pch.json.template119[120  {121    "directory": "DIR",122    "command": "clang -x c-header DIR/header.h -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -fdebug-compilation-dir=DIR/debug -fcoverage-compilation-dir=DIR/coverage -ftest-coverage -fprofile-instr-use=DIR/tu.profdata -o DIR/header.h.pch -serialize-diagnostics DIR/header.h.pch.diag ",123    "file": "DIR/header.h.pch"124  }125]126