Skip to content

[analyzer] Warn when CTU merge drops a USR defined in several TUs - #5189

Open
pcbeingused333 wants to merge 1 commit into
Ericsson:masterfrom
pcbeingused333:fix/5086-warn-multi-tu-usr
Open

pcbeingused333 wants to merge 1 commit into
Ericsson:masterfrom
pcbeingused333:fix/5086-warn-multi-tu-usr

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #5086

During CTU pre-analysis, merge_clang_extdef_mappings builds one externalDefMap.txt from the per-TU maps. A USR that appears in more than one AST file is omitted from that map and nothing is logged. Clang then has no definition to inline, so defects that are reachable only through CTU are not reported. The same name in different source files is a normal case; the compilation database does not have to list one file twice.

The merge still drops those USRs. It now logs a warning with the USR and the AST paths. CodeChecker analyze already configures the analyzer logger, so the warning uses that channel when it has handlers. The standalone merge-clang-extdef-mappings tool keeps using MergeClangExtdefMappings. Choosing which definition to keep (the usr-uniqueing idea on the issue) is left out: that would change which body CTU inlines, and this change only makes the current drop visible.

Tests in analyzer/tools/merge_clang_extdef_mappings/tests/unit feed two map files that share c:@F@both# and otherwise unique names. Before the change the shared USR is absent from the merged map and no warning is emitted. After the change the unique names are still merged, the shared USR is still absent, and exactly one warning names that USR and both AST paths. A second test attaches a handler to the analyzer logger and checks the warning is emitted there.

This change was prepared with the help of an AI coding assistant.

The externalDefMap merge kept a mangled name only when it mapped to one
AST file and dropped every other name without a log. Clang then skips
those functions for CTU inlining, so defects reachable only that way
are missed. Warn with the USR and the AST paths, and still drop it.

Fixes Ericsson#5086

Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
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.

CTU pre-analysis silently drops multi-TU USRs from externalDefMap.txt

1 participant