[llvm] r305405 - Specified ReportError as noreturn friendly to old compilers.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 12:02:12 PDT 2017


Removed the macro because it seemed a bit unnecessary (nice to have, but
unnecessary given the gotchas around macros, etc) in r305405.

On Wed, Jun 14, 2017 at 10:33 AM Galina Kistanova via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: gkistanova
> Date: Wed Jun 14 12:32:53 2017
> New Revision: 305405
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305405&view=rev
> Log:
> Specified ReportError as noreturn friendly to old compilers.
>
> Modified:
>     llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp?rev=305405&r1=305404&r2=305405&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp Wed Jun 14 12:32:53
> 2017
> @@ -514,6 +514,20 @@ static uint64_t readPointer(const DataEx
>    }
>  }
>
> +// This is a workaround for old compilers which do not allow
> +// noreturn attribute usage in lambdas. Once the support for those
> +// compilers are phased out, we can remove this and return back to
> +// a ReportError lambda: [StartOffset](const char *ErrorMsg).
> +#define ReportError(ErrorMsg) ReportErrorImpl(StartOffset,ErrorMsg)
> +static void LLVM_ATTRIBUTE_NORETURN
> +ReportErrorImpl(uint32_t StartOffset, const char *ErrorMsg) {
> +      std::string Str;
> +      raw_string_ostream OS(Str);
> +      OS << format(ErrorMsg, StartOffset);
> +      OS.flush();
> +      report_fatal_error(Str);
> +}
> +
>  void DWARFDebugFrame::parse(DataExtractor Data) {
>    uint32_t Offset = 0;
>    DenseMap<uint32_t, CIE *> CIEs;
> @@ -521,14 +535,6 @@ void DWARFDebugFrame::parse(DataExtracto
>    while (Data.isValidOffset(Offset)) {
>      uint32_t StartOffset = Offset;
>
> -    auto ReportError = [StartOffset](const char *ErrorMsg) {
> -      std::string Str;
> -      raw_string_ostream OS(Str);
> -      OS << format(ErrorMsg, StartOffset);
> -      OS.flush();
> -      report_fatal_error(Str);
> -    };
> -
>      bool IsDWARF64 = false;
>      uint64_t Length = Data.getU32(&Offset);
>      uint64_t Id;
> @@ -585,7 +591,6 @@ void DWARFDebugFrame::parse(DataExtracto
>            switch (AugmentationString[i]) {
>              default:
>                ReportError("Unknown augmentation character in entry at
> %lx");
> -              llvm_unreachable("ReportError should not return.");
>              case 'L':
>                LSDAPointerEncoding = Data.getU8(&Offset);
>                break;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170619/c70993c8/attachment.html>


More information about the llvm-commits mailing list