Skip to content

Commit 54920b9

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web'
2 parents 21f3f75 + a92376d commit 54920b9

File tree

414 files changed

+27783
-7116
lines changed

Some content is hidden

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

414 files changed

+27783
-7116
lines changed

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
446446
case DiagnosticsEngine::Warning:
447447
CheckName = "clang-diagnostic-warning";
448448
break;
449+
case DiagnosticsEngine::Remark:
450+
CheckName = "clang-diagnostic-remark";
451+
break;
449452
default:
450453
CheckName = "clang-diagnostic-unknown";
451454
break;
@@ -460,7 +463,10 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
460463
Level = ClangTidyError::Error;
461464
LastErrorRelatesToUserCode = true;
462465
LastErrorPassesLineFilter = true;
466+
} else if (DiagLevel == DiagnosticsEngine::Remark) {
467+
Level = ClangTidyError::Remark;
463468
}
469+
464470
bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning &&
465471
Context.treatAsError(CheckName);
466472
Errors.emplace_back(CheckName, Level, Context.getCurrentBuildDirectory(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// A
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module A { header "A.h" }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: rm -rf %t
2+
// RUN: cp -r %S/Inputs/remarks %t
3+
// RUN: cp %s %t/t.cpp
4+
5+
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-module-import' t.cpp -- \
6+
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
7+
// RUN: -fsyntax-only \
8+
// RUN: -I%S/Inputs/remarks \
9+
// RUN: -working-directory=%t \
10+
// RUN: -Rmodule-build -Rmodule-import t.cpp 2>&1 |\
11+
// RUN: FileCheck %s -implicit-check-not "remark:"
12+
13+
#include "A.h"
14+
// CHECK: remark: importing module 'A' from {{.*}} [clang-diagnostic-module-import]
15+

clang/docs/OpenCLSupport.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Missing features or with limited support
340340
.. _opencl_300:
341341

342342
OpenCL C 3.0 Usage
343-
================================
343+
==================
344344

345345
OpenCL C 3.0 language standard makes most OpenCL C 2.0 features optional. Optional
346346
functionality in OpenCL C 3.0 is indicated with the presence of feature-test macros
@@ -357,7 +357,7 @@ user should specify both (extension and feature) in command-line flag:
357357
358358
359359
OpenCL C 3.0 Implementation Status
360-
================================
360+
----------------------------------
361361

362362
The following table provides an overview of features in OpenCL C 3.0 and their
363363
implementation status.
@@ -371,7 +371,7 @@ implementation status.
371371
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
372372
| Predefined macros | Feature macros | :good:`done` | https://reviews.llvm.org/D95776 |
373373
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
374-
| Feature optionality | Generic address space | :none:`unclaimed` | |
374+
| Feature optionality | Generic address space | :none:`worked on` | https://reviews.llvm.org/D95778 (partial frontend) |
375375
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
376376
| Feature optionality | Builtin function overloads with generic address space | :part:`worked on` | https://reviews.llvm.org/D92004 |
377377
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
@@ -389,6 +389,8 @@ implementation status.
389389
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
390390
| Feature optionality | Work group collective functions | :part:`worked on` | https://reviews.llvm.org/D92004 |
391391
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
392+
| Feature optionality | Image types | :part:`unclaimed` | |
393+
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
392394
| New functionality | RGBA vector components | :good:`done` | https://reviews.llvm.org/D99969 |
393395
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
394396
| New functionality | Subgroup functions | :part:`worked on` | https://reviews.llvm.org/D92004 |

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
@@ -3518,6 +3518,10 @@ def NoSanitize : InheritableAttr {
35183518
}
35193519
return Mask;
35203520
}
3521+
3522+
bool hasCoverage() const {
3523+
return llvm::is_contained(sanitizers(), "coverage");
3524+
}
35213525
}];
35223526
}
35233527

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/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/TargetInfo.h

+6
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,12 @@ class TargetInfo : public virtual TransferrableTargetInfo,
10911091
return std::string(1, *Constraint);
10921092
}
10931093

1094+
/// Replace some escaped characters with another string based on
1095+
/// target-specific rules
1096+
virtual llvm::Optional<std::string> handleAsmEscapedChar(char C) const {
1097+
return llvm::None;
1098+
}
1099+
10941100
/// Returns a string of target-specific clobbers, in LLVM format.
10951101
virtual const char *getClobbers() const = 0;
10961102

clang/include/clang/CrossTU/CrossTranslationUnit.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TranslationUnitDecl;
3838
namespace cross_tu {
3939

4040
enum class index_error_code {
41+
success = 0,
4142
unspecified = 1,
4243
missing_index_file,
4344
invalid_index_format,
@@ -253,6 +254,7 @@ class CrossTranslationUnitContext {
253254
/// In case of on-demand parsing, the invocations for parsing the source
254255
/// files is stored.
255256
llvm::Optional<InvocationListTy> InvocationList;
257+
index_error_code PreviousParsingResult = index_error_code::success;
256258
};
257259

258260
/// Maintain number of AST loads and check for reaching the load limit.

clang/include/clang/Sema/Sema.h

+4
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,10 @@ class Sema final {
20962096
/// Retrieve the current captured region, if any.
20972097
sema::CapturedRegionScopeInfo *getCurCapturedRegion();
20982098

2099+
/// Retrieve the current function, if any, that should be analyzed for
2100+
/// potential availability violations.
2101+
sema::FunctionScopeInfo *getCurFunctionAvailabilityContext();
2102+
20992103
/// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
21002104
SmallVectorImpl<Decl *> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
21012105

clang/include/clang/Tooling/Core/Diagnostic.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct DiagnosticMessage {
6767
/// fixes to be applied.
6868
struct Diagnostic {
6969
enum Level {
70+
Remark = DiagnosticsEngine::Remark,
7071
Warning = DiagnosticsEngine::Warning,
7172
Error = DiagnosticsEngine::Error
7273
};

clang/include/clang/Tooling/DiagnosticsYaml.h

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ template <> struct ScalarEnumerationTraits<clang::tooling::Diagnostic::Level> {
106106
static void enumeration(IO &IO, clang::tooling::Diagnostic::Level &Value) {
107107
IO.enumCase(Value, "Warning", clang::tooling::Diagnostic::Warning);
108108
IO.enumCase(Value, "Error", clang::tooling::Diagnostic::Error);
109+
IO.enumCase(Value, "Remark", clang::tooling::Diagnostic::Remark);
109110
}
110111
};
111112

clang/lib/AST/Stmt.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
646646
continue;
647647
}
648648

649+
const TargetInfo &TI = C.getTargetInfo();
650+
649651
// Escaped "%" character in asm string.
650652
if (CurPtr == StrEnd) {
651653
// % at end of string is invalid (no escape).
@@ -656,6 +658,11 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
656658
char EscapedChar = *CurPtr++;
657659
switch (EscapedChar) {
658660
default:
661+
// Handle target-specific escaped characters.
662+
if (auto MaybeReplaceStr = TI.handleAsmEscapedChar(EscapedChar)) {
663+
CurStringPiece += *MaybeReplaceStr;
664+
continue;
665+
}
659666
break;
660667
case '%': // %% -> %
661668
case '{': // %{ -> {
@@ -688,7 +695,6 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
688695
EscapedChar = *CurPtr++;
689696
}
690697

691-
const TargetInfo &TI = C.getTargetInfo();
692698
const SourceManager &SM = C.getSourceManager();
693699
const LangOptions &LO = C.getLangOpts();
694700

clang/lib/Basic/Targets/M68k.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,30 @@ bool M68kTargetInfo::validateAsmConstraint(
191191
return false;
192192
}
193193

194+
llvm::Optional<std::string>
195+
M68kTargetInfo::handleAsmEscapedChar(char EscChar) const {
196+
char C;
197+
switch (EscChar) {
198+
case '.':
199+
case '#':
200+
C = EscChar;
201+
break;
202+
case '/':
203+
C = '%';
204+
break;
205+
case '$':
206+
C = 's';
207+
break;
208+
case '&':
209+
C = 'd';
210+
break;
211+
default:
212+
return llvm::None;
213+
}
214+
215+
return std::string(1, C);
216+
}
217+
194218
std::string M68kTargetInfo::convertConstraint(const char *&Constraint) const {
195219
if (*Constraint == 'C')
196220
// Two-character constraint; add "^" hint for later parsing

clang/lib/Basic/Targets/M68k.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class LLVM_LIBRARY_VISIBILITY M68kTargetInfo : public TargetInfo {
4747
std::string convertConstraint(const char *&Constraint) const override;
4848
bool validateAsmConstraint(const char *&Name,
4949
TargetInfo::ConstraintInfo &info) const override;
50+
llvm::Optional<std::string> handleAsmEscapedChar(char EscChar) const override;
5051
const char *getClobbers() const override;
5152
BuiltinVaListKind getBuiltinVaListKind() const override;
5253
bool setCPU(const std::string &Name) override;

clang/lib/CodeGen/BackendUtil.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
729729
addBoundsCheckingPass);
730730
}
731731

732-
if (CodeGenOpts.SanitizeCoverageType ||
733-
CodeGenOpts.SanitizeCoverageIndirectCalls ||
734-
CodeGenOpts.SanitizeCoverageTraceCmp) {
732+
if (CodeGenOpts.hasSanitizeCoverage()) {
735733
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
736734
addSanitizerCoveragePass);
737735
PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
@@ -1127,9 +1125,7 @@ static void addSanitizers(const Triple &TargetTriple,
11271125
const LangOptions &LangOpts, PassBuilder &PB) {
11281126
PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM,
11291127
PassBuilder::OptimizationLevel Level) {
1130-
if (CodeGenOpts.SanitizeCoverageType ||
1131-
CodeGenOpts.SanitizeCoverageIndirectCalls ||
1132-
CodeGenOpts.SanitizeCoverageTraceCmp) {
1128+
if (CodeGenOpts.hasSanitizeCoverage()) {
11331129
auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
11341130
MPM.addPass(ModuleSanitizerCoveragePass(
11351131
SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,

clang/lib/CodeGen/CodeGenFunction.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
888888
} while (0);
889889

890890
if (D) {
891-
// Apply the no_sanitize* attributes to SanOpts.
891+
bool NoSanitizeCoverage = false;
892+
892893
for (auto Attr : D->specific_attrs<NoSanitizeAttr>()) {
894+
// Apply the no_sanitize* attributes to SanOpts.
893895
SanitizerMask mask = Attr->getMask();
894896
SanOpts.Mask &= ~mask;
895897
if (mask & SanitizerKind::Address)
@@ -900,7 +902,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
900902
SanOpts.set(SanitizerKind::KernelHWAddress, false);
901903
if (mask & SanitizerKind::KernelHWAddress)
902904
SanOpts.set(SanitizerKind::HWAddress, false);
905+
906+
// SanitizeCoverage is not handled by SanOpts.
907+
if (Attr->hasCoverage())
908+
NoSanitizeCoverage = true;
903909
}
910+
911+
if (NoSanitizeCoverage && CGM.getCodeGenOpts().hasSanitizeCoverage())
912+
Fn->addFnAttr(llvm::Attribute::NoSanitizeCoverage);
904913
}
905914

906915
// Apply sanitizer attributes to the function.

clang/lib/CrossTU/CrossTranslationUnit.cpp

+17-5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class IndexErrorCategory : public std::error_category {
9292

9393
std::string message(int Condition) const override {
9494
switch (static_cast<index_error_code>(Condition)) {
95+
case index_error_code::success:
96+
// There should not be a success error. Jump to unreachable directly.
97+
// Add this case to make the compiler stop complaining.
98+
break;
9599
case index_error_code::unspecified:
96100
return "An unknown error has occurred.";
97101
case index_error_code::missing_index_file:
@@ -667,21 +671,29 @@ llvm::Error CrossTranslationUnitContext::ASTLoader::lazyInitInvocationList() {
667671
/// Lazily initialize the invocation list member used for on-demand parsing.
668672
if (InvocationList)
669673
return llvm::Error::success();
674+
if (index_error_code::success != PreviousParsingResult)
675+
return llvm::make_error<IndexError>(PreviousParsingResult);
670676

671677
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileContent =
672678
llvm::MemoryBuffer::getFile(InvocationListFilePath);
673-
if (!FileContent)
674-
return llvm::make_error<IndexError>(
675-
index_error_code::invocation_list_file_not_found);
679+
if (!FileContent) {
680+
PreviousParsingResult = index_error_code::invocation_list_file_not_found;
681+
return llvm::make_error<IndexError>(PreviousParsingResult);
682+
}
676683
std::unique_ptr<llvm::MemoryBuffer> ContentBuffer = std::move(*FileContent);
677684
assert(ContentBuffer && "If no error was produced after loading, the pointer "
678685
"should not be nullptr.");
679686

680687
llvm::Expected<InvocationListTy> ExpectedInvocationList =
681688
parseInvocationList(ContentBuffer->getBuffer(), PathStyle);
682689

683-
if (!ExpectedInvocationList)
684-
return ExpectedInvocationList.takeError();
690+
// Handle the error to store the code for next call to this function.
691+
if (!ExpectedInvocationList) {
692+
llvm::handleAllErrors(
693+
ExpectedInvocationList.takeError(),
694+
[&](const IndexError &E) { PreviousParsingResult = E.getCode(); });
695+
return llvm::make_error<IndexError>(PreviousParsingResult);
696+
}
685697

686698
InvocationList = *ExpectedInvocationList;
687699

clang/lib/Headers/cuda_wrappers/complex

+8
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,16 @@
7272
#define _GLIBCXX_USE_C99_COMPLEX 0
7373
#define _GLIBCXX_USE_C99_COMPLEX_TR1 0
7474

75+
// Work around a compatibility issue with libstdc++ 11.1.0
76+
// https://bugs.llvm.org/show_bug.cgi?id=50383
77+
#pragma push_macro("__failed_assertion")
78+
#if _GLIBCXX_RELEASE == 11
79+
#define __failed_assertion __cuda_failed_assertion
80+
#endif
81+
7582
#include_next <complex>
7683

84+
#pragma pop_macro("__failed_assertion")
7785
#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX_TR1")
7886
#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX")
7987

0 commit comments

Comments
 (0)