Mercurial > hg > CbC > CbC_llvm
changeset 40:e34ccae0bb26
create if(setjmp) statement automatically.
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 26 Dec 2013 19:56:35 +0900 |
parents | d93fae3b865e |
children | 1d6c745cd57d |
files | tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Parse/ParseDecl.cpp tools/clang/lib/Parse/ParseExpr.cpp tools/clang/lib/Parse/ParseStmt.cpp |
diffstat | 4 files changed, 467 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/include/clang/Parse/Parser.h Thu Dec 19 00:11:02 2013 +0900 +++ b/tools/clang/include/clang/Parse/Parser.h Thu Dec 26 19:56:35 2013 +0900 @@ -1539,6 +1539,8 @@ StmtResult ParseCbCGotoStatement(ParsedAttributesWithRange &Attrs,StmtVector &Stmts); StmtResult Create__returnStmt(); StmtResult CreateReturnAssignmentStmt(); + StmtResult CreateSjForContinuationWithEnv(); + StmtResult CreateSjForContinuationWithEnv2(); #endif StmtResult ParseContinueStatement(); StmtResult ParseBreakStatement();
--- a/tools/clang/lib/Parse/ParseDecl.cpp Thu Dec 19 00:11:02 2013 +0900 +++ b/tools/clang/lib/Parse/ParseDecl.cpp Thu Dec 26 19:56:35 2013 +0900 @@ -6001,7 +6001,7 @@ StructScope.Exit(); Actions.ActOnTagFinishDefinition(getCurScope(), TagDecl,Loc); bool Result; - Result = SDS.SetTypeSpecType(TagType, Loc,Loc.isValid() ? Loc : Loc,PrevSpec, DiagID, TagOrTempResult.get(), Owned); + Result = SDS.SetTypeSpecType(TagType, Loc,Loc.isValid() ? Loc : Loc, PrevSpec, DiagID, TagOrTempResult.get(), Owned); if (Result){ Diag(Loc, DiagID) << PrevSpec; }
--- a/tools/clang/lib/Parse/ParseExpr.cpp Thu Dec 19 00:11:02 2013 +0900 +++ b/tools/clang/lib/Parse/ParseExpr.cpp Thu Dec 26 19:56:35 2013 +0900 @@ -2423,10 +2423,16 @@ } #ifndef noCbC else if (Tok.is(tok::kw___return)){ - StmtResult __returnDeclaration,assginmentStmt; + StmtResult __returnDeclaration,assginmentStmt,setjmpStmt; + __returnDeclaration = Create__returnStmt(); if (__returnDeclaration.isUsable()) Stmtsp->push_back(__returnDeclaration.release()); + + setjmpStmt = CreateSjForContinuationWithEnv2(); + if (setjmpStmt.isUsable()) + Stmtsp->push_back(setjmpStmt.release()); + assginmentStmt = CreateReturnAssignmentStmt(); if (assginmentStmt.isUsable()) Stmtsp->push_back(assginmentStmt.release());
--- a/tools/clang/lib/Parse/ParseStmt.cpp Thu Dec 19 00:11:02 2013 +0900 +++ b/tools/clang/lib/Parse/ParseStmt.cpp Thu Dec 26 19:56:35 2013 +0900 @@ -2916,4 +2916,461 @@ Res = Actions.CreateBuiltinBinOp(Loc, BO_Assign, LHS.take(), RHS.take()); return Actions.ActOnExprStmt(Res); } + +namespace CbCSpace { +class CastExpressionIdValidator : public CorrectionCandidateCallback { + public: + CastExpressionIdValidator(bool AllowTypes, bool AllowNonTypes) + : AllowNonTypes(AllowNonTypes) { + WantTypeSpecifiers = AllowTypes; + } + + virtual bool ValidateCandidate(const TypoCorrection &candidate) { + NamedDecl *ND = candidate.getCorrectionDecl(); + if (!ND) + return candidate.isKeyword(); + + if (isa<TypeDecl>(ND)) + return WantTypeSpecifiers; + return AllowNonTypes; + } + + private: + bool AllowNonTypes; +}; +} + +StmtResult Parser::CreateSjForContinuationWithEnv(){ + SourceLocation Loc = Tok.getLocation(); + StmtResult IfRes; //= ParseStatementOrDeclarationAfterAttributes(Stmts,OnlyStatement, TrailingElseLoc, Attrs); 中へ + ParseScope IfScope(this, Scope::DeclScope | Scope::ControlScope, true/* C99 or CXX */); + ExprResult CondExp; + Decl *CondVar = 0; + //setjmpのIIを作る。 + //&II = *Tok.getIdentifierInfo(); //setjmp + //SourceLocation ILco = ConsumeToken(); // location of the setjmp + IdentifierInfo &setjmpII = *CreateIdentifierInfo("setjmp",6,Loc); + UnqualifiedId setjmpName; + CXXScopeSpec SS; + SourceLocation TemplateKWLoc; + CbCSpace::CastExpressionIdValidator Validator(false,true); + setjmpName.setIdentifier(&setjmpII, Loc); + TemplateArgumentListInfo TemplateArgsBuffer; + DeclarationNameInfo setjmpNameInfo; + const TemplateArgumentListInfo *TemplateArgs; //0x0000000107d0ef10 + Actions.DecomposeUnqualifiedId(setjmpName, TemplateArgsBuffer, setjmpNameInfo, TemplateArgs); + DeclarationName DName = setjmpNameInfo.getName(); + IdentifierInfo *setjmpII_ = DName.getAsIdentifierInfo(); + SourceLocation NameLoc = setjmpNameInfo.getLoc(); + LookupResult setjmpR(Actions, setjmpNameInfo,Actions.LookupOrdinaryName); + Actions.LookupParsedName(setjmpR, getCurScope(), &SS, true); + bool IvarLookupFollowUp = false; + Actions.LookupParsedName(setjmpR, getCurScope(), &SS, !IvarLookupFollowUp); + // sjljのprototype置かなかった時 + NamedDecl *sjljD = Actions.ImplicitlyDefineFunction(NameLoc, *setjmpII_, getCurScope()); + if (sjljD) setjmpR.addDecl(sjljD); + // ここまで + //return BuildDeclarationNameExpr(SS, setjmpR, false); //これがResにはいってarseCastExpressionまでくる。 + CondExp = Actions.BuildDeclarationNameExpr(SS, setjmpR, false); + Expr *ExecConfig = 0; + ExprVector ArgExprs; + // Exprs,&CommaLocs,Data,Args + + // __environmentのIIをつくる。仮に__envIIとしとくか。このへんの作業は関数化したいところ。 + IdentifierInfo &__envII = *CreateIdentifierInfo("__CbC_environment",17,Loc); + UnqualifiedId __envName; + //ScopeSpec,TemplateKWLoc,Validatorは値変わらないから使いまわす。 + __envName.setIdentifier(&__envII,Loc); + TemplateArgumentListInfo __envTemplateArgsBuffer; + DeclarationNameInfo __envNameInfo; + const TemplateArgumentListInfo *__envTemplateArgs; + Actions.DecomposeUnqualifiedId(__envName, __envTemplateArgsBuffer, __envNameInfo, __envTemplateArgs); + // DeclarationName __envDName = __envNameInfo.getName(); + LookupResult __envR(Actions, __envNameInfo,Actions.LookupOrdinaryName); + Actions.LookupParsedName(__envR, getCurScope(), &SS, true); + //return BuildDeclarationNameExpr(SS, __envR, false); //これがResに入って戻る。 + CondExp = Actions.BuildDeclarationNameExpr(SS, __envR, false); + ParsedType ObjectType; + //SourceLocation TemplateKWLoc;使いまわしていいかな。 + UnqualifiedId envName; + IdentifierInfo *envId = CreateIdentifierInfo("env",3,Loc); + envName.setIdentifier(envId,Loc); + Expr *envBase = CondExp.take(); + TemplateArgumentListInfo envTemplateArgsBuffer; + DeclarationNameInfo envNameInfo; + const TemplateArgumentListInfo *envTemplateArgs; + Actions.DecomposeUnqualifiedId(envName, envTemplateArgsBuffer, envNameInfo, envTemplateArgs); + // DeclarationName envDName = envNameInfo.getName(); + bool IsArrow = false; + CondExp = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), envBase); + envBase = CondExp.take(); + LookupResult envR(Actions, envNameInfo, Actions.LookupMemberName); + ExprResult envBaseResult = Actions.Owned(envBase); + CondExp = Actions.LookupMemberExpr(envR, envBaseResult, IsArrow, Loc, SS, 0, envTemplateArgs != 0); + envBase = envBaseResult.take(); + + Sema::ActOnMemberAccessExtraArgs envExtraArgs = {getCurScope(), envName, /*ObjCImpDecl*/0, /*HasTrailingLParen*/ false}; + CondExp = Actions.BuildMemberReferenceExpr(envBase, envBase->getType(), Loc, IsArrow, SS, TemplateKWLoc,0, envR, envTemplateArgs,false, &envExtraArgs); + ArgExprs.push_back(CondExp.release()); + CondExp = Actions.ActOnCallExpr(getCurScope(),CondExp.take(),Loc,ArgExprs,Loc,ExecConfig); + CondExp = Actions.ActOnBooleanCondition(getCurScope(), Loc, CondExp.get()); //????? + + FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get(), Loc)); + ParseScope InnerScope(this, Scope::DeclScope,false); + SourceLocation InnerStatementTrailingElseLoc; + + StmtResult ThenStmt; //thenStmtは多分ifの中身。 + StmtVector innerStmts; + unsigned ScopeFlags = Scope::DeclScope; + ParseScope CompoundScope(this, ScopeFlags); + PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),Tok.getLocation(),"in compound statement ('{}')"); + ExprResult innerReturnR; + // ExprResult innerReturnR(true); + // CastTy = ParsedType(); + DeclSpec CastDS(AttrFactory); + + if (CastDS.getSourceRange().isInvalid()) { + CastDS.SetRangeStart(Loc); + CastDS.SetRangeEnd(Loc); + } + ParsedAttributesWithRange attrs(AttrFactory); + bool isInvalid = false; + const char *PrevSpec = 0; + unsigned DiagID = 0; + isInvalid = CastDS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID); + CastDS.SetRangeEnd(Tok.getLocation()); + isInvalid = false; + //const char *PrevSpec = 0; + DiagID = 0; + CastDS.Finish(Diags, PP); + // unsigned CastSpecs = CastDS.getParsedSpecifiers(); + Declarator CastDeclaratorInfo(CastDS, Declarator::TypeNameContext); + CastDeclaratorInfo.SetRangeEnd(Loc); + DeclSpec pointerDS(AttrFactory); + pointerDS.Finish(Diags, PP); + CastDeclaratorInfo.SetIdentifier(0, Loc); + CastDeclaratorInfo.AddTypeInfo(DeclaratorChunk::getPointer(pointerDS.getTypeQualifiers(), Loc, + pointerDS.getConstSpecLoc(), + pointerDS.getVolatileSpecLoc(), + pointerDS.getRestrictSpecLoc()), + pointerDS.getAttributes(),SourceLocation()); + + IdentifierInfo &__envII__ = *Tok.getIdentifierInfo(); + UnqualifiedId __envName_; + CbCSpace::CastExpressionIdValidator Validator2(true,false); + __envName_.setIdentifier(&__envII__, Loc); + TemplateArgumentListInfo __envTemplateArgsBuffer_; + DeclarationNameInfo __envNameInfo_; + const TemplateArgumentListInfo *__envTemplateArgs_; + Actions.DecomposeUnqualifiedId(__envName_, __envTemplateArgsBuffer_, __envNameInfo_, __envTemplateArgs_); + // DeclarationName __envDName_ = __envNameInfo_.getName(); + // IdentifierInfo *__envII___ = __envDName_.getAsIdentifierInfo(); + LookupResult __envR_(Actions, __envNameInfo_,Actions.LookupOrdinaryName); + Actions.LookupParsedName(__envR_, getCurScope(), &SS, true); + innerReturnR = Actions.BuildDeclarationNameExpr(SS,__envR_, false); + UnqualifiedId ret_pName; + IdentifierInfo *ret_pId = CreateIdentifierInfo("ret_p",5,Loc); + ret_pName.setIdentifier(ret_pId,Loc); + TemplateArgumentListInfo ret_pTemplateArgsBuffer; + DeclarationNameInfo ret_pNameInfo; + const TemplateArgumentListInfo *ret_pTemplateArgs; + Actions.DecomposeUnqualifiedId(ret_pName, ret_pTemplateArgsBuffer, ret_pNameInfo, ret_pTemplateArgs); + // DeclarationName ret_pDName = ret_pNameInfo.getName(); + Expr *ret_pBase = innerReturnR.take(); + innerReturnR = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), ret_pBase); + ret_pBase = innerReturnR.take(); + LookupResult ret_pR(Actions, ret_pNameInfo, Actions.LookupMemberName); + ExprResult ret_pBaseResult = Actions.Owned(ret_pBase); + innerReturnR = Actions.LookupMemberExpr(ret_pR, ret_pBaseResult, IsArrow, Loc, SS, 0, envTemplateArgs != 0); + ret_pBase = ret_pBaseResult.take(); + Sema::ActOnMemberAccessExtraArgs ret_pExtraArgs = {getCurScope(), ret_pName, 0, /*HasTrailingLParen*/ false}; + innerReturnR = Actions.BuildMemberReferenceExpr(ret_pBase, ret_pBase->getType(), Loc, IsArrow, SS, TemplateKWLoc,0, ret_pR, ret_pTemplateArgs,false, &ret_pExtraArgs); + Expr *CastExpr = innerReturnR.take(); + TypeSourceInfo *castTInfo = Actions.GetTypeForDeclaratorCast(CastDeclaratorInfo, CastExpr->getType()); + Actions.checkUnusedDeclAttributes(CastDeclaratorInfo); + // QualType castType = castTInfo->getType(); + // CastTy = CreateParsedType(castType, castTInfo); + // ParenExpr *PE = dyn_cast<ParenExpr>(CastExpr); + // ParenListExpr *PLE = dyn_cast<ParenListExpr>(CastExpr); + innerReturnR = Actions.BuildCStyleCastExpr(Loc, castTInfo, Loc, CastExpr); //ちょい怪しい。 + innerReturnR = Actions.ActOnParenExpr(Loc, Loc, innerReturnR.take()); + innerReturnR = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, innerReturnR.get()); + // innerReturnR = Actions.ActOnReturnStmt(Loc, innerReturnR.take()); + ThenStmt = Actions.ActOnReturnStmt(Loc, innerReturnR.take()); + if (ThenStmt.isUsable()) + innerStmts.push_back(ThenStmt.release()); + ThenStmt = Actions.ActOnCompoundStmt(Loc, Loc,innerStmts, false); + InnerScope.Exit(); + IfScope.Exit(); + StmtResult ElseStmt; + IfRes = Actions.ActOnIfStmt(Loc, FullCondExp, CondVar, ThenStmt.get(),Loc, ElseStmt.get()); //これをStmtsにpush_backする。 + return IfRes; +} + +StmtResult Parser::CreateSjForContinuationWithEnv2(){ + SourceLocation Loc = Tok.getLocation(); + StmtResult IfRes; //= ParseStatementOrDeclarationAfterAttributes(Stmts,OnlyStatement, TrailingElseLoc, Attrs); 中へ + ParseScope IfScope(this, Scope::DeclScope | Scope::ControlScope, true/* C99 or CXX */); + ExprResult CondExp; + Decl *CondVar = 0; + ExprResult Res; + bool NotCastExpr = false; + //setjmpのIIを作る。 + //&II = *Tok.getIdentifierInfo(); //setjmp + //SourceLocation ILco = ConsumeToken(); // location of the setjmp + IdentifierInfo &setjmpII = *CreateIdentifierInfo("setjmp",6,Loc); + UnqualifiedId setjmpName; + CXXScopeSpec SS; + SourceLocation TemplateKWLoc; + CbCSpace::CastExpressionIdValidator Validator(false,true); + setjmpName.setIdentifier(&setjmpII, Loc); + TemplateArgumentListInfo TemplateArgsBuffer; + DeclarationNameInfo setjmpNameInfo; + const TemplateArgumentListInfo *TemplateArgs; //0x0000000107d0ef10 + Actions.DecomposeUnqualifiedId(setjmpName, TemplateArgsBuffer, setjmpNameInfo, TemplateArgs); + DeclarationName DName = setjmpNameInfo.getName(); + IdentifierInfo *setjmpII_ = DName.getAsIdentifierInfo(); + SourceLocation NameLoc = setjmpNameInfo.getLoc(); + LookupResult setjmpR(Actions, setjmpNameInfo,Actions.LookupOrdinaryName); + bool IvarLookupFollowUp = false; + Actions.LookupParsedName(setjmpR, getCurScope(), &SS, !IvarLookupFollowUp); + // sjljのprototype置かなかった時 + if (setjmpII_) { + NamedDecl *sjljD = Actions.ImplicitlyDefineFunction(NameLoc, *setjmpII_, getCurScope()); + if (sjljD) setjmpR.addDecl(sjljD); + } + // ここまで + Res = Actions.BuildDeclarationNameExpr(SS, setjmpR, false); + Expr *ExecConfig = 0; + ExprVector ArgExprs; + // Exprs,&CommaLocs,CodeCompleteCall,(Res.get())Data + ExprResult __envLHSTop; + __envLHSTop = Res; + ExprResult __envExpr = __envLHSTop.get(); + //__envExpr = + ExprResult __envLHS; + //__envLHS = + ExprResult __envRes; + ExprResult __envRes2 = __envExpr; + + // __environmentのIIをつくる。仮に__envIIとしとくか。このへんの作業は関数化したいところ。 + IdentifierInfo &__envII = *CreateIdentifierInfo("__CbC_environment",17,Loc); + UnqualifiedId __envName; + //ScopeSpec,TemplateKWLoc,Validatorは値変わらないから使いまわす。 + __envName.setIdentifier(&__envII,Loc); + TemplateArgumentListInfo __envTemplateArgsBuffer; + DeclarationNameInfo __envNameInfo; + const TemplateArgumentListInfo *__envTemplateArgs; + Actions.DecomposeUnqualifiedId(__envName, __envTemplateArgsBuffer, __envNameInfo, __envTemplateArgs); + DeclarationName __envDName = __envNameInfo.getName(); + IdentifierInfo *__envII_ = __envDName.getAsIdentifierInfo(); + SourceLocation __envNameLoc = __envNameInfo.getLoc(); + LookupResult __envR(Actions, __envNameInfo,Actions.LookupOrdinaryName); + Actions.LookupParsedName(__envR, getCurScope(), &SS, true); + //return BuildDeclarationNameExpr(SS, __envR, false); //これがResに入って戻る。 + __envRes2 = Actions.BuildDeclarationNameExpr(SS, __envR, false); + tok::TokenKind OpKind = tok::period; + ParsedType ObjectType; + bool MayBePseudoDestructor = false; + //SourceLocation TemplateKWLoc;使いまわしていいかな。 + UnqualifiedId envName; + //ParseUnqualifiedId入る。SS,false,true,false,ObjectType,TemplateKWLoc,Result(envId) + IdentifierInfo *envId = CreateIdentifierInfo("env",3,Loc); + envName.setIdentifier(envId,Loc); + //Res (LHS) = + Expr *envBase = __envRes2.take(); + TemplateArgumentListInfo envTemplateArgsBuffer; + DeclarationNameInfo envNameInfo; + const TemplateArgumentListInfo *envTemplateArgs; + Actions.DecomposeUnqualifiedId(envName, envTemplateArgsBuffer, envNameInfo, envTemplateArgs); + DeclarationName envDName = envNameInfo.getName(); + bool IsArrow = false; + NamedDecl *FirstQualifierInScope = 0; //使わなかったら消したい。 + ExprResult envEResult = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), envBase); + envBase = envEResult.take(); + LookupResult envR(Actions, envNameInfo, Actions.LookupMemberName); + ExprResult envBaseResult = Actions.Owned(envBase); + envEResult = Actions.LookupMemberExpr(envR, envBaseResult, IsArrow, Loc, SS, 0, envTemplateArgs != 0); + envBase = envBaseResult.take(); + + Sema::ActOnMemberAccessExtraArgs envExtraArgs = {getCurScope(), envName, /*ObjCImpDecl*/0, /*HasTrailingLParen*/ false}; + envEResult = Actions.BuildMemberReferenceExpr(envBase, envBase->getType(), Loc, IsArrow, SS, TemplateKWLoc,FirstQualifierInScope, envR, envTemplateArgs,false, &envExtraArgs); + //return Result; //これがParsePostfixExpressionSuffixの返す値。 + __envRes2 = envEResult; + // return Res (LHS); + __envRes = __envRes2; // __envRes + // return __envLHS; + __envLHS = __envRes; + ArgExprs.push_back(__envLHS.release()); + __envLHSTop = Actions.ActOnCallExpr(getCurScope(),__envLHSTop.take(),Loc,ArgExprs,Loc,ExecConfig); + // return __envLHS; + Res = __envLHSTop; + // return Res; + CondExp = Res; + // DeclResult = 0; + CondExp = Actions.ActOnBooleanCondition(getCurScope(), Loc, CondExp.get()); //????? + + FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get(), Loc)); + ParseScope InnerScope(this, Scope::DeclScope,false); + SourceLocation ThenStmtLoc = Loc; + SourceLocation InnerStatementTrailingElseLoc; + + //StmtResult ThenStmt(returnしたの); //thenStmtは多分ifの中身。 + //ThenStmt = + + StmtResult StmtRes; + StmtVector innerStmts; + //StmtRes = + StmtResult StmtRes2; + //StmtRes2= + unsigned ScopeFlags = Scope::DeclScope; + ParseScope CompoundScope(this, ScopeFlags); + //return + PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),Tok.getLocation(),"in compound statement ('{}')"); + Sema::FPContractStateRAII SaveFPContractState(Actions); + Sema::CompoundScopeRAII CompoundScope_(Actions); + StmtVector innerStmts2; + StmtResult innerR; + //innerR = + StmtResult innerRes; + //innerRes = + StmtResult innerRes2; + //innerRes2 = + ExprResult innerReturnR; + ExprResult innerLHS; + ParenParseOption ParenExprType = CastExpr; + ExprResult innerLHS2; + ExprResult innerRes3; + // bool NotCastExpr; + ExprResult innerRes4; + NotCastExpr = false; + ExprResult innerRes5; + ExprResult innerRes6; + // ParenParseOption ParenExprType = CastExpr; + ParsedType CastTy; + ExprResult returnResult(true); + CastTy = ParsedType(); + bool BridgeCast = false; + //returnResult = + ExprResult innerLHS3; + ExprResult innerLHS4; + bool NotCastExpr2; + ExprResult innerRes7; + ExprResult innerRes8; + NotCastExpr2 = false; + ParenParseOption ParenExprType2 = CastExpr; + ParsedType CastTy2; + ExprResult CastResult(true); + CastTy2 = ParsedType(); + bool BridgeCast2 = false; + DeclSpec CastDS(AttrFactory); + + if (CastDS.getSourceRange().isInvalid()) { + CastDS.SetRangeStart(Loc); + CastDS.SetRangeEnd(Loc); + } + bool EnteringContext = false; + bool AttrsLastTime = false; + ParsedAttributesWithRange attrs(AttrFactory); + bool isInvalid = false; + const char *PrevSpec = 0; + unsigned DiagID = 0; + isInvalid = CastDS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID); + CastDS.SetRangeEnd(Tok.getLocation()); + isInvalid = false; + //const char *PrevSpec = 0; + DiagID = 0; + ProhibitAttributes(attrs); + CastDS.Finish(Diags, PP); + unsigned CastSpecs = CastDS.getParsedSpecifiers(); + + Declarator CastDeclaratorInfo(CastDS, Declarator::TypeNameContext); + CastDeclaratorInfo.SetRangeEnd(Loc); + DeclSpec pointerDS(AttrFactory); + pointerDS.Finish(Diags, PP); + CastDeclaratorInfo.ExtendWithDeclSpec(pointerDS);//いらないかも + DeclaratorScopeObj DeclScopeObj(*this, CastDeclaratorInfo.getCXXScopeSpec()); + CastDeclaratorInfo.SetIdentifier(0, Loc); + CastDeclaratorInfo.AddTypeInfo(DeclaratorChunk::getPointer(pointerDS.getTypeQualifiers(), Loc, + pointerDS.getConstSpecLoc(), + pointerDS.getVolatileSpecLoc(), + pointerDS.getRestrictSpecLoc()), + pointerDS.getAttributes(),SourceLocation()); + bool NotCastExpr3; + ExprResult castRes; + ExprResult castRes2; + NotCastExpr3 = false; + IdentifierInfo &__envII__ = *CreateIdentifierInfo("__CbC_environment",17,Loc); + UnqualifiedId __envName_; + CXXScopeSpec SS2; + CbCSpace::CastExpressionIdValidator Validator2(true,false); + __envName_.setIdentifier(&__envII__, Loc); + TemplateArgumentListInfo __envTemplateArgsBuffer_; + DeclarationNameInfo __envNameInfo_; + const TemplateArgumentListInfo *__envTemplateArgs_; + Actions.DecomposeUnqualifiedId(__envName_, __envTemplateArgsBuffer_, __envNameInfo_, __envTemplateArgs_); + DeclarationName __envDName_ = __envNameInfo_.getName(); + IdentifierInfo *__envII___ = __envDName_.getAsIdentifierInfo(); + SourceLocation __envNameLoc_ = __envNameInfo_.getLoc(); + LookupResult __envR_(Actions, __envNameInfo_,Actions.LookupOrdinaryName); + Actions.LookupParsedName(__envR_, getCurScope(), &SS2, true); + castRes2 = Actions.BuildDeclarationNameExpr(SS2,__envR_, false); + ParsedType ObjectType2; + UnqualifiedId ret_pName; + CXXScopeSpec SS3; + IdentifierInfo *ret_pId = CreateIdentifierInfo("ret_p",5,Loc); + ret_pName.setIdentifier(ret_pId,Loc); + Expr *ret_pBase = castRes2.take(); + TemplateArgumentListInfo ret_pTemplateArgsBuffer; + DeclarationNameInfo ret_pNameInfo; + const TemplateArgumentListInfo *ret_pTemplateArgs; + Actions.DecomposeUnqualifiedId(ret_pName, ret_pTemplateArgsBuffer, ret_pNameInfo, ret_pTemplateArgs); + DeclarationName ret_pDName = ret_pNameInfo.getName(); + // bool IsArrow = false; + NamedDecl *FirstQualifierInScope_ = 0; //使わなかったら消したい。 + ExprResult ret_pResult = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), ret_pBase); + ret_pBase = ret_pResult.take(); + LookupResult ret_pR(Actions, ret_pNameInfo, Actions.LookupMemberName); + ExprResult ret_pBaseResult = Actions.Owned(ret_pBase); + ret_pResult = Actions.LookupMemberExpr(ret_pR, ret_pBaseResult, IsArrow, Loc, SS3, 0, ret_pTemplateArgs != 0); + ret_pBase = ret_pBaseResult.take(); + Sema::ActOnMemberAccessExtraArgs ret_pExtraArgs = {getCurScope(), ret_pName, 0, /*HasTrailingLParen*/ false}; + ret_pResult = Actions.BuildMemberReferenceExpr(ret_pBase, ret_pBase->getType(), Loc, IsArrow, SS3, TemplateKWLoc,FirstQualifierInScope_, ret_pR, ret_pTemplateArgs,false, &ret_pExtraArgs); + // return ret_pResult; + castRes2 = ret_pResult; + castRes = castRes2; + CastResult = castRes; + Expr *CastExpr = CastResult.take(); + TypeSourceInfo *castTInfo = Actions.GetTypeForDeclaratorCast(CastDeclaratorInfo, CastExpr->getType()); + Actions.checkUnusedDeclAttributes(CastDeclaratorInfo); + QualType castType = castTInfo->getType(); + CastTy2 = Actions.CreateParsedType(castType, castTInfo); + bool isVectorLiteral = false; + ParenExpr *PE = dyn_cast<ParenExpr>(CastExpr); + ParenListExpr *PLE = dyn_cast<ParenListExpr>(CastExpr); + //return + CastResult = Actions.BuildCStyleCastExpr(Loc, castTInfo, Loc, CastExpr); //ちょい怪しい。 + innerRes8 = CastResult; + innerRes7 = innerRes8; + returnResult = innerRes7; + ParenExprType = SimpleExpr; + returnResult = Actions.ActOnParenExpr(Loc, Loc, returnResult.take()); + innerRes6 = returnResult; + innerRes4 = innerRes6; + innerRes4 = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, innerRes4.get()); + innerLHS2 = innerRes4; + innerReturnR = innerLHS2; + innerRes2 = Actions.ActOnReturnStmt(Loc, innerReturnR.take()); + innerR = innerRes2; + if (innerR.isUsable()) + innerStmts2.push_back(innerR.release()); + StmtRes2 = Actions.ActOnCompoundStmt(Loc, Loc,innerStmts2, false); + StmtResult ThenStmt(StmtRes2); + InnerScope.Exit(); + IfScope.Exit(); + StmtResult ElseStmt; + IfRes = Actions.ActOnIfStmt(Loc, FullCondExp, CondVar, ThenStmt.get(),Loc, ElseStmt.get()); //これをStmtsにpush_backする。 + return IfRes; +} + #endif