Skip to content

Commit 053de53

Browse files
authored
Merge branch 'main' into hgh/libcxx/nodiscard-to-string_view
2 parents f2913ca + 840a43b commit 053de53

File tree

543 files changed

+19646
-10776
lines changed

Some content is hidden

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

543 files changed

+19646
-10776
lines changed

.ci/premerge_advisor_explain.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ def main(
7979
pr_number: The number of the PR associated with this run.
8080
return_code: The numerical return code of ninja/CMake.
8181
"""
82-
if return_code == 0:
83-
with open("comment", "w") as comment_file_handle:
84-
comment = get_comment(
85-
github_token,
86-
pr_number,
87-
":white_check_mark: With the latest revision this PR passed "
88-
"the premerge checks.",
89-
)
90-
if "id" in comment:
91-
json.dump([comment], comment_file_handle)
9282
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
9383
build_log_files
9484
)
@@ -105,34 +95,42 @@ def main(
10595
explanation_request["failures"].append(
10696
{"name": name, "message": failure_messsage}
10797
)
108-
else:
98+
elif return_code != 0:
10999
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
110100
for name, failure_message in ninja_failures:
111101
explanation_request["failures"].append(
112102
{"name": name, "message": failure_message}
113103
)
114-
advisor_response = requests.get(
115-
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
104+
comments = []
105+
advisor_explanations = []
106+
if return_code != 0:
107+
advisor_response = requests.get(
108+
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
109+
)
110+
if advisor_response.status_code == 200:
111+
print(advisor_response.json())
112+
advisor_explanations = advisor_response.json()
113+
else:
114+
print(advisor_response.reason)
115+
comments.append(
116+
get_comment(
117+
github_token,
118+
pr_number,
119+
generate_test_report_lib.generate_report(
120+
generate_test_report_lib.compute_platform_title(),
121+
return_code,
122+
junit_objects,
123+
ninja_logs,
124+
failure_explanations_list=advisor_explanations,
125+
),
126+
)
116127
)
117-
if advisor_response.status_code == 200:
118-
print(advisor_response.json())
119-
comments = [
120-
get_comment(
121-
github_token,
122-
pr_number,
123-
generate_test_report_lib.generate_report(
124-
generate_test_report_lib.compute_platform_title(),
125-
return_code,
126-
junit_objects,
127-
ninja_logs,
128-
failure_explanations_list=advisor_response.json(),
129-
),
130-
)
131-
]
132-
with open("comments", "w") as comment_file_handle:
133-
json.dump(comments, comment_file_handle)
134-
else:
135-
print(advisor_response.reason)
128+
if return_code == 0 and "id" not in comments[0]:
129+
# If the job succeeds and there is not an existing comment, we
130+
# should not write one to reduce noise.
131+
comments = []
132+
with open("comments", "w") as comment_file_handle:
133+
json.dump(comments, comment_file_handle)
136134

137135

138136
if __name__ == "__main__":

clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void AssertEqualsCheck::registerMatchers(MatchFinder *Finder) {
2525
for (const auto &[CurrName, _] : NameMap) {
2626
Finder->addMatcher(
2727
binaryOperator(anyOf(hasOperatorName("!="), hasOperatorName("==")),
28-
isExpandedFromMacro(CurrName),
28+
isExpandedFromMacro(std::string(CurrName)),
2929
anyOf(hasLHS(hasType(qualType(
3030
hasCanonicalType(asString("NSString *"))))),
3131
hasRHS(hasType(qualType(

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ std::optional<std::string> detectSysroot() {
132132

133133
std::string detectStandardResourceDir() {
134134
static int StaticForMainAddr; // Just an address in this process.
135-
return CompilerInvocation::GetResourcesPath("clangd",
136-
(void *)&StaticForMainAddr);
135+
return GetResourcesPath("clangd", (void *)&StaticForMainAddr);
137136
}
138137

139138
// The path passed to argv[0] is important:

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Compiler.h"
1010
#include "support/Logger.h"
1111
#include "clang/Basic/TargetInfo.h"
12+
#include "clang/Driver/CreateInvocationFromArgs.h"
1213
#include "clang/Frontend/CompilerInvocation.h"
1314
#include "clang/Lex/PreprocessorOptions.h"
1415
#include "clang/Serialization/PCHContainerOperations.h"

clang-tools-extra/clangd/SemanticSelection.cpp

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
#include "Protocol.h"
1212
#include "Selection.h"
1313
#include "SourceCode.h"
14+
#include "support/Bracket.h"
15+
#include "support/DirectiveTree.h"
16+
#include "support/Token.h"
1417
#include "clang/AST/DeclBase.h"
1518
#include "clang/Basic/SourceLocation.h"
1619
#include "clang/Basic/SourceManager.h"
20+
#include "clang/Basic/TokenKinds.h"
1721
#include "clang/Tooling/Syntax/BuildTree.h"
1822
#include "clang/Tooling/Syntax/Nodes.h"
1923
#include "clang/Tooling/Syntax/TokenBufferTokenManager.h"
@@ -22,9 +26,6 @@
2226
#include "llvm/ADT/StringRef.h"
2327
#include "llvm/Support/Casting.h"
2428
#include "llvm/Support/Error.h"
25-
#include "support/Bracket.h"
26-
#include "support/DirectiveTree.h"
27-
#include "support/Token.h"
2829
#include <optional>
2930
#include <queue>
3031
#include <vector>
@@ -163,6 +164,69 @@ llvm::Expected<SelectionRange> getSemanticRanges(ParsedAST &AST, Position Pos) {
163164
return std::move(Head);
164165
}
165166

167+
class PragmaRegionFinder {
168+
// Record the token range of a region:
169+
//
170+
// #pragma region name[[
171+
// ...
172+
// ]]#pragma endregion
173+
std::vector<Token::Range> &Ranges;
174+
const TokenStream &Code;
175+
// Stack of starting token (the name of the region) indices for nested #pragma
176+
// region.
177+
std::vector<unsigned> Stack;
178+
179+
public:
180+
PragmaRegionFinder(std::vector<Token::Range> &Ranges, const TokenStream &Code)
181+
: Ranges(Ranges), Code(Code) {}
182+
183+
void walk(const DirectiveTree &T) {
184+
for (const auto &C : T.Chunks)
185+
std::visit(*this, C);
186+
}
187+
188+
void operator()(const DirectiveTree::Code &C) {}
189+
190+
void operator()(const DirectiveTree::Directive &D) {
191+
// Get the tokens that make up this directive.
192+
auto Tokens = Code.tokens(D.Tokens);
193+
if (Tokens.empty())
194+
return;
195+
const Token &HashToken = Tokens.front();
196+
assert(HashToken.Kind == tok::hash);
197+
const Token &Pragma = HashToken.nextNC();
198+
if (Pragma.text() != "pragma")
199+
return;
200+
const Token &Value = Pragma.nextNC();
201+
202+
// Handle "#pragma region name"
203+
if (Value.text() == "region") {
204+
// Find the last token at the same line.
205+
const Token *T = &Value.next();
206+
while (T < Tokens.end() && T->Line == Pragma.Line)
207+
T = &T->next();
208+
--T;
209+
Stack.push_back(T->OriginalIndex);
210+
return;
211+
}
212+
213+
// Handle "#pragma endregion"
214+
if (Value.text() == "endregion") {
215+
if (Stack.empty())
216+
return; // unmatched end region; ignore.
217+
218+
unsigned StartIdx = Stack.back();
219+
Stack.pop_back();
220+
Ranges.push_back(Token::Range{StartIdx, HashToken.OriginalIndex});
221+
}
222+
}
223+
224+
void operator()(const DirectiveTree::Conditional &C) {
225+
for (const auto &[_, SubTree] : C.Branches)
226+
walk(SubTree);
227+
}
228+
};
229+
166230
// FIXME(kirillbobyrev): Collect comments, PP conditional regions, includes and
167231
// other code regions (e.g. public/private/protected sections of classes,
168232
// control flow statement bodies).
@@ -286,6 +350,17 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
286350
}
287351
AddFoldingRange(Start, End, FoldingRange::COMMENT_KIND);
288352
}
353+
354+
// #pragma region
355+
std::vector<Token::Range> Ranges;
356+
PragmaRegionFinder(Ranges, OrigStream).walk(DirectiveStructure);
357+
auto Ts = OrigStream.tokens();
358+
for (const auto &R : Ranges) {
359+
auto End = StartPosition(Ts[R.End]);
360+
if (LineFoldingOnly)
361+
End.line--;
362+
AddFoldingRange(EndPosition(Ts[R.Begin]), End, FoldingRange::REGION_KIND);
363+
}
289364
return Result;
290365
}
291366

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,22 @@ TEST(FoldingRanges, PseudoParserWithoutLineFoldings) {
410410
Variable = 3;
411411
#
412412
)cpp",
413+
R"cpp(
414+
#pragma region R1[[
415+
416+
#pragma region R2[[
417+
constexpr int a = 2;
418+
]]#pragma endregion
419+
420+
]]#pragma endregion
421+
)cpp",
422+
R"cpp(
423+
#pragma region[[
424+
]]#pragma endregion
425+
426+
#pragma /*comment1*/ region /*comment2*/name[[
427+
]]#pragma endregion
428+
)cpp",
413429
};
414430
for (const char *Test : Tests) {
415431
auto T = Annotations(Test);
@@ -470,6 +486,12 @@ TEST(FoldingRanges, PseudoParserLineFoldingsOnly) {
470486
//[[ foo
471487
/* bar */]]
472488
)cpp",
489+
R"cpp(
490+
#pragma region abc[[
491+
constexpr int a = 2;
492+
]]
493+
#pragma endregion
494+
)cpp",
473495
// FIXME: Support folding template arguments.
474496
// R"cpp(
475497
// template <[[typename foo, class bar]]> struct baz {};

clang-tools-extra/include-cleaner/test/lit.cfg.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
import os
2+
13
import lit.llvm
24

35
lit.llvm.initialize(lit_config, config)
46
lit.llvm.llvm_config.use_default_substitutions()
57

8+
# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.
9+
# See https://github.com/llvm/llvm-project/issues/106636 for more details.
10+
#
11+
# We prefer the lit internal shell which provides a better user experience on failures
12+
# and is faster unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0
13+
# env var.
14+
use_lit_shell = True
15+
lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
16+
if lit_shell_env:
17+
use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
18+
619
config.name = "ClangIncludeCleaner"
720
config.suffixes = [".test", ".c", ".cpp"]
821
config.excludes = ["Inputs"]
9-
config.test_format = lit.formats.ShTest(not lit.llvm.llvm_config.use_lit_shell)
22+
config.test_format = lit.formats.ShTest(not use_lit_shell)
1023
config.test_source_root = config.clang_include_cleaner_source_dir + "/test"
1124
config.test_exec_root = config.clang_include_cleaner_binary_dir + "/test"
1225

clang/docs/LibASTMatchersReference.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,7 +4222,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
42224222
</pre></td></tr>
42234223

42244224

4225-
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro0')"><a name="isExpandedFromMacro0Anchor">isExpandedFromMacro</a></td><td>StringRef MacroName</td></tr>
4225+
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro0')"><a name="isExpandedFromMacro0Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
42264226
<tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
42274227
Does not match if only part of the statement is expanded from that macro or
42284228
if different parts of the statement are expanded from different
@@ -5643,7 +5643,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
56435643
</pre></td></tr>
56445644

56455645

5646-
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro1')"><a name="isExpandedFromMacro1Anchor">isExpandedFromMacro</a></td><td>StringRef MacroName</td></tr>
5646+
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro1')"><a name="isExpandedFromMacro1Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
56475647
<tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro.
56485648
Does not match if only part of the statement is expanded from that macro or
56495649
if different parts of the statement are expanded from different
@@ -5843,7 +5843,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
58435843
</pre></td></tr>
58445844

58455845

5846-
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro2')"><a name="isExpandedFromMacro2Anchor">isExpandedFromMacro</a></td><td>StringRef MacroName</td></tr>
5846+
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro2')"><a name="isExpandedFromMacro2Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
58475847
<tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro.
58485848
Does not match if only part of the statement is expanded from that macro or
58495849
if different parts of the statement are expanded from different

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,8 @@ Potentially Breaking Changes
8484
- Downstream projects that previously linked only against ``clangDriver`` may
8585
now (also) need to link against the new ``clangOptions`` library, since
8686
options-related code has been moved out of the Driver into a separate library.
87-
- Clang now supports MSVC vector deleting destructors when targeting Windows.
88-
This means that vtables of classes with virtual destructors will contain a
89-
pointer to vector deleting destructor (instead of scalar deleting destructor)
90-
which in fact is a different symbol with different name and linkage. This
91-
may cause runtime failures if two binaries using the same class defining a
92-
virtual destructor are compiled with different versions of clang.
87+
- The ``clangFrontend`` library no longer depends on ``clangDriver``, which may
88+
break downstream projects that relied on this transitive dependency.
9389

9490
C/C++ Language Potentially Breaking Changes
9591
-------------------------------------------
@@ -563,6 +559,7 @@ Bug Fixes to C++ Support
563559
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)
564560
- Fix a crash when extracting unavailable member type from alias in template deduction. (#GH165560)
565561
- Fix incorrect diagnostics for lambdas with init-captures inside braced initializers. (#GH163498)
562+
- Fixed spurious diagnoses of certain nested lambda expressions. (#GH149121) (#GH156579)
566563

567564
Bug Fixes to AST Handling
568565
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -621,8 +618,6 @@ Windows Support
621618
- clang-cl now supports /arch:AVX10.1 and /arch:AVX10.2.
622619
- clang-cl now supports /vlen, /vlen=256 and /vlen=512.
623620

624-
- Clang now supports MSVC vector deleting destructors (GH19772).
625-
626621
LoongArch Support
627622
^^^^^^^^^^^^^^^^^
628623
- Enable linker relaxation by default for loongarch64.

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
370370
mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
371371
mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;
372372

373-
/// Global and array operators delete are only required for MSVC deleting
374-
/// destructors support. Store them here to avoid keeping 4 pointers that are
375-
/// not always used in each redeclaration of the destructor.
376-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
377-
OperatorDeletesForVirtualDtor;
378-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
379-
GlobalOperatorDeletesForVirtualDtor;
380-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
381-
ArrayOperatorDeletesForVirtualDtor;
382-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
383-
GlobalArrayOperatorDeletesForVirtualDtor;
384-
385373
/// The next string literal "version" to allocate during constant evaluation.
386374
/// This is used to distinguish between repeated evaluations of the same
387375
/// string literal.
@@ -3485,16 +3473,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
34853473
bool IsTypeAware);
34863474
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;
34873475

3488-
enum OperatorDeleteKind { Regular, GlobalRegular, Array, ArrayGlobal };
3489-
3490-
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
3491-
FunctionDecl *OperatorDelete,
3492-
OperatorDeleteKind K) const;
3493-
FunctionDecl *getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
3494-
OperatorDeleteKind K) const;
3495-
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor,
3496-
OperatorDeleteKind K) const;
3497-
34983476
/// Retrieve the context for computing mangling numbers in the given
34993477
/// DeclContext.
35003478
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);

0 commit comments

Comments
 (0)