annotate clang/lib/Parse/ParseCbC.cpp @ 157:5fe240291530

mod use AST/PrettyDeclStackTrace.h
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 12 Mar 2020 15:06:29 +0900
parents 70c77e05b61e
children bd617681647f
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"
126
mir3636
parents: 108
diff changeset
4 #include "clang/Parse/RAIIObjectsForParser.h"
41
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/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
7 #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
8 #include "clang/Sema/DeclSpec.h"
157
5fe240291530 mod use AST/PrettyDeclStackTrace.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 155
diff changeset
9 #include "clang/AST/PrettyDeclStackTrace.h"
41
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/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
11 #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
12 #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
13 #include "clang/AST/ASTConsumer.h"
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
14 #include "clang/Sema/SemaDiagnostic.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
155
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
78 /// goto with environment with out logjmp
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
79 /// basic idea is prepare struct containes pointer to return value variable and stack pointer
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
80 ///
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
81 /// int main() {
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
82 /// struct __CbC_return {
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
83 /// int* i;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
84 /// void* sp;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
85 // void* fp;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
86 /// } ret;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
87 // int i;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
88 /// if (0) {
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
89 // _CBC_RETURN:
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
90 // %fp = ret.fp;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
91 // %rsp = ret.sp;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
92 // i = *(ret.i); //?
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
93 // return i;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
94 // }
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
95 /// ret.i = &i;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
96 /// ret.sp = %rsp;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
97 // ret.fp = %rfp;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
98 /// __code c(int i,void* env) = _CBC_RETURN;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
99 /// goto f(c, &ret);
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
100 /// }
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
101 ///
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
102 /// __code ret(int, void* env) {
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
103 // sp = env;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
104 // %rax = 1;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
105 // jmp _CBC_RETURN;
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
106 /// }
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
107 ///
70c77e05b61e write goto with environment with out logjmp basic idea
anatofuz
parents: 152
diff changeset
108 ///
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
109
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
110 /// 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
111 /// 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
112 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
113 /// examples which are created:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
114 /// complex statement:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
115 /// ({
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
116 /// __code (*__CbC_return)(return_type, void*);
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
117 /// __CbC_return = code_segment_for_return;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
118 /// __CbC_return;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
119 /// });
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
120 /// code segment:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
121 /// __code ret(return_type retval, void *env){
105
f9b011216f60 fix comment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
122 /// *(return_type)((struct __CbC_env *)(env))->ret_p = retval;
f9b011216f60 fix comment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
123 /// longjmp((int*)(((struct __CbC_env *)env)->env),1);
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
124 /// }
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
125 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
126
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
127 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
128 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
129 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
130 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
131 }
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
132
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
133 StmtResult innerRes;
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
134 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
135 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
136 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
137 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
138
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
139 Actions.ActOnStartStmtExpr();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
140 StmtResult CompoundStmtRes;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
141 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
142 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
143 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
144
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
145 // 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
146 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
147
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
148 // __code (*__CbC_return)();
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
149 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
150 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
151 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
152
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
153 // __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
154 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
155 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
156 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
157
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
158 // __CbC_return;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
159 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
160 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
161 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
162
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
163 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
164 ConsumeToken(); // eat the '__return'.
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
165 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
166 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
168 /// 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
169 /// 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
170 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
171 /// examples which are created:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
172 /// complex statement:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
173 /// ({
106
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
174 /// volatile struct __CbC_env __CbC_environment;
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
175 /// jmp_buf env_buf;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
176 /// return_type retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
177 /// __CbC_environment.ret_p = &retval;
104
929371e51940 add ParseCbC.cpp to CMakeLists.txt
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
178 /// __CbC_environment.env = &env_buf;
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
179 /// if (setjmp(__CbC_environment.env)){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
180 /// return retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
181 /// }
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
182 /// &__CbC_environment;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
183 /// });
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
184 /// struct __CbC_env:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
185 /// struct __CbC_env{
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
186 /// void *ret_p,*env;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
187 /// }
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
188 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
189
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
190 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
191 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
192 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
193 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
194 }
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
195
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
196 StmtResult innerRes;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
197 SourceLocation Loc = Tok.getLocation();
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 Actions.ActOnStartStmtExpr();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
206 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
207 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
208 StmtVector CompoundStmts;
107
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
209 ExprResult Result(true);
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
210
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
211 // struct __CbC_env __CbC_environment;
106
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
212 innerRes = CreateDeclStmt(__CbC_envII, false, false, DeclSpec::TST_struct, structII, DeclSpec::TQ_volatile);
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
213 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
214 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
215
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
216 // returnType retval;
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
217 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
218 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
219 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
220
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
221 // jmp_buf env_buf;
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
222 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
223 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
224 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
225
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
226 // __CbC_environment.ret_p = &retval;
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
227 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
228 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
229 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
230
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
231 // __CbC_environment.env = env_buf;
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
232 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
233 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
234 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
235
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
236 // create statements of setjmp
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
237 innerRes = CreateSjForContinuationWithTheEnv();
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
238 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
239 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
240
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
241 // __CbC_environment;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
242 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
243 if (innerRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
244 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
245
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
246 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
247 ConsumeToken(); // eat the '__environment'.
107
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
248 Result = Actions.ActOnStmtExpr(Loc, CompoundStmtRes.get(), Loc);
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
249
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
250 // cast
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
251 ParsedType CastTy;
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
252 DeclSpec void_DS(AttrFactory);
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
253 setTST(&void_DS, DeclSpec::TST_void);
136
6cd7e602c98b Fix compile error to update llvm 5.0.1
mir3636
parents: 129
diff changeset
254 Declarator DeclaratorInfo(void_DS, DeclaratorContext::TypeNameContext);
107
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
255 DeclSpec star_DS(AttrFactory);
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
256 star_DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
257 DeclaratorInfo.ExtendWithDeclSpec(star_DS);
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
258 DeclaratorInfo.SetIdentifier(nullptr, Tok.getLocation());
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
259 DeclaratorInfo.AddTypeInfo(DeclaratorChunk::getPointer(star_DS.getTypeQualifiers(), Loc,star_DS.getConstSpecLoc(),star_DS.getVolatileSpecLoc(),
128
mir3636
parents: 126
diff changeset
260 star_DS.getRestrictSpecLoc(),star_DS.getAtomicSpecLoc(),star_DS.getUnalignedSpecLoc()),star_DS.getAttributes(),SourceLocation());
107
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
261 return Actions.ActOnCastExpr(getCurScope(), Loc, DeclaratorInfo, CastTy,Loc, Result.get());
a03ddd01be7e resolve warnings
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
262
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
263 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
264
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
265 /// 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
266 /// It can create 4 kinds of statement.
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
267 /// 1. common assignment statement:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
268 /// variable '=' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
269 /// 2. LHS variable is member of struct:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
270 /// structVar '.' member '=' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
271 /// 3. RHS variable is address of operand:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
272 /// variable '=' '&' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
273 /// 4. 2+3:
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
274 /// structVar '.' member '=' '&' variable ';'
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
275 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
276 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
277 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
278
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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 LHSToken.setKind(tok::annot_primary_expr);
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
288 std::unique_ptr<ExternalSpace::StatementFilterCCC> Validator(new ExternalSpace::StatementFilterCCC(Next));
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
289 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, LHSII, Loc, Next, false, SS.isEmpty() ? std::move(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
290 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
291 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
292 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
293
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 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
295
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
296 if (LHSisMemberAccess)
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
297 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
298
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
299 RHS = LookupNameAndBuildExpr(RHSII);
59
322ba4588e4f remove assignment flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 58
diff changeset
300 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
301 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
302
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
303 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
304
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
305 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
306 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
308 /// CreateDeclStmt - Create declaration statement such as "int aaa;".
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
309 /// 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
310 /// If copyType is true, type of variable is copied from callee.
106
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
311 StmtResult Parser::CreateDeclStmt(IdentifierInfo *II, bool isRetCS, bool copyType, DeclSpec::TST valueType, IdentifierInfo* Name, DeclSpec::TQ TQ){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
312 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
313 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
314 DeclGroupPtrTy DeclGPT;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
315 ParsingDeclSpec DS(*this);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
316 DeclSpec *DSp;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
317 DSp = &DS;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
318
106
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
319 setTST(&DS, valueType, Name, TQ);
136
6cd7e602c98b Fix compile error to update llvm 5.0.1
mir3636
parents: 129
diff changeset
320 ParsingDeclarator D(*this, DS, static_cast<DeclaratorContext>(DeclaratorContext::BlockContext));
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
321 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
322
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
323 if (isRetCS) {
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
324 D.setEllipsisLoc(SourceLocation());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
325 bool hadGroupingParens = D.hasGroupingParens();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
326 D.setGroupingParens(true);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
327 D.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
328 DeclSpec FDS(AttrFactory);
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
329 DS.Finish(Actions, Policy);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
330
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
331 D.AddTypeInfo(DeclaratorChunk::getPointer(FDS.getTypeQualifiers(), Loc, FDS.getConstSpecLoc(), FDS.getVolatileSpecLoc(),
128
mir3636
parents: 126
diff changeset
332 FDS.getRestrictSpecLoc(), DS.getAtomicSpecLoc(), FDS.getUnalignedSpecLoc()), FDS.getAttributes(), SourceLocation());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
333 D.setGroupingParens(hadGroupingParens);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
334
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
335
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
336 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
337 (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
338 bool HasProto = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
339 SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
340 SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc, RestrictQualifierLoc;
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
341 DeclSpec FPDS(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
342 bool RefQualifierIsLValueRef = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
343 ExceptionSpecificationType ESpecType = EST_None;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
344 SourceRange ESpecRange;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
345 SmallVector<ParsedType, 2> DynamicExceptions;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
346 SmallVector<SourceRange, 2> DynamicExceptionRanges;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
347 ExprResult NoexceptExpr;
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
348 CachedTokens *ExceptionSpecTokens = 0;
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
349 ParsedAttributes FnAttrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
350 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
351
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
352 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
353 FunctionDecl *CurFunctionDecl = Actions.getCurFunctionDecl();
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
354 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
355 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
356
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
365 D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto, false, Loc, ParamInfo.data(),
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
366 ParamInfo.size(), EllipsisLoc, Loc, FPDS.getTypeQualifiers(),
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
367 RefQualifierIsLValueRef, RefQualifierLoc, ConstQualifierLoc,
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
368 VolatileQualifierLoc, RefQualifierLoc, SourceLocation(),
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
369 ESpecType, ESpecRange.getBegin(),
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
370 DynamicExceptions.data(), DynamicExceptionRanges.data(),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
371 DynamicExceptions.size(),
128
mir3636
parents: 126
diff changeset
372 NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, ExceptionSpecTokens, None, Loc, Loc, D, TrailingReturnType),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
373 FnAttrs, Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
374 PrototypeScope.Exit();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
375 DSp = &FDS;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
376 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
377
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
378 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
379 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
380
60
d4de94500cd9 remove decl flags
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
381 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
382 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
383 else
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
384 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
385
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
386 D.complete(FirstDecl);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
387 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
388 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
389 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
390 }
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
391
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
392
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
393 /// handleDeclAndChangeDeclType - This function imitated Parser::ParseDeclarationAfterDeclaratorAndAttributes() and Sema::ActOnDeclarator().
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
394 /// 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
395 /// 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
396 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
397 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
398 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
399 DeclContext *DC = Actions.CurContext;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
400 QualType R = Actions.getCurFunctionDecl()->getReturnType(); // copy a type
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
401 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
402 Scope *S = getCurScope();
129
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
403 LookupResult Previous(Actions, NameInfo, Actions.LookupOrdinaryName, Actions.ForVisibleRedeclaration);
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
404 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
405 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
406
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
407 // 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
408 // 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
409 // 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
410 //
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
411 // 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
412 // 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
413 // 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
414 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
415 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
416 CreateBuiltins =
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
417 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
418 } 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
419 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
420
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
421 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
422 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
423
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
424 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
425
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
426 // 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
427 // (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
428 // 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
429 // 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
430 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
431 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
432 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
433 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
434 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
435 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
436 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
437 } else {
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
438 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
439 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
440 }
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
441
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
442 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
443 // 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
444 // 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
445 // 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
446 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
447 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
448 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
449 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
450 }
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
451
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
452 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
453 }
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
454
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
455 /// 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
456 /// code example:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
457 /// if (setjmp(__CbC_environment.env)){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
458 /// return retval;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
459 /// }
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
460 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
461 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
462 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
463 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
464 ExprResult CondExp;
129
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
465 StmtResult InitStmt;
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
466 Sema::ConditionResult Cond;
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
108
1881386f7909 use llvm.setjmp and llvm.longjmp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
468 CondExp = LookupNameAndBuildExpr(CreateIdentifierInfo("__builtin_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
469 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
470 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
471
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
472 __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
473 __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
474
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
475 ArgExprs.push_back(__envExprRes.get());
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
476 CondExp = Actions.ActOnCallExpr(getCurScope(), CondExp.get(), Loc, ArgExprs, Loc, 0);
138
53f12981605a Fix goto is environment
anatofuz
parents: 136
diff changeset
477 Cond = Actions.ActOnCondition(getCurScope(), Loc, CondExp.get(), Sema::ConditionKind::Boolean);
53f12981605a Fix goto is environment
anatofuz
parents: 136
diff changeset
478
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 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
481 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
482
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 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
484 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
485 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
486 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
487 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
488 ExprResult innerExprRes;
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
489 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
490 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
491 if (innerStmtRes.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
492 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
493 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
494 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
495 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
496 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
497 StmtResult ElseStmt;
138
53f12981605a Fix goto is environment
anatofuz
parents: 136
diff changeset
498 IfRes = Actions.ActOnIfStmt(Loc, false, CondExp.get(), Cond, ThenStmt.get(),Loc, ElseStmt.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
499 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
500 }
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
501
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
502
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
503 /// LookupNameAndBuildExpr - Look up name, create ExprResult and return it.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
504 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
505 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
506 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
507 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
508 SourceLocation TemplateKWLoc;
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
509 std::unique_ptr<ExternalSpace::CastExpressionIdValidator> Validator(new ExternalSpace::CastExpressionIdValidator(false,true));
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
510 Name.setIdentifier(II, Loc);
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
511 return Actions.ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Name, false, IsAddressOfOperand, std::move(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
512 }
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
513
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
514 /// 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
515 /// 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
516 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
517 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
518 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
519 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
520 SourceLocation TemplateKWLoc;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
521 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
522 Name.setIdentifier(II,Loc);
97
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
523 return Actions.ActOnMemberAccessExpr(getCurScope(), Base, Loc, OpKind, SS, TemplateKWLoc, Name, nullptr);
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
524 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
525
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 /// 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
528 /// 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
529 /// The example of struct which is created :
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
530 /// struct __CbC_env{
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
531 /// void *ret_p,*env;
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
532 /// };
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
533 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
534
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
535 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
536 // Check previous definition. If the __CbC_env has been already defined, we have not to create again.
129
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
537 LookupResult Previous(Actions, Name, Loc, Actions.LookupTagName, Actions.ForVisibleRedeclaration);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
538 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
539 return;
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
540
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
541 Scope *SavedScope = getCurScope();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
542 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
543 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
544
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
545 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
546 Scope *TopScope = getCurScope();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
547 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
548 TopScope = TopScope->getParent();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
549 Actions.CurScope = TopScope;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
550
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
551 ParsingDeclSpec SDS(*this);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
552 SDS.SetRangeStart(Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
553 SDS.SetRangeEnd(Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
554 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
555 DeclResult TagOrTempResult = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
556 bool Owned = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
557 bool IsDependent = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
558 ParsedAttributesWithRange attrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
559 MultiTemplateParamsArg TParams;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
560
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
561 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
562 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
563 SDS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
129
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
564 SourceLocation(), false, clang::TypeResult(), false, false);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
565
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
566 Decl *TagDecl = TagOrTempResult.get();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
567 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
568 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
569 Actions.ActOnTagStartDefinition(getCurScope(), TagDecl);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
570 SmallVector<Decl *, 32> FieldDecls;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
571
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
572 FieldDecls.push_back(Create__CbC_envBody(TagDecl, DeclSpec::TST_void, Loc, __CBC_STRUCT_POINTER_NAME));
108
1881386f7909 use llvm.setjmp and llvm.longjmp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
573 FieldDecls.push_back(Create__CbC_envBody(TagDecl, DeclSpec::TST_void, 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
574
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
575 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
576 StructScope.Exit();
72
9943a04bf572 remove unnecessary codes
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
577 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
578
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
579 Actions.CurScope = SavedScope;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
580 Actions.CurContext = SavedContext;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
581 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
582 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
583
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
584 /// 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
585 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
586 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
587 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
588 setTST(&PDS, T);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
589 SourceLocation CommaLoc;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
590 ParsingFieldDeclarator DeclaratorInfo(*this, PDS);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
591 DeclaratorInfo.D.setCommaLoc(CommaLoc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
592 DeclaratorInfo.D.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
593 DeclSpec DS(AttrFactory);
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
594 DS.Finish(Actions, 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
595 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
596
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
597 DeclaratorInfo.D.AddTypeInfo(DeclaratorChunk::getPointer(DS.getTypeQualifiers(), Loc,DS.getConstSpecLoc(),
128
mir3636
parents: 126
diff changeset
598 DS.getVolatileSpecLoc(),DS.getRestrictSpecLoc(), DS.getAtomicSpecLoc(), DS.getUnalignedSpecLoc()),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
599 DS.getAttributes(),SourceLocation());
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
600 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
601 DeclaratorInfo.D.getDeclSpec().getSourceRange().getBegin(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
602 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
603 DeclaratorInfo.complete(Field);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
604 return Field;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
605 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
606
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
607 /// CreateIdentifierInfo - Create IdentifierInfo from char pointer.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
608 /// usage :
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
609 /// 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
610 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
611 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
612 Token TokenForII;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
613 TokenForII.startToken();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
614 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
615 TokenForII.setLength(length);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
616 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
617 TokenForII.setRawIdentifierData(Name);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
618 IdentifierInfo *II;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
619 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
620 TokenForII.setIdentifierInfo(II);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
621 TokenForII.setKind(II->getTokenID());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
622 return II;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
623 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
624
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
625 /// CreateUniqueIdentifierInfo - Create unique IdentifierInfo.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
626 /// 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
627 /// Naming conventions :
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
628 /// current 'function name' '..' 'variable name' 'uniqueID'
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
629 /// 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
630 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
631 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
632 std::ostringstream os;
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
633
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
634 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
635 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
636 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
637 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
638 }
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
639
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
640
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
641 /// 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
642 /// create these codes:
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
643 /// __code ret(return_type retval, void *env){
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
644 /// *(return_type)((struct CbC_environment *)(env))->ret_p = n;
108
1881386f7909 use llvm.setjmp and llvm.longjmp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
645 /// longjmp((void*)(((struct __CbC_environment *)env)->env),1);
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
646 /// }
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
647 void Parser::CreateRetCS(IdentifierInfo *csName){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
648 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
649 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
650
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
651 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
652 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
653 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
654 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
655
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 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
657 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
658 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
659 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
660 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
661
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
662 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
663 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
664 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
665 setTST(&PDS, DeclSpec::TST___code);
136
6cd7e602c98b Fix compile error to update llvm 5.0.1
mir3636
parents: 129
diff changeset
666 ParsingDeclarator D(*this, PDS, static_cast<DeclaratorContext>(DeclaratorContext::FileContext));
64
0aa33659e8e4 modified Parser::CreateUniqueIdentifierInfo(). add unique id
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
667 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
668 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
669 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
670 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
671 SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
672 SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc, RestrictQualifierLoc;
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
673 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
674 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
675 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
676 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
677 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
678 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
679 ExprResult NoexceptExpr;
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
680 CachedTokens *ExceptionSpecTokens = 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
681 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
682 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
683 ParmVarDecl *Param;
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
684
52
c22698ecb2a9 modified CreateIdentifierInfo and create new function which was named 'CreateUniqueIdentifierInfo'.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
685 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
686 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
687 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
688 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
689
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
690 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
691 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
692 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
693 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
694
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
695 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
696 FDS.getTypeQualifiers(), RefQualifierIsLValueRef, RefQualifierLoc, ConstQualifierLoc,
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
697 VolatileQualifierLoc, RestrictQualifierLoc, SourceLocation(),
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
698 ESpecType, ESpecRange.getBegin(),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
699 DynamicExceptions.data(), DynamicExceptionRanges.data(), DynamicExceptions.size(),
128
mir3636
parents: 126
diff changeset
700 NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, ExceptionSpecTokens, None,
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
701 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
702 PrototypeScope.Exit();
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
703
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 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
705 ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
97
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
706 Sema::SkipBodyInfo SkipBody;
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
707 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo();
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
708 Decl *BodyRes = Actions.ActOnStartOfFunctionDef(getCurScope(), D,
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
709 TemplateInfo.TemplateParams ? *TemplateInfo.TemplateParams : MultiTemplateParamsArg(),
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
710 &SkipBody);
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
711
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 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
713 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
714 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
715 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
716 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
717 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
718 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
719 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
720 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
721 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
722 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
723 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
724
136
6cd7e602c98b Fix compile error to update llvm 5.0.1
mir3636
parents: 129
diff changeset
725 Declarator envDInfo(envDS, DeclaratorContext::TypeNameContext);
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
726 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
727 DeclSpec starDS(AttrFactory);
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
728 starDS.Finish(Actions, 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
729 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
730 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
731 starDS.getConstSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
732 starDS.getVolatileSpecLoc(),
97
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
733 starDS.getRestrictSpecLoc(),
128
mir3636
parents: 126
diff changeset
734 starDS.getAtomicSpecLoc(),
mir3636
parents: 126
diff changeset
735 starDS.getUnalignedSpecLoc()),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
736 starDS.getAttributes(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
737 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
738 ExprVector ArgExprs2;
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
739 LHS = LookupNameAndBuildExpr(envII);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
740 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
741 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
742 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
743 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
744 LHS = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), envCastExpr);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
745 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
746 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
747 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
748 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
749 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
750 LHS.get(), true);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
751 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
752 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
753 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
754 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
755 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
756 ExprResult RHS;
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
757 RHS = LookupNameAndBuildExpr(retvalII);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
758
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
759 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
760 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
761 if(innerR.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
762 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
763
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
764 ExprResult ljExpr,ljLHS;
108
1881386f7909 use llvm.setjmp and llvm.longjmp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
765 ljExpr = IIToExpr(CreateIdentifierInfo("__builtin_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
766 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
767 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
768 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
769
136
6cd7e602c98b Fix compile error to update llvm 5.0.1
mir3636
parents: 129
diff changeset
770 Declarator ljD(ljDS, DeclaratorContext::TypeNameContext);
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
771 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
772 DeclSpec starDS2(AttrFactory);
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
773 starDS2.Finish(Actions, 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
774 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
775 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
776 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
777 ljDS.getConstSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
778 ljDS.getVolatileSpecLoc(),
97
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
779 ljDS.getRestrictSpecLoc(),
128
mir3636
parents: 126
diff changeset
780 ljDS.getAtomicSpecLoc(),
mir3636
parents: 126
diff changeset
781 ljDS.getUnalignedSpecLoc()),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
782 ljDS.getAttributes(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
783 SourceLocation());
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
784 ljLHS = LookupNameAndBuildExpr(envII);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
785 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
786 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
787 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
788 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
789 ljLHS = LookupMemberAndBuildExpr(envII, ljLHS.get(), true);
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
790 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
791 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
792 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
793 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
794 ljArgExprs.push_back(ljLHS.get());
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
795 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
796 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
797 if(innerR.isUsable())
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
798 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
799 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
800 BodyScope.Exit();
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
801 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
802 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
803 (&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
804 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
805 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
806 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
807 }
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
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
809 /// IIToExpr - Create ExprResult from IdentifierInfo.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
810 /// 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
811 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
812 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
813 Token Next,IITok;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
814 Next.setKind(Kind);
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
815 std::unique_ptr<ExternalSpace::StatementFilterCCC> CCCValidator(new ExternalSpace::StatementFilterCCC(Next));
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
816 CXXScopeSpec SS;
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
817 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, II, Loc, Next, false, std::move(CCCValidator));
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
818 IITok.startToken();
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
819 IITok.setLocation(Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
820 IITok.setIdentifierInfo(II);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
821 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
822 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
823 IITok.setAnnotationEndLoc(Loc);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
824 PP.AnnotateCachedTokens(IITok);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
825 return getExprAnnotation(IITok);
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
826 }
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
827
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
828 /// CreateComplexStmtRet - Create return value for complex statements.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
829 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
830 /// ({ /* some statements */
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
831 /// return_value; )};
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
832 /// ^^^^^^^^^^^^^ Create it.
57
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
833 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
834 ExprResult ER;
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
835 if (IsAddressOfOperand) {
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
836 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
837 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
838 }
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
839 else
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
840 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
841 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
842 }
88b0e1f890d7 Use complex statements for goto with the environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 56
diff changeset
843
62
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
844 /// CreateParam - Create paramator for functions.
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
845 ///
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
846 /// int funcname(int aua) {
fe2728d9537d add comments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
847 /// ^^^^^^^ 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
848 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
849 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
850 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
851 DeclSpec DS(AttrFactory);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
852 setTST(&DS, T);
136
6cd7e602c98b Fix compile error to update llvm 5.0.1
mir3636
parents: 129
diff changeset
853 Declarator ParamDeclarator(DS, DeclaratorContext::PrototypeContext);
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 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
855 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
856 DeclSpec pointerDS(AttrFactory);
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
857 pointerDS.Finish(Actions, 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 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
859 pointerDS.getConstSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
860 pointerDS.getVolatileSpecLoc(),
97
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
861 pointerDS.getRestrictSpecLoc(),
128
mir3636
parents: 126
diff changeset
862 pointerDS.getAtomicSpecLoc(),
mir3636
parents: 126
diff changeset
863 pointerDS.getUnalignedSpecLoc()),
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
864 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
865 }
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
866 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
867 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
868
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
869 }
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
870
63
0d1cf6cb7029 add comments for setTST
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
871 /// setTST - set TypeSpecifierType(TST) DeclSpec.
0d1cf6cb7029 add comments for setTST
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
872 /// TST is specifiers the kind of type such as int, double, char, etc.
106
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
873 void Parser::setTST(DeclSpec *DS, DeclSpec::TST T, IdentifierInfo* Name, DeclSpec::TQ TQ){
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
874 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
875 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
876 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
877 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
878 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
879 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
880 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
881 DS->SetRangeEnd(Loc);
106
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
882 if (TQ != DeclSpec::TQ_unspecified) {
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
883 isInvalid = DS->SetTypeQual(DeclSpec::TQ_volatile, Loc, PrevSpec, DiagID,
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
884 getLangOpts());
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
885 }
596a38ee9c9e fix setjmp/longjmp with optimization bug (get some warnings)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
886
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
887 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
888 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
889 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
890 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
891 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
892 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
893 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
894 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
895 DS->getModulePrivateSpecLoc(),
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
896 TParams, Owned, IsDependent,
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
897 SourceLocation(), false,
129
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
898 clang::TypeResult(), false, false);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
899 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
900 }
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
901 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
902 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
903 Next.setKind(tok::identifier);
86
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
904 std::unique_ptr<ExternalSpace::StatementFilterCCC> CCCValidator(new ExternalSpace::StatementFilterCCC(Next));
99580de8d21d Fix compile error to update llvm 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
905 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, Name, Loc, Next, false, std::move(CCCValidator));
56
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
906 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
907 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
908 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
909 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
910 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
911 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
912 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
913 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
914 ParsedType PT = getTypeAnnotation(TypeTok);
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
915 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
916 } else
bdef5c940791 copy the previous function's return type to return value
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 54
diff changeset
917 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
918 }
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
919 else
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
920 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
921
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
922 DS->Finish(Actions, 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
923 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
924 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
925 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
926 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
927 Diag(Tok, DiagID)
80
67baa08a3894 update to LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 74
diff changeset
928 << 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
929 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
930 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
931 }
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
932 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
933
58
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
934 /// 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
935 /// If not, include it.
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
936 void Parser::CheckTheSjHeader(){
53
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
937 SourceLocation Loc = Tok.getLocation();
129
9ec641e857f8 Fix compile error to update llvm 5.0
mir3636
parents: 128
diff changeset
938 LookupResult R(Actions, CreateIdentifierInfo("setjmp", Loc), Loc, Actions.LookupOrdinaryName, Actions.ForVisibleRedeclaration);
58
01c954c1b51b include setjmp.h automatically without checking __code
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
939 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
940 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
941 ConsumeToken();
53
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
942 }
f679cc5126db include setjmp.h automatically
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
943 }
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
944
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
945 /// 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
946 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
947 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
948 }
97a220dc594f if __return or __environment used in void function, compiler emit error.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 80
diff changeset
949
87
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
950 /// ParseCbCGotoStatement
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
951 /// jump-statement:
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
952 /// [CbC] 'goto' codeSegment ';'
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
953 ///
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
954 StmtResult Parser::ParseCbCGotoStatement(ParsedAttributesWithRange &Attrs,StmtVector &Stmts) {
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
955 assert(Tok.is(tok::kw_goto) && "Not a goto stmt!");
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
956 ParseScope CompoundScope(this, Scope::DeclScope);
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
957 StmtVector CompoundedStmts;
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
958
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
959 SourceLocation gotoLoc = ConsumeToken(); // eat the 'goto'.
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
960 StmtResult gotoRes;
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
961 Token TokAfterGoto = Tok;
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
962 Stmtsp = &Stmts;
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
963
103
76d4b0e44709 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 98
diff changeset
964 gotoRes = ParseStatementOrDeclaration(Stmts, ACK_Any);
92
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
965
87
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
966 if (gotoRes.get() == NULL)
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
967 return StmtError();
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
968 else if (gotoRes.get()->getStmtClass() != Stmt::CallExprClass) { // if it is not function call
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
969 unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, "expected identifier or codesegment call");
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
970 Diag(TokAfterGoto, DiagID);
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
971 return StmtError();
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
972 }
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
973
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
974 assert((Attrs.empty() || gotoRes.isInvalid() || gotoRes.isUsable()) &&
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
975 "attributes on empty statement");
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
976 if (!(Attrs.empty() || gotoRes.isInvalid()))
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
977 gotoRes = Actions.ProcessStmtAttributes(gotoRes.get(), Attrs.getList(), Attrs.Range);
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
978 if (gotoRes.isUsable())
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
979 CompoundedStmts.push_back(gotoRes.get());
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
980
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
981 // add return; after goto codesegment();
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
982 if (Actions.getCurFunctionDecl()->getReturnType().getTypePtr()->is__CodeType()) {
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
983 ExprResult retExpr;
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
984 StmtResult retRes;
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
985 retRes = Actions.ActOnReturnStmt(gotoLoc, retExpr.get(), getCurScope());
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
986 if (retRes.isUsable())
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
987 CompoundedStmts.push_back(retRes.get());
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
988 }
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
989 return Actions.ActOnCompoundStmt(gotoLoc, Tok.getLocation(), CompoundedStmts, false);
ff9ec87918d4 move ParseCbCGotoStatement() to ParseCbC.cpp
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
990 }
88
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
991
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
992 /// SearchCodeSegmentDeclaration - Read tokens until we get to the specified code segment declaration.
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
993 /// If we can't find it , return false;
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
994 bool Parser::SearchCodeSegmentDeclaration(std::string Name){
90
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
995 while(SkipAnyUntil(tok::kw___code, StopBeforeMatch)){
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
996 if(NextToken().is(tok::identifier) && NextToken().getIdentifierInfo()->getName().str() == Name)
88
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
997 return true;
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
998 ConsumeToken();
88
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
999 }
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
1000 return false;
e471d82fb99b add SearchCodeSegmentDeclaration()
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
1001 }
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1002
92
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1003 bool Parser::NeedPrototypeDeclaration(Token IITok){
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1004 LookupResult LR(Actions, IITok.getIdentifierInfo(), IITok.getLocation(), Actions.LookupOrdinaryName);
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1005 CXXScopeSpec SS;
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1006 Actions.LookupParsedName(LR, getCurScope(), &SS, !(Actions.getCurMethodDecl()));
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1007
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1008 return (LR.getResultKind() == LookupResult::NotFound);
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1009 }
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1010
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1011 /// CreatePrototypeDeclaration - Create prototype declaration by it's definition.
92
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1012 void Parser::CreatePrototypeDeclaration(){
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1013 // move to the top level scope
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1014 Scope *SavedScope = getCurScope();
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1015 DeclContext *SavedContext = Actions.CurContext;
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1016 sema::FunctionScopeInfo *SavedFSI = Actions.FunctionScopes.pop_back_val();
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1017 Actions.CurContext = static_cast<DeclContext *>(Actions.Context.getTranslationUnitDecl());
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1018 Scope *TopScope = getCurScope();
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1019 while(TopScope->getParent() != NULL)
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1020 TopScope = TopScope->getParent();
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1021 Actions.CurScope = TopScope;
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1022
92
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1023 Token Next = NextToken();
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1024 Token CachedTokens[3] = {Next, PP.LookAhead(1)};
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1025 Token SavedToken = Tok;
92
8a1cd0ffee6e Create prototype declaration automatically if prototype was not found when parsing continuation arguments.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
1026 Token IITok = Tok.is(tok::identifier) ? Tok : Next;
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1027 PP.ClearCache();
98
88e6d15e811d fix proto generator bug
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
1028 PP.ProtoParsing = true;
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1029 ProtoParsing = true;
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1030
97
b0dd3743370f LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
1031 const DirectoryLookup *CurDir = nullptr;
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1032 FileID FID = PP.getSourceManager().createFileID(PP.getCurrentFileLexer()->getFileEntry(), IITok.getLocation(), SrcMgr::C_User);
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1033 PP.EnterSourceFile(FID,CurDir,IITok.getLocation());
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1034 ConsumeToken();
90
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1035
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1036 if(SearchCodeSegmentDeclaration(IITok.getIdentifierInfo()->getName().str())){
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1037 DeclGroupPtrTy ProtoDecl;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1038 ParseTopLevelDecl(ProtoDecl);
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1039 // add declaration to AST.
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1040 if(ProtoDecl)
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1041 (&Actions.getASTConsumer())->HandleTopLevelDecl(ProtoDecl.get());
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1042 // File Closing
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1043 Token T;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1044 PP.HandleEndOfFile(T, false);
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1045
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1046 // recover tokens.
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1047 Tok = SavedToken;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1048 PP.RestoreTokens(CachedTokens, 2);
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1049
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1050 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1051 else {
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1052 // recover tokens.
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1053 CachedTokens[2] = Tok;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1054 Tok = SavedToken;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1055 PP.RestoreTokens(CachedTokens, 3);
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1056 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1057
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1058 // move to the previous scope.
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1059 Actions.CurScope = SavedScope;
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1060 Actions.CurContext = SavedContext;
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1061 Actions.FunctionScopes.push_back(SavedFSI);
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1062
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1063 ProtoParsing = false;
98
88e6d15e811d fix proto generator bug
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 97
diff changeset
1064 PP.ProtoParsing = false;
89
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1065 }
9020ffd06b8b Create prototype declaration automatically (only support direct continuation)
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 88
diff changeset
1066
90
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1067 static bool HasFlagsSet(Parser::SkipUntilFlags L, Parser::SkipUntilFlags R) {
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1068 return (static_cast<unsigned>(L) & static_cast<unsigned>(R)) != 0;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1069 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1070
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1071 bool Parser::SkipAnyUntil(tok::TokenKind T, SkipUntilFlags Flags){
91
ae2ab28b985c fix bug: When we check the file is ended or not on SearchCodeSegmentDeclaration, we look up not the current lexer but the current file lexer.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
1072 const PreprocessorLexer *L = PP.getCurrentFileLexer();
90
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1073 while(1){
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1074 if(Tok.is(T)){
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1075 if (HasFlagsSet(Flags, StopBeforeMatch)) {
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1076 // Noop, don't consume the token.
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1077 } else {
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1078 ConsumeAnyToken();
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1079 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1080 return true;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1081 }
91
ae2ab28b985c fix bug: When we check the file is ended or not on SearchCodeSegmentDeclaration, we look up not the current lexer but the current file lexer.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
1082 else if(PP.getCurrentFileLexer() != L){
90
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1083 return false;
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1084 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1085
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1086 ConsumeAnyToken();
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1087 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1088 }
2ddce554fef0 fix bug:LLVM/clang doesn't crash when code segment declaration was not found.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 89
diff changeset
1089
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
1090 #endif