Skip to content

Add argument to parse headers via a source's flags#58

Merged
compnerd merged 5 commits into
compnerd:mainfrom
Steelskin:fabrice/add-cdb-source-parameter
May 22, 2026
Merged

Add argument to parse headers via a source's flags#58
compnerd merged 5 commits into
compnerd:mainfrom
Steelskin:fabrice/add-cdb-source-parameter

Conversation

@Steelskin

@Steelskin Steelskin commented May 7, 2026

Copy link
Copy Markdown
Contributor

idt requires input to have an entry in the compilation database in order to be properly parsed. This is not always the case when parsing headers, depending on the project configuration.

This change adds --main-file=<path>. When set, idt looks up <path> in the compilation database and adjusts the command line to parse the positional argument with the same flags as <path>, assuming that the positional argument is a header.

Fixits are gated behind the is_in_main_tu() helper when --main-file is set to prevent spilling of fixits outside of the positional input. The helper is a no-op otherwise, preserving existing behavior.

idt requires input to have an entry in the compilation database in order
to be properly parsed. This is not always the case when parsing headers,
depending on the project configuration.

This change adds `--cdb-source=<path>`. When set, idt looks up `<path>`
in the compilation database and adjusts the command line to parse the
positional argument with the same flags as `<path>`, assuming that the
positional argument is a header.

Fixits are gated behind the `is_in_main_tu()` helper when `--cdb-source`
is set to prevent spilling of fixits outside of the positional input.
The helper is a no-op otherwise, preserving existing behavior.
Comment thread Sources/idt/idt.cc Outdated
Comment thread Sources/idt/idt.cc Outdated
Comment thread Sources/idt/idt.cc Outdated
@Steelskin Steelskin requested a review from compnerd May 19, 2026 08:24
Comment thread Sources/idt/idt.cc Outdated
Comment thread Sources/idt/idt.cc
Comment thread Sources/idt/idt.cc Outdated
Comment thread Sources/idt/idt.cc Outdated
compnerd and others added 2 commits May 21, 2026 16:28
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
@Steelskin Steelskin requested a review from compnerd May 22, 2026 15:05
@Steelskin

Copy link
Copy Markdown
Contributor Author

@compnerd It looks like I can't run the workflow to double-check this is working as expected, though the tests pass on my machine.

@compnerd compnerd merged commit 6d9b77c into compnerd:main May 22, 2026
2 checks passed
Steelskin added a commit to Steelskin/llvm-project that referenced this pull request Jun 10, 2026
In compnerd/ids#58, support was added to parse a header file using a
given source file's flags. This solves many of the issues we had
encountered with the `ids-check-helper.py` script and its corresponding
workflow.

* Update ids to the current version, which includes the `--main-file`
  changes.
* Use a more recent LLVM compiler to build a subset of LLVM.
* Build a subset of LLVM targets to properly parse more header files.
* Use the `--main-file` argument when invoking `idt`.
* Add explicit overrides and exclude header lists.

This was tested on every public header in LLVM and forthcoming PRs will
land the changes found with the updated script. Once all of the headers
have been updated, the workflow will be re-enabled. This effort is
tracked in llvm#109483.
Steelskin added a commit to llvm/llvm-project that referenced this pull request Jun 10, 2026
In compnerd/ids#58, support was added to parse a header file using a
given source file's flags. This solves many of the issues we had
encountered with the `ids-check-helper.py` script and its corresponding
workflow.

* Update ids to the current version, which includes the `--main-file`
changes.
* Use a more recent LLVM compiler to build a subset of LLVM.
* Build a subset of LLVM targets to properly parse more header files.
* Use the `--main-file` argument when invoking `idt`.
* Add explicit overrides and exclude header lists.

This was tested on every public header in LLVM and forthcoming PRs will
land the changes found with the updated script. Once all of the headers
have been updated, the workflow will be re-enabled. This effort is
tracked in #109483.
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jun 10, 2026
In compnerd/ids#58, support was added to parse a header file using a
given source file's flags. This solves many of the issues we had
encountered with the `ids-check-helper.py` script and its corresponding
workflow.

* Update ids to the current version, which includes the `--main-file`
changes.
* Use a more recent LLVM compiler to build a subset of LLVM.
* Build a subset of LLVM targets to properly parse more header files.
* Use the `--main-file` argument when invoking `idt`.
* Add explicit overrides and exclude header lists.

This was tested on every public header in LLVM and forthcoming PRs will
land the changes found with the updated script. Once all of the headers
have been updated, the workflow will be re-enabled. This effort is
tracked in #109483.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants