Skip to content

Commit ccf9c88

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into autogen_tests
2 parents 1695544 + 95c24cb commit ccf9c88

File tree

84 files changed

+4229
-1509
lines changed

Some content is hidden

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

84 files changed

+4229
-1509
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ C++ Specific Potentially Breaking Changes
9999
// Was error, now evaluates to false.
100100
constexpr bool b = f() == g();
101101
102+
- Clang will now correctly not consider pointers to non classes for covariance.
103+
104+
.. code-block:: c++
105+
106+
struct A {
107+
virtual const int *f() const;
108+
};
109+
struct B : A {
110+
// Return type has less cv-qualification but doesn't point to a class.
111+
// Error will be generated.
112+
int *f() const override;
113+
};
114+
102115
- The warning ``-Wdeprecated-literal-operator`` is now on by default, as this is
103116
something that WG21 has shown interest in removing from the language. The
104117
result is that anyone who is compiling with ``-Werror`` should see this

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,16 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
12941294
CmdArgs.push_back("-lFortranRuntime");
12951295
CmdArgs.push_back("-lFortranDecimal");
12961296
}
1297+
1298+
// libomp needs libatomic for atomic operations if using libgcc
1299+
if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
1300+
options::OPT_fno_openmp, false)) {
1301+
Driver::OpenMPRuntimeKind OMPRuntime =
1302+
TC.getDriver().getOpenMPRuntime(Args);
1303+
ToolChain::RuntimeLibType RuntimeLib = TC.GetRuntimeLibType(Args);
1304+
if (OMPRuntime == Driver::OMPRT_OMP && RuntimeLib == ToolChain::RLT_Libgcc)
1305+
CmdArgs.push_back("-latomic");
1306+
}
12971307
}
12981308

12991309
void tools::addFortranRuntimeLibraryPath(const ToolChain &TC,

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18273,7 +18273,7 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
1827318273
}
1827418274

1827518275
// The return types aren't either both pointers or references to a class type.
18276-
if (NewClassTy.isNull()) {
18276+
if (NewClassTy.isNull() || !NewClassTy->isStructureOrClassType()) {
1827718277
Diag(New->getLocation(),
1827818278
diag::err_different_return_type_for_overriding_virtual_function)
1827918279
<< New->getDeclName() << NewTy << OldTy

clang/test/SemaCXX/virtual-override.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ struct b { };
1919

2020
class A {
2121
virtual a* f(); // expected-note{{overridden virtual function is here}}
22+
virtual int *g(); // expected-note{{overridden virtual function is here}}
2223
};
2324

2425
class B : A {
2526
virtual b* f(); // expected-error{{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('b *' is not derived from 'a *')}}
27+
virtual char *g(); // expected-error{{virtual function 'g' has a different return type ('char *') than the function it overrides (which has return type 'int *')}}
2628
};
2729

2830
}
@@ -83,11 +85,15 @@ struct a { };
8385
class A {
8486
virtual const a* f();
8587
virtual a* g(); // expected-note{{overridden virtual function is here}}
88+
virtual const int* h(); // expected-note{{overridden virtual function is here}}
89+
virtual int* i(); // expected-note{{overridden virtual function is here}}
8690
};
8791

8892
class B : A {
8993
virtual a* f();
9094
virtual const a* g(); // expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides (class type 'const a *' is more qualified than class type 'a *'}}
95+
virtual int* h(); // expected-error{{virtual function 'h' has a different return type ('int *') than the function it overrides (which has return type 'const int *')}}
96+
virtual const int* i(); // expected-error{{virtual function 'i' has a different return type ('const int *') than the function it overrides (which has return type 'int *')}}
9197
};
9298

9399
}

clang/utils/TableGen/MveEmitter.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,15 +1033,15 @@ class EmitterBase {
10331033
// to expand Tablegen classes like 'Vector' which mean something different in
10341034
// each member of a parametric family.
10351035
const Type *getType(const Record *R, const Type *Param);
1036-
const Type *getType(DagInit *D, const Type *Param);
1037-
const Type *getType(Init *I, const Type *Param);
1036+
const Type *getType(const DagInit *D, const Type *Param);
1037+
const Type *getType(const Init *I, const Type *Param);
10381038

10391039
// Functions that translate the Tablegen representation of an intrinsic's
10401040
// code generation into a collection of Value objects (which will then be
10411041
// reprocessed to read out the actual C++ code included by CGBuiltin.cpp).
1042-
Result::Ptr getCodeForDag(DagInit *D, const Result::Scope &Scope,
1042+
Result::Ptr getCodeForDag(const DagInit *D, const Result::Scope &Scope,
10431043
const Type *Param);
1044-
Result::Ptr getCodeForDagArg(DagInit *D, unsigned ArgNum,
1044+
Result::Ptr getCodeForDagArg(const DagInit *D, unsigned ArgNum,
10451045
const Result::Scope &Scope, const Type *Param);
10461046
Result::Ptr getCodeForArg(unsigned ArgNum, const Type *ArgType, bool Promote,
10471047
bool Immediate);
@@ -1060,10 +1060,10 @@ class EmitterBase {
10601060
void EmitBuiltinAliases(raw_ostream &OS);
10611061
};
10621062

1063-
const Type *EmitterBase::getType(Init *I, const Type *Param) {
1064-
if (auto Dag = dyn_cast<DagInit>(I))
1063+
const Type *EmitterBase::getType(const Init *I, const Type *Param) {
1064+
if (const auto *Dag = dyn_cast<DagInit>(I))
10651065
return getType(Dag, Param);
1066-
if (auto Def = dyn_cast<DefInit>(I))
1066+
if (const auto *Def = dyn_cast<DefInit>(I))
10671067
return getType(Def->getDef(), Param);
10681068

10691069
PrintFatalError("Could not convert this value into a type");
@@ -1088,7 +1088,7 @@ const Type *EmitterBase::getType(const Record *R, const Type *Param) {
10881088
PrintFatalError(R->getLoc(), "Could not convert this record into a type");
10891089
}
10901090

1091-
const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
1091+
const Type *EmitterBase::getType(const DagInit *D, const Type *Param) {
10921092
// The meat of the getType system: types in the Tablegen are represented by a
10931093
// dag whose operators select sub-cases of this function.
10941094

@@ -1156,7 +1156,8 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
11561156
PrintFatalError("Bad operator in type dag expression");
11571157
}
11581158

1159-
Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
1159+
Result::Ptr EmitterBase::getCodeForDag(const DagInit *D,
1160+
const Result::Scope &Scope,
11601161
const Type *Param) {
11611162
const Record *Op = cast<DefInit>(D->getOperator())->getDef();
11621163

@@ -1199,14 +1200,14 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
11991200
Result::Ptr Arg = getCodeForDagArg(D, 0, Scope, Param);
12001201

12011202
const Type *Ty = nullptr;
1202-
if (auto *DI = dyn_cast<DagInit>(D->getArg(0)))
1203+
if (const auto *DI = dyn_cast<DagInit>(D->getArg(0)))
12031204
if (auto *PTy = dyn_cast<PointerType>(getType(DI->getOperator(), Param)))
12041205
Ty = PTy->getPointeeType();
12051206
if (!Ty)
12061207
PrintFatalError("'address' pointer argument should be a pointer");
12071208

12081209
unsigned Alignment;
1209-
if (auto *II = dyn_cast<IntInit>(D->getArg(1))) {
1210+
if (const auto *II = dyn_cast<IntInit>(D->getArg(1))) {
12101211
Alignment = II->getValue();
12111212
} else {
12121213
PrintFatalError("'address' alignment argument should be an integer");
@@ -1267,10 +1268,10 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
12671268
}
12681269
}
12691270

1270-
Result::Ptr EmitterBase::getCodeForDagArg(DagInit *D, unsigned ArgNum,
1271+
Result::Ptr EmitterBase::getCodeForDagArg(const DagInit *D, unsigned ArgNum,
12711272
const Result::Scope &Scope,
12721273
const Type *Param) {
1273-
Init *Arg = D->getArg(ArgNum);
1274+
const Init *Arg = D->getArg(ArgNum);
12741275
StringRef Name = D->getArgNameStr(ArgNum);
12751276

12761277
if (!Name.empty()) {
@@ -1286,18 +1287,18 @@ Result::Ptr EmitterBase::getCodeForDagArg(DagInit *D, unsigned ArgNum,
12861287
// Sometimes the Arg is a bit. Prior to multiclass template argument
12871288
// checking, integers would sneak through the bit declaration,
12881289
// but now they really are bits.
1289-
if (auto *BI = dyn_cast<BitInit>(Arg))
1290+
if (const auto *BI = dyn_cast<BitInit>(Arg))
12901291
return std::make_shared<IntLiteralResult>(getScalarType("u32"),
12911292
BI->getValue());
12921293

1293-
if (auto *II = dyn_cast<IntInit>(Arg))
1294+
if (const auto *II = dyn_cast<IntInit>(Arg))
12941295
return std::make_shared<IntLiteralResult>(getScalarType("u32"),
12951296
II->getValue());
12961297

1297-
if (auto *DI = dyn_cast<DagInit>(Arg))
1298+
if (const auto *DI = dyn_cast<DagInit>(Arg))
12981299
return getCodeForDag(DI, Scope, Param);
12991300

1300-
if (auto *DI = dyn_cast<DefInit>(Arg)) {
1301+
if (const auto *DI = dyn_cast<DefInit>(Arg)) {
13011302
const Record *Rec = DI->getDef();
13021303
if (Rec->isSubClassOf("Type")) {
13031304
const Type *T = getType(Rec, Param);
@@ -1307,7 +1308,7 @@ Result::Ptr EmitterBase::getCodeForDagArg(DagInit *D, unsigned ArgNum,
13071308

13081309
PrintError("bad DAG argument type for code generation");
13091310
PrintNote("DAG: " + D->getAsString());
1310-
if (TypedInit *Typed = dyn_cast<TypedInit>(Arg))
1311+
if (const auto *Typed = dyn_cast<TypedInit>(Arg))
13111312
PrintNote("argument type: " + Typed->getType()->getAsString());
13121313
PrintFatalNote("argument number " + Twine(ArgNum) + ": " + Arg->getAsString());
13131314
}
@@ -1379,13 +1380,13 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, const Record *R,
13791380
HeaderOnly = R->getValueAsBit("headerOnly");
13801381

13811382
// Process the intrinsic's argument list.
1382-
DagInit *ArgsDag = R->getValueAsDag("args");
1383+
const DagInit *ArgsDag = R->getValueAsDag("args");
13831384
Result::Scope Scope;
13841385
for (unsigned i = 0, e = ArgsDag->getNumArgs(); i < e; ++i) {
1385-
Init *TypeInit = ArgsDag->getArg(i);
1386+
const Init *TypeInit = ArgsDag->getArg(i);
13861387

13871388
bool Promote = true;
1388-
if (auto TypeDI = dyn_cast<DefInit>(TypeInit))
1389+
if (const auto *TypeDI = dyn_cast<DefInit>(TypeInit))
13891390
if (TypeDI->getDef()->isSubClassOf("unpromoted"))
13901391
Promote = false;
13911392

@@ -1397,7 +1398,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, const Record *R,
13971398
// If the argument is a subclass of Immediate, record the details about
13981399
// what values it can take, for Sema checking.
13991400
bool Immediate = false;
1400-
if (auto TypeDI = dyn_cast<DefInit>(TypeInit)) {
1401+
if (const auto *TypeDI = dyn_cast<DefInit>(TypeInit)) {
14011402
const Record *TypeRec = TypeDI->getDef();
14021403
if (TypeRec->isSubClassOf("Immediate")) {
14031404
Immediate = true;
@@ -1444,7 +1445,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, const Record *R,
14441445

14451446
// Finally, go through the codegen dag and translate it into a Result object
14461447
// (with an arbitrary DAG of depended-on Results hanging off it).
1447-
DagInit *CodeDag = R->getValueAsDag("codegen");
1448+
const DagInit *CodeDag = R->getValueAsDag("codegen");
14481449
const Record *MainOp = cast<DefInit>(CodeDag->getOperator())->getDef();
14491450
if (MainOp->isSubClassOf("CustomCodegen")) {
14501451
// Or, if it's the special case of CustomCodegen, just accumulate
@@ -1456,9 +1457,9 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, const Record *R,
14561457
StringRef Name = CodeDag->getArgNameStr(i);
14571458
if (Name.empty()) {
14581459
PrintFatalError("Operands to CustomCodegen should have names");
1459-
} else if (auto *II = dyn_cast<IntInit>(CodeDag->getArg(i))) {
1460+
} else if (const auto *II = dyn_cast<IntInit>(CodeDag->getArg(i))) {
14601461
CustomCodeGenArgs[std::string(Name)] = itostr(II->getValue());
1461-
} else if (auto *SI = dyn_cast<StringInit>(CodeDag->getArg(i))) {
1462+
} else if (const auto *SI = dyn_cast<StringInit>(CodeDag->getArg(i))) {
14621463
CustomCodeGenArgs[std::string(Name)] = std::string(SI->getValue());
14631464
} else {
14641465
PrintFatalError("Operands to CustomCodegen should be integers");

flang/lib/Evaluate/intrinsics-library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ template <> struct HostRuntimeLibrary<double, LibraryVersion::LibmExtensions> {
417417
static_assert(map.Verify(), "map must be sorted");
418418
};
419419

420-
#if HAS_FLOAT80 || HAS_LDBL128
420+
#if defined(__GLIBC__) && (HAS_FLOAT80 || HAS_LDBL128)
421421
template <>
422422
struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
423423
using F = FuncPointer<long double, long double>;

flang/runtime/Float128Math/math-entries.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ DEFINE_SIMPLE_ALIAS(Hypot, std::hypot)
187187
DEFINE_SIMPLE_ALIAS(Ilogb, std::ilogb)
188188
DEFINE_SIMPLE_ALIAS(Isinf, std::isinf)
189189
DEFINE_SIMPLE_ALIAS(Isnan, std::isnan)
190-
DEFINE_SIMPLE_ALIAS(J0, j0l)
191-
DEFINE_SIMPLE_ALIAS(J1, j1l)
192-
DEFINE_SIMPLE_ALIAS(Jn, jnl)
193190
DEFINE_SIMPLE_ALIAS(Ldexp, std::ldexp)
194191
DEFINE_SIMPLE_ALIAS(Lgamma, std::lgamma)
195192
DEFINE_SIMPLE_ALIAS(Llround, std::llround)
@@ -207,9 +204,15 @@ DEFINE_SIMPLE_ALIAS(Tan, std::tan)
207204
DEFINE_SIMPLE_ALIAS(Tanh, std::tanh)
208205
DEFINE_SIMPLE_ALIAS(Tgamma, std::tgamma)
209206
DEFINE_SIMPLE_ALIAS(Trunc, std::trunc)
207+
208+
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
209+
DEFINE_SIMPLE_ALIAS(J0, j0l)
210+
DEFINE_SIMPLE_ALIAS(J1, j1l)
211+
DEFINE_SIMPLE_ALIAS(Jn, jnl)
210212
DEFINE_SIMPLE_ALIAS(Y0, y0l)
211213
DEFINE_SIMPLE_ALIAS(Y1, y1l)
212214
DEFINE_SIMPLE_ALIAS(Yn, ynl)
215+
#endif
213216

214217
// Use numeric_limits to produce infinity of the right type.
215218
#define F128_RT_INFINITY \

flang/test/Driver/atomic.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
!RUN: %flang --target=aarch64-unknown-linux-gnu -fuse-ld=ld -fopenmp -rtlib=libgcc -### %s 2>&1 | FileCheck --check-prefixes=GCC %s
2+
!RUN: %flang --target=aarch64-unknown-linux-gnu -fuse-ld=ld -fopenmp -rtlib=compiler-rt -### %s 2>&1 | FileCheck --check-prefixes=CRT %s
3+
4+
!GCC: -latomic
5+
!CRT-NOT: -latomic

0 commit comments

Comments
 (0)