[clang] [Clang][NFC] Use const ASTContext reference in Decl Create methods (PR #185401)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 20 08:20:40 PDT 2026
================
@@ -138,12 +138,12 @@ class TranslationUnitDecl : public Decl,
using redeclarable_base::redecls_begin;
using redeclarable_base::redecls_end;
- ASTContext &getASTContext() const { return Ctx; }
+ ASTContext &getASTContext() const { return const_cast<ASTContext &>(Ctx); }
----------------
Endilll wrote:
Also see https://github.com/llvm/llvm-project/blob/3fdec1c9f9469587de24a525b48aa6ceddc392f5/clang/include/clang/AST/DeclBase.h#L2128-L2130 as an example how we use `const_cast` to deduplicate body of const-qualified overload.
https://github.com/llvm/llvm-project/pull/185401
More information about the cfe-commits
mailing list