This revision was automatically updated to reflect the committed changes. Closed by commit rG5b6c08379b43: [clang][deps] Reset some benign codegen options (authored by jansvoboda11).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112923/new/ https://reviews.llvm.org/D112923 Files: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template clang/test/ClangScanDeps/removed-args.c Index: clang/test/ClangScanDeps/removed-args.c =================================================================== --- clang/test/ClangScanDeps/removed-args.c +++ clang/test/ClangScanDeps/removed-args.c @@ -1,6 +1,8 @@ // Some command-line arguments used for compiling translation units are not -// compatible with the semantics of modules and should be removed. In this test -// case, the command-lines for modules should drop the '-include' argument. +// compatible with the semantics of modules or are likely to differ between +// identical modules discovered from different translation units. This test +// checks such arguments are removed from the command-lines: '-include', +// '-dwarf-debug-flag' and '-main-file-name'. // RUN: rm -rf %t && mkdir %t // RUN: cp %S/Inputs/removed-args/* %t @@ -18,6 +20,8 @@ // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap", // CHECK-NEXT: "command-line": [ // CHECK-NEXT: "-cc1" +// CHECK-NOT: "-dwarf-debug-flags" +// CHECK-NOT: "-main-file-name" // CHECK-NOT: "-include" // CHECK: ], // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER:.*]]", Index: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template =================================================================== --- clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template +++ clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template @@ -1,7 +1,7 @@ [ { "directory": "DIR", - "command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -o DIR/tu.o", + "command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o", "file": "DIR/tu.c" } ] Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -37,9 +37,13 @@ CI.getLangOpts()->resetNonModularOptions(); CI.getPreprocessorOpts().resetNonModularOptions(); - // Remove options incompatible with explicit module build. + // Remove options incompatible with explicit module build or are likely to + // differ between identical modules discovered from different translation + // units. CI.getFrontendOpts().Inputs.clear(); CI.getFrontendOpts().OutputFile.clear(); + CI.getCodeGenOpts().MainFileName.clear(); + CI.getCodeGenOpts().DwarfDebugFlags.clear(); CI.getFrontendOpts().ProgramAction = frontend::GenerateModule; CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
Index: clang/test/ClangScanDeps/removed-args.c =================================================================== --- clang/test/ClangScanDeps/removed-args.c +++ clang/test/ClangScanDeps/removed-args.c @@ -1,6 +1,8 @@ // Some command-line arguments used for compiling translation units are not -// compatible with the semantics of modules and should be removed. In this test -// case, the command-lines for modules should drop the '-include' argument. +// compatible with the semantics of modules or are likely to differ between +// identical modules discovered from different translation units. This test +// checks such arguments are removed from the command-lines: '-include', +// '-dwarf-debug-flag' and '-main-file-name'. // RUN: rm -rf %t && mkdir %t // RUN: cp %S/Inputs/removed-args/* %t @@ -18,6 +20,8 @@ // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap", // CHECK-NEXT: "command-line": [ // CHECK-NEXT: "-cc1" +// CHECK-NOT: "-dwarf-debug-flags" +// CHECK-NOT: "-main-file-name" // CHECK-NOT: "-include" // CHECK: ], // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER:.*]]", Index: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template =================================================================== --- clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template +++ clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template @@ -1,7 +1,7 @@ [ { "directory": "DIR", - "command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -o DIR/tu.o", + "command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o", "file": "DIR/tu.c" } ] Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -37,9 +37,13 @@ CI.getLangOpts()->resetNonModularOptions(); CI.getPreprocessorOpts().resetNonModularOptions(); - // Remove options incompatible with explicit module build. + // Remove options incompatible with explicit module build or are likely to + // differ between identical modules discovered from different translation + // units. CI.getFrontendOpts().Inputs.clear(); CI.getFrontendOpts().OutputFile.clear(); + CI.getCodeGenOpts().MainFileName.clear(); + CI.getCodeGenOpts().DwarfDebugFlags.clear(); CI.getFrontendOpts().ProgramAction = frontend::GenerateModule; CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits