Added "isExact" field to FloatingLiteral.  This flag indicates whether or not
the APFloat representing the parsed literal can represent the literal value
exactly.  This is useful when performing various semantic checks on the code,
and issuing appropriate warnings to users.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44423 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/StmtSerialization.cpp b/AST/StmtSerialization.cpp
index 3134f88..120b68e 100644
--- a/AST/StmtSerialization.cpp
+++ b/AST/StmtSerialization.cpp
@@ -507,14 +507,16 @@
 void FloatingLiteral::EmitImpl(Serializer& S) const {
   S.Emit(Loc);
   S.Emit(getType());
+  S.EmitBool(isExact());
   S.Emit(Value);
 }
 
 FloatingLiteral* FloatingLiteral::CreateImpl(Deserializer& D) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   QualType t = QualType::ReadVal(D);
+  bool isExact = D.ReadBool();
   llvm::APFloat Val = llvm::APFloat::ReadVal(D);
-  FloatingLiteral* expr = new FloatingLiteral(Val,t,Loc);
+  FloatingLiteral* expr = new FloatingLiteral(Val,&isExact,t,Loc);
   return expr;
 }
 
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 14302aa..336dca7 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -188,8 +188,12 @@
       Context.Target.getDoubleInfo(Size, Align, Format, Tok.getLocation());
     }
     
-    Res = new FloatingLiteral(Literal.GetFloatValue(*Format), Ty,
-                              Tok.getLocation());
+    // isExact will be set by GetFloatValue().
+    bool isExact = false;
+    
+    Res = new FloatingLiteral(Literal.GetFloatValue(*Format,&isExact), &isExact, 
+                              Ty, Tok.getLocation());
+    
   } else if (!Literal.isIntegerLiteral()) {
     return ExprResult(true);
   } else {
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 7ee3afc..91cee5e 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -240,12 +240,16 @@
 
 class FloatingLiteral : public Expr {
   llvm::APFloat Value;
+  bool IsExact : 1;
   SourceLocation Loc;
 public:
-  FloatingLiteral(const llvm::APFloat &V, QualType Type, SourceLocation L)
-    : Expr(FloatingLiteralClass, Type), Value(V), Loc(L) {} 
+  FloatingLiteral(const llvm::APFloat &V, bool* isexact, 
+                  QualType Type, SourceLocation L)
+    : Expr(FloatingLiteralClass, Type), Value(V), IsExact(*isexact), Loc(L) {} 
 
   const llvm::APFloat &getValue() const { return Value; }
+  
+  bool isExact() const { return IsExact; }
 
   /// getValueAsDouble - This returns the value as an inaccurate double.  Note
   /// that this may cause loss of precision, but is useful for debugging dumps