[PATCH] D138782: [include-cleaner] Implement IWYU begin_keep/end_keep pragma support.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 28 04:20:58 PST 2022


hokein added inline comments.


================
Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:299
+      } else if (Pragma->starts_with("end_keep")) {
+        InsidePragmaKeepBlock = false;
+      }
----------------
using a simple variable is not enough to handle the nested case like 

```
// IWYU pragma: begin_keep
#include "keep1.h" 
// IWYU pragma: begin_keep
#include "keep2.h" 
#include "keep3.h"
// IWYU pragma: end_keep
#include "keep4.h"
// IWYU pragma: end_keep
```

now `keep4.h` is marked as unkeeped. I think we need to maintain a stack for `Keep` here (we already have a similar pattern for `export`)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138782/new/

https://reviews.llvm.org/D138782



More information about the cfe-commits mailing list