Skip to content

Commit 6aba6bf

Browse files
committed
make GlobalStrings an array
1 parent 8f09b5f commit 6aba6bf

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ void IRGenModule::SetCStringLiteralSection(llvm::GlobalVariable *GV,
10651065
GV->setSection(IRGenModule::ObjCMethodTypeSectionName);
10661066
return;
10671067
case ObjCLabelType::PropertyName:
1068-
GV->setSection(IRGenModule::ObjCPropertyNameSectionName);
1068+
GV->setSection(IRGenModule::ObjCMethodNameSectionName);
10691069
return;
10701070
}
10711071
case llvm::Triple::ELF:
@@ -6043,16 +6043,15 @@ IRGenModule::getAddrOfGlobalString(StringRef data, CStringSectionType type,
60436043
case CStringSectionType::ObjCMethodType:
60446044
sectionName = ObjCMethodTypeSectionName;
60456045
break;
6046-
case CStringSectionType::ObjCPropertyName:
6047-
sectionName = ObjCPropertyNameSectionName;
6048-
break;
60496046
case CStringSectionType::OSLogString:
60506047
sectionName = OSLogStringSectionName;
60516048
break;
6049+
case CStringSectionType::NumTypes:
6050+
llvm_unreachable("invalid type");
60526051
}
60536052

60546053
// Check whether this string already exists.
6055-
auto &entry = GlobalStrings[sectionName][data];
6054+
auto &entry = GlobalStrings[static_cast<size_t>(type)][data];
60566055

60576056
if (entry.second) {
60586057
// FIXME: Clear unnamed_addr if the global will be relative referenced

lib/IRGen/IRGenModule.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,11 @@ enum class CStringSectionType {
674674
ObjCClassName,
675675
ObjCMethodName,
676676
ObjCMethodType,
677-
ObjCPropertyName,
678677
OSLogString,
678+
// Place all new section types above this line
679+
NumTypes,
680+
// Place all alias below this line
681+
ObjCPropertyName = ObjCMethodName,
679682
};
680683

681684
/// IRGenModule - Primary class for emitting IR for global declarations.
@@ -1340,8 +1343,9 @@ class IRGenModule {
13401343
llvm::DenseMap<LinkEntity, llvm::Function*> GlobalFuncs;
13411344
llvm::DenseSet<const clang::Decl *> GlobalClangDecls;
13421345
// Maps sectionName -> string data -> constant
1343-
llvm::StringMap<
1344-
llvm::StringMap<std::pair<llvm::GlobalVariable *, llvm::Constant *>>>
1346+
std::array<
1347+
llvm::StringMap<std::pair<llvm::GlobalVariable *, llvm::Constant *>>,
1348+
static_cast<size_t>(CStringSectionType::NumTypes)>
13451349
GlobalStrings;
13461350
llvm::StringMap<llvm::Constant*> GlobalUTF16Strings;
13471351
llvm::StringMap<std::pair<llvm::GlobalVariable*, llvm::Constant*>>
@@ -1559,8 +1563,6 @@ class IRGenModule {
15591563
"__TEXT,__objc_methname,cstring_literals";
15601564
static constexpr const char ObjCMethodTypeSectionName[] =
15611565
"__TEXT,__objc_methtype,cstring_literals";
1562-
static constexpr const char ObjCPropertyNameSectionName[] =
1563-
"__TEXT,__objc_methname,cstring_literals";
15641566
static constexpr const char OSLogStringSectionName[] =
15651567
"__TEXT,__oslogstring,cstring_literals";
15661568

0 commit comments

Comments
 (0)