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

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 18 00:40:30 PDT 2021


steakhal added a reviewer: balazske.
steakhal added a comment.

I don't really like having multiple files with the same name.
And the importer TU should be simple to be simply `cat`-ed into a temporal file.
At that point, you could put the importee's content into this file. It would result in a single, self-contained test case.

I'm not really familiar with the extdefmap part, but I'm surprised that we are using spaces as separators.
Shouldn't we consider using a different character?



================
Comment at: clang/test/Analysis/ctu-lookup-name-with-space.cpp:7
+// RUN: echo '"%t/importee.cpp" : ["g++", "-c", "%t/importee.cpp"]' > %t/invocations.yaml
+// RUN: echo '[{"directory": "%t", "command": "g++ -c %t/importee.cpp", "file": "%t/importee.cpp"}, {"directory": "%t", "command": "g++ -c %t/trigger.cpp", "file": "%t/trigger.cpp"}]' > %t/compile_commands.json
+
----------------
Probably splitting this up into multiple lines would result in a more readable solution.

Something along these lines should work:
```
cat >%t/compile_commands.json <<EOL
line 1
line 2
...
EOL
```


================
Comment at: clang/test/Analysis/ctu-lookup-name-with-space.cpp:11-23
+// RUN: cd %t && %clang_cc1 -fsyntax-only -analyze \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=. \
+// RUN:   -analyzer-config ctu-invocation-list=invocations.yaml \
+// RUN:   trigger.cpp 2>&1 | FileCheck importee.cpp
+
----------------
Why do you need two separate invocations? Couldn't you just merge these?
I've seen cases where `-verify` was used in conjunction with `FileCheck`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102669



More information about the cfe-commits mailing list