Skip to content

Commit 923ea72

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-early-exit-handle-early
2 parents 4747678 + fe56c8f commit 923ea72

File tree

348 files changed

+54166
-10638
lines changed

Some content is hidden

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

348 files changed

+54166
-10638
lines changed

bolt/test/runtime/X86/fdata-escape-chars.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ define internal void @static_symb_backslash_b() #0 {
8282
; INSTR_CHECK: Binary Function "main"
8383
; INSTR_CHECK: Exec Count : 1
8484
; INSTR_CHECK: {{([[:xdigit:]]+)}}: callq "symb whitespace" # Count: 1
85-
; INSTR_CHECK: {{([[:xdigit:]]+)}}: callq "symb backslash\" # Count: 2
85+
; INSTR_CHECK: {{([[:xdigit:]]+)}}: callq "symb backslash\\" # Count: 2
8686
; INSTR_CHECK: Binary Function "static symb backslash\/1(*2)"
8787
; INSTR_CHECK: Exec Count : 1
8888
; INSTR_CHECK: {{([[:xdigit:]]+)}}: callq "symb whitespace" # Count: 1

clang/docs/PointerAuthentication.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,14 @@ __ptrauth Qualifier
284284
^^^^^^^^^^^^^^^^^^^
285285

286286
``__ptrauth(key, address, discriminator)`` is an extended type
287-
qualifier which causes so-qualified objects to hold pointers signed using the
288-
specified schema rather than the default schema for such types.
287+
qualifier which causes so-qualified objects to hold pointers or pointer sized
288+
integers signed using the specified schema rather than the default schema for
289+
such types.
289290

290291
In the current implementation in Clang, the qualified type must be a C pointer
291-
type, either to a function or to an object. It currently cannot be an
292-
Objective-C pointer type, a C++ reference type, or a block pointer type; these
293-
restrictions may be lifted in the future.
292+
type, either to a function or to an object, or a pointer sized integer. It
293+
currently cannot be an Objective-C pointer type, a C++ reference type, or a
294+
block pointer type; these restrictions may be lifted in the future.
294295

295296
The qualifier's operands are as follows:
296297

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,15 @@ Improvements to Clang's diagnostics
509509
- Clang now prints the namespace for an attribute, if any,
510510
when emitting an unknown attribute diagnostic.
511511

512+
- ``-Wvolatile`` now warns about volatile-qualified class return types
513+
as well as volatile-qualified scalar return types. Fixes #GH133380
514+
512515
- Several compatibility diagnostics that were incorrectly being grouped under
513516
``-Wpre-c++20-compat`` are now part of ``-Wc++20-compat``. (#GH138775)
514517

518+
- Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about overlapping and non-overlapping ranges involving character literals and floating-point literals.
519+
The warning message for non-overlapping cases has also been improved (#GH13473).
520+
515521
Improvements to Clang's time-trace
516522
----------------------------------
517523

@@ -680,6 +686,8 @@ Bug Fixes to C++ Support
680686
- Improved parser recovery of invalid requirement expressions. In turn, this
681687
fixes crashes from follow-on processing of the invalid requirement. (#GH138820)
682688
- Fixed the handling of pack indexing types in the constraints of a member function redeclaration. (#GH138255)
689+
- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` and ``alignas`` attributes for declarations (#GH133107)
690+
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
683691

684692
Bug Fixes to AST Handling
685693
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -916,7 +924,8 @@ Improvements
916924
^^^^^^^^^^^^
917925

918926
Additional Information
919-
======================
927+
928+
===================
920929

921930
A wide variety of additional information is available on the `Clang web
922931
page <https://clang.llvm.org/>`_. The web page contains versions of the

clang/include/clang/AST/Type.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,9 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25602560
bool isFunctionProtoType() const { return getAs<FunctionProtoType>(); }
25612561
bool isPointerType() const;
25622562
bool isPointerOrReferenceType() const;
2563-
bool isSignableType() const;
2563+
bool isSignableType(const ASTContext &Ctx) const;
2564+
bool isSignablePointerType() const;
2565+
bool isSignableIntegerType(const ASTContext &Ctx) const;
25642566
bool isAnyPointerType() const; // Any C pointer or ObjC object pointer
25652567
bool isCountAttributedType() const;
25662568
bool isBlockPointerType() const;
@@ -8216,7 +8218,13 @@ inline bool Type::isAnyPointerType() const {
82168218
return isPointerType() || isObjCObjectPointerType();
82178219
}
82188220

8219-
inline bool Type::isSignableType() const { return isPointerType(); }
8221+
inline bool Type::isSignableType(const ASTContext &Ctx) const {
8222+
return isSignablePointerType() || isSignableIntegerType(Ctx);
8223+
}
8224+
8225+
inline bool Type::isSignablePointerType() const {
8226+
return isPointerType() || isObjCClassType() || isObjCQualifiedClassType();
8227+
}
82208228

82218229
inline bool Type::isBlockPointerType() const {
82228230
return isa<BlockPointerType>(CanonicalType);

clang/include/clang/Analysis/Analyses/ThreadSafety.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,14 @@ enum AccessKind {
9494

9595
/// This enum distinguishes between different situations where we warn due to
9696
/// inconsistent locking.
97-
/// \enum SK_LockedSomeLoopIterations -- a mutex is locked for some but not all
98-
/// loop iterations.
99-
/// \enum SK_LockedSomePredecessors -- a mutex is locked in some but not all
100-
/// predecessors of a CFGBlock.
101-
/// \enum SK_LockedAtEndOfFunction -- a mutex is still locked at the end of a
102-
/// function.
10397
enum LockErrorKind {
98+
/// A capability is locked for some but not all loop iterations.
10499
LEK_LockedSomeLoopIterations,
100+
/// A capability is locked in some but not all predecessors of a CFGBlock.
105101
LEK_LockedSomePredecessors,
102+
/// A capability is still locked at the end of a function.
106103
LEK_LockedAtEndOfFunction,
104+
/// Expecting a capability to be held at the end of function.
107105
LEK_NotLockedAtEndOfFunction
108106
};
109107

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
499499
/// The name of a file to use with \c .secure_log_unique directives.
500500
std::string AsSecureLogFile;
501501

502+
/// A list of functions that are replacable by the loader.
503+
std::vector<std::string> LoaderReplaceableFunctionNames;
504+
502505
public:
503506
// Define accessors/mutators for code generation options of enumeration type.
504507
#define CODEGENOPT(Name, Bits, Default)
@@ -571,6 +574,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
571574
/// Reset all of the options that are not considered when building a
572575
/// module.
573576
void resetNonModularOptions(StringRef ModuleFormat);
577+
578+
// Is the given function name one of the functions that can be replaced by the
579+
// loader?
580+
bool isLoaderReplaceableFunctionName(StringRef FuncName) const {
581+
return llvm::is_contained(LoaderReplaceableFunctionNames, FuncName);
582+
}
574583
};
575584

576585
} // end namespace clang

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,5 +1856,6 @@ def err_hlsl_unexpected_end_of_params
18561856
def err_hlsl_rootsig_repeat_param : Error<"specified the same parameter '%0' multiple times">;
18571857
def err_hlsl_rootsig_missing_param : Error<"did not specify mandatory parameter '%0'">;
18581858
def err_hlsl_number_literal_overflow : Error<"integer literal is too large to be represented as a 32-bit %select{signed |}0 integer type">;
1859+
def err_hlsl_rootsig_non_zero_flag : Error<"flag value is neither a literal 0 nor a named value">;
18591860

18601861
} // end of Parser diagnostics

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,19 +1028,22 @@ def err_ptrauth_indirect_goto_addrlabel_arithmetic : Error<
10281028

10291029
// __ptrauth qualifier
10301030
def err_ptrauth_qualifier_invalid : Error<
1031-
"%select{return type|parameter type|property}1 may not be qualified with '__ptrauth'; type is %0">;
1031+
"%select{return type|parameter type|property}1 may not be qualified with "
1032+
"'__ptrauth'; type is %0">;
10321033
def err_ptrauth_qualifier_cast : Error<
10331034
"cannot cast to '__ptrauth'-qualified type %0">;
1034-
def err_ptrauth_qualifier_nonpointer : Error<
1035-
"'__ptrauth' qualifier only applies to pointer types; %0 is invalid">;
1036-
def err_ptrauth_qualifier_redundant : Error<
1037-
"type %0 is already %1-qualified">;
1035+
def err_ptrauth_qualifier_invalid_target : Error<
1036+
"'__ptrauth' qualifier only applies to pointer or pointer sized integer "
1037+
"types; %0 is invalid">;
1038+
def err_ptrauth_qualifier_redundant: Error<
1039+
"type %0 is already '__ptrauth'-qualified">;
10381040
def err_ptrauth_arg_not_ice : Error<
10391041
"argument to '__ptrauth' must be an integer constant expression">;
10401042
def err_ptrauth_address_discrimination_invalid : Error<
10411043
"invalid address discrimination flag '%0'; '__ptrauth' requires '0' or '1'">;
10421044
def err_ptrauth_extra_discriminator_invalid : Error<
1043-
"invalid extra discriminator flag '%0'; '__ptrauth' requires a value between '0' and '%1'">;
1045+
"invalid extra discriminator flag '%0'; '__ptrauth' requires a value between "
1046+
"'0' and '%1'">;
10441047

10451048
/// main()
10461049
// static main() is not an error in C, just in C++.
@@ -10528,7 +10531,7 @@ def warn_tautological_negation_or_compare: Warning<
1052810531
"'||' of a value and its negation always evaluates to true">,
1052910532
InGroup<TautologicalNegationCompare>, DefaultIgnore;
1053010533
def warn_tautological_overlap_comparison : Warning<
10531-
"overlapping comparisons always evaluate to %select{false|true}0">,
10534+
"%select{non-|}0overlapping comparisons always evaluate to %select{false|true}0">,
1053210535
InGroup<TautologicalOverlapCompare>, DefaultIgnore;
1053310536
def warn_depr_array_comparison : Warning<
1053410537
"comparison between two arrays is deprecated; "

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7826,6 +7826,9 @@ def import_call_optimization : Flag<["-"], "import-call-optimization">,
78267826
"by the Windows kernel to enable import call optimization">,
78277827
MarshallingInfoFlag<CodeGenOpts<"ImportCallOptimization">>;
78287828

7829+
def replaceable_function: Joined<["-"], "loader-replaceable-function=">,
7830+
MarshallingInfoStringVector<CodeGenOpts<"LoaderReplaceableFunctionNames">>;
7831+
78297832
} // let Visibility = [CC1Option]
78307833

78317834
//===----------------------------------------------------------------------===//
@@ -9088,6 +9091,10 @@ def _SLASH_Gregcall : CLFlag<"Gregcall">,
90889091
def _SLASH_Gregcall4 : CLFlag<"Gregcall4">,
90899092
HelpText<"Set __regcall4 as a default calling convention to respect __regcall ABI v.4">;
90909093

9094+
def _SLASH_funcoverride : CLCompileJoined<"funcoverride:">,
9095+
HelpText<"Mark <function> as being replaceable by the Windows kernel loader">,
9096+
MetaVarName<"<function>">;
9097+
90919098
// GNU Driver aliases
90929099

90939100
def : Separate<["-"], "Xmicrosoft-visualc-tools-root">, Alias<_SLASH_vctoolsdir>;

clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#endif
2828

2929
// Defines the various types of enum
30+
#ifndef ROOT_FLAG_ENUM
31+
#define ROOT_FLAG_ENUM(NAME, LIT) ENUM(NAME, LIT)
32+
#endif
3033
#ifndef UNBOUNDED_ENUM
3134
#define UNBOUNDED_ENUM(NAME, LIT) ENUM(NAME, LIT)
3235
#endif
@@ -74,6 +77,7 @@ PUNCTUATOR(minus, '-')
7477

7578
// RootElement Keywords:
7679
KEYWORD(RootSignature) // used only for diagnostic messaging
80+
KEYWORD(RootFlags)
7781
KEYWORD(DescriptorTable)
7882
KEYWORD(RootConstants)
7983

@@ -101,6 +105,20 @@ UNBOUNDED_ENUM(unbounded, "unbounded")
101105
// Descriptor Range Offset Enum:
102106
DESCRIPTOR_RANGE_OFFSET_ENUM(DescriptorRangeOffsetAppend, "DESCRIPTOR_RANGE_OFFSET_APPEND")
103107

108+
// Root Flag Enums:
109+
ROOT_FLAG_ENUM(AllowInputAssemblerInputLayout, "ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT")
110+
ROOT_FLAG_ENUM(DenyVertexShaderRootAccess, "DENY_VERTEX_SHADER_ROOT_ACCESS")
111+
ROOT_FLAG_ENUM(DenyHullShaderRootAccess, "DENY_HULL_SHADER_ROOT_ACCESS")
112+
ROOT_FLAG_ENUM(DenyDomainShaderRootAccess, "DENY_DOMAIN_SHADER_ROOT_ACCESS")
113+
ROOT_FLAG_ENUM(DenyGeometryShaderRootAccess, "DENY_GEOMETRY_SHADER_ROOT_ACCESS")
114+
ROOT_FLAG_ENUM(DenyPixelShaderRootAccess, "DENY_PIXEL_SHADER_ROOT_ACCESS")
115+
ROOT_FLAG_ENUM(DenyAmplificationShaderRootAccess, "DENY_AMPLIFICATION_SHADER_ROOT_ACCESS")
116+
ROOT_FLAG_ENUM(DenyMeshShaderRootAccess, "DENY_MESH_SHADER_ROOT_ACCESS")
117+
ROOT_FLAG_ENUM(AllowStreamOutput, "ALLOW_STREAM_OUTPUT")
118+
ROOT_FLAG_ENUM(LocalRootSignature, "LOCAL_ROOT_SIGNATURE")
119+
ROOT_FLAG_ENUM(CBVSRVUAVHeapDirectlyIndexed, "CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED")
120+
ROOT_FLAG_ENUM(SamplerHeapDirectlyIndexed , "SAMPLER_HEAP_DIRECTLY_INDEXED")
121+
104122
// Root Descriptor Flag Enums:
105123
ROOT_DESCRIPTOR_FLAG_ENUM(DataVolatile, "DATA_VOLATILE")
106124
ROOT_DESCRIPTOR_FLAG_ENUM(DataStaticWhileSetAtExecute, "DATA_STATIC_WHILE_SET_AT_EXECUTE")
@@ -128,6 +146,7 @@ SHADER_VISIBILITY_ENUM(Mesh, "SHADER_VISIBILITY_MESH")
128146
#undef DESCRIPTOR_RANGE_FLAG_ENUM_OFF
129147
#undef DESCRIPTOR_RANGE_FLAG_ENUM_ON
130148
#undef ROOT_DESCRIPTOR_FLAG_ENUM
149+
#undef ROOT_FLAG_ENUM
131150
#undef DESCRIPTOR_RANGE_OFFSET_ENUM
132151
#undef UNBOUNDED_ENUM
133152
#undef ENUM

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class RootSignatureParser {
7171
// expected, or, there is a lexing error
7272

7373
/// Root Element parse methods:
74+
std::optional<llvm::hlsl::rootsig::RootFlags> parseRootFlags();
7475
std::optional<llvm::hlsl::rootsig::RootConstants> parseRootConstants();
7576
std::optional<llvm::hlsl::rootsig::DescriptorTable> parseDescriptorTable();
7677
std::optional<llvm::hlsl::rootsig::DescriptorTableClause>

clang/include/clang/Parse/Parser.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3081,13 +3081,16 @@ class Parser : public CodeCompletionHandler {
30813081
bool CouldBeBitField = false);
30823082
Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
30833083

3084-
void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3084+
bool MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3085+
bool AttrsParsed = false;
30853086
if ((getLangOpts().MicrosoftExt || getLangOpts().HLSL) &&
30863087
Tok.is(tok::l_square)) {
30873088
ParsedAttributes AttrsWithRange(AttrFactory);
30883089
ParseMicrosoftAttributes(AttrsWithRange);
3090+
AttrsParsed = !AttrsWithRange.empty();
30893091
Attrs.takeAllFrom(AttrsWithRange);
30903092
}
3093+
return AttrsParsed;
30913094
}
30923095
void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
30933096
void ParseMicrosoftAttributes(ParsedAttributes &Attrs);

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,6 +2943,9 @@ bool ASTContext::hasUniqueObjectRepresentations(
29432943

29442944
// All integrals and enums are unique.
29452945
if (Ty->isIntegralOrEnumerationType()) {
2946+
// Address discriminated integer types are not unique.
2947+
if (Ty.hasAddressDiscriminatedPointerAuth())
2948+
return false;
29462949
// Except _BitInt types that have padding bits.
29472950
if (const auto *BIT = Ty->getAs<BitIntType>())
29482951
return getTypeSize(BIT) == BIT->getNumBits();

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -942,15 +942,6 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This) {
942942
return false;
943943
}
944944

945-
bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) {
946-
if (!MD->isPureVirtual())
947-
return true;
948-
const SourceInfo &E = S.Current->getSource(OpPC);
949-
S.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << MD;
950-
S.Note(MD->getLocation(), diag::note_declared_at);
951-
return false;
952-
}
953-
954945
bool CheckFloatResult(InterpState &S, CodePtr OpPC, const Floating &Result,
955946
APFloat::opStatus Status, FPOptions FPO) {
956947
// [expr.pre]p4:

clang/lib/AST/ByteCode/Interp.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ bool CheckCallDepth(InterpState &S, CodePtr OpPC);
114114
/// Checks the 'this' pointer.
115115
bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This);
116116

117-
/// Checks if a method is pure virtual.
118-
bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD);
119-
120117
/// Checks if all the arguments annotated as 'nonnull' are in fact not null.
121118
bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
122119
const CallExpr *CE, unsigned ArgSize);

clang/lib/AST/Type.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5075,6 +5075,12 @@ AttributedType::stripOuterNullability(QualType &T) {
50755075
return std::nullopt;
50765076
}
50775077

5078+
bool Type::isSignableIntegerType(const ASTContext &Ctx) const {
5079+
if (!isIntegralType(Ctx) || isEnumeralType())
5080+
return false;
5081+
return Ctx.getTypeSize(this) == Ctx.getTypeSize(Ctx.VoidPtrTy);
5082+
}
5083+
50785084
bool Type::isBlockCompatibleObjCPointerType(ASTContext &ctx) const {
50795085
const auto *objcPtr = getAs<ObjCObjectPointerType>();
50805086
if (!objcPtr)

0 commit comments

Comments
 (0)