File: pch-from-libclang.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (38 lines) | stat: -rw-r--r-- 1,688 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Check that clang can use a PCH created from libclang.

// https://PR46644
// XFAIL: target=arm64-apple-{{.*}}

// This test doesn't use -fdisable-module-hash and hence requires that
// CompilerInvocation::getModuleHash() computes exactly the same hash
// for c-index-test and clang, which in turn requires that the both use
// exactly the same resource-dir, even without calling realpath() on it:
// - a/../b/ and b/ are not considered the same
// - on Windows, c:\ and C:\ (only different in case) are not the same

// RUN: rm -rf %t.mcp %t.h.pch
// RUN: %clang_cc1 -fsyntax-only %s -verify
// RUN: c-index-test -write-pch %t.h.pch %s -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin
// RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang -triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors
// RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang -triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors -Xclang -verify
// RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin | FileCheck %s

// FIXME: Still fails on at least some linux boxen.
// REQUIRES: system-darwin

#ifndef HEADER
#define HEADER

void some_function(undeclared_type p); // expected-error{{unknown type name}}

struct S { int x; };

#else
// expected-no-diagnostics

void test(struct S *s) {
  // CHECK: [[@LINE+1]]:6: MemberRefExpr=x:[[@LINE-6]]:16
  s->x = 0;
}

#endif