Mercurial > hg > CbC > CbC_llvm
changeset 41:1d6c745cd57d
move some methods to ParseCbC.cpp which were written by me.
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 26 Dec 2013 22:29:30 +0900 |
parents | e34ccae0bb26 |
children | 3e178477409f |
files | tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Parse/ParseCbC.cpp tools/clang/lib/Parse/ParseExpr.cpp tools/clang/lib/Parse/ParseStmt.cpp |
diffstat | 4 files changed, 353 insertions(+), 583 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/include/clang/Parse/Parser.h Thu Dec 26 19:56:35 2013 +0900 +++ b/tools/clang/include/clang/Parse/Parser.h Thu Dec 26 22:29:30 2013 +0900 @@ -1540,7 +1540,6 @@ StmtResult Create__returnStmt(); StmtResult CreateReturnAssignmentStmt(); StmtResult CreateSjForContinuationWithEnv(); - StmtResult CreateSjForContinuationWithEnv2(); #endif StmtResult ParseContinueStatement(); StmtResult ParseBreakStatement();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/clang/lib/Parse/ParseCbC.cpp Thu Dec 26 22:29:30 2013 +0900 @@ -0,0 +1,352 @@ +#include "clang/Parse/Parser.h" +#include "RAIIObjectsForParser.h" +#include "clang/AST/ASTContext.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/PrettyStackTrace.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Basic/TargetInfo.h" +#include "clang/Sema/DeclSpec.h" +#include "clang/Sema/PrettyDeclStackTrace.h" +#include "clang/Sema/Scope.h" +#include "clang/Sema/TypoCorrection.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/MC/MCParser/MCAsmParser.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MCTargetAsmParser.h" +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" +#include "llvm/ADT/SmallString.h" +#include "clang/Sema/Lookup.h" +using namespace clang; + +namespace ExternalSpace { +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; +}; + +class StatementFilterCCC : public CorrectionCandidateCallback { +public: + StatementFilterCCC(Token nextTok) : NextToken(nextTok) { + WantTypeSpecifiers = nextTok.is(tok::l_paren) || nextTok.is(tok::less) || + nextTok.is(tok::identifier) || nextTok.is(tok::star) || + nextTok.is(tok::amp) || nextTok.is(tok::l_square); + WantExpressionKeywords = nextTok.is(tok::l_paren) || + nextTok.is(tok::identifier) || + nextTok.is(tok::arrow) || nextTok.is(tok::period); + WantRemainingKeywords = nextTok.is(tok::l_paren) || nextTok.is(tok::semi) || + nextTok.is(tok::identifier) || + nextTok.is(tok::l_brace); + WantCXXNamedCasts = false; + } + + virtual bool ValidateCandidate(const TypoCorrection &candidate) { + if (FieldDecl *FD = candidate.getCorrectionDeclAs<FieldDecl>()) + return !candidate.getCorrectionSpecifier() || isa<ObjCIvarDecl>(FD); + if (NextToken.is(tok::equal)) + return candidate.getCorrectionDeclAs<VarDecl>(); + if (NextToken.is(tok::period) && + candidate.getCorrectionDeclAs<NamespaceDecl>()) + return false; + return CorrectionCandidateCallback::ValidateCandidate(candidate); + } + +private: + Token NextToken; +}; +} + +StmtResult Parser::Create__returnStmt(){ + SourceLocation Loc = Tok.getLocation(); + unsigned Context = Declarator::BlockContext; + ParsedAttributesWithRange __retAttrs(AttrFactory); + SourceLocation DeclStart = Loc, DeclEnd = Loc; + ParsingDeclSpec PDS(*this); + DeclSpec &__retDS = PDS; + const char *PrevSpec = 0; + unsigned DiagID = 0; + bool isInvalid = false; + if (__retDS.getSourceRange().isInvalid()) { + __retDS.SetRangeStart(Loc); + __retDS.SetRangeEnd(Loc); + } + isInvalid = __retDS.SetTypeSpecType(DeclSpec::TST___code, Loc, PrevSpec, DiagID); + if (isInvalid) { + assert(PrevSpec && "Method did not return previous specifier!"); + assert(DiagID); + if (DiagID == diag::ext_duplicate_declspec) + Diag(Tok, DiagID) + << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation()); + else + Diag(Tok, DiagID) << PrevSpec; + } + __retDS.SetRangeEnd(Loc); + __retDS.Finish(Diags, PP); + ParsingDeclarator D(*this, PDS, static_cast<Declarator::TheContext>(Context)); + D.setEllipsisLoc(SourceLocation()); + bool hadGroupingParens = D.hasGroupingParens(); + D.setGroupingParens(true); + IdentifierInfo* II = CreateIdentifierInfo("__CbC_return",12, Loc); // CreateIdentifierInfo(name,length of the name, SourceLocation); + D.SetRangeEnd(Loc); + DeclSpec DS_(AttrFactory); + + DS_.Finish(Diags, PP); + D.SetIdentifier(II, Loc); + + D.AddTypeInfo(DeclaratorChunk::getPointer(DS_.getTypeQualifiers(), Loc,DS_.getConstSpecLoc(),DS_.getVolatileSpecLoc(), + DS_.getRestrictSpecLoc()),DS_.getAttributes(),SourceLocation()); + D.setGroupingParens(hadGroupingParens); + + + ParseScope PrototypeScope(this,Scope::FunctionPrototypeScope|Scope::DeclScope| + (D.isFunctionDeclaratorAFunctionDeclaration() ? Scope::FunctionDeclarationScope : 0)); + bool HasProto = false; + SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo; + SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc; + DeclSpec DS__(AttrFactory); + bool RefQualifierIsLValueRef = true; + ExceptionSpecificationType ESpecType = EST_None; + SourceRange ESpecRange; + SmallVector<ParsedType, 2> DynamicExceptions; + SmallVector<SourceRange, 2> DynamicExceptionRanges; + ExprResult NoexceptExpr; + ParsedAttributes FnAttrs(AttrFactory); + TypeResult TrailingReturnType; + D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto,false,Loc,ParamInfo.data(), + ParamInfo.size(),EllipsisLoc, Loc,DS__.getTypeQualifiers(), + RefQualifierIsLValueRef,RefQualifierLoc, ConstQualifierLoc, + VolatileQualifierLoc,SourceLocation(),ESpecType, ESpecRange.getBegin(), + DynamicExceptions.data(),DynamicExceptionRanges.data(), + DynamicExceptions.size(), + NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0,Loc, Loc, D,TrailingReturnType), + FnAttrs, Loc); + PrototypeScope.Exit(); + + SmallVector<Decl *, 8> DeclsInGroup; + Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(D); + D.complete(FirstDecl); + DeclsInGroup.push_back(FirstDecl); + + DeclGroupPtrTy __retDecl = Actions.FinalizeDeclaratorGroup(getCurScope(), DS_, DeclsInGroup); + return Actions.ActOnDeclStmt(__retDecl, DeclStart, DeclEnd); +} + +StmtResult Parser::CreateReturnAssignmentStmt(){ + ExprResult Res,LHS,RHS; + Token LHSToken,Next; + IdentifierInfo *II; + SourceLocation Loc = Tok.getLocation(); + CXXScopeSpec SS; + II = CreateIdentifierInfo("__CbC_return", 12, Loc); + Next.startToken(); + Next.setLocation(Loc); + Next.setKind(tok::equal); + LHSToken.startToken(); + LHSToken.setLocation(Loc); + LHSToken.setLength(II->getLength()); + LHSToken.setIdentifierInfo(II); + LHSToken.setKind(tok::identifier); + + ExternalSpace::StatementFilterCCC Validator(Next); + Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, II, Loc, Next, false, SS.isEmpty() ? &Validator : 0); + + LHSToken.setKind(tok::annot_primary_expr); + setExprAnnotation(LHSToken, Classification.getExpression()); + LHSToken.setAnnotationEndLoc(Loc); + PP.AnnotateCachedTokens(LHSToken); + LHS = getExprAnnotation(LHSToken); + IdentifierInfo &return1II = *CreateIdentifierInfo("return1", 7, Loc); + UnqualifiedId Name; + Name.setIdentifier(&return1II, Loc); + + DeclarationNameInfo NameInfo; + const TemplateArgumentListInfo *TemplateArgs; + TemplateArgumentListInfo TemplateArgsBuffer; + Actions.DecomposeUnqualifiedId(Name, TemplateArgsBuffer, NameInfo, TemplateArgs); + DeclarationName DName = NameInfo.getName(); + IdentifierInfo *IIFromName = DName.getAsIdentifierInfo(); + LookupResult LR(Actions, NameInfo, Actions.LookupOrdinaryName); + bool IvarLookupFollowUp = IIFromName && !SS.isSet() && Actions.getCurMethodDecl(); + Actions.LookupParsedName(LR, getCurScope(), &SS, !IvarLookupFollowUp); + RHS = Actions.BuildDeclarationNameExpr(SS, LR, /* ADL = */ false); + + Res = Actions.CreateBuiltinBinOp(Loc, BO_Assign, LHS.take(), RHS.take()); + return Actions.ActOnExprStmt(Res); +} + + +StmtResult Parser::CreateSjForContinuationWithEnv(){ + SourceLocation Loc = Tok.getLocation(); + StmtResult IfRes; + ParseScope IfScope(this, Scope::DeclScope | Scope::ControlScope, true/* C99 or CXX */); + ExprResult CondExp; + Decl *CondVar = 0; + IdentifierInfo &setjmpII = *CreateIdentifierInfo("setjmp",6,Loc); + UnqualifiedId setjmpName; + CXXScopeSpec SS; + SourceLocation TemplateKWLoc; + ExternalSpace::CastExpressionIdValidator Validator(false,true); + setjmpName.setIdentifier(&setjmpII, Loc); + TemplateArgumentListInfo TemplateArgsBuffer; + DeclarationNameInfo setjmpNameInfo; + const TemplateArgumentListInfo *TemplateArgs; + 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); + + if (setjmpII_ && setjmpR.empty()) { + NamedDecl *sjljD = Actions.ImplicitlyDefineFunction(NameLoc, *setjmpII_, getCurScope()); + if (sjljD) setjmpR.addDecl(sjljD); + } + + CondExp = Actions.BuildDeclarationNameExpr(SS, setjmpR, false); + Expr *ExecConfig = 0; + ExprVector ArgExprs; + ExprResult __envExprRes = CondExp.get(); + IdentifierInfo &__envII = *CreateIdentifierInfo("__CbC_environment",17,Loc); + UnqualifiedId __envName; + + __envName.setIdentifier(&__envII,Loc); + TemplateArgumentListInfo __envTemplateArgsBuffer; + DeclarationNameInfo __envNameInfo; + const TemplateArgumentListInfo *__envTemplateArgs; + Actions.DecomposeUnqualifiedId(__envName, __envTemplateArgsBuffer, __envNameInfo, __envTemplateArgs); + LookupResult __envR(Actions, __envNameInfo,Actions.LookupOrdinaryName); + Actions.LookupParsedName(__envR, getCurScope(), &SS, true); + __envExprRes = Actions.BuildDeclarationNameExpr(SS, __envR, false); + UnqualifiedId envName; + IdentifierInfo *envId = CreateIdentifierInfo("env",3,Loc); + envName.setIdentifier(envId,Loc); + + Expr *envBase = __envExprRes.take(); + TemplateArgumentListInfo envTemplateArgsBuffer; + DeclarationNameInfo envNameInfo; + const TemplateArgumentListInfo *envTemplateArgs; + Actions.DecomposeUnqualifiedId(envName, envTemplateArgsBuffer, envNameInfo, envTemplateArgs); + bool IsArrow = false; + + __envExprRes = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), envBase); + envBase = __envExprRes.take(); + LookupResult envR(Actions, envNameInfo, Actions.LookupMemberName); + ExprResult envBaseResult = Actions.Owned(envBase); + __envExprRes = Actions.LookupMemberExpr(envR, envBaseResult, IsArrow, Loc, SS, 0, envTemplateArgs != 0); + envBase = envBaseResult.take(); + + Sema::ActOnMemberAccessExtraArgs envExtraArgs = {getCurScope(), envName, 0, false}; + __envExprRes = Actions.BuildMemberReferenceExpr(envBase, envBase->getType(), Loc, IsArrow, SS, TemplateKWLoc, 0, envR, envTemplateArgs,false, &envExtraArgs); + + ArgExprs.push_back(__envExprRes.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 StmtRes; + ParseScope CompoundScope(this, Scope::DeclScope); + PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),Tok.getLocation(),"in create setjmp statement for CbC"); + StmtVector innerStmts; + StmtResult innerStmtRes; + ExprResult innerExprRes; + ExprResult CastResult(true); + 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; + DiagID = 0; + ProhibitAttributes(attrs); + CastDS.Finish(Diags, PP); + + Declarator CastDeclaratorInfo(CastDS, Declarator::TypeNameContext); + CastDeclaratorInfo.SetRangeEnd(Loc); + DeclSpec pointerDS(AttrFactory); + pointerDS.Finish(Diags, PP); + 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()); + IdentifierInfo &__envII__ = *CreateIdentifierInfo("__CbC_environment",17,Loc); + UnqualifiedId __envName_; + ExternalSpace::CastExpressionIdValidator Validator2(true,false); + __envName_.setIdentifier(&__envII__, Loc); + TemplateArgumentListInfo __envTemplateArgsBuffer_; + DeclarationNameInfo __envNameInfo_; + const TemplateArgumentListInfo *__envTemplateArgs_; + Actions.DecomposeUnqualifiedId(__envName_, __envTemplateArgsBuffer_, __envNameInfo_, __envTemplateArgs_); + LookupResult __envR_(Actions, __envNameInfo_,Actions.LookupOrdinaryName); + Actions.LookupParsedName(__envR_, getCurScope(), &SS, true); + CastResult = Actions.BuildDeclarationNameExpr(SS,__envR_, false); + UnqualifiedId ret_pName; + IdentifierInfo *ret_pId = CreateIdentifierInfo("ret_p",5,Loc); + ret_pName.setIdentifier(ret_pId,Loc); + Expr *ret_pBase = CastResult.take(); + TemplateArgumentListInfo ret_pTemplateArgsBuffer; + DeclarationNameInfo ret_pNameInfo; + const TemplateArgumentListInfo *ret_pTemplateArgs; + Actions.DecomposeUnqualifiedId(ret_pName, ret_pTemplateArgsBuffer, ret_pNameInfo, ret_pTemplateArgs); + CastResult = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), ret_pBase); + ret_pBase = CastResult.take(); + LookupResult ret_pR(Actions, ret_pNameInfo, Actions.LookupMemberName); + ExprResult ret_pBaseResult = Actions.Owned(ret_pBase); + CastResult = Actions.LookupMemberExpr(ret_pR, ret_pBaseResult, IsArrow, Loc, SS, 0, ret_pTemplateArgs != 0); + ret_pBase = ret_pBaseResult.take(); + Sema::ActOnMemberAccessExtraArgs ret_pExtraArgs = {getCurScope(), ret_pName, 0, false}; + CastResult = Actions.BuildMemberReferenceExpr(ret_pBase, ret_pBase->getType(), Loc, IsArrow, SS, TemplateKWLoc, 0, ret_pR, ret_pTemplateArgs,false, &ret_pExtraArgs); + + Expr *CastExpr = CastResult.take(); + TypeSourceInfo *castTInfo = Actions.GetTypeForDeclaratorCast(CastDeclaratorInfo, CastExpr->getType()); + Actions.checkUnusedDeclAttributes(CastDeclaratorInfo); + + CastResult = Actions.BuildCStyleCastExpr(Loc, castTInfo, Loc, CastExpr); + innerExprRes = CastResult; + innerExprRes = Actions.ActOnParenExpr(Loc, Loc, innerExprRes.take()); + innerExprRes = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, innerExprRes.get()); + innerStmtRes = Actions.ActOnReturnStmt(Loc, innerExprRes.take()); + if (innerStmtRes.isUsable()) + innerStmts.push_back(innerStmtRes.release()); + StmtRes = Actions.ActOnCompoundStmt(Loc, Loc,innerStmts, false); + StmtResult ThenStmt(StmtRes); + InnerScope.Exit(); + IfScope.Exit(); + StmtResult ElseStmt; + IfRes = Actions.ActOnIfStmt(Loc, FullCondExp, CondVar, ThenStmt.get(),Loc, ElseStmt.get()); + return IfRes; +}
--- a/tools/clang/lib/Parse/ParseExpr.cpp Thu Dec 26 19:56:35 2013 +0900 +++ b/tools/clang/lib/Parse/ParseExpr.cpp Thu Dec 26 22:29:30 2013 +0900 @@ -2429,7 +2429,7 @@ if (__returnDeclaration.isUsable()) Stmtsp->push_back(__returnDeclaration.release()); - setjmpStmt = CreateSjForContinuationWithEnv2(); + setjmpStmt = CreateSjForContinuationWithEnv(); if (setjmpStmt.isUsable()) Stmtsp->push_back(setjmpStmt.release());
--- a/tools/clang/lib/Parse/ParseStmt.cpp Thu Dec 26 19:56:35 2013 +0900 +++ b/tools/clang/lib/Parse/ParseStmt.cpp Thu Dec 26 22:29:30 2013 +0900 @@ -36,10 +36,6 @@ #include "llvm/Support/TargetSelect.h" #include "llvm/ADT/SmallString.h" -#ifndef noCbC -#include "clang/Sema/Lookup.h" -#endif - using namespace clang; //===----------------------------------------------------------------------===// @@ -2797,580 +2793,3 @@ } Braces.consumeClose(); } - -#ifndef noCbC -StmtResult Parser::Create__returnStmt(){ - SourceLocation Loc = Tok.getLocation(); - unsigned Context = Declarator::BlockContext; - ParsedAttributesWithRange __retAttrs(AttrFactory); - SourceLocation DeclStart = Loc, DeclEnd = Loc; - ParsingDeclSpec PDS(*this); - DeclSpec &__retDS = PDS; - const char *PrevSpec = 0; - unsigned DiagID = 0; - bool isInvalid = false; - if (__retDS.getSourceRange().isInvalid()) { - __retDS.SetRangeStart(Loc); - __retDS.SetRangeEnd(Loc); - } - isInvalid = __retDS.SetTypeSpecType(DeclSpec::TST___code, Loc, PrevSpec, DiagID); - if (isInvalid) { - assert(PrevSpec && "Method did not return previous specifier!"); - assert(DiagID); - if (DiagID == diag::ext_duplicate_declspec) - Diag(Tok, DiagID) - << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation()); - else - Diag(Tok, DiagID) << PrevSpec; - } - __retDS.SetRangeEnd(Loc); - __retDS.Finish(Diags, PP); - ParsingDeclarator D(*this, PDS, static_cast<Declarator::TheContext>(Context)); - D.setEllipsisLoc(SourceLocation()); - bool hadGroupingParens = D.hasGroupingParens(); - D.setGroupingParens(true); - IdentifierInfo* II = CreateIdentifierInfo("__CbC_return",12, Loc); // CreateIdentifierInfo(name,length of the name, SourceLocation); - D.SetRangeEnd(Loc); - DeclSpec DS_(AttrFactory); - - DS_.Finish(Diags, PP); - D.SetIdentifier(II, Loc); - - D.AddTypeInfo(DeclaratorChunk::getPointer(DS_.getTypeQualifiers(), Loc,DS_.getConstSpecLoc(),DS_.getVolatileSpecLoc(), - DS_.getRestrictSpecLoc()),DS_.getAttributes(),SourceLocation()); - D.setGroupingParens(hadGroupingParens); - - - ParseScope PrototypeScope(this,Scope::FunctionPrototypeScope|Scope::DeclScope| - (D.isFunctionDeclaratorAFunctionDeclaration() ? Scope::FunctionDeclarationScope : 0)); - bool HasProto = false; - SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo; - SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc; - DeclSpec DS__(AttrFactory); - bool RefQualifierIsLValueRef = true; - ExceptionSpecificationType ESpecType = EST_None; - SourceRange ESpecRange; - SmallVector<ParsedType, 2> DynamicExceptions; - SmallVector<SourceRange, 2> DynamicExceptionRanges; - ExprResult NoexceptExpr; - ParsedAttributes FnAttrs(AttrFactory); - TypeResult TrailingReturnType; - D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto,false,Loc,ParamInfo.data(), - ParamInfo.size(),EllipsisLoc, Loc,DS__.getTypeQualifiers(), - RefQualifierIsLValueRef,RefQualifierLoc, ConstQualifierLoc, - VolatileQualifierLoc,SourceLocation(),ESpecType, ESpecRange.getBegin(), - DynamicExceptions.data(),DynamicExceptionRanges.data(), - DynamicExceptions.size(), - NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0,Loc, Loc, D,TrailingReturnType), - FnAttrs, Loc); - PrototypeScope.Exit(); - - SmallVector<Decl *, 8> DeclsInGroup; - Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(D); - D.complete(FirstDecl); - DeclsInGroup.push_back(FirstDecl); - - DeclGroupPtrTy __retDecl = Actions.FinalizeDeclaratorGroup(getCurScope(), DS_, DeclsInGroup); - return Actions.ActOnDeclStmt(__retDecl, DeclStart, DeclEnd); -} - -StmtResult Parser::CreateReturnAssignmentStmt(){ - ExprResult Res,LHS,RHS; - Token LHSToken,Next; - IdentifierInfo *II; - SourceLocation Loc = Tok.getLocation(); - CXXScopeSpec SS; - II = CreateIdentifierInfo("__CbC_return", 12, Loc); - Next.startToken(); - Next.setLocation(Loc); - Next.setKind(tok::equal); - LHSToken.startToken(); - LHSToken.setLocation(Loc); - LHSToken.setLength(II->getLength()); - LHSToken.setIdentifierInfo(II); - LHSToken.setKind(tok::identifier); - - StatementFilterCCC Validator(Next); - Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, II, Loc, Next, false, SS.isEmpty() ? &Validator : 0); - - LHSToken.setKind(tok::annot_primary_expr); - setExprAnnotation(LHSToken, Classification.getExpression()); - LHSToken.setAnnotationEndLoc(Loc); - PP.AnnotateCachedTokens(LHSToken); - LHS = getExprAnnotation(LHSToken); - IdentifierInfo &return1II = *CreateIdentifierInfo("return1", 7, Loc); - UnqualifiedId Name; - Name.setIdentifier(&return1II, Loc); - - DeclarationNameInfo NameInfo; - const TemplateArgumentListInfo *TemplateArgs; - TemplateArgumentListInfo TemplateArgsBuffer; - Actions.DecomposeUnqualifiedId(Name, TemplateArgsBuffer, NameInfo, TemplateArgs); - DeclarationName DName = NameInfo.getName(); - IdentifierInfo *IIFromName = DName.getAsIdentifierInfo(); - LookupResult LR(Actions, NameInfo, Actions.LookupOrdinaryName); - bool IvarLookupFollowUp = IIFromName && !SS.isSet() && Actions.getCurMethodDecl(); - Actions.LookupParsedName(LR, getCurScope(), &SS, !IvarLookupFollowUp); - RHS = Actions.BuildDeclarationNameExpr(SS, LR, /* ADL = */ false); - - 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