[cfe-commits] r152137 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/Parse/ include/clang/Sema/ include/clang/Serialization/ lib/AST/ lib/CodeGen/ lib/Driver/ lib/Lex/ lib/Parse/ lib/Sema/ lib/Serialization/ test/CodeGenObjC/ test/CodeGenObjC/Inputs/ test/CodeGenObjCXX/ test/CodeGenObjCXX/Inputs/ test/Driver/ test/PCH/ test/SemaObjC/ test/SemaObjCXX/

Jordan Rose jediknil at belkadan.com
Sat Mar 17 17:40:39 PDT 2012


On Mar 6, 2012, at 12:05, Ted Kremenek wrote:

> +ExprResult Sema::ActOnObjCBoolLiteral(SourceLocation AtLoc, 
> +                                      SourceLocation ValueLoc,
> +                                      bool Value) {
> +  ExprResult Inner;
> +  if (getLangOptions().CPlusPlus) {
> +    Inner = ActOnCXXBoolLiteral(ValueLoc, Value? tok::kw_true : tok::kw_false);
> +  } else {
> +    // C doesn't actually have a way to represent literal values of type 
> +    // _Bool. So, we'll use 0/1 and implicit cast to _Bool.
> +    Inner = ActOnIntegerConstant(ValueLoc, Value? 1 : 0);
> +    Inner = ImpCastExprToType(Inner.get(), Context.BoolTy, 
> +                              CK_IntegralToBoolean);
> +  }
> +  
> +  return BuildObjCNumericLiteral(AtLoc, Inner.get());

Late with code review, but since you have ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind), why not use that now? I assume that's why it was even introduced...to AVOID this cast dance.

(The names are confusing me, too... ActOnObjCBoolLiteral is handling both __objc_yes and @__objc_yes (...and @true).)





More information about the cfe-commits mailing list