当前位置: 首页>>代码示例>>C++>>正文


C++ Sema::PerformInitializationByConstructor方法代码示例

本文整理汇总了C++中Sema::PerformInitializationByConstructor方法的典型用法代码示例。如果您正苦于以下问题:C++ Sema::PerformInitializationByConstructor方法的具体用法?C++ Sema::PerformInitializationByConstructor怎么用?C++ Sema::PerformInitializationByConstructor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sema的用法示例。


在下文中一共展示了Sema::PerformInitializationByConstructor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DeclarationName

/// TryStaticImplicitCast - Tests whether a conversion according to C++ 5.2.9p2
/// is valid:
///
///   An expression e can be explicitly converted to a type T using a
///   @c static_cast if the declaration "T t(e);" is well-formed [...].
TryCastResult
TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
                      bool CStyle, const SourceRange &OpRange, unsigned &msg)
{
  if (DestType->isReferenceType()) {
    // At this point of CheckStaticCast, if the destination is a reference,
    // this has to work. There is no other way that works.
    // On the other hand, if we're checking a C-style cast, we've still got
    // the reinterpret_cast way. In that case, we pass an ICS so we don't
    // get error messages.
    ImplicitConversionSequence ICS;
    bool failed = Self.CheckReferenceInit(SrcExpr, DestType, CStyle ? &ICS : 0);
    if (!failed)
      return TC_Success;
    if (CStyle)
      return TC_NotApplicable;
    // If we didn't pass the ICS, we already got an error message.
    msg = 0;
    return TC_Failed;
  }
  if (DestType->isRecordType()) {
    // There are no further possibilities for the target type being a class,
    // neither in static_cast nor in a C-style cast. So we can fail here.
    // FIXME: We need to store this constructor in the AST.
    if (Self.PerformInitializationByConstructor(DestType, &SrcExpr, 1,
          OpRange.getBegin(), OpRange, DeclarationName(), Sema::IK_Direct))
      return TC_Success;
    // The function already emitted an error.
    msg = 0;
    return TC_Failed;
  }

  // FIXME: To get a proper error from invalid conversions here, we need to
  // reimplement more of this.
  // FIXME: This does not actually perform the conversion, and thus does not
  // check for ambiguity or access.
  ImplicitConversionSequence ICS = Self.TryImplicitConversion(
    SrcExpr, DestType);
  return ICS.ConversionKind == ImplicitConversionSequence::BadConversion ?
    TC_NotApplicable : TC_Success;
}
开发者ID:Killfrra,项目名称:llvm-kernel,代码行数:46,代码来源:SemaCXXCast.cpp


注:本文中的Sema::PerformInitializationByConstructor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。