[PATCH] D85180: [YAMLTraits] Fix mapping <none> value that followed by comments.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 01:45:44 PDT 2020


grimar added inline comments.


================
Comment at: llvm/include/llvm/Support/YAMLTraits.h:1631-1632
     if (!outputting())
       if (auto *Node = dyn_cast<ScalarNode>(((Input *)this)->getCurrentNode()))
-        IsNone = Node->getRawValue() == "<none>";
+        IsNone = Node->getRawValue().trim() == "<none>";
 
----------------
Higuoxing wrote:
> Another approach would be using `getValue(SmallVectorImpl<char> &Storage)`.
> 
> ```
>    /// Gets the value of this node as a StringRef.
>    ///
>    /// \param Storage is used to store the content of the returned StringRef iff
>    ///        it requires any modification from how it appeared in the source.
>    ///        This happens with escaped characters and multi-line literals.
>    StringRef getValue(SmallVectorImpl<char> &Storage) const;
> ```
> 
> ```
> Flags: [[FLAGS='<none>']] can also be correctly parsed.
> ```
I'd probably just stop on on `rtrim(` `)` as it does exactly what we need here.

`ScalarNode::getValue(SmallVectorImpl<char> &Storage)` also handles single and double quotes,
what doesn't seem like something what we want to support.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85180/new/

https://reviews.llvm.org/D85180



More information about the llvm-commits mailing list