From: Chris Lattner Date: Wed, 30 Jul 2003 04:26:44 +0000 (+0000) Subject: Allow specification of anonymous definitions X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=fc06bf0eaabb68449aaa699c4649799cd31fb5db;p=oota-llvm.git Allow specification of anonymous definitions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7408 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y index b0161f23175..7a374e178fd 100644 --- a/support/tools/TableGen/FileParser.y +++ b/support/tools/TableGen/FileParser.y @@ -6,10 +6,10 @@ %{ #include "Record.h" +#include "Support/StringExtras.h" #include #include -#include -#include +#include #define YYERROR_VERBOSE 1 int yyerror(const char *ErrorMsg); @@ -181,7 +181,7 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { %type Value OptValue %type ValueList ValueListNE %type BitList OptBitList RBitList -%type Declaration +%type Declaration OptID %start File %% @@ -398,7 +398,12 @@ DeclListNE : Declaration { TemplateArgList : '<' DeclListNE '>' {}; OptTemplateArgList : /*empty*/ | TemplateArgList; -ObjectBody : ID { +OptID : ID { $$ = $1; } | /*empty*/ { $$ = new std::string(); }; + +ObjectBody : OptID { + static unsigned AnonCounter = 0; + if ($1->empty()) + *$1 = "anonymous."+utostr(AnonCounter++); CurRec = new Record(*$1); delete $1; } OptTemplateArgList ClassList { diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index b0161f23175..7a374e178fd 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -6,10 +6,10 @@ %{ #include "Record.h" +#include "Support/StringExtras.h" #include #include -#include -#include +#include #define YYERROR_VERBOSE 1 int yyerror(const char *ErrorMsg); @@ -181,7 +181,7 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { %type Value OptValue %type ValueList ValueListNE %type BitList OptBitList RBitList -%type Declaration +%type Declaration OptID %start File %% @@ -398,7 +398,12 @@ DeclListNE : Declaration { TemplateArgList : '<' DeclListNE '>' {}; OptTemplateArgList : /*empty*/ | TemplateArgList; -ObjectBody : ID { +OptID : ID { $$ = $1; } | /*empty*/ { $$ = new std::string(); }; + +ObjectBody : OptID { + static unsigned AnonCounter = 0; + if ($1->empty()) + *$1 = "anonymous."+utostr(AnonCounter++); CurRec = new Record(*$1); delete $1; } OptTemplateArgList ClassList {