[llvm-commits] [llvm] r89245 - in /llvm/trunk/utils/TableGen: OptParserEmitter.cpp OptParserEmitter.h TableGen.cpp

Chris Lattner clattner at apple.com
Tue Dec 1 14:04:43 PST 2009


On Nov 18, 2009, at 1:29 PM, Daniel Dunbar wrote:

> Author: ddunbar
> Date: Wed Nov 18 15:29:51 2009
> New Revision: 89245
>
> URL: http://llvm.org/viewvc/llvm-project?rev=89245&view=rev
> Log:
> TableGen: Add initial backend for clang Driver's option parsing.

Cool.

> +void OptParserEmitter::run(raw_ostream &OS) {
> +  // Get the option groups and options.
> +  const std::vector<Record*> &Groups =
> +    Records.getAllDerivedDefinitions("OptionGroup");
> +  std::vector<Record*> Opts =  
> Records.getAllDerivedDefinitions("Option");
> +
> +  if (GenDefs) {
> +    OS << "\
> +//=== TableGen'erated File - Option Parsing Definitions ---------*-  
> C++ -*-===//\n \

Please use TableGenBackend::EmitSourceFileHeader instead of  
duplicating it.

One thing I've learned in my time hacking tblgen is that it is  
probably best to emit one .inc file for a given purpose, instead of  
emitting one for the ".h" and one for the ".cpp".  If you emit  
something like:

#ifdef GET_HEADER_CODE
...
#endif

#ifdef GET_FILE_CODE
...
#endif

then #include it into the right contexts with the right #defines set.

-Chris




More information about the llvm-commits mailing list