Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIR][CIRGen] Remove -clangir-disable-emit-cxx-default #1198

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/include/clang/CIR/CIRGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class CIRGenerator : public clang::ASTConsumer {
bool verifyModule();

void emitDeferredDecls();
void emitDefaultMethods();
};

} // namespace cir
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3062,10 +3062,6 @@ def clangir_disable_verifier : Flag<["-"], "clangir-disable-verifier">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"ClangIR: Disable MLIR module verifier">,
MarshallingInfoFlag<FrontendOpts<"ClangIRDisableCIRVerifier">>;
def clangir_disable_emit_cxx_default : Flag<["-"], "clangir-disable-emit-cxx-default">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"ClangIR: Disable emission of c++ default (compiler implemented) methods.">,
MarshallingInfoFlag<FrontendOpts<"ClangIRDisableEmitCXXDefault">>;
def clangir_verify_diagnostics : Flag<["-"], "clangir-verify-diagnostics">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"ClangIR: Enable diagnostic verification in MLIR, similar to clang's -verify">,
Expand Down
10 changes: 3 additions & 7 deletions clang/include/clang/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,6 @@ class FrontendOptions {
/// Disable Clang IR (CIR) verifier
unsigned ClangIRDisableCIRVerifier : 1;

/// Disable ClangIR emission for CXX default (compiler generated methods).
unsigned ClangIRDisableEmitCXXDefault : 1;

/// Enable diagnostic verification for CIR
unsigned ClangIRVerifyDiags : 1;

Expand Down Expand Up @@ -655,10 +652,9 @@ class FrontendOptions {
EmitPrettySymbolGraphs(false), GenReducedBMI(false),
UseClangIRPipeline(false), ClangIRDirectLowering(false),
ClangIRDisablePasses(false), ClangIRDisableCIRVerifier(false),
ClangIRDisableEmitCXXDefault(false), ClangIRLifetimeCheck(false),
ClangIRIdiomRecognizer(false), ClangIRLibOpt(false),
ClangIRAnalysisOnly(false), TimeTraceGranularity(500),
TimeTraceVerbose(false) {}
ClangIRLifetimeCheck(false), ClangIRIdiomRecognizer(false),
ClangIRLibOpt(false), ClangIRAnalysisOnly(false),
TimeTraceGranularity(500), TimeTraceVerbose(false) {}

/// getInputKindForExtension - Return the appropriate input kind for a file
/// extension. For example, "c" would return Language::C.
Expand Down
12 changes: 1 addition & 11 deletions clang/lib/CIR/CodeGen/CIRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2786,10 +2786,7 @@ cir::FuncOp CIRGenModule::GetOrCreateCIRFunction(
FD = FD->getPreviousDecl()) {
if (isa<CXXRecordDecl>(FD->getLexicalDeclContext())) {
if (FD->doesThisDeclarationHaveABody()) {
if (isDefaultedMethod(FD))
addDefaultMethodsToEmit(GD.getWithDecl(FD));
else
addDeferredDeclToEmit(GD.getWithDecl(FD));
addDeferredDeclToEmit(GD.getWithDecl(FD));
break;
}
}
Expand Down Expand Up @@ -2939,13 +2936,6 @@ void CIRGenModule::emitDeferred(unsigned recursionLimit) {
}
}

void CIRGenModule::emitDefaultMethods() {
// Differently from DeferredDeclsToEmit, there's no recurrent use of
// DefaultMethodsToEmit, so use it directly for emission.
for (auto &D : DefaultMethodsToEmit)
emitGlobalDecl(D);
}

mlir::IntegerAttr CIRGenModule::getSize(CharUnits size) {
return builder.getSizeFromCharUnits(&getMLIRContext(), size);
}
Expand Down
11 changes: 0 additions & 11 deletions clang/lib/CIR/CodeGen/CIRGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,14 +566,6 @@ class CIRGenModule : public CIRGenTypeCache {
DeferredDeclsToEmit.emplace_back(GD);
}

// After HandleTranslation finishes, differently from DeferredDeclsToEmit,
// DefaultMethodsToEmit is only called after a set of CIR passes run. See
// addDefaultMethodsToEmit usage for examples.
std::vector<clang::GlobalDecl> DefaultMethodsToEmit;
void addDefaultMethodsToEmit(clang::GlobalDecl GD) {
DefaultMethodsToEmit.emplace_back(GD);
}

std::pair<cir::FuncType, cir::FuncOp> getAddrAndTypeOfCXXStructor(
clang::GlobalDecl GD, const CIRGenFunctionInfo *FnInfo = nullptr,
cir::FuncType FnType = nullptr, bool Dontdefer = false,
Expand Down Expand Up @@ -718,9 +710,6 @@ class CIRGenModule : public CIRGenTypeCache {
/// Helper for `emitDeferred` to apply actual codegen.
void emitGlobalDecl(clang::GlobalDecl &D);

/// Build default methods not emitted before this point.
void emitDefaultMethods();

const llvm::Triple &getTriple() const { return target.getTriple(); }

// Finalize CIR code generation.
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ void CIRGenerator::HandleInlineFunctionDefinition(FunctionDecl *D) {
CGM->AddDeferredUnusedCoverageMapping(D);
}

void CIRGenerator::emitDefaultMethods() { CGM->emitDefaultMethods(); }

void CIRGenerator::emitDeferredDecls() {
if (DeferredInlineMemberFuncDefs.empty())
return;
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/CIR/FrontendAction/CIRGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
case CIRGenAction::OutputType::EmitCIR:
case CIRGenAction::OutputType::EmitCIRFlat:
if (outputStream && mlirMod) {
// Emit remaining defaulted C++ methods
if (!feOptions.ClangIRDisableEmitCXXDefault)
gen->emitDefaultMethods();

// FIXME: we cannot roundtrip prettyForm=true right now.
mlir::OpPrintingFlags flags;
flags.enableDebugInfo(/*enable=*/true, /*prettyForm=*/false);
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3055,9 +3055,6 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_clangir_disable_verifier))
Opts.ClangIRDisableCIRVerifier = true;

if (Args.hasArg(OPT_clangir_disable_emit_cxx_default))
Opts.ClangIRDisableEmitCXXDefault = true;

if (Args.hasArg(OPT_clangir_verify_diagnostics))
Opts.ClangIRVerifyDiags = true;

Expand Down
11 changes: 0 additions & 11 deletions clang/test/CIR/CodeGen/assign-operator.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %clang_cc1 -std=c++17 -mconstructor-aliases -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

// RUN: %clang_cc1 -std=c++17 -mconstructor-aliases -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -clangir-disable-emit-cxx-default %s -o %t-disable.cir
// RUN: FileCheck --input-file=%t-disable.cir %s --check-prefix=DISABLE

int strlen(char const *);

struct String {
Expand Down Expand Up @@ -40,9 +37,6 @@ struct String {
// CHECK: cir.return
// CHECK: }

// DISABLE: cir.func linkonce_odr @_ZN10StringViewC2ERK6String
// DISABLE-NEXT: %0 = cir.alloca !cir.ptr<!ty_StringView>, !cir.ptr<!cir.ptr<!ty_StringView>>, ["this", init] {alignment = 8 : i64}

// StringView::operator=(StringView&&)
//
// CHECK: cir.func linkonce_odr @_ZN10StringViewaSEOS_
Expand All @@ -61,9 +55,6 @@ struct String {
// CHECK: %8 = cir.load %2 : !cir.ptr<!cir.ptr<!ty_StringView>>
// CHECK: cir.return %8 : !cir.ptr<!ty_StringView>
// CHECK: }

// DISABLE: cir.func private @_ZN10StringViewaSEOS_
// DISABLE-NEXT: cir.func @main()
};

struct StringView {
Expand Down Expand Up @@ -179,8 +170,6 @@ struct Trivial {
// CHECK-NEXT: %[[#OTHER_I_CAST:]] = cir.cast(bitcast, %[[#OTHER_I]] : !cir.ptr<!s32i>), !cir.ptr<!void>
// CHECK-NEXT: cir.libc.memcpy %[[#MEMCPY_SIZE]] bytes from %[[#OTHER_I_CAST]] to %[[#THIS_I_CAST]]
// CHECK-NEXT: cir.store %[[#THIS_LOAD]], %[[#RETVAL]]
// CHECK-NEXT: cir.br ^bb1
// CHECK-NEXT: ^bb1:
// CHECK-NEXT: %[[#RETVAL_LOAD:]] = cir.load %[[#RETVAL]]
// CHECK-NEXT: cir.return %[[#RETVAL_LOAD]]
// CHECK-NEXT: }
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/coro-task.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

namespace std {
Expand Down
24 changes: 24 additions & 0 deletions clang/test/CIR/CodeGen/default-methods.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir --check-prefix=CIR %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll --check-prefix=LLVM %s

// We should emit and call both implicit operator= functions.
struct S {
struct T {
int x;
} t;
};

// CIR-LABEL: cir.func linkonce_odr @_ZN1S1TaSERKS0_({{.*}} {
// CIR-LABEL: cir.func linkonce_odr @_ZN1SaSERKS_(
// CIR: cir.call @_ZN1S1TaSERKS0_(
// CIR-LABEL: cir.func @_Z1fR1SS0_(
// CIR: cir.call @_ZN1SaSERKS_(

// LLVM-LABEL: define linkonce_odr ptr @_ZN1S1TaSERKS0_(
// LLVM-LABEL: define linkonce_odr ptr @_ZN1SaSERKS_(
// LLVM: call ptr @_ZN1S1TaSERKS0_(
// LLVM-LABEL: define dso_local void @_Z1fR1SS0_(
// LLVM: call ptr @_ZN1SaSERKS_(
void f(S &s1, S &s2) { s1 = s2; }
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/delete.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

typedef __typeof(sizeof(int)) size_t;
Expand All @@ -12,4 +12,4 @@ namespace test1 {

// CHECK: %[[CONST:.*]] = cir.const #cir.int<4> : !u64i
// CHECK: cir.call @_ZN5test11AdlEPvm({{.*}}, %[[CONST]])
}
}
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/derived-to-base.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

typedef enum {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/dtors-scopes.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s
// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -std=c++20 -fclangir -emit-cir %s -o %t2.cir
// RUN: FileCheck --input-file=%t2.cir %s --check-prefix=DTOR_BODY
Expand Down Expand Up @@ -33,4 +33,4 @@ void dtor1() {

// DTOR_BODY: cir.call @_ZN1CD2Ev
// DTOR_BODY: cir.return
// DTOR_BODY: }
// DTOR_BODY: }
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/dtors.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

enum class EFMode { Always, Verbose };
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/libcall.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

typedef __builtin_va_list va_list;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/move.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

namespace std {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/new.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand Down Expand Up @@ -55,4 +55,4 @@ class B {
void t() {
B b;
b.construct(&b);
}
}
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/nrvo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/rangefor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/std-array.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand All @@ -14,4 +14,4 @@ void t() {
// CHECK: {{.*}} = cir.cast(array_to_ptrdecay
// CHECK: {{.*}} = cir.const #cir.int<9> : !u32i

// CHECK: cir.call @_ZNSt5arrayIhLj9EE3endEv
// CHECK: cir.call @_ZNSt5arrayIhLj9EE3endEv
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/std-find.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand All @@ -24,4 +24,4 @@ int test_find(unsigned char n = 3)
// CHECK: cir.if %[[neq_cmp]]

return num_found;
}
}
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/vector.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand Down Expand Up @@ -32,4 +32,4 @@ void m() {
std::vector<unsigned long long> a;
int i = 43;
a.resize(i);
}
}
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/vtable-rtti.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -mconstructor-aliases -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -fno-rtti -mconstructor-aliases -clangir-disable-emit-cxx-default -emit-cir %s -o %t2.cir
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -fno-rtti -mconstructor-aliases -emit-cir %s -o %t2.cir
// RUN: FileCheck --input-file=%t2.cir --check-prefix=RTTI_DISABLED %s

class A
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Transforms/lib-opt-find.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -clangir-disable-emit-cxx-default -fclangir -fclangir-idiom-recognizer -fclangir-lib-opt -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -fclangir-idiom-recognizer -fclangir-lib-opt -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

#include "std-cxx.h"
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Transforms/lifetime-check-agg.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -mconstructor-aliases -fclangir -clangir-disable-emit-cxx-default -fclangir-lifetime-check="history=all;remarks=all" -clangir-verify-diagnostics -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -mconstructor-aliases -fclangir -fclangir-lifetime-check="history=all;remarks=all" -clangir-verify-diagnostics -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -mconstructor-aliases -fclangir-analysis-only -fclangir-lifetime-check="history=all;remarks=all" %s -clangir-verify-diagnostics -emit-obj -o /dev/null

typedef enum SType {
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CIR/Transforms/lifetime-check-owner.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fclangir-lifetime-check="history=all;remarks=all;history_limit=1" -clangir-verify-diagnostics -emit-cir %s -o %t.cir

struct [[gsl::Owner(int)]] MyIntOwner {
struct [[gsl::Owner(int)]] MyIntOwner { // expected-remark {{pset => { fn_arg:0 }}}
int val;
MyIntOwner(int v) : val(v) {}
void changeInt(int i);
int &operator*();
int read() const;
};

struct [[gsl::Pointer(int)]] MyIntPointer {
struct [[gsl::Pointer(int)]] MyIntPointer { // expected-remark {{pset => { fn_arg:0 }}}
int *ptr;
MyIntPointer(int *p = nullptr) : ptr(p) {}
MyIntPointer(const MyIntOwner &);
Expand Down Expand Up @@ -68,4 +68,4 @@ void yolo4() {
p.read(); // expected-warning {{use of invalid pointer 'p'}}
// expected-remark@-1 {{pset => { invalid }}}
q.read(); // expected-remark {{pset => { o1__1' }}}
}
}
4 changes: 2 additions & 2 deletions clang/test/CIR/Transforms/lifetime-check-range-for-vector.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -mconstructor-aliases -fclangir -clangir-disable-emit-cxx-default -fclangir-lifetime-check="history=all" -fclangir-skip-system-headers -clangir-verify-diagnostics -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -mconstructor-aliases -fclangir -fclangir-lifetime-check="history=all" -fclangir-skip-system-headers -clangir-verify-diagnostics -emit-cir %s -o %t.cir

#include "std-cxx.h"

Expand All @@ -25,4 +25,4 @@ void swappy(unsigned c) {
for (unsigned i = 0; i < c; i++) {
images2[i] = {INFO_ENUM_1};
}
}
}
8 changes: 4 additions & 4 deletions clang/test/CIR/Transforms/lifetime-check-string.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -mconstructor-aliases -fclangir -clangir-disable-emit-cxx-default -fclangir-lifetime-check="history=all;remarks=all" -clangir-verify-diagnostics -emit-cir %s -o %t.cir
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -mconstructor-aliases -fclangir -fclangir-lifetime-check="history=all;remarks=all" -clangir-verify-diagnostics -emit-cir %s -o %t.cir

int strlen(char const *);

struct [[gsl::Owner(char *)]] String {
struct [[gsl::Owner(char *)]] String { // expected-remark {{pset => { fn_arg:0 }}}
long size;
long capacity;
const char *storage;
Expand All @@ -11,7 +11,7 @@ struct [[gsl::Owner(char *)]] String {
String(char const *s) : size{strlen(s)}, capacity{size}, storage{s} {}
};

struct [[gsl::Pointer(int)]] StringView {
struct [[gsl::Pointer(int)]] StringView { // expected-remark {{pset => { fn_arg:0 }}}
long size;
const char *storage;
char operator[](int);
Expand Down Expand Up @@ -84,4 +84,4 @@ void sv3() {
cout << name; // expected-note {{invalidated by non-const use of owner type}}
cout << sv; // expected-warning {{passing invalid pointer 'sv'}}
// expected-remark@-1 {{pset => { invalid }}}
}
}
Loading
Loading