Skip to content

[clang] Use *Map::try_emplace (NFC) #143563

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

Merged
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
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/IdentifierTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class IdentifierTable {
/// introduce or modify an identifier. If they called get(), they would
/// likely end up in a recursion.
IdentifierInfo &getOwn(StringRef Name) {
auto &Entry = *HashTable.insert(std::make_pair(Name, nullptr)).first;
auto &Entry = *HashTable.try_emplace(Name).first;

IdentifierInfo *&II = Entry.second;
if (II)
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/ExtractAPI/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ APISet::createRecord(StringRef USR, StringRef Name,
CtorArgsContTy &&...CtorArgs) {
// Ensure USR refers to a String stored in the allocator.
auto USRString = copyString(USR);
auto Result = USRBasedLookupTable.insert({USRString, nullptr});
auto Result = USRBasedLookupTable.try_emplace(USRString);
RecordTy *Record;

// Create the record if it does not already exist
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CodeGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
auto *MPTy = cast<MemberPointerType>(Ty);
if (!getCXXABI().isMemberPointerConvertible(MPTy)) {
auto *C = MPTy->getMostRecentCXXRecordDecl()->getTypeForDecl();
auto Insertion = RecordsWithOpaqueMemberPointers.insert({C, nullptr});
auto Insertion = RecordsWithOpaqueMemberPointers.try_emplace(C);
if (Insertion.second)
Insertion.first->second = llvm::StructType::create(getLLVMContext());
ResultType = Insertion.first->second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ DependencyScanningFilesystemSharedCache::CacheShard::getOrEmplaceEntryForUID(
llvm::sys::fs::UniqueID UID, llvm::vfs::Status Stat,
std::unique_ptr<llvm::MemoryBuffer> Contents) {
std::lock_guard<std::mutex> LockGuard(CacheLock);
auto [It, Inserted] = EntriesByUID.insert({UID, nullptr});
auto [It, Inserted] = EntriesByUID.try_emplace(UID);
auto &CachedEntry = It->getSecond();
if (Inserted) {
CachedFileContents *StoredContents = nullptr;
Expand Down
Loading