[clang] [Clang] [NFC] Add an accessor for `ASTUnit::CodeGenOpts` (PR #172164)

via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 13 09:27:45 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (Sirraide)

<details>
<summary>Changes</summary>

There is currently no way to actually access `ASTUnit::CodeGenOpts`; this is almost certainly an oversight, so this adds a getter for it.

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


1 Files Affected:

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


``````````diff
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 341460e1962cb..0e3c52ae59320 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -476,6 +476,11 @@ class ASTUnit {
     return *LangOpts;
   }
 
+  const CodeGenOptions &getCodeGenOpts() const {
+    assert(CodeGenOpts && "ASTUnit does not have codegen options");
+    return *CodeGenOpts;
+  }
+
   const HeaderSearchOptions &getHeaderSearchOpts() const {
     assert(HSOpts && "ASTUnit does not have header search options");
     return *HSOpts;

``````````

</details>


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


More information about the cfe-commits mailing list