[clang] [clang][CIR][doc] Add auto-generated ClangIR documentation (PR #190354)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 06:56:53 PDT 2026


Lancern wrote:

> Cannot we at least extend mlir-tblgen not to need postprocessing?

I think this is achievable actually. The amount of work needed to be done to make `mlir-tblgen` generate a whole page in its entirety should be moderate.

But then we would have another reason to keep a small script. Imagine that `mlir-tblgen` could directly generate `CIRLangRef.rst` into the `clang/docs/CIR` subdirectory. Since CIR is opt-in behind a CMake flag `CLANG_ENABLE_CIR`, the `CIRLangRef.rst` page is generated only when CIR is included in the build.

A somewhat annoying feature of Sphinx is that you have to list your pages explicitly in parent pages. So in `clang/docs/CIR/index.rst`, you have to explicitly list the `CIRLangRef.rst` page inside a `toctree::` directive. But if CIR is not included in the build, you would get a Sphinx build error since this page won't exist when CIR is not enabled. So you need a small script to tweak the `toctree::` directives based on whether the `CIRLangRef.rst` page is present.

I'm not a Sphinx expert so I'm not sure whether we could have a cleaner way to resolve similar problems. But I don't think this is a problem in the long-term since eventually we will make CIR enabled by default.

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


More information about the cfe-commits mailing list