[PATCH] D57860: [analyzer] Validate checker option names and values

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 07:20:54 PDT 2019


baloghadamsoftware added inline comments.


================
Comment at: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp:325
+  std::string FullOption =
+      (llvm::Twine() + FullName + ":" + OptionName).str();
+
----------------
whisperity wrote:
> baloghadamsoftware wrote:
> > Is this the most efficient way to concatenate `StringRef`s?
> > @baloghadamsoftware 
> > Is this the most efficient way to concatenate `StringRef`s?
> 
> `Twine` is specifically designed for that, yes.
> You can't evade the final "copy", although most likely there'll be a RVO taking place.
> 
> However, the *first* `Twine` could be initialised from the `FullName` variable, as opposed to empty node.
> And you could use single characters as characters, as opposed to strings,  i.e. `(Twine(FullName) + ':' + OptionName).str()`.
The constructor `Twine(const StringRef &Str)` is implicit so `(FullName + ':' + OptionName).str()` results the same and is more readable.


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

https://reviews.llvm.org/D57860





More information about the cfe-commits mailing list