[cfe-commits] r145244 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/Sema/Initialization.h include/clang/Sema/Sema.h lib/Sema/Sema.cpp lib/Sema/SemaCast.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaInit.cpp test/Index/preamble_macro_template.cpp test/Index/recursive-cxx-member-calls.cpp
Nicola Gigante
nicola.gigante at gmail.com
Mon Nov 28 04:21:57 PST 2011
Author: gigabytes
Date: Mon Nov 28 06:21:57 2011
New Revision: 145244
URL: http://llvm.org/viewvc/llvm-project?rev=145244&view=rev
Log:
Removed useless ImplicitCast nodes in explicit cstyle and static casts
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Index/preamble_macro_template.cpp
cfe/trunk/test/Index/recursive-cxx-member-calls.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Nov 28 06:21:57 2011
@@ -178,9 +178,11 @@
/// \brief Retrieve the location of the cast operator keyword, e.g.,
/// "static_cast".
SourceLocation getOperatorLoc() const { return Loc; }
+ void setOperatorLoc(SourceLocation const& OpLoc) { Loc = OpLoc; }
/// \brief Retrieve the location of the closing parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; }
+ void setRParenLoc(SourceLocation const& Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const {
return SourceRange(Loc, RParenLoc);
Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Mon Nov 28 06:21:57 2011
@@ -340,7 +340,7 @@
SIK_Default = IK_Default, ///< Default initialization
SIK_Value = IK_Value, ///< Value initialization
SIK_ImplicitValue, ///< Implicit value initialization
- SIK_DirectCast, ///< Direct initialization due to a cast
+ SIK_DirectStaticCast, ///< Direct initialization due to a static cast
/// \brief Direct initialization due to a C-style cast.
SIK_DirectCStyleCast,
/// \brief Direct initialization due to a functional-style cast.
@@ -372,8 +372,8 @@
/// \brief Create a direct initialization due to a cast that isn't a C-style
/// or functional cast.
- static InitializationKind CreateCast(SourceRange TypeRange) {
- return InitializationKind(SIK_DirectCast,
+ static InitializationKind CreateStaticCast(SourceRange TypeRange) {
+ return InitializationKind(SIK_DirectStaticCast,
TypeRange.getBegin(), TypeRange.getBegin(),
TypeRange.getEnd());
}
@@ -425,7 +425,7 @@
/// \brief Determine whether this initialization is an explicit cast.
bool isExplicitCast() const {
- return Kind == SIK_DirectCast ||
+ return Kind == SIK_DirectStaticCast ||
Kind == SIK_DirectCStyleCast ||
Kind == SIK_DirectFunctionalCast;
}
@@ -440,6 +440,11 @@
return Kind == SIK_DirectCStyleCast;
}
+ /// brief Determine whether this is a static cast.
+ bool isStaticCast() const {
+ return Kind == SIK_DirectStaticCast;
+ }
+
/// brief Determine whether this is a functional-style cast.
bool isFunctionalCast() const {
return Kind == SIK_DirectFunctionalCast;
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Nov 28 06:21:57 2011
@@ -5557,18 +5557,26 @@
CCK_CStyleCast,
/// \brief A functional-style cast.
CCK_FunctionalCast,
+ /// \breif A static cast
+ CCK_StaticCast,
/// \brief A cast other than a C-style cast.
CCK_OtherCast
};
- /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
- /// cast. If there is already an implicit cast, merge into the existing one.
- /// If isLvalue, the result of the cast is an lvalue.
+ /// CastExprToType - If Expr is not of type 'Type', insert a cast of the
+ /// specified kind.
+ /// Redundant implicit casts are merged together.
+ ExprResult CastExprToType(Expr *E, QualType Ty,
+ CastKind Kind, ExprValueKind VK,
+ const CXXCastPath *BasePath,
+ CheckedConversionKind CCK);
+
+ /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
+ /// If there is already an implicit cast, merge into the existing one.
+ /// The result is of the given category.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK,
ExprValueKind VK = VK_RValue,
- const CXXCastPath *BasePath = 0,
- CheckedConversionKind CCK
- = CCK_ImplicitConversion);
+ const CXXCastPath *BasePath = 0);
/// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
/// to the conversion from scalar type ScalarTy to the Boolean type.
@@ -5757,10 +5765,10 @@
AssignmentAction Action,
CheckedConversionKind CCK
= CCK_ImplicitConversion);
- ExprResult PerformImplicitConversion(Expr *From, QualType ToType,
- const StandardConversionSequence& SCS,
- AssignmentAction Action,
- CheckedConversionKind CCK);
+ ExprResult PerformConversion(Expr *From, QualType ToType,
+ const StandardConversionSequence& SCS,
+ AssignmentAction Action,
+ CheckedConversionKind CCK);
/// the following "Check" methods will return a valid/converted QualType
/// or a null QualType (indicating an error diagnostic was issued).
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon Nov 28 06:21:57 2011
@@ -234,13 +234,16 @@
AnalysisWarnings.PrintStats();
}
-/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
-/// If there is already an implicit cast, merge into the existing one.
-/// The result is of the given category.
-ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
- CastKind Kind, ExprValueKind VK,
- const CXXCastPath *BasePath,
- CheckedConversionKind CCK) {
+/// CastExprToType - If Expr is not of type 'Type', insert a cast of the
+/// specified kind.
+/// Redundant implicit casts are merged together.
+/// Pay attention: if CCK != CCK_ImplicitConversion,
+/// users of this function must fill
+/// SourceTypeInfos and SourceLocations later
+ExprResult Sema::CastExprToType(Expr *E, QualType Ty,
+ CastKind Kind, ExprValueKind VK,
+ const CXXCastPath *BasePath,
+ CheckedConversionKind CCK) {
#ifndef NDEBUG
if (VK == VK_RValue && !E->isRValue()) {
switch (Kind) {
@@ -276,16 +279,41 @@
MarkVTableUsed(E->getLocStart(),
cast<CXXRecordDecl>(RecordTy->getDecl()));
}
-
- if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
- if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
- ImpCast->setType(Ty);
- ImpCast->setValueKind(VK);
- return Owned(E);
- }
+
+ switch(CCK) {
+ default:
+ llvm_unreachable("Unexpected CheckedConversionKind");
+ case CCK_ImplicitConversion:
+ if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
+ if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
+ ImpCast->setType(Ty);
+ ImpCast->setValueKind(VK);
+ return Owned(E);
+ }
+ }
+ return Owned(ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK));
+ case CCK_CStyleCast:
+ return Owned(CStyleCastExpr::Create(Context, Ty, VK, Kind, E, BasePath,
+ 0, SourceLocation(), SourceLocation()));
+ case CCK_FunctionalCast:
+ return Owned(CXXFunctionalCastExpr::Create(Context, Ty, VK, 0,
+ SourceLocation(), Kind, E,
+ BasePath, SourceLocation()));
+ case CCK_StaticCast:
+ return Owned(CXXStaticCastExpr::Create(Context, Ty, VK, Kind, E, BasePath,
+ 0, SourceLocation(),
+ SourceLocation()));
}
+
+}
- return Owned(ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK));
+/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
+/// If there is already an implicit cast, merge into the existing one.
+/// The result is of the given category.
+ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
+ CastKind Kind, ExprValueKind VK,
+ const CXXCastPath *BasePath) {
+ return CastExprToType(E, Ty, Kind, VK, BasePath, CCK_ImplicitConversion);
}
/// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Mon Nov 28 06:21:57 2011
@@ -75,9 +75,9 @@
// Top-level semantics-checking routines.
void CheckConstCast();
void CheckReinterpretCast();
- void CheckStaticCast();
+ void CheckStaticCast(bool &CastNodesCreated);
void CheckDynamicCast();
- void CheckCXXCStyleCast(bool FunctionalCast);
+ void CheckCXXCStyleCast(bool FunctionalCast, bool &CastNodesCreated);
void CheckCStyleCast();
/// Complete an apparently-successful cast operation that yields
@@ -283,12 +283,28 @@
Parens.getEnd()));
}
case tok::kw_static_cast: {
+ bool CastNodesCreated = false;
if (!TypeDependent) {
- Op.CheckStaticCast();
+ Op.CheckStaticCast(CastNodesCreated);
if (Op.SrcExpr.isInvalid())
return ExprError();
}
+ // CheckStaticCast _may_ have already created the cast node. Let's check
+ if (CastNodesCreated) {
+ if (CXXStaticCastExpr *Cast =
+ dyn_cast<CXXStaticCastExpr>(Op.SrcExpr.get())) {
+ assert(!Cast->getTypeInfoAsWritten() &&
+ "The explicit cast node created by CheckStaticCast "
+ "has source type infos!");
+
+ Cast->setTypeInfoAsWritten(DestTInfo);
+ Cast->setOperatorLoc(OpLoc);
+ Cast->setRParenLoc(Parens.getEnd());
+
+ return Op.complete(Cast);
+ }
+ }
return Op.complete(CXXStaticCastExpr::Create(Context, Op.ResultType,
Op.ValueKind, Op.Kind, Op.SrcExpr.take(),
&Op.BasePath, DestTInfo,
@@ -327,7 +343,7 @@
= (CT == CT_CStyle)? InitializationKind::CreateCStyleCast(range.getBegin(),
range)
: (CT == CT_Functional)? InitializationKind::CreateFunctionalCast(range)
- : InitializationKind::CreateCast(/*type range?*/ range);
+ : InitializationKind::CreateStaticCast(/*type range?*/ range);
InitializationSequence sequence(S, entity, initKind, &src, 1);
assert(sequence.Failed() && "initialization succeeded on second try?");
@@ -714,7 +730,7 @@
/// CheckStaticCast - Check that a static_cast\<DestType\>(SrcExpr) is valid.
/// Refer to C++ 5.2.9 for details. Static casts are mostly used for making
/// implicit conversions explicit and getting rid of data loss warnings.
-void CastOperation::CheckStaticCast() {
+void CastOperation::CheckStaticCast(bool &CastNodesCreated) {
if (isPlaceholder()) {
checkNonOverloadPlaceholders();
if (SrcExpr.isInvalid())
@@ -747,9 +763,10 @@
return;
}
+ Expr *SrcExprOrig = SrcExpr.get();
unsigned msg = diag::err_bad_cxx_cast_generic;
TryCastResult tcr
- = TryStaticCast(Self, SrcExpr, DestType, Sema::CCK_OtherCast, OpRange, msg,
+ = TryStaticCast(Self, SrcExpr, DestType, Sema::CCK_StaticCast, OpRange, msg,
Kind, BasePath);
if (tcr != TC_Success && msg != 0) {
if (SrcExpr.isInvalid())
@@ -767,10 +784,12 @@
if (Kind == CK_BitCast)
checkCastAlign();
if (Self.getLangOptions().ObjCAutoRefCount)
- checkObjCARCConversion(Sema::CCK_OtherCast);
+ checkObjCARCConversion(Sema::CCK_StaticCast);
} else if (Kind == CK_BitCast) {
checkCastAlign();
}
+
+ CastNodesCreated = (SrcExpr.get() != SrcExprOrig);
}
/// TryStaticCast - Check if a static cast can be performed, and do so if
@@ -1308,7 +1327,7 @@
? InitializationKind::CreateCStyleCast(OpRange.getBegin(), OpRange)
: (CCK == Sema::CCK_FunctionalCast)
? InitializationKind::CreateFunctionalCast(OpRange)
- : InitializationKind::CreateCast(OpRange);
+ : InitializationKind::CreateStaticCast(OpRange);
Expr *SrcExprRaw = SrcExpr.get();
InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExprRaw, 1);
@@ -1742,7 +1761,9 @@
return TC_Success;
}
-void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle) {
+void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
+ bool &CastNodesCreated) {
+ CastNodesCreated = false;
// Handle placeholders.
if (isPlaceholder()) {
// C-style casts can resolve __unknown_any types.
@@ -1823,6 +1844,7 @@
= FunctionalStyle? Sema::CCK_FunctionalCast
: Sema::CCK_CStyleCast;
if (tcr == TC_NotApplicable) {
+ Expr *SrcExprOrig = SrcExpr.get();
// ... or if that is not possible, a static_cast, ignoring const, ...
tcr = TryStaticCast(Self, SrcExpr, DestType, CCK, OpRange,
msg, Kind, BasePath);
@@ -1836,6 +1858,8 @@
if (SrcExpr.isInvalid())
return;
}
+
+ CastNodesCreated = (SrcExpr.get() != SrcExprOrig);
}
if (Self.getLangOptions().ObjCAutoRefCount && tcr == TC_Success)
@@ -2053,8 +2077,9 @@
Op.DestRange = CastTypeInfo->getTypeLoc().getSourceRange();
Op.OpRange = SourceRange(LPLoc, CastExpr->getLocEnd());
+ bool CastNodesCreated = false;
if (getLangOptions().CPlusPlus) {
- Op.CheckCXXCStyleCast(/*FunctionalStyle=*/ false);
+ Op.CheckCXXCStyleCast(/*FunctionalStyle=*/ false, CastNodesCreated);
} else {
Op.CheckCStyleCast();
}
@@ -2062,6 +2087,20 @@
if (Op.SrcExpr.isInvalid())
return ExprError();
+ // CheckCXXCStyleCast _may_ have already created the CStyleCastExpr
+ // node. Let's check.
+ if (CastNodesCreated) {
+ if (CStyleCastExpr *Cast = dyn_cast<CStyleCastExpr>(Op.SrcExpr.get())){
+ assert(!Cast->getTypeInfoAsWritten() &&
+ "The explicit cast node created by CheckStaticCast "
+ "has source type infos!");
+ Cast->setTypeInfoAsWritten(CastTypeInfo);
+ Cast->setLParenLoc(LPLoc);
+ Cast->setRParenLoc(RPLoc);
+ return Op.complete(Cast);
+ }
+ }
+
return Op.complete(CStyleCastExpr::Create(Context, Op.ResultType,
Op.ValueKind, Op.Kind, Op.SrcExpr.take(),
&Op.BasePath, CastTypeInfo, LPLoc, RPLoc));
@@ -2075,11 +2114,28 @@
Op.DestRange = CastTypeInfo->getTypeLoc().getSourceRange();
Op.OpRange = SourceRange(Op.DestRange.getBegin(), CastExpr->getLocEnd());
- Op.CheckCXXCStyleCast(/*FunctionalStyle=*/ true);
+ bool CastNodesCreated = false;
+ Op.CheckCXXCStyleCast(/*FunctionalStyle=*/ true, CastNodesCreated);
if (Op.SrcExpr.isInvalid())
return ExprError();
+ // CheckCXXCStyleCast _may_ have already created the CXXFunctionalCastExpr
+ // node. Let's check.
+ if (CastNodesCreated) {
+ if (CXXFunctionalCastExpr *Cast =
+ dyn_cast<CXXFunctionalCastExpr>(Op.SrcExpr.get())){
+ assert(!Cast->getTypeInfoAsWritten() &&
+ "The explicit cast node created by CheckStaticCast "
+ "has source type infos!");
+ Cast->setTypeInfoAsWritten(CastTypeInfo);
+ Cast->setTypeBeginLoc(Op.DestRange.getBegin());
+ Cast->setRParenLoc(RPLoc);
+ return Op.complete(Cast);
+ }
+ }
+
return Op.complete(CXXFunctionalCastExpr::Create(Context, Op.ResultType,
Op.ValueKind, CastTypeInfo, Op.DestRange.getBegin(),
Op.Kind, Op.SrcExpr.take(), &Op.BasePath, RPLoc));
}
+
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Nov 28 06:21:57 2011
@@ -2125,8 +2125,8 @@
CheckedConversionKind CCK) {
switch (ICS.getKind()) {
case ImplicitConversionSequence::StandardConversion: {
- ExprResult Res = PerformImplicitConversion(From, ToType, ICS.Standard,
- Action, CCK);
+ ExprResult Res = PerformConversion(From, ToType, ICS.Standard,
+ Action, CCK);
if (Res.isInvalid())
return ExprError();
From = Res.take();
@@ -2160,9 +2160,8 @@
// Watch out for elipsis conversion.
if (!ICS.UserDefined.EllipsisConversion) {
ExprResult Res =
- PerformImplicitConversion(From, BeforeToType,
- ICS.UserDefined.Before, AA_Converting,
- CCK);
+ PerformConversion(From, BeforeToType,
+ ICS.UserDefined.Before, AA_Converting, CCK);
if (Res.isInvalid())
return ExprError();
From = Res.take();
@@ -2182,8 +2181,8 @@
From = CastArg.take();
- return PerformImplicitConversion(From, ToType, ICS.UserDefined.After,
- AA_Converting, CCK);
+ return PerformConversion(From, ToType, ICS.UserDefined.After,
+ AA_Converting, CCK);
}
case ImplicitConversionSequence::AmbiguousConversion:
@@ -2203,13 +2202,13 @@
return Owned(From);
}
-/// PerformImplicitConversion - Perform an implicit conversion of the
+/// PerformConversion - Perform a conversion of the
/// expression From to the type ToType by following the standard
/// conversion sequence SCS. Returns the converted
/// expression. Flavor is the context in which we're performing this
/// conversion, for use in error messages.
ExprResult
-Sema::PerformImplicitConversion(Expr *From, QualType ToType,
+Sema::PerformConversion(Expr *From, QualType ToType,
const StandardConversionSequence& SCS,
AssignmentAction Action,
CheckedConversionKind CCK) {
@@ -2263,7 +2262,7 @@
FromType = From->getType();
}
- // Perform the first implicit conversion.
+ // Perform the first conversion step.
switch (SCS.First) {
case ICK_Identity:
// Nothing to do.
@@ -2278,21 +2277,21 @@
case ICK_Array_To_Pointer:
FromType = Context.getArrayDecayedType(FromType);
- From = ImpCastExprToType(From, FromType, CK_ArrayToPointerDecay,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, FromType, CK_ArrayToPointerDecay,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Function_To_Pointer:
FromType = Context.getPointerType(FromType);
- From = ImpCastExprToType(From, FromType, CK_FunctionToPointerDecay,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, FromType, CK_FunctionToPointerDecay,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
default:
llvm_unreachable("Improper first standard conversion");
}
- // Perform the second implicit conversion
+ // Perform the second conversion step
switch (SCS.Second) {
case ICK_Identity:
// If both sides are functions (or pointers/references to them), there could
@@ -2308,20 +2307,20 @@
if (CheckExceptionSpecCompatibility(From, ToType))
return ExprError();
- From = ImpCastExprToType(From, ToType, CK_NoOp,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_NoOp,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Integral_Promotion:
case ICK_Integral_Conversion:
- From = ImpCastExprToType(From, ToType, CK_IntegralCast,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_IntegralCast,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Floating_Promotion:
case ICK_Floating_Conversion:
- From = ImpCastExprToType(From, ToType, CK_FloatingCast,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_FloatingCast,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Complex_Promotion:
@@ -2339,23 +2338,23 @@
} else {
CK = CK_IntegralComplexCast;
}
- From = ImpCastExprToType(From, ToType, CK,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
}
case ICK_Floating_Integral:
if (ToType->isRealFloatingType())
- From = ImpCastExprToType(From, ToType, CK_IntegralToFloating,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_IntegralToFloating,
+ VK_RValue, /*BasePath=*/0, CCK).take();
else
- From = ImpCastExprToType(From, ToType, CK_FloatingToIntegral,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_FloatingToIntegral,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Compatible_Conversion:
- From = ImpCastExprToType(From, ToType, CK_NoOp,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_NoOp,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Writeback_Conversion:
@@ -2403,8 +2402,7 @@
From = E.take();
}
- From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
- .take();
+ From = CastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK).take();
break;
}
@@ -2415,8 +2413,7 @@
return ExprError();
if (CheckExceptionSpecCompatibility(From, ToType))
return ExprError();
- From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
- .take();
+ From = CastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK).take();
break;
}
@@ -2427,9 +2424,9 @@
FromType = Context.FloatTy;
}
- From = ImpCastExprToType(From, Context.BoolTy,
- ScalarTypeToBooleanCastKind(FromType),
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, Context.BoolTy,
+ ScalarTypeToBooleanCastKind(FromType),
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Derived_To_Base: {
@@ -2442,20 +2439,20 @@
CStyle))
return ExprError();
- From = ImpCastExprToType(From, ToType.getNonReferenceType(),
- CK_DerivedToBase, From->getValueKind(),
- &BasePath, CCK).take();
+ From = CastExprToType(From, ToType.getNonReferenceType(),
+ CK_DerivedToBase, From->getValueKind(),
+ &BasePath, CCK).take();
break;
}
case ICK_Vector_Conversion:
- From = ImpCastExprToType(From, ToType, CK_BitCast,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_BitCast,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Vector_Splat:
- From = ImpCastExprToType(From, ToType, CK_VectorSplat,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType, CK_VectorSplat,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
case ICK_Complex_Real:
@@ -2468,17 +2465,22 @@
if (Context.hasSameUnqualifiedType(ElType, From->getType())) {
// do nothing
} else if (From->getType()->isRealFloatingType()) {
- From = ImpCastExprToType(From, ElType,
- isFloatingComplex ? CK_FloatingCast : CK_FloatingToIntegral).take();
+ From = CastExprToType(From, ElType,
+ isFloatingComplex ? CK_FloatingCast
+ : CK_FloatingToIntegral,
+ VK_RValue, /*BasePath=*/0, CCK).take();
} else {
assert(From->getType()->isIntegerType());
- From = ImpCastExprToType(From, ElType,
- isFloatingComplex ? CK_IntegralToFloating : CK_IntegralCast).take();
+ From = CastExprToType(From, ElType,
+ isFloatingComplex ? CK_IntegralToFloating
+ : CK_IntegralCast,
+ VK_RValue, /*BasePath=*/0, CCK).take();
}
// y -> _Complex y
- From = ImpCastExprToType(From, ToType,
- isFloatingComplex ? CK_FloatingRealToComplex
- : CK_IntegralRealToComplex).take();
+ From = CastExprToType(From, ToType,
+ isFloatingComplex ? CK_FloatingRealToComplex
+ : CK_IntegralRealToComplex,
+ VK_RValue, /*BasePath=*/ 0, CCK).take();
// Case 2. _Complex x -> y
} else {
@@ -2489,30 +2491,32 @@
bool isFloatingComplex = ElType->isRealFloatingType();
// _Complex x -> x
- From = ImpCastExprToType(From, ElType,
- isFloatingComplex ? CK_FloatingComplexToReal
- : CK_IntegralComplexToReal,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ElType,
+ isFloatingComplex ? CK_FloatingComplexToReal
+ : CK_IntegralComplexToReal,
+ VK_RValue, /*BasePath=*/0, CCK).take();
// x -> y
if (Context.hasSameUnqualifiedType(ElType, ToType)) {
// do nothing
} else if (ToType->isRealFloatingType()) {
- From = ImpCastExprToType(From, ToType,
- isFloatingComplex ? CK_FloatingCast : CK_IntegralToFloating,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType,
+ isFloatingComplex ? CK_FloatingCast
+ : CK_IntegralToFloating,
+ VK_RValue, /*BasePath=*/0, CCK).take();
} else {
assert(ToType->isIntegerType());
- From = ImpCastExprToType(From, ToType,
- isFloatingComplex ? CK_FloatingToIntegral : CK_IntegralCast,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType,
+ isFloatingComplex ? CK_FloatingToIntegral
+ : CK_IntegralCast,
+ VK_RValue, /*BasePath=*/0, CCK).take();
}
}
break;
case ICK_Block_Pointer_Conversion: {
- From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
- VK_RValue, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
+ VK_RValue, /*BasePath=*/0, CCK).take();
break;
}
@@ -2547,8 +2551,8 @@
// target type isn't a reference.
ExprValueKind VK = ToType->isReferenceType() ?
From->getValueKind() : VK_RValue;
- From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context),
- CK_NoOp, VK, /*BasePath=*/0, CCK).take();
+ From = CastExprToType(From, ToType.getNonLValueExprType(Context),
+ CK_NoOp, VK, /*BasePath=*/0, CCK).take();
if (SCS.DeprecatedStringLiteralToCharPtr &&
!getLangOptions().WritableStrings)
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Nov 28 06:21:57 2011
@@ -4863,7 +4863,7 @@
Sema::CheckedConversionKind CCK
= Kind.isCStyleCast()? Sema::CCK_CStyleCast
: Kind.isFunctionalCast()? Sema::CCK_FunctionalCast
- : Kind.isExplicitCast()? Sema::CCK_OtherCast
+ : Kind.isStaticCast()? Sema::CCK_StaticCast
: Sema::CCK_ImplicitConversion;
ExprResult CurInitExprRes =
S.PerformImplicitConversion(CurInit.get(), Step->Type, *Step->ICS,
Modified: cfe/trunk/test/Index/preamble_macro_template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/preamble_macro_template.cpp?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/test/Index/preamble_macro_template.cpp (original)
+++ cfe/trunk/test/Index/preamble_macro_template.cpp Mon Nov 28 06:21:57 2011
@@ -9,7 +9,6 @@
// CHECK: preamble_macro_template.h:4:16: CompoundStmt= Extent=[4:16 - 6:2]
// CHECK: preamble_macro_template.h:5:3: CStyleCastExpr= Extent=[5:3 - 5:27]
// CHECK: preamble_macro_template.h:1:21: CXXStaticCastExpr= Extent=[1:21 - 5:27]
-// CHECK: preamble_macro_template.h:5:25: UnexposedExpr= Extent=[5:25 - 5:26]
// CHECK: preamble_macro_template.h:5:25: IntegerLiteral= Extent=[5:25 - 5:26]
// CHECK: preamble_macro_template.cpp:3:5: FunctionDecl=main:3:5 (Definition) Extent=[3:1 - 3:15]
// CHECK: preamble_macro_template.cpp:3:12: CompoundStmt= Extent=[3:12 - 3:15]
Modified: cfe/trunk/test/Index/recursive-cxx-member-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/recursive-cxx-member-calls.cpp?rev=145244&r1=145243&r2=145244&view=diff
==============================================================================
--- cfe/trunk/test/Index/recursive-cxx-member-calls.cpp (original)
+++ cfe/trunk/test/Index/recursive-cxx-member-calls.cpp Mon Nov 28 06:21:57 2011
@@ -1632,7 +1632,6 @@
// CHECK: 41:30: UnaryOperator= Extent=[41:30 - 41:40]
// CHECK: 41:31: CXXFunctionalCastExpr= Extent=[41:31 - 41:40]
// CHECK: 41:31: TypeRef=size_t:2:25 Extent=[41:31 - 41:37]
-// CHECK: 41:38: UnexposedExpr= Extent=[41:38 - 41:39]
// CHECK: 41:38: IntegerLiteral= Extent=[41:38 - 41:39]
// CHECK: 42:1: CXXAccessSpecifier=:42:1 (Definition) Extent=[42:1 - 42:9]
// CHECK: 43:15: FieldDecl=Data:43:15 (Definition) Extent=[43:3 - 43:19]
@@ -1804,7 +1803,6 @@
// CHECK: 75:13: ParenExpr= Extent=[75:13 - 75:30]
// CHECK: 75:14: CStyleCastExpr= Extent=[75:14 - 75:29]
// CHECK: 75:25: UnexposedExpr= Extent=[75:25 - 75:29]
-// CHECK: 75:25: UnexposedExpr= Extent=[75:25 - 75:29]
// CHECK: 75:25: ArraySubscriptExpr= Extent=[75:25 - 75:29]
// CHECK: 75:25: DeclRefExpr=p:74:17 Extent=[75:25 - 75:26]
// CHECK: 75:27: IntegerLiteral= Extent=[75:27 - 75:28]
@@ -1813,7 +1811,6 @@
// CHECK: 75:34: ParenExpr= Extent=[75:34 - 75:51]
// CHECK: 75:35: CStyleCastExpr= Extent=[75:35 - 75:50]
// CHECK: 75:46: UnexposedExpr= Extent=[75:46 - 75:50]
-// CHECK: 75:46: UnexposedExpr= Extent=[75:46 - 75:50]
// CHECK: 75:46: ArraySubscriptExpr= Extent=[75:46 - 75:50]
// CHECK: 75:46: DeclRefExpr=p:74:17 Extent=[75:46 - 75:47]
// CHECK: 75:48: IntegerLiteral= Extent=[75:48 - 75:49]
More information about the cfe-commits
mailing list