Skip to content

Commit 3dbdefb

Browse files
committed
Cast directly and simplify assertions
1 parent ff0399f commit 3dbdefb

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

clang/lib/CodeGen/Address.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/PointerIntPair.h"
2121
#include "llvm/IR/Constants.h"
2222
#include "llvm/IR/DerivedTypes.h"
23+
#include "llvm/Support/Casting.h"
2324
#include "llvm/Support/MathExtras.h"
2425

2526
namespace clang {
@@ -198,9 +199,7 @@ class Address {
198199

199200
/// Return the type of the pointer value.
200201
llvm::PointerType *getType() const {
201-
auto AS = llvm::cast<llvm::PointerType>(Pointer.getPointer()->getType())
202-
->getAddressSpace();
203-
return llvm::PointerType::get(ElementType->getContext(), AS);
202+
return llvm::cast<llvm::PointerType>(Pointer.getPointer()->getType());
204203
}
205204

206205
/// Return the type of the values stored in this address.

clang/lib/CodeGen/CGDeclCXX.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,7 @@ void CodeGenFunction::registerGlobalDtorWithLLVM(const VarDecl &VD,
345345

346346
void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
347347
// extern "C" int atexit(void (*f)(void));
348-
assert(dtorStub->getType() ==
349-
llvm::PointerType::get(
350-
CGM.getLLVMContext(),
351-
dtorStub->getType()->getPointerAddressSpace()) &&
348+
assert(dtorStub->getType()->isPointerTy() &&
352349
"Argument to atexit has a wrong type.");
353350

354351
llvm::FunctionType *atexitTy =
@@ -372,10 +369,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
372369
// value is returned.
373370
//
374371
// extern "C" int unatexit(void (*f)(void));
375-
assert(dtorStub->getType() ==
376-
llvm::PointerType::get(
377-
CGM.getLLVMContext(),
378-
dtorStub->getType()->getPointerAddressSpace()) &&
372+
assert(dtorStub->getType()->isPointerTy() &&
379373
"Argument to unatexit has a wrong type.");
380374

381375
llvm::FunctionType *unatexitTy =

0 commit comments

Comments
 (0)