[all-commits] [llvm/llvm-project] 9f9025: [analyzer][ctu] Fix wrong 'multiple definitions' e...

Ella Ma via All-commits all-commits at lists.llvm.org
Mon Mar 21 19:45:01 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9f90254286dc6ec9be39648200712dfe2e4b1fda
      https://github.com/llvm/llvm-project/commit/9f90254286dc6ec9be39648200712dfe2e4b1fda
  Author: Ella Ma <alansnape3058 at gmail.com>
  Date:   2022-03-22 (Tue, 22 Mar 2022)

  Changed paths:
    M clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
    M clang/include/clang/Basic/DiagnosticCrossTUKinds.td
    M clang/lib/CrossTU/CrossTranslationUnit.cpp
    M clang/test/Analysis/Inputs/ctu-import.c.externalDefMap.ast-dump.txt
    A clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp
    M clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
    M clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
    M clang/test/Analysis/Inputs/plist-macros-with-expansion-ctu.c.externalDefMap.txt
    M clang/test/Analysis/ctu-inherited-default-ctor.cpp
    A clang/test/Analysis/ctu-lookup-name-with-space.cpp
    M clang/test/Analysis/func-mapping-test.cpp
    M clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

  Log Message:
  -----------
  [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

This error was found when analyzing MySQL with CTU enabled.

When there are space characters in the lookup name, the current
delimiter searching strategy will make the file path wrongly parsed.
And when two lookup names have the same prefix before their first space
characters, a 'multiple definitions' error will be wrongly reported.

e.g. The lookup names for the two lambda exprs in the test case are
`c:@S at G@F at G#@Sa at F@operator int (*)(char)#1` and
`c:@S at G@F at G#@Sa at F@operator bool (*)(char)#1` respectively. And their
prefixes are both `c:@S at G@F at G#@Sa at F@operator` when using the first space
character as the delimiter.

Solving the problem by adding a length for the lookup name, making the
index items in the format of `<USR-Length>:<USR File> <Path>`.

---

In the test case of this patch, we found that it will trigger a "triple
mismatch" warning when using `clang -cc1` to analyze the source file
with CTU using the on-demand-parsing strategy in Darwin systems. And
this problem is also encountered in D75665, which is the patch
introducing the on-demand parsing strategy.
We temporarily bypass this problem by using the loading-ast-file
strategy.

Refer to the [discourse topic](https://discourse.llvm.org/t/60762) for
more details.

Differential Revision: https://reviews.llvm.org/D102669




More information about the All-commits mailing list