[clang] Change `ASTUnit::getASTContext() const` to return a non-const `ASTContext` (PR #130096)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 6 04:53:08 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Boaz Brickner (bricknerb)

<details>
<summary>Changes</summary>

Also, remove the non-const `ASTUnit::getASTContext()` since it's no longer necessary.
This would make it similar to `Decl::getAstContext() const` for a more consistent and flexible API.

---
Full diff: https://github.com/llvm/llvm-project/pull/130096.diff


1 Files Affected:

- (modified) clang/include/clang/Frontend/ASTUnit.h (+1-2) 


``````````diff
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 1f98c6ab328ba..bd55c8b627941 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -439,8 +439,7 @@ class ASTUnit {
   Preprocessor &getPreprocessor() { return *PP; }
   std::shared_ptr<Preprocessor> getPreprocessorPtr() const { return PP; }
 
-  const ASTContext &getASTContext() const { return *Ctx; }
-  ASTContext &getASTContext() { return *Ctx; }
+  ASTContext &getASTContext() const { return *Ctx; }
 
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
   void setPreprocessor(std::shared_ptr<Preprocessor> pp);

``````````

</details>


https://github.com/llvm/llvm-project/pull/130096


More information about the cfe-commits mailing list