Skip to content

[DRAFT] [backend] analyze procedures defined in changed headers - #2151

Draft
VladimirMakaev wants to merge 1 commit into
facebook:mainfrom
VladimirMakaev:changed-files-index-headers
Draft

VladimirMakaev wants to merge 1 commit into
facebook:mainfrom
VladimirMakaev:changed-files-index-headers

Conversation

@VladimirMakaev

@VladimirMakaev VladimirMakaev commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

With --changed-files-index, a changed header only selects the source file with the same name, so
procedures defined in headers (inline functions, in-class methods, templates) are not analyzed when
only the header changes.

// include/widget.h; changed files index: include/widget.h
inline int widget_get() {
  int* p = nullptr;
  return *p; // Infer missed: null dereference
}

// src/user.cpp, unchanged
#include "widget.h"
int use_widget() { return widget_get(); }

Now, for each procedure defined in a changed header, a captured source file that contains it is
analyzed too, and --incremental-analysis invalidates these procedures. With
--compilation-database, Infer warns about changed headers whose includers were not captured.

Limitations: such files are analyzed in full, so their unrelated issues are reported too, and the
file chosen for a header can change between versions, which reportdiff shows as fixed or
introduced issues.

Test plan

New build system tests incremental_analysis_change_header and differential_changed_header;
clang_compilation_db_headers also covers a partial index and a template used by two files. These,
the other clang_compilation_db* and incremental_analysis_* tests and the codetoanalyze tests
pass.

@meta-cla meta-cla Bot added the CLA Signed label Oct 2, 2026
@VladimirMakaev VladimirMakaev changed the title [backend] analyze procedures defined in changed headers [DRAFT] [backend] analyze procedures defined in changed headers Oct 2, 2026
@VladimirMakaev
VladimirMakaev force-pushed the changed-files-index-headers branch from 094cdc4 to 6b24a53 Compare October 2, 2026 20:00
With `--changed-files-index`, a changed header only selects the source file with the same name, so
procedures defined in headers (inline functions, in-class methods, templates) are not analyzed when
only the header changes.

```cpp
// include/widget.h; changed files index: include/widget.h
inline int widget_get() {
  int* p = nullptr;
  return *p; // Infer missed: null dereference
}

// src/user.cpp, unchanged
#include "widget.h"
int use_widget() { return widget_get(); }
```

Now, for each procedure defined in a changed header, a captured source file that contains it is
analyzed too, and `--incremental-analysis` invalidates these procedures. With
`--compilation-database`, Infer warns about changed headers whose includers were not captured.

Limitations: such files are analyzed in full, so their unrelated issues are reported too, and the
file chosen for a header can change between versions, which `reportdiff` shows as fixed or
introduced issues.

## Test plan

New build system tests `incremental_analysis_change_header` and `differential_changed_header`;
`clang_compilation_db_headers` also covers a partial index and a template used by two files. These,
the other `clang_compilation_db*` and `incremental_analysis_*` tests and the codetoanalyze tests
pass.
@VladimirMakaev
VladimirMakaev force-pushed the changed-files-index-headers branch from 6b24a53 to 61b4da7 Compare October 3, 2026 21:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant