[llvm] r312277 - [NFC] Change Key in Argument to a std::string
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 31 13:47:37 PDT 2017
Author: paquette
Date: Thu Aug 31 13:47:37 2017
New Revision: 312277
URL: http://llvm.org/viewvc/llvm-project?rev=312277&view=rev
Log:
[NFC] Change Key in Argument to a std::string
Before, Key was a StringRef to avoid unnecessary copies. This commit changes
that to a std::string.
This was okay previously because when people called emit for remarks before,
they would create the remark *within* the call to emit. However, if you build
the remark up and call emit *afterward*, it's possible to end up freeing the
memory assigned to the StringRef before the call to emit.
This caused a test failure with https://reviews.llvm.org/D37085 on Linux.
Since building remarks before a call to emit is a valid use-case, it makes
sense to replace this with a std::string.
Modified:
llvm/trunk/include/llvm/IR/DiagnosticInfo.h
Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=312277&r1=312276&r2=312277&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Thu Aug 31 13:47:37 2017
@@ -188,17 +188,13 @@ private:
public:
/// \p The function that is concerned by this stack size diagnostic.
/// \p The computed stack size.
- DiagnosticInfoResourceLimit(const Function &Fn,
- const char *ResourceName,
+ DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName,
uint64_t ResourceSize,
DiagnosticSeverity Severity = DS_Warning,
DiagnosticKind Kind = DK_ResourceLimit,
uint64_t ResourceLimit = 0)
- : DiagnosticInfo(Kind, Severity),
- Fn(Fn),
- ResourceName(ResourceName),
- ResourceSize(ResourceSize),
- ResourceLimit(ResourceLimit) {}
+ : DiagnosticInfo(Kind, Severity), Fn(Fn), ResourceName(ResourceName),
+ ResourceSize(ResourceSize), ResourceLimit(ResourceLimit) {}
const Function &getFunction() const { return Fn; }
const char *getResourceName() const { return ResourceName; }
@@ -209,19 +205,17 @@ public:
void print(DiagnosticPrinter &DP) const override;
static bool classof(const DiagnosticInfo *DI) {
- return DI->getKind() == DK_ResourceLimit ||
- DI->getKind() == DK_StackSize;
+ return DI->getKind() == DK_ResourceLimit || DI->getKind() == DK_StackSize;
}
};
class DiagnosticInfoStackSize : public DiagnosticInfoResourceLimit {
public:
- DiagnosticInfoStackSize(const Function &Fn,
- uint64_t StackSize,
+ DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize,
DiagnosticSeverity Severity = DS_Warning,
uint64_t StackLimit = 0)
- : DiagnosticInfoResourceLimit(Fn, "stack size", StackSize,
- Severity, DK_StackSize, StackLimit) {}
+ : DiagnosticInfoResourceLimit(Fn, "stack size", StackSize, Severity,
+ DK_StackSize, StackLimit) {}
uint64_t getStackSize() const { return getResourceSize(); }
uint64_t getStackLimit() const { return getResourceLimit(); }
@@ -244,7 +238,7 @@ public:
/// \p The module that is concerned by this debug metadata version diagnostic.
/// \p The actual metadata version.
DiagnosticInfoDebugMetadataVersion(const Module &M, unsigned MetadataVersion,
- DiagnosticSeverity Severity = DS_Warning)
+ DiagnosticSeverity Severity = DS_Warning)
: DiagnosticInfo(DK_DebugMetadataVersion, Severity), M(M),
MetadataVersion(MetadataVersion) {}
@@ -411,7 +405,7 @@ public:
/// \brief Used in the streaming interface as the general argument type. It
/// internally converts everything into a key-value pair.
struct Argument {
- StringRef Key;
+ std::string Key;
std::string Val;
// If set, the debug location corresponding to the value.
DiagnosticLocation Loc;
More information about the llvm-commits
mailing list