本文整理汇总了C++中PresumedLoc::getLine方法的典型用法代码示例。如果您正苦于以下问题:C++ PresumedLoc::getLine方法的具体用法?C++ PresumedLoc::getLine怎么用?C++ PresumedLoc::getLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PresumedLoc
的用法示例。
在下文中一共展示了PresumedLoc::getLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitImportLocation
void TextDiagnostic::emitImportLocation(SourceLocation Loc, PresumedLoc PLoc,
StringRef ModuleName,
const SourceManager &SM) {
if (DiagOpts->ShowLocation && PLoc.isValid())
OS << "In module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
OS << "In module '" << ModuleName << "':\n";
}
示例2: printSourceLocation
static void printSourceLocation(SourceLocation loc, ASTContext &Ctx,
raw_ostream &OS) {
SourceManager &SM = Ctx.getSourceManager();
PresumedLoc PL = SM.getPresumedLoc(loc);
OS << llvm::sys::path::filename(PL.getFilename());
OS << ":" << PL.getLine() << ":"
<< PL.getColumn();
}
示例3: emitBuildingModuleLocation
void TextDiagnostic::emitBuildingModuleLocation(FullSourceLoc Loc,
PresumedLoc PLoc,
StringRef ModuleName) {
if (DiagOpts->ShowLocation && PLoc.isValid())
OS << "While building module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
OS << "While building module '" << ModuleName << "':\n";
}
示例4: emitIncludeLocation
void TextDiagnostic::emitIncludeLocation(SourceLocation Loc,
PresumedLoc PLoc,
const SourceManager &SM) {
if (DiagOpts->ShowLocation && PLoc.isValid())
OS << "In file included from " << PLoc.getFilename() << ':'
<< PLoc.getLine() << ":\n";
else
OS << "In included file:\n";
}
示例5: emitBuildingPCModuleLocation
void TextDiagnostic::emitBuildingPCModuleLocation(SourceLocation Loc,
PresumedLoc PLoc,
StringRef PCModuleName,
const SourceManager &SM) {
if (DiagOpts->ShowLocation && PLoc.getFilename())
OS << "While building module '" << PCModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
OS << "While building module '" << PCModuleName << "':\n";
}
示例6: emitIncludeLocation
void DiagnosticNoteRenderer::emitIncludeLocation(SourceLocation Loc,
PresumedLoc PLoc,
const SourceManager &SM) {
// Generate a note indicating the include location.
SmallString<200> MessageStorage;
llvm::raw_svector_ostream Message(MessageStorage);
Message << "in file included from " << PLoc.getFilename() << ':'
<< PLoc.getLine() << ":";
emitNote(Loc, Message.str(), &SM);
}
示例7: GetOrCreateDefaultOpenMPLocation
llvm::Value *CGOpenMPRuntime::EmitOpenMPUpdateLocation(
CodeGenFunction &CGF, SourceLocation Loc, OpenMPLocationFlags Flags) {
// If no debug info is generated - return global default location.
if (CGM.getCodeGenOpts().getDebugInfo() == CodeGenOptions::NoDebugInfo ||
Loc.isInvalid())
return GetOrCreateDefaultOpenMPLocation(Flags);
assert(CGF.CurFn && "No function in current CodeGenFunction.");
llvm::Value *LocValue = nullptr;
auto I = OpenMPLocThreadIDMap.find(CGF.CurFn);
if (I != OpenMPLocThreadIDMap.end())
LocValue = I->second.DebugLoc;
// OpenMPLocThreadIDMap may have null DebugLoc and non-null ThreadID, if
// GetOpenMPThreadID was called before this routine.
if (LocValue == nullptr) {
// Generate "ident_t .kmpc_loc.addr;"
llvm::AllocaInst *AI = CGF.CreateTempAlloca(IdentTy, ".kmpc_loc.addr");
AI->setAlignment(CGM.getDataLayout().getPrefTypeAlignment(IdentTy));
auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
Elem.second.DebugLoc = AI;
LocValue = AI;
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
CGF.Builder.CreateMemCpy(LocValue, GetOrCreateDefaultOpenMPLocation(Flags),
llvm::ConstantExpr::getSizeOf(IdentTy),
CGM.PointerAlignInBytes);
}
// char **psource = &.kmpc_loc_<flags>.addr.psource;
auto *PSource =
CGF.Builder.CreateConstInBoundsGEP2_32(LocValue, 0, IdentField_PSource);
auto OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding());
if (OMPDebugLoc == nullptr) {
SmallString<128> Buffer2;
llvm::raw_svector_ostream OS2(Buffer2);
// Build debug location
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
OS2 << ";" << PLoc.getFilename() << ";";
if (const FunctionDecl *FD =
dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl)) {
OS2 << FD->getQualifiedNameAsString();
}
OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str());
OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc;
}
// *psource = ";<File>;<Function>;<Line>;<Column>;;";
CGF.Builder.CreateStore(OMPDebugLoc, PSource);
return LocValue;
}
示例8: printSourceRange
static void printSourceRange(CharSourceRange range, ASTContext &Ctx,
raw_ostream &OS) {
SourceManager &SM = Ctx.getSourceManager();
const LangOptions &langOpts = Ctx.getLangOpts();
PresumedLoc PL = SM.getPresumedLoc(range.getBegin());
OS << llvm::sys::path::filename(PL.getFilename());
OS << " [" << PL.getLine() << ":"
<< PL.getColumn();
OS << " - ";
SourceLocation end = range.getEnd();
PL = SM.getPresumedLoc(end);
unsigned endCol = PL.getColumn() - 1;
if (!range.isTokenRange())
endCol += Lexer::MeasureTokenLength(end, SM, langOpts);
OS << PL.getLine() << ":" << endCol << "]";
}
示例9: pl_getPresumedLoc
foreign_t pl_getPresumedLoc(term_t DeclT, term_t FilenameT,
term_t LineT, term_t ColT) {
const Decl *D;
if ( !PL_get_pointer(DeclT, (void **) &D))
return PL_warning("getPresumedLoc/4: instantiation fault on first arg");
const SourceManager &SM = getCompilationInfo()->getSourceManager();
const PresumedLoc PL = SM.getPresumedLoc(D->getLocation());
if ( !PL_unify_atom_chars(FilenameT, PL.getFilename())) return FALSE;
if ( !PL_unify_int64(LineT, (int64_t) PL.getLine())) return FALSE;
return PL_unify_int64(ColT, (int64_t) PL.getColumn());
}
示例10: GetLocString
std::string BlinkGCPluginConsumer::GetLocString(SourceLocation loc) {
const SourceManager& source_manager = instance_.getSourceManager();
PresumedLoc ploc = source_manager.getPresumedLoc(loc);
if (ploc.isInvalid())
return "";
std::string loc_str;
llvm::raw_string_ostream os(loc_str);
os << ploc.getFilename()
<< ":" << ploc.getLine()
<< ":" << ploc.getColumn();
return os.str();
}
示例11: Message
void
DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc,
PresumedLoc PLoc,
StringRef ModuleName,
const SourceManager &SM) {
// Generate a note indicating the include location.
SmallString<200> MessageStorage;
llvm::raw_svector_ostream Message(MessageStorage);
Message << "while building module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":";
emitNote(Loc, Message.str(), &SM);
}
示例12:
llvm::MDNode *SanitizerMetadata::getLocationMetadata(SourceLocation Loc) {
PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
if (!PLoc.isValid())
return nullptr;
llvm::LLVMContext &VMContext = CGM.getLLVMContext();
llvm::Value *LocMetadata[] = {
llvm::MDString::get(VMContext, PLoc.getFilename()),
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), PLoc.getLine()),
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
PLoc.getColumn()),
};
return llvm::MDNode::get(VMContext, LocMetadata);
}
示例13: PrintIncludeStack
void TextDiagnosticPrinter::
PrintIncludeStack(SourceLocation Loc, const SourceManager &SM) {
if (Loc.isInvalid()) return;
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
// Print out the other include frames first.
PrintIncludeStack(PLoc.getIncludeLoc(), SM);
if (DiagOpts->ShowLocation)
OS << "In file included from " << PLoc.getFilename()
<< ':' << PLoc.getLine() << ":\n";
else
OS << "In included file:\n";
}
示例14: addLocation
//---------------------------------------------------------
PresumedLoc DocumentXML::addLocation(const SourceLocation& Loc)
{
SourceManager& SM = Ctx->getSourceManager();
SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
PresumedLoc PLoc;
if (!SpellingLoc.isInvalid())
{
PLoc = SM.getPresumedLoc(SpellingLoc);
addSourceFileAttribute(PLoc.getFilename());
addAttribute("line", PLoc.getLine());
addAttribute("col", PLoc.getColumn());
}
// else there is no error in some cases (eg. CXXThisExpr)
return PLoc;
}
示例15: emitIncludeStackRecursively
/// \brief Helper to recursivly walk up the include stack and print each layer
/// on the way back down.
void TextDiagnostic::emitIncludeStackRecursively(SourceLocation Loc) {
if (Loc.isInvalid())
return;
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
if (PLoc.isInvalid())
return;
// Emit the other include frames first.
emitIncludeStackRecursively(PLoc.getIncludeLoc());
if (DiagOpts.ShowLocation)
OS << "In file included from " << PLoc.getFilename()
<< ':' << PLoc.getLine() << ":\n";
else
OS << "In included file:\n";
}