[cfe-dev] What is the StringRef equivalent of NULL?

Peter Davies ultratwo at gmail.com
Wed Aug 18 01:39:53 PDT 2010


>If someone believes his code can contain null pointers, the check could be before calling the constructor.
The only exception is a copy constructor.

Consider this:
void foo(const char * bar) { ... }

I can convert it to this:
void foo(llvm::StringRef bar) { /* converted as needed */ ... }

Unless bar can be NULL, in which case I have to add set check too all
the callers (ugh!). To make matters worse, if I miss one, the program
still type-checks.

Peter



More information about the cfe-dev mailing list