Skip to content

Commit 541e697

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW23) #3852
LLVM: llvm/llvm-project@caf86d2 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@485c8c7
2 parents e8d8b3a + fd85b9d commit 541e697

File tree

1,745 files changed

+109468
-84203
lines changed

Some content is hidden

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

1,745 files changed

+109468
-84203
lines changed

clang-tools-extra/clangd/ClangdServer.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
7575
const CanonicalIncludes &CanonIncludes) override {
7676
if (FIndex)
7777
FIndex->updatePreamble(Path, Version, Ctx, std::move(PP), CanonIncludes);
78-
if (ServerCallbacks)
79-
ServerCallbacks->onSemanticsMaybeChanged(Path);
8078
}
8179

8280
void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {
@@ -105,6 +103,11 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
105103
ServerCallbacks->onFileUpdated(File, Status);
106104
}
107105

106+
void onPreamblePublished(PathRef File) override {
107+
if (ServerCallbacks)
108+
ServerCallbacks->onSemanticsMaybeChanged(File);
109+
}
110+
108111
private:
109112
FileIndex *FIndex;
110113
ClangdServer::Callbacks *ServerCallbacks;

clang-tools-extra/clangd/TUScheduler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ void PreambleThread::build(Request Req) {
909909
ASTPeer.updatePreamble(std::move(Req.CI), std::move(Req.Inputs),
910910
LatestBuild, std::move(Req.CIDiags),
911911
std::move(Req.WantDiags));
912+
Callbacks.onPreamblePublished(FileName);
912913
});
913914

914915
if (!LatestBuild || Inputs.ForceRebuild) {

clang-tools-extra/clangd/TUScheduler.h

+5
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class ParsingCallbacks {
169169

170170
/// Called whenever the TU status is updated.
171171
virtual void onFileUpdated(PathRef File, const TUStatus &Status) {}
172+
173+
/// Preamble for the TU have changed. This might imply new semantics (e.g.
174+
/// different highlightings). Any actions on the file are guranteed to see new
175+
/// preamble after the callback.
176+
virtual void onPreamblePublished(PathRef File) {}
172177
};
173178

174179
/// Handles running tasks for ClangdServer and managing the resources (e.g.,

clang/cmake/caches/Fuchsia-stage2.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ if(FUCHSIA_SDK)
145145
set(FUCHSIA_x86_64-unknown-fuchsia_NAME x64)
146146
set(FUCHSIA_riscv64-unknown-fuchsia_NAME riscv64)
147147
foreach(target i386-unknown-fuchsia;x86_64-unknown-fuchsia;aarch64-unknown-fuchsia;riscv64-unknown-fuchsia)
148-
set(FUCHSIA_${target}_COMPILER_FLAGS "--target=${target} -I${FUCHSIA_SDK}/pkg/fdio/include")
148+
set(FUCHSIA_${target}_COMPILER_FLAGS "--target=${target} -I${FUCHSIA_SDK}/pkg/sync/include -I${FUCHSIA_SDK}/pkg/fdio/include")
149149
set(FUCHSIA_${target}_LINKER_FLAGS "-L${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/lib")
150150
set(FUCHSIA_${target}_SYSROOT "${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/sysroot")
151151
endforeach()

clang/docs/SanitizerCoverage.rst

+9-3
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,17 @@ will not be instrumented.
312312
// for every non-constant array index.
313313
void __sanitizer_cov_trace_gep(uintptr_t Idx);
314314

315-
Partially disabling instrumentation
316-
===================================
315+
Disabling instrumentation with ``__attribute__((no_sanitize("coverage")))``
316+
===========================================================================
317+
318+
It is possible to disable coverage instrumentation for select functions via the
319+
function attribute ``__attribute__((no_sanitize("coverage")))``.
320+
321+
Disabling instrumentation without source modification
322+
=====================================================
317323

318324
It is sometimes useful to tell SanitizerCoverage to instrument only a subset of the
319-
functions in your target.
325+
functions in your target without modifying source files.
320326
With ``-fsanitize-coverage-allowlist=allowlist.txt``
321327
and ``-fsanitize-coverage-blocklist=blocklist.txt``,
322328
you can specify such a subset through the combination of an allowlist and a blocklist.

clang/include/clang/Basic/Attr.td

+4
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,10 @@ def NoSanitize : InheritableAttr {
35353535
}
35363536
return Mask;
35373537
}
3538+
3539+
bool hasCoverage() const {
3540+
return llvm::is_contained(sanitizers(), "coverage");
3541+
}
35383542
}];
35393543
}
35403544

clang/include/clang/Basic/AttrDocs.td

+11-6
Original file line numberDiff line numberDiff line change
@@ -3736,12 +3736,17 @@ def NoSanitizeDocs : Documentation {
37363736
let Content = [{
37373737
Use the ``no_sanitize`` attribute on a function or a global variable
37383738
declaration to specify that a particular instrumentation or set of
3739-
instrumentations should not be applied. The attribute takes a list of
3740-
string literals, which have the same meaning as values accepted by the
3741-
``-fno-sanitize=`` flag. For example,
3742-
``__attribute__((no_sanitize("address", "thread")))`` specifies that
3743-
AddressSanitizer and ThreadSanitizer should not be applied to the
3744-
function or variable.
3739+
instrumentations should not be applied.
3740+
3741+
The attribute takes a list of string literals with the following accepted
3742+
values:
3743+
* all values accepted by ``-fno-sanitize=``;
3744+
* ``coverage``, to disable SanitizerCoverage instrumentation.
3745+
3746+
For example, ``__attribute__((no_sanitize("address", "thread")))`` specifies
3747+
that AddressSanitizer and ThreadSanitizer should not be applied to the function
3748+
or variable. Using ``__attribute__((no_sanitize("coverage")))`` specifies that
3749+
SanitizerCoverage should not be applied to the function.
37453750

37463751
See :ref:`Controlling Code Generation <controlling-code-generation>` for a
37473752
full list of supported sanitizer flags.

clang/include/clang/Basic/Builtins.def

+16-16
Original file line numberDiff line numberDiff line change
@@ -1577,22 +1577,22 @@ BUILTIN(__builtin_nontemporal_store, "v.", "t")
15771577
BUILTIN(__builtin_nontemporal_load, "v.", "t")
15781578

15791579
// Coroutine intrinsics.
1580-
BUILTIN(__builtin_coro_resume, "vv*", "")
1581-
BUILTIN(__builtin_coro_destroy, "vv*", "")
1582-
BUILTIN(__builtin_coro_done, "bv*", "n")
1583-
BUILTIN(__builtin_coro_promise, "v*v*IiIb", "n")
1584-
1585-
BUILTIN(__builtin_coro_size, "z", "n")
1586-
BUILTIN(__builtin_coro_frame, "v*", "n")
1587-
BUILTIN(__builtin_coro_noop, "v*", "n")
1588-
BUILTIN(__builtin_coro_free, "v*v*", "n")
1589-
1590-
BUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n")
1591-
BUILTIN(__builtin_coro_alloc, "b", "n")
1592-
BUILTIN(__builtin_coro_begin, "v*v*", "n")
1593-
BUILTIN(__builtin_coro_end, "bv*Ib", "n")
1594-
BUILTIN(__builtin_coro_suspend, "cIb", "n")
1595-
BUILTIN(__builtin_coro_param, "bv*v*", "n")
1580+
LANGBUILTIN(__builtin_coro_resume, "vv*", "", COR_LANG)
1581+
LANGBUILTIN(__builtin_coro_destroy, "vv*", "", COR_LANG)
1582+
LANGBUILTIN(__builtin_coro_done, "bv*", "n", COR_LANG)
1583+
LANGBUILTIN(__builtin_coro_promise, "v*v*IiIb", "n", COR_LANG)
1584+
1585+
LANGBUILTIN(__builtin_coro_size, "z", "n", COR_LANG)
1586+
LANGBUILTIN(__builtin_coro_frame, "v*", "n", COR_LANG)
1587+
LANGBUILTIN(__builtin_coro_noop, "v*", "n", COR_LANG)
1588+
LANGBUILTIN(__builtin_coro_free, "v*v*", "n", COR_LANG)
1589+
1590+
LANGBUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n", COR_LANG)
1591+
LANGBUILTIN(__builtin_coro_alloc, "b", "n", COR_LANG)
1592+
LANGBUILTIN(__builtin_coro_begin, "v*v*", "n", COR_LANG)
1593+
LANGBUILTIN(__builtin_coro_end, "bv*Ib", "n", COR_LANG)
1594+
LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", COR_LANG)
1595+
LANGBUILTIN(__builtin_coro_param, "bv*v*", "n", COR_LANG)
15961596

15971597
// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
15981598
// We need the generic prototype, since the packet type could be anything.

clang/include/clang/Basic/Builtins.h

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum LanguageID {
3737
OCLC1X_LANG = 0x40, // builtin for OpenCL C 1.x only.
3838
OMP_LANG = 0x80, // builtin requires OpenMP.
3939
CUDA_LANG = 0x100, // builtin requires CUDA.
40+
COR_LANG = 0x200, // builtin requires use of 'fcoroutine-ts' option.
4041
ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages.
4142
ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode.
4243
ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG, // builtin requires MS mode.

clang/include/clang/Basic/CodeGenOptions.h

+6
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
452452
bool hasMaybeUnusedDebugInfo() const {
453453
return getDebugInfo() >= codegenoptions::UnusedTypeInfo;
454454
}
455+
456+
// Check if any one of SanitizeCoverage* is enabled.
457+
bool hasSanitizeCoverage() const {
458+
return SanitizeCoverageType || SanitizeCoverageIndirectCalls ||
459+
SanitizeCoverageTraceCmp;
460+
}
455461
};
456462

457463
} // end namespace clang

clang/include/clang/Basic/DiagnosticLexKinds.td

+4-2
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,11 @@ def err_pp_malformed_ident : Error<"invalid #ident directive">;
455455
def err_pp_unterminated_conditional : Error<
456456
"unterminated conditional directive">;
457457
def pp_err_else_after_else : Error<"#else after #else">;
458-
def pp_err_elif_after_else : Error<"#elif after #else">;
458+
def pp_err_elif_after_else : Error<
459+
"%select{#elif|#elifdef|#elifndef}0 after #else">;
459460
def pp_err_else_without_if : Error<"#else without #if">;
460-
def pp_err_elif_without_if : Error<"#elif without #if">;
461+
def pp_err_elif_without_if : Error<
462+
"%select{#elif|#elifdef|#elifndef}0 without #if">;
461463
def err_pp_endif_without_if : Error<"#endif without #if">;
462464
def err_pp_expected_value_in_expr : Error<"expected value in expression">;
463465
def err_pp_expected_rparen : Error<"expected ')' in preprocessor expression">;

clang/include/clang/Basic/TokenKinds.def

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ PPKEYWORD(if)
9898
PPKEYWORD(ifdef)
9999
PPKEYWORD(ifndef)
100100
PPKEYWORD(elif)
101+
PPKEYWORD(elifdef)
102+
PPKEYWORD(elifndef)
101103
PPKEYWORD(else)
102104
PPKEYWORD(endif)
103105
PPKEYWORD(defined)

clang/include/clang/Driver/Options.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -6092,7 +6092,7 @@ def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">,
60926092
HelpText<"Set runtime encoding, supports only UTF-8">,
60936093
Alias<fexec_charset_EQ>;
60946094
def _SLASH_std : CLCompileJoined<"std:">,
6095-
HelpText<"Set language version (c++14,c++17,c++latest,c11,c17)">;
6095+
HelpText<"Set language version (c++14,c++17,c++20,c++latest,c11,c17)">;
60966096
def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
60976097
MetaVarName<"<macro>">, Alias<U>;
60986098
def _SLASH_validate_charset : CLFlag<"validate-charset">,

clang/include/clang/Format/Format.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,9 @@ struct FormatStyle {
19731973
ELAAMS_Always,
19741974
};
19751975

1976-
/// Defines in which cases to put empty line after access modifiers.
1976+
/// Defines when to put an empty line after access modifiers.
1977+
/// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
1978+
/// empty lines between two access modifiers.
19771979
EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;
19781980

19791981
/// Different styles for empty line before access modifiers.

clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ enum TokenKind {
4444
pp_ifdef,
4545
pp_ifndef,
4646
pp_elif,
47+
pp_elifdef,
48+
pp_elifndef,
4749
pp_else,
4850
pp_endif,
4951
decl_at_import,

clang/include/clang/Lex/PPCallbacks.h

+58
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,22 @@ class PPCallbacks {
351351
const MacroDefinition &MD) {
352352
}
353353

354+
/// Hook called whenever an \#elifdef branch is taken.
355+
/// \param Loc the source location of the directive.
356+
/// \param MacroNameTok Information on the token being tested.
357+
/// \param MD The MacroDefinition if the name was a macro, null otherwise.
358+
virtual void Elifdef(SourceLocation Loc, const Token &MacroNameTok,
359+
const MacroDefinition &MD) {
360+
}
361+
/// Hook called whenever an \#elifdef is skipped.
362+
/// \param Loc the source location of the directive.
363+
/// \param ConditionRange The SourceRange of the expression being tested.
364+
/// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
365+
// FIXME: better to pass in a list (or tree!) of Tokens.
366+
virtual void Elifdef(SourceLocation Loc, SourceRange ConditionRange,
367+
SourceLocation IfLoc) {
368+
}
369+
354370
/// Hook called whenever an \#ifndef is seen.
355371
/// \param Loc the source location of the directive.
356372
/// \param MacroNameTok Information on the token being tested.
@@ -359,6 +375,22 @@ class PPCallbacks {
359375
const MacroDefinition &MD) {
360376
}
361377

378+
/// Hook called whenever an \#elifndef branch is taken.
379+
/// \param Loc the source location of the directive.
380+
/// \param MacroNameTok Information on the token being tested.
381+
/// \param MD The MacroDefinition if the name was a macro, null otherwise.
382+
virtual void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
383+
const MacroDefinition &MD) {
384+
}
385+
/// Hook called whenever an \#elifndef is skipped.
386+
/// \param Loc the source location of the directive.
387+
/// \param ConditionRange The SourceRange of the expression being tested.
388+
/// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
389+
// FIXME: better to pass in a list (or tree!) of Tokens.
390+
virtual void Elifndef(SourceLocation Loc, SourceRange ConditionRange,
391+
SourceLocation IfLoc) {
392+
}
393+
362394
/// Hook called whenever an \#else is seen.
363395
/// \param Loc the source location of the directive.
364396
/// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
@@ -586,13 +618,39 @@ class PPChainedCallbacks : public PPCallbacks {
586618
Second->Ifdef(Loc, MacroNameTok, MD);
587619
}
588620

621+
/// Hook called whenever an \#elifdef is taken.
622+
void Elifdef(SourceLocation Loc, const Token &MacroNameTok,
623+
const MacroDefinition &MD) override {
624+
First->Elifdef(Loc, MacroNameTok, MD);
625+
Second->Elifdef(Loc, MacroNameTok, MD);
626+
}
627+
/// Hook called whenever an \#elifdef is skipped.
628+
void Elifdef(SourceLocation Loc, SourceRange ConditionRange,
629+
SourceLocation IfLoc) override {
630+
First->Elifdef(Loc, ConditionRange, IfLoc);
631+
Second->Elifdef(Loc, ConditionRange, IfLoc);
632+
}
633+
589634
/// Hook called whenever an \#ifndef is seen.
590635
void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
591636
const MacroDefinition &MD) override {
592637
First->Ifndef(Loc, MacroNameTok, MD);
593638
Second->Ifndef(Loc, MacroNameTok, MD);
594639
}
595640

641+
/// Hook called whenever an \#elifndef is taken.
642+
void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
643+
const MacroDefinition &MD) override {
644+
First->Elifndef(Loc, MacroNameTok, MD);
645+
Second->Elifndef(Loc, MacroNameTok, MD);
646+
}
647+
/// Hook called whenever an \#elifndef is skipped.
648+
void Elifndef(SourceLocation Loc, SourceRange ConditionRange,
649+
SourceLocation IfLoc) override {
650+
First->Elifndef(Loc, ConditionRange, IfLoc);
651+
Second->Elifndef(Loc, ConditionRange, IfLoc);
652+
}
653+
596654
/// Hook called whenever an \#else is seen.
597655
void Else(SourceLocation Loc, SourceLocation IfLoc) override {
598656
First->Else(Loc, IfLoc);

clang/include/clang/Lex/PPConditionalDirectiveRecord.h

+8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ class PPConditionalDirectiveRecord : public PPCallbacks {
9393
const MacroDefinition &MD) override;
9494
void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
9595
const MacroDefinition &MD) override;
96+
void Elifdef(SourceLocation Loc, const Token &MacroNameTok,
97+
const MacroDefinition &MD) override;
98+
void Elifdef(SourceLocation Loc, SourceRange ConditionRange,
99+
SourceLocation IfLoc) override;
100+
void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
101+
const MacroDefinition &MD) override;
102+
void Elifndef(SourceLocation Loc, SourceRange ConditionRange,
103+
SourceLocation IfLoc) override;
96104
void Else(SourceLocation Loc, SourceLocation IfLoc) override;
97105
void Endif(SourceLocation Loc, SourceLocation IfLoc) override;
98106
};

clang/include/clang/Lex/PreprocessingRecord.h

+7
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@ class Token;
539539
void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
540540
const MacroDefinition &MD) override;
541541

542+
using PPCallbacks::Elifdef;
543+
using PPCallbacks::Elifndef;
544+
void Elifdef(SourceLocation Loc, const Token &MacroNameTok,
545+
const MacroDefinition &MD) override;
546+
void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
547+
const MacroDefinition &MD) override;
548+
542549
/// Hook called whenever the 'defined' operator is seen.
543550
void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
544551
SourceRange Range) override;

clang/include/clang/Lex/Preprocessor.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,8 @@ class Preprocessor {
23572357
bool ReadAnyTokensBeforeDirective);
23582358
void HandleEndifDirective(Token &EndifToken);
23592359
void HandleElseDirective(Token &Result, const Token &HashToken);
2360-
void HandleElifDirective(Token &ElifToken, const Token &HashToken);
2360+
void HandleElifFamilyDirective(Token &ElifToken, const Token &HashToken,
2361+
tok::PPKeywordKind Kind);
23612362

23622363
// Pragmas.
23632364
void HandlePragmaDirective(PragmaIntroducer Introducer);

clang/lib/Basic/Builtins.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo,
6060
bool BuiltinsUnsupported =
6161
(LangOpts.NoBuiltin || LangOpts.isNoBuiltinFunc(BuiltinInfo.Name)) &&
6262
strchr(BuiltinInfo.Attributes, 'f');
63+
bool CorBuiltinsUnsupported =
64+
!LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG);
6365
bool MathBuiltinsUnsupported =
6466
LangOpts.NoMathBuiltin && BuiltinInfo.HeaderName &&
6567
llvm::StringRef(BuiltinInfo.HeaderName).equals("math.h");
@@ -78,10 +80,11 @@ bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo,
7880
bool CUDAUnsupported = !LangOpts.CUDA && BuiltinInfo.Langs == CUDA_LANG;
7981
bool CPlusPlusUnsupported =
8082
!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG;
81-
return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported &&
82-
!OclC1Unsupported && !OclC2Unsupported && !OpenMPUnsupported &&
83-
!GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
84-
!CPlusPlusUnsupported && !CUDAUnsupported;
83+
return !BuiltinsUnsupported && !CorBuiltinsUnsupported &&
84+
!MathBuiltinsUnsupported && !OclCUnsupported && !OclC1Unsupported &&
85+
!OclC2Unsupported && !OpenMPUnsupported && !GnuModeUnsupported &&
86+
!MSModeUnsupported && !ObjCUnsupported && !CPlusPlusUnsupported &&
87+
!CUDAUnsupported;
8588
}
8689

8790
/// initializeBuiltins - Mark the identifiers for all the builtins with their

clang/lib/Basic/IdentifierTable.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
343343
CASE( 6, 'p', 'a', pragma);
344344

345345
CASE( 7, 'd', 'f', defined);
346+
CASE( 7, 'e', 'i', elifdef);
346347
CASE( 7, 'i', 'c', include);
347348
CASE( 7, 'w', 'r', warning);
348349

350+
CASE( 8, 'e', 'i', elifndef);
349351
CASE( 8, 'u', 'a', unassert);
350352
CASE(12, 'i', 'c', include_next);
351353

0 commit comments

Comments
 (0)