[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:19 PST 2025


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

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

>From 7084d1a1a966342a26b6b02a076961d3fc808db8 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Sat, 13 Dec 2025 18:24:57 +0100
Subject: [PATCH] [Clang] Add an accessor for 'ASTUnit::CodeGenOpts'

---
 clang/include/clang/Frontend/ASTUnit.h | 5 +++++
 1 file changed, 5 insertions(+)

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;



More information about the cfe-commits mailing list