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


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

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


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

示例1: Diag

void C2Sema::ActOnImport(const char* moduleName_, SourceLocation loc, Token& aliasTok, bool isLocal) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: import " << moduleName_ << " at ";
    loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    std::string moduleName = moduleName_;
    // check if importing own module
    if (ast.getModuleName() == moduleName) {
        Diag(loc, diag::err_import_own_module) << moduleName_;
        return;
    }
    // check for duplicate import of module
    const ImportDecl* old = findModule(moduleName);
    if (old) {
        Diag(loc, diag::err_duplicate_import) << moduleName;
        Diag(old->getLocation(), diag::note_previous_import);
        return;
    }
    std::string name = moduleName;
    if (aliasTok.is(tok::identifier)) {
        name = aliasTok.getIdentifierInfo()->getNameStart();
        // check if same as normal module name
        if (name == moduleName) {
            Diag(aliasTok.getLocation(), diag::err_alias_same_as_module);
            return;
        }
    }
    ImportDecl* U = new ImportDecl(name, loc, isLocal, moduleName, aliasTok.getLocation());
    U->setType(typeContext.getModuleType(U));
    ast.addImport(U);
    addSymbol(U);
}
开发者ID:8l,项目名称:c2compiler,代码行数:33,代码来源:C2Sema.cpp

示例2: Diag

void C2Sema::ActOnUse(const char* name, SourceLocation loc, Token& aliasTok, bool isLocal) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: use " << name << " at ";
    loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    // check if use-ing own package
    if (ast.getPkgName() == name) {
        Diag(loc, diag::err_use_own_package) << name;
        return;
    }
    // check for duplicate use
    const Decl* old = findUse(name);
    if (old) {
        Diag(loc, diag::err_duplicate_use) << name;
        Diag(old->getLocation(), diag::note_previous_use);
        return;
    }
    const char* aliasName = "";
    if (aliasTok.is(tok::identifier)) {
        aliasName = aliasTok.getIdentifierInfo()->getNameStart();
        // check if same as normal package name
        if (strcmp(name, aliasName) == 0) {
            Diag(aliasTok.getLocation(), diag::err_alias_same_as_package);
            return;
        }
        const UseDecl* old = findAlias(aliasName);
        if (old) {
            Diag(aliasTok.getLocation(), diag::err_duplicate_use) << aliasName;
            Diag(old->getAliasLocation(), diag::note_previous_use);
            return;
        }
    }
    ast.addDecl(new UseDecl(name, loc, isLocal, aliasName, aliasTok.getLocation()));
}
开发者ID:vfr-nl,项目名称:c2compiler,代码行数:35,代码来源:C2Sema.cpp

示例3: Diag

void C2Sema::ActOnModule(const char* name, SourceLocation loc) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA << "SEMA: module " << name << " at ";
    loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    if (name[0] == '_' && name[1] == '_') {
        Diag(loc, diag::err_invalid_symbol_name) << name;
        return;
    }
    if (!islower(name[0]) && !ast.isInterface()) {
        Diag(loc, diag::err_module_casing);
        return;
    }

    if (strcmp(name, "c2") == 0) {
        Diag(loc, diag::err_module_c2);
        return;
    }
    if (strcmp(name, "main") == 0) {
        Diag(loc, diag::err_module_invalid_name) << name;
        return;
    }
    ast.setName(name, loc);
    ImportDecl* U = new ImportDecl(name, loc, true, name, SourceLocation());
    U->setType(typeContext.getModuleType(U));
    U->setUsed();
    ast.addImport(U);
    addSymbol(U);
}
开发者ID:unixaaa,项目名称:c2compiler,代码行数:30,代码来源:C2Sema.cpp

示例4: StmtResult

C2::StmtResult C2Sema::ActOnLabelStmt(const char* name, SourceLocation loc, Stmt* subStmt) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: label statement at ";
    loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    return StmtResult(new LabelStmt(name, loc, subStmt));
}
开发者ID:8l,项目名称:c2compiler,代码行数:8,代码来源:C2Sema.cpp

示例5: ArrayValueDecl

void C2Sema::ActOnArrayValue(const char* name, SourceLocation loc, Expr* Value) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: arrayvalue at ";
    loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    ast.addArrayValue(new ArrayValueDecl(name, loc, Value));
}
开发者ID:8l,项目名称:c2compiler,代码行数:8,代码来源:C2Sema.cpp

示例6: ExprResult

C2::ExprResult C2Sema::ActOnNil(SourceLocation L) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: nil expr at ";
    L.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    return ExprResult(new NilExpr(L));
}
开发者ID:8l,项目名称:c2compiler,代码行数:8,代码来源:C2Sema.cpp

示例7: id

C2::ExprResult C2Sema::ActOnIdExpression(IdentifierInfo& symII, SourceLocation symLoc) {
    std::string id(symII.getNameStart(), symII.getLength());
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: identifier " << id << " at ";
    symLoc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    return ExprResult(new IdentifierExpr(symLoc, id));
}
开发者ID:8l,项目名称:c2compiler,代码行数:9,代码来源:C2Sema.cpp

示例8: ExprResult

C2::ExprResult C2Sema::ActOnCharacterConstant(SourceLocation Loc, const std::string& value) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: char constant at ";
    Loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    // TODO parse value (\0, octal, \0x, etc) (see clang::CharLiteralParser)
    const char* str = value.c_str();
    assert(str[0] == '\'' && str[2] == '\'' && "char constant parsing not supported yet");
    unsigned cvalue = str[1];
    return ExprResult(new CharacterLiteral(Loc, cvalue));
}
开发者ID:vfr-nl,项目名称:c2compiler,代码行数:12,代码来源:C2Sema.cpp

示例9: DeclResult

C2::DeclResult C2Sema::ActOnStructVar(const char* name, SourceLocation loc, Expr* type, Expr* InitValue, bool is_public) {
#ifdef SEMA_DEBUG
    std::cerr << COL_SEMA"SEMA: struct var " << name << " at ";
    loc.dump(SourceMgr);
    std::cerr << ANSI_NORMAL"\n";
#endif
    TypeExpr* typeExpr = cast<TypeExpr>(type);
    if (typeExpr->hasLocalQualifier()) {
        //Diag(loc, diag::err_invalid_local_structmember);
#warning "TODO add diag msg to clang"
    }
    VarDecl* V =  createVarDecl(name, loc, typeExpr, InitValue, is_public);
    return DeclResult(V);
}
开发者ID:vfr-nl,项目名称:c2compiler,代码行数:14,代码来源:C2Sema.cpp


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