@@ -146,11 +146,12 @@ class DiagnosticInfoGeneric : public DiagnosticInfo {
146146  // / \p MsgStr is the message to be reported to the frontend.
147147  // / This class does not copy \p MsgStr, therefore the reference must be valid
148148  // / for the whole life time of the Diagnostic.
149-   DiagnosticInfoGeneric (const  Twine &MsgStr,
149+   DiagnosticInfoGeneric (const  Twine &MsgStr LLVM_LIFETIME_BOUND ,
150150                        DiagnosticSeverity Severity = DS_Error)
151151      : DiagnosticInfo(DK_Generic, Severity), MsgStr(MsgStr) {}
152152
153-   DiagnosticInfoGeneric (const  Instruction *I, const  Twine &ErrMsg,
153+   DiagnosticInfoGeneric (const  Instruction *I,
154+                         const  Twine &ErrMsg LLVM_LIFETIME_BOUND,
154155                        DiagnosticSeverity Severity = DS_Error)
155156      : DiagnosticInfo(DK_Generic, Severity), MsgStr(ErrMsg), Inst(I) {}
156157
@@ -181,15 +182,17 @@ class DiagnosticInfoInlineAsm : public DiagnosticInfo {
181182  // / \p MsgStr gives the message.
182183  // / This class does not copy \p MsgStr, therefore the reference must be valid
183184  // / for the whole life time of the Diagnostic.
184-   DiagnosticInfoInlineAsm (uint64_t  LocCookie, const  Twine &MsgStr,
185+   DiagnosticInfoInlineAsm (uint64_t  LocCookie,
186+                           const  Twine &MsgStr LLVM_LIFETIME_BOUND,
185187                          DiagnosticSeverity Severity = DS_Error);
186188
187189  // / \p Instr gives the original instruction that triggered the diagnostic.
188190  // / \p MsgStr gives the message.
189191  // / This class does not copy \p MsgStr, therefore the reference must be valid
190192  // / for the whole life time of the Diagnostic.
191193  // / Same for \p I.
192-   DiagnosticInfoInlineAsm (const  Instruction &I, const  Twine &MsgStr,
194+   DiagnosticInfoInlineAsm (const  Instruction &I,
195+                           const  Twine &MsgStr LLVM_LIFETIME_BOUND,
193196                          DiagnosticSeverity Severity = DS_Error);
194197
195198  uint64_t  getLocCookie () const  { return  LocCookie; }
@@ -258,15 +261,16 @@ class DiagnosticInfoIgnoringInvalidDebugMetadata : public DiagnosticInfo {
258261class  DiagnosticInfoSampleProfile  : public  DiagnosticInfo  {
259262public: 
260263  DiagnosticInfoSampleProfile (StringRef FileName, unsigned  LineNum,
261-                               const  Twine &Msg,
264+                               const  Twine &Msg LLVM_LIFETIME_BOUND ,
262265                              DiagnosticSeverity Severity = DS_Error)
263266      : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
264267        LineNum (LineNum), Msg(Msg) {}
265-   DiagnosticInfoSampleProfile (StringRef FileName, const  Twine &Msg,
268+   DiagnosticInfoSampleProfile (StringRef FileName,
269+                               const  Twine &Msg LLVM_LIFETIME_BOUND,
266270                              DiagnosticSeverity Severity = DS_Error)
267271      : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
268272        Msg(Msg) {}
269-   DiagnosticInfoSampleProfile (const  Twine &Msg,
273+   DiagnosticInfoSampleProfile (const  Twine &Msg LLVM_LIFETIME_BOUND ,
270274                              DiagnosticSeverity Severity = DS_Error)
271275      : DiagnosticInfo(DK_SampleProfile, Severity), Msg(Msg) {}
272276
@@ -296,7 +300,8 @@ class DiagnosticInfoSampleProfile : public DiagnosticInfo {
296300// / Diagnostic information for the PGO profiler.
297301class  DiagnosticInfoPGOProfile  : public  DiagnosticInfo  {
298302public: 
299-   DiagnosticInfoPGOProfile (const  char  *FileName, const  Twine &Msg,
303+   DiagnosticInfoPGOProfile (const  char  *FileName,
304+                            const  Twine &Msg LLVM_LIFETIME_BOUND,
300305                           DiagnosticSeverity Severity = DS_Error)
301306      : DiagnosticInfo(DK_PGOProfile, Severity), FileName(FileName), Msg(Msg) {}
302307
@@ -364,7 +369,7 @@ class DiagnosticInfoWithLocationBase : public DiagnosticInfo {
364369
365370  // / Return the absolute path tot the file.
366371  std::string getAbsolutePath () const ;
367-    
372+ 
368373  const  Function &getFunction () const  { return  Fn; }
369374  DiagnosticLocation getLocation () const  { return  Loc; }
370375
@@ -1062,7 +1067,7 @@ class DiagnosticInfoOptimizationFailure : public DiagnosticInfoIROptimization {
10621067// / Diagnostic information for unsupported feature in backend.
10631068class  DiagnosticInfoUnsupported  : public  DiagnosticInfoWithLocationBase  {
10641069private: 
1065-   Twine Msg;
1070+   const   Twine & Msg;
10661071
10671072public: 
10681073  // / \p Fn is the function where the diagnostic is being emitted. \p Loc is
@@ -1072,7 +1077,7 @@ class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase {
10721077  // / copy this message, so this reference must be valid for the whole life time
10731078  // / of the diagnostic.
10741079  DiagnosticInfoUnsupported (
1075-       const  Function &Fn, const  Twine &Msg,
1080+       const  Function &Fn, const  Twine &Msg LLVM_LIFETIME_BOUND ,
10761081      const  DiagnosticLocation &Loc = DiagnosticLocation(),
10771082      DiagnosticSeverity Severity = DS_Error)
10781083      : DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
@@ -1090,7 +1095,8 @@ class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase {
10901095// / Diagnostic information for MisExpect analysis.
10911096class  DiagnosticInfoMisExpect  : public  DiagnosticInfoWithLocationBase  {
10921097public: 
1093-   DiagnosticInfoMisExpect (const  Instruction *Inst, const  Twine &Msg);
1098+   DiagnosticInfoMisExpect (const  Instruction *Inst,
1099+                           const  Twine &Msg LLVM_LIFETIME_BOUND);
10941100
10951101  // / \see DiagnosticInfo::print.
10961102  void  print (DiagnosticPrinter &DP) const  override ;
0 commit comments