Skip to content

Commit 2cac4e7

Browse files
author
Pavel V Chupin
committed
Merge from 'main' to 'sycl-web' (35 commits)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaDeclAttr.cpp
2 parents 95ae688 + a58d0af commit 2cac4e7

File tree

121 files changed

+3715
-2385
lines changed

Some content is hidden

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

121 files changed

+3715
-2385
lines changed

clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ static bool isIntegralConstant(const Token &Token) {
9292
Begin, End, [](char C) { return C == '.' || std::toupper(C) == 'E'; });
9393
}
9494

95+
static StringRef getTokenName(const Token &Tok) {
96+
return Tok.is(tok::raw_identifier) ? Tok.getRawIdentifier()
97+
: Tok.getIdentifierInfo()->getName();
98+
}
99+
95100
namespace {
96101

97102
struct EnumMacro {
@@ -279,19 +284,11 @@ void MacroToEnumCallbacks::checkCondition(SourceRange Range) {
279284
}
280285

281286
void MacroToEnumCallbacks::checkName(const Token &MacroNameTok) {
282-
std::string Id;
283-
if (MacroNameTok.is(tok::raw_identifier))
284-
Id = MacroNameTok.getRawIdentifier().str();
285-
else if (MacroNameTok.is(tok::identifier))
286-
Id = MacroNameTok.getIdentifierInfo()->getName().str();
287-
else {
288-
assert(false && "Expected either an identifier or raw identifier token");
289-
return;
290-
}
287+
StringRef Id = getTokenName(MacroNameTok);
291288

292289
llvm::erase_if(Enums, [&Id](const MacroList &MacroList) {
293290
return llvm::any_of(MacroList, [&Id](const EnumMacro &Macro) {
294-
return Macro.Name.getIdentifierInfo()->getName().str() == Id;
291+
return getTokenName(Macro.Name) == Id;
295292
});
296293
});
297294
}
@@ -355,8 +352,7 @@ void MacroToEnumCallbacks::MacroUndefined(const Token &MacroNameTok,
355352
const MacroDefinition &MD,
356353
const MacroDirective *Undef) {
357354
auto MatchesToken = [&MacroNameTok](const EnumMacro &Macro) {
358-
return Macro.Name.getIdentifierInfo()->getName() ==
359-
MacroNameTok.getIdentifierInfo()->getName();
355+
return getTokenName(Macro.Name) == getTokenName(MacroNameTok);
360356
};
361357

362358
auto It = llvm::find_if(Enums, [MatchesToken](const MacroList &MacroList) {
@@ -432,8 +428,8 @@ void MacroToEnumCallbacks::EndOfMainFile() {
432428

433429
void MacroToEnumCallbacks::warnMacroEnum(const EnumMacro &Macro) const {
434430
Check->diag(Macro.Directive->getLocation(),
435-
"macro %0 defines an integral constant; prefer an enum instead")
436-
<< Macro.Name.getIdentifierInfo();
431+
"macro '%0' defines an integral constant; prefer an enum instead")
432+
<< getTokenName(Macro.Name);
437433
}
438434

439435
void MacroToEnumCallbacks::fixEnumMacro(const MacroList &MacroList) const {

clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ inline void used_ifndef() {}
208208
#define IFNDEF3 3
209209
#endif
210210

211+
// Sometimes an argument to ifdef can be classified as a keyword token.
212+
#ifdef __restrict
213+
#endif
214+
211215
// These macros do not expand to integral constants.
212216
#define HELLO "Hello, "
213217
#define WORLD "World"

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,6 @@ Major New Features
5454
There is an analogous ``zero_call_used_regs`` attribute to allow for finer
5555
control of this feature.
5656

57-
- Clang now supports randomizing structure layout in C. This feature is a
58-
compile-time hardening technique, making it more difficult for an attacker to
59-
retrieve data from structures. Specify randomization with the
60-
``randomize_layout`` attribute. The corresponding ``no_randomize_layout``
61-
attribute can be used to turn the feature off.
62-
63-
A seed value is required to enable randomization, and is deterministic based
64-
on a seed value. Use the ``-frandomize-layout-seed=`` or
65-
``-frandomize-layout-seed-file=`` flags.
66-
67-
.. note::
68-
69-
Randomizing structure layout is a C-only feature.
70-
7157
Bug Fixes
7258
------------------
7359
- ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
@@ -129,6 +115,15 @@ Improvements to Clang's diagnostics
129115
- ``-Wunused-variable`` no longer warn for references extending the lifetime
130116
of temporaries with side effects. This fixes `Issue 54489
131117
<https://github.com/llvm/llvm-project/issues/54489>`_.
118+
- Modified the behavior of ``-Wstrict-prototypes`` and added a new, related
119+
diagnostic ``-Wdeprecated-non-prototype``. The strict prototypes warning will
120+
now only diagnose deprecated declarations and definitions of functions
121+
without a prototype where the behavior in C2x will remain correct. This
122+
diagnostic remains off by default but is now enabled via ``-pedantic`` due to
123+
it being a deprecation warning. ``-Wdeprecated-non-prototype`` will diagnose
124+
cases where the deprecated declarations or definitions of a function without
125+
a prototype will change behavior in C2x. This diagnostic is grouped under the
126+
``-Wstrict-prototypes`` warning group, but is enabled by default.
132127

133128
Non-comprehensive list of changes in this release
134129
-------------------------------------------------

clang/include/clang/AST/Decl.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,12 +4052,6 @@ class RecordDecl : public TagDecl {
40524052
RecordDeclBits.ParamDestroyedInCallee = V;
40534053
}
40544054

4055-
bool isRandomized() const { return RecordDeclBits.IsRandomized; }
4056-
4057-
void setIsRandomized(bool V) { RecordDeclBits.IsRandomized = V; }
4058-
4059-
void reorderFields(const SmallVectorImpl<Decl *> &Fields);
4060-
40614055
/// Determines whether this declaration represents the
40624056
/// injected class name.
40634057
///

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ class alignas(8) Decl {
313313
friend class ASTReader;
314314
friend class CXXClassMemberWrapper;
315315
friend class LinkageComputer;
316-
friend class RecordDecl;
317316
template<typename decl_type> friend class Redeclarable;
318317

319318
/// Access - Used by C++ decls for the access specifier.
@@ -1541,13 +1540,10 @@ class DeclContext {
15411540

15421541
/// Represents the way this type is passed to a function.
15431542
uint64_t ArgPassingRestrictions : 2;
1544-
1545-
/// Indicates whether this struct has had its field layout randomized.
1546-
uint64_t IsRandomized : 1;
15471543
};
15481544

15491545
/// Number of non-inherited bits in RecordDeclBitfields.
1550-
enum { NumRecordDeclBits = 15 };
1546+
enum { NumRecordDeclBits = 14 };
15511547

15521548
/// Stores the bits used by OMPDeclareReductionDecl.
15531549
/// If modified NumOMPDeclareReductionDeclBits and the accessor

clang/include/clang/AST/Randstruct.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4859,18 +4859,3 @@ def HLSLNumThreads: InheritableAttr {
48594859
let LangOpts = [HLSL];
48604860
let Documentation = [NumThreadsDocs];
48614861
}
4862-
4863-
def RandomizeLayout : InheritableAttr {
4864-
let Spellings = [GCC<"randomize_layout">];
4865-
let Subjects = SubjectList<[Record]>;
4866-
let Documentation = [ClangRandomizeLayoutDocs];
4867-
let LangOpts = [COnly];
4868-
}
4869-
4870-
def NoRandomizeLayout : InheritableAttr {
4871-
let Spellings = [GCC<"no_randomize_layout">];
4872-
let Subjects = SubjectList<[Record]>;
4873-
let Documentation = [ClangRandomizeLayoutDocs];
4874-
let LangOpts = [COnly];
4875-
}
4876-
def : MutualExclusions<[RandomizeLayout, NoRandomizeLayout]>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7957,35 +7957,3 @@ dictate the thread id. Total number of threads executed is ``X * Y * Z``.
79577957
The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-attributes-numthreads
79587958
}];
79597959
}
7960-
7961-
def ClangRandomizeLayoutDocs : Documentation {
7962-
let Category = DocCatDecl;
7963-
let Heading = "randomize_layout, no_randomize_layout";
7964-
let Content = [{
7965-
The attribute ``randomize_layout``, when attached to a C structure, selects it
7966-
for structure layout field randomization; a compile-time hardening technique. A
7967-
"seed" value, is specified via the ``-frandomize-layout-seed=`` command line flag.
7968-
For example:
7969-
7970-
.. code-block:: bash
7971-
7972-
SEED=`od -A n -t x8 -N 32 /dev/urandom | tr -d ' \n'`
7973-
make ... CFLAGS="-frandomize-layout-seed=$SEED" ...
7974-
7975-
You can also supply the seed in a file with ``-frandomize-layout-seed-file=``.
7976-
For example:
7977-
7978-
.. code-block:: bash
7979-
7980-
od -A n -t x8 -N 32 /dev/urandom | tr -d ' \n' > /tmp/seed_file.txt
7981-
make ... CFLAGS="-frandomize-layout-seed-file=/tmp/seed_file.txt" ...
7982-
7983-
The randomization is deterministic based for a given seed, so the entire
7984-
program should be compiled with the same seed, but keep the seed safe
7985-
otherwise.
7986-
7987-
The attribute ``no_randomize_layout``, when attached to a C structure,
7988-
instructs the compiler that this structure should not have its field layout
7989-
randomized.
7990-
}];
7991-
}

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ def err_drv_amdgpu_ieee_without_no_honor_nans : Error<
180180
"invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling">;
181181
def err_drv_argument_not_allowed_with : Error<
182182
"invalid argument '%0' not allowed with '%1'">;
183-
def err_drv_cannot_open_randomize_layout_seed_file : Error<
184-
"cannot read randomize layout seed file '%0'">;
185183
def err_drv_invalid_version_number : Error<
186184
"invalid version number in '%0'">;
187185
def err_drv_no_linker_llvm_support : Error<

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ def InlineNamespaceReopenedNoninline
447447
def InvalidNoreturn : DiagGroup<"invalid-noreturn">;
448448
def InvalidSourceEncoding : DiagGroup<"invalid-source-encoding">;
449449
def KNRPromotedParameter : DiagGroup<"knr-promoted-parameter">;
450+
def DeprecatedNonPrototype : DiagGroup<"deprecated-non-prototype">;
451+
def StrictPrototypes : DiagGroup<"strict-prototypes", [DeprecatedNonPrototype]>;
450452
def : DiagGroup<"init-self">;
451453
def : DiagGroup<"inline">;
452454
def : DiagGroup<"invalid-pch">;

0 commit comments

Comments
 (0)