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


C++ SourceLocation::getPtrEncoding方法代码示例

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


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

示例1: MakeCursorTypeRef

CXCursor cxcursor::MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc,
                                     CXTranslationUnit TU) {
    assert(Type && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_TypeRef, 0, { Type, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:7,代码来源:CXCursor.cpp

示例2: MakeMacroExpansionCursor

CXCursor cxcursor::MakeMacroExpansionCursor(MacroDefinition *MI,
        SourceLocation Loc,
        CXTranslationUnit TU) {
    assert(Loc.isValid());
    CXCursor C = { CXCursor_MacroExpansion, 0, { MI, Loc.getPtrEncoding(), TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:7,代码来源:CXCursor.cpp

示例3: MakeCursorLabelRef

CXCursor cxcursor::MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc,
                                      CXTranslationUnit TU) {

    assert(Label && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_LabelRef, 0, { Label, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:8,代码来源:CXCursor.cpp

示例4: MakeCursorMemberRef

CXCursor cxcursor::MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
                                       CXTranslationUnit TU) {

    assert(Field && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_MemberRef, 0, { Field, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:8,代码来源:CXCursor.cpp

示例5: MakeCursorVariableRef

CXCursor cxcursor::MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
        CXTranslationUnit TU) {

    assert(Var && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_VariableRef, 0, { Var, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:8,代码来源:CXCursor.cpp

示例6: MakeCursorObjCProtocolRef

CXCursor cxcursor::MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto,
        SourceLocation Loc,
        CXTranslationUnit TU) {
    assert(Proto && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_ObjCProtocolRef, 0, { Proto, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:8,代码来源:CXCursor.cpp

示例7: MakeCursorObjCSuperClassRef

CXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
        SourceLocation Loc,
        CXTranslationUnit TU) {
    assert(Super && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_ObjCSuperClassRef, 0, { Super, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:8,代码来源:CXCursor.cpp

示例8: MakeCursorNamespaceRef

CXCursor cxcursor::MakeCursorNamespaceRef(const NamedDecl *NS,
        SourceLocation Loc,
        CXTranslationUnit TU) {

    assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU &&
           "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_NamespaceRef, 0, { NS, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:10,代码来源:CXCursor.cpp

示例9: MakeCursorObjCClassRef

CXCursor cxcursor::MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class,
        SourceLocation Loc,
        CXTranslationUnit TU) {
    // 'Class' can be null for invalid code.
    if (!Class)
        return MakeCXCursorInvalid(CXCursor_InvalidCode);
    assert(TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    CXCursor C = { CXCursor_ObjCClassRef, 0, { Class, RawLoc, TU } };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:11,代码来源:CXCursor.cpp

示例10: MakeCursorOverloadedDeclRef

CXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name,
        SourceLocation Loc,
        CXTranslationUnit TU) {
    assert(Name.getAsOverloadedTemplate() && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    OverloadedDeclRefStorage Storage(Name.getAsOverloadedTemplate());
    CXCursor C = {
        CXCursor_OverloadedDeclRef, 0,
        { Storage.getOpaqueValue(), RawLoc, TU }
    };
    return C;
}
开发者ID:nicolaisi,项目名称:root,代码行数:12,代码来源:CXCursor.cpp

示例11: VisitRecordTypeLoc

bool EmptyStructToIntRewriteVisitor::VisitRecordTypeLoc(RecordTypeLoc RTLoc)
{
  const RecordDecl *RD = RTLoc.getDecl();
  if (RD->getCanonicalDecl() == ConsumerInstance->TheRecordDecl) {
    SourceLocation LocStart = RTLoc.getLocStart();
    void *LocPtr = LocStart.getPtrEncoding();
    if (ConsumerInstance->VisitedLocs.count(LocPtr))
      return true;
    ConsumerInstance->VisitedLocs.insert(LocPtr);

    // handle a special case -
    // struct S1 {
    //   struct { } S;
    // };
    const IdentifierInfo *TypeId = RTLoc.getType().getBaseTypeIdentifier();
    if (!TypeId)
      return true;
    ConsumerInstance->RewriteHelper->replaceRecordType(RTLoc, "int");
    ConsumerInstance->Rewritten = true;
  }
  return true;
}
开发者ID:BlastarIndia,项目名称:creduce,代码行数:22,代码来源:EmptyStructToInt.cpp

示例12: ActOnMSAsmStmt

StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
                                ArrayRef<Token> AsmToks,SourceLocation EndLoc) {
  SmallVector<IdentifierInfo*, 4> Names;
  SmallVector<StringRef, 4> ConstraintRefs;
  SmallVector<Expr*, 4> Exprs;
  SmallVector<StringRef, 4> ClobberRefs;

  llvm::Triple TheTriple = Context.getTargetInfo().getTriple();
  llvm::Triple::ArchType ArchTy = TheTriple.getArch();
  bool UnsupportedArch = ArchTy != llvm::Triple::x86 &&
    ArchTy != llvm::Triple::x86_64;
  if (UnsupportedArch)
    Diag(AsmLoc, diag::err_msasm_unsupported_arch) << TheTriple.getArchName();
    
  // Empty asm statements don't need to instantiate the AsmParser, etc.
  if (UnsupportedArch || AsmToks.empty()) {
    StringRef EmptyAsmStr;
    MSAsmStmt *NS =
      new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true,
                              /*IsVolatile*/ true, AsmToks, /*NumOutputs*/ 0,
                              /*NumInputs*/ 0, Names, ConstraintRefs, Exprs,
                              EmptyAsmStr, ClobberRefs, EndLoc);
    return Owned(NS);
  }

  std::string AsmString;
  SmallVector<unsigned, 8> TokOffsets;
  if (buildMSAsmString(*this, AsmLoc, AsmToks, TokOffsets, AsmString))
    return StmtError();

  // Get the target specific parser.
  std::string Error;
  const std::string &TT = TheTriple.getTriple();
  const llvm::Target *TheTarget(llvm::TargetRegistry::lookupTarget(TT, Error));

  OwningPtr<llvm::MCAsmInfo> MAI(TheTarget->createMCAsmInfo(TT));
  OwningPtr<llvm::MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));
  OwningPtr<llvm::MCObjectFileInfo> MOFI(new llvm::MCObjectFileInfo());
  OwningPtr<llvm::MCSubtargetInfo>
    STI(TheTarget->createMCSubtargetInfo(TT, "", ""));

  llvm::SourceMgr SrcMgr;
  llvm::MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr);
  llvm::MemoryBuffer *Buffer =
    llvm::MemoryBuffer::getMemBuffer(AsmString, "<MS inline asm>");

  // Tell SrcMgr about this buffer, which is what the parser will pick up.
  SrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc());

  OwningPtr<llvm::MCStreamer> Str(createNullStreamer(Ctx));
  OwningPtr<llvm::MCAsmParser>
    Parser(createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
  OwningPtr<llvm::MCTargetAsmParser>
    TargetParser(TheTarget->createMCAsmParser(*STI, *Parser));

  // Get the instruction descriptor.
  const llvm::MCInstrInfo *MII = TheTarget->createMCInstrInfo(); 
  llvm::MCInstPrinter *IP =
    TheTarget->createMCInstPrinter(1, *MAI, *MII, *MRI, *STI);

  // Change to the Intel dialect.
  Parser->setAssemblerDialect(1);
  Parser->setTargetParser(*TargetParser.get());
  Parser->setParsingInlineAsm(true);
  TargetParser->setParsingInlineAsm(true);

  MCAsmParserSemaCallbackImpl MCAPSI(*this, AsmLoc, AsmToks, TokOffsets);
  TargetParser->setSemaCallback(&MCAPSI);
  SrcMgr.setDiagHandler(MCAsmParserSemaCallbackImpl::MSAsmDiagHandlerCallback,
                        &MCAPSI);

  unsigned NumOutputs;
  unsigned NumInputs;
  std::string AsmStringIR;
  SmallVector<std::pair<void *, bool>, 4> OpDecls;
  SmallVector<std::string, 4> Constraints;
  SmallVector<std::string, 4> Clobbers;
  if (Parser->parseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR,
                               NumOutputs, NumInputs, OpDecls, Constraints,
                               Clobbers, MII, IP, MCAPSI))
    return StmtError();

  // Build the vector of clobber StringRefs.
  unsigned NumClobbers = Clobbers.size();
  ClobberRefs.resize(NumClobbers);
  for (unsigned i = 0; i != NumClobbers; ++i)
    ClobberRefs[i] = StringRef(Clobbers[i]);

  // Recast the void pointers and build the vector of constraint StringRefs.
  unsigned NumExprs = NumOutputs + NumInputs;
  Names.resize(NumExprs);
  ConstraintRefs.resize(NumExprs);
  Exprs.resize(NumExprs);
  for (unsigned i = 0, e = NumExprs; i != e; ++i) {
    NamedDecl *OpDecl = static_cast<NamedDecl *>(OpDecls[i].first);
    if (!OpDecl)
      return StmtError();

    DeclarationNameInfo NameInfo(OpDecl->getDeclName(), AsmLoc);
    ExprResult OpExpr = BuildDeclarationNameExpr(CXXScopeSpec(), NameInfo,
//.........这里部分代码省略.........
开发者ID:chrislambda,项目名称:clang,代码行数:101,代码来源:SemaStmtAsm.cpp

示例13: ParseMicrosoftAsmStatement


//.........这里部分代码省略.........
  assert(!LBraceLocs.empty() && "Should have at least one location here");

  // If we don't support assembly, or the assembly is empty, we don't
  // need to instantiate the AsmParser, etc.
  if (!TheTarget || AsmToks.empty()) {
    return Actions.ActOnMSAsmStmt(AsmLoc, LBraceLocs[0], AsmToks, StringRef(),
                                  /*NumOutputs*/ 0, /*NumInputs*/ 0,
                                  ConstraintRefs, ClobberRefs, Exprs, EndLoc);
  }

  // Expand the tokens into a string buffer.
  SmallString<512> AsmString;
  SmallVector<unsigned, 8> TokOffsets;
  if (buildMSAsmString(PP, AsmLoc, AsmToks, TokOffsets, AsmString))
    return StmtError();

  std::unique_ptr<llvm::MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));
  std::unique_ptr<llvm::MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TT));
  // Get the instruction descriptor.
  std::unique_ptr<llvm::MCInstrInfo> MII(TheTarget->createMCInstrInfo());
  std::unique_ptr<llvm::MCObjectFileInfo> MOFI(new llvm::MCObjectFileInfo());
  std::unique_ptr<llvm::MCSubtargetInfo> STI(
      TheTarget->createMCSubtargetInfo(TT, "", ""));

  llvm::SourceMgr TempSrcMgr;
  llvm::MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &TempSrcMgr);
  MOFI->InitMCObjectFileInfo(TheTriple, llvm::Reloc::Default,
                             llvm::CodeModel::Default, Ctx);
  std::unique_ptr<llvm::MemoryBuffer> Buffer =
      llvm::MemoryBuffer::getMemBuffer(AsmString, "<MS inline asm>");

  // Tell SrcMgr about this buffer, which is what the parser will pick up.
  TempSrcMgr.AddNewSourceBuffer(std::move(Buffer), llvm::SMLoc());

  std::unique_ptr<llvm::MCStreamer> Str(createNullStreamer(Ctx));
  std::unique_ptr<llvm::MCAsmParser> Parser(
      createMCAsmParser(TempSrcMgr, Ctx, *Str.get(), *MAI));

  // FIXME: init MCOptions from sanitizer flags here.
  llvm::MCTargetOptions MCOptions;
  std::unique_ptr<llvm::MCTargetAsmParser> TargetParser(
      TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));

  std::unique_ptr<llvm::MCInstPrinter> IP(
      TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));

  // Change to the Intel dialect.
  Parser->setAssemblerDialect(1);
  Parser->setTargetParser(*TargetParser.get());
  Parser->setParsingInlineAsm(true);
  TargetParser->setParsingInlineAsm(true);

  ClangAsmParserCallback Callback(*this, AsmLoc, AsmString, AsmToks,
                                  TokOffsets);
  TargetParser->setSemaCallback(&Callback);
  TempSrcMgr.setDiagHandler(ClangAsmParserCallback::DiagHandlerCallback,
                            &Callback);

  unsigned NumOutputs;
  unsigned NumInputs;
  std::string AsmStringIR;
  SmallVector<std::pair<void *, bool>, 4> OpExprs;
  SmallVector<std::string, 4> Constraints;
  SmallVector<std::string, 4> Clobbers;
  if (Parser->parseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR, NumOutputs,
                               NumInputs, OpExprs, Constraints, Clobbers,
                               MII.get(), IP.get(), Callback))
    return StmtError();

  // Filter out "fpsw".  Clang doesn't accept it, and it always lists flags and
  // fpsr as clobbers.
  auto End = std::remove(Clobbers.begin(), Clobbers.end(), "fpsw");
  Clobbers.erase(End, Clobbers.end());

  // Build the vector of clobber StringRefs.
  ClobberRefs.insert(ClobberRefs.end(), Clobbers.begin(), Clobbers.end());

  // Recast the void pointers and build the vector of constraint StringRefs.
  unsigned NumExprs = NumOutputs + NumInputs;
  ConstraintRefs.resize(NumExprs);
  Exprs.resize(NumExprs);
  for (unsigned i = 0, e = NumExprs; i != e; ++i) {
    Expr *OpExpr = static_cast<Expr *>(OpExprs[i].first);
    if (!OpExpr)
      return StmtError();

    // Need address of variable.
    if (OpExprs[i].second)
      OpExpr =
          Actions.BuildUnaryOp(getCurScope(), AsmLoc, UO_AddrOf, OpExpr).get();

    ConstraintRefs[i] = StringRef(Constraints[i]);
    Exprs[i] = OpExpr;
  }

  // FIXME: We should be passing source locations for better diagnostics.
  return Actions.ActOnMSAsmStmt(AsmLoc, LBraceLocs[0], AsmToks, AsmStringIR,
                                NumOutputs, NumInputs, ConstraintRefs,
                                ClobberRefs, Exprs, EndLoc);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:101,代码来源:ParseStmtAsm.cpp


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