Skip to content

Commit c915d19

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I1f2ba7628f710a9d5a381d4a7d6cef7b53f266a8
2 parents 444077a + f740366 commit c915d19

File tree

220 files changed

+5100
-2844
lines changed

Some content is hidden

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

220 files changed

+5100
-2844
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ The following type trait primitives are supported by Clang. Those traits marked
15821582
* ``__is_integral`` (C++, Embarcadero)
15831583
* ``__is_interface_class`` (Microsoft):
15841584
Returns ``false``, even for types defined with ``__interface``.
1585+
* ``__is_layout_compatible`` (C++, GNU, Microsoft)
15851586
* ``__is_literal`` (Clang):
15861587
Synonym for ``__is_literal_type``.
15871588
* ``__is_literal_type`` (C++, GNU, Microsoft):

clang/docs/ReleaseNotes.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ C++20 Feature Support
9696
behavior can use the flag '-Xclang -fno-skip-odr-check-in-gmf'.
9797
(`#79240 <https://github.com/llvm/llvm-project/issues/79240>`_).
9898

99+
- Implemented the `__is_layout_compatible` intrinsic to support
100+
`P0466R5: Layout-compatibility and Pointer-interconvertibility Traits <https://wg21.link/P0466R5>`_.
101+
Note: `CWG1719: Layout compatibility and cv-qualification revisited <https://cplusplus.github.io/CWG/issues/1719.html>`_
102+
and `CWG2759: [[no_unique_address] and common initial sequence <https://cplusplus.github.io/CWG/issues/2759.html>`_
103+
are not yet implemented.
104+
99105
C++23 Feature Support
100106
^^^^^^^^^^^^^^^^^^^^^
101107

@@ -140,6 +146,11 @@ C23 Feature Support
140146
141147
Fixes (`#81472 <https://github.com/llvm/llvm-project/issues/81472>`_).
142148

149+
- Clang now generates predefined macros of the form ``__TYPE_FMTB__`` and
150+
``__TYPE_FMTb__`` (e.g., ``__UINT_FAST64_FMTB__``) in C23 mode for use with
151+
macros typically exposed from ``<inttypes.h>``, such as ``PRIb8``.
152+
(`#81896: <https://github.com/llvm/llvm-project/issues/81896>`_).
153+
143154
Non-comprehensive list of changes in this release
144155
-------------------------------------------------
145156

@@ -172,6 +183,8 @@ Modified Compiler Flags
172183
Removed Compiler Flags
173184
-------------------------
174185

186+
- The ``-freroll-loops`` flag has been removed. It had no effect since Clang 13.
187+
175188
Attribute Changes in Clang
176189
--------------------------
177190

@@ -193,6 +206,18 @@ Improvements to Clang's diagnostics
193206
- Added diagnostics for C11 keywords being incompatible with language standards
194207
before C11, under a new warning group: ``-Wpre-c11-compat``.
195208

209+
- Now diagnoses an enumeration constant whose value is larger than can be
210+
represented by ``unsigned long long``, which can happen with a large constant
211+
using the ``wb`` or ``uwb`` suffix. The maximal underlying type is currently
212+
``unsigned long long``, but this behavior may change in the future when Clang
213+
implements
214+
`WG14 N3029 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm>`_.
215+
Fixes `#69352 <https://github.com/llvm/llvm-project/issues/69352>`_.
216+
217+
- Clang now diagnoses extraneous template parameter lists as a language extension.
218+
219+
- Clang now diagnoses declarative nested name specifiers that name alias templates.
220+
196221
Improvements to Clang's time-trace
197222
----------------------------------
198223

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5325,7 +5325,7 @@ def err_alias_template_extra_headers : Error<
53255325
def err_template_spec_extra_headers : Error<
53265326
"extraneous template parameter list in template specialization or "
53275327
"out-of-line template definition">;
5328-
def warn_template_spec_extra_headers : Warning<
5328+
def ext_template_spec_extra_headers : ExtWarn<
53295329
"extraneous template parameter list in template specialization">;
53305330
def note_explicit_template_spec_does_not_need_header : Note<
53315331
"'template<>' header not required for explicitly-specialized class %0 "
@@ -8255,6 +8255,9 @@ def err_not_tag_in_scope : Error<
82558255
def ext_template_after_declarative_nns : ExtWarn<
82568256
"'template' cannot be used after a declarative nested name specifier">,
82578257
InGroup<DiagGroup<"template-in-declaration-name">>;
8258+
def ext_alias_template_in_declarative_nns : ExtWarn<
8259+
"a declarative nested name specifier cannot name an alias template">,
8260+
InGroup<DiagGroup<"alias-template-in-declaration-name">>;
82588261

82598262
def err_no_typeid_with_fno_rtti : Error<
82608263
"use of typeid requires -frtti">;

clang/include/clang/Basic/TokenKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ TYPE_TRAIT_1(__is_trivially_copyable, IsTriviallyCopyable, KEYCXX)
520520
TYPE_TRAIT_1(__is_union, IsUnion, KEYCXX)
521521
TYPE_TRAIT_1(__has_unique_object_representations,
522522
HasUniqueObjectRepresentations, KEYCXX)
523+
TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX)
523524

524525
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) KEYWORD(__##Trait, KEYCXX)
525526
#include "clang/Basic/TransformTypeTraits.def"

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,10 +3948,6 @@ def funroll_loops : Flag<["-"], "funroll-loops">, Group<f_Group>,
39483948
HelpText<"Turn on loop unroller">, Visibility<[ClangOption, CC1Option]>;
39493949
def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group<f_Group>,
39503950
HelpText<"Turn off loop unroller">, Visibility<[ClangOption, CC1Option]>;
3951-
defm reroll_loops : BoolFOption<"reroll-loops",
3952-
CodeGenOpts<"RerollLoops">, DefaultFalse,
3953-
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Turn on loop reroller">,
3954-
NegFlag<SetFalse>>;
39553951
def ffinite_loops: Flag<["-"], "ffinite-loops">, Group<f_Group>,
39563952
HelpText<"Assume all loops are finite.">, Visibility<[ClangOption, CC1Option]>;
39573953
def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group<f_Group>,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===- InstallAPI/FileList.h ------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// The JSON file list parser is used to communicate input to InstallAPI.
10+
///
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_INSTALLAPI_FILELIST_H
14+
#define LLVM_CLANG_INSTALLAPI_FILELIST_H
15+
16+
#include "clang/Basic/Diagnostic.h"
17+
#include "clang/Basic/FileManager.h"
18+
#include "clang/InstallAPI/HeaderFile.h"
19+
#include "llvm/Support/Error.h"
20+
#include "llvm/Support/MemoryBuffer.h"
21+
22+
namespace clang {
23+
namespace installapi {
24+
25+
class FileListReader {
26+
public:
27+
/// Decode JSON input and append header input into destination container.
28+
/// Headers are loaded in the order they appear in the JSON input.
29+
///
30+
/// \param InputBuffer JSON input data.
31+
/// \param Destination Container to load headers into.
32+
static llvm::Error
33+
loadHeaders(std::unique_ptr<llvm::MemoryBuffer> InputBuffer,
34+
HeaderSeq &Destination);
35+
36+
FileListReader() = delete;
37+
};
38+
39+
} // namespace installapi
40+
} // namespace clang
41+
42+
#endif // LLVM_CLANG_INSTALLAPI_FILELIST_H
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//===- InstallAPI/HeaderFile.h ----------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// Representations of a library's headers for InstallAPI.
10+
///
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_INSTALLAPI_HEADERFILE_H
14+
#define LLVM_CLANG_INSTALLAPI_HEADERFILE_H
15+
16+
#include "clang/Basic/LangStandard.h"
17+
#include "llvm/ADT/StringRef.h"
18+
#include "llvm/Support/Regex.h"
19+
#include <optional>
20+
#include <string>
21+
22+
namespace clang::installapi {
23+
enum class HeaderType {
24+
/// Represents declarations accessible to all clients.
25+
Public,
26+
/// Represents declarations accessible to a disclosed set of clients.
27+
Private,
28+
/// Represents declarations only accessible as implementation details to the
29+
/// input library.
30+
Project,
31+
};
32+
33+
class HeaderFile {
34+
/// Full input path to header.
35+
std::string FullPath;
36+
/// Access level of header.
37+
HeaderType Type;
38+
/// Expected way header will be included by clients.
39+
std::string IncludeName;
40+
/// Supported language mode for header.
41+
std::optional<clang::Language> Language;
42+
43+
public:
44+
HeaderFile(StringRef FullPath, HeaderType Type,
45+
StringRef IncludeName = StringRef(),
46+
std::optional<clang::Language> Language = std::nullopt)
47+
: FullPath(FullPath), Type(Type), IncludeName(IncludeName),
48+
Language(Language) {}
49+
50+
static llvm::Regex getFrameworkIncludeRule();
51+
52+
bool operator==(const HeaderFile &Other) const {
53+
return std::tie(Type, FullPath, IncludeName, Language) ==
54+
std::tie(Other.Type, Other.FullPath, Other.IncludeName,
55+
Other.Language);
56+
}
57+
};
58+
59+
/// Assemble expected way header will be included by clients.
60+
/// As in what maps inside the brackets of `#include <IncludeName.h>`
61+
/// For example,
62+
/// "/System/Library/Frameworks/Foo.framework/Headers/Foo.h" returns
63+
/// "Foo/Foo.h"
64+
///
65+
/// \param FullPath Path to the header file which includes the library
66+
/// structure.
67+
std::optional<std::string> createIncludeHeaderName(const StringRef FullPath);
68+
using HeaderSeq = std::vector<HeaderFile>;
69+
70+
} // namespace clang::installapi
71+
72+
#endif // LLVM_CLANG_INSTALLAPI_HEADERFILE_H

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14082,6 +14082,8 @@ class Sema final {
1408214082
bool SemaValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
1408314083

1408414084
public:
14085+
bool IsLayoutCompatible(QualType T1, QualType T2) const;
14086+
1408514087
// Used by C++ template instantiation.
1408614088
ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
1408714089
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,

clang/lib/AST/Interp/Descriptor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ struct Descriptor final {
165165
return dyn_cast_if_present<ValueDecl>(asDecl());
166166
}
167167

168+
const VarDecl *asVarDecl() const {
169+
return dyn_cast_if_present<VarDecl>(asDecl());
170+
}
171+
168172
const FieldDecl *asFieldDecl() const {
169173
return dyn_cast_if_present<FieldDecl>(asDecl());
170174
}

clang/lib/AST/Interp/Interp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,18 @@ bool CheckMutable(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
357357

358358
bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
359359
AccessKinds AK) {
360+
assert(Ptr.isLive());
361+
360362
if (Ptr.isInitialized())
361363
return true;
362364

363365
if (!S.checkingPotentialConstantExpression()) {
366+
if (const auto *VD = Ptr.getDeclDesc()->asVarDecl();
367+
VD && VD->hasGlobalStorage()) {
368+
const SourceInfo &Loc = S.Current->getSource(OpPC);
369+
S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD;
370+
S.Note(VD->getLocation(), diag::note_declared_at);
371+
}
364372
S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_uninit)
365373
<< AK << /*uninitialized=*/true << S.Current->getRange(OpPC);
366374
}

0 commit comments

Comments
 (0)