[PATCH] D102062: [analyzer][ctu] Append ctu-dir to ctu-invocation-list for non-absolute paths

Ella Ma via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 7 20:29:26 PDT 2021


OikawaKirie added a comment.

In D102062#2744267 <https://reviews.llvm.org/D102062#2744267>, @steakhal wrote:

> On second thought the current behavior is reasonable.

The behavior of all CTU affairs are related to the `ctu-dir` rather than CWD, such as loading the external function map file and looking for the AST dumps and source files to be imported.
If a relative path is provided for these files, the `ctu-dir` will be added to the path when trying to open the file (see the comments in the code).
Therefore, IMO the behavior of `ctu-invocation-list` and its contents should also be relative to the `ctu-dir` unless an absolute path is provided.

> We call clang from a command line, so I think it's fair to expect that relative paths are resolved using the CWD.

I do not know how other people use CSA, but I prefer using CSA via `clang-check`.
It works with the relative path to the "directory" option in the compilation database of each source file, which could make the CWD not unique.

> AFAIK if one does not supply the `ctu-invocation-list`, then it would be substituted by `ctu-dir/invocations.yaml` anyway.

But we cannot currently distinguish the difference between setting `ctu-invocation-list` to `invocations.yaml` and not setting it. As the default value of `ctu-invocation-list` is `invocations.yaml` rather than an empty string.
Therefore, adding the `ctu-dir` to a relative `ctu-invocation-list` path by default seems to be a better choice.



================
Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:470
   else
     llvm::sys::path::append(IndexFile, IndexName);
 
----------------
Loading the external function map.


================
Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:516
     Path = CTUDir;
     llvm::sys::path::append(Path, PathStyle, Identifier);
   }
----------------
Loading the ASTUnit from external AST dumps or source files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102062



More information about the cfe-commits mailing list