Skip to content

Commit a858b24

Browse files
Jenkinsronlieb
authored andcommitted
merge main into amd-staging
Change-Id: I70be33525e9782398f92dbcacd49f4be5ec30976
2 parents bc39367 + 266bb49 commit a858b24

File tree

167 files changed

+7029
-1395
lines changed

Some content is hidden

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

167 files changed

+7029
-1395
lines changed

clang/docs/LibASTMatchersReference.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,6 +3449,19 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
34493449
</pre></td></tr>
34503450

34513451

3452+
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentScopeDeclRefExpr.html">DependentScopeDeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasDependentName0')"><a name="hasDependentName0Anchor">hasDependentName</a></td><td>std::string N</td></tr>
3453+
<tr><td colspan="4" class="doc" id="hasDependentName0"><pre>Matches the dependent name of a DependentScopeDeclRefExpr.
3454+
3455+
Matches the dependent name of a DependentScopeDeclRefExpr
3456+
3457+
Given:
3458+
3459+
template &lt;class T&lt; class X : T { void f() { T::v; } };
3460+
3461+
dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
3462+
</pre></td></tr>
3463+
3464+
34523465
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;</td><td class="name" onclick="toggle('memberHasSameNameAsBoundNode0')"><a name="memberHasSameNameAsBoundNode0Anchor">memberHasSameNameAsBoundNode</a></td><td>std::string BindingID</td></tr>
34533466
<tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
34543467
node

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,8 @@ AST Matchers
11501150

11511151
- Add ``dependentTemplateSpecializationType`` matcher to match a dependent template specialization type.
11521152

1153+
- Add ``hasDependentName`` matcher to match the dependent name of a DependentScopeDeclRefExpr.
1154+
11531155
clang-format
11541156
------------
11551157

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,6 +3257,17 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode,
32573257
});
32583258
}
32593259

3260+
/// Matches the dependent name of a DependentScopeDeclRefExpr
3261+
///
3262+
/// Given:
3263+
/// \code
3264+
/// template <class T> class X : T { void f() { T::v; } };
3265+
/// \endcode
3266+
/// \c dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
3267+
AST_MATCHER_P(DependentScopeDeclRefExpr, hasDependentName, std::string, N) {
3268+
return Node.getDeclName().getAsString() == N;
3269+
}
3270+
32603271
/// Matches C++ classes that are directly or indirectly derived from a class
32613272
/// matching \c Base, or Objective-C classes that directly or indirectly
32623273
/// subclass a class matching \c Base.

clang/include/clang/Basic/Builtins.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,6 +3568,19 @@ def Frexp : FPMathTemplate, LibBuiltin<"math.h"> {
35683568
let AddBuiltinPrefixedAlias = 1;
35693569
}
35703570

3571+
def Sincos : FPMathTemplate, GNULibBuiltin<"math.h"> {
3572+
let Spellings = ["sincos"];
3573+
let Attributes = [NoThrow];
3574+
let Prototype = "void(T, T*, T*)";
3575+
let AddBuiltinPrefixedAlias = 1;
3576+
}
3577+
3578+
def SincosF16F128 : F16F128MathTemplate, Builtin {
3579+
let Spellings = ["__builtin_sincos"];
3580+
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
3581+
let Prototype = "void(T, T*, T*)";
3582+
}
3583+
35713584
def Ldexp : FPMathTemplate, LibBuiltin<"math.h"> {
35723585
let Spellings = ["ldexp"];
35733586
let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];

clang/lib/ASTMatchers/Dynamic/Registry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ RegistryMaps::RegistryMaps() {
314314
REGISTER_MATCHER(hasDeducedType);
315315
REGISTER_MATCHER(hasDefaultArgument);
316316
REGISTER_MATCHER(hasDefinition);
317+
REGISTER_MATCHER(hasDependentName);
317318
REGISTER_MATCHER(hasDescendant);
318319
REGISTER_MATCHER(hasDestinationType);
319320
REGISTER_MATCHER(hasDirectBase);

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,38 @@ static Value *emitFrexpBuiltin(CodeGenFunction &CGF, const CallExpr *E,
835835
return CGF.Builder.CreateExtractValue(Call, 0);
836836
}
837837

838+
static void emitSincosBuiltin(CodeGenFunction &CGF, const CallExpr *E,
839+
llvm::Intrinsic::ID IntrinsicID) {
840+
llvm::Value *Val = CGF.EmitScalarExpr(E->getArg(0));
841+
llvm::Value *Dest0 = CGF.EmitScalarExpr(E->getArg(1));
842+
llvm::Value *Dest1 = CGF.EmitScalarExpr(E->getArg(2));
843+
844+
llvm::Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {Val->getType()});
845+
llvm::Value *Call = CGF.Builder.CreateCall(F, Val);
846+
847+
llvm::Value *SinResult = CGF.Builder.CreateExtractValue(Call, 0);
848+
llvm::Value *CosResult = CGF.Builder.CreateExtractValue(Call, 1);
849+
850+
QualType DestPtrType = E->getArg(1)->getType()->getPointeeType();
851+
LValue SinLV = CGF.MakeNaturalAlignAddrLValue(Dest0, DestPtrType);
852+
LValue CosLV = CGF.MakeNaturalAlignAddrLValue(Dest1, DestPtrType);
853+
854+
llvm::StoreInst *StoreSin =
855+
CGF.Builder.CreateStore(SinResult, SinLV.getAddress());
856+
llvm::StoreInst *StoreCos =
857+
CGF.Builder.CreateStore(CosResult, CosLV.getAddress());
858+
859+
// Mark the two stores as non-aliasing with each other. The order of stores
860+
// emitted by this builtin is arbitrary, enforcing a particular order will
861+
// prevent optimizations later on.
862+
llvm::MDBuilder MDHelper(CGF.getLLVMContext());
863+
MDNode *Domain = MDHelper.createAnonymousAliasScopeDomain();
864+
MDNode *AliasScope = MDHelper.createAnonymousAliasScope(Domain);
865+
MDNode *AliasScopeList = MDNode::get(Call->getContext(), AliasScope);
866+
StoreSin->setMetadata(LLVMContext::MD_alias_scope, AliasScopeList);
867+
StoreCos->setMetadata(LLVMContext::MD_noalias, AliasScopeList);
868+
}
869+
838870
/// EmitFAbs - Emit a call to @llvm.fabs().
839871
static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) {
840872
Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -3232,6 +3264,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
32323264
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
32333265
*this, E, Intrinsic::sinh, Intrinsic::experimental_constrained_sinh));
32343266

3267+
case Builtin::BI__builtin_sincos:
3268+
case Builtin::BI__builtin_sincosf:
3269+
case Builtin::BI__builtin_sincosf16:
3270+
case Builtin::BI__builtin_sincosl:
3271+
case Builtin::BI__builtin_sincosf128:
3272+
emitSincosBuiltin(*this, E, Intrinsic::sincos);
3273+
return RValue::get(nullptr);
3274+
32353275
case Builtin::BIsqrt:
32363276
case Builtin::BIsqrtf:
32373277
case Builtin::BIsqrtl:

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,10 @@ class AnnotatingParser {
15821582
return false;
15831583
break;
15841584
case tok::l_brace:
1585-
if (Style.Language == FormatStyle::LK_TextProto) {
1585+
if (IsCpp) {
1586+
if (Tok->is(TT_RequiresExpressionLBrace))
1587+
Line.Type = LT_RequiresExpression;
1588+
} else if (Style.Language == FormatStyle::LK_TextProto) {
15861589
FormatToken *Previous = Tok->getPreviousNonComment();
15871590
if (Previous && Previous->isNot(TT_DictLiteral))
15881591
Previous->setType(TT_SelectorName);
@@ -2024,8 +2027,11 @@ class AnnotatingParser {
20242027
if (!consumeToken())
20252028
return LT_Invalid;
20262029
}
2027-
if (Line.Type == LT_AccessModifier)
2028-
return LT_AccessModifier;
2030+
if (const auto Type = Line.Type; Type == LT_AccessModifier ||
2031+
Type == LT_RequiresExpression ||
2032+
Type == LT_SimpleRequirement) {
2033+
return Type;
2034+
}
20292035
if (KeywordVirtualFound)
20302036
return LT_VirtualFunctionDecl;
20312037
if (ImportStatement)
@@ -3102,8 +3108,10 @@ class AnnotatingParser {
31023108
}
31033109
}
31043110

3105-
if (!Scopes.empty() && Scopes.back() == ST_CompoundRequirement)
3111+
if (Line.Type == LT_SimpleRequirement ||
3112+
(!Scopes.empty() && Scopes.back() == ST_CompoundRequirement)) {
31063113
return TT_BinaryOperator;
3114+
}
31073115

31083116
return TT_PointerOrReference;
31093117
}
@@ -3693,8 +3701,15 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
36933701

36943702
if (!Line.Children.empty()) {
36953703
ScopeStack.push_back(ST_ChildBlock);
3696-
for (auto &Child : Line.Children)
3704+
const bool InRequiresExpression = Line.Type == LT_RequiresExpression;
3705+
for (auto &Child : Line.Children) {
3706+
if (InRequiresExpression &&
3707+
!Child->First->isOneOf(tok::kw_typename, tok::kw_requires,
3708+
TT_CompoundRequirementLBrace)) {
3709+
Child->Type = LT_SimpleRequirement;
3710+
}
36973711
annotate(*Child);
3712+
}
36983713
// ScopeStack can become empty if Child has an unmatched `}`.
36993714
if (!ScopeStack.empty())
37003715
ScopeStack.pop_back();

clang/lib/Format/TokenAnnotator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ enum LineType {
3333
LT_VirtualFunctionDecl,
3434
LT_ArrayOfStructInitializer,
3535
LT_CommentAbovePPDirective,
36+
LT_RequiresExpression,
37+
LT_SimpleRequirement,
3638
};
3739

3840
enum ScopeType {

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7230,6 +7230,10 @@ void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
72307230
if (!D->isFromASTFile())
72317231
return; // Declaration not imported from PCH.
72327232

7233+
// The function definition may not have a body due to parsing errors.
7234+
if (!D->doesThisDeclarationHaveABody())
7235+
return;
7236+
72337237
// Implicit function decl from a PCH was defined.
72347238
DeclUpdates[D].push_back(DeclUpdate(UPD_CXX_ADDED_FUNCTION_DEFINITION));
72357239
}
@@ -7249,6 +7253,10 @@ void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
72497253
if (!D->isFromASTFile())
72507254
return;
72517255

7256+
// The function definition may not have a body due to parsing errors.
7257+
if (!D->doesThisDeclarationHaveABody())
7258+
return;
7259+
72527260
DeclUpdates[D].push_back(DeclUpdate(UPD_CXX_ADDED_FUNCTION_DEFINITION));
72537261
}
72547262

clang/test/CXX/drs/cwg0xx.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98,cxx98-14 -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy
1+
// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98,cxx98-14 -fexceptions -fcxx-exceptions -pedantic-errors
22
// RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11,cxx98-14,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
33
// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11,cxx98-14,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
44
// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
@@ -709,11 +709,11 @@ namespace cwg39 { // cwg39: no
709709
// expected-error@#cwg39-sizeof {{unknown type name}}
710710
#if __cplusplus >= 201103L
711711
decltype(D::n) n;
712-
/* expected-error@-1
712+
/* since-cxx11-error@-1
713713
{{non-static member 'n' found in multiple base-class subobjects of type 'A':
714714
struct cwg39::PR5916::D -> B -> A
715715
struct cwg39::PR5916::D -> C -> A}} */
716-
// expected-note@#cwg39-A-n {{member found by ambiguous name lookup}}
716+
// since-cxx11-note@#cwg39-A-n {{member found by ambiguous name lookup}}
717717
#endif
718718
}
719719
} // namespace cwg39
@@ -1150,8 +1150,8 @@ namespace cwg73 { // cwg73: sup 1652
11501150
#if __cplusplus >= 201103L
11511151
int a, b;
11521152
static_assert(&a + 1 != &b, "");
1153-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
1154-
// expected-note@-2 {{comparison against pointer '&a + 1' that points past the end of a complete object has unspecified value}}
1153+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
1154+
// since-cxx11-note@-2 {{comparison against pointer '&a + 1' that points past the end of a complete object has unspecified value}}
11551155
#endif
11561156
} // namespace cwg73
11571157

@@ -1255,14 +1255,14 @@ namespace cwg85 { // cwg85: 3.4
12551255
enum E1 : int;
12561256
enum E1 : int { e1 }; // #cwg85-E1-def
12571257
enum E1 : int;
1258-
// expected-error@-1 {{class member cannot be redeclared}}
1259-
// expected-note@#cwg85-E1-def {{previous declaration is here}}
1258+
// since-cxx11-error@-1 {{class member cannot be redeclared}}
1259+
// since-cxx11-note@#cwg85-E1-def {{previous declaration is here}}
12601260

12611261
enum class E2;
12621262
enum class E2 { e2 }; // #cwg85-E2-def
12631263
enum class E2;
1264-
// expected-error@-1 {{class member cannot be redeclared}}
1265-
// expected-note@#cwg85-E2-def {{previous declaration is here}}
1264+
// since-cxx11-error@-1 {{class member cannot be redeclared}}
1265+
// since-cxx11-note@#cwg85-E2-def {{previous declaration is here}}
12661266
#endif
12671267
};
12681268

0 commit comments

Comments
 (0)