[PATCH] D86998: [llvm-dwarfdump] Warn user when it encounters no null terminated strings.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 03:29:56 PDT 2020
Higuoxing added inline comments.
================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:533
+ Error Err = Error::success();
+ cantFail(std::move(Err));
+
----------------
Higuoxing wrote:
> jhenderson wrote:
> > Higuoxing wrote:
> > > MaskRay wrote:
> > > > `operator bool` sets the checked state if Error is in a success state.
> > > >
> > > > So you can just run: `(void)!Err`
> > > >
> > > > If you want to ensure an Error in a success state is also checked (not in this case), `ErrorAsOutParameter ...(&Err)`
> > > Thanks. Actually I'm not sure about it. I didn't find anything about creating a checked error in [LLVM Programmer's manual](https://llvm.org/docs/ProgrammersManual.html).
> > >
> > > I usually do it using
> > >
> > > ```
> > > Error Err = Error::success();
> > > cantFail(std::move(Err));
> > > ```
> > >
> > > Can we record it in programmer's manual?
> > Do you actually need this here? It seems to me a `cantFail(std::move(Err));` after the loop might be more appropriate. The `getCStr` function handles the `Error` that gets passed in, so that it doesn't need checking beforehand.
> I'm not sure whether to put it after the loop or put it after `Error::success()` but I'm sure we need it. If we remove the `cantFail(std::move(Err))` or `(void)!Err`, it will crash due to an unhandled error when parsing the following object file.
>
> ```
> ...
> Sections:
> - Name: .debug_str
> Type: SHT_PROGBITS
> Size: 0
> ```
Sorry, I missed your point. We can remove the `cantFail(std::move(Err))`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86998/new/
https://reviews.llvm.org/D86998
More information about the llvm-commits
mailing list