Skip to content

Commit 30f770b

Browse files
author
iclsrc
committed
Merge from 'master' to 'sycl-web' (#204)
2 parents ef666b1 + ecd2aae commit 30f770b

File tree

708 files changed

+30101
-8086
lines changed

Some content is hidden

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

708 files changed

+30101
-8086
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ CheckOptions:
1414
value: CamelCase
1515
- key: readability-identifier-naming.VariableCase
1616
value: CamelCase
17+
- key: readability-identifier-naming.IgnoreMainLikeFunctions
18+
value: 1
1719

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static void addUsage(RenamerClangTidyCheck::NamingCheckFailureMap &Failures,
133133
const RenamerClangTidyCheck::NamingCheckId &Decl,
134134
SourceRange Range, SourceManager *SourceMgr = nullptr) {
135135
// Do nothing if the provided range is invalid.
136-
if (Range.getBegin().isInvalid() || Range.getEnd().isInvalid())
136+
if (Range.isInvalid())
137137
return;
138138

139139
// If we have a source manager, use it to convert to the spelling location for
@@ -290,11 +290,9 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
290290
Value->getReturnType().getTypePtr()->getAs<TypedefType>())
291291
addUsage(NamingCheckFailures, Typedef->getDecl(),
292292
Value->getSourceRange());
293-
for (unsigned i = 0; i < Value->getNumParams(); ++i) {
294-
if (const TypedefType *Typedef = Value->parameters()[i]
295-
->getType()
296-
.getTypePtr()
297-
->getAs<TypedefType>())
293+
for (const ParmVarDecl *Param : Value->parameters()) {
294+
if (const TypedefType *Typedef =
295+
Param->getType().getTypePtr()->getAs<TypedefType>())
298296
addUsage(NamingCheckFailures, Typedef->getDecl(),
299297
Value->getSourceRange());
300298
}

clang-tools-extra/clangd/Hover.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ void enhanceFromIndex(HoverInfo &Hover, const NamedDecl &ND,
250250
});
251251
}
252252

253+
// Default argument might exist but be unavailable, in the case of unparsed
254+
// arguments for example. This function returns the default argument if it is
255+
// available.
256+
const Expr *getDefaultArg(const ParmVarDecl *PVD) {
257+
// Default argument can be unparsed or uninstatiated. For the former we
258+
// can't do much, as token information is only stored in Sema and not
259+
// attached to the AST node. For the latter though, it is safe to proceed as
260+
// the expression is still valid.
261+
if (!PVD->hasDefaultArg() || PVD->hasUnparsedDefaultArg())
262+
return nullptr;
263+
return PVD->hasUninstantiatedDefaultArg() ? PVD->getUninstantiatedDefaultArg()
264+
: PVD->getDefaultArg();
265+
}
266+
253267
// Populates Type, ReturnType, and Parameters for function-like decls.
254268
void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D,
255269
const FunctionDecl *FD,
@@ -269,10 +283,10 @@ void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D,
269283
}
270284
if (!PVD->getName().empty())
271285
P.Name = PVD->getNameAsString();
272-
if (PVD->hasDefaultArg()) {
286+
if (const Expr *DefArg = getDefaultArg(PVD)) {
273287
P.Default.emplace();
274288
llvm::raw_string_ostream Out(*P.Default);
275-
PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
289+
DefArg->printPretty(Out, nullptr, Policy);
276290
}
277291
}
278292

clang-tools-extra/clangd/unittests/HoverTests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,22 @@ TEST(Hover, All) {
16091609
HI.Type = "unsigned long";
16101610
HI.Value = "1";
16111611
}},
1612+
{
1613+
R"cpp(
1614+
template <typename T = int>
1615+
void foo(const T& = T()) {
1616+
[[f^oo]]<>(3);
1617+
})cpp",
1618+
[](HoverInfo &HI) {
1619+
HI.Name = "foo";
1620+
HI.Kind = index::SymbolKind::Function;
1621+
HI.Type = "void (const int &)";
1622+
HI.ReturnType = "void";
1623+
HI.Parameters = {
1624+
{std::string("const int &"), llvm::None, std::string("T()")}};
1625+
HI.Definition = "template <> void foo<int>(const int &)";
1626+
HI.NamespaceScope = "";
1627+
}},
16121628
};
16131629

16141630
// Create a tiny index, so tests above can verify documentation is fetched.

clang/.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ CheckOptions:
1919
value: CamelCase
2020
- key: readability-identifier-naming.VariableCase
2121
value: CamelCase
22+
- key: readability-identifier-naming.IgnoreMainLikeFunctions
23+
value: 1
2224

clang/docs/ClangCommandLineReference.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,12 @@ Strip (or keep only, if negative) a given number of path components when emittin
904904

905905
Turn on runtime checks for various forms of undefined or suspicious behavior. See user manual for available checks
906906

907+
.. option:: -fno-semantic-interposition, -fsemantic-interposition
908+
909+
Enable semantic interposition. Semantic interposition allows for the
910+
interposition of a symbol by another at runtime, thus preventing a range of
911+
inter-procedural optimisation.
912+
907913
.. option:: -moutline, -mno-outline
908914

909915
Enable function outlining (AArch64 only)

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,29 @@ the configuration (without a prefix: ``Auto``).
20172017
[self onOperationDone];
20182018
}];
20192019
2020+
**ObjCBreakBeforeNestedBlockParam** (``bool``)
2021+
Break parameters list into lines when there is nested block
2022+
parameters in a fuction call.
2023+
2024+
.. code-block:: c++
2025+
2026+
false:
2027+
- (void)_aMethod
2028+
{
2029+
[self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
2030+
u = c;
2031+
}]
2032+
}
2033+
true:
2034+
- (void)_aMethod
2035+
{
2036+
[self.test1 t:self
2037+
w:self
2038+
callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
2039+
u = c;
2040+
}]
2041+
}
2042+
20202043
**ObjCSpaceAfterProperty** (``bool``)
20212044
Add a space after ``@property`` in Objective-C, i.e. use
20222045
``@property (readonly)`` instead of ``@property(readonly)``.

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ clang-format
158158
It helps avoid having the closing bracket align with the switch statement's
159159
closing bracket (when ``IndentCaseLabels`` is ``false``).
160160

161+
- Option ``ObjCBreakBeforeNestedBlockParam`` has been added to optionally apply
162+
linebreaks for function arguments declarations before nested blocks.
163+
161164
.. code-block:: c++
162-
165+
163166
switch (fool) { vs. switch (fool) {
164167
case 1: case 1: {
165168
{ bar();

clang/include/clang/AST/DeclCXX.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,10 @@ class CXXRecordDecl : public RecordDecl {
16961696
/// actually abstract.
16971697
bool mayBeAbstract() const;
16981698

1699+
/// Determine whether it's impossible for a class to be derived from this
1700+
/// class. This is best-effort, and may conservatively return false.
1701+
bool isEffectivelyFinal() const;
1702+
16991703
/// If this is the closure type of a lambda expression, retrieve the
17001704
/// number to be used for name mangling in the Itanium C++ ABI.
17011705
///

clang/include/clang/AST/ExprConcepts.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ class ConceptSpecializationExpr final : public Expr, public ConceptReference,
6363
ArrayRef<TemplateArgument> ConvertedArgs,
6464
const ConstraintSatisfaction *Satisfaction);
6565

66+
ConceptSpecializationExpr(const ASTContext &C, ConceptDecl *NamedConcept,
67+
ArrayRef<TemplateArgument> ConvertedArgs,
68+
const ConstraintSatisfaction *Satisfaction,
69+
bool Dependent,
70+
bool ContainsUnexpandedParameterPack);
71+
6672
ConceptSpecializationExpr(EmptyShell Empty, unsigned NumTemplateArgs);
6773

6874
public:
@@ -75,6 +81,13 @@ class ConceptSpecializationExpr final : public Expr, public ConceptReference,
7581
ArrayRef<TemplateArgument> ConvertedArgs,
7682
const ConstraintSatisfaction *Satisfaction);
7783

84+
static ConceptSpecializationExpr *
85+
Create(const ASTContext &C, ConceptDecl *NamedConcept,
86+
ArrayRef<TemplateArgument> ConvertedArgs,
87+
const ConstraintSatisfaction *Satisfaction,
88+
bool Dependent,
89+
bool ContainsUnexpandedParameterPack);
90+
7891
static ConceptSpecializationExpr *
7992
Create(ASTContext &C, EmptyShell Empty, unsigned NumTemplateArgs);
8093

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ def GNULabelsAsValue : DiagGroup<"gnu-label-as-value">;
384384
def LiteralRange : DiagGroup<"literal-range">;
385385
def LocalTypeTemplateArgs : DiagGroup<"local-type-template-args",
386386
[CXX98CompatLocalTypeTemplateArgs]>;
387-
def RangeLoopAnalysis : DiagGroup<"range-loop-analysis">;
387+
def RangeLoopConstruct : DiagGroup<"range-loop-construct">;
388+
def RangeLoopBindReference : DiagGroup<"range-loop-bind-reference">;
389+
def RangeLoopAnalysis : DiagGroup<"range-loop-analysis",
390+
[RangeLoopConstruct, RangeLoopBindReference]>;
388391
def ForLoopAnalysis : DiagGroup<"for-loop-analysis">;
389392
def LoopAnalysis : DiagGroup<"loop-analysis", [ForLoopAnalysis,
390393
RangeLoopAnalysis]>;
@@ -860,14 +863,15 @@ def Most : DiagGroup<"most", [
860863
Comment,
861864
DeleteNonVirtualDtor,
862865
Format,
866+
ForLoopAnalysis,
863867
Implicit,
864868
InfiniteRecursion,
865869
IntInBoolContext,
866-
LoopAnalysis,
867870
MismatchedTags,
868871
MissingBraces,
869872
Move,
870873
MultiChar,
874+
RangeLoopConstruct,
871875
Reorder,
872876
ReturnType,
873877
SelfAssignment,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,17 +2415,17 @@ def warn_for_range_const_reference_copy : Warning<
24152415
"loop variable %0 "
24162416
"%diff{has type $ but is initialized with type $"
24172417
"| is initialized with a value of a different type}1,2 resulting in a copy">,
2418-
InGroup<RangeLoopAnalysis>, DefaultIgnore;
2418+
InGroup<RangeLoopConstruct>, DefaultIgnore;
24192419
def note_use_type_or_non_reference : Note<
24202420
"use non-reference type %0 to keep the copy or type %1 to prevent copying">;
24212421
def warn_for_range_variable_always_copy : Warning<
24222422
"loop variable %0 is always a copy because the range of type %1 does not "
24232423
"return a reference">,
2424-
InGroup<RangeLoopAnalysis>, DefaultIgnore;
2424+
InGroup<RangeLoopBindReference>, DefaultIgnore;
24252425
def note_use_non_reference_type : Note<"use non-reference type %0">;
24262426
def warn_for_range_copy : Warning<
24272427
"loop variable %0 of type %1 creates a copy from type %2">,
2428-
InGroup<RangeLoopAnalysis>, DefaultIgnore;
2428+
InGroup<RangeLoopConstruct>, DefaultIgnore;
24292429
def note_use_reference_type : Note<"use reference type %0 to prevent copying">;
24302430
def err_objc_for_range_init_stmt : Error<
24312431
"initialization statement is not supported when iterating over Objective-C "
@@ -8438,6 +8438,12 @@ def note_defaulted_comparison_cannot_deduce : Note<
84388438
"return type of defaulted 'operator<=>' cannot be deduced because "
84398439
"return type %2 of three-way comparison for %select{|member|base class}0 %1 "
84408440
"is not a standard comparison category type">;
8441+
def err_defaulted_comparison_cannot_deduce_undeduced_auto : Error<
8442+
"return type of defaulted 'operator<=>' cannot be deduced because "
8443+
"three-way comparison for %select{|member|base class}0 %1 "
8444+
"has a deduced return type and is not yet defined">;
8445+
def note_defaulted_comparison_cannot_deduce_undeduced_auto : Note<
8446+
"%select{|member|base class}0 %1 declared here">;
84418447
def note_defaulted_comparison_cannot_deduce_callee : Note<
84428448
"selected 'operator<=>' for %select{|member|base class}0 %1 declared here">;
84438449
def err_incorrect_defaulted_comparison_constexpr : Error<

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
289289
"default visibility for types [-ftype-visibility]")
290290
LANGOPT(SetVisibilityForExternDecls, 1, 0,
291291
"apply global symbol visibility to external declarations without an explicit visibility")
292+
BENIGN_LANGOPT(SemanticInterposition , 1, 0, "semantic interposition")
292293
ENUM_LANGOPT(StackProtector, StackProtectorMode, 2, SSPOff,
293294
"stack protector mode")
294295
ENUM_LANGOPT(TrivialAutoVarInit, TrivialAutoVarInitKind, 2, TrivialAutoVarInitKind::Uninitialized,

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3342,7 +3342,8 @@ defm inline_small_functions : BooleanFFlag<"inline-small-functions">,
33423342
defm ipa_cp : BooleanFFlag<"ipa-cp">,
33433343
Group<clang_ignored_gcc_optimization_f_Group>;
33443344
defm ivopts : BooleanFFlag<"ivopts">, Group<clang_ignored_gcc_optimization_f_Group>;
3345-
def : Flag<["-"], "fno-semantic-interposition">, Group<clang_ignored_f_Group>;
3345+
def fsemantic_interposition : Flag<["-"], "fsemantic-interposition">, Group<f_Group>, Flags<[CC1Option]>;
3346+
def fno_semantic_interposition: Flag<["-"], "fno-semantic-interposition">, Group<f_Group>;
33463347
defm non_call_exceptions : BooleanFFlag<"non-call-exceptions">, Group<clang_ignored_f_Group>;
33473348
defm peel_loops : BooleanFFlag<"peel-loops">, Group<clang_ignored_gcc_optimization_f_Group>;
33483349
defm permissive : BooleanFFlag<"permissive">, Group<clang_ignored_f_Group>;

clang/include/clang/Format/Format.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,29 @@ struct FormatStyle {
16881688
/// ``@property (readonly)`` instead of ``@property(readonly)``.
16891689
bool ObjCSpaceAfterProperty;
16901690

1691+
/// Break parameters list into lines when there is nested block
1692+
/// parameters in a fuction call.
1693+
/// \code
1694+
/// false:
1695+
/// - (void)_aMethod
1696+
/// {
1697+
/// [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
1698+
/// *u, NSNumber *v) {
1699+
/// u = c;
1700+
/// }]
1701+
/// }
1702+
/// true:
1703+
/// - (void)_aMethod
1704+
/// {
1705+
/// [self.test1 t:self
1706+
/// w:self
1707+
/// callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
1708+
/// u = c;
1709+
/// }]
1710+
/// }
1711+
/// \endcode
1712+
bool ObjCBreakBeforeNestedBlockParam;
1713+
16911714
/// Add a space in front of an Objective-C protocol list, i.e. use
16921715
/// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
16931716
bool ObjCSpaceBeforeProtocolList;
@@ -2178,6 +2201,8 @@ struct FormatStyle {
21782201
NamespaceMacros == R.NamespaceMacros &&
21792202
ObjCBinPackProtocolList == R.ObjCBinPackProtocolList &&
21802203
ObjCBlockIndentWidth == R.ObjCBlockIndentWidth &&
2204+
ObjCBreakBeforeNestedBlockParam ==
2205+
R.ObjCBreakBeforeNestedBlockParam &&
21812206
ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
21822207
ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
21832208
PenaltyBreakAssignment == R.PenaltyBreakAssignment &&

clang/include/clang/Sema/Sema.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class Sema final {
499499
/// The maximum alignment, same as in llvm::Value. We duplicate them here
500500
/// because that allows us not to duplicate the constants in clang code,
501501
/// which we must to since we can't directly use the llvm constants.
502-
/// The value is verified against llvm here: lib/CodeGen/CGValue.h
502+
/// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
503503
///
504504
/// This is the greatest alignment value supported by load, store, and alloca
505505
/// instructions, and global values.
@@ -3069,10 +3069,19 @@ class Sema final {
30693069
bool ConsiderCudaAttrs = true,
30703070
bool ConsiderRequiresClauses = true);
30713071

3072+
enum class AllowedExplicit {
3073+
/// Allow no explicit functions to be used.
3074+
None,
3075+
/// Allow explicit conversion functions but not explicit constructors.
3076+
Conversions,
3077+
/// Allow both explicit conversion functions and explicit constructors.
3078+
All
3079+
};
3080+
30723081
ImplicitConversionSequence
30733082
TryImplicitConversion(Expr *From, QualType ToType,
30743083
bool SuppressUserConversions,
3075-
bool AllowExplicit,
3084+
AllowedExplicit AllowExplicit,
30763085
bool InOverloadResolution,
30773086
bool CStyle,
30783087
bool AllowObjCWritebackConversion);
@@ -7152,7 +7161,7 @@ class Sema final {
71527161
/// Get a template argument mapping the given template parameter to itself,
71537162
/// e.g. for X in \c template<int X>, this would return an expression template
71547163
/// argument referencing X.
7155-
TemplateArgumentLoc getIdentityTemplateArgumentLoc(Decl *Param,
7164+
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param,
71567165
SourceLocation Location);
71577166

71587167
void translateTemplateArguments(const ASTTemplateArgsPtr &In,

clang/include/clang/Sema/SemaConcept.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ struct AtomicConstraint {
4343
if (ParameterMapping->size() != Other.ParameterMapping->size())
4444
return false;
4545

46-
for (unsigned I = 0, S = ParameterMapping->size(); I < S; ++I)
47-
if (!C.getCanonicalTemplateArgument((*ParameterMapping)[I].getArgument())
48-
.structurallyEquals(C.getCanonicalTemplateArgument(
49-
(*Other.ParameterMapping)[I].getArgument())))
46+
for (unsigned I = 0, S = ParameterMapping->size(); I < S; ++I) {
47+
llvm::FoldingSetNodeID IDA, IDB;
48+
C.getCanonicalTemplateArgument((*ParameterMapping)[I].getArgument())
49+
.Profile(IDA, C);
50+
C.getCanonicalTemplateArgument((*Other.ParameterMapping)[I].getArgument())
51+
.Profile(IDB, C);
52+
if (IDA != IDB)
5053
return false;
54+
}
5155
return true;
5256
}
5357

clang/lib/AST/ASTContext.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,12 +731,8 @@ canonicalizeImmediatelyDeclaredConstraint(const ASTContext &C, Expr *IDC,
731731
NewConverted.push_back(Arg);
732732
}
733733
Expr *NewIDC = ConceptSpecializationExpr::Create(
734-
C, NestedNameSpecifierLoc(), /*TemplateKWLoc=*/SourceLocation(),
735-
CSE->getConceptNameInfo(), /*FoundDecl=*/CSE->getNamedConcept(),
736-
CSE->getNamedConcept(),
737-
// Actually canonicalizing a TemplateArgumentLoc is difficult so we
738-
// simply omit the ArgsAsWritten
739-
/*ArgsAsWritten=*/nullptr, NewConverted, nullptr);
734+
C, CSE->getNamedConcept(), NewConverted, nullptr,
735+
CSE->isInstantiationDependent(), CSE->containsUnexpandedParameterPack());
740736

741737
if (auto *OrigFold = dyn_cast<CXXFoldExpr>(IDC))
742738
NewIDC = new (C) CXXFoldExpr(OrigFold->getType(), SourceLocation(), NewIDC,

0 commit comments

Comments
 (0)