Skip to content

Commit 421b26b

Browse files
committed
Revert "origin pr"
This reverts commit a686695.
1 parent a686695 commit 421b26b

File tree

9 files changed

+1
-254
lines changed

9 files changed

+1
-254
lines changed

clang-tools-extra/clang-tidy/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
1111
add_clang_library(clangTidy STATIC
1212
ClangTidy.cpp
1313
ClangTidyCheck.cpp
14-
ClangQueryCheck.cpp
1514
ClangTidyModule.cpp
1615
ClangTidyDiagnosticConsumer.cpp
1716
ClangTidyOptions.cpp
@@ -39,7 +38,6 @@ clang_target_link_libraries(clangTidy
3938
clangSerialization
4039
clangTooling
4140
clangToolingCore
42-
clangQuery
4341
)
4442

4543
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)

clang-tools-extra/clang-tidy/ClangQueryCheck.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

clang-tools-extra/clang-tidy/ClangQueryCheck.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "ClangTidy.h"
18-
#include "ClangQueryCheck.h"
1918
#include "ClangTidyCheck.h"
2019
#include "ClangTidyDiagnosticConsumer.h"
2120
#include "ClangTidyModuleRegistry.h"
@@ -351,13 +350,6 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
351350
std::unique_ptr<ClangTidyModule> Module = E.instantiate();
352351
Module->addCheckFactories(*CheckFactories);
353352
}
354-
355-
for (const auto &[k, v] : Context.getOptions().ClangQueryChecks) {
356-
CheckFactories->registerCheckFactory(k, [v](StringRef Name,
357-
ClangTidyContext *Context) {
358-
return std::make_unique<misc::ClangQueryCheck>(Name, Context, v.Matchers);
359-
});
360-
}
361353
}
362354

363355
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "ClangTidyOptions.h"
10-
#include "../clang-query/Query.h"
11-
#include "../clang-query/QueryParser.h"
1210
#include "ClangTidyModuleRegistry.h"
1311
#include "clang/Basic/LLVM.h"
1412
#include "llvm/ADT/SmallString.h"
@@ -128,83 +126,6 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
128126
}
129127
}
130128

131-
std::vector<clang::ast_matchers::dynamic::DynTypedMatcher>
132-
processQuerySource(IO &IO, StringRef SourceRef,
133-
clang::query::QuerySession &QS) {
134-
namespace query = clang::query;
135-
std::vector<clang::ast_matchers::dynamic::DynTypedMatcher> Matchers;
136-
137-
while (!SourceRef.empty()) {
138-
query::QueryRef Q = query::QueryParser::parse(SourceRef, QS);
139-
switch (Q->Kind) {
140-
case query::QK_Match: {
141-
const auto &MatchQuerry = llvm::cast<query::MatchQuery>(*Q);
142-
Matchers.push_back(MatchQuerry.Matcher);
143-
break;
144-
}
145-
case query::QK_Let: {
146-
const auto &LetQuerry = llvm::cast<query::LetQuery>(*Q);
147-
LetQuerry.run(llvm::errs(), QS);
148-
break;
149-
}
150-
case query::QK_Invalid: {
151-
const auto &InvalidQuerry = llvm::cast<query::InvalidQuery>(*Q);
152-
for (const auto &Line : llvm::split(InvalidQuerry.ErrStr, "\n")) {
153-
IO.setError(Line);
154-
}
155-
break;
156-
}
157-
// FIXME FileQuerry should also be supported, but what to do with relative
158-
// paths?
159-
case query::QK_File:
160-
case query::QK_DisableOutputKind:
161-
case query::QK_EnableOutputKind:
162-
case query::QK_SetOutputKind:
163-
case query::QK_SetTraversalKind:
164-
case query::QK_Help:
165-
case query::QK_NoOp:
166-
case query::QK_Quit:
167-
case query::QK_SetBool: {
168-
IO.setError("unsupported querry kind");
169-
}
170-
}
171-
SourceRef = Q->RemainingContent;
172-
}
173-
174-
return Matchers;
175-
}
176-
177-
template <>
178-
void yamlize(IO &IO, ClangTidyOptions::QueryCheckMap &Val, bool,
179-
EmptyContext &Ctx) {
180-
IO.beginMapping();
181-
if (IO.outputting()) {
182-
for (auto &[k, v] : Val) {
183-
IO.mapRequired(k.data(), v);
184-
}
185-
} else {
186-
for (StringRef Key : IO.keys()) {
187-
IO.mapRequired(Key.data(), Val[Key]);
188-
}
189-
}
190-
IO.endMapping();
191-
}
192-
193-
template <>
194-
void yamlize(IO &IO, ClangTidyOptions::QueryCheckValue &Val, bool,
195-
EmptyContext &Ctx) {
196-
if (IO.outputting()) {
197-
StringRef SourceRef = Val.Source;
198-
IO.blockScalarString(SourceRef);
199-
} else {
200-
StringRef SourceRef;
201-
IO.blockScalarString(SourceRef);
202-
Val.Source = SourceRef;
203-
clang::query::QuerySession QS({});
204-
Val.Matchers = processQuerySource(IO, SourceRef, QS);
205-
}
206-
}
207-
208129
struct ChecksVariant {
209130
std::optional<std::string> AsString;
210131
std::optional<std::vector<std::string>> AsVector;
@@ -260,7 +181,6 @@ template <> struct MappingTraits<ClangTidyOptions> {
260181
IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
261182
IO.mapOptional("UseColor", Options.UseColor);
262183
IO.mapOptional("SystemHeaders", Options.SystemHeaders);
263-
IO.mapOptional("ClangQueryChecks", Options.ClangQueryChecks);
264184
}
265185
};
266186

@@ -329,10 +249,6 @@ ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
329249
ClangTidyValue(KeyValue.getValue().Value,
330250
KeyValue.getValue().Priority + Order));
331251
}
332-
333-
for (const auto &KeyValue : Other.ClangQueryChecks) {
334-
ClangQueryChecks.insert_or_assign(KeyValue.getKey(), KeyValue.getValue());
335-
}
336252
return *this;
337253
}
338254

clang-tools-extra/clang-tidy/ClangTidyOptions.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
1111

12-
#include "clang/ASTMatchers/Dynamic/VariantValue.h"
1312
#include "llvm/ADT/IntrusiveRefCntPtr.h"
1413
#include "llvm/ADT/SmallString.h"
1514
#include "llvm/ADT/StringMap.h"
@@ -127,15 +126,8 @@ struct ClangTidyOptions {
127126
using StringPair = std::pair<std::string, std::string>;
128127
using OptionMap = llvm::StringMap<ClangTidyValue>;
129128

130-
struct QueryCheckValue {
131-
std::string Source;
132-
std::vector<ast_matchers::dynamic::DynTypedMatcher> Matchers;
133-
};
134-
using QueryCheckMap = llvm::StringMap<QueryCheckValue>;
135-
136129
/// Key-value mapping used to store check-specific options.
137130
OptionMap CheckOptions;
138-
QueryCheckMap ClangQueryChecks;
139131

140132
using ArgList = std::vector<std::string>;
141133

clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ Configuration files:
6060
Checks - Same as '--checks'. Additionally, the list of
6161
globs can be specified as a list instead of a
6262
string.
63-
ClangQueryChecks - List of key-value pairs. Key specifies a name
64-
of the new check and value specifies a list
65-
of matchers in the form of clang-query
66-
syntax. Example:
67-
ClangQueryChecks:
68-
custom-check: |
69-
let matcher varDecl(
70-
hasTypeLoc(
71-
typeLoc().bind("Custom message")
72-
)
73-
)
74-
match matcher
7563
ExcludeHeaderFilterRegex - Same as '--exclude-header-filter'.
7664
ExtraArgs - Same as '--extra-arg'.
7765
ExtraArgsBefore - Same as '--extra-arg-before'.
@@ -495,8 +483,7 @@ static StringRef closest(StringRef Value, const StringSet<> &Allowed) {
495483
return Closest;
496484
}
497485

498-
static constexpr llvm::StringLiteral VerifyConfigWarningEnd =
499-
" [-verify-config]\n";
486+
static constexpr StringLiteral VerifyConfigWarningEnd = " [-verify-config]\n";
500487

501488
static bool verifyChecks(const StringSet<> &AllChecks, StringRef CheckGlob,
502489
StringRef Source) {

clang-tools-extra/docs/clang-tidy/index.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,6 @@ An overview of all the command-line options:
292292
Checks - Same as '--checks'. Additionally, the list of
293293
globs can be specified as a list instead of a
294294
string.
295-
ClangQueryChecks - List of key-value pairs. Key specifies a name
296-
of the new check and value specifies a list
297-
of matchers in the form of clang-query
298-
syntax. Example:
299-
ClangQueryChecks:
300-
custom-check: |
301-
let matcher varDecl(
302-
hasTypeLoc(
303-
typeLoc().bind("Custom message")
304-
)
305-
)
306-
match matcher
307295
ExcludeHeaderFilterRegex - Same as '--exclude-header-filter'.
308296
ExtraArgs - Same as '--extra-arg'.
309297
ExtraArgsBefore - Same as '--extra-arg-before'.

clang-tools-extra/test/clang-tidy/infrastructure/query-checks.cpp

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)