Skip to content

Commit 9c2387b

Browse files
author
Pavel V Chupin
committed
Merge from 'main' to 'sycl-web' (intel#67)
CONFLICT (content): Merge conflict in clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
2 parents bea9b4d + 4fd05e0 commit 9c2387b

File tree

295 files changed

+5636
-1570
lines changed

Some content is hidden

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

295 files changed

+5636
-1570
lines changed

clang-tools-extra/clang-tidy/utils/Matchers.h

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,76 @@ AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isPointerToConst) {
4949
return pointerType(pointee(qualType(isConstQualified())));
5050
}
5151

52-
AST_MATCHER_P(NamedDecl, matchesAnyListedName, std::vector<std::string>,
53-
NameList) {
54-
return llvm::any_of(NameList, [&Node](const std::string &Name) {
55-
return llvm::Regex(Name).match(Node.getName());
52+
// A matcher implementation that matches a list of type name regular expressions
53+
// against a NamedDecl. If a regular expression contains the substring "::"
54+
// matching will occur against the qualified name, otherwise only the typename.
55+
class MatchesAnyListedNameMatcher
56+
: public ast_matchers::internal::MatcherInterface<NamedDecl> {
57+
public:
58+
explicit MatchesAnyListedNameMatcher(llvm::ArrayRef<std::string> NameList) {
59+
std::transform(
60+
NameList.begin(), NameList.end(), std::back_inserter(NameMatchers),
61+
[](const llvm::StringRef Name) { return NameMatcher(Name); });
62+
}
63+
bool matches(
64+
const NamedDecl &Node, ast_matchers::internal::ASTMatchFinder *Finder,
65+
ast_matchers::internal::BoundNodesTreeBuilder *Builder) const override {
66+
return llvm::any_of(NameMatchers, [&Node](const NameMatcher &NM) {
67+
return NM.match(Node);
5668
});
69+
}
70+
71+
private:
72+
class NameMatcher {
73+
llvm::Regex Regex;
74+
enum class MatchMode {
75+
// Match against the unqualified name because the regular expression
76+
// does not contain ":".
77+
MatchUnqualified,
78+
// Match against the qualified name because the regular expression
79+
// contains ":" suggesting name and namespace should be matched.
80+
MatchQualified,
81+
// Match against the fully qualified name because the regular expression
82+
// starts with ":".
83+
MatchFullyQualified,
84+
};
85+
MatchMode Mode;
86+
87+
public:
88+
NameMatcher(const llvm::StringRef Regex)
89+
: Regex(Regex), Mode(determineMatchMode(Regex)) {}
90+
91+
bool match(const NamedDecl &ND) const {
92+
switch (Mode) {
93+
case MatchMode::MatchQualified:
94+
return Regex.match(ND.getQualifiedNameAsString());
95+
case MatchMode::MatchFullyQualified:
96+
return Regex.match("::" + ND.getQualifiedNameAsString());
97+
default:
98+
return Regex.match(ND.getName());
99+
}
100+
}
101+
102+
private:
103+
MatchMode determineMatchMode(llvm::StringRef Regex) {
104+
if (Regex.startswith(":") || Regex.startswith("^:")) {
105+
return MatchMode::MatchFullyQualified;
106+
}
107+
return Regex.contains(":") ? MatchMode::MatchQualified
108+
: MatchMode::MatchUnqualified;
109+
}
110+
};
111+
112+
std::vector<NameMatcher> NameMatchers;
113+
};
114+
115+
// Returns a matcher that matches NamedDecl's against a list of provided regular
116+
// expressions. If a regular expression contains starts ':' the NamedDecl's
117+
// qualified name will be used for matching, otherwise its name will be used.
118+
inline ::clang::ast_matchers::internal::Matcher<NamedDecl>
119+
matchesAnyListedName(llvm::ArrayRef<std::string> NameList) {
120+
return ::clang::ast_matchers::internal::makeMatcher(
121+
new MatchesAnyListedNameMatcher(NameList));
57122
}
58123

59124
} // namespace matchers

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ prepareCompilerInstance(std::unique_ptr<clang::CompilerInvocation> CI,
118118
VFS = VFSWithRemapping;
119119
Clang->createFileManager(VFS);
120120

121-
Clang->setTarget(TargetInfo::CreateTargetInfo(
122-
Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
123-
if (!Clang->hasTarget())
121+
if (!Clang->createTarget())
124122
return nullptr;
125123

126124
// RemappedFileBuffers will handle the lifetime of the Buffer pointer,

clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ Options
6262

6363
.. option:: CheckImplicitCasts
6464

65-
If `true`, enables detection of implicit casts. Default is `true`.
65+
If `true`, enables detection of implicit casts. Default is `false`.

clang-tools-extra/docs/clang-tidy/checks/performance-for-range-copy.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ Options
3131
A semicolon-separated list of names of types allowed to be copied in each
3232
iteration. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches
3333
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default
34-
is empty.
34+
is empty. If a name in the list contains the sequence `::` it is matched
35+
against the qualified typename (i.e. `namespace::Type`, otherwise it is
36+
matched against only the type name (i.e. `Type`).

clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ Options
4343

4444
A semicolon-separated list of names of types allowed to be initialized by
4545
copying. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches
46-
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The
47-
default is empty.
46+
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default
47+
is empty. If a name in the list contains the sequence `::` it is matched
48+
against the qualified typename (i.e. `namespace::Type`, otherwise it is
49+
matched against only the type name (i.e. `Type`).

clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-value-param.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ Options
6666

6767
A semicolon-separated list of names of types allowed to be passed by value.
6868
Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches every type
69-
with suffix `Ref`, `ref`, `Reference` and `reference`. The default is empty.
69+
with suffix `Ref`, `ref`, `Reference` and `reference`. The default is
70+
empty. If a name in the list contains the sequence `::` it is matched against
71+
the qualified typename (i.e. `namespace::Type`, otherwise it is matched
72+
against only the type name (i.e. `Type`).

clang-tools-extra/test/clang-tidy/checkers/performance-for-range-copy-allowed-types.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %check_clang_tidy %s performance-for-range-copy %t -- \
2-
// RUN: -config="{CheckOptions: [{key: performance-for-range-copy.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" \
2+
// RUN: -config="{CheckOptions: [{key: performance-for-range-copy.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$;qualified::Type;::fully::QualifiedType'}]}" \
33
// RUN: -- -fno-delayed-template-parsing
44

55
template <typename T>
@@ -63,6 +63,18 @@ template <typename T> struct SomeComplexTemplate {
6363

6464
typedef SomeComplexTemplate<int> NotTooComplexRef;
6565

66+
namespace qualified {
67+
struct Type {
68+
~Type();
69+
};
70+
} // namespace qualified
71+
72+
namespace fully {
73+
struct QualifiedType {
74+
~QualifiedType();
75+
};
76+
} // namespace fully
77+
6678
void negativeSmartPointer() {
6779
for (auto P : View<Iterator<SmartPointer>>()) {
6880
auto P2 = P;
@@ -124,3 +136,23 @@ void negativeNotTooComplexRef() {
124136
auto R2 = R;
125137
}
126138
}
139+
140+
void negativeQualified() {
141+
for (auto Q : View<Iterator<qualified::Type>>()) {
142+
auto Q2 = Q;
143+
}
144+
using qualified::Type;
145+
for (auto Q : View<Iterator<Type>>()) {
146+
auto Q2 = Q;
147+
}
148+
}
149+
150+
void negativeFullyQualified() {
151+
for (auto Q : View<Iterator<fully::QualifiedType>>()) {
152+
auto Q2 = Q;
153+
}
154+
using fully::QualifiedType;
155+
for (auto Q : View<Iterator<QualifiedType>>()) {
156+
auto Q2 = Q;
157+
}
158+
}

clang/include/clang/Basic/Builtins.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,9 +1636,6 @@ LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES)
16361636
BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
16371637
BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
16381638

1639-
// OpenMP 4.0
1640-
LANGBUILTIN(omp_is_initial_device, "i", "nc", OMP_LANG)
1641-
16421639
// CUDA/HIP
16431640
LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG)
16441641

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8232,6 +8232,9 @@ def err_atomic_op_needs_non_const_pointer : Error<
82328232
def err_atomic_op_needs_trivial_copy : Error<
82338233
"address argument to atomic operation must be a pointer to a "
82348234
"trivially-copyable type (%0 invalid)">;
8235+
def err_atomic_op_needs_atomic_int_ptr_or_fp : Error<
8236+
"address argument to atomic operation must be a pointer to %select{|atomic }0"
8237+
"integer, pointer or supported floating point type (%1 invalid)">;
82358238
def err_atomic_op_needs_atomic_int_or_ptr : Error<
82368239
"address argument to atomic operation must be a pointer to %select{|atomic }0"
82378240
"integer or pointer (%1 invalid)">;

clang/include/clang/Index/DeclOccurrence.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@
99
#ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
1010
#define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
1111

12+
#include "clang/AST/DeclBase.h"
1213
#include "clang/Basic/LLVM.h"
1314
#include "clang/Index/IndexSymbol.h"
15+
#include "clang/Lex/MacroInfo.h"
1416
#include "llvm/ADT/ArrayRef.h"
17+
#include "llvm/ADT/PointerUnion.h"
1518
#include "llvm/ADT/SmallVector.h"
1619

1720
namespace clang {
18-
class Decl;
19-
2021
namespace index {
2122

2223
struct DeclOccurrence {
2324
SymbolRoleSet Roles;
2425
unsigned Offset;
25-
const Decl *Dcl;
26+
llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro;
27+
const IdentifierInfo *MacroName = nullptr;
2628
SmallVector<SymbolRelation, 3> Relations;
2729

2830
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
2931
ArrayRef<SymbolRelation> Relations)
30-
: Roles(R), Offset(Offset), Dcl(D),
32+
: Roles(R), Offset(Offset), DeclOrMacro(D),
3133
Relations(Relations.begin(), Relations.end()) {}
34+
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
35+
const MacroInfo *MI)
36+
: Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}
3237

3338
friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
3439
return LHS.Offset < RHS.Offset;

0 commit comments

Comments
 (0)