Skip to content

Commit f46ef3b

Browse files
committed
Merge branch 'sycl' into oneapins
Signed-off-by: James Brodman <[email protected]>
2 parents 4877aad + f658918 commit f46ef3b

File tree

2,039 files changed

+100991
-35119
lines changed

Some content is hidden

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

2,039 files changed

+100991
-35119
lines changed

buildbot/configure.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def do_configure(args):
3838
libclc_targets_to_build = 'nvptx64--;nvptx64--nvidiacl'
3939
sycl_build_pi_cuda = 'ON'
4040

41+
# replace not append, so ARM ^ X86
42+
if args.arm:
43+
llvm_targets_to_build = 'ARM;AArch64'
44+
4145
if args.no_werror:
4246
sycl_werror = 'OFF'
4347

@@ -128,6 +132,7 @@ def main():
128132
parser.add_argument("-t", "--build-type",
129133
metavar="BUILD_TYPE", default="Release", help="build type: Debug, Release")
130134
parser.add_argument("--cuda", action='store_true', help="switch from OpenCL to CUDA")
135+
parser.add_argument("--arm", action='store_true', help="build ARM support rather than x86")
131136
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
132137
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
133138
parser.add_argument("--system-ocl", action='store_true', help="use OpenCL deps from system (no download)")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ struct EqualClangTidyError {
744744
std::vector<ClangTidyError> ClangTidyDiagnosticConsumer::take() {
745745
finalizeLastError();
746746

747-
llvm::sort(Errors, LessClangTidyError());
747+
llvm::stable_sort(Errors, LessClangTidyError());
748748
Errors.erase(std::unique(Errors.begin(), Errors.end(), EqualClangTidyError()),
749749
Errors.end());
750750
if (RemoveIncompatibleErrors)

clang-tools-extra/clang-tidy/add_new_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def write_implementation(module_path, module, namespace, check_name_camel):
136136
void %(check_name)s::check(const MatchFinder::MatchResult &Result) {
137137
// FIXME: Add callback implementation.
138138
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("x");
139-
if (MatchedDecl->getName().startswith("awesome_"))
139+
if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_"))
140140
return;
141141
diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
142142
<< MatchedDecl;

clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) {
3939
return llvm::None;
4040
const MacroInfo *MI = PP->getMacroInfo(It->first);
4141
const Token &T = MI->tokens().back();
42-
if (!T.isLiteral())
42+
if (!T.isLiteral() || !T.getLiteralData())
4343
return llvm::None;
4444
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
4545

clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,16 @@ void NotNullTerminatedResultCheck::check(
802802
while (It != PP->macro_end() && !AreSafeFunctionsWanted.hasValue()) {
803803
if (It->first->getName() == "__STDC_WANT_LIB_EXT1__") {
804804
const auto *MI = PP->getMacroInfo(It->first);
805-
const auto &T = MI->tokens().back();
806-
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
807-
llvm::APInt IntValue;
808-
ValueStr.getAsInteger(10, IntValue);
809-
AreSafeFunctionsWanted = IntValue.getZExtValue();
805+
// PP->getMacroInfo() returns nullptr if macro has no definition.
806+
if (MI) {
807+
const auto &T = MI->tokens().back();
808+
if (T.isLiteral() && T.getLiteralData()) {
809+
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
810+
llvm::APInt IntValue;
811+
ValueStr.getAsInteger(10, IntValue);
812+
AreSafeFunctionsWanted = IntValue.getZExtValue();
813+
}
814+
}
810815
}
811816

812817
++It;

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

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,11 @@ AST_MATCHER_P(QualType, isSugarFor, Matcher<QualType>, SugarMatcher) {
119119
/// \endcode
120120
///
121121
/// namedDecl(hasStdIteratorName()) matches \c I and \c CI.
122-
AST_MATCHER(NamedDecl, hasStdIteratorName) {
123-
static const char *const IteratorNames[] = {"iterator", "reverse_iterator",
124-
"const_iterator",
125-
"const_reverse_iterator"};
126-
127-
for (const char *Name : IteratorNames) {
128-
if (hasName(Name).matches(Node, Finder, Builder))
129-
return true;
130-
}
131-
return false;
122+
Matcher<NamedDecl> hasStdIteratorName() {
123+
static const StringRef IteratorNames[] = {"iterator", "reverse_iterator",
124+
"const_iterator",
125+
"const_reverse_iterator"};
126+
return hasAnyName(IteratorNames);
132127
}
133128

134129
/// Matches named declarations that have one of the standard container
@@ -143,26 +138,21 @@ AST_MATCHER(NamedDecl, hasStdIteratorName) {
143138
///
144139
/// recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
145140
/// but not \c my_vec.
146-
AST_MATCHER(NamedDecl, hasStdContainerName) {
147-
static const char *const ContainerNames[] = {
148-
"array", "deque",
149-
"forward_list", "list",
150-
"vector",
141+
Matcher<NamedDecl> hasStdContainerName() {
142+
static StringRef ContainerNames[] = {"array", "deque",
143+
"forward_list", "list",
144+
"vector",
151145

152-
"map", "multimap",
153-
"set", "multiset",
146+
"map", "multimap",
147+
"set", "multiset",
154148

155-
"unordered_map", "unordered_multimap",
156-
"unordered_set", "unordered_multiset",
149+
"unordered_map", "unordered_multimap",
150+
"unordered_set", "unordered_multiset",
157151

158-
"queue", "priority_queue",
159-
"stack"};
152+
"queue", "priority_queue",
153+
"stack"};
160154

161-
for (const char *Name : ContainerNames) {
162-
if (hasName(Name).matches(Node, Finder, Builder))
163-
return true;
164-
}
165-
return false;
155+
return hasAnyName(ContainerNames);
166156
}
167157

168158
/// Matches declarations whose declaration context is the C++ standard library

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
5353

5454
void TransformerClangTidyCheck::registerPPCallbacks(
5555
const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
56-
// Only register the IncludeInsert when some `Case` will add
57-
// includes.
58-
if (Rule && llvm::any_of(Rule->Cases, [](const RewriteRule::Case &C) {
59-
return !C.AddedIncludes.empty();
60-
}))
61-
Inserter.registerPreprocessor(PP);
56+
Inserter.registerPreprocessor(PP);
6257
}
6358

6459
void TransformerClangTidyCheck::registerMatchers(
@@ -96,13 +91,19 @@ void TransformerClangTidyCheck::check(
9691
// Associate the diagnostic with the location of the first change.
9792
DiagnosticBuilder Diag = diag((*Edits)[0].Range.getBegin(), *Explanation);
9893
for (const auto &T : *Edits)
99-
Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
100-
101-
for (const auto &I : Case.AddedIncludes) {
102-
Diag << Inserter.createMainFileIncludeInsertion(
103-
I.first,
104-
/*IsAngled=*/I.second == transformer::IncludeFormat::Angled);
105-
}
94+
switch (T.Kind) {
95+
case transformer::EditKind::Range:
96+
Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
97+
break;
98+
case transformer::EditKind::AddInclude: {
99+
StringRef FileName = T.Replacement;
100+
bool IsAngled = FileName.startswith("<") && FileName.endswith(">");
101+
Diag << Inserter.createMainFileIncludeInsertion(
102+
IsAngled ? FileName.substr(1, FileName.size() - 2) : FileName,
103+
IsAngled);
104+
break;
105+
}
106+
}
106107
}
107108

108109
void TransformerClangTidyCheck::storeOptions(

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,10 @@ class CodeCompleteFlow {
16171617

16181618
llvm::Optional<float> fuzzyScore(const CompletionCandidate &C) {
16191619
// Macros can be very spammy, so we only support prefix completion.
1620-
// We won't end up with underfull index results, as macros are sema-only.
1621-
if (C.SemaResult && C.SemaResult->Kind == CodeCompletionResult::RK_Macro &&
1620+
if (((C.SemaResult &&
1621+
C.SemaResult->Kind == CodeCompletionResult::RK_Macro) ||
1622+
(C.IndexResult &&
1623+
C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro)) &&
16221624
!C.Name.startswith_lower(Filter->pattern()))
16231625
return None;
16241626
return Filter->match(C.Name);

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,21 @@ struct TargetFinder {
355355
Flags |= Rel::Underlying; // continue with the underlying decl.
356356
} else if (const auto *DG = dyn_cast<CXXDeductionGuideDecl>(D)) {
357357
D = DG->getDeducedTemplate();
358+
} else if (const ObjCImplementationDecl *IID =
359+
dyn_cast<ObjCImplementationDecl>(D)) {
360+
// Treat ObjC{Interface,Implementation}Decl as if they were a decl/def
361+
// pair as long as the interface isn't implicit.
362+
if (const auto *CID = IID->getClassInterface())
363+
if (const auto *DD = CID->getDefinition())
364+
if (!DD->isImplicitInterfaceDecl())
365+
D = DD;
366+
} else if (const ObjCCategoryImplDecl *CID =
367+
dyn_cast<ObjCCategoryImplDecl>(D)) {
368+
// Treat ObjC{Category,CategoryImpl}Decl as if they were a decl/def pair.
369+
D = CID->getCategoryDecl();
358370
}
371+
if (!D)
372+
return;
359373

360374
if (const Decl *Pat = getTemplatePattern(D)) {
361375
assert(Pat != D);
@@ -596,6 +610,19 @@ struct TargetFinder {
596610
add(CCI->getAnyMember(), Flags);
597611
// Constructor calls contain a TypeLoc node, so we don't handle them here.
598612
}
613+
614+
void add(const TemplateArgument &Arg, RelSet Flags) {
615+
// Only used for template template arguments.
616+
// For type and non-type template arguments, SelectionTree
617+
// will hit a more specific node (e.g. a TypeLoc or a
618+
// DeclRefExpr).
619+
if (Arg.getKind() == TemplateArgument::Template ||
620+
Arg.getKind() == TemplateArgument::TemplateExpansion) {
621+
if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) {
622+
report(TD, Flags);
623+
}
624+
}
625+
}
599626
};
600627

601628
} // namespace
@@ -619,6 +646,8 @@ allTargetDecls(const ast_type_traits::DynTypedNode &N) {
619646
Finder.add(*QT, Flags);
620647
else if (const CXXCtorInitializer *CCI = N.get<CXXCtorInitializer>())
621648
Finder.add(CCI, Flags);
649+
else if (const TemplateArgumentLoc *TAL = N.get<TemplateArgumentLoc>())
650+
Finder.add(TAL->getArgument(), Flags);
622651

623652
return Finder.takeDecls();
624653
}

clang-tools-extra/clangd/ParsedAST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ParsedAST {
131131
std::unique_ptr<FrontendAction> Action;
132132
/// Tokens recorded after the preamble finished.
133133
/// - Includes all spelled tokens for the main file.
134-
/// - Includes expanded tokens produced **after** preabmle.
134+
/// - Includes expanded tokens produced **after** preamble.
135135
/// - Does not have spelled or expanded tokens for files from preamble.
136136
syntax::TokenBuffer Tokens;
137137

clang-tools-extra/clangd/RIFF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ llvm::Expected<Chunk> readChunk(llvm::StringRef &Stream) {
3333
llvm::Twine(Stream.size()));
3434
C.Data = Stream.take_front(Len);
3535
Stream = Stream.drop_front(Len);
36-
if (Len % 2 & !Stream.empty()) { // Skip padding byte.
36+
if ((Len % 2) && !Stream.empty()) { // Skip padding byte.
3737
if (Stream.front())
3838
return makeError("nonzero padding byte");
3939
Stream = Stream.drop_front();

clang-tools-extra/clangd/Selection.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ class SelectionVisitor : public RecursiveASTVisitor<SelectionVisitor> {
479479
bool TraverseTypeLoc(TypeLoc X) {
480480
return traverseNode(&X, [&] { return Base::TraverseTypeLoc(X); });
481481
}
482+
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &X) {
483+
return traverseNode(&X,
484+
[&] { return Base::TraverseTemplateArgumentLoc(X); });
485+
}
482486
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc X) {
483487
return traverseNode(
484488
&X, [&] { return Base::TraverseNestedNameSpecifierLoc(X); });

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ llvm::Optional<HighlightingKind> kindForDecl(const NamedDecl *D) {
9090
? HighlightingKind::StaticField
9191
: VD->isLocalVarDecl() ? HighlightingKind::LocalVariable
9292
: HighlightingKind::Variable;
93-
if (isa<BindingDecl>(D))
94-
return HighlightingKind::Variable;
93+
if (const auto *BD = dyn_cast<BindingDecl>(D))
94+
return BD->getDeclContext()->isFunctionOrMethod()
95+
? HighlightingKind::LocalVariable
96+
: HighlightingKind::Variable;
9597
if (isa<FunctionDecl>(D))
9698
return HighlightingKind::Function;
9799
if (isa<NamespaceDecl>(D) || isa<NamespaceAliasDecl>(D) ||
@@ -296,6 +298,18 @@ class CollectExtraHighlightings
296298
return true;
297299
}
298300

301+
bool TraverseTemplateArgumentLoc(TemplateArgumentLoc L) {
302+
switch (L.getArgument().getKind()) {
303+
case TemplateArgument::Template:
304+
case TemplateArgument::TemplateExpansion:
305+
H.addToken(L.getTemplateNameLoc(), HighlightingKind::DependentType);
306+
break;
307+
default:
308+
break;
309+
}
310+
return RecursiveASTVisitor::TraverseTemplateArgumentLoc(L);
311+
}
312+
299313
// findExplicitReferences will walk nested-name-specifiers and
300314
// find anything that can be resolved to a Decl. However, non-leaf
301315
// components of nested-name-specifiers which are dependent names

0 commit comments

Comments
 (0)