From e2428a11a3da6a4b8101d48a914af9028c5a05ab Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 17 Oct 2019 06:47:50 -0700 Subject: [PATCH] Avoid showing line number when its not relevant --- IDE/src/BuildContext.bf | 4 ++-- IDEHelper/CMakeLists.txt | 3 ++- IDEHelper/Compiler/BfIRCodeGen.cpp | 32 ++++++++++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/IDE/src/BuildContext.bf b/IDE/src/BuildContext.bf index 227f1586..6b07062a 100644 --- a/IDE/src/BuildContext.bf +++ b/IDE/src/BuildContext.bf @@ -322,10 +322,10 @@ namespace IDE } else { - IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/x86_64-w64-mingw32/lib")); + /*IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/x86_64-w64-mingw32/lib")); linkLine.Append(" "); IDEUtils.AppendWithOptionalQuotes(linkLine, scope String("-L", llvmDir, "/lib/gcc/x86_64-w64-mingw32/5.2.0")); - linkLine.Append(" "); + linkLine.Append(" ");*/ } } else // Microsoft diff --git a/IDEHelper/CMakeLists.txt b/IDEHelper/CMakeLists.txt index 9558ad46..207300bd 100644 --- a/IDEHelper/CMakeLists.txt +++ b/IDEHelper/CMakeLists.txt @@ -170,7 +170,8 @@ file(GLOB SRC_FILES Compiler/BfSystem.cpp Compiler/BfUtil.cpp Compiler/BfVarDeclChecker.cpp - Compiler/MemReporter.cpp + Compiler/BfTargetTriple.cpp + Compiler/MemReporter.cpp ) # Add library to build. diff --git a/IDEHelper/Compiler/BfIRCodeGen.cpp b/IDEHelper/Compiler/BfIRCodeGen.cpp index c0727353..31e5e75a 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.cpp +++ b/IDEHelper/Compiler/BfIRCodeGen.cpp @@ -390,14 +390,17 @@ void BfIRCodeGen::Fail(const StringImpl& error) if (mFailed) return; - auto dbgLoc = mIRBuilder->getCurrentDebugLocation(); - if (dbgLoc) + if (mHasDebugLoc) { - llvm::DIFile* file = NULL; - if (llvm::DIScope* scope = llvm::dyn_cast(dbgLoc.getScope())) - { - BfIRCodeGenBase::Fail(StrFormat("%s at line %d:%d in %s/%s", error.c_str(), dbgLoc.getLine(), dbgLoc.getCol(), scope->getDirectory().data(), scope->getFilename().data())); - return; + auto dbgLoc = mIRBuilder->getCurrentDebugLocation(); + if (dbgLoc) + { + llvm::DIFile* file = NULL; + if (llvm::DIScope* scope = llvm::dyn_cast(dbgLoc.getScope())) + { + BfIRCodeGenBase::Fail(StrFormat("%s at line %d:%d in %s/%s", error.c_str(), dbgLoc.getLine(), dbgLoc.getCol(), scope->getDirectory().data(), scope->getFilename().data())); + return; + } } } @@ -2615,6 +2618,7 @@ void BfIRCodeGen::HandleNextCmd() case BfIRCmd_StatementStart: // We only commit the debug loc for statement starts mIRBuilder->SetCurrentDebugLocation(mDebugLoc); + mHasDebugLoc = true; break; case BfIRCmd_ObjectAccessCheck: { @@ -3942,6 +3946,8 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen // // } + mHasDebugLoc = false; // So fails don't show a line number + bool enableLTO = codeGenOptions.mLTOType != BfLTOType_None; if (enableLTO) @@ -4166,8 +4172,8 @@ int BF_LinuxFixLinkage() int BF_AARC64_Linkage() { - LLVMInitializeAArch64TargetInfo(); - LLVMInitializeAArch64Target(); + LLVMInitializeAArch64TargetInfo(); + LLVMInitializeAArch64Target(); LLVMInitializeAArch64TargetMC(); return 0; } @@ -4175,15 +4181,15 @@ int BF_AARC64_Linkage() void BfIRCodeGen::StaticInit() { - LLVMInitializeX86TargetInfo(); - LLVMInitializeX86Target(); + LLVMInitializeX86TargetInfo(); + LLVMInitializeX86Target(); LLVMInitializeX86TargetMC(); LLVMInitializeX86AsmPrinter(); LLVMInitializeX86AsmParser(); LLVMInitializeX86Disassembler(); - LLVMInitializeAArch64TargetInfo(); - LLVMInitializeAArch64Target(); + LLVMInitializeAArch64TargetInfo(); + LLVMInitializeAArch64Target(); LLVMInitializeAArch64TargetMC(); LLVMInitializeAArch64AsmPrinter(); //LLVMInitializeAArch64Parser();