[clang] 2ec95c1 - [clang] Use llvm::to_underlying (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 9 17:08:54 PST 2023


Author: Kazu Hirata
Date: 2023-12-09T17:08:48-08:00
New Revision: 2ec95c19a267b5e58033701b12f55e0870bd3e6a

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

LOG: [clang] Use llvm::to_underlying (NFC)

Added: 
    

Modified: 
    clang/include/clang/AST/Type.h
    clang/lib/CodeGen/CGCall.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index b14184afe5840..b3ae66e6e769d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -36,6 +36,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
@@ -7514,7 +7515,7 @@ inline const Type *Type::getPointeeOrArrayElementType() const {
 /// spaces into a diagnostic with <<.
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
                                              LangAS AS) {
-  PD.AddTaggedVal(static_cast<std::underlying_type_t<LangAS>>(AS),
+  PD.AddTaggedVal(llvm::to_underlying(AS),
                   DiagnosticsEngine::ArgumentKind::ak_addrspace);
   return PD;
 }

diff  --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index aee86a3242fd3..1c0d15dc932ad 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -20,6 +20,7 @@
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/AST/Type.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/IR/Value.h"
 
 namespace llvm {
@@ -406,15 +407,13 @@ enum class FnInfoOpts {
 };
 
 inline FnInfoOpts operator|(FnInfoOpts A, FnInfoOpts B) {
-  return static_cast<FnInfoOpts>(
-      static_cast<std::underlying_type_t<FnInfoOpts>>(A) |
-      static_cast<std::underlying_type_t<FnInfoOpts>>(B));
+  return static_cast<FnInfoOpts>(llvm::to_underlying(A) |
+                                 llvm::to_underlying(B));
 }
 
 inline FnInfoOpts operator&(FnInfoOpts A, FnInfoOpts B) {
-  return static_cast<FnInfoOpts>(
-      static_cast<std::underlying_type_t<FnInfoOpts>>(A) &
-      static_cast<std::underlying_type_t<FnInfoOpts>>(B));
+  return static_cast<FnInfoOpts>(llvm::to_underlying(A) &
+                                 llvm::to_underlying(B));
 }
 
 inline FnInfoOpts operator|=(FnInfoOpts A, FnInfoOpts B) {


        


More information about the cfe-commits mailing list