[clang] 9932eb0 - [AST] Use DenseMapBase::lookup (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 18 11:53:07 PDT 2023


Author: Kazu Hirata
Date: 2023-06-18T11:52:59-07:00
New Revision: 9932eb083a0b735dbbf8b3341ba93dccc00358ae

URL: https://github.com/llvm/llvm-project/commit/9932eb083a0b735dbbf8b3341ba93dccc00358ae
DIFF: https://github.com/llvm/llvm-project/commit/9932eb083a0b735dbbf8b3341ba93dccc00358ae.diff

LOG: [AST] Use DenseMapBase::lookup (NFC)

Added: 
    

Modified: 
    clang/lib/AST/DeclCXX.cpp
    clang/lib/AST/MicrosoftMangle.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index efc933ef5cbcd..56c40e18ca28f 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1659,10 +1659,7 @@ void CXXRecordDecl::setLambdaNumbering(LambdaNumbering Numbering) {
 
 unsigned CXXRecordDecl::getDeviceLambdaManglingNumber() const {
   assert(isLambda() && "Not a lambda closure type!");
-  auto I = getASTContext().DeviceLambdaManglingNumbers.find(this);
-  if (I != getASTContext().DeviceLambdaManglingNumbers.end())
-    return I->second;
-  return 0;
+  return getASTContext().DeviceLambdaManglingNumbers.lookup(this);
 }
 
 static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) {

diff  --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index d70f1a19acbbd..1f9687e322c9d 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -290,12 +290,8 @@ class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
     assert(!RD->isExternallyVisible() && "RD must not be visible!");
     assert(RD->getLambdaManglingNumber() == 0 &&
            "RD must not have a mangling number!");
-    llvm::DenseMap<const CXXRecordDecl *, unsigned>::iterator Result =
-        LambdaIds.find(RD);
     // The lambda should exist, but return 0 in case it doesn't.
-    if (Result == LambdaIds.end())
-      return 0;
-    return Result->second;
+    return LambdaIds.lookup(RD);
   }
 
   /// Return a character sequence that is (somewhat) unique to the TU suitable


        


More information about the cfe-commits mailing list