aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--support/tools/TableGen/FileParser.y13
-rw-r--r--utils/TableGen/FileParser.y13
2 files changed, 18 insertions, 8 deletions
diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y
index b0161f2317..7a374e178f 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 <iostream>
#include <algorithm>
-#include <string>
-#include <stdio.h>
+#include <cstdio>
#define YYERROR_VERBOSE 1
int yyerror(const char *ErrorMsg);
@@ -181,7 +181,7 @@ static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
%type <Initializer> Value OptValue
%type <FieldList> ValueList ValueListNE
%type <BitList> BitList OptBitList RBitList
-%type <StrVal> Declaration
+%type <StrVal> 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 b0161f2317..7a374e178f 100644
--- a/utils/TableGen/FileParser.y
+++ b/utils/TableGen/FileParser.y
@@ -6,10 +6,10 @@
%{
#include "Record.h"
+#include "Support/StringExtras.h"
#include <iostream>
#include <algorithm>
-#include <string>
-#include <stdio.h>
+#include <cstdio>
#define YYERROR_VERBOSE 1
int yyerror(const char *ErrorMsg);
@@ -181,7 +181,7 @@ static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
%type <Initializer> Value OptValue
%type <FieldList> ValueList ValueListNE
%type <BitList> BitList OptBitList RBitList
-%type <StrVal> Declaration
+%type <StrVal> 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 {