Skip to content

Commit 0a94750

Browse files
committed
Merge release/21.x into cheriot-clang21
2 parents 2670f93 + 0fb2434 commit 0a94750

37 files changed

+2351
-1830
lines changed

clang-tools-extra/clangd/ConfigFragment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,15 @@ struct Fragment {
315315
/// AngledHeaders (i.e. a header matches a regex in both QuotedHeaders and
316316
/// AngledHeaders), system headers use <> and non-system headers use "".
317317
/// These can match any suffix of the header file in question.
318-
/// Matching is performed against the header text, not its absolute path
318+
/// Matching is performed against the absolute path of the header
319319
/// within the project.
320320
std::vector<Located<std::string>> QuotedHeaders;
321321
/// List of regexes for headers that should always be included with a
322322
/// <>-style include. By default, and in case of a conflict with
323323
/// AngledHeaders (i.e. a header matches a regex in both QuotedHeaders and
324324
/// AngledHeaders), system headers use <> and non-system headers use "".
325325
/// These can match any suffix of the header file in question.
326-
/// Matching is performed against the header text, not its absolute path
326+
/// Matching is performed against the absolute path of the header
327327
/// within the project.
328328
std::vector<Located<std::string>> AngledHeaders;
329329
};

clang-tools-extra/clangd/Headers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,17 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
304304
// FIXME: should we allow (some limited number of) "../header.h"?
305305
if (llvm::sys::path::is_absolute(Suggested))
306306
return std::nullopt;
307+
auto HeaderPath = llvm::sys::path::convert_to_slash(InsertedHeader.File);
307308
bool IsAngled = false;
308309
for (auto &Filter : AngledHeaders) {
309-
if (Filter(Suggested)) {
310+
if (Filter(HeaderPath)) {
310311
IsAngled = true;
311312
break;
312313
}
313314
}
314315
bool IsQuoted = false;
315316
for (auto &Filter : QuotedHeaders) {
316-
if (Filter(Suggested)) {
317+
if (Filter(HeaderPath)) {
317318
IsQuoted = true;
318319
break;
319320
}
@@ -324,7 +325,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
324325
if (IsAngled && IsQuoted) {
325326
elog("Header '{0}' matches both quoted and angled regexes, default will "
326327
"be used.",
327-
Suggested);
328+
HeaderPath);
328329
}
329330
IsAngled = IsAngledByDefault;
330331
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ TEST(CompletionTest, IncludeInsertionRespectsQuotedAngledConfig) {
938938
{
939939
Config C;
940940
C.Style.AngledHeaders.push_back(
941-
[](auto header) { return header == "bar.h"; });
941+
[](auto header) { return header.contains("bar.h"); });
942942
WithContextValue WithCfg(Config::Key, std::move(C));
943943
Results = completions(TU, Test.point(), {Sym});
944944
EXPECT_THAT(Results.Completions,
@@ -947,7 +947,7 @@ TEST(CompletionTest, IncludeInsertionRespectsQuotedAngledConfig) {
947947
{
948948
Config C;
949949
C.Style.QuotedHeaders.push_back(
950-
[](auto header) { return header == "bar.h"; });
950+
[](auto header) { return header.contains("bar.h"); });
951951
WithContextValue WithCfg(Config::Key, std::move(C));
952952
Results = completions(TU, Test.point(), {Sym});
953953
EXPECT_THAT(Results.Completions,

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,17 @@ TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketed) {
344344
EXPECT_EQ(calculate(BarHeader), "<sub/bar.h>");
345345
}
346346

347+
TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketedFilterByFullPath) {
348+
// The filter receives the full path of the header, so it is able to filter by
349+
// the parent directory, even if it is part of the include search path
350+
AngledHeaders.push_back([](auto Path) {
351+
llvm::Regex Pattern("sub/.*");
352+
return Pattern.match(Path);
353+
});
354+
std::string BarHeader = testPath("sub/bar.h");
355+
EXPECT_EQ(calculate(BarHeader), "<bar.h>");
356+
}
357+
347358
TEST_F(HeadersTest, ShortenedIncludeNotInSearchPath) {
348359
std::string BarHeader =
349360
llvm::sys::path::convert_to_slash(testPath("sub-2/bar.h"));

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ Major New Features
4646
Improvements to clangd
4747
----------------------
4848

49-
Inlay hints
50-
^^^^^^^^^^^
49+
Language feature support
50+
^^^^^^^^^^^^^^^^^^^^^^^^
5151

52-
Diagnostics
53-
^^^^^^^^^^^
52+
- Performance improvements and bugfixes to C++20 Modules support
53+
- Improved support for C++23 "deducing this"
54+
- Improvements to objective-c++ support
5455

55-
Semantic Highlighting
56-
^^^^^^^^^^^^^^^^^^^^^
56+
New Language Server Protocol features
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
- Added support for `textDocument/rangesFormatting`
60+
- Added support for `positionEncoding`
5761

5862
Compile flags
5963
^^^^^^^^^^^^^
@@ -64,24 +68,58 @@ Compile flags
6468
Hover
6569
^^^^^
6670

71+
- Fixed a bug that would sometimes prevent documentation comments of standard library functions
72+
from being shown
73+
6774
Code completion
6875
^^^^^^^^^^^^^^^
6976

70-
Code actions
71-
^^^^^^^^^^^^
72-
73-
Signature help
74-
^^^^^^^^^^^^^^
77+
- Added `HeaderInsertion` config option to control whether code completion inserts a missing
78+
header needed for the symbol being completed. This is equivalent to the `--header-insertion`
79+
command-line option.
80+
- Added a `CodePatterns` config option to control whether code completion should offer code
81+
patterns as completions in addition to symbols.
7582

7683
Cross-references
7784
^^^^^^^^^^^^^^^^
7885

79-
Objective-C
86+
- References to symbols are now collected in array designators
87+
- Find-references now works for operators new and delete
88+
- Improvements to code navigation in templated code
89+
90+
Call hierarchy
91+
^^^^^^^^^^^^^^
92+
93+
- Call hierarchy now works with the remote index
94+
- Fixed a bug where call hierarchy could sometimes return bogus results
95+
96+
Inlay hints
8097
^^^^^^^^^^^
8198

99+
- Parameter hint forwarding now works for variadic forwarding functions declared in header files
100+
- Improved presentation of block-end hints
101+
102+
Code actions
103+
^^^^^^^^^^^^
104+
105+
- Improved the rename refactor's name collision checking logic
106+
107+
Clang-tidy integration
108+
^^^^^^^^^^^^^^^^^^^^^^
109+
110+
- Disabled the cppcoreguidelines-macro-to-enum checker which is incompatible with clangd
111+
112+
Include-cleaner integration
113+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
114+
115+
- Clangd now respects the `AngledHeaders` and `QuotedHeaders` config options for headers
116+
inserted to resolve include-cleaner diagnostics
117+
82118
Miscellaneous
83119
^^^^^^^^^^^^^
84120

121+
- Various crash fixes and other stability improvements
122+
85123
Improvements to clang-doc
86124
-------------------------
87125

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct Header {
136136
}
137137
StringRef verbatim() const { return std::get<Verbatim>(Storage); }
138138

139-
/// For phiscal files, either absolute path or path relative to the execution
139+
/// For physical files, either absolute path or path relative to the execution
140140
/// root. Otherwise just the spelling without surrounding quotes/brackets.
141141
llvm::StringRef resolvedPath() const;
142142

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ C/C++ Language Potentially Breaking Changes
5555
case for old-style offsetof idioms like ``((int)(&(((struct S *)0)->field)))``, to
5656
ensure they are not caught by these optimizations. It is also possible to use
5757
``-fwrapv-pointer`` or ``-fno-delete-null-pointer-checks`` to make pointer arithmetic
58-
on null pointers well-defined. (#GH130734, #GH130742, #GH130952)
58+
on null pointers well-defined. (#GH130734, #GH130952)
5959

6060
C++ Specific Potentially Breaking Changes
6161
-----------------------------------------

clang/lib/AST/ASTStructuralEquivalence.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context,
456456
const Decl *D1, const Decl *D2,
457457
const Decl *PrimaryDecl = nullptr) {
458458
// If either declaration has an attribute on it, we treat the declarations
459-
// as not being structurally equivalent.
459+
// as not being structurally equivalent unless both declarations are implicit
460+
// (ones generated by the compiler like __NSConstantString_tag).
461+
//
460462
// FIXME: this should be handled on a case-by-case basis via tablegen in
461463
// Attr.td. There are multiple cases to consider: one declaration with the
462464
// attribute, another without it; different attribute syntax|spellings for
@@ -468,7 +470,7 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context,
468470
D1Attr = *D1->getAttrs().begin();
469471
if (D2->hasAttrs())
470472
D2Attr = *D2->getAttrs().begin();
471-
if (D1Attr || D2Attr) {
473+
if ((D1Attr || D2Attr) && !D1->isImplicit() && !D2->isImplicit()) {
472474
const auto *DiagnoseDecl = cast<TypeDecl>(PrimaryDecl ? PrimaryDecl : D2);
473475
Context.Diag2(DiagnoseDecl->getLocation(),
474476
diag::warn_odr_tag_type_with_attributes)

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,8 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr,
23672367
bool IsExact = !IsDynamicCastToVoid &&
23682368
CGM.getCodeGenOpts().OptimizationLevel > 0 &&
23692369
DestRecordTy->getAsCXXRecordDecl()->isEffectivelyFinal() &&
2370-
CGM.getCXXABI().shouldEmitExactDynamicCast(DestRecordTy);
2370+
CGM.getCXXABI().shouldEmitExactDynamicCast(DestRecordTy) &&
2371+
!getLangOpts().PointerAuthCalls;
23712372

23722373
// C++ [expr.dynamic.cast]p4:
23732374
// If the value of v is a null pointer value in the pointer case, the result

clang/lib/Driver/ToolChain.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -851,17 +851,30 @@ void ToolChain::addFortranRuntimeLibs(const ArgList &Args,
851851

852852
void ToolChain::addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args,
853853
ArgStringList &CmdArgs) const {
854-
// Default to the <driver-path>/../lib directory. This works fine on the
855-
// platforms that we have tested so far. We will probably have to re-fine
856-
// this in the future. In particular, on some platforms, we may need to use
857-
// lib64 instead of lib.
854+
auto AddLibSearchPathIfExists = [&](const Twine &Path) {
855+
// Linker may emit warnings about non-existing directories
856+
if (!llvm::sys::fs::is_directory(Path))
857+
return;
858+
859+
if (getTriple().isKnownWindowsMSVCEnvironment())
860+
CmdArgs.push_back(Args.MakeArgString("-libpath:" + Path));
861+
else
862+
CmdArgs.push_back(Args.MakeArgString("-L" + Path));
863+
};
864+
865+
// Search for flang_rt.* at the same location as clang_rt.* with
866+
// LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0. On most platforms, flang_rt is
867+
// located at the path returned by getRuntimePath() which is already added to
868+
// the library search path. This exception is for Apple-Darwin.
869+
AddLibSearchPathIfExists(getCompilerRTPath());
870+
871+
// Fall back to the non-resource directory <driver-path>/../lib. We will
872+
// probably have to refine this in the future. In particular, on some
873+
// platforms, we may need to use lib64 instead of lib.
858874
SmallString<256> DefaultLibPath =
859875
llvm::sys::path::parent_path(getDriver().Dir);
860876
llvm::sys::path::append(DefaultLibPath, "lib");
861-
if (getTriple().isKnownWindowsMSVCEnvironment())
862-
CmdArgs.push_back(Args.MakeArgString("-libpath:" + DefaultLibPath));
863-
else
864-
CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath));
877+
AddLibSearchPathIfExists(DefaultLibPath);
865878
}
866879

867880
void ToolChain::addFlangRTLibPath(const ArgList &Args,

0 commit comments

Comments
 (0)