Skip to content

Commit 337d325

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (37 commits)
2 parents bfd1194 + 02232b9 commit 337d325

File tree

118 files changed

+3576
-1530
lines changed

Some content is hidden

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

118 files changed

+3576
-1530
lines changed

clang-tools-extra/include-cleaner/lib/HTMLReport.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,27 @@ void writeHTMLReport(FileID File, const include_cleaner::Includes &Includes,
502502
const Preprocessor &PP, PragmaIncludes *PI,
503503
llvm::raw_ostream &OS) {
504504
Reporter R(OS, Ctx, PP, Includes, PI, File);
505-
const auto& SM = Ctx.getSourceManager();
505+
const auto &SM = Ctx.getSourceManager();
506506
for (Decl *Root : Roots)
507507
walkAST(*Root, [&](SourceLocation Loc, const NamedDecl &D, RefType T) {
508-
if(!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
508+
// FIXME: we should merge this logic with `walkUsed` to prevent
509+
// divergences in the future. It isn't trivial though, as we also update
510+
// RefType. Since HTMLReport is only used for debugging purposes,
511+
// divergences aren't critical.
512+
auto SpellLoc = SM.getSpellingLoc(Loc);
513+
// Tokens resulting from macro concatenation ends up in scratch space and
514+
// clang currently doesn't have a good/simple APIs for tracking where
515+
// pieces of a concataned token originated from.
516+
// So we use the macro expansion location instead, and downgrade reference
517+
// type to ambigious to prevent false negatives.
518+
if (SM.isWrittenInScratchSpace(SpellLoc)) {
519+
Loc = SM.getExpansionLoc(Loc);
520+
if (T == RefType::Explicit)
521+
T = RefType::Ambiguous;
522+
SpellLoc = SM.getSpellingLoc(Loc);
523+
}
524+
auto FID = SM.getFileID(SpellLoc);
525+
if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
509526
return;
510527
R.addRef(SymbolReference{D, Loc, T});
511528
});

clang-tools-extra/include-cleaner/lib/Record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ toFileEntries(llvm::ArrayRef<StringRef> FileNames, FileManager &FM) {
424424
llvm::SmallVector<FileEntryRef> Results;
425425

426426
for (auto FName : FileNames) {
427-
// FIMXE: log the failing cases?
427+
// FIXME: log the failing cases?
428428
if (auto FE = FM.getOptionalFileRef(FName))
429429
Results.push_back(*FE);
430430
}

clang-tools-extra/test/clang-tidy/checkers/bugprone/invalid-enum-default-initialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Enum2 E2_2 = Enum2();
4242
// CHECK-NOTES: :14:6: note: enum is defined here
4343

4444
void f1() {
45-
static Enum1 S; // FIMXE: warn for this?
45+
static Enum1 S; // FIXME: warn for this?
4646
Enum1 A;
4747
Enum1 B = Enum1();
4848
// CHECK-NOTES: :[[@LINE-1]]:13: warning: enum value of type 'Enum1' initialized with invalid value of 0, enum doesn't have a zero-value enumerator
@@ -62,7 +62,7 @@ void f2() {
6262
// CHECK-NOTES: :9:12: note: enum is defined here
6363
// CHECK-NOTES: :[[@LINE-3]]:17: warning: enum value of type 'Enum1' initialized with invalid value of 0, enum doesn't have a zero-value enumerator
6464
// CHECK-NOTES: :9:12: note: enum is defined here
65-
Enum1 D[5] = {}; // FIMXE: warn for this?
65+
Enum1 D[5] = {}; // FIXME: warn for this?
6666
// CHECK-NOTES: :[[@LINE-1]]:16: warning: enum value of type 'Enum1' initialized with invalid value of 0, enum doesn't have a zero-value enumerator
6767
// CHECK-NOTES: :9:12: note: enum is defined here
6868
}

clang/bindings/python/clang/cindex.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,19 +3170,55 @@ def string(self) -> CompletionString | None:
31703170
return None
31713171
return CompletionString(res)
31723172

3173+
__deprecation_message = (
3174+
"'CompletionChunk.{}' will be removed in a future release. "
3175+
"All uses of 'CompletionChunk.{}' should be replaced by checking "
3176+
"if 'CompletionChunk.kind` is equal to 'CompletionChunkKind.{}'."
3177+
)
3178+
31733179
def isKindOptional(self) -> bool:
3180+
deprecation_message = self.__deprecation_message.format(
3181+
"isKindOptional",
3182+
"isKindOptional",
3183+
"OPTIONAL",
3184+
)
3185+
warnings.warn(deprecation_message, DeprecationWarning)
31743186
return self.kind == CompletionChunkKind.OPTIONAL
31753187

31763188
def isKindTypedText(self) -> bool:
3189+
deprecation_message = self.__deprecation_message.format(
3190+
"isKindTypedText",
3191+
"isKindTypedText",
3192+
"TYPED_TEXT",
3193+
)
3194+
warnings.warn(deprecation_message, DeprecationWarning)
31773195
return self.kind == CompletionChunkKind.TYPED_TEXT
31783196

31793197
def isKindPlaceHolder(self) -> bool:
3198+
deprecation_message = self.__deprecation_message.format(
3199+
"isKindPlaceHolder",
3200+
"isKindPlaceHolder",
3201+
"PLACEHOLDER",
3202+
)
3203+
warnings.warn(deprecation_message, DeprecationWarning)
31803204
return self.kind == CompletionChunkKind.PLACEHOLDER
31813205

31823206
def isKindInformative(self) -> bool:
3207+
deprecation_message = self.__deprecation_message.format(
3208+
"isKindInformative",
3209+
"isKindInformative",
3210+
"INFORMATIVE",
3211+
)
3212+
warnings.warn(deprecation_message, DeprecationWarning)
31833213
return self.kind == CompletionChunkKind.INFORMATIVE
31843214

31853215
def isKindResultType(self) -> bool:
3216+
deprecation_message = self.__deprecation_message.format(
3217+
"isKindResultType",
3218+
"isKindResultType",
3219+
"RESULT_TYPE",
3220+
)
3221+
warnings.warn(deprecation_message, DeprecationWarning)
31863222
return self.kind == CompletionChunkKind.RESULT_TYPE
31873223

31883224

clang/docs/LanguageExtensions.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,50 @@ between the host and device is known to be compatible.
28842884
);
28852885
#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_param_types : disable
28862886
2887+
``__cl_clang_function_scope_local_variables``
2888+
----------------------------------------------
2889+
2890+
This extension allows declaring variables in the local address space within
2891+
function scope, including non-kernel functions or nested scopes within a kernel,
2892+
using regular OpenCL extension pragma mechanism detailed in `the OpenCL
2893+
Extension Specification, section 1.2
2894+
<https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#extensions-overview>`_.
2895+
2896+
This relaxes the `Declaration Scopes and Variable Types
2897+
<https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#_usage_for_declaration_scopes_and_variable_types>`_
2898+
rule that limits local-address-space variable declarations to the outermost
2899+
compound statement inside the body of the kernel function.
2900+
2901+
To expose static local allocations at kernel scope, targets can either force-
2902+
inline non-kernel functions that declare local memory or pass a kernel-allocated
2903+
local buffer to those functions via an implicit argument.
2904+
2905+
.. code-block:: c++
2906+
2907+
#pragma OPENCL EXTENSION __cl_clang_function_scope_local_variables : enable
2908+
kernel void kernel1(...)
2909+
{
2910+
{
2911+
local float a; // compiled - no diagnostic generated
2912+
}
2913+
}
2914+
void foo()
2915+
{
2916+
local float c; // compiled - no diagnostic generated
2917+
}
2918+
2919+
#pragma OPENCL EXTENSION __cl_clang_function_scope_local_variables : disable
2920+
kernel void kernel2(...)
2921+
{
2922+
{
2923+
local float a; // error - variables in the local address space can only be declared in the outermost scope of a kernel function
2924+
}
2925+
}
2926+
void bar()
2927+
{
2928+
local float c; // error - non-kernel function variable cannot be declared in local address space
2929+
}
2930+
28872931
Remove address space builtin function
28882932
-------------------------------------
28892933

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Miscellaneous Clang Crashes Fixed
198198
- Fixed a crash when attempting to jump over initialization of a variable with variably modified type. (#GH175540)
199199
- Fixed a crash when using loop hint with a value dependent argument inside a
200200
generic lambda. (#GH172289)
201+
- Fixed a crash in C++ overload resolution with ``_Atomic``-qualified argument types. (#GH170433)
201202

202203
OpenACC Specific Changes
203204
------------------------
@@ -302,6 +303,13 @@ Sanitizers
302303

303304
Python Binding Changes
304305
----------------------
306+
- Add deprecation warnings to ``CompletionChunk.isKind...`` methods.
307+
These will be removed in a future release. Existing uses should be adapted
308+
to directly compare equality of the ``CompletionChunk`` kind with
309+
the corresponding ``CompletionChunkKind`` variant.
310+
311+
Affected methods: ``isKindOptional``, ``isKindTypedText``, ``isKindPlaceHolder``,
312+
``isKindInformative`` and ``isKindResultType``.
305313

306314
OpenMP Support
307315
--------------

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,7 @@ DEF_TRAVERSE_STMT(CXXNewExpr, {
27972797
DEF_TRAVERSE_STMT(OffsetOfExpr, {
27982798
// The child-iterator will pick up the expression representing
27992799
// the field.
2800-
// FIMXE: for code like offsetof(Foo, a.b.c), should we get
2800+
// FIXME: for code like offsetof(Foo, a.b.c), should we get
28012801
// making a MemberExpr callbacks for Foo.a, Foo.a.b, and Foo.a.b.c?
28022802
TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
28032803
})

clang/include/clang/Analysis/Analyses/LifetimeSafety/Checker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace clang::lifetimes::internal {
2828
void runLifetimeChecker(const LoanPropagationAnalysis &LoanPropagation,
2929
const LiveOriginsAnalysis &LiveOrigins,
3030
const FactManager &FactMgr, AnalysisDeclContext &ADC,
31-
LifetimeSafetyReporter *Reporter);
31+
LifetimeSafetySemaHelper *SemaHelper);
3232

3333
} // namespace clang::lifetimes::internal
3434

clang/include/clang/Analysis/Analyses/LifetimeSafety/Facts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class TestPointFact : public Fact {
195195
class FactManager {
196196
public:
197197
FactManager(const AnalysisDeclContext &AC, const CFG &Cfg)
198-
: OriginMgr(AC.getASTContext()) {
198+
: OriginMgr(AC.getASTContext(), AC.getDecl()) {
199199
BlockToFacts.resize(Cfg.getNumBlockIDs());
200200
}
201201

clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,20 @@ enum class SuggestionScope {
4242
IntraTU // For suggestions on definitions local to a Translation Unit.
4343
};
4444

45-
class LifetimeSafetyReporter {
45+
/// Abstract interface for operations requiring Sema access.
46+
///
47+
/// This class exists to break a circular dependency: the LifetimeSafety
48+
/// analysis target cannot directly depend on clangSema (which would create the
49+
/// cycle: clangSema -> clangAnalysis -> clangAnalysisLifetimeSafety ->
50+
/// clangSema).
51+
///
52+
/// Instead, this interface is implemented in AnalysisBasedWarnings.cpp (part of
53+
/// clangSema), allowing the analysis to report diagnostics and modify the AST
54+
/// through Sema without introducing a circular dependency.
55+
class LifetimeSafetySemaHelper {
4656
public:
47-
LifetimeSafetyReporter() = default;
48-
virtual ~LifetimeSafetyReporter() = default;
57+
LifetimeSafetySemaHelper() = default;
58+
virtual ~LifetimeSafetySemaHelper() = default;
4959

5060
virtual void reportUseAfterFree(const Expr *IssueExpr, const Expr *UseExpr,
5161
SourceLocation FreeLoc,
@@ -56,15 +66,24 @@ class LifetimeSafetyReporter {
5666
SourceLocation ExpiryLoc,
5767
Confidence Confidence) {}
5868

59-
// Suggests lifetime bound annotations for function paramters
60-
virtual void suggestAnnotation(SuggestionScope Scope,
61-
const ParmVarDecl *ParmToAnnotate,
62-
const Expr *EscapeExpr) {}
69+
// Suggests lifetime bound annotations for function paramters.
70+
virtual void suggestLifetimeboundToParmVar(SuggestionScope Scope,
71+
const ParmVarDecl *ParmToAnnotate,
72+
const Expr *EscapeExpr) {}
73+
74+
// Suggests lifetime bound annotations for implicit this.
75+
virtual void suggestLifetimeboundToImplicitThis(SuggestionScope Scope,
76+
const CXXMethodDecl *MD,
77+
const Expr *EscapeExpr) {}
78+
79+
// Adds inferred lifetime bound attribute for implicit this to its
80+
// TypeSourceInfo.
81+
virtual void addLifetimeBoundToImplicitThis(const CXXMethodDecl *MD) {}
6382
};
6483

6584
/// The main entry point for the analysis.
6685
void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC,
67-
LifetimeSafetyReporter *Reporter,
86+
LifetimeSafetySemaHelper *SemaHelper,
6887
LifetimeSafetyStats &Stats, bool CollectStats);
6988

7089
namespace internal {
@@ -85,7 +104,7 @@ struct LifetimeFactory {
85104
class LifetimeSafetyAnalysis {
86105
public:
87106
LifetimeSafetyAnalysis(AnalysisDeclContext &AC,
88-
LifetimeSafetyReporter *Reporter);
107+
LifetimeSafetySemaHelper *SemaHelper);
89108

90109
void run();
91110

@@ -98,7 +117,7 @@ class LifetimeSafetyAnalysis {
98117

99118
private:
100119
AnalysisDeclContext &AC;
101-
LifetimeSafetyReporter *Reporter;
120+
LifetimeSafetySemaHelper *SemaHelper;
102121
LifetimeFactory Factory;
103122
std::unique_ptr<FactManager> FactMgr;
104123
std::unique_ptr<LiveOriginsAnalysis> LiveOrigins;

0 commit comments

Comments
 (0)