# HG changeset patch # User Shinji KONO # Date 1590895811 -32400 # Node ID df311c476dd5be2618bda9142dcfe9bf496dfd12 # Parent 680fa57a2f2041e6aecbcbae894e1808c064a4d9 CreateIdentifierInfo in ParseCbC (not yet worked) diff -r 680fa57a2f20 -r df311c476dd5 clang/include/clang/Parse/Parser.h --- a/clang/include/clang/Parse/Parser.h Sat May 30 17:44:06 2020 +0900 +++ b/clang/include/clang/Parse/Parser.h Sun May 31 12:30:11 2020 +0900 @@ -2352,6 +2352,7 @@ void CreateRetCS(IdentifierInfo* csName); void Create__CbC_envStruct(SourceLocation Loc, AccessSpecifier AS); IdentifierInfo* CreateIdentifierInfo(const char* Name, SourceLocation Loc); + IdentifierInfo* CreateIdentifierInfo(const char* Name, tok::TokenKind kind, SourceLocation Loc); Decl* Create__CbC_envBody(Decl* TagDecl, DeclSpec::TST T, SourceLocation Loc, const char* Name); ExprResult LookupNameAndBuildExpr(IdentifierInfo *II = 0, bool IsAddressOfOperand = false); ExprResult LookupMemberAndBuildExpr(IdentifierInfo *II, Expr* Base, bool IsArrow); @@ -2365,6 +2366,7 @@ void setTST(DeclSpec *DS = 0, DeclSpec::TST T = DeclSpec::TST_int, IdentifierInfo *Name = 0, DeclSpec::TQ TQ = DeclSpec::TQ_unspecified); void CheckTheSjHeader(); ExprResult IIToExpr(IdentifierInfo *II, tok::TokenKind Kind); + ExprResult AnonToExpr(IdentifierInfo *II, tok::TokenKind Kind); StmtResult CreateComplexStmtRet(IdentifierInfo *II, bool IsAddressOfOperand); ExprResult Prepare__retForGotoWithTheEnvExpr(); ExprResult Prepare__envForGotoWithTheEnvExpr(); diff -r 680fa57a2f20 -r df311c476dd5 clang/lib/Parse/ParseCbC.cpp --- a/clang/lib/Parse/ParseCbC.cpp Sat May 30 17:44:06 2020 +0900 +++ b/clang/lib/Parse/ParseCbC.cpp Sun May 31 12:30:11 2020 +0900 @@ -614,14 +614,15 @@ /// CreateIdentifierInfo - Create IdentifierInfo from char pointer. /// usage : -/// IdentifierInfo *II = CreateIdentifierInfo(IIName, Location); -IdentifierInfo* Parser::CreateIdentifierInfo(const char* Name, SourceLocation Loc) { +/// IdentifierInfo *II = CreateIdentifierInfo(IIName, Kind, Location); + +IdentifierInfo* Parser::CreateIdentifierInfo(const char* Name, tok::TokenKind kind, SourceLocation Loc) { int length = strlen(Name); Token TokenForII; TokenForII.startToken(); TokenForII.setLocation(Loc); TokenForII.setLength(length); - TokenForII.setKind(tok::raw_identifier); + TokenForII.setKind(kind); TokenForII.setRawIdentifierData(Name); IdentifierInfo *II; II = PP.getIdentifierInfo(TokenForII.getRawIdentifier()); @@ -630,6 +631,10 @@ return II; } +IdentifierInfo* Parser::CreateIdentifierInfo(const char* Name, SourceLocation Loc) { + return CreateIdentifierInfo(Name, tok::raw_identifier, Loc); +} + /// CreateUniqueIdentifierInfo - Create unique IdentifierInfo. /// IdentifierInfos have unique name which were created by this function. /// Naming conventions : @@ -645,7 +650,6 @@ return II; } - /// CreateRetCS - Create code segment which is used for continuation with the environment. /// create these codes: /// __code ret(return_type retval, void *env){ @@ -770,7 +774,7 @@ FnStmts.push_back(innerR.get()); ExprResult ljExpr,ljLHS; - ljExpr = IIToExpr(CreateIdentifierInfo("__builtin_longjmp", Loc), tok::l_paren); + ljExpr = AnonToExpr(CreateIdentifierInfo("__builtin_longjmp", tok::annot_non_type, Loc), tok::l_paren); ExprVector ljArgExprs; DeclSpec ljDS(AttrFactory); setTST(&ljDS, DeclSpec::TST_struct, structName); @@ -833,6 +837,18 @@ return getExprAnnotation(IITok); } +ExprResult Parser::AnonToExpr(IdentifierInfo *II, tok::TokenKind Kind){ + SourceLocation Loc = Tok.getLocation(); + Token Next; + Next.setKind(Kind); + ExternalSpace::StatementFilterCCC CCCValidator(Next); + CXXScopeSpec SS; + NamedDecl *ND = getNonTypeAnnotation(Tok); + ExprResult E(Actions.ActOnNameClassifiedAsNonType(getCurScope(), SS, ND, Loc, Tok)); + PP.AnnotateCachedTokens(Tok); + return E; +} + /// CreateComplexStmtRet - Create return value for complex statements. /// /// ({ /* some statements */ @@ -943,7 +959,7 @@ /// If not, include it. void Parser::CheckTheSjHeader(){ SourceLocation Loc = Tok.getLocation(); - LookupResult R(Actions, CreateIdentifierInfo("setjmp", Loc), Loc, Actions.LookupOrdinaryName, Actions.ForVisibleRedeclaration); + LookupResult R(Actions, CreateIdentifierInfo("setjmp", tok::annot_non_type, Loc), Loc, Actions.LookupOrdinaryName, Actions.ForVisibleRedeclaration); if (!Actions.LookupName(R, getCurScope())){ // look up the setjmp if (PP.IncludeHeader(Tok, "setjmp.h")) ConsumeToken();