Convert the type of the LValue offset variable in APValue to CharUnits, moving
the LValue-related methods of APValue out of line to avoid header file leaching.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93512 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp
index 772a884..50a6e0a 100644
--- a/lib/AST/APValue.cpp
+++ b/lib/AST/APValue.cpp
@@ -12,9 +12,20 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/AST/APValue.h"
+#include "clang/AST/CharUnits.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 
+namespace {
+  struct LV {
+    Expr* Base;
+    CharUnits Offset;
+  };
+}
+
+APValue::APValue(Expr* B) : Kind(Uninitialized) {
+  MakeLValue(); setLValue(B, CharUnits::Zero());
+}
 
 const APValue &APValue::operator=(const APValue &RHS) {
   if (Kind != RHS.Kind) {
@@ -106,3 +117,25 @@
   }
 }
 
+Expr* APValue::getLValueBase() const {
+  assert(isLValue() && "Invalid accessor");
+  return ((const LV*)(const void*)Data)->Base;
+}
+
+CharUnits APValue::getLValueOffset() const {
+    assert(isLValue() && "Invalid accessor");
+    return ((const LV*)(const void*)Data)->Offset;
+}
+
+void APValue::setLValue(Expr *B, const CharUnits &O) {
+  assert(isLValue() && "Invalid accessor");
+  ((LV*)(char*)Data)->Base = B;
+  ((LV*)(char*)Data)->Offset = O;
+}
+
+void APValue::MakeLValue() {
+  assert(isUninit() && "Bad state change");
+  new ((void*)(char*)Data) LV();
+  Kind = LValue;
+}
+