[PATCH] D81424: Driver: Accept multiple --config options if filenames are the same

Tom Stellard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 12:40:14 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd970ab63e22e: Driver: Accept multiple --config options if filenames are the same (authored by tstellar).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81424/new/

https://reviews.llvm.org/D81424

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file.c


Index: clang/test/Driver/config-file.c
===================================================================
--- clang/test/Driver/config-file.c
+++ clang/test/Driver/config-file.c
@@ -71,3 +71,8 @@
 // RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir=%S/Inputs/config2 --config config-4 -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-PRECEDENCE
 // CHECK-PRECEDENCE: Configuration file: {{.*}}Inputs{{.}}config2{{.}}config-4.cfg
 // CHECK-PRECEDENCE: -Wall
+
+
+//--- Duplicate --config options are allowed if the value is the same
+// RUN: %clang --config-system-dir=%S/Inputs/config --config-user-dir=%S/Inputs/config2 --config config-4 --config config-4 -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-SAME-CONFIG
+// CHECK-SAME-CONFIG: Configuration file: {{.*}}Inputs{{.}}config2{{.}}config-4.cfg
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -833,8 +833,12 @@
     std::vector<std::string> ConfigFiles =
         CLOptions->getAllArgValues(options::OPT_config);
     if (ConfigFiles.size() > 1) {
-      Diag(diag::err_drv_duplicate_config);
-      return true;
+      if (!std::all_of(
+              ConfigFiles.begin(), ConfigFiles.end(),
+              [ConfigFiles](std::string s) { return s == ConfigFiles[0]; })) {
+        Diag(diag::err_drv_duplicate_config);
+        return true;
+      }
     }
 
     if (!ConfigFiles.empty()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81424.271170.patch
Type: text/x-patch
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200616/f503aff9/attachment.bin>


More information about the cfe-commits mailing list