[cfe-commits] Patch to remove some code duplication

Nico Weber nicolasweber at gmx.de
Fri Aug 29 10:33:50 PDT 2008


> I'm not sure this patch is a good idea.

Me neither. It's just that every client that wants to support -D  
(nearly every client) needs a copy of that function. Case in point:  
it's currently defined both in clang.cpp and Preprocessor.cpp. I  
thought about adding a PredefineBuffer class, but that seems overkill  
(?).

>  The Preprocessor interface is already really complex, and this  
> method doesn't use the preprocessor at all: it is just a helper  
> method for injecting a string into a vector.  At the least, it  
> should be a static method

The patch adds the function as a "global function", it's not contained  
in any class.

> , but could it be moved somewhere else?

Sure. Where? As Preprocessor uses it, it needs to be in Lex (or  
Basic). None of the headers looks like a good fit. Creating a new  
header just for this again looks like overkill.

Nico



More information about the cfe-commits mailing list