From af5a3c6af37a16b0ca686e6af994010b0b3785dd Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 1 May 2011 08:48:21 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130653 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 2ad59e74f2..0f715f0b8f 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2987,13 +2987,20 @@ ExprResult Sema::BuildArrayTypeTrait(ArrayTypeTrait ATT, 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, -- 2.50.1