[LLVMbugs] [Bug 13274] New: AST for valid code should not be altered with __builtin_trap

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 5 02:19:08 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13274

             Bug #: 13274
           Summary: AST for valid code should not be altered with
                    __builtin_trap
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: abramobagnara at tin.it
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


As the following typescript shows, clang adds to the AST a call to
__builtin_trap and this impact negatively against source fidelity.

As an orthogonal note, it should be observed that in this specific case the
call cannot happens as sizeof argument is not evaluated.

The test is taken from g++ testsuite:

$ cat sizeof6.C
// { dg-do compile }
// Contributed by Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
// PR c++/13683: bogus warning about passing non-PODs through ellipsis

struct B {};
struct NonPOD : B {};

struct A
{
  static int check(...);
  static NonPOD GetNonPOD(void);
  enum { value = sizeof(A::check(A::GetNonPOD())) };
};
$ ~/llvm_trunk/Release+Asserts/bin/clang++ -cc1 -ast-dump sizeof6.C
typedef __int128 __int128_t;
typedef unsigned __int128 __uint128_t;
typedef __va_list_tag __builtin_va_list[1];
struct B {
    struct B;
    inline void ~B() throw();
};
struct NonPOD :  B {
    struct NonPOD;
    inline void ~NonPOD() throw();
};
struct A {
    struct A;
    static int check(...);
    static NonPOD GetNonPOD();
    enum  {
        value = (ImplicitCastExpr 0x2d8adb0 <sizeof6.C:12:18, col:49>
'unsigned int' <IntegralCast>
  (UnaryExprOrTypeTraitExpr 0x2d8ad40 <col:18, col:49> 'unsigned long'
sizeof
    (ParenExpr 0x2d8ad20 <col:24, col:49> 'int'
      (CallExpr 0x2d8ab10 <col:25, col:48> 'int'
        (ImplicitCastExpr 0x2d8aaf8 <col:25, col:28> 'int (*)(...)'
<FunctionToPointerDecay>
          (DeclRefExpr 0x2d8a778 <col:25, col:28> 'int (...)' lvalue
CXXMethod 0x2d8a460 'check' 'int (...)'))
        (BinaryOperator 0x2d8acf8 <col:34, col:47> 'struct NonPOD' ','
          (CallExpr 0x2d8acd0 <col:34, col:47> 'void'
            (ImplicitCastExpr 0x2d8acb8 <col:34> 'void (*)(void)
__attribute__((noreturn))' <FunctionToPointerDecay>
              (DeclRefExpr 0x2d8ac68 <col:34> 'void (void)
__attribute__((noreturn))' lvalue Function 0x2d8ab70 '__builtin_trap'
'void (void) __attribute__((noreturn))')))
          (CallExpr 0x2d8a860 <col:34, col:47> 'struct NonPOD'
            (ImplicitCastExpr 0x2d8a848 <col:34, col:37> 'struct NonPOD
(*)(void)' <FunctionToPointerDecay>
              (DeclRefExpr 0x2d8a7e8 <col:34, col:37> 'struct NonPOD
(void)' lvalue CXXMethod 0x2d8a5c0 'GetNonPOD' 'struct NonPOD
(void)'))))))))

    };
};
void __builtin_trap() __attribute__((nothrow));

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list