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
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;
}
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 {
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