[PATCH] D158157: [clang-tidy] Disable implicit search for a compilation db in some tests

Justin Bogner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 17 01:31:35 PDT 2023


bogner created this revision.
bogner added reviewers: njames93, PiotrZSL, carlosgalvezp.
Herald added subscribers: xazax.hun, mcrosier.
Herald added a project: All.
bogner requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

These tests were failing for me on windows with a very curious error:

  error: argument unused during compilation: '/Zc:preprocessor'

It turns out that they were walking up the directory structure and
finding the compilation DB in my top level llvm-project directory.

Add `--` to the ends of the clang-tidy command lines so that they
don't go looking for random compilation databases. Also replace args
specified with `-extra-arg` with directly specifying them to the
FixedCompilationDatabase.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158157

Files:
  clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-pp-no-crash.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-case-violation.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-multiple-TUs.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/use-color.cpp
@@ -5,9 +5,9 @@
 // RUN: clang-tidy -config='UseColor: false' -dump-config | FileCheck -check-prefix=CHECK-CONFIG-NO-COLOR %s
 // RUN: clang-tidy -help | FileCheck -check-prefix=CHECK-OPT-PRESENT %s
 
-// RUN: clang-tidy -checks='-*, modernize-use-override' -extra-arg=-std=c++11 -use-color=false %s | FileCheck -check-prefix=CHECK-NO-COLOR %s
-// RUN: clang-tidy -checks='-*, modernize-use-override' -extra-arg=-std=c++11 %s | FileCheck -check-prefix=CHECK-NO-COLOR %s
-// RUN: clang-tidy -checks='-*, modernize-use-override' -extra-arg=-std=c++11 -use-color %s | FileCheck -check-prefix=CHECK-COLOR %s
+// RUN: clang-tidy -checks='-*, modernize-use-override' -use-color=false %s -- -std=c++11 | FileCheck -check-prefix=CHECK-NO-COLOR %s
+// RUN: clang-tidy -checks='-*, modernize-use-override' %s -- -std=c++11 | FileCheck -check-prefix=CHECK-NO-COLOR %s
+// RUN: clang-tidy -checks='-*, modernize-use-override' -use-color %s -- -std=c++11 | FileCheck -check-prefix=CHECK-COLOR %s
 
 // CHECK-NOT: UseColor
 // CHECK-CONFIG-NO-COLOR: UseColor: false
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-multiple-TUs.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-multiple-TUs.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-multiple-TUs.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %S/Inputs/nolintbeginend/1st-translation-unit.cpp %S/Inputs/nolintbeginend/2nd-translation-unit.cpp --checks='-*,google-explicit-constructor' 2>&1 | FileCheck %s
+// RUN: clang-tidy %S/Inputs/nolintbeginend/1st-translation-unit.cpp %S/Inputs/nolintbeginend/2nd-translation-unit.cpp --checks='-*,google-explicit-constructor' -- 2>&1 | FileCheck %s
 
 // CHECK-NOT: 1st-translation-unit.cpp:2:11: warning: single-argument constructors must be marked explicit
 // CHECK: 1st-translation-unit.cpp:5:11: warning: single-argument constructors must be marked explicit
Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-case-violation.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-case-violation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-case-violation.cpp
@@ -5,7 +5,7 @@
 // RUN:   readability-identifier-naming.ClassCase: UUPER_CASE, \
 // RUN:   readability-identifier-naming.StructCase: CAMEL, \
 // RUN:   readability-identifier-naming.EnumCase: AnY_cASe, \
-// RUN:   }}" 2>&1 | FileCheck %s --implicit-check-not="{{warning|error}}:"
+// RUN:   }}" -- 2>&1 | FileCheck %s --implicit-check-not="{{warning|error}}:"
 
 // CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'? [clang-tidy-config]
 // CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'? [clang-tidy-config]
Index: clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-pp-no-crash.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-pp-no-crash.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-pp-no-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks=-*,readability-else-after-return
+// RUN: clang-tidy %s -checks=-*,readability-else-after-return --
 
 // We aren't concerned about the output here, just want to ensure clang-tidy doesn't crash.
 void foo() {
Index: clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
-// RUN: clang-tidy --extra-arg='-std=c++17' --extra-arg='-faligned-allocation' -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s
-// RUN: clang-tidy --extra-arg='-std=c++20' --extra-arg='-faligned-allocation' -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s
+// RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation
+// RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation
 
 struct alignas(128) Vector {
   char Elems[128];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158157.551041.patch
Type: text/x-patch
Size: 4951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230817/38f9e59a/attachment.bin>


More information about the cfe-commits mailing list