[clang] c0917ab - [clang][NFC] Convert `Sema::IfExistsResult` to scoped enum

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Fri May 2 03:05:44 PDT 2025


Author: Vlad Serebrennikov
Date: 2025-05-02T13:05:37+03:00
New Revision: c0917ab2e1cf603c3746f519fe1826869767bd8b

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

LOG: [clang][NFC] Convert `Sema::IfExistsResult` to scoped enum

Added: 
    

Modified: 
    clang/include/clang/Sema/Sema.h
    clang/lib/Parse/Parser.cpp
    clang/lib/Sema/SemaExprCXX.cpp
    clang/lib/Sema/TreeTransform.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d5ac4d2fa0fb2..0ea07e2ab4cd4 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -783,6 +783,22 @@ enum class AllocationFunctionScope {
   Both
 };
 
+/// Describes the result of an "if-exists" condition check.
+enum class IfExistsResult {
+  /// The symbol exists.
+  Exists,
+
+  /// The symbol does not exist.
+  DoesNotExist,
+
+  /// The name is a dependent name, so the results will 
diff er
+  /// from one instantiation to the next.
+  Dependent,
+
+  /// An error occurred.
+  Error
+};
+
 /// Sema - This implements semantic analysis and AST building for C.
 /// \nosubgrouping
 class Sema final : public SemaBase {
@@ -8667,22 +8683,6 @@ class Sema final : public SemaBase {
                                            RecoverUncorrectedTypos, Filter);
   }
 
-  /// Describes the result of an "if-exists" condition check.
-  enum IfExistsResult {
-    /// The symbol exists.
-    IER_Exists,
-
-    /// The symbol does not exist.
-    IER_DoesNotExist,
-
-    /// The name is a dependent name, so the results will 
diff er
-    /// from one instantiation to the next.
-    IER_Dependent,
-
-    /// An error occurred.
-    IER_Error
-  };
-
   IfExistsResult
   CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
                                const DeclarationNameInfo &TargetNameInfo);

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index ec87317897200..cab0604821c03 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -2436,21 +2436,21 @@ bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) {
   switch (Actions.CheckMicrosoftIfExistsSymbol(getCurScope(), Result.KeywordLoc,
                                                Result.IsIfExists, Result.SS,
                                                Result.Name)) {
-  case Sema::IER_Exists:
+  case IfExistsResult::Exists:
     Result.Behavior =
         Result.IsIfExists ? IfExistsBehavior::Parse : IfExistsBehavior::Skip;
     break;
 
-  case Sema::IER_DoesNotExist:
+  case IfExistsResult::DoesNotExist:
     Result.Behavior =
         !Result.IsIfExists ? IfExistsBehavior::Parse : IfExistsBehavior::Skip;
     break;
 
-  case Sema::IER_Dependent:
+  case IfExistsResult::Dependent:
     Result.Behavior = IfExistsBehavior::Dependent;
     break;
 
-  case Sema::IER_Error:
+  case IfExistsResult::Error:
     return true;
   }
 

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index ee45e196bdb5d..87a840d37e1d9 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -9671,17 +9671,16 @@ StmtResult Sema::ActOnFinishFullStmt(Stmt *FullStmt) {
   return MaybeCreateStmtWithCleanups(FullStmt);
 }
 
-Sema::IfExistsResult
-Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
-                                   CXXScopeSpec &SS,
+IfExistsResult
+Sema::CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
                                    const DeclarationNameInfo &TargetNameInfo) {
   DeclarationName TargetName = TargetNameInfo.getName();
   if (!TargetName)
-    return IER_DoesNotExist;
+    return IfExistsResult::DoesNotExist;
 
   // If the name itself is dependent, then the result is dependent.
   if (TargetName.isDependentName())
-    return IER_Dependent;
+    return IfExistsResult::Dependent;
 
   // Do the redeclaration lookup in the current scope.
   LookupResult R(*this, TargetNameInfo, Sema::LookupAnyName,
@@ -9694,29 +9693,30 @@ Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
   case LookupResultKind::FoundOverloaded:
   case LookupResultKind::FoundUnresolvedValue:
   case LookupResultKind::Ambiguous:
-    return IER_Exists;
+    return IfExistsResult::Exists;
 
   case LookupResultKind::NotFound:
-    return IER_DoesNotExist;
+    return IfExistsResult::DoesNotExist;
 
   case LookupResultKind::NotFoundInCurrentInstantiation:
-    return IER_Dependent;
+    return IfExistsResult::Dependent;
   }
 
   llvm_unreachable("Invalid LookupResult Kind!");
 }
 
-Sema::IfExistsResult
-Sema::CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc,
-                                   bool IsIfExists, CXXScopeSpec &SS,
-                                   UnqualifiedId &Name) {
+IfExistsResult Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
+                                                  SourceLocation KeywordLoc,
+                                                  bool IsIfExists,
+                                                  CXXScopeSpec &SS,
+                                                  UnqualifiedId &Name) {
   DeclarationNameInfo TargetNameInfo = GetNameFromUnqualifiedId(Name);
 
   // Check for an unexpanded parameter pack.
   auto UPPC = IsIfExists ? UPPC_IfExists : UPPC_IfNotExists;
   if (DiagnoseUnexpandedParameterPack(SS, UPPC) ||
       DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC))
-    return IER_Error;
+    return IfExistsResult::Error;
 
   return CheckMicrosoftIfExistsSymbol(S, SS, TargetNameInfo);
 }

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 3946662f807b2..aed00e0ff06cd 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -9292,23 +9292,23 @@ TreeTransform<Derived>::TransformMSDependentExistsStmt(
   SS.Adopt(QualifierLoc);
   bool Dependent = false;
   switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
-  case Sema::IER_Exists:
+  case IfExistsResult::Exists:
     if (S->isIfExists())
       break;
 
     return new (getSema().Context) NullStmt(S->getKeywordLoc());
 
-  case Sema::IER_DoesNotExist:
+  case IfExistsResult::DoesNotExist:
     if (S->isIfNotExists())
       break;
 
     return new (getSema().Context) NullStmt(S->getKeywordLoc());
 
-  case Sema::IER_Dependent:
+  case IfExistsResult::Dependent:
     Dependent = true;
     break;
 
-  case Sema::IER_Error:
+  case IfExistsResult::Error:
     return StmtError();
   }
 


        


More information about the cfe-commits mailing list