Implementation of pre-compiled headers (PCH) based on lazy
de-serialization of abstract syntax trees.
PCH support serializes the contents of the abstract syntax tree (AST)
to a bitstream. When the PCH file is read, declarations are serialized
as-needed. For example, a declaration of a variable "x" will be
deserialized only when its VarDecl can be found by a client, e.g.,
based on name lookup for "x" or traversing the entire contents of the
owner of "x".
This commit provides the framework for serialization and (lazy)
deserialization, along with support for variable and typedef
declarations (along with several kinds of types). More
declarations/types, along with important auxiliary structures (source
manager, preprocessor, etc.), will follow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68732 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/PCH/variables.c b/test/PCH/variables.c
new file mode 100644
index 0000000..2981a67
--- /dev/null
+++ b/test/PCH/variables.c
@@ -0,0 +1,6 @@
+// RUN: clang-cc -emit-pch -o %t %S/variables.h &&
+// RUN: clang-cc -include-pch %t -fsyntax-only -verify %s
+
+int *ip2 = &x;
+float *fp = &ip; // expected-warning{{incompatible pointer types}}
+
diff --git a/test/PCH/variables.h b/test/PCH/variables.h
new file mode 100644
index 0000000..442b5f6
--- /dev/null
+++ b/test/PCH/variables.h
@@ -0,0 +1,5 @@
+// RUN: clang-cc -emit-pch -o variables.h.pch variables.h
+extern int x;
+extern float y;
+extern int *ip;
+float z;
diff --git a/test/TestRunner.sh b/test/TestRunner.sh
index 754ab30..66c1e1e 100755
--- a/test/TestRunner.sh
+++ b/test/TestRunner.sh
@@ -8,6 +8,7 @@
#
# %s - Replaced with the input name of the program, or the program to
# execute, as appropriate.
+# %S - Replaced with the directory where the input file resides
# %prcontext - prcontext.tcl script
# %t - temporary file name (derived from testcase name)
#
@@ -15,6 +16,7 @@
FILENAME=$1
TESTNAME=$1
SUBST=$1
+FILEDIR=`dirname $TESTNAME`
OUTPUT=Output/$1.out
@@ -78,6 +80,7 @@
-e "s| clang | $CLANG |g" \
-e "s| clang-cc | $CLANGCC |g" \
-e "s|%s|$SUBST|g" \
+ -e "s|%S|$FILEDIR|g" \
-e "s|%prcontext|prcontext.tcl|g" \
-e "s|%t|$TEMPOUTPUT|g" > $SCRIPT