[PATCH] D73120: [Clang] Alternate fix for "expansion of response files in -Wp after integrated-cc1 change"
Alexandre Ganea via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 22 13:55:09 PST 2020
This revision was automatically updated to reflect the committed changes.
aganea marked an inline comment as done.
Closed by commit rG68d7f06092e5: Clang] Fix expansion of response files in -Wp after integrated-cc1 change (authored by aganea).
Changed prior to commit:
https://reviews.llvm.org/D73120?vs=239420&id=239687#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73120/new/
https://reviews.llvm.org/D73120
Files:
clang/include/clang/Driver/Driver.h
clang/test/Driver/Wp-args.c
clang/tools/driver/driver.cpp
Index: clang/tools/driver/driver.cpp
===================================================================
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -241,8 +241,6 @@
*NumberSignPtr = '=';
}
-static int ExecuteCC1Tool(ArrayRef<const char *> argv);
-
static void SetBackdoorDriverOutputsFromEnvVars(Driver &TheDriver) {
// Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
@@ -313,21 +311,27 @@
TheDriver.setInstalledDir(InstalledPathParent);
}
-static int ExecuteCC1Tool(ArrayRef<const char *> argv) {
+static int ExecuteCC1Tool(SmallVectorImpl<const char *> &ArgV) {
// If we call the cc1 tool from the clangDriver library (through
// Driver::CC1Main), we need to clean up the options usage count. The options
// are currently global, and they might have been used previously by the
// driver.
llvm::cl::ResetAllOptionOccurrences();
- StringRef Tool = argv[1];
- void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
+
+ llvm::BumpPtrAllocator A;
+ llvm::StringSaver Saver(A);
+ llvm::cl::ExpandResponseFiles(Saver, &llvm::cl::TokenizeGNUCommandLine, ArgV,
+ /*MarkEOLs=*/false);
+ StringRef Tool = ArgV[1];
+ void *GetExecutablePathVP = (void *)(intptr_t)GetExecutablePath;
if (Tool == "-cc1")
- return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
+ return cc1_main(makeArrayRef(ArgV).slice(2), ArgV[0], GetExecutablePathVP);
if (Tool == "-cc1as")
- return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
+ return cc1as_main(makeArrayRef(ArgV).slice(2), ArgV[0],
+ GetExecutablePathVP);
if (Tool == "-cc1gen-reproducer")
- return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
-
+ return cc1gen_reproducer_main(makeArrayRef(ArgV).slice(2), ArgV[0],
+ GetExecutablePathVP);
// Reject unknown tools.
llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
<< "Valid tools include '-cc1' and '-cc1as'.\n";
Index: clang/test/Driver/Wp-args.c
===================================================================
--- clang/test/Driver/Wp-args.c
+++ clang/test/Driver/Wp-args.c
@@ -19,3 +19,13 @@
// MMD: "-cc1"
// MMD-NOT: -MMD
// MMD: "-dependency-file" "Wp-args.d"
+
+// Ensure response files are properly expanded with -Wp
+// RUN: echo -DTEST > %t.rsp
+// RUN: %clang -Wp,@%t.rsp -E %s | FileCheck -check-prefix RSP %s
+
+#ifdef TEST
+void foo();
+#endif
+
+// RSP: foo()
Index: clang/include/clang/Driver/Driver.h
===================================================================
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -208,7 +208,7 @@
/// When the clangDriver lib is used through clang.exe, this provides a
/// shortcut for executing the -cc1 command-line directly, in the same
/// process.
- typedef int (*CC1ToolFunc)(ArrayRef<const char *> argv);
+ typedef int (*CC1ToolFunc)(SmallVectorImpl<const char *> &ArgV);
CC1ToolFunc CC1Main = nullptr;
private:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73120.239687.patch
Type: text/x-patch
Size: 3156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200122/6560c5ee/attachment.bin>
More information about the cfe-commits
mailing list