[ASTContext][NFC] Remove getTargetAddressSpace(Qualifiers Q)
authorAlex Richardson <alexrichardson@google.com>
Tue, 22 Nov 2022 10:01:18 +0000 (10:01 +0000)
committerAlex Richardson <alexrichardson@google.com>
Wed, 23 Nov 2022 09:04:42 +0000 (09:04 +0000)
This simply calls getTargetAddressSpace(Q.getAddressSpace()) and there
are only two callers, so adjust those caller instead.

clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenTypes.cpp

index 2a21f2d..6f695f0 100644 (file)
@@ -2812,8 +2812,6 @@ public:
 
   unsigned getTargetAddressSpace(QualType T) const;
 
-  unsigned getTargetAddressSpace(Qualifiers Q) const;
-
   unsigned getTargetAddressSpace(LangAS AS) const;
 
   LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
index b9f9bec..e887f44 100644 (file)
@@ -12234,11 +12234,7 @@ unsigned ASTContext::getTargetAddressSpace(QualType T) const {
   // the best address space based on the type information
   return T->isFunctionType() && !T.hasAddressSpace()
              ? getTargetInfo().getProgramAddressSpace()
-             : getTargetAddressSpace(T.getQualifiers());
-}
-
-unsigned ASTContext::getTargetAddressSpace(Qualifiers Q) const {
-  return getTargetAddressSpace(Q.getAddressSpace());
+             : getTargetAddressSpace(T.getAddressSpace());
 }
 
 unsigned ASTContext::getTargetAddressSpace(LangAS AS) const {
index 05956c2..3869285 100644 (file)
@@ -772,10 +772,10 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
     // Block pointers lower to function type. For function type,
     // getTargetAddressSpace() returns default address space for
     // function pointer i.e. program address space. Therefore, for block
-    // pointers, it is important to pass qualifiers when calling
-    // getTargetAddressSpace(), to ensure that we get the address space
-    // for data pointers and not function pointers.
-    unsigned AS = Context.getTargetAddressSpace(FTy.getQualifiers());
+    // pointers, it is important to pass the pointee AST address space when
+    // calling getTargetAddressSpace(), to ensure that we get the LLVM IR
+    // address space for data pointers and not function pointers.
+    unsigned AS = Context.getTargetAddressSpace(FTy.getAddressSpace());
     ResultType = llvm::PointerType::get(PointeeType, AS);
     break;
   }