[clang] 7d4afba - [clang][bytecode][NFC] Fix Function::getName() for non-decl functions

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 7 01:56:46 PDT 2024


Author: Timm Bäder
Date: 2024-09-07T10:56:18+02:00
New Revision: 7d4afba831bcf9b3e50ee7b6a3fbc9c0a7c61597

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

LOG: [clang][bytecode][NFC] Fix Function::getName() for non-decl functions

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Function.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Function.h b/clang/lib/AST/ByteCode/Function.h
index b21fa8497130ea..640bfa65644f0f 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -103,10 +103,10 @@ class Function final {
   /// Returns the name of the function decl this code
   /// was generated for.
   const std::string getName() const {
-    if (!Source)
+    if (!Source || !getDecl())
       return "<<expr>>";
 
-    return Source.get<const FunctionDecl *>()->getQualifiedNameAsString();
+    return getDecl()->getQualifiedNameAsString();
   }
 
   /// Returns a parameter descriptor.


        


More information about the cfe-commits mailing list