Skip to content

Commit 7dfc12d

Browse files
committed
Merge from 'main' to 'sycl-web' (29 commits)
This merge cause two tests fail: SYCL-Unit :: Extensions/CommandGraph/./CommandGraphExtensionTests/32/46 SYCL-Unit :: Extensions/CommandGraph/./CommandGraphExtensionTests/33/46 CONFLICT (content): Merge conflict in clang/include/clang/Sema/Sema.h CONFLICT (content): Merge conflict in clang/lib/Sema/Sema.cpp
2 parents ee3fb55 + ac74d9e commit 7dfc12d

File tree

146 files changed

+20179
-12393
lines changed

Some content is hidden

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

146 files changed

+20179
-12393
lines changed

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,10 @@ void ClangdServer::formatOnType(PathRef File, Position Pos,
551551
auto Action = [File = File.str(), Code = std::move(*Code),
552552
TriggerText = TriggerText.str(), CursorPos = *CursorPos,
553553
CB = std::move(CB), this]() mutable {
554-
auto Style = format::getStyle(format::DefaultFormatStyle, File,
555-
format::DefaultFallbackStyle, Code,
556-
TFS.view(/*CWD=*/std::nullopt).get());
557-
if (!Style)
558-
return CB(Style.takeError());
559-
554+
auto Style = getFormatStyleForFile(File, Code, TFS);
560555
std::vector<TextEdit> Result;
561556
for (const tooling::Replacement &R :
562-
formatIncremental(Code, CursorPos, TriggerText, *Style))
557+
formatIncremental(Code, CursorPos, TriggerText, Style))
563558
Result.push_back(replacementToEdit(Code, R));
564559
return CB(Result);
565560
};

clang-tools-extra/clangd/FindSymbols.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ std::string getSymbolDetail(ASTContext &Ctx, const NamedDecl &ND) {
223223
std::optional<DocumentSymbol> declToSym(ASTContext &Ctx, const NamedDecl &ND) {
224224
auto &SM = Ctx.getSourceManager();
225225

226-
SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
227-
SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
226+
SourceLocation BeginLoc = ND.getBeginLoc();
227+
SourceLocation EndLoc = ND.getEndLoc();
228228
const auto SymbolRange =
229229
toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
230230
if (!SymbolRange)

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,15 @@ bool mayConsiderUnused(const Inclusion &Inc, ParsedAST &AST,
111111

112112
std::vector<Diag> generateMissingIncludeDiagnostics(
113113
ParsedAST &AST, llvm::ArrayRef<MissingIncludeDiagInfo> MissingIncludes,
114-
llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
114+
llvm::StringRef Code, HeaderFilter IgnoreHeaders, const ThreadsafeFS &TFS) {
115115
std::vector<Diag> Result;
116116
const SourceManager &SM = AST.getSourceManager();
117117
const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID());
118118

119-
auto FileStyle = format::getStyle(
120-
format::DefaultFormatStyle, AST.tuPath(), format::DefaultFallbackStyle,
121-
Code, &SM.getFileManager().getVirtualFileSystem());
122-
if (!FileStyle) {
123-
elog("Couldn't infer style", FileStyle.takeError());
124-
FileStyle = format::getLLVMStyle();
125-
}
119+
auto FileStyle = getFormatStyleForFile(AST.tuPath(), Code, TFS);
126120

127121
tooling::HeaderIncludes HeaderIncludes(AST.tuPath(), Code,
128-
FileStyle->IncludeStyle);
122+
FileStyle.IncludeStyle);
129123
for (const auto &SymbolWithMissingInclude : MissingIncludes) {
130124
llvm::StringRef ResolvedPath =
131125
SymbolWithMissingInclude.Providers.front().resolvedPath();
@@ -459,14 +453,15 @@ bool isPreferredProvider(const Inclusion &Inc,
459453
std::vector<Diag>
460454
issueIncludeCleanerDiagnostics(ParsedAST &AST, llvm::StringRef Code,
461455
const IncludeCleanerFindings &Findings,
456+
const ThreadsafeFS &TFS,
462457
HeaderFilter IgnoreHeaders) {
463458
trace::Span Tracer("IncludeCleaner::issueIncludeCleanerDiagnostics");
464459
std::vector<Diag> UnusedIncludes = generateUnusedIncludeDiagnostics(
465460
AST.tuPath(), Findings.UnusedIncludes, Code, IgnoreHeaders);
466461
std::optional<Fix> RemoveAllUnused = removeAllUnusedIncludes(UnusedIncludes);
467462

468463
std::vector<Diag> MissingIncludeDiags = generateMissingIncludeDiagnostics(
469-
AST, Findings.MissingIncludes, Code, IgnoreHeaders);
464+
AST, Findings.MissingIncludes, Code, IgnoreHeaders, TFS);
470465
std::optional<Fix> AddAllMissing = addAllMissingIncludes(MissingIncludeDiags);
471466

472467
std::optional<Fix> FixAll;

clang-tools-extra/clangd/IncludeCleaner.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ using HeaderFilter = llvm::ArrayRef<std::function<bool(llvm::StringRef)>>;
5959
std::vector<Diag>
6060
issueIncludeCleanerDiagnostics(ParsedAST &AST, llvm::StringRef Code,
6161
const IncludeCleanerFindings &Findings,
62+
const ThreadsafeFS &TFS,
6263
HeaderFilter IgnoreHeader = {});
6364

6465
/// Affects whether standard library includes should be considered for

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ void applyWarningOptions(llvm::ArrayRef<std::string> ExtraArgs,
360360
}
361361
}
362362

363-
std::vector<Diag> getIncludeCleanerDiags(ParsedAST &AST, llvm::StringRef Code) {
363+
std::vector<Diag> getIncludeCleanerDiags(ParsedAST &AST, llvm::StringRef Code,
364+
const ThreadsafeFS &TFS) {
364365
auto &Cfg = Config::current();
365366
if (Cfg.Diagnostics.SuppressAll)
366367
return {};
@@ -377,7 +378,7 @@ std::vector<Diag> getIncludeCleanerDiags(ParsedAST &AST, llvm::StringRef Code) {
377378
Findings.MissingIncludes.clear();
378379
if (SuppressUnused)
379380
Findings.UnusedIncludes.clear();
380-
return issueIncludeCleanerDiagnostics(AST, Code, Findings,
381+
return issueIncludeCleanerDiagnostics(AST, Code, Findings, TFS,
381382
Cfg.Diagnostics.Includes.IgnoreHeader);
382383
}
383384

@@ -741,7 +742,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
741742
std::move(Clang), std::move(Action), std::move(Tokens),
742743
std::move(Macros), std::move(Marks), std::move(ParsedDecls),
743744
std::move(Diags), std::move(Includes), std::move(PI));
744-
llvm::move(getIncludeCleanerDiags(Result, Inputs.Contents),
745+
llvm::move(getIncludeCleanerDiags(Result, Inputs.Contents, *Inputs.TFS),
745746
std::back_inserter(Result.Diags));
746747
return std::move(Result);
747748
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,23 @@ TEST(SignatureHelpTest, FunctionPointers) {
14621462
typedef void (__stdcall *fn)(int x, int y);
14631463
fn foo;
14641464
int main() { foo(^); }
1465+
)cpp",
1466+
// Field of function pointer type
1467+
R"cpp(
1468+
struct S {
1469+
void (*foo)(int x, int y);
1470+
};
1471+
S s;
1472+
int main() { s.foo(^); }
1473+
)cpp",
1474+
// Field of function pointer typedef type
1475+
R"cpp(
1476+
typedef void (*fn)(int x, int y);
1477+
struct S {
1478+
fn foo;
1479+
};
1480+
S s;
1481+
int main() { s.foo(^); }
14651482
)cpp"};
14661483
for (auto Test : Tests)
14671484
EXPECT_THAT(signatures(Test).signatures,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,9 @@ TEST(DocumentSymbols, RangeFromMacro) {
750750
$fullDef[[FF3() {
751751
int var = 42;
752752
}]]
753+
754+
#define FF4(name) int name = 0
755+
$FooRange[[FF4($FooSelectionRange[[foo]])]];
753756
)");
754757
TU.Code = Main.code().str();
755758
EXPECT_THAT(
@@ -766,7 +769,11 @@ TEST(DocumentSymbols, RangeFromMacro) {
766769
AllOf(withName("FF3"), withDetail("()"),
767770
symRange(Main.range("fullDef")),
768771
children(AllOf(withName("waldo"), withDetail("void ()"),
769-
symRange(Main.range("fullDef")))))));
772+
symRange(Main.range("fullDef"))))),
773+
AllOf(
774+
withName("FF4"), withDetail("(foo)"),
775+
children(AllOf(withName("foo"), symRange(Main.range("FooRange")),
776+
symNameRange(Main.range("FooSelectionRange")))))));
770777
}
771778

772779
TEST(DocumentSymbols, FuncTemplates) {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
252252
auto Findings = computeIncludeCleanerFindings(AST);
253253
Findings.UnusedIncludes.clear();
254254
std::vector<clangd::Diag> Diags = issueIncludeCleanerDiagnostics(
255-
AST, TU.Code, Findings,
255+
AST, TU.Code, Findings, MockFS(),
256256
{[](llvm::StringRef Header) { return Header.ends_with("buzz.h"); }});
257257
EXPECT_THAT(
258258
Diags,
@@ -505,8 +505,8 @@ TEST(IncludeCleaner, BatchFix) {
505505
)cpp";
506506
auto AST = TU.build();
507507
EXPECT_THAT(
508-
issueIncludeCleanerDiagnostics(AST, TU.Code,
509-
computeIncludeCleanerFindings(AST)),
508+
issueIncludeCleanerDiagnostics(
509+
AST, TU.Code, computeIncludeCleanerFindings(AST), MockFS()),
510510
UnorderedElementsAre(withFix({FixMessage("#include \"foo.h\""),
511511
FixMessage("fix all includes")}),
512512
withFix({FixMessage("remove #include directive"),
@@ -520,8 +520,8 @@ TEST(IncludeCleaner, BatchFix) {
520520
)cpp";
521521
AST = TU.build();
522522
EXPECT_THAT(
523-
issueIncludeCleanerDiagnostics(AST, TU.Code,
524-
computeIncludeCleanerFindings(AST)),
523+
issueIncludeCleanerDiagnostics(
524+
AST, TU.Code, computeIncludeCleanerFindings(AST), MockFS()),
525525
UnorderedElementsAre(withFix({FixMessage("#include \"foo.h\""),
526526
FixMessage("fix all includes")}),
527527
withFix({FixMessage("remove #include directive"),
@@ -539,8 +539,8 @@ TEST(IncludeCleaner, BatchFix) {
539539
)cpp";
540540
AST = TU.build();
541541
EXPECT_THAT(
542-
issueIncludeCleanerDiagnostics(AST, TU.Code,
543-
computeIncludeCleanerFindings(AST)),
542+
issueIncludeCleanerDiagnostics(
543+
AST, TU.Code, computeIncludeCleanerFindings(AST), MockFS()),
544544
UnorderedElementsAre(withFix({FixMessage("#include \"foo.h\""),
545545
FixMessage("add all missing includes"),
546546
FixMessage("fix all includes")}),

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ C++20 Feature Support
8686
- Implemented the `__is_layout_compatible` intrinsic to support
8787
`P0466R5: Layout-compatibility and Pointer-interconvertibility Traits <https://wg21.link/P0466R5>`_.
8888

89+
- Clang now implements [module.import]p7 fully. Clang now will import module
90+
units transitively for the module units coming from the same module of the
91+
current module units.
92+
Fixes `#84002 <https://github.com/llvm/llvm-project/issues/84002>`_.
93+
8994
C++23 Feature Support
9095
^^^^^^^^^^^^^^^^^^^^^
9196

@@ -138,6 +143,9 @@ C23 Feature Support
138143
macros typically exposed from ``<inttypes.h>``, such as ``PRIb8``.
139144
(`#81896: <https://github.com/llvm/llvm-project/issues/81896>`_).
140145

146+
- Clang now supports `N3018 The constexpr specifier for object definitions`
147+
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3018.htm>`_.
148+
141149
Non-comprehensive list of changes in this release
142150
-------------------------------------------------
143151

clang/include/clang/AST/Expr.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,17 @@ class StringLiteral final
18751875
llvm_unreachable("Unsupported character width!");
18761876
}
18771877

1878+
// Get code unit but preserve sign info.
1879+
int64_t getCodeUnitS(size_t I, uint64_t BitWidth) const {
1880+
int64_t V = getCodeUnit(I);
1881+
if (isOrdinary() || isWide()) {
1882+
unsigned Width = getCharByteWidth() * BitWidth;
1883+
llvm::APInt AInt(Width, (uint64_t)V);
1884+
V = AInt.getSExtValue();
1885+
}
1886+
return V;
1887+
}
1888+
18781889
unsigned getByteLength() const { return getCharByteWidth() * getLength(); }
18791890
unsigned getLength() const { return *getTrailingObjects<unsigned>(); }
18801891
unsigned getCharByteWidth() const { return StringLiteralBits.CharByteWidth; }

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,18 @@ def warn_private_extern : Warning<
29892989
def note_private_extern : Note<
29902990
"use __attribute__((visibility(\"hidden\"))) attribute instead">;
29912991

2992+
// C23 constexpr
2993+
def err_c23_constexpr_not_variable : Error<
2994+
"'constexpr' can only be used in variable declarations">;
2995+
def err_c23_constexpr_invalid_type : Error<
2996+
"constexpr variable cannot have type %0">;
2997+
def err_c23_constexpr_init_not_representable : Error<
2998+
"constexpr initializer evaluates to %0 which is not exactly representable in type %1">;
2999+
def err_c23_constexpr_init_type_mismatch : Error<
3000+
"constexpr initializer for type %0 is of type %1">;
3001+
def err_c23_constexpr_pointer_not_null : Error<
3002+
"constexpr pointer initializer is not null">;
3003+
29923004
// C++ Concepts
29933005
def err_concept_decls_may_only_appear_in_global_namespace_scope : Error<
29943006
"concept declarations may only appear in global or namespace scope">;

clang/include/clang/Basic/Module.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,11 @@ class alignas(8) Module {
598598
Kind == ModulePartitionImplementation;
599599
}
600600

601+
/// Is this a module partition implementation unit.
602+
bool isModulePartitionImplementation() const {
603+
return Kind == ModulePartitionImplementation;
604+
}
605+
601606
/// Is this a module implementation.
602607
bool isModuleImplementation() const {
603608
return Kind == ModuleImplementationUnit;
@@ -853,12 +858,6 @@ class VisibleModuleSet {
853858
VisibleCallback Vis = [](Module *) {},
854859
ConflictCallback Cb = [](ArrayRef<Module *>, Module *,
855860
StringRef) {});
856-
857-
/// Make transitive imports visible for [module.import]/7.
858-
void makeTransitiveImportsVisible(
859-
Module *M, SourceLocation Loc, VisibleCallback Vis = [](Module *) {},
860-
ConflictCallback Cb = [](ArrayRef<Module *>, Module *, StringRef) {});
861-
862861
private:
863862
/// Import locations for each visible module. Indexed by the module's
864863
/// VisibilityID.

clang/include/clang/Basic/TokenKinds.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ CXX11_KEYWORD(alignas , KEYC23)
394394
CXX11_UNARY_EXPR_OR_TYPE_TRAIT(alignof, AlignOf, KEYC23)
395395
CXX11_KEYWORD(char16_t , KEYNOMS18)
396396
CXX11_KEYWORD(char32_t , KEYNOMS18)
397-
CXX11_KEYWORD(constexpr , 0)
397+
CXX11_KEYWORD(constexpr , KEYC23)
398398
CXX11_KEYWORD(decltype , 0)
399399
CXX11_KEYWORD(noexcept , 0)
400400
CXX11_KEYWORD(nullptr , KEYC23)

0 commit comments

Comments
 (0)