Mercurial > hg > CbC > CbC_llvm
changeset 8:ac3ff95a8c30
don't set optimization level to 2 if extension is 'cbc' (cancel 4th commit).
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 03 Jul 2013 12:42:47 +0900 |
parents | eac3edb8778b |
children | 1d7e5c85e4cf |
files | tools/clang/include/clang/Basic/LangOptions.def tools/clang/include/clang/Frontend/FrontendOptions.h tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Frontend/CompilerInvocation.cpp tools/clang/lib/Frontend/FrontendActions.cpp tools/clang/lib/Frontend/FrontendOptions.cpp tools/clang/lib/Parse/ParseAST.cpp tools/clang/lib/Parse/ParseDecl.cpp tools/clang/lib/Parse/ParseStmt.cpp |
diffstat | 9 files changed, 35 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/include/clang/Basic/LangOptions.def Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/include/clang/Basic/LangOptions.def Wed Jul 03 12:42:47 2013 +0900 @@ -173,6 +173,11 @@ BENIGN_LANGOPT(RetainCommentsFromSystemHeaders, 1, 0, "retain documentation comments from system headers in the AST") + +#ifndef noCbC +LANGOPT(HasCodeSegment , 1, 0, "CbC") +#endif + #undef LANGOPT #undef VALUE_LANGOPT #undef BENIGN_LANGOPT
--- a/tools/clang/include/clang/Frontend/FrontendOptions.h Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/include/clang/Frontend/FrontendOptions.h Wed Jul 03 12:42:47 2013 +0900 @@ -72,9 +72,6 @@ IK_OpenCL, IK_CUDA, IK_AST, -#ifndef noCbC - IK_CbC, -#endif IK_LLVM_IR };
--- a/tools/clang/include/clang/Parse/Parser.h Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/include/clang/Parse/Parser.h Wed Jul 03 12:42:47 2013 +0900 @@ -1497,7 +1497,9 @@ StmtResult ParseDoStatement(); StmtResult ParseForStatement(SourceLocation *TrailingElseLoc); StmtResult ParseGotoStatement(); - StmtResult ParseCbCGotoStatement(); +#ifndef noCbC + StmtResult ParseCbCGotoStatement(ParsedAttributesWithRange &Attrs,StmtVector &Stmts); +#endif StmtResult ParseContinueStatement(); StmtResult ParseBreakStatement(); StmtResult ParseReturnStatement();
--- a/tools/clang/lib/Frontend/CompilerInvocation.cpp Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/lib/Frontend/CompilerInvocation.cpp Wed Jul 03 12:42:47 2013 +0900 @@ -66,11 +66,6 @@ if (IK == IK_OpenCL && !Args.hasArg(OPT_cl_opt_disable)) DefaultOpt = 2; -#ifndef noCbC - if (IK == IK_CbC) - DefaultOpt = 2; -#endif - if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { if (A->getOption().matches(options::OPT_O0)) return 0; @@ -795,7 +790,7 @@ .Cases("ast", "pcm", IK_AST) .Case("ir", IK_LLVM_IR) #ifndef noCbC - .Case("cbc", IK_CbC) + .Case("cbc", IK_C) #endif .Default(IK_None); if (DashX == IK_None) @@ -977,9 +972,6 @@ case IK_PreprocessedC: case IK_ObjC: case IK_PreprocessedObjC: -#ifndef noCbC - case IK_CbC: -#endif LangStd = LangStandard::lang_gnu99; break; case IK_CXX: @@ -1085,9 +1077,6 @@ case IK_ObjC: case IK_PreprocessedC: case IK_PreprocessedObjC: -#ifndef noCbC - case IK_CbC: -#endif if (!(Std.isC89() || Std.isC99())) Diags.Report(diag::err_drv_argument_not_allowed_with) << A->getAsString(Args) << "C/ObjC";
--- a/tools/clang/lib/Frontend/FrontendActions.cpp Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/lib/Frontend/FrontendActions.cpp Wed Jul 03 12:42:47 2013 +0900 @@ -562,9 +562,6 @@ case IK_ObjCXX: case IK_OpenCL: case IK_CUDA: -#ifndef noCbC - case IK_CbC: -#endif break; case IK_None:
--- a/tools/clang/lib/Frontend/FrontendOptions.cpp Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/lib/Frontend/FrontendOptions.cpp Wed Jul 03 12:42:47 2013 +0900 @@ -29,7 +29,7 @@ .Case("cu", IK_CUDA) .Cases("ll", "bc", IK_LLVM_IR) #ifndef noCbC - .Case("cbc", IK_CbC) + .Case("cbc", IK_C) #endif .Default(IK_C); }
--- a/tools/clang/lib/Parse/ParseAST.cpp Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/lib/Parse/ParseAST.cpp Wed Jul 03 12:42:47 2013 +0900 @@ -144,6 +144,13 @@ } while (!P.ParseTopLevelDecl(ADecl)); } +#ifndef noCbC + if(S.getLangOpts().HasCodeSegment && !S.getLangOpts().Optimize){ // If codes has code segments , set Optlevel to 2. + // S.getLangOpts().Optimize = 1; + // S.getCodeGenOpts().OptimizationLevel = 2; + } +#endif + // Process any TopLevelDecls generated by #pragma weak. for (SmallVector<Decl*,2>::iterator I = S.WeakTopLevelDecls().begin(),
--- a/tools/clang/lib/Parse/ParseDecl.cpp Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/lib/Parse/ParseDecl.cpp Wed Jul 03 12:42:47 2013 +0900 @@ -2878,6 +2878,7 @@ case tok::kw___code: isInvalid = DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec, DiagID); + // getLangOpts().HasCodeSegment = 1; break; #endif case tok::kw_char:
--- a/tools/clang/lib/Parse/ParseStmt.cpp Thu Jun 20 15:02:26 2013 +0900 +++ b/tools/clang/lib/Parse/ParseStmt.cpp Wed Jul 03 12:42:47 2013 +0900 @@ -226,8 +226,8 @@ case tok::kw_goto: // C99 6.8.6.1: goto-statement or CbC goto #ifndef noCbC if (PP.LookAhead(1).is(tok::l_paren)) { // is CbC goto : 'goto' codeSegment() ';' - return ParseCbCGotoStatement(); SemiError = "goto code segment"; + return ParseCbCGotoStatement(Attrs, Stmts); } #endif Res = ParseGotoStatement(); @@ -1634,12 +1634,11 @@ /// jump-statement: /// 'goto' codeSegment ';' /// -/// -StmtResult Parser::ParseCbCGotoStatement() { +StmtResult Parser::ParseCbCGotoStatement(ParsedAttributesWithRange &Attrs,StmtVector &Stmts) { assert(Tok.is(tok::kw_goto) && "Not a goto stmt!"); - ConsumeToken(); // eat the 'goto'. + SourceLocation gotoLoc = ConsumeToken(); // eat the 'goto'. - StmtResult Res; + StmtResult gotoRes; if (Tok.is(tok::identifier) && NextToken().is(tok::l_paren)) { // 'goto' codeSegment() ';' @@ -1658,13 +1657,24 @@ ConsumeToken(); return StmtError(); } - Res = ParseExprStatement(); + gotoRes = ParseExprStatement(); } else { Diag(Tok, diag::err_expected_ident); return StmtError(); } - return Res; + assert((Attrs.empty() || gotoRes.isInvalid() || gotoRes.isUsable()) && + "attributes on empty statement"); + + if (!(Attrs.empty() || gotoRes.isInvalid())) + gotoRes = Actions.ProcessStmtAttributes(gotoRes.get(), Attrs.getList(), Attrs.Range); + + if(gotoRes.isUsable()) + Stmts.push_back(gotoRes.release()); + /* add return; after goto code segment. */ + + ExprResult R; + return Actions.ActOnReturnStmt(gotoLoc, R.take()); } #endif