Skip to content

Commit 81dd2e0

Browse files
authored
merge main into amd-staging (llvm#1685)
2 parents 9b12b58 + a27a7ca commit 81dd2e0

File tree

155 files changed

+1671
-1362
lines changed

Some content is hidden

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

155 files changed

+1671
-1362
lines changed

.github/workflows/premerge.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Upload Artifacts
7070
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
7171
with:
72-
name: Premerge Artifacts
72+
name: Premerge Artifacts (Linux)
7373
path: artifacts/
7474
retention-days: 5
7575
include-hidden-files: 'true'
@@ -124,7 +124,7 @@ jobs:
124124
- name: Upload Artifacts
125125
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
126126
with:
127-
name: Premerge Artifacts
127+
name: Premerge Artifacts (Windows)
128128
path: artifacts/
129129
retention-days: 5
130130
include-hidden-files: 'true'

clang/bindings/python/clang/cindex.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,19 @@ def get_canonical(self):
25932593
"""
25942594
return Type.from_result(conf.lib.clang_getCanonicalType(self), (self,))
25952595

2596+
def get_fully_qualified_name(self, policy, with_global_ns_prefix=False):
2597+
"""
2598+
Get the fully qualified name for a type.
2599+
2600+
This includes full qualification of all template parameters.
2601+
2602+
policy - This PrintingPolicy can further refine the type formatting
2603+
with_global_ns_prefix - If true, prepend '::' to qualified names
2604+
"""
2605+
return _CXString.from_result(
2606+
conf.lib.clang_getFullyQualifiedName(self, policy, with_global_ns_prefix)
2607+
)
2608+
25962609
def is_const_qualified(self):
25972610
"""Determine whether a Type has the "const" qualifier set.
25982611
@@ -4022,6 +4035,7 @@ def set_property(self, property, value):
40224035
("clang_getTypeSpelling", [Type], _CXString),
40234036
("clang_hashCursor", [Cursor], c_uint),
40244037
("clang_isAttribute", [CursorKind], bool),
4038+
("clang_getFullyQualifiedName", [Type, PrintingPolicy, c_uint], _CXString),
40254039
("clang_isConstQualifiedType", [Type], bool),
40264040
("clang_isCursorDefinition", [Cursor], bool),
40274041
("clang_isDeclaration", [CursorKind], bool),

clang/bindings/python/tests/cindex/test_type.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,25 @@ def test_pretty(self):
535535
pp.set_property(PrintingPolicyProperty.SuppressTagKeyword, False)
536536
self.assertEqual(f.type.get_canonical().pretty_printed(pp), "struct X")
537537

538+
def test_fully_qualified_name(self):
539+
source = """
540+
namespace home {
541+
class Bar {
542+
};
543+
class Foo {
544+
public:
545+
void setIt(Bar*);
546+
};
547+
}
548+
class A : public home::Foo {
549+
};
550+
"""
551+
tu = get_tu(source, lang="cpp")
552+
arg = next(get_cursor(tu, "setIt").get_arguments())
553+
pp = PrintingPolicy.create(arg)
554+
self.assertEqual(arg.type.get_fully_qualified_name(pp), "home::Bar *")
555+
self.assertEqual(arg.type.get_fully_qualified_name(pp, True), "::home::Bar *")
556+
538557
def test_base_classes(self):
539558
source = """
540559
class A { int a; };

clang/docs/InternalsManual.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ Description:
416416
and the modifier indexes in the substitution are re-numbered accordingly. The
417417
substituted text must itself be a valid format string before substitution.
418418

419+
**"quoted" format**
420+
421+
Example:
422+
``"expression %quoted0 evaluates to 0"``
423+
Class:
424+
``String``
425+
Description:
426+
This is a simple formatter which adds quotes around the given string.
427+
This is useful when the argument could be a string in some cases, but
428+
another class in other cases, and it needs to be quoted consistently.
429+
419430
.. _internals-producing-diag:
420431

421432
Producing the Diagnostic

clang/docs/ReleaseNotes.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ Improvements to Clang's diagnostics
314314
- Clang now respects the current language mode when printing expressions in
315315
diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also
316316
a bunch of HLSL types being printed as their C++ equivalents.
317+
- Clang now consistently quotes expressions in diagnostics.
317318
- When printing types for diagnostics, clang now doesn't suppress the scopes of
318319
template arguments contained within nested names.
319320
- The ``-Wshift-bool`` warning has been added to warn about shifting a boolean. (#GH28334)
@@ -413,6 +414,9 @@ Bug Fixes in This Version
413414
414415
#if 1 ? 1 : 999999999999999999999
415416
#endif
417+
- ``#embed`` directive now diagnoses use of a non-character file (device file)
418+
such as ``/dev/urandom`` as an error. This restriction may be relaxed in the
419+
future. See (#GH126629).
416420

417421
Bug Fixes to Compiler Builtins
418422
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -541,6 +545,9 @@ X86 Support
541545
Arm and AArch64 Support
542546
^^^^^^^^^^^^^^^^^^^^^^^
543547
- For ARM targets, cc1as now considers the FPU's features for the selected CPU or Architecture.
548+
- The ``+nosimd`` attribute is now fully supported for ARM. Previously, this had no effect when being used with
549+
ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is
550+
also now printed when the ``--print-supported-extensions`` option is used.
544551

545552
Android Support
546553
^^^^^^^^^^^^^^^
@@ -620,6 +627,8 @@ libclang
620627
--------
621628
- Added ``clang_visitCXXMethods``, which allows visiting the methods
622629
of a class.
630+
- Added ``clang_getFullyQualifiedName``, which provides fully qualified type names as
631+
instructed by a PrintingPolicy.
623632

624633
- Fixed a buffer overflow in ``CXString`` implementation. The fix may result in
625634
increased memory allocation.
@@ -674,6 +683,8 @@ Python Binding Changes
674683
the cursor is a specialization of.
675684
- Added ``Type.get_methods``, a binding for ``clang_visitCXXMethods``, which
676685
allows visiting the methods of a class.
686+
- Added ``Type.get_fully_qualified_name``, which provides fully qualified type names as
687+
instructed by a PrintingPolicy.
677688

678689
OpenMP Support
679690
--------------

clang/include/clang-c/Index.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4223,6 +4223,18 @@ CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
42234223
CINDEX_LINKAGE CXString clang_getTypePrettyPrinted(CXType CT,
42244224
CXPrintingPolicy cxPolicy);
42254225

4226+
/**
4227+
* Get the fully qualified name for a type.
4228+
*
4229+
* This includes full qualification of all template parameters.
4230+
*
4231+
* Policy - Further refine the type formatting
4232+
* WithGlobalNsPrefix - If non-zero, function will prepend a '::' to qualified
4233+
* names
4234+
*/
4235+
CINDEX_LINKAGE CXString clang_getFullyQualifiedName(
4236+
CXType CT, CXPrintingPolicy Policy, unsigned WithGlobalNsPrefix);
4237+
42264238
/**
42274239
* Retrieve the display name for the entity referenced by this cursor.
42284240
*

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def note_constexpr_null_subobject : Note<
143143
"access array element of|perform pointer arithmetic on|"
144144
"access real component of|"
145145
"access imaginary component of}0 null pointer">;
146-
def note_constexpr_null_callee : Note<
147-
"'%0' evaluates to a null function pointer">;
146+
def note_constexpr_null_callee
147+
: Note<"%0 evaluates to a null function pointer">;
148148
def note_constexpr_function_param_value_unknown : Note<
149149
"function parameter %0 with unknown value cannot be used in a constant "
150150
"expression">;

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ def warn_compat_pp_embed_directive : Warning<
458458
InGroup<CPre23Compat>, DefaultIgnore;
459459
def err_pp_embed_dup_params : Error<
460460
"cannot specify parameter '%0' twice in the same '#embed' directive">;
461+
def err_pp_embed_device_file : Error<
462+
"device files are not yet supported by '#embed' directive">;
461463

462464
def ext_pp_extra_tokens_at_eol : ExtWarn<
463465
"extra tokens at end of #%0 directive">, InGroup<ExtraTokens>;

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ def note_omp_ctx_compatible_set_and_selector_for_property
16391639
"'match(%2={%1(%0)})'">;
16401640
def warn_omp_ctx_incompatible_score_for_property
16411641
: Warning<"the context selector '%0' in the context set '%1' cannot have a "
1642-
"score ('%2'); score ignored">,
1642+
"score (%quoted2); score ignored">,
16431643
InGroup<OpenMPClauses>;
16441644
def warn_omp_more_one_device_type_clause
16451645
: Warning<"more than one 'device_type' clause is specified">,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ def err_expr_not_string_literal : Error<"expression is not a string literal">;
167167
def ext_predef_outside_function : Warning<
168168
"predefined identifier is only valid inside function">,
169169
InGroup<DiagGroup<"predefined-identifier-outside-function">>;
170-
def ext_init_from_predefined : ExtWarn<
171-
"initializing an array from a '%0' predefined identifier is a Microsoft extension">,
172-
InGroup<MicrosoftInitFromPredefined>;
170+
def ext_init_from_predefined
171+
: ExtWarn<"initializing an array from a %0 predefined identifier is a "
172+
"Microsoft extension">,
173+
InGroup<MicrosoftInitFromPredefined>;
173174
def ext_string_literal_from_predefined : ExtWarn<
174175
"expansion of predefined identifier '%0' to a string literal is a Microsoft extension">,
175176
InGroup<MicrosoftStringLiteralFromPredefined>;
@@ -3021,14 +3022,14 @@ def note_substituted_constraint_expr_is_ill_formed : Note<
30213022
"because substituted constraint expression is ill-formed%0">;
30223023
def note_constraint_references_error
30233024
: Note<"constraint depends on a previously diagnosed expression">;
3024-
def note_atomic_constraint_evaluated_to_false : Note<
3025-
"%select{and|because}0 '%1' evaluated to false">;
3026-
def note_concept_specialization_constraint_evaluated_to_false : Note<
3027-
"%select{and|because}0 '%1' evaluated to false">;
3025+
def note_atomic_constraint_evaluated_to_false
3026+
: Note<"%select{and|because}0 %1 evaluated to false">;
3027+
def note_concept_specialization_constraint_evaluated_to_false
3028+
: Note<"%select{and|because}0 %1 evaluated to false">;
30283029
def note_single_arg_concept_specialization_constraint_evaluated_to_false : Note<
30293030
"%select{and|because}0 %1 does not satisfy %2">;
3030-
def note_atomic_constraint_evaluated_to_false_elaborated : Note<
3031-
"%select{and|because}0 '%1' (%2 %3 %4) evaluated to false">;
3031+
def note_atomic_constraint_evaluated_to_false_elaborated
3032+
: Note<"%select{and|because}0 %1 (%2 %3 %4) evaluated to false">;
30323033
def note_is_deducible_constraint_evaluated_to_false : Note<
30333034
"cannot deduce template arguments for %0 from %1">;
30343035
def err_constrained_virtual_method : Error<
@@ -3048,14 +3049,14 @@ def note_expr_requirement_expr_substitution_error : Note<
30483049
"%select{and|because}0 '%1' would be invalid: %2">;
30493050
def note_expr_requirement_expr_unknown_substitution_error : Note<
30503051
"%select{and|because}0 '%1' would be invalid">;
3051-
def note_expr_requirement_noexcept_not_met : Note<
3052-
"%select{and|because}0 '%1' may throw an exception">;
3052+
def note_expr_requirement_noexcept_not_met
3053+
: Note<"%select{and|because}0 %1 may throw an exception">;
30533054
def note_expr_requirement_type_requirement_substitution_error : Note<
30543055
"%select{and|because}0 '%1' would be invalid: %2">;
30553056
def note_expr_requirement_type_requirement_unknown_substitution_error : Note<
30563057
"%select{and|because}0 '%1' would be invalid">;
3057-
def note_expr_requirement_constraints_not_satisfied : Note<
3058-
"%select{and|because}0 type constraint '%1' was not satisfied:">;
3058+
def note_expr_requirement_constraints_not_satisfied
3059+
: Note<"%select{and|because}0 type constraint %1 was not satisfied:">;
30593060
def note_expr_requirement_constraints_not_satisfied_simple : Note<
30603061
"%select{and|because}0 %1 does not satisfy %2:">;
30613062
def note_type_requirement_substitution_error : Note<
@@ -4356,9 +4357,9 @@ def note_reference_is_return_value : Note<"%0 returns a reference">;
43564357

43574358
def note_pointer_declared_here : Note<
43584359
"pointer %0 declared here">;
4359-
def warn_division_sizeof_ptr : Warning<
4360-
"'%0' will return the size of the pointer, not the array itself">,
4361-
InGroup<DiagGroup<"sizeof-pointer-div">>;
4360+
def warn_division_sizeof_ptr
4361+
: Warning<"%0 will return the size of the pointer, not the array itself">,
4362+
InGroup<DiagGroup<"sizeof-pointer-div">>;
43624363
def warn_division_sizeof_array : Warning<
43634364
"expression does not compute the number of elements in this array; element "
43644365
"type is %0, not %1">,
@@ -5581,8 +5582,9 @@ def note_function_member_spec_matched : Note<
55815582
def err_template_recursion_depth_exceeded : Error<
55825583
"recursive template instantiation exceeded maximum depth of %0">,
55835584
DefaultFatal, NoSFINAE;
5584-
def err_constraint_depends_on_self : Error<
5585-
"satisfaction of constraint '%0' depends on itself">, NoSFINAE;
5585+
def err_constraint_depends_on_self
5586+
: Error<"satisfaction of constraint %0 depends on itself">,
5587+
NoSFINAE;
55865588
def note_template_recursion_depth : Note<
55875589
"use -ftemplate-depth=N to increase recursive template instantiation depth">;
55885590

@@ -7098,8 +7100,8 @@ def warn_precedence_bitwise_rel : Warning<
70987100
InGroup<Parentheses>;
70997101
def note_precedence_bitwise_first : Note<
71007102
"place parentheses around the %0 expression to evaluate it first">;
7101-
def note_precedence_silence : Note<
7102-
"place parentheses around the '%0' expression to silence this warning">;
7103+
def note_precedence_silence : Note<"place parentheses around the %quoted0 "
7104+
"expression to silence this warning">;
71037105

71047106
def warn_precedence_conditional : Warning<
71057107
"operator '?:' has lower precedence than '%0'; '%0' will be evaluated first">,
@@ -7117,9 +7119,11 @@ def warn_consecutive_comparison : Warning<
71177119
def warn_enum_constant_in_bool_context : Warning<
71187120
"converting the enum constant to a boolean">,
71197121
InGroup<IntInBoolContext>, DefaultIgnore;
7120-
def warn_left_shift_in_bool_context : Warning<
7121-
"converting the result of '<<' to a boolean; did you mean '(%0) != 0'?">,
7122-
InGroup<IntInBoolContext>, DefaultIgnore;
7122+
def warn_left_shift_in_bool_context
7123+
: Warning<"converting the result of '<<' to a boolean; did you mean to "
7124+
"compare with '0'?">,
7125+
InGroup<IntInBoolContext>,
7126+
DefaultIgnore;
71237127
def warn_logical_instead_of_bitwise : Warning<
71247128
"use of logical '%0' with constant operand">,
71257129
InGroup<DiagGroup<"constant-logical-operand">>;
@@ -10331,9 +10335,11 @@ def warn_dangling_pointer_assignment : Warning<
1033110335
"object backing %select{|the pointer }0%1 "
1033210336
"will be destroyed at the end of the full-expression">,
1033310337
InGroup<DanglingAssignment>;
10334-
def warn_dangling_reference_captured : Warning<
10335-
"object whose reference is captured by '%0' will be destroyed at the end of "
10336-
"the full-expression">, InGroup<DanglingCapture>;
10338+
def warn_dangling_reference_captured
10339+
: Warning<"object whose reference is captured by %0 will be destroyed at "
10340+
"the end of "
10341+
"the full-expression">,
10342+
InGroup<DanglingCapture>;
1033710343
def warn_dangling_reference_captured_by_unknown : Warning<
1033810344
"object whose reference is captured will be destroyed at the end of "
1033910345
"the full-expression">, InGroup<DanglingCapture>;
@@ -13042,15 +13048,15 @@ def note_acc_atomic_too_many_stmts
1304213048
def note_acc_atomic_expected_binop : Note<"expected binary operation on right "
1304313049
"hand side of assignment operator">;
1304413050
def note_acc_atomic_mismatch_operand
13045-
: Note<"left hand side of assignment operation('%0') must match one side "
13046-
"of the sub-operation on the right hand side('%1' and '%2')">;
13051+
: Note<"left hand side of assignment operation(%0) must match one side "
13052+
"of the sub-operation on the right hand side(%1 and %2)">;
1304713053
def note_acc_atomic_mismatch_compound_operand
1304813054
: Note<"variable %select{|in unary expression|on right hand side of "
1304913055
"assignment|on left hand side of assignment|on left hand side of "
13050-
"compound assignment|on left hand side of assignment}2('%3') must "
13056+
"compound assignment|on left hand side of assignment}2(%3) must "
1305113057
"match variable used %select{|in unary expression|on right hand "
1305213058
"side of assignment|<not possible>|on left hand side of compound "
13053-
"assignment|on left hand side of assignment}0('%1') from the first "
13059+
"assignment|on left hand side of assignment}0(%1) from the first "
1305413060
"statement">;
1305513061
def err_acc_declare_required_clauses
1305613062
: Error<"no valid clauses specified in OpenACC 'declare' directive">;
@@ -13070,9 +13076,9 @@ def err_acc_multiple_references
1307013076
: Error<"variable referenced in '%0' clause of OpenACC 'declare' directive "
1307113077
"was already referenced">;
1307213078
def err_acc_routine_not_func
13073-
: Error<"OpenACC routine name '%0' does not name a function">;
13079+
: Error<"OpenACC routine name %0 does not name a function">;
1307413080
def err_acc_routine_overload_set
13075-
: Error<"OpenACC routine name '%0' names a set of overloads">;
13081+
: Error<"OpenACC routine name %0 names a set of overloads">;
1307613082
def err_acc_magic_static_in_routine
1307713083
: Error<"function static variables are not permitted in functions to which "
1307813084
"an OpenACC 'routine' directive applies">;

clang/include/clang/Basic/FileEntry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class FileEntryRef {
8282
inline const llvm::sys::fs::UniqueID &getUniqueID() const;
8383
inline time_t getModificationTime() const;
8484
inline bool isNamedPipe() const;
85+
inline bool isDeviceFile() const;
8586
inline void closeFile() const;
8687

8788
/// Check if the underlying FileEntry is the same, intentially ignoring
@@ -316,6 +317,7 @@ class FileEntry {
316317
llvm::sys::fs::UniqueID UniqueID;
317318
unsigned UID = 0; // A unique (small) ID for the file.
318319
bool IsNamedPipe = false;
320+
bool IsDeviceFile = false;
319321

320322
/// The open file, if it is owned by the \p FileEntry.
321323
mutable std::unique_ptr<llvm::vfs::File> File;
@@ -340,6 +342,7 @@ class FileEntry {
340342
/// Check whether the file is a named pipe (and thus can't be opened by
341343
/// the native FileManager methods).
342344
bool isNamedPipe() const { return IsNamedPipe; }
345+
bool isDeviceFile() const { return IsDeviceFile; }
343346

344347
void closeFile() const;
345348
};
@@ -357,6 +360,9 @@ time_t FileEntryRef::getModificationTime() const {
357360
}
358361

359362
bool FileEntryRef::isNamedPipe() const { return getFileEntry().isNamedPipe(); }
363+
bool FileEntryRef::isDeviceFile() const {
364+
return getFileEntry().isDeviceFile();
365+
}
360366

361367
void FileEntryRef::closeFile() const { getFileEntry().closeFile(); }
362368

clang/lib/AST/ASTDiagnostic.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,6 @@ void clang::FormatASTNodeDiagnosticArgument(
512512
const Expr *E = reinterpret_cast<Expr *>(Val);
513513
assert(E && "Received null Expr!");
514514
E->printPretty(OS, /*Helper=*/nullptr, Context.getPrintingPolicy());
515-
// FIXME: Include quotes when printing expressions.
516-
NeedQuotes = false;
517515
break;
518516
}
519517
}

0 commit comments

Comments
 (0)