Skip to content

Commit 8fd03e6

Browse files
committed
Merge from 'main' to 'sycl-web' (322 commits)
CONFLICT (modify/delete): llvm/test/ThinLTO/X86/windows-vftable.ll deleted in 2c239da and modified in HEAD. Version HEAD of llvm/test/ThinLTO/X86/windows-vftable.ll left in tree. CONFLICT (modify/delete): llvm/test/ThinLTO/X86/constructor-alias.ll deleted in 2c239da and modified in HEAD. Version HEAD of llvm/test/ThinLTO/X86/constructor-alias.ll left in tree. CONFLICT (content): Merge conflict in llvm/test/LTO/Resolution/X86/comdat-mixed-lto.ll
2 parents 5861ecf + 2c239da commit 8fd03e6

File tree

1,255 files changed

+40013
-21560
lines changed

Some content is hidden

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

1,255 files changed

+40013
-21560
lines changed

bolt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ add_subdirectory(lib)
7676
add_subdirectory(tools)
7777

7878
if (BOLT_INCLUDE_TESTS)
79-
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
79+
if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
8080
add_subdirectory(unittests)
8181
list(APPEND BOLT_TEST_DEPS BoltUnitTests)
8282
endif()

clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ static CheckResult checkDef(const clang::FunctionDecl *Def,
105105
return Result;
106106
}
107107

108+
void ConstReturnTypeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
109+
Options.store(Opts, "IgnoreMacros", IgnoreMacros);
110+
}
111+
108112
void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
109113
// Find all function definitions for which the return types are `const`
110114
// qualified, ignoring decltype types.
@@ -114,13 +118,20 @@ void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
114118
Finder->addMatcher(
115119
functionDecl(
116120
returns(allOf(isConstQualified(), unless(NonLocalConstType))),
117-
anyOf(isDefinition(), cxxMethodDecl(isPure())))
121+
anyOf(isDefinition(), cxxMethodDecl(isPure())),
122+
// Overridden functions are not actionable.
123+
unless(cxxMethodDecl(isOverride())))
118124
.bind("func"),
119125
this);
120126
}
121127

122128
void ConstReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
123129
const auto *Def = Result.Nodes.getNodeAs<FunctionDecl>("func");
130+
// Suppress the check if macros are involved.
131+
if (IgnoreMacros &&
132+
(Def->getBeginLoc().isMacroID() || Def->getEndLoc().isMacroID()))
133+
return;
134+
124135
CheckResult CR = checkDef(Def, Result);
125136
{
126137
// Clang only supports one in-flight diagnostic at a time. So, delimit the

clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ namespace readability {
2222
/// http://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html
2323
class ConstReturnTypeCheck : public ClangTidyCheck {
2424
public:
25-
using ClangTidyCheck::ClangTidyCheck;
26-
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
27-
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
25+
ConstReturnTypeCheck(StringRef Name, ClangTidyContext *Context)
26+
: ClangTidyCheck(Name, Context),
27+
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
28+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
29+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
30+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
31+
32+
private:
33+
const bool IgnoreMacros;
2834
};
2935

3036
} // namespace readability

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ struct CodeCompletionBuilder {
411411
bool IsPattern = C.SemaResult->Kind == CodeCompletionResult::RK_Pattern;
412412
getSignature(*SemaCCS, &S.Signature, &S.SnippetSuffix,
413413
&Completion.RequiredQualifier, IsPattern);
414+
if (!C.SemaResult->FunctionCanBeCall)
415+
S.SnippetSuffix.clear();
414416
S.ReturnType = getReturnType(*SemaCCS);
415417
} else if (C.IndexResult) {
416418
S.Signature = std::string(C.IndexResult->Signature);

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
465465
std::vector<std::unique_ptr<tidy::ClangTidyCheck>> CTChecks;
466466
ast_matchers::MatchFinder CTFinder;
467467
llvm::Optional<tidy::ClangTidyContext> CTContext;
468+
// Must outlive FixIncludes.
469+
auto BuildDir = VFS->getCurrentWorkingDirectory();
468470
llvm::Optional<IncludeFixer> FixIncludes;
469471
llvm::DenseMap<diag::kind, DiagnosticsEngine::Level> OverriddenSeverity;
470472
// No need to run clang-tidy or IncludeFixerif we are not going to surface
@@ -551,7 +553,6 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
551553

552554
// Add IncludeFixer which can recover diagnostics caused by missing includes
553555
// (e.g. incomplete type) and attach include insertion fixes to diagnostics.
554-
auto BuildDir = VFS->getCurrentWorkingDirectory();
555556
if (Inputs.Index && !BuildDir.getError()) {
556557
auto Style =
557558
getFormatStyleForFile(Filename, Inputs.Contents, *Inputs.TFS);

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,63 @@ TEST(CompletionTest, Snippets) {
505505
snippetSuffix("(${1:int i}, ${2:const float f})")));
506506
}
507507

508+
TEST(CompletionTest, HeuristicsForMemberFunctionCompletion) {
509+
clangd::CodeCompleteOptions Opts;
510+
Opts.EnableSnippets = true;
511+
512+
Annotations Code(R"cpp(
513+
struct Foo {
514+
static int staticMethod();
515+
int method() const;
516+
Foo() {
517+
this->$keepSnippet^
518+
$keepSnippet^
519+
Foo::$keepSnippet^
520+
}
521+
};
522+
523+
struct Derived : Foo {
524+
Derived() {
525+
Foo::$keepSnippet^
526+
}
527+
};
528+
529+
struct OtherClass {
530+
OtherClass() {
531+
Foo f;
532+
f.$keepSnippet^
533+
&Foo::$noSnippet^
534+
}
535+
};
536+
537+
int main() {
538+
Foo f;
539+
f.$keepSnippet^
540+
&Foo::$noSnippet^
541+
}
542+
)cpp");
543+
auto TU = TestTU::withCode(Code.code());
544+
545+
for (const auto &P : Code.points("noSnippet")) {
546+
auto Results = completions(TU, P, /*IndexSymbols*/ {}, Opts);
547+
EXPECT_THAT(Results.Completions,
548+
Contains(AllOf(named("method"), snippetSuffix(""))));
549+
}
550+
551+
for (const auto &P : Code.points("keepSnippet")) {
552+
auto Results = completions(TU, P, /*IndexSymbols*/ {}, Opts);
553+
EXPECT_THAT(Results.Completions,
554+
Contains(AllOf(named("method"), snippetSuffix("()"))));
555+
}
556+
557+
// static method will always keep the snippet
558+
for (const auto &P : Code.points()) {
559+
auto Results = completions(TU, P, /*IndexSymbols*/ {}, Opts);
560+
EXPECT_THAT(Results.Completions,
561+
Contains(AllOf(named("staticMethod"), snippetSuffix("()"))));
562+
}
563+
}
564+
508565
TEST(CompletionTest, NoSnippetsInUsings) {
509566
clangd::CodeCompleteOptions Opts;
510567
Opts.EnableSnippets = true;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ Changes in existing checks
171171
:doc:`readability-simplify-boolean-expr <clang-tidy/checks/readability/simplify-boolean-expr>`
172172
when using a C++23 ``if consteval`` statement.
173173

174+
- Change the behavior of :doc:`readability-const-return-type
175+
<clang-tidy/checks/readability/const-return-type>` to not
176+
warn about `const` return types in overridden functions since the derived
177+
class cannot always choose to change the function signature.
178+
179+
- Change the default behavior of :doc:`readability-const-return-type
180+
<clang-tidy/checks/readability/const-return-type>` to not
181+
warn about `const` value parameters of declarations inside macros.
182+
174183
- Improved :doc:`misc-redundant-expression <clang-tidy/checks/misc/redundant-expression>`
175184
check.
176185

clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ pointers or references to const values. For example, these are fine:
2424
const int* foo();
2525
const int& foo();
2626
const Clazz* foo();
27+
28+
29+
Options
30+
-------
31+
32+
.. option:: IgnoreMacros
33+
34+
If set to `true`, the check will not give warnings inside macros. Default
35+
is `true`.

clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,21 @@ struct Symbol {
5252
Declaration,
5353
/// A preprocessor macro, as defined in a specific location.
5454
Macro,
55-
/// A recognized symbol from the standard library, like std::string.
56-
Standard,
5755
};
5856

5957
Symbol(const Decl &D) : Storage(&D) {}
6058
Symbol(struct Macro M) : Storage(M) {}
61-
Symbol(tooling::stdlib::Symbol S) : Storage(S) {}
6259

6360
Kind kind() const { return static_cast<Kind>(Storage.index()); }
6461
bool operator==(const Symbol &RHS) const { return Storage == RHS.Storage; }
6562

6663
const Decl &declaration() const { return *std::get<Declaration>(Storage); }
6764
struct Macro macro() const { return std::get<Macro>(Storage); }
68-
tooling::stdlib::Symbol standard() const {
69-
return std::get<Standard>(Storage);
70-
}
7165

7266
private:
7367
// FIXME: Add support for macros.
7468
// Order must match Kind enum!
75-
std::variant<const Decl *, struct Macro, tooling::stdlib::Symbol> Storage;
69+
std::variant<const Decl *, struct Macro> Storage;
7670
};
7771
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Symbol &);
7872

@@ -122,9 +116,7 @@ struct Header {
122116
tooling::stdlib::Header standard() const {
123117
return std::get<Standard>(Storage);
124118
}
125-
StringRef verbatim() const {
126-
return std::get<Verbatim>(Storage);
127-
}
119+
StringRef verbatim() const { return std::get<Verbatim>(Storage); }
128120

129121
private:
130122
// Order must match Kind enum!

clang-tools-extra/include-cleaner/lib/Analysis.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ void walkUsed(llvm::ArrayRef<Decl *> ASTRoots,
2525
for (auto *Root : ASTRoots) {
2626
auto &SM = Root->getASTContext().getSourceManager();
2727
walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
28+
SymbolReference SymRef{Loc, ND, RT};
2829
if (auto SS = Recognizer(&ND)) {
2930
// FIXME: Also report forward decls from main-file, so that the caller
3031
// can decide to insert/ignore a header.
31-
return CB({Loc, Symbol(*SS), RT}, findHeaders(*SS, SM, PI));
32+
return CB(SymRef, findHeaders(*SS, SM, PI));
3233
}
3334
// FIXME: Extract locations from redecls.
34-
return CB({Loc, Symbol(ND), RT}, findHeaders(ND.getLocation(), SM, PI));
35+
return CB(SymRef, findHeaders(ND.getLocation(), SM, PI));
3536
});
3637
}
3738
for (const SymbolReference &MacroRef : MacroRefs) {

0 commit comments

Comments
 (0)