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

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 05:53:19 PDT 2026


https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/227266

>From 6eafb171968d667ea1f182c019763d0ab6307314 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 29 Sep 2026 12:35:19 +0200
Subject: [PATCH] [clang][bytecode][NFC] Simplify Descriptor::getLocation()

`DeclOrExpr` already has a function for this, so just forward a call to
it.
---
 clang/lib/AST/ByteCode/Descriptor.cpp | 8 --------
 clang/lib/AST/ByteCode/Descriptor.h   | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

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