[PATCH] D156978: [symbolizer][NFC] Move file argument parsing into separate function
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 4 16:38:46 PDT 2023
ikudrin added inline comments.
================
Comment at: llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp:138
+static std::pair<std::string, StringRef>
+getSpaceDelimitedWord(StringRef Source) {
----------------
sepavloff wrote:
> ikudrin wrote:
> > The function returns a part of its input, so there is no need to allocate new memory for that, `StringRef` is enough. It should be the responsibility of the caller to copy the result if necessary.
> >
> > Also, the function can update `Source` if it is passed as a reference, which would simplify the code even more.
> Indeed, `StringRef` can be used here.
>
> > the function can update Source if it is passed as a reference
>
> Passing by reference can bring new issues. In this case it prevents from using constructs like `getSpaceDelimitedWord(Source.ltrim())`.
Are there any reasons not to do the trimming within this function?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156978/new/
https://reviews.llvm.org/D156978
More information about the llvm-commits
mailing list