https://github.com/Vipul-Cariappa created 
https://github.com/llvm/llvm-project/pull/110101

Return the first `Decl` when using `TranslationUnitDecl::getCanonicalDecl`

>From 43d0e353e6e5870cf601ea83d072d8c05dbe94eb Mon Sep 17 00:00:00 2001
From: Vipul Cariappa <vipulcaria...@gmail.com>
Date: Thu, 26 Sep 2024 10:28:02 +0000
Subject: [PATCH] [clang] return first Decl for CanonicalDecl in
 TranslationUnitDecl

---
 clang/include/clang/AST/Decl.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 0600ecc4d14a18..7ff35d73df5997 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -133,6 +133,10 @@ class TranslationUnitDecl : public Decl,
   static TranslationUnitDecl *castFromDeclContext(const DeclContext *DC) {
     return static_cast<TranslationUnitDecl *>(const_cast<DeclContext*>(DC));
   }
+
+  /// Retrieves the canonical declaration of this translation unit.
+  TranslationUnitDecl *getCanonicalDecl() override { return getFirstDecl(); }
+  const TranslationUnitDecl *getCanonicalDecl() const { return getFirstDecl(); 
}
 };
 
 /// Represents a `#pragma comment` line. Always a child of

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to