[clang] e0f3c0a - [clang][bytecode][NFC] Simplify Descriptor::getLocation() (#227266)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 23:46:40 PDT 2026


Author: Timm Baeder
Date: 2026-09-30T08:46:32+02:00
New Revision: e0f3c0a384c05cdb0685a5dad437a423e399cfb9

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

LOG: [clang][bytecode][NFC] Simplify Descriptor::getLocation() (#227266)

`DeclOrExpr` already has a function for this, so just forward a call to
it.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Descriptor.cpp
    clang/lib/AST/ByteCode/Descriptor.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Descriptor.cpp b/clang/lib/AST/ByteCode/Descriptor.cpp
index 862940ec32bf4..a20fdcaa8c0e9 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -470,14 +470,6 @@ QualType Descriptor::getDataType(const ASTContext &Ctx) const {
   return getType();
 }
 
-SourceLocation Descriptor::getLocation() const {
-  if (auto *D = Source.asDecl())
-    return D->getLocation();
-  if (auto *E = Source.asExpr())
-    return E->getExprLoc();
-  llvm_unreachable("Invalid descriptor type");
-}
-
 SourceInfo Descriptor::getLoc() const {
   if (const auto *D = Source.asDecl())
     return SourceInfo(D);

diff  --git a/clang/lib/AST/ByteCode/Descriptor.h b/clang/lib/AST/ByteCode/Descriptor.h
index ee88b8bad3aee..bec7ca653e055 100644
--- a/clang/lib/AST/ByteCode/Descriptor.h
+++ b/clang/lib/AST/ByteCode/Descriptor.h
@@ -195,7 +195,7 @@ struct Descriptor final {
   QualType getType() const;
   QualType getElemQualType() const;
   QualType getDataType(const ASTContext &Ctx) const;
-  SourceLocation getLocation() const;
+  SourceLocation getLocation() const { return Source.getLocation(); }
   SourceInfo getLoc() const;
 
   const Decl *asDecl() const { return Source.asDecl(); }


        


More information about the cfe-commits mailing list