Skip to content

Commit dd3a824

Browse files
committed
Merge from 'master' to 'sycl-web' (#56)
2 parents 5797b8c + aad3d57 commit dd3a824

File tree

257 files changed

+4920
-2097
lines changed

Some content is hidden

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

257 files changed

+4920
-2097
lines changed

clang/cmake/caches/CrossWinToARMLinux.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX OFF CACHE BOOL "")
8989
set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
9090
set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX OFF CACHE BOOL "")
9191

92+
# FIXME: Remove this when https://reviews.llvm.org/D78200 is merged.
93+
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
94+
9295
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
9396
set(LIBCXX_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
9497
set(LIBCXX_SYSROOT "${DEFAULT_SYSROOT}" CACHE STRING "")

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ Modified Compiler Flags
110110
- Duplicate qualifiers on asm statements (ex. `asm volatile volatile ("")`) no
111111
longer produces a warning via -Wduplicate-decl-specifier, but now an error
112112
(this matches GCC's behavior).
113+
- The deprecated argument ``-f[no-]sanitize-recover`` has changed to mean
114+
``-f[no-]sanitize-recover=all`` instead of
115+
``-f[no-]sanitize-recover=undefined,integer`` and is no longer deprecated.
116+
- The argument to ``-f[no-]sanitize-trap=...`` is now optional and defaults to
117+
``all``.
113118

114119
New Pragmas in Clang
115120
--------------------

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ and define the desired behavior for each kind of check:
5454
* ``-fno-sanitize-recover=...``: print a verbose error report and exit the program;
5555
* ``-fsanitize-trap=...``: execute a trap instruction (doesn't require UBSan run-time support).
5656

57+
Note that the ``trap`` / ``recover`` options do not enable the corresponding
58+
sanitizer, and in general need to be accompanied by a suitable ``-fsanitize=``
59+
flag.
60+
5761
For example if you compile/link your program as:
5862

5963
.. code-block:: console

clang/docs/UsersManual.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ are listed below.
14661466

14671467
**-f[no-]sanitize-recover=check1,check2,...**
14681468

1469-
**-f[no-]sanitize-recover=all**
1469+
**-f[no-]sanitize-recover[=all]**
14701470

14711471
Controls which checks enabled by ``-fsanitize=`` flag are non-fatal.
14721472
If the check is fatal, program will halt after the first error
@@ -1492,16 +1492,16 @@ are listed below.
14921492

14931493
**-f[no-]sanitize-trap=check1,check2,...**
14941494

1495+
**-f[no-]sanitize-trap[=all]**
1496+
14951497
Controls which checks enabled by the ``-fsanitize=`` flag trap. This
14961498
option is intended for use in cases where the sanitizer runtime cannot
14971499
be used (for instance, when building libc or a kernel module), or where
14981500
the binary size increase caused by the sanitizer runtime is a concern.
14991501

15001502
This flag is only compatible with :doc:`control flow integrity
15011503
<ControlFlowIntegrity>` schemes and :doc:`UndefinedBehaviorSanitizer`
1502-
checks other than ``vptr``. If this flag
1503-
is supplied together with ``-fsanitize=undefined``, the ``vptr`` sanitizer
1504-
will be implicitly disabled.
1504+
checks other than ``vptr``.
15051505

15061506
This flag is enabled by default for sanitizers in the ``cfi`` group.
15071507

clang/include/clang/Basic/Module.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ class Module {
207207
/// A module with the same name that shadows this module.
208208
Module *ShadowingModule = nullptr;
209209

210-
/// Whether this module is missing a feature from \c Requirements.
211-
unsigned IsMissingRequirement : 1;
210+
/// Whether this module has declared itself unimportable, either because
211+
/// it's missing a requirement from \p Requirements or because it's been
212+
/// shadowed by another module.
213+
unsigned IsUnimportable : 1;
212214

213215
/// Whether we tried and failed to load a module file for this module.
214216
unsigned HasIncompatibleModuleFile : 1;
@@ -384,6 +386,25 @@ class Module {
384386

385387
~Module();
386388

389+
/// Determine whether this module has been declared unimportable.
390+
bool isUnimportable() const { return IsUnimportable; }
391+
392+
/// Determine whether this module has been declared unimportable.
393+
///
394+
/// \param LangOpts The language options used for the current
395+
/// translation unit.
396+
///
397+
/// \param Target The target options used for the current translation unit.
398+
///
399+
/// \param Req If this module is unimportable because of a missing
400+
/// requirement, this parameter will be set to one of the requirements that
401+
/// is not met for use of this module.
402+
///
403+
/// \param ShadowingModule If this module is unimportable because it is
404+
/// shadowed, this parameter will be set to the shadowing module.
405+
bool isUnimportable(const LangOptions &LangOpts, const TargetInfo &Target,
406+
Requirement &Req, Module *&ShadowingModule) const;
407+
387408
/// Determine whether this module is available for use within the
388409
/// current translation unit.
389410
bool isAvailable() const { return IsAvailable; }
@@ -535,7 +556,7 @@ class Module {
535556
const TargetInfo &Target);
536557

537558
/// Mark this module and all of its submodules as unavailable.
538-
void markUnavailable(bool MissingRequirement = false);
559+
void markUnavailable(bool Unimportable);
539560

540561
/// Find the submodule with the given name.
541562
///

clang/include/clang/Driver/Options.td

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,27 +1102,35 @@ def fsanitize_hwaddress_abi_EQ
11021102
: Joined<["-"], "fsanitize-hwaddress-abi=">,
11031103
Group<f_clang_Group>,
11041104
HelpText<"Select the HWAddressSanitizer ABI to target (interceptor or platform, default interceptor). This option is currently unused.">;
1105-
def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group<f_clang_Group>;
1106-
def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
1107-
Flags<[CoreOption, DriverOption]>,
1108-
Group<f_clang_Group>;
11091105
def fsanitize_recover_EQ : CommaJoined<["-"], "fsanitize-recover=">,
11101106
Group<f_clang_Group>,
11111107
HelpText<"Enable recovery for specified sanitizers">;
1112-
def fno_sanitize_recover_EQ
1113-
: CommaJoined<["-"], "fno-sanitize-recover=">,
1114-
Group<f_clang_Group>,
1115-
Flags<[CoreOption, DriverOption]>,
1116-
HelpText<"Disable recovery for specified sanitizers">;
1108+
def fno_sanitize_recover_EQ : CommaJoined<["-"], "fno-sanitize-recover=">,
1109+
Group<f_clang_Group>, Flags<[CoreOption, DriverOption]>,
1110+
HelpText<"Disable recovery for specified sanitizers">;
1111+
def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group<f_clang_Group>,
1112+
Alias<fsanitize_recover_EQ>, AliasArgs<["all"]>;
1113+
def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
1114+
Flags<[CoreOption, DriverOption]>, Group<f_clang_Group>,
1115+
Alias<fno_sanitize_recover_EQ>, AliasArgs<["all"]>;
11171116
def fsanitize_trap_EQ : CommaJoined<["-"], "fsanitize-trap=">, Group<f_clang_Group>,
11181117
HelpText<"Enable trapping for specified sanitizers">;
11191118
def fno_sanitize_trap_EQ : CommaJoined<["-"], "fno-sanitize-trap=">, Group<f_clang_Group>,
11201119
Flags<[CoreOption, DriverOption]>,
11211120
HelpText<"Disable trapping for specified sanitizers">;
1122-
def fsanitize_undefined_trap_on_error : Flag<["-"], "fsanitize-undefined-trap-on-error">,
1123-
Group<f_clang_Group>;
1124-
def fno_sanitize_undefined_trap_on_error : Flag<["-"], "fno-sanitize-undefined-trap-on-error">,
1125-
Group<f_clang_Group>;
1121+
def fsanitize_trap : Flag<["-"], "fsanitize-trap">, Group<f_clang_Group>,
1122+
Alias<fsanitize_trap_EQ>, AliasArgs<["all"]>,
1123+
HelpText<"Enable trapping for all sanitizers">;
1124+
def fno_sanitize_trap : Flag<["-"], "fno-sanitize-trap">, Group<f_clang_Group>,
1125+
Alias<fno_sanitize_trap_EQ>, AliasArgs<["all"]>,
1126+
Flags<[CoreOption, DriverOption]>,
1127+
HelpText<"Disable trapping for all sanitizers">;
1128+
def fsanitize_undefined_trap_on_error
1129+
: Flag<["-"], "fsanitize-undefined-trap-on-error">, Group<f_clang_Group>,
1130+
Alias<fsanitize_trap_EQ>, AliasArgs<["undefined"]>;
1131+
def fno_sanitize_undefined_trap_on_error
1132+
: Flag<["-"], "fno-sanitize-undefined-trap-on-error">, Group<f_clang_Group>,
1133+
Alias<fno_sanitize_trap_EQ>, AliasArgs<["undefined"]>;
11261134
def fsanitize_minimal_runtime : Flag<["-"], "fsanitize-minimal-runtime">,
11271135
Group<f_clang_Group>;
11281136
def fno_sanitize_minimal_runtime : Flag<["-"], "fno-sanitize-minimal-runtime">,

clang/lib/Basic/Module.cpp

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using namespace clang;
3737
Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
3838
bool IsFramework, bool IsExplicit, unsigned VisibilityID)
3939
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
40-
VisibilityID(VisibilityID), IsMissingRequirement(false),
40+
VisibilityID(VisibilityID), IsUnimportable(false),
4141
HasIncompatibleModuleFile(false), IsAvailable(true),
4242
IsFromModuleFile(false), IsFramework(IsFramework), IsExplicit(IsExplicit),
4343
IsSystem(false), IsExternC(false), IsInferred(false),
@@ -46,17 +46,12 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
4646
NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
4747
HasUmbrellaDir(false), NameVisibility(Hidden) {
4848
if (Parent) {
49-
if (!Parent->isAvailable())
50-
IsAvailable = false;
51-
if (Parent->IsSystem)
52-
IsSystem = true;
53-
if (Parent->IsExternC)
54-
IsExternC = true;
55-
if (Parent->NoUndeclaredIncludes)
56-
NoUndeclaredIncludes = true;
57-
if (Parent->ModuleMapIsPrivate)
58-
ModuleMapIsPrivate = true;
59-
IsMissingRequirement = Parent->IsMissingRequirement;
49+
IsAvailable = Parent->isAvailable();
50+
IsUnimportable = Parent->isUnimportable();
51+
IsSystem = Parent->IsSystem;
52+
IsExternC = Parent->IsExternC;
53+
NoUndeclaredIncludes = Parent->NoUndeclaredIncludes;
54+
ModuleMapIsPrivate = Parent->ModuleMapIsPrivate;
6055

6156
Parent->SubModuleIndex[Name] = Parent->SubModules.size();
6257
Parent->SubModules.push_back(this);
@@ -132,25 +127,42 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
132127
return HasFeature;
133128
}
134129

135-
bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
136-
Requirement &Req,
137-
UnresolvedHeaderDirective &MissingHeader,
138-
Module *&ShadowingModule) const {
139-
if (IsAvailable)
140-
return true;
130+
bool Module::isUnimportable(const LangOptions &LangOpts,
131+
const TargetInfo &Target, Requirement &Req,
132+
Module *&ShadowingModule) const {
133+
if (!IsUnimportable)
134+
return false;
141135

142136
for (const Module *Current = this; Current; Current = Current->Parent) {
143137
if (Current->ShadowingModule) {
144138
ShadowingModule = Current->ShadowingModule;
145-
return false;
139+
return true;
146140
}
147141
for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
148142
if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
149143
Current->Requirements[I].second) {
150144
Req = Current->Requirements[I];
151-
return false;
145+
return true;
152146
}
153147
}
148+
}
149+
150+
llvm_unreachable("could not find a reason why module is unimportable");
151+
}
152+
153+
bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
154+
Requirement &Req,
155+
UnresolvedHeaderDirective &MissingHeader,
156+
Module *&ShadowingModule) const {
157+
if (IsAvailable)
158+
return true;
159+
160+
if (isUnimportable(LangOpts, Target, Req, ShadowingModule))
161+
return false;
162+
163+
// FIXME: All missing headers are listed on the top-level module. Should we
164+
// just look there?
165+
for (const Module *Current = this; Current; Current = Current->Parent) {
154166
if (!Current->MissingHeaders.empty()) {
155167
MissingHeader = Current->MissingHeaders.front();
156168
return false;
@@ -287,12 +299,12 @@ void Module::addRequirement(StringRef Feature, bool RequiredState,
287299
if (hasFeature(Feature, LangOpts, Target) == RequiredState)
288300
return;
289301

290-
markUnavailable(/*MissingRequirement*/true);
302+
markUnavailable(/*Unimportable*/true);
291303
}
292304

293-
void Module::markUnavailable(bool MissingRequirement) {
294-
auto needUpdate = [MissingRequirement](Module *M) {
295-
return M->IsAvailable || (!M->IsMissingRequirement && MissingRequirement);
305+
void Module::markUnavailable(bool Unimportable) {
306+
auto needUpdate = [Unimportable](Module *M) {
307+
return M->IsAvailable || (!M->IsUnimportable && Unimportable);
296308
};
297309

298310
if (!needUpdate(this))
@@ -308,7 +320,7 @@ void Module::markUnavailable(bool MissingRequirement) {
308320
continue;
309321

310322
Current->IsAvailable = false;
311-
Current->IsMissingRequirement |= MissingRequirement;
323+
Current->IsUnimportable |= Unimportable;
312324
for (submodule_iterator Sub = Current->submodule_begin(),
313325
SubEnd = Current->submodule_end();
314326
Sub != SubEnd; ++Sub) {
@@ -642,8 +654,8 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
642654
SmallVector<Module *, 16> Exports;
643655
V.M->getExportedModules(Exports);
644656
for (Module *E : Exports) {
645-
// Don't recurse to unavailable submodules.
646-
if (E->isAvailable())
657+
// Don't import non-importable modules.
658+
if (!E->isUnimportable())
647659
VisitModule({E, &V});
648660
}
649661

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ static const SanitizerMask Unrecoverable =
5656
SanitizerKind::Unreachable | SanitizerKind::Return;
5757
static const SanitizerMask AlwaysRecoverable =
5858
SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress;
59-
static const SanitizerMask LegacyFsanitizeRecoverMask =
60-
SanitizerKind::Undefined | SanitizerKind::Integer;
6159
static const SanitizerMask NeedsLTO = SanitizerKind::CFI;
6260
static const SanitizerMask TrappingSupported =
6361
(SanitizerKind::Undefined & ~SanitizerKind::Vptr) |
@@ -221,16 +219,6 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
221219
} else if (Arg->getOption().matches(options::OPT_fno_sanitize_trap_EQ)) {
222220
Arg->claim();
223221
TrapRemove |= expandSanitizerGroups(parseArgValues(D, Arg, true));
224-
} else if (Arg->getOption().matches(
225-
options::OPT_fsanitize_undefined_trap_on_error)) {
226-
Arg->claim();
227-
TrappingKinds |=
228-
expandSanitizerGroups(SanitizerKind::UndefinedGroup & ~TrapRemove) &
229-
~TrapRemove;
230-
} else if (Arg->getOption().matches(
231-
options::OPT_fno_sanitize_undefined_trap_on_error)) {
232-
Arg->claim();
233-
TrapRemove |= expandSanitizerGroups(SanitizerKind::UndefinedGroup);
234222
}
235223
}
236224

@@ -541,18 +529,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
541529
SanitizerMask DiagnosedUnrecoverableKinds;
542530
SanitizerMask DiagnosedAlwaysRecoverableKinds;
543531
for (const auto *Arg : Args) {
544-
const char *DeprecatedReplacement = nullptr;
545-
if (Arg->getOption().matches(options::OPT_fsanitize_recover)) {
546-
DeprecatedReplacement =
547-
"-fsanitize-recover=undefined,integer' or '-fsanitize-recover=all";
548-
RecoverableKinds |= expandSanitizerGroups(LegacyFsanitizeRecoverMask);
549-
Arg->claim();
550-
} else if (Arg->getOption().matches(options::OPT_fno_sanitize_recover)) {
551-
DeprecatedReplacement = "-fno-sanitize-recover=undefined,integer' or "
552-
"'-fno-sanitize-recover=all";
553-
RecoverableKinds &= ~expandSanitizerGroups(LegacyFsanitizeRecoverMask);
554-
Arg->claim();
555-
} else if (Arg->getOption().matches(options::OPT_fsanitize_recover_EQ)) {
532+
if (Arg->getOption().matches(options::OPT_fsanitize_recover_EQ)) {
556533
SanitizerMask Add = parseArgValues(D, Arg, true);
557534
// Report error if user explicitly tries to recover from unrecoverable
558535
// sanitizer.
@@ -581,10 +558,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
581558
RecoverableKinds &= ~expandSanitizerGroups(Remove);
582559
Arg->claim();
583560
}
584-
if (DeprecatedReplacement) {
585-
D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
586-
<< DeprecatedReplacement;
587-
}
588561
}
589562
RecoverableKinds &= Kinds;
590563
RecoverableKinds &= ~Unrecoverable;

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) {
15761576
Stack.push_back(M);
15771577
while (!Stack.empty()) {
15781578
Module *Current = Stack.pop_back_val();
1579-
if (Current->IsMissingRequirement) continue;
1579+
if (Current->IsUnimportable) continue;
15801580
Current->IsAvailable = true;
15811581
Stack.insert(Stack.end(),
15821582
Current->submodule_begin(), Current->submodule_end());

clang/lib/Lex/ModuleMap.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void ModuleMap::resolveHeader(Module *Mod,
282282
// resolved. (Such a module still can't be built though, except from
283283
// preprocessed source.)
284284
if (!Header.Size && !Header.ModTime)
285-
Mod->markUnavailable();
285+
Mod->markUnavailable(/*Unimportable=*/false);
286286
}
287287
}
288288

@@ -544,6 +544,9 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
544544
static bool isBetterKnownHeader(const ModuleMap::KnownHeader &New,
545545
const ModuleMap::KnownHeader &Old) {
546546
// Prefer available modules.
547+
// FIXME: Considering whether the module is available rather than merely
548+
// importable is non-hermetic and can result in surprising behavior for
549+
// prebuilt modules. Consider only checking for importability here.
547550
if (New.getModule()->isAvailable() && !Old.getModule()->isAvailable())
548551
return true;
549552

@@ -1094,7 +1097,7 @@ Module *ModuleMap::createShadowedModule(StringRef Name, bool IsFramework,
10941097
new Module(Name, SourceLocation(), /*Parent=*/nullptr, IsFramework,
10951098
/*IsExplicit=*/false, NumCreatedModules++);
10961099
Result->ShadowingModule = ShadowingModule;
1097-
Result->IsAvailable = false;
1100+
Result->markUnavailable(/*Unimportable*/true);
10981101
ModuleScopeIDs[Result] = CurrentModuleScopeID;
10991102
ShadowModules.push_back(Result);
11001103

@@ -2096,9 +2099,9 @@ void ModuleMapParser::parseModuleDecl() {
20962099

20972100
// If the module meets all requirements but is still unavailable, mark the
20982101
// whole tree as unavailable to prevent it from building.
2099-
if (!ActiveModule->IsAvailable && !ActiveModule->IsMissingRequirement &&
2102+
if (!ActiveModule->IsAvailable && !ActiveModule->IsUnimportable &&
21002103
ActiveModule->Parent) {
2101-
ActiveModule->getTopLevelModule()->markUnavailable();
2104+
ActiveModule->getTopLevelModule()->markUnavailable(/*Unimportable=*/false);
21022105
ActiveModule->getTopLevelModule()->MissingHeaders.append(
21032106
ActiveModule->MissingHeaders.begin(), ActiveModule->MissingHeaders.end());
21042107
}

0 commit comments

Comments
 (0)