Skip to content

Commit d4cd3aa

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-narrow-interleave
2 parents 885984d + 9c48a04 commit d4cd3aa

File tree

82 files changed

+757
-199
lines changed

Some content is hidden

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

82 files changed

+757
-199
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5293,7 +5293,7 @@ bool Compiler<Emitter>::compileDestructor(const CXXDestructorDecl *Dtor) {
52935293
if (!D->isPrimitive() && !D->isPrimitiveArray()) {
52945294
if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
52955295
return false;
5296-
if (!this->emitDestruction(D))
5296+
if (!this->emitDestruction(D, SourceInfo{}))
52975297
return false;
52985298
if (!this->emitPopPtr(SourceInfo{}))
52995299
return false;
@@ -5307,7 +5307,7 @@ bool Compiler<Emitter>::compileDestructor(const CXXDestructorDecl *Dtor) {
53075307

53085308
if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
53095309
return false;
5310-
if (!this->emitRecordDestruction(Base.R))
5310+
if (!this->emitRecordDestruction(Base.R, {}))
53115311
return false;
53125312
if (!this->emitPopPtr(SourceInfo{}))
53135313
return false;
@@ -6148,7 +6148,7 @@ bool Compiler<Emitter>::emitComplexComparison(const Expr *LHS, const Expr *RHS,
61486148
/// on the stack.
61496149
/// Emit destruction of record types (or arrays of record types).
61506150
template <class Emitter>
6151-
bool Compiler<Emitter>::emitRecordDestruction(const Record *R) {
6151+
bool Compiler<Emitter>::emitRecordDestruction(const Record *R, SourceInfo Loc) {
61526152
assert(R);
61536153
assert(!R->isAnonymousUnion());
61546154
const CXXDestructorDecl *Dtor = R->getDestructor();
@@ -6161,15 +6161,16 @@ bool Compiler<Emitter>::emitRecordDestruction(const Record *R) {
61616161
return false;
61626162
assert(DtorFunc->hasThisPointer());
61636163
assert(DtorFunc->getNumParams() == 1);
6164-
if (!this->emitDupPtr(SourceInfo{}))
6164+
if (!this->emitDupPtr(Loc))
61656165
return false;
6166-
return this->emitCall(DtorFunc, 0, SourceInfo{});
6166+
return this->emitCall(DtorFunc, 0, Loc);
61676167
}
61686168
/// When calling this, we have a pointer of the local-to-destroy
61696169
/// on the stack.
61706170
/// Emit destruction of record types (or arrays of record types).
61716171
template <class Emitter>
6172-
bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc) {
6172+
bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
6173+
SourceInfo Loc) {
61736174
assert(Desc);
61746175
assert(!Desc->isPrimitive());
61756176
assert(!Desc->isPrimitiveArray());
@@ -6193,13 +6194,13 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc) {
61936194
}
61946195

61956196
for (ssize_t I = Desc->getNumElems() - 1; I >= 0; --I) {
6196-
if (!this->emitConstUint64(I, SourceInfo{}))
6197+
if (!this->emitConstUint64(I, Loc))
61976198
return false;
6198-
if (!this->emitArrayElemPtrUint64(SourceInfo{}))
6199+
if (!this->emitArrayElemPtrUint64(Loc))
61996200
return false;
6200-
if (!this->emitDestruction(ElemDesc))
6201+
if (!this->emitDestruction(ElemDesc, Loc))
62016202
return false;
6202-
if (!this->emitPopPtr(SourceInfo{}))
6203+
if (!this->emitPopPtr(Loc))
62036204
return false;
62046205
}
62056206
return true;
@@ -6209,7 +6210,7 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc) {
62096210
if (Desc->ElemRecord->isAnonymousUnion())
62106211
return true;
62116212

6212-
return this->emitRecordDestruction(Desc->ElemRecord);
6213+
return this->emitRecordDestruction(Desc->ElemRecord, Loc);
62136214
}
62146215

62156216
namespace clang {

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
364364
bool emitComplexBoolCast(const Expr *E);
365365
bool emitComplexComparison(const Expr *LHS, const Expr *RHS,
366366
const BinaryOperator *E);
367-
bool emitRecordDestruction(const Record *R);
368-
bool emitDestruction(const Descriptor *Desc);
367+
bool emitRecordDestruction(const Record *R, SourceInfo Loc);
368+
bool emitDestruction(const Descriptor *Desc, SourceInfo Loc);
369369
unsigned collectBaseOffset(const QualType BaseType,
370370
const QualType DerivedType);
371371
bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
@@ -540,7 +540,7 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> {
540540
if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
541541
return false;
542542

543-
if (!this->Ctx->emitDestruction(Local.Desc))
543+
if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
544544
return false;
545545

546546
if (!this->Ctx->emitPopPtr(E))

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Pointer.h"
1616
#include "PrimType.h"
1717
#include "Record.h"
18+
#include "Source.h"
1819

1920
using namespace clang;
2021
using namespace clang::interp;
@@ -423,6 +424,14 @@ SourceLocation Descriptor::getLocation() const {
423424
llvm_unreachable("Invalid descriptor type");
424425
}
425426

427+
SourceInfo Descriptor::getLoc() const {
428+
if (const auto *D = Source.dyn_cast<const Decl *>())
429+
return SourceInfo(D);
430+
if (const auto *E = Source.dyn_cast<const Expr *>())
431+
return SourceInfo(E);
432+
llvm_unreachable("Invalid descriptor type");
433+
}
434+
426435
bool Descriptor::isUnion() const { return isRecord() && ElemRecord->isUnion(); }
427436

428437
InitMap::InitMap(unsigned N)

clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace clang {
2121
namespace interp {
2222
class Block;
2323
class Record;
24+
class SourceInfo;
2425
struct InitMap;
2526
struct Descriptor;
2627
enum PrimType : unsigned;
@@ -194,6 +195,7 @@ struct Descriptor final {
194195
QualType getType() const;
195196
QualType getElemQualType() const;
196197
SourceLocation getLocation() const;
198+
SourceInfo getLoc() const;
197199

198200
const Decl *asDecl() const { return Source.dyn_cast<const Decl *>(); }
199201
const Expr *asExpr() const { return Source.dyn_cast<const Expr *>(); }

clang/test/AST/ByteCode/cxx23.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,23 @@ namespace AnonUnionDtor {
269269

270270
void bar() { foo(); }
271271
}
272+
273+
/// FIXME: The two interpreters disagree about there to diagnose the non-constexpr destructor call.
274+
namespace NonLiteralDtorInParam {
275+
class NonLiteral { // all20-note {{is not an aggregate and has no constexpr constructors other than copy or move constructors}}
276+
public:
277+
NonLiteral() {}
278+
~NonLiteral() {} // all23-note {{declared here}}
279+
};
280+
constexpr int F2(NonLiteral N) { // all20-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}} \
281+
// ref23-note {{non-constexpr function '~NonLiteral' cannot be used in a constant expression}}
282+
return 8;
283+
}
284+
285+
286+
void test() {
287+
NonLiteral L;
288+
constexpr auto D = F2(L); // all23-error {{must be initialized by a constant expression}} \
289+
// expected23-note {{non-constexpr function '~NonLiteral' cannot be used in a constant expression}}
290+
}
291+
}
File renamed without changes.

flang/include/flang/Frontend/LangOptions.h renamed to flang/include/flang/Common/LangOptions.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
#ifndef FORTRAN_FRONTEND_LANGOPTIONS_H
16-
#define FORTRAN_FRONTEND_LANGOPTIONS_H
15+
#ifndef FORTRAN_COMMON_LANGOPTIONS_H
16+
#define FORTRAN_COMMON_LANGOPTIONS_H
1717

1818
#include <string>
1919
#include <vector>
2020

2121
#include "llvm/TargetParser/Triple.h"
2222

23-
namespace Fortran::frontend {
23+
namespace Fortran::common {
2424

2525
/// Bitfields of LangOptions, split out from LangOptions to ensure
2626
/// that this large collection of bitfields is a trivial class type.
@@ -37,12 +37,12 @@ class LangOptionsBase {
3737

3838
#define LANGOPT(Name, Bits, Default) unsigned Name : Bits;
3939
#define ENUM_LANGOPT(Name, Type, Bits, Default)
40-
#include "flang/Frontend/LangOptions.def"
40+
#include "flang/Common/LangOptions.def"
4141

4242
protected:
4343
#define LANGOPT(Name, Bits, Default)
4444
#define ENUM_LANGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
45-
#include "flang/Frontend/LangOptions.def"
45+
#include "flang/Common/LangOptions.def"
4646
};
4747

4848
/// Tracks various options which control the dialect of Fortran that is
@@ -52,10 +52,10 @@ class LangOptions : public LangOptionsBase {
5252
public:
5353
// Define accessors/mutators for code generation options of enumeration type.
5454
#define LANGOPT(Name, Bits, Default)
55-
#define ENUM_LANGOPT(Name, Type, Bits, Default) \
56-
Type get##Name() const { return static_cast<Type>(Name); } \
55+
#define ENUM_LANGOPT(Name, Type, Bits, Default) \
56+
Type get##Name() const { return static_cast<Type>(Name); } \
5757
void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
58-
#include "flang/Frontend/LangOptions.def"
58+
#include "flang/Common/LangOptions.def"
5959

6060
/// Name of the IR file that contains the result of the OpenMP target
6161
/// host code generation.
@@ -67,6 +67,6 @@ class LangOptions : public LangOptionsBase {
6767
LangOptions();
6868
};
6969

70-
} // end namespace Fortran::frontend
70+
} // end namespace Fortran::common
7171

72-
#endif // FORTRAN_FRONTEND_LANGOPTIONS_H
72+
#endif // FORTRAN_COMMON_LANGOPTIONS_H

flang/include/flang/Frontend/CompilerInvocation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#ifndef FORTRAN_FRONTEND_COMPILERINVOCATION_H
1414
#define FORTRAN_FRONTEND_COMPILERINVOCATION_H
1515

16+
#include "flang/Common/LangOptions.h"
1617
#include "flang/Frontend/CodeGenOptions.h"
1718
#include "flang/Frontend/FrontendOptions.h"
18-
#include "flang/Frontend/LangOptions.h"
1919
#include "flang/Frontend/PreprocessorOptions.h"
2020
#include "flang/Frontend/TargetOptions.h"
2121
#include "flang/Lower/LoweringOptions.h"
@@ -84,7 +84,7 @@ class CompilerInvocation : public CompilerInvocationBase {
8484
Fortran::frontend::CodeGenOptions codeGenOpts;
8585

8686
/// Options controlling language dialect.
87-
Fortran::frontend::LangOptions langOpts;
87+
Fortran::common::LangOptions langOpts;
8888

8989
// The original invocation of the compiler driver.
9090
// This string will be set as the return value from the COMPILER_OPTIONS
@@ -158,8 +158,8 @@ class CompilerInvocation : public CompilerInvocationBase {
158158
CodeGenOptions &getCodeGenOpts() { return codeGenOpts; }
159159
const CodeGenOptions &getCodeGenOpts() const { return codeGenOpts; }
160160

161-
LangOptions &getLangOpts() { return langOpts; }
162-
const LangOptions &getLangOpts() const { return langOpts; }
161+
Fortran::common::LangOptions &getLangOpts() { return langOpts; }
162+
const Fortran::common::LangOptions &getLangOpts() const { return langOpts; }
163163

164164
Fortran::lower::LoweringOptions &getLoweringOpts() { return loweringOpts; }
165165
const Fortran::lower::LoweringOptions &getLoweringOpts() const {

flang/include/flang/Semantics/semantics.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "scope.h"
1313
#include "symbol.h"
1414
#include "flang/Common/Fortran-features.h"
15+
#include "flang/Common/LangOptions.h"
1516
#include "flang/Evaluate/common.h"
1617
#include "flang/Evaluate/intrinsics.h"
1718
#include "flang/Evaluate/target.h"
@@ -65,15 +66,17 @@ using ConstructStack = std::vector<ConstructNode>;
6566
class SemanticsContext {
6667
public:
6768
SemanticsContext(const common::IntrinsicTypeDefaultKinds &,
68-
const common::LanguageFeatureControl &, parser::AllCookedSources &);
69+
const common::LanguageFeatureControl &, const common::LangOptions &,
70+
parser::AllCookedSources &);
6971
~SemanticsContext();
7072

7173
const common::IntrinsicTypeDefaultKinds &defaultKinds() const {
7274
return defaultKinds_;
7375
}
7476
const common::LanguageFeatureControl &languageFeatures() const {
7577
return languageFeatures_;
76-
};
78+
}
79+
const common::LangOptions &langOptions() const { return langOpts_; }
7780
int GetDefaultKind(TypeCategory) const;
7881
int doublePrecisionKind() const {
7982
return defaultKinds_.doublePrecisionKind();
@@ -273,6 +276,7 @@ class SemanticsContext {
273276

274277
const common::IntrinsicTypeDefaultKinds &defaultKinds_;
275278
const common::LanguageFeatureControl &languageFeatures_;
279+
const common::LangOptions &langOpts_;
276280
parser::AllCookedSources &allCookedSources_;
277281
std::optional<parser::CharBlock> location_;
278282
std::vector<std::string> searchDirectories_;

flang/include/flang/Tools/CrossToolHelpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
1414
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
1515

16+
#include "flang/Common/LangOptions.h"
1617
#include "flang/Common/MathOptionsBase.h"
1718
#include "flang/Frontend/CodeGenOptions.h"
18-
#include "flang/Frontend/LangOptions.h"
1919
#include <cstdint>
2020

2121
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
@@ -145,7 +145,7 @@ struct OffloadModuleOpts {
145145
OMPTargetTriples(OMPTargetTriples.begin(), OMPTargetTriples.end()),
146146
NoGPULib(NoGPULib) {}
147147

148-
OffloadModuleOpts(Fortran::frontend::LangOptions &Opts)
148+
OffloadModuleOpts(Fortran::common::LangOptions &Opts)
149149
: OpenMPTargetDebug(Opts.OpenMPTargetDebug),
150150
OpenMPTeamSubscription(Opts.OpenMPTeamSubscription),
151151
OpenMPThreadSubscription(Opts.OpenMPThreadSubscription),

0 commit comments

Comments
 (0)