__builtin___CFStringMakeConstantString. (We get into trouble in
GenerateStaticBlockVarDecl if the constant folder isn't accurate.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62949
91177308-0d34-0410-b5e6-
96231b3b80d8
{ return APValue(E, 0); }
APValue VisitAddrLabelExpr(AddrLabelExpr *E)
{ return APValue(E, 0); }
+ APValue VisitCallExpr(CallExpr *E);
APValue VisitConditionalOperator(ConditionalOperator *E);
};
} // end anonymous namespace
return APValue();
}
+APValue PointerExprEvaluator::VisitCallExpr(CallExpr *E) {
+ if (E->isBuiltinCall() == Builtin::BI__builtin___CFStringMakeConstantString)
+ return APValue(E, 0);
+ return APValue();
+}
+
APValue PointerExprEvaluator::VisitConditionalOperator(ConditionalOperator *E) {
bool BoolResult;
if (!HandleConversionToBool(E->getCond(), BoolResult, Info))
if (E->Evaluate(Result, CGM.getContext())) {
if (Result.Val.isInt())
return RValue::get(llvm::ConstantInt::get(Result.Val.getInt()));
- assert(Result.Val.isFloat() && "Unsupported constant type");
- return RValue::get(llvm::ConstantFP::get(Result.Val.getFloat()));
+ else if (Result.Val.isFloat())
+ return RValue::get(llvm::ConstantFP::get(Result.Val.getFloat()));
}
switch (BuiltinID) {
llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::Int32Ty, id);
return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType()));
}
+ case Expr::CallExprClass: {
+ CallExpr* CE = cast<CallExpr>(E);
+ if (CE->isBuiltinCall() != Builtin::BI__builtin___CFStringMakeConstantString)
+ break;
+ const Expr *Arg = CE->getArg(0)->IgnoreParenCasts();
+ const StringLiteral *Literal = cast<StringLiteral>(Arg);
+ std::string S(Literal->getStrData(), Literal->getByteLength());
+ return CGM.GetAddrOfConstantCFString(S);
+ }
}
CGM.ErrorUnsupported(E, "constant l-value expression");
llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType()));
// rdar://6248329
void *G = CFSTR("yo joe");
-
+void h() {
+ static void* h = CFSTR("Goodbye, World!");
+}