[PATCH] StringRef-izing some of clang-check

David Blaikie dblaikie at gmail.com
Sun Apr 21 20:35:06 PDT 2013

On Sun, Apr 21, 2013 at 8:16 PM, Christopher Jones
<chrisjones.lambda at gmail.com> wrote:
> Hi all,
> This patch is pretty small and probably doesn't have much impact, but it's
> my first one and I mainly want to make sure I have the workflow down.  I'd
> appreciate any criticism.
> This is a first attempt at the StringRef-ization open project.  If anyone
> has any recommendations on which parts of the interface would be most useful
> to start on, I'd appreciate it.

There's probably more value in changing parameter types rather than
return types.

(& I'd say there's probably more immediate value in ArrayRef-ization
than StringRef-ization, maybe - especially in call sites that are
passing magic constant "array size" parameters (some of these were
just recently fixed in LLVM, for example), but for StringRefization,
the value is in updating API/usage that may currently accept a "const
std::string&" but never actually needs a string object (because both
the caller passes in non-std::strings (string literals, for example)
and the implementation doesn't use complex std::string operations))

> Otherwise, I'll do something of a random
> walk through the code.

Some of the code you've updated will leade to dangling StringRefs -
several of the RewriteFilename functions return local variables - they
will go out of scope at the end of the function & the caller will be
left with a dangling StringRef. That's no good.

> Thanks,
> Chris
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

More information about the cfe-commits mailing list