Skip to content

Commit ba271be

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:b44da2446b17aaa847bf76f81a01870917f8736b into amd-gfx:b625170ac5f7
Local branch amd-gfx b625170 Merged main:76883932014bcce2efb57be062f901de26317707 into amd-gfx:888e970457a7 Remote branch main b44da24 [lldb] Change the implementation of Status to store an llvm::Error (NFC) (llvm#106774)
2 parents b625170 + b44da24 commit ba271be

File tree

565 files changed

+25031
-8888
lines changed

Some content is hidden

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

565 files changed

+25031
-8888
lines changed

.github/new-prs-labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,8 @@ bazel:
10081008

10091009
offload:
10101010
- offload/**
1011+
1012+
tablegen:
1013+
- llvm/include/TableGen/**
1014+
- llvm/lib/TableGen/**
1015+
- llvm/utils/TableGen/**

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "bolt/Core/MCPlus.h"
2020
#include "llvm/ADT/GraphTraits.h"
2121
#include "llvm/ADT/StringRef.h"
22+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
2223
#include "llvm/MC/MCInst.h"
2324
#include "llvm/MC/MCSymbol.h"
2425
#include "llvm/Support/ErrorOr.h"

clang-tools-extra/clang-move/HelperDeclRefGraph.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ HelperDeclRefGraph::getReachableNodes(const Decl *Root) const {
7676
llvm::DenseSet<const CallGraphNode *> ConnectedNodes;
7777
std::function<void(const CallGraphNode *)> VisitNode =
7878
[&](const CallGraphNode *Node) {
79-
if (ConnectedNodes.count(Node))
79+
if (!ConnectedNodes.insert(Node).second)
8080
return;
81-
ConnectedNodes.insert(Node);
82-
for (auto It = Node->begin(), End = Node->end(); It != End; ++It)
83-
VisitNode(*It);
81+
for (const CallGraphNode::CallRecord &Callee : *Node)
82+
VisitNode(Callee);
8483
};
8584

8685
VisitNode(RootNode);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ void ExpandModularHeadersPPCallbacks::handleModuleFile(
116116
if (!MF)
117117
return;
118118
// Avoid processing a ModuleFile more than once.
119-
if (VisitedModules.count(MF))
119+
if (!VisitedModules.insert(MF).second)
120120
return;
121-
VisitedModules.insert(MF);
122121

123122
// Visit all the input files of this module and mark them to record their
124123
// contents later.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ DanglingHandleCheck::DanglingHandleCheck(StringRef Name,
9797
ClangTidyContext *Context)
9898
: ClangTidyCheck(Name, Context),
9999
HandleClasses(utils::options::parseStringList(Options.get(
100-
"HandleClasses",
101-
"std::basic_string_view;std::experimental::basic_string_view"))),
100+
"HandleClasses", "std::basic_string_view;std::experimental::basic_"
101+
"string_view;std::span"))),
102102
IsAHandle(cxxRecordDecl(hasAnyName(HandleClasses)).bind("handle")) {}
103103

104104
void DanglingHandleCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

clang-tools-extra/clangd/FS.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ PreambleFileStatusCache::getProducingFS(
6464
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
6565

6666
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
67-
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
68-
auto File = getUnderlyingFS().openFileForRead(Path, IsText);
67+
openFileForRead(const llvm::Twine &Path) override {
68+
auto File = getUnderlyingFS().openFileForRead(Path);
6969
if (!File || !*File)
7070
return File;
7171
// Eagerly stat opened file, as the followup `status` call on the file

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ class TidyDiagnosticGroups {
280280
llvm::StringRef Check;
281281
while (!Checks.empty()) {
282282
std::tie(Check, Checks) = Checks.split(',');
283+
Check = Check.trim();
284+
283285
if (Check.empty())
284286
continue;
285287

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ class TimerFS : public llvm::vfs::ProxyFileSystem {
479479
: ProxyFileSystem(std::move(FS)) {}
480480

481481
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
482-
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
482+
openFileForRead(const llvm::Twine &Path) override {
483483
WallTimerRegion T(Timer);
484-
auto FileOr = getUnderlyingFS().openFileForRead(Path, IsText);
484+
auto FileOr = getUnderlyingFS().openFileForRead(Path);
485485
if (!FileOr)
486486
return FileOr;
487487
return std::make_unique<TimerFile>(Timer, std::move(FileOr.get()));

clang-tools-extra/clangd/support/ThreadsafeFS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
2929
: ProxyFileSystem(std::move(FS)) {}
3030

3131
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
32-
openFileForRead(const llvm::Twine &InPath, bool IsText = true) override {
32+
openFileForRead(const llvm::Twine &InPath) override {
3333
llvm::SmallString<128> Path;
3434
InPath.toVector(Path);
3535

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ TEST(ClangdTests, PreambleVFSStatCache) {
10101010
: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}
10111011

10121012
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
1013-
openFileForRead(const Twine &Path, bool IsText = true) override {
1013+
openFileForRead(const Twine &Path) override {
10141014
++CountStats[llvm::sys::path::filename(Path.str())];
10151015
return ProxyFileSystem::openFileForRead(Path);
10161016
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ TEST(DiagnosticTest, ClangTidyEnablesClangWarning) {
748748
TU.ExtraArgs = {"-Wunused"};
749749
TU.ClangTidyProvider = addClangArgs({"-Wno-unused"}, {});
750750
EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
751+
752+
TU.ExtraArgs = {"-Wno-unused"};
753+
TU.ClangTidyProvider = addClangArgs({"-Wunused"}, {"-*, clang-diagnostic-*"});
754+
EXPECT_THAT(TU.build().getDiagnostics(), SizeIs(1));
751755
}
752756

753757
TEST(DiagnosticTest, LongFixMessages) {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ Changes in existing checks
117117
<clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing
118118
the offending code with ``reinterpret_cast``, to more clearly express intent.
119119

120+
- Improved :doc:`bugprone-dangling-handle
121+
<clang-tidy/checks/bugprone/dangling-handle>` check to treat `std::span` as a
122+
handle class.
123+
120124
- Improved :doc:`bugprone-forwarding-reference-overload
121125
<clang-tidy/checks/bugprone/forwarding-reference-overload>` check by fixing
122126
a crash when determining if an ``enable_if[_t]`` was found.

clang-tools-extra/docs/clang-tidy/checks/bugprone/dangling-handle.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ Examples:
2828
return Array;
2929
}
3030

31+
span<int> g() {
32+
array<int, 1> V;
33+
return {V};
34+
int Array[10]{};
35+
return {Array};
36+
}
37+
3138
Options
3239
-------
3340

3441
.. option:: HandleClasses
3542

3643
A semicolon-separated list of class names that should be treated as handles.
37-
By default only ``std::basic_string_view`` and
38-
``std::experimental::basic_string_view`` are considered.
44+
By default only ``std::basic_string_view``,
45+
``std::experimental::basic_string_view`` and ``std::span`` are considered.

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,17 @@ Bug Fixes to C++ Support
403403
- Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175)
404404
- Fixed an assertion failure in debug mode, and potential crashes in release mode, when
405405
diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
406+
- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
407+
- Clang now uses the correct set of template argument lists when comparing the constraints of
408+
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
409+
a class template. (#GH102320)
406410

407411
Bug Fixes to AST Handling
408412
^^^^^^^^^^^^^^^^^^^^^^^^^
409413

410414
- Fixed a crash that occurred when dividing by zero in complex integer division. (#GH55390).
415+
- Fixed a bug in ``ASTContext::getRawCommentForAnyRedecl()`` where the function could
416+
sometimes incorrectly return null even if a comment was present. (#GH108145)
411417

412418
Miscellaneous Bug Fixes
413419
^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,37 @@ Currently, Clang accepts the above example, though it may produce surprising
462462
results if the debugging code depends on consistent use of ``NDEBUG`` in other
463463
translation units.
464464

465+
Source Files Consistency
466+
^^^^^^^^^^^^^^^^^^^^^^^^
467+
468+
Clang may open the input files\ :sup:`1`` of a BMI during the compilation. This implies that
469+
when Clang consumes a BMI, all the input files need to be present in the original path
470+
and with the original contents.
471+
472+
To overcome these requirements and simplify cases like distributed builds and sandboxed
473+
builds, users can use the ``-fmodules-embed-all-files`` flag to embed all input files
474+
into the BMI so that Clang does not need to open the corresponding file on disk.
475+
476+
When the ``-fmodules-embed-all-files`` flag are enabled, Clang explicitly emits the source
477+
code into the BMI file, the contents of the BMI file contain a sufficiently verbose
478+
representation to reproduce the original source file.
479+
480+
:sup:`1`` Input files: The source files which took part in the compilation of the BMI.
481+
For example:
482+
483+
.. code-block:: c++
484+
485+
// M.cppm
486+
module;
487+
#include "foo.h"
488+
export module M;
489+
490+
// foo.h
491+
#pragma once
492+
#include "bar.h"
493+
494+
The ``M.cppm``, ``foo.h`` and ``bar.h`` are input files for the BMI of ``M.cppm``.
495+
465496
Object definition consistency
466497
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
467498

@@ -484,6 +515,13 @@ fragment is disabled by default. These checks can be enabled by specifying
484515
and you encounter incorrect or missing diagnostics, please report them via the
485516
`community issue tracker <https://github.com/llvm/llvm-project/issues/>`_.
486517

518+
Privacy Issue
519+
-------------
520+
521+
BMIs are not and should not be treated as an information hiding mechanism.
522+
They should always be assumed to contain all the information that was used to
523+
create them, in a recoverable form.
524+
487525
ABI Impacts
488526
-----------
489527

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
22

33
if(WIN32 OR CYGWIN)
4-
target_link_libraries(Attribute PRIVATE
4+
set(LLVM_LINK_COMPONENTS
5+
Support
6+
)
7+
clang_target_link_libraries(Attribute PRIVATE
58
clangAST
69
clangBasic
710
clangFrontend
811
clangLex
9-
LLVMSupport
1012
)
1113
endif()

clang/include/clang/AST/DeclTemplate.h

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,11 @@ class RedeclarableTemplateDecl : public TemplateDecl,
781781
EntryType *Entry, void *InsertPos);
782782

783783
struct CommonBase {
784-
CommonBase() : InstantiatedFromMember(nullptr, false) {}
784+
CommonBase() {}
785785

786786
/// The template from which this was most
787787
/// directly instantiated (or null).
788-
///
789-
/// The boolean value indicates whether this template
790-
/// was explicitly specialized.
791-
llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
792-
InstantiatedFromMember;
788+
RedeclarableTemplateDecl *InstantiatedFromMember = nullptr;
793789

794790
/// If non-null, points to an array of specializations (including
795791
/// partial specializations) known only by their external declaration IDs.
@@ -809,14 +805,19 @@ class RedeclarableTemplateDecl : public TemplateDecl,
809805
};
810806

811807
/// Pointer to the common data shared by all declarations of this
812-
/// template.
813-
mutable CommonBase *Common = nullptr;
808+
/// template, and a flag indicating if the template is a member
809+
/// specialization.
810+
mutable llvm::PointerIntPair<CommonBase *, 1, bool> Common;
811+
812+
CommonBase *getCommonPtrInternal() const { return Common.getPointer(); }
814813

815814
/// Retrieves the "common" pointer shared by all (re-)declarations of
816815
/// the same template. Calling this routine may implicitly allocate memory
817816
/// for the common pointer.
818817
CommonBase *getCommonPtr() const;
819818

819+
void setCommonPtr(CommonBase *C) const { Common.setPointer(C); }
820+
820821
virtual CommonBase *newCommon(ASTContext &C) const = 0;
821822

822823
// Construct a template decl with name, parameters, and templated element.
@@ -857,15 +858,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
857858
/// template<> template<typename T>
858859
/// struct X<int>::Inner { /* ... */ };
859860
/// \endcode
860-
bool isMemberSpecialization() const {
861-
return getCommonPtr()->InstantiatedFromMember.getInt();
862-
}
861+
bool isMemberSpecialization() const { return Common.getInt(); }
863862

864863
/// Note that this member template is a specialization.
865864
void setMemberSpecialization() {
866-
assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
867-
"Only member templates can be member template specializations");
868-
getCommonPtr()->InstantiatedFromMember.setInt(true);
865+
assert(!isMemberSpecialization() && "already a member specialization");
866+
Common.setInt(true);
869867
}
870868

871869
/// Retrieve the member template from which this template was
@@ -905,12 +903,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
905903
/// void X<T>::f(T, U);
906904
/// \endcode
907905
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() const {
908-
return getCommonPtr()->InstantiatedFromMember.getPointer();
906+
return getCommonPtr()->InstantiatedFromMember;
909907
}
910908

911909
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD) {
912-
assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
913-
getCommonPtr()->InstantiatedFromMember.setPointer(TD);
910+
assert(!getCommonPtr()->InstantiatedFromMember);
911+
getCommonPtr()->InstantiatedFromMember = TD;
914912
}
915913

916914
/// Retrieve the "injected" template arguments that correspond to the
@@ -1989,6 +1987,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19891987
/// template arguments have been deduced.
19901988
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
19911989
const TemplateArgumentList *TemplateArgs) {
1990+
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
1991+
"A partial specialization cannot be instantiated from a template");
19921992
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
19931993
"Already set to a class template partial specialization!");
19941994
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2000,6 +2000,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
20002000
/// Note that this class template specialization is an instantiation
20012001
/// of the given class template.
20022002
void setInstantiationOf(ClassTemplateDecl *TemplDecl) {
2003+
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
2004+
"A partial specialization cannot be instantiated from a template");
20032005
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
20042006
"Previously set to a class template partial specialization!");
20052007
SpecializedTemplate = TemplDecl;
@@ -2187,18 +2189,11 @@ class ClassTemplatePartialSpecializationDecl
21872189
/// struct X<int>::Inner<T*> { /* ... */ };
21882190
/// \endcode
21892191
bool isMemberSpecialization() const {
2190-
const auto *First =
2191-
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2192-
return First->InstantiatedFromMember.getInt();
2192+
return InstantiatedFromMember.getInt();
21932193
}
21942194

21952195
/// Note that this member template is a specialization.
2196-
void setMemberSpecialization() {
2197-
auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2198-
assert(First->InstantiatedFromMember.getPointer() &&
2199-
"Only member templates can be member template specializations");
2200-
return First->InstantiatedFromMember.setInt(true);
2201-
}
2196+
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
22022197

22032198
/// Retrieves the injected specialization type for this partial
22042199
/// specialization. This is not the same as the type-decl-type for
@@ -2268,10 +2263,6 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22682263
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
22692264
}
22702265

2271-
void setCommonPtr(Common *C) {
2272-
RedeclarableTemplateDecl::Common = C;
2273-
}
2274-
22752266
public:
22762267

22772268
friend class ASTDeclReader;
@@ -2754,6 +2745,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27542745
/// template arguments have been deduced.
27552746
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec,
27562747
const TemplateArgumentList *TemplateArgs) {
2748+
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2749+
"A partial specialization cannot be instantiated from a template");
27572750
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27582751
"Already set to a variable template partial specialization!");
27592752
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2765,6 +2758,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27652758
/// Note that this variable template specialization is an instantiation
27662759
/// of the given variable template.
27672760
void setInstantiationOf(VarTemplateDecl *TemplDecl) {
2761+
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2762+
"A partial specialization cannot be instantiated from a template");
27682763
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27692764
"Previously set to a variable template partial specialization!");
27702765
SpecializedTemplate = TemplDecl;
@@ -2949,18 +2944,11 @@ class VarTemplatePartialSpecializationDecl
29492944
/// U* X<int>::Inner<T*> = (T*)(0) + 1;
29502945
/// \endcode
29512946
bool isMemberSpecialization() const {
2952-
const auto *First =
2953-
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2954-
return First->InstantiatedFromMember.getInt();
2947+
return InstantiatedFromMember.getInt();
29552948
}
29562949

29572950
/// Note that this member template is a specialization.
2958-
void setMemberSpecialization() {
2959-
auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2960-
assert(First->InstantiatedFromMember.getPointer() &&
2961-
"Only member templates can be member template specializations");
2962-
return First->InstantiatedFromMember.setInt(true);
2963-
}
2951+
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
29642952

29652953
SourceRange getSourceRange() const override LLVM_READONLY;
29662954

0 commit comments

Comments
 (0)