annotate tools/clang/lib/Parse/ParseCbC.cpp @ 81:97a220dc594f

if __return or __environment used in void function, compiler emit error.
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Wed, 22 Oct 2014 18:26:28 +0900
parents 67baa08a3894
children 99580de8d21d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
1 #ifndef noCbC
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
2
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "clang/Parse/Parser.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "RAIIObjectsForParser.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "clang/AST/ASTContext.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "clang/Basic/Diagnostic.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "clang/Basic/PrettyStackTrace.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "clang/Basic/TargetInfo.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "clang/Sema/DeclSpec.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "clang/Sema/PrettyDeclStackTrace.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "clang/Sema/Scope.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "clang/Sema/Lookup.h"
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
13 #include "clang/Lex/LiteralSupport.h"
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
14 #include "clang/AST/ASTConsumer.h"
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
15
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
16 #include <sstream>
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
17 #include <string>
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
18 #include "CbCHelper.h"
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
19
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 using namespace clang;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
22 /// The class which belong to this namespace is from other files' namespace.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
23 /// Because those namespaces are unnamed namespaces, we can't access them.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
24 /// So create this namespace and copy classes from those namespaces.
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
25 namespace ExternalSpace { // from ParseExpr.cpp , ParseStmt.cpp
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
26 class CastExpressionIdValidator : public CorrectionCandidateCallback {
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
27 public:
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
28 CastExpressionIdValidator(bool AllowTypes, bool AllowNonTypes)
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 : AllowNonTypes(AllowNonTypes) {
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
30 WantTypeSpecifiers = AllowTypes;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
31 }
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
33 virtual bool ValidateCandidate(const TypoCorrection &candidate) {
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
34 NamedDecl *ND = candidate.getCorrectionDecl();
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
35 if (!ND)
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
36 return candidate.isKeyword();
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
38 if (isa<TypeDecl>(ND))
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
39 return WantTypeSpecifiers;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
40 return AllowNonTypes;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
41 }
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
43 private:
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
44 bool AllowNonTypes;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
45 };
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
47 class StatementFilterCCC : public CorrectionCandidateCallback {
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
48 public:
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
49 StatementFilterCCC(Token nextTok) : NextToken(nextTok) {
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
50 WantTypeSpecifiers = nextTok.is(tok::l_paren) || nextTok.is(tok::less) ||
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
51 nextTok.is(tok::identifier) || nextTok.is(tok::star) ||
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
52 nextTok.is(tok::amp) || nextTok.is(tok::l_square);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
53 WantExpressionKeywords = nextTok.is(tok::l_paren) ||
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
54 nextTok.is(tok::identifier) ||
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
55 nextTok.is(tok::arrow) || nextTok.is(tok::period);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
56 WantRemainingKeywords = nextTok.is(tok::l_paren) || nextTok.is(tok::semi) ||
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
57 nextTok.is(tok::identifier) ||
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
58 nextTok.is(tok::l_brace);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
59 WantCXXNamedCasts = false;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
60 }
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
62 virtual bool ValidateCandidate(const TypoCorrection &candidate) {
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
63 if (FieldDecl *FD = candidate.getCorrectionDeclAs<FieldDecl>())
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
64 return !candidate.getCorrectionSpecifier() || isa<ObjCIvarDecl>(FD);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
65 if (NextToken.is(tok::equal))
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
66 return candidate.getCorrectionDeclAs<VarDecl>();
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
67 if (NextToken.is(tok::period) &&
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
68 candidate.getCorrectionDeclAs<NamespaceDecl>())
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
69 return false;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
70 return CorrectionCandidateCallback::ValidateCandidate(candidate);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
71 }
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
73 private:
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
74 Token NextToken;
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
75 };
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
78
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
79 /// Prepare__retForGotoWithTheEnvExpr - Prepare __CbC_return, code segment for returning and some necessary statements.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
80 /// It is called when the parser find __return and statements are put into complex statement.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
81 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
82 /// examples which are created:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
83 /// complex statement:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
84 /// ({
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
85 /// __code (*__CbC_return)(return_type, void*);
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
86 /// __CbC_return = code_segment_for_return;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
87 /// __CbC_return;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
88 /// });
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
89 /// code segment:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
90 /// __code ret(return_type retval, void *env){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
91 /// *(return_type)((struct CbC_environment *)(env))->ret_p = n;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
92 /// longjmp((int*)(((struct __CbC_environment *)env)->env),1);
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
93 /// }
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
94 ExprResult Parser::Prepare__retForGotoWithTheEnvExpr(){
81
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
95
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
96 if (isVoidFunction()) { // error check : function type is void or not.
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
97 unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, "continuation with the environment cannot use in the void function");
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
98 Diag(Tok, DiagID);
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
99 return ExprError();
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
100 }
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
101
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
102 StmtResult innerRes;
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
103 SourceLocation Loc = Tok.getLocation();
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
104 IdentifierInfo *__CbC_retII = CreateIdentifierInfo(__CBC_RETURN_NAME, Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
105 IdentifierInfo *retcsII = CreateUniqueIdentifierInfo(__CBC_RET_CODE_BASE_NAME, Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
106 Create__CbC_envStruct(Loc, AS_none);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
107
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
108 Actions.ActOnStartStmtExpr();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
109 StmtResult CompoundStmtRes;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
110 ParseScope CompoundScope(this, Scope::DeclScope);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
111 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),Loc,"in compound statement ('{}')");
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
112 StmtVector CompoundStmts;
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
113
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
114 // create code segment for return to C's function
81
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
115 CreateRetCS(retcsII);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
116
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
117 // __code (*__CbC_return)();
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
118 innerRes = CreateDeclStmt(__CbC_retII, true, false, DeclSpec::TST___code);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
119 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
120 CompoundStmts.push_back(innerRes.get());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
121
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
122 // __CbC_return = ret;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
123 innerRes = CreateAssignmentStmt(__CbC_retII, retcsII);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
124 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
125 CompoundStmts.push_back(innerRes.get());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
126
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
127 // __CbC_return;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
128 innerRes = CreateComplexStmtRet(__CbC_retII, false);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
129 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
130 CompoundStmts.push_back(innerRes.get());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
131
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
132 CompoundStmtRes = Actions.ActOnCompoundStmt(Loc,Loc,CompoundStmts,true);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
133 ConsumeToken(); // eat the '__return'.
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
134 return Actions.ActOnStmtExpr(Loc, CompoundStmtRes.get(), Loc);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
137 /// Prepare__envForGotoWithTheEnvExpr - Prepare __CbC_environment, struct __CbC_env and some necessary statements.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
138 /// It is called when the parser find __environment and statements are put into complex statement.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
139 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
140 /// examples which are created:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
141 /// complex statement:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
142 /// ({
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
143 /// struct __CbC_env __CbC_environment;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
144 /// jmp_buf env_buf;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
145 /// return_type retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
146 /// __CbC_environment.ret_p = &retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
147 /// __CbC_environment.env = &env_buf
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
148 /// if (setjmp(__CbC_environment.env)){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
149 /// return retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
150 /// }
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
151 /// &__CbC_environment;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
152 /// });
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
153 /// struct __CbC_env:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
154 /// struct __CbC_env{
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
155 /// void *ret_p,*env;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
156 /// }
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
157 ExprResult Parser::Prepare__envForGotoWithTheEnvExpr(){
81
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
158
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
159 if (isVoidFunction()) { // error check : function type is void or not.
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
160 unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, "continuation with the environment cannot use in the void function");
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
161 Diag(Tok, DiagID);
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
162 return ExprError();
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
163 }
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
164
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
165 StmtResult innerRes;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
166 SourceLocation Loc = Tok.getLocation();
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
167 IdentifierInfo *bufII = CreateIdentifierInfo(__CBC_BUF_NAME, Loc);
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
168 IdentifierInfo *retvalII = CreateIdentifierInfo(__CBC_RETVAL_NAME, Loc);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
169 IdentifierInfo *structII = CreateIdentifierInfo(__CBC_STRUCT_NAME, Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
170 IdentifierInfo *__CbC_envII = CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
171 IdentifierInfo *envII = CreateIdentifierInfo(__CBC_STRUCT_ENV_NAME, Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
172 IdentifierInfo *ret_pII = CreateIdentifierInfo(__CBC_STRUCT_POINTER_NAME, Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
173 Create__CbC_envStruct(Loc, AS_none);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
174 Actions.ActOnStartStmtExpr();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
175 ParseScope CompoundScope(this, Scope::DeclScope);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
176 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),Loc,"in compound statement ('{}')");
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
177 StmtVector CompoundStmts;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
178
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
179 // struct __CbC_env __CbC_environment;
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
180 innerRes = CreateDeclStmt(__CbC_envII, false, false, DeclSpec::TST_struct, structII);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
181 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
182 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
183
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
184 // returnType retval;
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
185 innerRes = CreateDeclStmt(retvalII, false, true);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
186 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
187 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
188
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
189 // jmp_buf env_buf;
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
190 innerRes = CreateDeclStmt(bufII, false, false, DeclSpec::TST_typename, CreateIdentifierInfo("jmp_buf", Loc));
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
191 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
192 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
193
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
194 // __CbC_environment.ret_p = &retval;
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
195 innerRes = CreateAssignmentStmt(__CbC_envII, retvalII, true, true, ret_pII);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
196 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
197 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
198
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
199 // __CbC_environment.env = env_buf;
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
200 innerRes = CreateAssignmentStmt(__CbC_envII, bufII, true, false, envII);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
201 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
202 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
203
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
204 // create statements of setjmp
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
205 innerRes = CreateSjForContinuationWithTheEnv();
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
206 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
207 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
208
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
209 // __CbC_environment;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
210 innerRes = CreateComplexStmtRet(__CbC_envII, true);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
211 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
212 CompoundStmts.push_back(innerRes.get());
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
213
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
214 StmtResult CompoundStmtRes = Actions.ActOnCompoundStmt(Loc,Loc,CompoundStmts,true);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
215 ConsumeToken(); // eat the '__environment'.
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
216 return Actions.ActOnStmtExpr(Loc, CompoundStmtRes.get(), Loc);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
217 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
218
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
219 /// CreateAssignmentStmt - Create assignment statement such as "aaa = bbb;", "auaua = llll;", etc.
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
220 /// It can create 4 kinds of statement.
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
221 /// 1. common assignment statement:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
222 /// variable '=' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
223 /// 2. LHS variable is member of struct:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
224 /// structVar '.' member '=' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
225 /// 3. RHS variable is address of operand:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
226 /// variable '=' '&' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
227 /// 4. 2+3:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
228 /// structVar '.' member '=' '&' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
229 StmtResult Parser::CreateAssignmentStmt(IdentifierInfo* LHSII, IdentifierInfo* RHSII, bool LHSisMemberAccess, bool RHShasAmp,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
230 IdentifierInfo* extraLHSII, IdentifierInfo* extraRHSII){
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
231 ExprResult Expr,LHS,RHS;
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
232
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
233 Token Next,LHSToken;
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 SourceLocation Loc = Tok.getLocation();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 CXXScopeSpec SS;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 Next.startToken();
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
237 Next.setKind(tok::period);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 LHSToken.startToken();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 LHSToken.setLocation(Loc);
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
240 LHSToken.setIdentifierInfo(LHSII);
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
241 LHSToken.setKind(tok::annot_primary_expr);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 ExternalSpace::StatementFilterCCC Validator(Next);
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
243 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, LHSII, Loc, Next, false, SS.isEmpty() ? &Validator : 0);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 setExprAnnotation(LHSToken, Classification.getExpression());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 LHSToken.setAnnotationEndLoc(Loc);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 PP.AnnotateCachedTokens(LHSToken);
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
247
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 LHS = getExprAnnotation(LHSToken);
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
249
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
250 if (LHSisMemberAccess)
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
251 LHS = LookupMemberAndBuildExpr(extraLHSII, LHS.get(), false);
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
252
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
253 RHS = LookupNameAndBuildExpr(RHSII);
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
254 if (RHShasAmp)
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
255 RHS = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::amp, RHS.get());
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
256
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
257 Expr = Actions.ActOnBinOp(getCurScope(), Loc,tok::equal,LHS.get(),RHS.get());
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
258
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
259 return Actions.ActOnExprStmt(Expr);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
262 /// CreateDeclStmt - Create declaration statement such as "int aaa;".
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
263 /// If isRetCS is true, create code segment for return to C's function. And Name is name of code segment.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
264 /// If copyType is true, type of variable is copied from callee.
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
265 StmtResult Parser::CreateDeclStmt(IdentifierInfo *II, bool isRetCS, bool copyType, DeclSpec::TST valueType, IdentifierInfo* Name){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
266 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
267 SourceLocation Loc = Tok.getLocation();
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
268 DeclGroupPtrTy DeclGPT;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
269 ParsingDeclSpec DS(*this);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
270 DeclSpec *DSp;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
271 DSp = &DS;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
272
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
273 setTST(&DS, valueType, Name);
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
274 ParsingDeclarator D(*this, DS, static_cast<Declarator::TheContext>(Declarator::BlockContext));
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
275 D.SetIdentifier(II, Loc);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
276
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
277 if (isRetCS) {
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
278 D.setEllipsisLoc(SourceLocation());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
279 bool hadGroupingParens = D.hasGroupingParens();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
280 D.setGroupingParens(true);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
281 D.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
282 DeclSpec FDS(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
283 DS.Finish(Diags, PP, Policy);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
284
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
285 D.AddTypeInfo(DeclaratorChunk::getPointer(FDS.getTypeQualifiers(), Loc, FDS.getConstSpecLoc(), FDS.getVolatileSpecLoc(),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
286 FDS.getRestrictSpecLoc()), FDS.getAttributes(), SourceLocation());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
287 D.setGroupingParens(hadGroupingParens);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
288
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
289
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
290 ParseScope PrototypeScope(this,Scope::FunctionPrototypeScope|Scope::DeclScope|
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
291 (D.isFunctionDeclaratorAFunctionDeclaration() ? Scope::FunctionDeclarationScope : 0));
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
292 bool HasProto = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
293 SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
294 SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
295 DeclSpec FPDS(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
296 bool RefQualifierIsLValueRef = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
297 ExceptionSpecificationType ESpecType = EST_None;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
298 SourceRange ESpecRange;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
299 SmallVector<ParsedType, 2> DynamicExceptions;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
300 SmallVector<SourceRange, 2> DynamicExceptionRanges;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
301 ExprResult NoexceptExpr;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
302 ParsedAttributes FnAttrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
303 TypeResult TrailingReturnType;
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
304
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
305 ParmVarDecl *Param;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
306 FunctionDecl *CurFunctionDecl = Actions.getCurFunctionDecl();
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
307 QualType CurFuncResQT = CurFunctionDecl->getReturnType();
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
308 TypeSourceInfo *CurFuncTI = Actions.Context.CreateTypeSourceInfo(CurFuncResQT);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
309
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
310 Param = CreateParam();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
311 Param->setTypeSourceInfo(CurFuncTI);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
312 Param->setType(CurFuncResQT);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
313 ParamInfo.push_back(DeclaratorChunk::ParamInfo(0, Loc, Param, 0));
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
314 Param = CreateParam(0, 1, DeclSpec::TST_void);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
315 ParamInfo.push_back(DeclaratorChunk::ParamInfo(0, Loc, Param, 0));
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
316 HasProto = true;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
317
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
318 D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto,false,Loc,ParamInfo.data(),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
319 ParamInfo.size(),EllipsisLoc, Loc, FPDS.getTypeQualifiers(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
320 RefQualifierIsLValueRef,RefQualifierLoc, ConstQualifierLoc,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
321 VolatileQualifierLoc,SourceLocation(),ESpecType, ESpecRange.getBegin(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
322 DynamicExceptions.data(),DynamicExceptionRanges.data(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
323 DynamicExceptions.size(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
324 NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0,Loc, Loc, D,TrailingReturnType),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
325 FnAttrs, Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
326 PrototypeScope.Exit();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
327 DSp = &FDS;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
328 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
329
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
330 SmallVector<Decl *, 8> DeclsInGroup;
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
331 Decl *FirstDecl;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
332
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
333 if (copyType)
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
334 FirstDecl = HandleDeclAndChangeDeclType(D);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
335 else
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
336 FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(D);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
337
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
338 D.complete(FirstDecl);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
339 DeclsInGroup.push_back(FirstDecl);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
340 DeclGPT = Actions.FinalizeDeclaratorGroup(getCurScope(), *DSp, DeclsInGroup);
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
341 return Actions.ActOnDeclStmt(DeclGPT, Loc, Loc);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
342 }
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
343
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
344
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
345 /// handleDeclAndChangeDeclType - This function imitated Parser::ParseDeclarationAfterDeclaratorAndAttributes() and Sema::ActOnDeclarator().
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
346 /// The origins get Type from Declarator but this function get Type from current function.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
347 /// It is useful for CbC to create statements for the continuation with the environments.
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
348 Decl* Parser::HandleDeclAndChangeDeclType(Declarator &D) {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
349 D.setFunctionDefinitionKind(FDK_Declaration);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
350 DeclarationNameInfo NameInfo = Actions.GetNameForDeclarator(D);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
351 DeclContext *DC = Actions.CurContext;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
352 QualType R = Actions.getCurFunctionDecl()->getReturnType(); // copy a type
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
353 TypeSourceInfo *TInfo = Actions.Context.CreateTypeSourceInfo(R); // copy a type infomation
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
354 Scope *S = getCurScope();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
355 LookupResult Previous(Actions, NameInfo, Actions.LookupOrdinaryName, Actions.ForRedeclaration);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
356 bool IsLinkageLookup = false;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
357 bool CreateBuiltins = false;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
358
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
359 // If the declaration we're planning to build will be a function
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
360 // or object with linkage, then look for another declaration with
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
361 // linkage (C99 6.2.2p4-5 and C++ [basic.link]p6).
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
362 //
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
363 // If the declaration we're planning to build will be declared with
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
364 // external linkage in the translation unit, create any builtin with
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
365 // the same name.
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
366 if (R->isFunctionType()) {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
367 IsLinkageLookup = true;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
368 CreateBuiltins =
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
369 Actions.CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
370 } else if (Actions.CurContext->getRedeclContext()->isTranslationUnit())
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
371 CreateBuiltins = true;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
372
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
373 if (IsLinkageLookup)
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
374 Previous.clear(Actions.LookupRedeclarationWithLinkage);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
375
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
376 Actions.LookupName(Previous, S, CreateBuiltins);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
377
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
378 // In C++, the previous declaration we find might be a tag type
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
379 // (class or enum). In this case, the new declaration will hide the
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
380 // tag type. Note that this does does not apply if we're declaring a
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
381 // typedef (C++ [dcl.typedef]p4).
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
382 if (Previous.isSingleTagDecl())
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
383 Previous.clear();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
384 NamedDecl *New;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
385 bool AddToScope = true;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
386 if (R->isFunctionType()) {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
387 New = Actions.ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
388 MultiTemplateParamsArg(), AddToScope);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
389 } else {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
390 New = Actions.ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
391 MultiTemplateParamsArg(), AddToScope);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
392 }
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
393
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
394 if (New->getDeclName() && AddToScope) {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
395 // Only make a locally-scoped extern declaration visible if it is the first
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
396 // declaration of this entity. Qualified lookup for such an entity should
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
397 // only find this declaration if there is no visible declaration of it.
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
398 bool AddToContext = !D.isRedeclaration() || !New->isLocalExternDecl();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
399 Actions.PushOnScopeChains(New, S, AddToContext);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
400 if (!AddToContext)
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
401 Actions.CurContext->addHiddenDecl(New);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
402 }
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
403
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
404 return New;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
405 }
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
406
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
407
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
408 /// CreateSjForContinuationWithEnv - Create statements of setjmp for continuation with the environment.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
409 /// code example:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
410 /// if (setjmp(__CbC_environment.env)){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
411 /// return retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
412 /// }
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
413 StmtResult Parser::CreateSjForContinuationWithTheEnv(){
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 SourceLocation Loc = Tok.getLocation();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 StmtResult IfRes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 ParseScope IfScope(this, Scope::DeclScope | Scope::ControlScope, true/* C99 or CXX */);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 ExprResult CondExp;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 Decl *CondVar = 0;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
420 CondExp = LookupNameAndBuildExpr(CreateIdentifierInfo("setjmp", Loc));
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 ExprVector ArgExprs;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 ExprResult __envExprRes = CondExp.get();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
424 __envExprRes = LookupNameAndBuildExpr(CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, Loc));
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
425 __envExprRes = LookupMemberAndBuildExpr(CreateIdentifierInfo(__CBC_STRUCT_ENV_NAME, Loc), __envExprRes.get(), false);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
427 ArgExprs.push_back(__envExprRes.get());
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
428 CondExp = Actions.ActOnCallExpr(getCurScope(), CondExp.get(), Loc, ArgExprs, Loc, 0);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 CondExp = Actions.ActOnBooleanCondition(getCurScope(), Loc, CondExp.get());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get(), Loc));
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 ParseScope InnerScope(this, Scope::DeclScope,false);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 SourceLocation InnerStatementTrailingElseLoc;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 StmtResult StmtRes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 ParseScope CompoundScope(this, Scope::DeclScope);
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
437 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),Loc,"in create setjmp statement for CbC");
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 StmtVector innerStmts;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 StmtResult innerStmtRes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 ExprResult innerExprRes;
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
441 innerExprRes = LookupNameAndBuildExpr(CreateIdentifierInfo(__CBC_RETVAL_NAME, Loc));
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
442 innerStmtRes = Actions.ActOnReturnStmt(Loc, innerExprRes.get(), getCurScope());
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 if (innerStmtRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
444 innerStmts.push_back(innerStmtRes.get());
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 StmtRes = Actions.ActOnCompoundStmt(Loc, Loc,innerStmts, false);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 StmtResult ThenStmt(StmtRes);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 InnerScope.Exit();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 IfScope.Exit();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 StmtResult ElseStmt;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 IfRes = Actions.ActOnIfStmt(Loc, FullCondExp, CondVar, ThenStmt.get(),Loc, ElseStmt.get());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 return IfRes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 }
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
453
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
454
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
455 /// LookupNameAndBuildExpr - Look up name, create ExprResult and return it.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
456 ExprResult Parser::LookupNameAndBuildExpr(IdentifierInfo *II, bool IsAddressOfOperand){
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
457 SourceLocation Loc = Tok.getLocation();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
458 UnqualifiedId Name;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
459 CXXScopeSpec SS;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
460 SourceLocation TemplateKWLoc;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
461 ExternalSpace::CastExpressionIdValidator Validator(false,true);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
462 Name.setIdentifier(II, Loc);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
463 return Actions.ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Name, false, IsAddressOfOperand, &Validator);
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
464 }
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
465
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
466 /// LookupMemberAndBuildExpr - Look up member name, create ExprResult and return it.
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
467 /// If IsArrow is true, the name is accessed by arrow operand.
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
468 ExprResult Parser::LookupMemberAndBuildExpr(IdentifierInfo *II, Expr* Base, bool IsArrow){
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
469 SourceLocation Loc = Tok.getLocation();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
470 CXXScopeSpec SS;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
471 UnqualifiedId Name;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
472 SourceLocation TemplateKWLoc;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
473 tok::TokenKind OpKind = (IsArrow ? tok::arrow : tok::period);
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
474 Name.setIdentifier(II,Loc);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
475 return Actions.ActOnMemberAccessExpr(getCurScope(), Base, Loc, OpKind, SS, TemplateKWLoc, Name, nullptr, false);
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
476 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
477
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
478
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
479 /// Create__CbC_envStruct - This method create "struct __CbC_env" which is used to continuation with environment.
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
480 /// If the __CbC_env has been already defined, it doesn't create __CbC_env again.
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
481 /// The example of struct which is created :
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
482 /// struct __CbC_env{
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
483 /// void *ret_p,*env;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
484 /// };
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
485 void Parser::Create__CbC_envStruct(SourceLocation Loc, AccessSpecifier AS) {
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
486
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
487 IdentifierInfo *Name = CreateIdentifierInfo(__CBC_STRUCT_NAME, Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
488 // Check previous definition. If the __CbC_env has been already defined, we have not to create again.
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
489 LookupResult Previous(Actions, Name, Loc, Actions.LookupTagName, Actions.ForRedeclaration);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
490 if(Actions.LookupName(Previous, getCurScope()))
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
491 return;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
492
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
493 Scope *SavedScope = getCurScope();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
494 DeclContext *SavedContext = Actions.CurContext;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
495 sema::FunctionScopeInfo *SavedFSI = Actions.FunctionScopes.pop_back_val();
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
496
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
497 Actions.CurContext = static_cast<DeclContext *>(Actions.Context.getTranslationUnitDecl());
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
498 Scope *TopScope = getCurScope();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
499 while(TopScope->getParent() != NULL)
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
500 TopScope = TopScope->getParent();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
501 Actions.CurScope = TopScope;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
502
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
503 ParsingDeclSpec SDS(*this);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
504 SDS.SetRangeStart(Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
505 SDS.SetRangeEnd(Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
506 DeclSpec::TST TagType = DeclSpec::TST_struct;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
507 DeclResult TagOrTempResult = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
508 bool Owned = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
509 bool IsDependent = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
510 ParsedAttributesWithRange attrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
511 MultiTemplateParamsArg TParams;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
512
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
513 TagOrTempResult = Actions.ActOnTag(getCurScope(), TagType, Sema::TUK_Definition, Loc,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
514 SDS.getTypeSpecScope(), Name, Loc, attrs.getList(), AS,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
515 SDS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
516 SourceLocation(), false, clang::TypeResult(), false);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
517
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
518 Decl *TagDecl = TagOrTempResult.get();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
519 PrettyDeclStackTraceEntry CrashInfo(Actions, TagDecl, Loc, "parsing struct/union body");
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
520 ParseScope StructScope(this, Scope::ClassScope|Scope::DeclScope);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
521 Actions.ActOnTagStartDefinition(getCurScope(), TagDecl);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
522 SmallVector<Decl *, 32> FieldDecls;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
523
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
524 FieldDecls.push_back(Create__CbC_envBody(TagDecl, DeclSpec::TST_void, Loc, __CBC_STRUCT_POINTER_NAME));
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
525 FieldDecls.push_back(Create__CbC_envBody(TagDecl, DeclSpec::TST_int, Loc, __CBC_STRUCT_ENV_NAME));
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
526
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
527 Actions.ActOnFields(getCurScope(),Loc, TagDecl, FieldDecls,Loc, Loc,attrs.getList());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
528 StructScope.Exit();
72
9943a04bf572 remove unnecessary codes
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
529 Actions.ActOnTagFinishDefinition(getCurScope(), TagDecl, Loc);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
530
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
531 Actions.CurScope = SavedScope;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
532 Actions.CurContext = SavedContext;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
533 Actions.FunctionScopes.push_back(SavedFSI);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
534 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
535
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
536 /// Create__CbC_envBody - Create void type pointer ret_p and env which are member of __CbC_env.
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
537 Decl* Parser::Create__CbC_envBody(Decl* TagDecl, DeclSpec::TST T, SourceLocation Loc, const char* Name){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
538 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
539 ParsingDeclSpec PDS(*this);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
540 setTST(&PDS, T);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
541 SourceLocation CommaLoc;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
542 ParsingFieldDeclarator DeclaratorInfo(*this, PDS);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
543 DeclaratorInfo.D.setCommaLoc(CommaLoc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
544 DeclaratorInfo.D.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
545 DeclSpec DS(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
546 DS.Finish(Diags, PP, Policy);
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
547 DeclaratorInfo.D.SetIdentifier(CreateIdentifierInfo(Name, Loc),Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
548
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
549 DeclaratorInfo.D.AddTypeInfo(DeclaratorChunk::getPointer(DS.getTypeQualifiers(), Loc,DS.getConstSpecLoc(),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
550 DS.getVolatileSpecLoc(),DS.getRestrictSpecLoc()),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
551 DS.getAttributes(),SourceLocation());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
552 Decl *Field = Actions.ActOnField(getCurScope(), TagDecl,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
553 DeclaratorInfo.D.getDeclSpec().getSourceRange().getBegin(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
554 DeclaratorInfo.D, DeclaratorInfo.BitfieldSize);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
555 DeclaratorInfo.complete(Field);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
556 return Field;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
557 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
558
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
559 /// CreateIdentifierInfo - Create IdentifierInfo from char pointer.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
560 /// usage :
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
561 /// IdentifierInfo *II = CreateIdentifierInfo(IIName, Location);
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
562 IdentifierInfo* Parser::CreateIdentifierInfo(const char* Name, SourceLocation Loc) {
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
563 int length = strlen(Name);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
564 Token TokenForII;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
565 TokenForII.startToken();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
566 TokenForII.setLocation(Loc);
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
567 TokenForII.setLength(length);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
568 TokenForII.setKind(tok::raw_identifier);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
569 TokenForII.setRawIdentifierData(Name);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
570 IdentifierInfo *II;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
571 II = PP.getIdentifierInfo(TokenForII.getRawIdentifier());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
572 TokenForII.setIdentifierInfo(II);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
573 TokenForII.setKind(II->getTokenID());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
574 return II;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
575 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
576
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
577 /// CreateUniqueIdentifierInfo - Create unique IdentifierInfo.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
578 /// IdentifierInfos have unique name which were created by this function.
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
579 /// Naming conventions :
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
580 /// current 'function name' '..' 'variable name' 'uniqueID'
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
581 /// For example, if current function's name is 'main' and variable name is 'auaua', IdentifierInfo's name is 'main..auaua'.
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
582 IdentifierInfo* Parser::CreateUniqueIdentifierInfo(const char* Name, SourceLocation Loc){
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
583 IdentifierInfo *II;
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
584 std::ostringstream os;
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
585
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
586 os << curFuncName << ".." /* separator */ << Name << UniqueId;
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
587 II = CreateIdentifierInfo(os.str().c_str(), Loc);
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
588 UniqueId++; // Modify the unique ID.
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
589 return II;
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
590 }
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
591
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
592
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
593 /// CreateRetCS - Create code segment which is used for continuation with the environment.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
594 /// create these codes:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
595 /// __code ret(return_type retval, void *env){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
596 /// *(return_type)((struct CbC_environment *)(env))->ret_p = n;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
597 /// longjmp((int*)(((struct __CbC_environment *)env)->env),1);
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
598 /// }
81
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
599 void Parser::CreateRetCS(IdentifierInfo *csName){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
600 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
81
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
601 QualType CurFuncResQT = Actions.getCurFunctionDecl()->getReturnType();
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
602
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
603 Scope *SavedScope = getCurScope();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
604 DeclContext *SavedContext = Actions.CurContext;
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
605 TypeSourceInfo *CurFuncTI = Actions.Context.CreateTypeSourceInfo(CurFuncResQT);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
606 sema::FunctionScopeInfo *SavedFSI = Actions.FunctionScopes.pop_back_val();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
607
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
608 Actions.CurContext = static_cast<DeclContext *>(Actions.Context.getTranslationUnitDecl());
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
609 Scope *TopScope = getCurScope();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
610 while(TopScope->getParent() != NULL)
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
611 TopScope = TopScope->getParent();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
612 Actions.CurScope = TopScope;
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
613
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
614 DeclGroupPtrTy returnDecl = DeclGroupPtrTy();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
615 SourceLocation Loc = Tok.getLocation();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
616 ParsingDeclSpec PDS(*this);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
617 setTST(&PDS, DeclSpec::TST___code);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
618 ParsingDeclarator D(*this, PDS, static_cast<Declarator::TheContext>(Declarator::FileContext));
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
619 D.SetIdentifier(csName, Loc);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
620 ParseScope PrototypeScope(this,Scope::FunctionPrototypeScope|Scope::DeclScope|Scope::FunctionDeclarationScope);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
621 bool IsAmbiguous = false;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
622 bool HasProto = true;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
623 SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
624 SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
625 DeclSpec FDS(AttrFactory);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
626 bool RefQualifierIsLValueRef = true;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
627 ExceptionSpecificationType ESpecType = EST_None;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
628 SourceRange ESpecRange;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
629 SmallVector<ParsedType, 2> DynamicExceptions;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
630 SmallVector<SourceRange, 2> DynamicExceptionRanges;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
631 ExprResult NoexceptExpr;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
632 ParsedAttributes FnAttrs(AttrFactory);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
633 TypeResult TrailingReturnType;
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
634 ParmVarDecl *Param;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
635
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
636 IdentifierInfo *retvalII = CreateIdentifierInfo(__CBC_RETVAL_NAME, Loc);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
637 Param = CreateParam(retvalII);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
638 Param->setTypeSourceInfo(CurFuncTI);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
639 Param->setType(CurFuncResQT);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
640
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
641 ParamInfo.push_back(DeclaratorChunk::ParamInfo(retvalII, Loc, Param, 0));
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
642 IdentifierInfo *envII = CreateIdentifierInfo(__CBC_STRUCT_ENV_NAME, Loc);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
643 Param = CreateParam(envII, 1, DeclSpec::TST_void);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
644 ParamInfo.push_back(DeclaratorChunk::ParamInfo(envII, Loc, Param, 0));
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
645
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
646 D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto, IsAmbiguous, Loc, ParamInfo.data(), ParamInfo.size(), EllipsisLoc, Loc,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
647 FDS.getTypeQualifiers(), RefQualifierIsLValueRef, RefQualifierLoc, ConstQualifierLoc,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
648 VolatileQualifierLoc, SourceLocation(), ESpecType, ESpecRange.getBegin(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
649 DynamicExceptions.data(), DynamicExceptionRanges.data(), DynamicExceptions.size(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
650 NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
651 Loc, Loc, D, TrailingReturnType), FnAttrs, Loc);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
652 PrototypeScope.Exit();
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
653
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
654 Decl *TheDecl;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
655 ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
656 Decl *BodyRes = Actions.ActOnStartOfFunctionDef(getCurScope(), D);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
657
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
658 D.complete(BodyRes);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
659 D.getMutableDeclSpec().abort();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
660 Actions.ActOnDefaultCtorInitializers(BodyRes);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
661 StmtResult FnBody;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
662 StmtVector FnStmts;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
663 StmtResult innerR;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
664 ExprResult retvalAssginmentExpr,LHS;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
665 ExprVector ArgExprs;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
666 CommaLocsTy CommaLocs;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
667 DeclSpec envDS(AttrFactory);
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
668 IdentifierInfo *structName = CreateIdentifierInfo(__CBC_STRUCT_NAME, Loc);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
669 setTST(&envDS, DeclSpec::TST_struct, structName);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
670
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
671 Declarator envDInfo(envDS, Declarator::TypeNameContext);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
672 envDInfo.SetRangeEnd(Loc);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
673 DeclSpec starDS(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
674 starDS.Finish(Diags, PP, Policy);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
675 envDInfo.SetIdentifier(0,Loc);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
676 envDInfo.AddTypeInfo(DeclaratorChunk::getPointer(starDS.getTypeQualifiers(), Loc,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
677 starDS.getConstSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
678 starDS.getVolatileSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
679 starDS.getRestrictSpecLoc()),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
680 starDS.getAttributes(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
681 SourceLocation());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
682 ExprVector ArgExprs2;
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
683 LHS = LookupNameAndBuildExpr(envII);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
684 ArgExprs2.push_back(LHS.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
685 LHS = Actions.ActOnParenListExpr(Loc, Loc, ArgExprs2);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
686 Expr *envCastExpr = LHS.get();
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
687 TypeSourceInfo *castTInfo = Actions.GetTypeForDeclaratorCast(envDInfo, envCastExpr->getType());
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
688 LHS = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), envCastExpr);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
689 envCastExpr = LHS.get();
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
690 LHS = Actions.BuildCStyleCastExpr(Loc, castTInfo, Loc, envCastExpr);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
691 ArgExprs.push_back(LHS.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
692 LHS = Actions.ActOnParenListExpr(Loc, Loc, ArgExprs);
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
693 LHS = LookupMemberAndBuildExpr(CreateIdentifierInfo(__CBC_STRUCT_POINTER_NAME, Loc),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
694 LHS.get(), true);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
695 Expr *ret_pCastExpr = LHS.get();
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
696 DeclarationName noValDeclName;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
697 TypeSourceInfo *CurFuncTypesPointerTI = Actions.Context.CreateTypeSourceInfo(Actions.BuildPointerType(CurFuncResQT, Loc, noValDeclName));
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
698 LHS = Actions.BuildCStyleCastExpr(Loc, CurFuncTypesPointerTI, Loc, ret_pCastExpr);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
699 LHS = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, LHS.get());
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
700 ExprResult RHS;
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
701 RHS = LookupNameAndBuildExpr(retvalII);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
702
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
703 retvalAssginmentExpr = Actions.ActOnBinOp(getCurScope(), Loc, tok::equal, LHS.get(), RHS.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
704 innerR = Actions.ActOnExprStmt(retvalAssginmentExpr);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
705 if(innerR.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
706 FnStmts.push_back(innerR.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
707
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
708 ExprResult ljExpr,ljLHS;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
709 ljExpr = IIToExpr(CreateIdentifierInfo("longjmp", Loc), tok::l_paren);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
710 ExprVector ljArgExprs;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
711 DeclSpec ljDS(AttrFactory);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
712 setTST(&ljDS, DeclSpec::TST_struct, structName);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
713
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
714 Declarator ljD(ljDS, Declarator::TypeNameContext);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
715 ljD.SetRangeEnd(Loc);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
716 DeclSpec starDS2(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
717 starDS2.Finish(Diags, PP, Policy);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
718 ljD.ExtendWithDeclSpec(starDS2);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
719 ljD.SetIdentifier(0, Loc);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
720 ljD.AddTypeInfo(DeclaratorChunk::getPointer(ljDS.getTypeQualifiers(), Loc,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
721 ljDS.getConstSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
722 ljDS.getVolatileSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
723 ljDS.getRestrictSpecLoc()),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
724 ljDS.getAttributes(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
725 SourceLocation());
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
726 ljLHS = LookupNameAndBuildExpr(envII);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
727 Expr *ljCastExpr = ljLHS.get();
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
728 TypeSourceInfo *ljCastTInfo = Actions.GetTypeForDeclaratorCast(ljD, ljCastExpr->getType());
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
729 ljLHS = Actions.BuildCStyleCastExpr(Loc, ljCastTInfo, Loc, ljCastExpr);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
730 ljLHS = Actions.ActOnParenExpr(Loc, Loc, ljLHS.get());
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
731 ljLHS = LookupMemberAndBuildExpr(envII, ljLHS.get(), true);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
732 ljLHS = Actions.ActOnParenExpr(Loc, Loc, ljLHS.get());
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
733 ljArgExprs.push_back(ljLHS.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
734 CommaLocs.push_back(Loc);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
735 ljLHS = Actions.ActOnIntegerConstant(Loc, 1 /* return value for setjmp */);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
736 ljArgExprs.push_back(ljLHS.get());
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
737 ljExpr = Actions.ActOnCallExpr(getCurScope(), ljExpr.get(), Loc, ljArgExprs, Loc, 0);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
738 innerR = Actions.ActOnExprStmt(ljExpr);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
739 if(innerR.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
740 FnStmts.push_back(innerR.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
741 FnBody = Actions.ActOnCompoundStmt(Loc, Loc, FnStmts, false);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
742 BodyScope.Exit();
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
743 TheDecl = Actions.ActOnFinishFunctionBody(BodyRes, FnBody.get());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
744 returnDecl = Actions.ConvertDeclToDeclGroup(TheDecl);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
745 (&Actions.getASTConsumer())->HandleTopLevelDecl(returnDecl.get());
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
746 Actions.CurScope = SavedScope;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
747 Actions.CurContext = SavedContext;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
748 Actions.FunctionScopes.push_back(SavedFSI);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
749 }
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
750
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
751 /// IIToExpr - Create ExprResult from IdentifierInfo.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
752 /// It is used when II is a not primary expression such as not primary types, a function's name, etc.
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
753 ExprResult Parser::IIToExpr(IdentifierInfo *II, tok::TokenKind Kind){
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
754 SourceLocation Loc = Tok.getLocation();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
755 Token Next,IITok;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
756 Next.setKind(Kind);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
757 ExternalSpace::StatementFilterCCC CCCValidator(Next);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
758 CXXScopeSpec SS;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
759 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, II, Loc, Next, false, &CCCValidator);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
760 IITok.startToken();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
761 IITok.setLocation(Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
762 IITok.setIdentifierInfo(II);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
763 IITok.setKind(tok::annot_primary_expr);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
764 setExprAnnotation(IITok, Classification.getExpression());
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
765 IITok.setAnnotationEndLoc(Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
766 PP.AnnotateCachedTokens(IITok);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
767 return getExprAnnotation(IITok);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
768 }
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
769
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
770 /// CreateComplexStmtRet - Create return value for complex statements.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
771 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
772 /// ({ /* some statements */
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
773 /// return_value; )};
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
774 /// ^^^^^^^^^^^^^ Create it.
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
775 StmtResult Parser::CreateComplexStmtRet(IdentifierInfo *II, bool IsAddressOfOperand){
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
776 ExprResult ER;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
777 if (IsAddressOfOperand) {
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
778 ER = LookupNameAndBuildExpr(II, true);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
779 ER = Actions.ActOnUnaryOp(getCurScope(), Tok.getLocation(), tok::amp, ER.get());
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
780 }
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
781 else
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
782 ER = IIToExpr(II,tok::semi);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
783 return Actions.ActOnExprStmt(ER);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
784 }
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
785
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
786 /// CreateParam - Create paramator for functions.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
787 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
788 /// int funcname(int aua) {
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
789 /// ^^^^^^^ Create it.
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
790 ParmVarDecl* Parser::CreateParam(IdentifierInfo *II, int pointerNum, DeclSpec::TST T){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
791 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
792 SourceLocation Loc = Tok.getLocation();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
793 DeclSpec DS(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
794 setTST(&DS, T);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
795 Declarator ParamDeclarator(DS, Declarator::PrototypeContext);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
796 ParamDeclarator.SetIdentifier(II, Loc);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
797 for(int i = 0;i<pointerNum; i++){
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
798 DeclSpec pointerDS(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
799 pointerDS.Finish(Diags, PP, Policy);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
800 ParamDeclarator.AddTypeInfo(DeclaratorChunk::getPointer(pointerDS.getTypeQualifiers(), Loc,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
801 pointerDS.getConstSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
802 pointerDS.getVolatileSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
803 pointerDS.getRestrictSpecLoc()),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
804 pointerDS.getAttributes(),SourceLocation());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
805 }
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
806 ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Actions.ActOnParamDeclarator(getCurScope(), ParamDeclarator));
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
807 return Param;
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
808
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
809 }
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
810
63
0d1cf6cb7029 add comments for setTST
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
811 /// setTST - set TypeSpecifierType(TST) DeclSpec.
0d1cf6cb7029 add comments for setTST
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
812 /// TST is specifiers the kind of type such as int, double, char, etc.
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
813 void Parser::setTST(DeclSpec *DS, DeclSpec::TST T, IdentifierInfo* Name){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
814 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
815 SourceLocation Loc = Tok.getLocation();
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
816 bool isInvalid = false;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
817 const char *PrevSpec = 0;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
818 unsigned DiagID = 0;
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
819 CXXScopeSpec SS;
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
820 DS->SetRangeStart(Loc);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
821 DS->SetRangeEnd(Loc);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
822 if (T == DeclSpec::TST_struct) {
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
823 ParsedAttributesWithRange attrs(AttrFactory);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
824 DeclResult TagOrTempResult = true;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
825 bool Owned = false;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
826 bool IsDependent = false;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
827 MultiTemplateParamsArg TParams;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
828 TagOrTempResult = Actions.ActOnTag(getCurScope(), T, Sema::TUK_Reference, Loc,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
829 SS, Name, Loc, attrs.getList(), AS_none,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
830 DS->getModulePrivateSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
831 TParams, Owned, IsDependent,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
832 SourceLocation(), false,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
833 clang::TypeResult(), false);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
834 isInvalid = DS->SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, TagOrTempResult.get(), Owned, Policy);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
835 }
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
836 else if (T == DeclSpec::TST_typename) {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
837 Token Next,TypeTok;
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
838 Next.setKind(tok::identifier);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
839 ExternalSpace::StatementFilterCCC CCCValidator(Next);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
840 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, Name, Loc, Next, false, &CCCValidator);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
841 TypeTok.startToken();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
842 TypeTok.setLocation(Loc);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
843 TypeTok.setIdentifierInfo(Name);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
844 TypeTok.setKind(tok::annot_typename);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
845 setTypeAnnotation(TypeTok, Classification.getType());
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
846 TypeTok.setAnnotationEndLoc(Loc);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
847 PP.AnnotateCachedTokens(TypeTok);
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
848 if (TypeTok.getAnnotationValue()) {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
849 ParsedType PT = getTypeAnnotation(TypeTok);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
850 isInvalid = DS->SetTypeSpecType(T, Loc, PrevSpec, DiagID, PT, Policy);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
851 } else
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
852 DS->SetTypeSpecError();
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
853 }
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
854 else
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
855 isInvalid = DS->SetTypeSpecType(T, Loc, PrevSpec, DiagID, Policy);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
856
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
857 DS->Finish(Diags, PP, Policy);
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
858 if (isInvalid) {
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
859 assert(PrevSpec && "Method did not return previous specifier!");
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
860 assert(DiagID);
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
861 if (DiagID == diag::ext_duplicate_declspec)
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
862 Diag(Tok, DiagID)
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
863 << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
48
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
864 else
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
865 Diag(Tok, DiagID) << PrevSpec;
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
866 }
4b59af982ef3 create return function for continuation with the environment automatically, but it can return only int value and it's name is not unique now
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
867 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
868
58
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
869 /// CheckTheSjHeader - Check whether setjmp.h has been already included or not.
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
870 /// If not, include it.
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
871 void Parser::CheckTheSjHeader(){
53
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
872 SourceLocation Loc = Tok.getLocation();
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
873 LookupResult R(Actions, CreateIdentifierInfo("setjmp", Loc), Loc, Actions.LookupOrdinaryName, Actions.ForRedeclaration);
58
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
874 if (!Actions.LookupName(R, getCurScope())){ // look up the setjmp
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
875 if (PP.IncludeHeader(Tok, "setjmp.h"))
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
876 ConsumeToken();
53
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
877 }
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
878 }
81
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
879
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
880 /// isVoidFunction - Return true if current function return type is void.
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
881 bool Parser::isVoidFunction(){
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
882 return Actions.getCurFunctionDecl()->getReturnType().getTypePtr()->isVoidType();
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
883 }
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
884
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
885 #endif