[clang-tools-extra] [clangd] Implement simple folding for preprocessor branches (PR #140959)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 23 05:33:50 PDT 2025


================
@@ -220,6 +220,24 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
   auto EndPosition = [&](const Token &T) {
     return offsetToPosition(Code, EndOffset(T));
   };
+
+  // Preprocessor directives
----------------
HighCommander4 wrote:

A couple of minor points here:

* Since this code block does not use `Preprocessed` or `ParseableStream`, while the code blocks for producing the other kinds of regions do, I think it would make sense for code organization to move this block above the declarations of those variables.
* At the top of this function, please revise the comment `// FIXME( usaxena95): Collect PP conditional regions, includes and other code regions ... "` to `// FIXME( usaxena95): Collect includes and other code regions ...`


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


More information about the cfe-commits mailing list