Skip to content

Commit eca9873

Browse files
committed
fixup! no need for std::optional
(cherry picked from commit 7aeed0f)
1 parent 3ab2a45 commit eca9873

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
19911991
const bool is_artificial = false;
19921992

19931993
CXXMethodDecl *method_decl = m_clang_ast_context->AddMethodToCXXRecordType(
1994-
copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", std::nullopt,
1994+
copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", /*asm_label=*/{},
19951995
method_type, lldb::eAccessPublic, is_virtual, is_static, is_inline,
19961996
is_explicit, is_attr_used, is_artificial);
19971997

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram,
250250
return cv_quals;
251251
}
252252

253-
static std::optional<std::string> MakeLLDBFuncAsmLabel(const DWARFDIE &die) {
253+
static std::string MakeLLDBFuncAsmLabel(const DWARFDIE &die) {
254254
char const *name = die.GetMangledName(/*substitute_name_allowed*/ false);
255255
if (!name)
256-
return std::nullopt;
256+
return {};
257257

258258
SymbolFileDWARF *dwarf = die.GetDWARF();
259259
if (!dwarf)
260-
return std::nullopt;
260+
return {};
261261

262262
auto get_module_id = [&](SymbolFile *sym) {
263263
if (!sym)
@@ -279,11 +279,11 @@ static std::optional<std::string> MakeLLDBFuncAsmLabel(const DWARFDIE &die) {
279279
module_id = get_module_id(dwarf);
280280

281281
if (module_id == LLDB_INVALID_UID)
282-
return std::nullopt;
282+
return {};
283283

284284
const auto die_id = die.GetID();
285285
if (die_id == LLDB_INVALID_UID)
286-
return std::nullopt;
286+
return {};
287287

288288
return FunctionCallLabel{/*module_id=*/module_id,
289289
/*symbol_id=*/die_id,
@@ -1436,7 +1436,7 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
14361436
ignore_containing_context ? m_ast.GetTranslationUnitDecl()
14371437
: containing_decl_ctx,
14381438
GetOwningClangModule(die), attrs.name.GetStringRef(), clang_type,
1439-
attrs.storage, attrs.is_inline, /*asm_label=*/std::nullopt);
1439+
attrs.storage, attrs.is_inline, /*asm_label=*/{});
14401440
clang::FunctionTemplateDecl *func_template_decl =
14411441
m_ast.CreateFunctionTemplateDecl(
14421442
containing_decl_ctx, GetOwningClangModule(die),

lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct CreateMethodDecl : public TypeVisitorCallbacks {
8888
MethodOptions::CompilerGenerated;
8989
function_decl = m_clang.AddMethodToCXXRecordType(
9090
parent_ty, proc_name,
91-
/*mangled_name=*/std::nullopt, func_ct, /*access=*/access_type,
91+
/*asm_label=*/{}, func_ct, /*access=*/access_type,
9292
/*is_virtual=*/is_virtual, /*is_static=*/is_static,
9393
/*is_inline=*/false, /*is_explicit=*/false,
9494
/*is_attr_used=*/false, /*is_artificial=*/is_artificial);
@@ -903,7 +903,7 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId func_id,
903903
if (!function_decl) {
904904
function_decl = m_clang.AddMethodToCXXRecordType(
905905
parent_opaque_ty, func_name,
906-
/*mangled_name=*/std::nullopt, func_ct,
906+
/*asm_label=*/{}, func_ct,
907907
/*access=*/lldb::AccessType::eAccessPublic,
908908
/*is_virtual=*/false, /*is_static=*/false,
909909
/*is_inline=*/false, /*is_explicit=*/false,
@@ -913,7 +913,7 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId func_id,
913913
} else {
914914
function_decl = m_clang.CreateFunctionDeclaration(
915915
parent, OptionalClangModuleID(), func_name, func_ct, func_storage,
916-
is_inline, /*asm_label=*/std::nullopt);
916+
is_inline, /*asm_label=*/{});
917917
CreateFunctionParameters(func_id, *function_decl, param_count);
918918
}
919919
return function_decl;

lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void UdtRecordCompleter::AddMethod(llvm::StringRef name, TypeIndex type_idx,
111111
bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
112112
MethodOptions::CompilerGenerated;
113113
m_ast_builder.clang().AddMethodToCXXRecordType(
114-
derived_opaque_ty, name.data(), std::nullopt, method_ct, access_type,
114+
derived_opaque_ty, name.data(), /*asm_label=*/{}, method_ct, access_type,
115115
attrs.isVirtual(), attrs.isStatic(), false, false, false, is_artificial);
116116

117117
m_cxx_record_map[derived_opaque_ty].insert({name, method_ct});

lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
955955
auto decl = m_ast.CreateFunctionDeclaration(
956956
decl_context, OptionalClangModuleID(), name,
957957
type->GetForwardCompilerType(), storage, func->hasInlineAttribute(),
958-
/*asm_label=*/std::nullopt);
958+
/*asm_label=*/{});
959959

960960
std::vector<clang::ParmVarDecl *> params;
961961
if (std::unique_ptr<PDBSymbolTypeFunctionSig> sig = func->getSignature()) {
@@ -1447,8 +1447,8 @@ PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file,
14471447
// TODO: get mangled name for the method.
14481448
return m_ast.AddMethodToCXXRecordType(
14491449
record_type.GetOpaqueQualType(), name.c_str(),
1450-
/*mangled_name*/ std::nullopt, method_comp_type, access,
1451-
method.isVirtual(), method.isStatic(), method.hasInlineAttribute(),
1450+
/*asm_label=*/{}, method_comp_type, access, method.isVirtual(),
1451+
method.isStatic(), method.hasInlineAttribute(),
14521452
/*is_explicit*/ false, // FIXME: Need this field in CodeView.
14531453
/*is_attr_used*/ false,
14541454
/*is_artificial*/ method.isCompilerGenerated());

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,8 +2138,7 @@ std::string TypeSystemClang::GetTypeNameForDecl(const NamedDecl *named_decl,
21382138
FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
21392139
clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
21402140
llvm::StringRef name, const CompilerType &function_clang_type,
2141-
clang::StorageClass storage, bool is_inline,
2142-
std::optional<std::string> asm_label) {
2141+
clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label) {
21432142
FunctionDecl *func_decl = nullptr;
21442143
ASTContext &ast = getASTContext();
21452144
if (!decl_ctx)
@@ -2171,8 +2170,8 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
21712170
// example is generating calls to ABI-tagged template functions.
21722171
// This is done separately for member functions in
21732172
// AddMethodToCXXRecordType.
2174-
if (asm_label)
2175-
func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, *asm_label,
2173+
if (!asm_label.empty())
2174+
func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label,
21762175
/*literal=*/true));
21772176

21782177
SetOwningModule(func_decl, owning_module);
@@ -7668,7 +7667,7 @@ TypeSystemClang::CreateParameterDeclarations(
76687667

76697668
clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
76707669
lldb::opaque_compiler_type_t type, llvm::StringRef name,
7671-
std::optional<std::string> asm_label, const CompilerType &method_clang_type,
7670+
llvm::StringRef asm_label, const CompilerType &method_clang_type,
76727671
lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
76737672
bool is_explicit, bool is_attr_used, bool is_artificial) {
76747673
if (!type || !method_clang_type.IsValid() || name.empty())
@@ -7801,9 +7800,9 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
78017800
if (is_attr_used)
78027801
cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(getASTContext()));
78037802

7804-
if (asm_label)
7803+
if (!asm_label.empty())
78057804
cxx_method_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
7806-
getASTContext(), *asm_label, /*literal=*/true));
7805+
getASTContext(), asm_label, /*literal=*/true));
78077806

78087807
// Parameters on member function declarations in DWARF generally don't
78097808
// have names, so we omit them when creating the ParmVarDecls.

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ class TypeSystemClang : public TypeSystem {
477477
clang::FunctionDecl *CreateFunctionDeclaration(
478478
clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
479479
llvm::StringRef name, const CompilerType &function_Type,
480-
clang::StorageClass storage, bool is_inline,
481-
std::optional<std::string> asm_label);
480+
clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label);
482481

483482
CompilerType
484483
CreateFunctionType(const CompilerType &result_type,
@@ -1002,7 +1001,7 @@ class TypeSystemClang : public TypeSystem {
10021001

10031002
clang::CXXMethodDecl *AddMethodToCXXRecordType(
10041003
lldb::opaque_compiler_type_t type, llvm::StringRef name,
1005-
std::optional<std::string> mangled_name, const CompilerType &method_type,
1004+
llvm::StringRef asm_label, const CompilerType &method_type,
10061005
lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
10071006
bool is_explicit, bool is_attr_used, bool is_artificial);
10081007

lldb/unittests/Symbol/TestTypeSystemClang.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateConstruction) {
869869
CompilerType clang_type = m_ast->CreateFunctionType(int_type, {}, false, 0U);
870870
FunctionDecl *func = m_ast->CreateFunctionDeclaration(
871871
TU, OptionalClangModuleID(), "foo", clang_type, StorageClass::SC_None,
872-
false, std::nullopt);
872+
false, /*asm_label=*/{});
873873
TypeSystemClang::TemplateParameterInfos empty_params;
874874

875875
// Create the actual function template.
@@ -900,7 +900,7 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateInRecordConstruction) {
900900
// 2. It is mirroring the behavior of DWARFASTParserClang::ParseSubroutine.
901901
FunctionDecl *func = m_ast->CreateFunctionDeclaration(
902902
TU, OptionalClangModuleID(), "foo", clang_type, StorageClass::SC_None,
903-
false, std::nullopt);
903+
false, /*asm_label=*/{});
904904
TypeSystemClang::TemplateParameterInfos empty_params;
905905

906906
// Create the actual function template.
@@ -938,7 +938,7 @@ TEST_F(TestTypeSystemClang, TestDeletingImplicitCopyCstrDueToMoveCStr) {
938938
bool is_attr_used = false;
939939
bool is_artificial = false;
940940
m_ast->AddMethodToCXXRecordType(
941-
t.GetOpaqueQualType(), class_name, std::nullopt, function_type,
941+
t.GetOpaqueQualType(), class_name, /*asm_label=*/{}, function_type,
942942
lldb::AccessType::eAccessPublic, is_virtual, is_static, is_inline,
943943
is_explicit, is_attr_used, is_artificial);
944944

@@ -975,7 +975,7 @@ TEST_F(TestTypeSystemClang, TestNotDeletingUserCopyCstrDueToMoveCStr) {
975975
CompilerType function_type = m_ast->CreateFunctionType(
976976
return_type, args, /*variadic=*/false, /*quals*/ 0U);
977977
m_ast->AddMethodToCXXRecordType(
978-
t.GetOpaqueQualType(), class_name, std::nullopt, function_type,
978+
t.GetOpaqueQualType(), class_name, /*asm_label=*/{}, function_type,
979979
lldb::AccessType::eAccessPublic, is_virtual, is_static, is_inline,
980980
is_explicit, is_attr_used, is_artificial);
981981
}
@@ -987,7 +987,7 @@ TEST_F(TestTypeSystemClang, TestNotDeletingUserCopyCstrDueToMoveCStr) {
987987
m_ast->CreateFunctionType(return_type, args,
988988
/*variadic=*/false, /*quals*/ 0U);
989989
m_ast->AddMethodToCXXRecordType(
990-
t.GetOpaqueQualType(), class_name, std::nullopt, function_type,
990+
t.GetOpaqueQualType(), class_name, /*asm_label=*/{}, function_type,
991991
lldb::AccessType::eAccessPublic, is_virtual, is_static, is_inline,
992992
is_explicit, is_attr_used, is_artificial);
993993
}
@@ -1098,7 +1098,7 @@ TEST_F(TestTypeSystemClang, AddMethodToCXXRecordType_ParmVarDecls) {
10981098
m_ast->CreateFunctionType(return_type, param_types,
10991099
/*variadic=*/false, /*quals*/ 0U);
11001100
m_ast->AddMethodToCXXRecordType(
1101-
t.GetOpaqueQualType(), "myFunc", std::nullopt, function_type,
1101+
t.GetOpaqueQualType(), "myFunc", /*asm_label=*/{}, function_type,
11021102
lldb::AccessType::eAccessPublic, is_virtual, is_static, is_inline,
11031103
is_explicit, is_attr_used, is_artificial);
11041104

0 commit comments

Comments
 (0)