[PATCH] D148369: [DependencyScanning] Canonicalize `CodeGenOptions.RelaxAll`
Argyrios Kyrtzidis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 14 17:40:15 PDT 2023
akyrtzi updated this revision to Diff 513828.
akyrtzi added a comment.
Remove `-optimize-args` from the test invocations since it's not relevant for the test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148369/new/
https://reviews.llvm.org/D148369
Files:
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/shared-module-for-tu-and-pch.c
clang/tools/clang-scan-deps/ClangScanDeps.cpp
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===================================================================
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -226,6 +226,12 @@
llvm::cl::init(false),
llvm::cl::cat(DependencyScannerCategory));
+llvm::cl::opt<bool>
+ BriefResult("brief", llvm::cl::Optional,
+ llvm::cl::desc("Use brief dependency info output."),
+ llvm::cl::init(false),
+ llvm::cl::cat(DependencyScannerCategory));
+
} // end anonymous namespace
/// Takes the result of a dependency scan and prints error / dependency files
@@ -402,6 +408,8 @@
OS << llvm::formatv("{0:2}\n", Value(std::move(Output)));
}
+ size_t getNumModules() const { return Modules.size(); }
+
private:
struct IndexedModuleID {
ModuleID ID;
@@ -893,6 +901,11 @@
if (FD && FD->roundTripCommands(llvm::errs()))
HadErrors = true;
+ if (BriefResult && FD) {
+ llvm::outs() << "num modules: " << FD->getNumModules() << '\n';
+ return HadErrors;
+ }
+
if (Format == ScanningOutputFormat::Full)
FD->printFullOutput(llvm::outs());
else if (Format == ScanningOutputFormat::P1689)
Index: clang/test/ClangScanDeps/shared-module-for-tu-and-pch.c
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/shared-module-for-tu-and-pch.c
@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.debug.template > %t/cdb.debug.json
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.release.template > %t/cdb.release.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.debug.json -format=experimental-full -brief | FileCheck %s
+// RUN: clang-scan-deps -compilation-database %t/cdb.release.json -format=experimental-full -brief | FileCheck %s
+// CHECK: num modules: 1
+
+//--- cdb.json.debug.template
+[{
+ "directory": "DIR",
+ "file": "DIR/tu.c",
+ "command": "clang -target x86_64-apple-macosx12 -x c -fmodules -gmodules -fmodules-cache-path=DIR/cache -I DIR/include -c DIR/tu.c -o DIR/tu.o -O0 -g"
+},
+{
+ "directory": "DIR",
+ "file": "DIR/tu.prefix.h",
+ "command": "clang -target x86_64-apple-macosx12 -x c-header -fmodules -gmodules -fmodules-cache-path=DIR/cache -I DIR/include -c DIR/tu.prefix.h -o DIR/tu.pch -O0 -g"
+}]
+//--- cdb.json.release.template
+[{
+ "directory": "DIR",
+ "file": "DIR/tu.c",
+ "command": "clang -target x86_64-apple-macosx12 -x c -fmodules -gmodules -fmodules-cache-path=DIR/cache -I DIR/include -c DIR/tu.c -o DIR/tu.o -Os -g"
+},
+{
+ "directory": "DIR",
+ "file": "DIR/tu.prefix.h",
+ "command": "clang -target x86_64-apple-macosx12 -x c-header -fmodules -gmodules -fmodules-cache-path=DIR/cache -I DIR/include -c DIR/tu.prefix.h -o DIR/tu.pch -Os -g"
+}]
+
+//--- include/module.modulemap
+module Top { header "top.h" }
+//--- include/top.h
+#define TOP int
+//--- tu.c
+#include "top.h"
+TOP fn(void);
+//--- tu.prefix.h
+#include "top.h"
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -102,6 +102,7 @@
CI.getCodeGenOpts().CoverageCompilationDir.clear();
CI.getCodeGenOpts().CoverageDataFile.clear();
CI.getCodeGenOpts().CoverageNotesFile.clear();
+ CI.getCodeGenOpts().RelaxAll = false;
}
// Map output paths that affect behaviour to "-" so their existence is in the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148369.513828.patch
Type: text/x-patch
Size: 3666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230415/f7e5424c/attachment.bin>
More information about the cfe-commits
mailing list