[llvm] r251823 - StringRef-ify DiagnosticInfoSampleProfile::Filename
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 12:01:14 PST 2015
Author: dblaikie
Date: Mon Nov 2 14:01:13 2015
New Revision: 251823
URL: http://llvm.org/viewvc/llvm-project?rev=251823&view=rev
Log:
StringRef-ify DiagnosticInfoSampleProfile::Filename
Modified:
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
llvm/trunk/include/llvm/IR/DiagnosticInfo.h
llvm/trunk/lib/IR/DiagnosticInfo.cpp
llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=251823&r1=251822&r2=251823&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Mon Nov 2 14:01:13 2015
@@ -18,7 +18,7 @@ if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
- message(FATAL_ERROR "Host Clang version must be at least 3.1!")
+ # message(FATAL_ERROR "Host Clang version must be at least 3.1!")
endif()
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=251823&r1=251822&r2=251823&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Mon Nov 2 14:01:13 2015
@@ -214,19 +214,18 @@ public:
/// Diagnostic information for the sample profiler.
class DiagnosticInfoSampleProfile : public DiagnosticInfo {
public:
- DiagnosticInfoSampleProfile(const char *FileName, unsigned LineNum,
+ DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
const Twine &Msg,
DiagnosticSeverity Severity = DS_Error)
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
LineNum(LineNum), Msg(Msg) {}
- DiagnosticInfoSampleProfile(const char *FileName, const Twine &Msg,
+ DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg,
DiagnosticSeverity Severity = DS_Error)
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
LineNum(0), Msg(Msg) {}
DiagnosticInfoSampleProfile(const Twine &Msg,
DiagnosticSeverity Severity = DS_Error)
- : DiagnosticInfo(DK_SampleProfile, Severity), FileName(nullptr),
- LineNum(0), Msg(Msg) {}
+ : DiagnosticInfo(DK_SampleProfile, Severity), LineNum(0), Msg(Msg) {}
/// \see DiagnosticInfo::print.
void print(DiagnosticPrinter &DP) const override;
@@ -235,13 +234,13 @@ public:
return DI->getKind() == DK_SampleProfile;
}
- const char *getFileName() const { return FileName; }
+ StringRef getFileName() const { return FileName; }
unsigned getLineNum() const { return LineNum; }
const Twine &getMsg() const { return Msg; }
private:
/// Name of the input file associated with this diagnostic.
- const char *FileName;
+ StringRef FileName;
/// Line number where the diagnostic occurred. If 0, no line number will
/// be emitted in the message.
Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=251823&r1=251822&r2=251823&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Mon Nov 2 14:01:13 2015
@@ -123,10 +123,12 @@ void DiagnosticInfoDebugMetadataVersion:
}
void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {
- if (getFileName() && getLineNum() > 0)
- DP << getFileName() << ":" << getLineNum() << ": ";
- else if (getFileName())
- DP << getFileName() << ": ";
+ if (!FileName.empty()) {
+ DP << getFileName();
+ if (LineNum > 0)
+ DP << ":" << getLineNum();
+ DP << ": ";
+ }
DP << getMsg();
}
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=251823&r1=251822&r2=251823&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Nov 2 14:01:13 2015
@@ -1009,9 +1009,8 @@ bool SampleProfileLoader::emitAnnotation
unsigned Total = CoverageTracker.countBodySamples(Samples);
unsigned Coverage = CoverageTracker.computeCoverage(Used, Total);
if (Coverage < SampleProfileCoverage) {
- StringRef Filename = getDISubprogram(&F)->getFilename();
F.getContext().diagnose(DiagnosticInfoSampleProfile(
- Filename.str().c_str(), getFunctionLoc(F),
+ getDISubprogram(&F)->getFilename(), getFunctionLoc(F),
Twine(Used) + " of " + Twine(Total) + " available profile records (" +
Twine(Coverage) + "%) were applied",
DS_Warning));
@@ -1033,7 +1032,7 @@ bool SampleProfileLoader::doInitializati
auto ReaderOrErr = SampleProfileReader::create(Filename, Ctx);
if (std::error_code EC = ReaderOrErr.getError()) {
std::string Msg = "Could not open profile: " + EC.message();
- Ctx.diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));
+ Ctx.diagnose(DiagnosticInfoSampleProfile(Filename, Msg));
return false;
}
Reader = std::move(ReaderOrErr.get());
More information about the llvm-commits
mailing list