diff options
author | smanna12 <soumi.manna@intel.com> | 2024-07-31 15:36:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 17:36:21 -0500 |
commit | cf79aba99db4909437b8977a59c51bc8899ddb9c (patch) | |
tree | 5d9604fd6b29f7d852d66eb7a48c06a35d0c1d4a /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 74f95794433f315a14bd6878d97877566863bc34 (diff) | |
download | llvm-cf79aba99db4909437b8977a59c51bc8899ddb9c.zip llvm-cf79aba99db4909437b8977a59c51bc8899ddb9c.tar.gz llvm-cf79aba99db4909437b8977a59c51bc8899ddb9c.tar.bz2 |
[Clang] [NFC] Fix potential dereferencing of nullptr (#101405)
This patch replaces getAs with castAs and dyn_cast with cast to ensure
type safety and prevents potential null pointer dereferences. These
changes enforce compile-time checks for correct type casting in
ASTContext and CodeGenModule.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 344a0e5..760185d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5659,7 +5659,7 @@ void CodeGenModule::EmitExternalFunctionDeclaration(const FunctionDecl *FD) { if (getCodeGenOpts().hasReducedDebugInfo()) { auto *Ty = getTypes().ConvertType(FD->getType()); StringRef MangledName = getMangledName(FD); - auto *Fn = dyn_cast<llvm::Function>( + auto *Fn = cast<llvm::Function>( GetOrCreateLLVMFunction(MangledName, Ty, FD, /* ForVTable */ false)); if (!Fn->getSubprogram()) DI->EmitFunctionDecl(FD, FD->getLocation(), FD->getType(), Fn); |