[cfe-commits] r130653 - /cfe/trunk/lib/Sema/SemaExprCXX.cpp

Chandler Carruth chandlerc at gmail.com
Sun May 1 01:48:21 PDT 2011


Author: chandlerc
Date: Sun May  1 03:48:21 2011
New Revision: 130653

URL: http://llvm.org/viewvc/llvm-project?rev=130653&view=rev
Log:
Have the array type traits build an expression with type 'size_t'
instead of 'int'.

The Embarcadero spec says 'unsigned int', not 'int'. That's what
'size_t' is on Windows, but for Clang using a 'size_t' that can be
larger than int seems more appropriate.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=130653&r1=130652&r2=130653&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun May  1 03:48:21 2011
@@ -2987,13 +2987,20 @@
                                      SourceLocation RParen) {
   QualType T = TSInfo->getType();
 
+  // FIXME: This should likely be tracked as an APInt to remove any host
+  // assumptions about the width of size_t on the target.
   uint64_t Value = 0;
   if (!T->isDependentType())
     Value = EvaluateArrayTypeTrait(*this, ATT, T, DimExpr, KWLoc);
 
+  // While the specification for these traits from the Embarcadero C++
+  // compiler's documentation says the return type is 'unsigned int', Clang
+  // returns 'size_t'. On Windows, the primary platform for the Embarcadero
+  // compiler, there is no difference. On several other platforms this is an
+  // important distinction.
   return Owned(new (Context) ArrayTypeTraitExpr(KWLoc, ATT, TSInfo, Value,
                                                 DimExpr, RParen,
-                                                Context.IntTy));
+                                                Context.getSizeType()));
 }
 
 ExprResult Sema::ActOnExpressionTrait(ExpressionTrait ET,





More information about the cfe-commits mailing list