Intercept sizeof and alignof references before they get into ASTContext methods. This fixes a crash when writing sizeof(Incomplete&), and lets ASTContext's methods do the right thing for CodeGen, which fixes PR5590.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89668 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/alignof-sizeof-reference.cpp b/test/SemaCXX/alignof-sizeof-reference.cpp
new file mode 100644
index 0000000..27d98ab
--- /dev/null
+++ b/test/SemaCXX/alignof-sizeof-reference.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-cc -std=c++0x -fsyntax-only -verify %s
+
+struct s0; // expected-note {{forward declaration}}
+char ar[sizeof(s0&)]; // expected-error {{invalid application of 'sizeof' to an incomplete type}}
+void test() {
+  char &r = ar[0];
+  static_assert(alignof(r) == 1, "bad alignment");
+  static_assert(sizeof(r) == 1, "bad size");
+}