Skip to content

Commit b93fda8

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
2 parents d7eba00 + 7a42bab commit b93fda8

File tree

796 files changed

+23184
-10832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

796 files changed

+23184
-10832
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
409409
}
410410

411411
for (auto &Check : Checks) {
412+
if (!Check->isLanguageVersionSupported(Context.getLangOpts()))
413+
continue;
412414
Check->registerMatchers(&*Finder);
413415
Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
414416
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,24 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
5353
/// constructor using the Options.get() methods below.
5454
ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
5555

56+
/// Override this to disable registering matchers and PP callbacks if an
57+
/// invalid language version is being used.
58+
///
59+
/// For example if a check is examining overloaded functions then this should
60+
/// be overridden to return false when the CPlusPlus flag is not set in
61+
/// \p LangOpts.
62+
virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const {
63+
return true;
64+
}
65+
5666
/// Override this to register ``PPCallbacks`` in the preprocessor.
5767
///
5868
/// This should be used for clang-tidy checks that analyze preprocessor-
5969
/// dependent properties, e.g. include directives and macro definitions.
6070
///
71+
/// This will only be executed if the function isLanguageVersionSupported
72+
/// returns true.
73+
///
6174
/// There are two Preprocessors to choose from that differ in how they handle
6275
/// modular #includes:
6376
/// - PP is the real Preprocessor. It doesn't walk into modular #includes and
@@ -80,6 +93,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
8093
/// "this" will be used as callback, but you can also specify other callback
8194
/// classes. Thereby, different matchers can trigger different callbacks.
8295
///
96+
/// This will only be executed if the function isLanguageVersionSupported
97+
/// returns true.
98+
///
8399
/// If you need to merge information between the different matchers, you can
84100
/// store these as members of the derived class. However, note that all
85101
/// matches occur in the order of the AST traversal.

clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void NoRecursionCheck::check(const MatchFinder::MatchResult &Result) {
264264
for (llvm::scc_iterator<CallGraph *> SCCI = llvm::scc_begin(&CG),
265265
SCCE = llvm::scc_end(&CG);
266266
SCCI != SCCE; ++SCCI) {
267-
if (!SCCI.hasLoop()) // We only care about cycles, not standalone nodes.
267+
if (!SCCI.hasCycle()) // We only care about cycles, not standalone nodes.
268268
continue;
269269
handleSCC(*SCCI);
270270
}

clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,12 @@ bool MakeSmartPtrCheck::isLanguageVersionSupported(
6868
void MakeSmartPtrCheck::registerPPCallbacks(const SourceManager &SM,
6969
Preprocessor *PP,
7070
Preprocessor *ModuleExpanderPP) {
71-
if (isLanguageVersionSupported(getLangOpts())) {
7271
Inserter = std::make_unique<utils::IncludeInserter>(SM, getLangOpts(),
7372
IncludeStyle);
7473
PP->addPPCallbacks(Inserter->CreatePPCallbacks());
75-
}
7674
}
7775

7876
void MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
79-
if (!isLanguageVersionSupported(getLangOpts()))
80-
return;
81-
8277
// Calling make_smart_ptr from within a member function of a type with a
8378
// private or protected constructor would be ill-formed.
8479
auto CanCallCtor = unless(has(ignoringImpCasts(

clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MakeSmartPtrCheck : public ClangTidyCheck {
4141
virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
4242

4343
/// Returns whether the C++ version is compatible with current check.
44-
virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
44+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
4545

4646
static const char PointerType[];
4747

clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ AST_MATCHER(CXXRecordDecl, isMoveConstructible) {
4646
}
4747
} // namespace
4848

49-
static TypeMatcher constRefType() {
50-
return lValueReferenceType(pointee(isConstQualified()));
49+
static TypeMatcher notTemplateSpecConstRefType() {
50+
return lValueReferenceType(
51+
pointee(unless(templateSpecializationType()), isConstQualified()));
5152
}
5253

5354
static TypeMatcher nonConstValueType() {
@@ -145,16 +146,18 @@ void PassByValueCheck::registerMatchers(MatchFinder *Finder) {
145146
// ParenListExpr is generated instead of a CXXConstructExpr,
146147
// filtering out templates automatically for us.
147148
withInitializer(cxxConstructExpr(
148-
has(ignoringParenImpCasts(declRefExpr(to(
149-
parmVarDecl(
150-
hasType(qualType(
151-
// Match only const-ref or a non-const value
152-
// parameters. Rvalues and const-values
153-
// shouldn't be modified.
154-
ValuesOnly ? nonConstValueType()
155-
: anyOf(constRefType(),
156-
nonConstValueType()))))
157-
.bind("Param"))))),
149+
has(ignoringParenImpCasts(declRefExpr(
150+
to(parmVarDecl(
151+
hasType(qualType(
152+
// Match only const-ref or a non-const
153+
// value parameters. Rvalues,
154+
// TemplateSpecializationValues and
155+
// const-values shouldn't be modified.
156+
ValuesOnly
157+
? nonConstValueType()
158+
: anyOf(notTemplateSpecConstRefType(),
159+
nonConstValueType()))))
160+
.bind("Param"))))),
158161
hasDeclaration(cxxConstructorDecl(
159162
isCopyConstructor(), unless(isDeleted()),
160163
hasDeclContext(

clang-tools-extra/clang-tidy/utils/LexerUtils.cpp

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

99
#include "LexerUtils.h"
10+
#include "clang/Basic/SourceManager.h"
1011

1112
namespace clang {
1213
namespace tidy {

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,6 @@ void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
394394
WorkScheduler.runWithAST("Rename", File, std::move(Action));
395395
}
396396

397-
void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
398-
bool WantFormat, Callback<FileEdits> CB) {
399-
RenameOptions Opts;
400-
Opts.WantFormat = WantFormat;
401-
Opts.AllowCrossFile = false;
402-
rename(File, Pos, NewName, Opts, std::move(CB));
403-
}
404-
405397
// May generate several candidate selections, due to SelectionTree ambiguity.
406398
// vector of pointers because GCC doesn't like non-copyable Selection.
407399
static llvm::Expected<std::vector<std::unique_ptr<Tweak::Selection>>>

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ class ClangdServer {
264264
/// highlighting them in prepare stage).
265265
void rename(PathRef File, Position Pos, llvm::StringRef NewName,
266266
const RenameOptions &Opts, Callback<FileEdits> CB);
267-
// FIXME: remove this compatibility method in favor above.
268-
void rename(PathRef File, Position Pos, llvm::StringRef NewName,
269-
bool WantFormat, Callback<FileEdits> CB);
270267

271268
struct TweakRef {
272269
std::string ID; /// ID to pass for applyTweak.

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ ParsedAST::build(std::unique_ptr<clang::CompilerInvocation> CI,
301301
});
302302
Preprocessor *PP = &Clang->getPreprocessor();
303303
for (const auto &Check : CTChecks) {
304+
if (!Check->isLanguageVersionSupported(CTContext->getLangOpts()))
305+
continue;
304306
// FIXME: the PP callbacks skip the entire preamble.
305307
// Checks that want to see #includes in the main file do not see them.
306308
Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/ADT/None.h"
2727
#include "llvm/ADT/Optional.h"
2828
#include "llvm/ADT/STLExtras.h"
29+
#include "llvm/Support/Base64.h"
2930
#include "llvm/Support/Casting.h"
3031
#include <algorithm>
3132

@@ -283,37 +284,6 @@ class CollectExtraHighlightings
283284
HighlightingsBuilder &H;
284285
};
285286

286-
// Encode binary data into base64.
287-
// This was copied from compiler-rt/lib/fuzzer/FuzzerUtil.cpp.
288-
// FIXME: Factor this out into llvm/Support?
289-
std::string encodeBase64(const llvm::SmallVectorImpl<char> &Bytes) {
290-
static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
291-
"abcdefghijklmnopqrstuvwxyz"
292-
"0123456789+/";
293-
std::string Res;
294-
size_t I;
295-
for (I = 0; I + 2 < Bytes.size(); I += 3) {
296-
uint32_t X = (Bytes[I] << 16) + (Bytes[I + 1] << 8) + Bytes[I + 2];
297-
Res += Table[(X >> 18) & 63];
298-
Res += Table[(X >> 12) & 63];
299-
Res += Table[(X >> 6) & 63];
300-
Res += Table[X & 63];
301-
}
302-
if (I + 1 == Bytes.size()) {
303-
uint32_t X = (Bytes[I] << 16);
304-
Res += Table[(X >> 18) & 63];
305-
Res += Table[(X >> 12) & 63];
306-
Res += "==";
307-
} else if (I + 2 == Bytes.size()) {
308-
uint32_t X = (Bytes[I] << 16) + (Bytes[I + 1] << 8);
309-
Res += Table[(X >> 18) & 63];
310-
Res += Table[(X >> 12) & 63];
311-
Res += Table[(X >> 6) & 63];
312-
Res += "=";
313-
}
314-
return Res;
315-
}
316-
317287
void write32be(uint32_t I, llvm::raw_ostream &OS) {
318288
std::array<char, 4> Buf;
319289
llvm::support::endian::write32be(Buf.data(), I);

0 commit comments

Comments
 (0)