[cfe-commits] r132612 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Sema/ include/clang/Serialization/ lib/AST/ lib/CodeGen/ lib/Parse/ lib/Sema/ lib/Serialization/ lib/StaticAnalyzer/Core/ test/Parser/ tools/libclang/

Dimitry Andric dimitry at andric.com
Wed Jun 8 05:58:26 PDT 2011


On 2011-06-04 02:47, Tanya Lattner wrote:
> Author: tbrethou
> Date: Fri Jun  3 19:47:47 2011
> New Revision: 132612
>
> URL: http://llvm.org/viewvc/llvm-project?rev=132612&view=rev
...
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=132612&r1=132611&r2=132612&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun  3 19:47:47 2011
> @@ -4995,6 +4995,26 @@
>     return ActOnCallExpr(S, ConfigDR, LLLLoc, execConfig, GGGLoc, 0);
>   }
>
> +/// ActOnAsTypeExpr - create a new asType (bitcast) from the arguments.
> +///
> +/// __builtin_astype( value, dst type )
> +///
> +ExprResult Sema::ActOnAsTypeExpr(Expr *expr, ParsedType destty,
> +                                 SourceLocation BuiltinLoc,
> +                                 SourceLocation RParenLoc) {
> +  ExprValueKind VK = VK_RValue;
> +  ExprObjectKind OK = OK_Ordinary;
> +  QualType DstTy = GetTypeFromParser(destty);
> +  QualType SrcTy = expr->getType();
> +  if (Context.getTypeSize(DstTy) != Context.getTypeSize(SrcTy))
> +    return ExprError(Diag(BuiltinLoc,
> +                          diag::err_invalid_astype_of_different_size)
> +<<  DstTy.getAsString().c_str()
> +<<  SrcTy.getAsString().c_str()
> +<<  expr->getSourceRange());
> +  return Owned(new (Context) AsTypeExpr(expr, DstTy, VK, OK, BuiltinLoc, RParenLoc));
> +}
> +

For me, this leads to a failure when testing a self-hosted clang:

FAIL: Clang :: Parser/opencl-astype.cl (1800 of 3142)
******************** TEST 'Clang :: Parser/opencl-astype.cl' FAILED ********************
Script:
--
/home/dim/obj/llvm-2/Release+Asserts/bin/clang -cc1 -fsyntax-only -verify /home/dim/src/llvm/trunk/tools/clang/test/Parser/opencl-astype.cl
--
Exit Code: 1
Command Output (stderr):
--
error: 'error' diagnostics expected but not seen:
   Line 14: invalid reinterpretation: sizes of double4 and float4 must match
error: 'error' diagnostics seen but not expected:
   Line 14: invalid reinterpretation: sizes of ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ and ZZZZZZZZ must match
2 errors generated.
--

********************

Because I'm using FreeBSD CURRENT, which poisons freed memory, the most
likely reason is that the strings returned by
DstTy.getAsString().c_str() and SrcTy.getAsString().c_str() are already
destroyed at the moment the diagnostics are printed.  Would it make
sense to convert them to StringRefs, or something else?

Btw, it doesn't seem possible to directly output std::string to a
DiagnosticBuilder, was there any particular reason for that?



More information about the cfe-commits mailing list