xref: /llvm-project/clang/test/Analysis/ctu-lookup-name-with-space.cpp (revision e4d242768aefabc0091dd01fabecaffbc2b6984b)
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 
4 // RUN: echo '41:c:@S@G@F@G#@Sa@F@operator void (*)(int)#1 %/t/importee.ast' >> %t/externalDefMap.txt
5 // RUN: echo '38:c:@S@G@F@G#@Sa@F@operator void (*)()#1 %/t/importee.ast' >> %t/externalDefMap.txt
6 // RUN: echo '14:c:@F@importee# %/t/importee.ast' >> %t/externalDefMap.txt
7 // RUN: %clang_cc1 -emit-pch %/S/Inputs/ctu-lookup-name-with-space.cpp -o %t/importee.ast
8 
9 // RUN: cd %t
10 // RUN: %clang_cc1 -analyze \
11 // RUN:   -analyzer-checker=core \
12 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
13 // RUN:   -analyzer-config ctu-dir=. \
14 // RUN:   -analyzer-config display-ctu-progress=true \
15 // RUN:   -verify %s 2>&1 | FileCheck %s
16 
17 // CHECK: CTU loaded AST file
18 
19 // FIXME: In this test case, we cannot use the on-demand-parsing approach to
20 //        load the external TU.
21 //
22 //        In the Darwin system, the target triple is determined by the driver,
23 //        rather than using the default one like other systems. However, when
24 //        using bare `clang -cc1`, the adjustment is not done, which cannot
25 //        match the one loaded with on-demand-parsing (adjusted triple).
26 //        We bypass this problem by loading AST files, whose target triple is
27 //        also unadjusted when generated via `clang -cc1 -emit-pch`.
28 //
29 //        Refer to: https://discourse.llvm.org/t/60762
30 //
31 //        This is also the reason why the test case of D75665 (introducing
32 //        the on-demand-parsing feature) is enabled only on Linux.
33 
34 void importee();
35 
trigger()36 void trigger() {
37   // Call an external function to trigger the parsing process of CTU index.
38   // Refer to file Inputs/ctu-lookup-name-with-space.cpp for more details.
39 
40   importee(); // expected-no-diagnostics
41 }
42