[clang] c493394 - [clang] Use DenseMapBase::lookup (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 00:25:01 PDT 2023
Author: Kazu Hirata
Date: 2023-06-13T00:24:43-07:00
New Revision: c4933940f76bb775c33b70f4543d30c2e595ef1f
URL: https://github.com/llvm/llvm-project/commit/c4933940f76bb775c33b70f4543d30c2e595ef1f
DIFF: https://github.com/llvm/llvm-project/commit/c4933940f76bb775c33b70f4543d30c2e595ef1f.diff
LOG: [clang] Use DenseMapBase::lookup (NFC)
Added:
Modified:
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/ExtractAPI/API.cpp
clang/lib/Lex/PreprocessingRecord.cpp
clang/lib/Serialization/ModuleManager.cpp
clang/tools/libclang/CXIndexDataConsumer.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index a771149f15912..b8286cef396c0 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -69,12 +69,7 @@ static bool isIncompletePhi(const til::SExpr *E) {
using CallingContext = SExprBuilder::CallingContext;
-til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) {
- auto It = SMap.find(S);
- if (It != SMap.end())
- return It->second;
- return nullptr;
-}
+til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) { return SMap.lookup(S); }
til::SCFG *SExprBuilder::buildCFG(CFGWalker &Walker) {
Walker.walk(*this);
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 553b7bbe710f8..10e79b37de739 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -249,10 +249,7 @@ APIRecord *APISet::findRecordForUSR(StringRef USR) const {
if (USR.empty())
return nullptr;
- auto It = USRBasedLookupTable.find(USR);
- if (It != USRBasedLookupTable.end())
- return It->second;
- return nullptr;
+ return USRBasedLookupTable.lookup(USR);
}
StringRef APISet::recordUSR(const Decl *D) {
diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp
index 85eb57f616116..aab6a2bed89d9 100644
--- a/clang/lib/Lex/PreprocessingRecord.cpp
+++ b/clang/lib/Lex/PreprocessingRecord.cpp
@@ -381,12 +381,7 @@ PreprocessingRecord::getLoadedPreprocessedEntity(unsigned Index) {
MacroDefinitionRecord *
PreprocessingRecord::findMacroDefinition(const MacroInfo *MI) {
- llvm::DenseMap<const MacroInfo *, MacroDefinitionRecord *>::iterator Pos =
- MacroDefinitions.find(MI);
- if (Pos == MacroDefinitions.end())
- return nullptr;
-
- return Pos->second;
+ return MacroDefinitions.lookup(MI);
}
void PreprocessingRecord::addMacroExpansion(const Token &Id,
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index 81dd54692d77e..5b099b740e1d3 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -59,11 +59,7 @@ ModuleFile *ModuleManager::lookupByModuleName(StringRef Name) const {
}
ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
- auto Known = Modules.find(File);
- if (Known == Modules.end())
- return nullptr;
-
- return Known->second;
+ return Modules.lookup(File);
}
std::unique_ptr<llvm::MemoryBuffer>
diff --git a/clang/tools/libclang/CXIndexDataConsumer.cpp b/clang/tools/libclang/CXIndexDataConsumer.cpp
index 006e55500798e..83f1f72cb7850 100644
--- a/clang/tools/libclang/CXIndexDataConsumer.cpp
+++ b/clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -970,12 +970,7 @@ void CXIndexDataConsumer::addContainerInMap(const DeclContext *DC,
}
CXIdxClientEntity CXIndexDataConsumer::getClientEntity(const Decl *D) const {
- if (!D)
- return nullptr;
- EntityMapTy::const_iterator I = EntityMap.find(D);
- if (I == EntityMap.end())
- return nullptr;
- return I->second;
+ return D ? EntityMap.lookup(D) : nullptr;
}
void CXIndexDataConsumer::setClientEntity(const Decl *D, CXIdxClientEntity client) {
@@ -1079,25 +1074,11 @@ CXIndexDataConsumer::getEntityContainer(const Decl *D) const {
CXIdxClientContainer
CXIndexDataConsumer::getClientContainerForDC(const DeclContext *DC) const {
- if (!DC)
- return nullptr;
-
- ContainerMapTy::const_iterator I = ContainerMap.find(DC);
- if (I == ContainerMap.end())
- return nullptr;
-
- return I->second;
+ return DC ? ContainerMap.lookup(DC) : nullptr;
}
CXIdxClientFile CXIndexDataConsumer::getIndexFile(const FileEntry *File) {
- if (!File)
- return nullptr;
-
- FileMapTy::iterator FI = FileMap.find(File);
- if (FI != FileMap.end())
- return FI->second;
-
- return nullptr;
+ return File ? FileMap.lookup(File) : nullptr;
}
CXIdxLoc CXIndexDataConsumer::getIndexLoc(SourceLocation Loc) const {
More information about the cfe-commits
mailing list