[cfe-dev] Refactoring internal CXString APIs

Csaba Raduly rcsaba at gmail.com
Mon Jan 28 01:01:49 PST 2013


On Sun, Jan 27, 2013 at 10:59 PM, Dmitri Gribenko  wrote:
> Hello Argyrios and cfe-dev,
>
> In order to fix the bug discussed in "createCXString reads one past
> end byte", we need change CXString internal APIs: when creating a
> CXString from a StringRef, we also need a TU, to find the StringPool.
>
> I see this as a good opportunity to refactor internal CXString APIs.
> What I want to do is to change current createCXString to be more
> intuitive.
(snip)
> (3) libclang code is full of comments explaining the meaning of the
> second parameter to createCXString:
>
> createCXString(Cmd->CommandLine[Arg].c_str(), /*DupString=*/false)
>
> If the API needs that, we should consider changing the API :)  And we
> easily can:

This just proves that boolean parameters make the code harder to read.
Furthermore:

http://martinfowler.com/bliki/FlagArgument.html
http://silkandspinach.net/2004/07/15/avoid-boolean-parameters/
http://blog.ometer.com/2011/01/20/boolean-parameters-are-wrong/


Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds



More information about the cfe-dev mailing list