annotate tools/clang/lib/Parse/ParseCbC.cpp @ 47:5b813d18f000

replace __environment with &__CbC_environment in a code segment's arguments
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 02 Jan 2014 01:28:55 +0900
parents 9ebfb52ddd9b
children 4b59af982ef3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
1 #ifndef noCbC
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
2
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "clang/Parse/Parser.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "RAIIObjectsForParser.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "clang/AST/ASTContext.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "clang/Basic/Diagnostic.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "clang/Basic/PrettyStackTrace.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "clang/Basic/SourceManager.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "clang/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
10 #include "clang/Sema/DeclSpec.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "clang/Sema/PrettyDeclStackTrace.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #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
13 #include "clang/Sema/TypoCorrection.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "llvm/MC/MCAsmInfo.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #include "llvm/MC/MCContext.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include "llvm/MC/MCObjectFileInfo.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #include "llvm/MC/MCParser/MCAsmParser.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #include "llvm/MC/MCRegisterInfo.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #include "llvm/MC/MCStreamer.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #include "llvm/MC/MCSubtargetInfo.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "llvm/MC/MCTargetAsmParser.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "llvm/Support/SourceMgr.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "llvm/Support/TargetRegistry.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "llvm/Support/TargetSelect.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "llvm/ADT/SmallString.h"
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #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
27 #include "clang/Lex/LiteralSupport.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
28
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
29 #include <cmath>
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
30 #include <sstream>
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
31
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
32 #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
33
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 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
35
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
36 namespace ExternalSpace { // from ParseExpr.cpp , ParseStmt.cpp
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 class CastExpressionIdValidator : public CorrectionCandidateCallback {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 public:
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 CastExpressionIdValidator(bool AllowTypes, bool AllowNonTypes)
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 : AllowNonTypes(AllowNonTypes) {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 WantTypeSpecifiers = AllowTypes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 virtual bool ValidateCandidate(const TypoCorrection &candidate) {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 NamedDecl *ND = candidate.getCorrectionDecl();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 if (!ND)
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 return candidate.isKeyword();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 if (isa<TypeDecl>(ND))
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 return WantTypeSpecifiers;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 return AllowNonTypes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 private:
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 bool AllowNonTypes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 };
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 class StatementFilterCCC : public CorrectionCandidateCallback {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 public:
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 StatementFilterCCC(Token nextTok) : NextToken(nextTok) {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 WantTypeSpecifiers = nextTok.is(tok::l_paren) || nextTok.is(tok::less) ||
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 nextTok.is(tok::identifier) || nextTok.is(tok::star) ||
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 nextTok.is(tok::amp) || nextTok.is(tok::l_square);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 WantExpressionKeywords = nextTok.is(tok::l_paren) ||
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 nextTok.is(tok::identifier) ||
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 nextTok.is(tok::arrow) || nextTok.is(tok::period);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 WantRemainingKeywords = nextTok.is(tok::l_paren) || nextTok.is(tok::semi) ||
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 nextTok.is(tok::identifier) ||
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 nextTok.is(tok::l_brace);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 WantCXXNamedCasts = false;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 virtual bool ValidateCandidate(const TypoCorrection &candidate) {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 if (FieldDecl *FD = candidate.getCorrectionDeclAs<FieldDecl>())
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 return !candidate.getCorrectionSpecifier() || isa<ObjCIvarDecl>(FD);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 if (NextToken.is(tok::equal))
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 return candidate.getCorrectionDeclAs<VarDecl>();
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if (NextToken.is(tok::period) &&
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 candidate.getCorrectionDeclAs<NamespaceDecl>())
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 return false;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 return CorrectionCandidateCallback::ValidateCandidate(candidate);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 private:
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 Token NextToken;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 };
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
89 namespace CbCSpace{
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
90 enum AssignmentFlags {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
91 HasStar = 0x01,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
92 HasAmp = 0x02,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
93 HasPeriod = 0x04,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
94 HasArrow = 0x08
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
95 };
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
96
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
97 bool hasStar(unsigned F) { return F & HasStar; }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
98 bool hasAmp(unsigned F) { return F & HasAmp; }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
99 bool hasPeriod(unsigned F) { return F & HasPeriod; }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
100 bool hasArrow(unsigned F) { return F & HasArrow; }
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
101
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
102 enum DeclarationFlags {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
103 ArrayType = 0x01,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
104 PointerType = 0x02,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
105 FunctionType = 0x04
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
106 };
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
108 bool isArray(unsigned F) { return F & ArrayType; }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
109 bool isPointer(unsigned F) { return F & PointerType; }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
110 bool isFunction(unsigned F) { return F & FunctionType; }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
111 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
112
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
113
47
5b813d18f000 replace __environment with &__CbC_environment in a code segment's arguments
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
114 void Parser::PrepareForGotoWithTheEnv(){
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
115 StmtResult Res;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
116 SourceLocation Loc = Tok.getLocation();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
117
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
118 Res = CreateDeclStmt(CreateIdentifierInfo(__CBC_STRUCT_NAME, __CBC_STRUCT_LENGTH, Loc), CbCSpace::FunctionType, DeclSpec::TST___code);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
119 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
120 Stmtsp->push_back(Res.release());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
121
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
122 Res = CreateDeclStmt(CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, __CBC_ENVIRONMENT_LENGTH, Loc), 0, DeclSpec::TST_struct,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
123 CreateIdentifierInfo(__CBC_STRUCT_NAME, __CBC_STRUCT_LENGTH, Loc));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
124 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
125 Stmtsp->push_back(Res.release());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
126
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
127 bufII = CreateSingleIdentifierInfo(__CBC_BUF_NAME, __CBC_BUF_LENGTH, Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
128 Res = CreateDeclStmt(bufII, CbCSpace::ArrayType, DeclSpec::TST_int);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
129 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
130 Stmtsp->push_back(Res.release());
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
132 retvalII = CreateSingleIdentifierInfo(__CBC_RETVAL_NAME, __CBC_RETVAL_LENGTH, Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
133 Res = CreateDeclStmt(retvalII, 0, DeclSpec::TST_int);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
134 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
135 Stmtsp->push_back(Res.release());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
136
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
137 Res = CreateAssignmentStmt(CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, __CBC_ENVIRONMENT_LENGTH, Loc),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
138 retvalII, CbCSpace::HasPeriod, CbCSpace::HasAmp, CreateIdentifierInfo(__CBC_STRUCT_POINTER_NAME, __CBC_STRUCT_POINTER_LENGTH, Loc));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
139 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
140 Stmtsp->push_back(Res.release());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
141
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
142 Res = CreateAssignmentStmt(CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, __CBC_ENVIRONMENT_LENGTH, Loc),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
143 bufII, CbCSpace::HasPeriod, 0, CreateIdentifierInfo(__CBC_STRUCT_ENV_NAME, __CBC_STRUCT_ENV_LENGTH, Loc));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
144 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
145 Stmtsp->push_back(Res.release());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
146
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
147 Res = CreateSjForContinuationWithEnv();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
148 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
149 Stmtsp->push_back(Res.release());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
150
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
151 Res = CreateAssignmentStmt(CreateIdentifierInfo(__CBC_RETURN_NAME, __CBC_RETURN_LENGTH, Loc),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
152 CreateIdentifierInfo("return1", 7, Loc));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
153 if (Res.isUsable())
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
154 Stmtsp->push_back(Res.release());
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
157
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
158 StmtResult Parser::CreateAssignmentStmt(IdentifierInfo* LHSII,IdentifierInfo* RHSII,unsigned LHSFlags,unsigned RHSFlags,
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
159 IdentifierInfo* extraLHSII,IdentifierInfo* extraRHSII){
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
160 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
161
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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 LHSToken.setKind(tok::annot_primary_expr);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 ExternalSpace::StatementFilterCCC Validator(Next);
43
7116d17d6428 Two assignment statements, __CbC_environment.env = i_buf and _CbC_environment.ret_p = &retval, were createed automarically when we found __return.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 42
diff changeset
172 Sema::NameClassification Classification = Actions.ClassifyName(getCurScope(), SS, LHSII, Loc, Next, false, SS.isEmpty() ? &Validator : 0);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 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
174 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
175 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
176
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 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
178
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
179 if ( CbCSpace::hasPeriod(LHSFlags) )
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
180 LHS = LookupMemberAndBuildExpr(extraLHSII, LHS.take(), false);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
181 else if ( CbCSpace::hasArrow(LHSFlags) )
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
182 LHS = LookupMemberAndBuildExpr(extraLHSII, LHS.take(), true); // It is not sure.
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
183
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
184 RHS = LookupAndDeclareName(RHSII);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
185 if ( CbCSpace::hasAmp(RHSFlags) )
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
186 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
187
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
188 else if ( CbCSpace::hasStar(RHSFlags) )
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
189 RHS = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, RHS.get()); // It is not sure.
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
190
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
191 Expr = Actions.ActOnBinOp(getCurScope(), Loc,tok::equal,LHS.take(),RHS.take());
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
192
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
193 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
194 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
196 IdentifierInfo* Parser::CreateSingleIdentifierInfo(const char* Name, int length, SourceLocation Loc){
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
197 IdentifierInfo *II;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
198 int i = 0;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
199 std::ostringstream os;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
200
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
201 while (true) {
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
202 i++;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
203 os << Name << i;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
204 II = CreateIdentifierInfo(os.str().c_str(),length + (int)(floor(log10(i))+1),Loc);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
205 LookupResult Previous(Actions, II, Loc, Actions.LookupOrdinaryName, Actions.ForRedeclaration);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
206 if (!Actions.LookupName(Previous, getCurScope()))
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
207 return II;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
208 }
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
209 }
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
210
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
211 StmtResult Parser::CreateDeclStmt(IdentifierInfo *II, unsigned DeclFlags, DeclSpec::TST valueType, IdentifierInfo* Name){
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
212 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
213 DeclGroupPtrTy DeclGPT;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
214 ParsingDeclSpec DS(*this);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
215 DeclSpec *DSp;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
216 DSp = &DS;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
217
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
218 DS.SetRangeStart(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
219 DS.SetRangeEnd(Loc);
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
220
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
221 bool isInvalid = false;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
222 const char *PrevSpec = 0;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
223 unsigned DiagID = 0;
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
224
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
225 if (valueType == DeclSpec::TST_struct) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
226 ParsedAttributesWithRange attrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
227 CXXScopeSpec &SS = DS.getTypeSpecScope();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
228 DeclResult TagOrTempResult = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
229 bool Owned = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
230 bool IsDependent = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
231 MultiTemplateParamsArg TParams;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
232 TagOrTempResult = Actions.ActOnTag(getCurScope(), valueType, Sema::TUK_Reference, Loc,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
233 SS, Name, Loc, attrs.getList(), AS_none,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
234 DS.getModulePrivateSpecLoc(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
235 TParams, Owned, IsDependent,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
236 SourceLocation(), false,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
237 clang::TypeResult());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
238 isInvalid = DS.SetTypeSpecType(valueType, Loc, Loc, PrevSpec, DiagID, TagOrTempResult.get(), Owned);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
239 if (isInvalid)
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
240 Diag(Loc, DiagID) << PrevSpec;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
241 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
242
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
243 else
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
244 isInvalid = DS.SetTypeSpecType(valueType, Loc, PrevSpec, DiagID);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
245
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
246 DS.SetRangeEnd(Loc);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
247 DS.Finish(Diags, PP);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
248 ParsingDeclarator D(*this, DS, static_cast<Declarator::TheContext>(Declarator::BlockContext));
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
249 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
250
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
251 if (CbCSpace::isFunction(DeclFlags)) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
252 D.setEllipsisLoc(SourceLocation());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
253 bool hadGroupingParens = D.hasGroupingParens();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
254 D.setGroupingParens(true);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
255 IdentifierInfo* II = CreateIdentifierInfo(__CBC_RETURN_NAME, __CBC_RETURN_LENGTH, Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
256 D.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
257 DeclSpec FDS(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
258
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
259 DS.Finish(Diags, PP);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
260 D.SetIdentifier(II, Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
261
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
262 D.AddTypeInfo(DeclaratorChunk::getPointer(FDS.getTypeQualifiers(), Loc, FDS.getConstSpecLoc(), FDS.getVolatileSpecLoc(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
263 FDS.getRestrictSpecLoc()), FDS.getAttributes(), SourceLocation());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
264 D.setGroupingParens(hadGroupingParens);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
265
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
266
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
267 ParseScope PrototypeScope(this,Scope::FunctionPrototypeScope|Scope::DeclScope|
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
268 (D.isFunctionDeclaratorAFunctionDeclaration() ? Scope::FunctionDeclarationScope : 0));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
269 bool HasProto = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
270 SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
271 SourceLocation EllipsisLoc, RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
272 DeclSpec FPDS(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
273 bool RefQualifierIsLValueRef = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
274 ExceptionSpecificationType ESpecType = EST_None;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
275 SourceRange ESpecRange;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
276 SmallVector<ParsedType, 2> DynamicExceptions;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
277 SmallVector<SourceRange, 2> DynamicExceptionRanges;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
278 ExprResult NoexceptExpr;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
279 ParsedAttributes FnAttrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
280 TypeResult TrailingReturnType;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
281 D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto,false,Loc,ParamInfo.data(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
282 ParamInfo.size(),EllipsisLoc, Loc, FPDS.getTypeQualifiers(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
283 RefQualifierIsLValueRef,RefQualifierLoc, ConstQualifierLoc,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
284 VolatileQualifierLoc,SourceLocation(),ESpecType, ESpecRange.getBegin(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
285 DynamicExceptions.data(),DynamicExceptionRanges.data(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
286 DynamicExceptions.size(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
287 NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0,Loc, Loc, D,TrailingReturnType),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
288 FnAttrs, Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
289 PrototypeScope.Exit();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
290 DSp = &FDS;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
291 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
292 if (CbCSpace::isArray(DeclFlags))
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
293 CreateArrayDecl(D, Loc);
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
294
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
295 SmallVector<Decl *, 8> DeclsInGroup;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
296 Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(D);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
297 D.complete(FirstDecl);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
298 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
299 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
300 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
301 }
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
302
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
303 void Parser::CreateArrayDecl(ParsingDeclarator &D, SourceLocation Loc){
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
304 ExprResult ExprRes;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
305 ParsedAttributesWithRange attrs(AttrFactory);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
306 SmallString<128> SpellingBuffer;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
307 SpellingBuffer.resize(__JMP_BUF_SIZE_LENGTH + 1);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
308 StringRef TokSpelling = StringRef(__JMP_BUF_SIZE,__JMP_BUF_SIZE_LENGTH);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
309 NumericLiteralParser Literal(TokSpelling, Loc, PP);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
310 Expr *sizeRes;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
311 QualType Ty;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
312 unsigned MaxWidth = Actions.Context.getTargetInfo().getIntMaxTWidth();
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
313 llvm::APInt ResultVal(MaxWidth, 0);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
314 Literal.GetIntegerValue(ResultVal);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
315 unsigned Width = 0;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
316 unsigned IntSize = Actions.Context.getTargetInfo().getIntWidth();
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
317 Ty = Actions.Context.IntTy;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
318 Width = IntSize;
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
319 ResultVal = ResultVal.trunc(Width);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
320 sizeRes = IntegerLiteral::Create(Actions.Context, ResultVal, Ty, Loc);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
321 ExprRes = Actions.Owned(sizeRes);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
322 D.AddTypeInfo(DeclaratorChunk::getArray(0, false, false,ExprRes.release(),Loc,Loc),attrs,Loc);
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
323 }
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 StmtResult Parser::CreateSjForContinuationWithEnv(){
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 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
327 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
328 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
329 ExprResult CondExp;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 Decl *CondVar = 0;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
332 CondExp = LookupAndDeclareName(CreateIdentifierInfo("setjmp",6,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
333 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
334 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
335
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
336 __envExprRes = LookupAndDeclareName(CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, __CBC_ENVIRONMENT_LENGTH, Loc));
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
337 __envExprRes = LookupMemberAndBuildExpr(CreateIdentifierInfo(__CBC_STRUCT_ENV_NAME, __CBC_STRUCT_ENV_LENGTH,Loc), __envExprRes.take(), 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
338
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 ArgExprs.push_back(__envExprRes.release());
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
340 CondExp = Actions.ActOnCallExpr(getCurScope(), CondExp.take(), Loc, ArgExprs, Loc, 0);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 CondExp = Actions.ActOnBooleanCondition(getCurScope(), Loc, CondExp.get());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get(), Loc));
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 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
345 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
346
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 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
348 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
349 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
350 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
351 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
352 ExprResult innerExprRes;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 DeclSpec CastDS(AttrFactory);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 if (CastDS.getSourceRange().isInvalid()) {
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 CastDS.SetRangeStart(Loc);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 CastDS.SetRangeEnd(Loc);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 }
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 ParsedAttributesWithRange attrs(AttrFactory);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 bool isInvalid = false;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 const char *PrevSpec = 0;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 unsigned DiagID = 0;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 isInvalid = CastDS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID);
44
aabc64b7263e create two declaration statements, env_buf and retval.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
364 CastDS.SetRangeEnd(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
365 isInvalid = false;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 DiagID = 0;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 ProhibitAttributes(attrs);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 CastDS.Finish(Diags, PP);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 Declarator CastDeclaratorInfo(CastDS, Declarator::TypeNameContext);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 CastDeclaratorInfo.SetRangeEnd(Loc);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 DeclSpec pointerDS(AttrFactory);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 pointerDS.Finish(Diags, PP);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 DeclaratorScopeObj DeclScopeObj(*this, CastDeclaratorInfo.getCXXScopeSpec());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 CastDeclaratorInfo.SetIdentifier(0, Loc);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 CastDeclaratorInfo.AddTypeInfo(DeclaratorChunk::getPointer(pointerDS.getTypeQualifiers(), Loc,
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 pointerDS.getConstSpecLoc(),
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 pointerDS.getVolatileSpecLoc(),
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 pointerDS.getRestrictSpecLoc()),
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 pointerDS.getAttributes(),SourceLocation());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381
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
382 innerExprRes = LookupAndDeclareName(CreateIdentifierInfo(__CBC_ENVIRONMENT_NAME, __CBC_ENVIRONMENT_LENGTH, Loc));
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
383 innerExprRes = LookupMemberAndBuildExpr(CreateIdentifierInfo(__CBC_STRUCT_POINTER_NAME,__CBC_STRUCT_POINTER_LENGTH,Loc), innerExprRes.take(), false);
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
384 Expr *CastExpr = innerExprRes.take();
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 TypeSourceInfo *castTInfo = Actions.GetTypeForDeclaratorCast(CastDeclaratorInfo, CastExpr->getType());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 Actions.checkUnusedDeclAttributes(CastDeclaratorInfo);
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
388 innerExprRes = Actions.BuildCStyleCastExpr(Loc, castTInfo, Loc, CastExpr);
41
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 innerExprRes = Actions.ActOnParenExpr(Loc, Loc, innerExprRes.take());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 innerExprRes = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, innerExprRes.get());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 innerStmtRes = Actions.ActOnReturnStmt(Loc, innerExprRes.take());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 if (innerStmtRes.isUsable())
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 innerStmts.push_back(innerStmtRes.release());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 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
395 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
396 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
397 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
398 StmtResult ElseStmt;
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 IfRes = Actions.ActOnIfStmt(Loc, FullCondExp, CondVar, ThenStmt.get(),Loc, ElseStmt.get());
1d6c745cd57d move some methods to ParseCbC.cpp which were written by me.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 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
401 }
42
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
402
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
403 ExprResult Parser::LookupAndDeclareName(IdentifierInfo *II){
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
404 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
405 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
406 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
407 SourceLocation TemplateKWLoc;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
408 ExternalSpace::CastExpressionIdValidator Validator(false,true);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
409 Name.setIdentifier(II, Loc);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
410 TemplateArgumentListInfo TemplateArgsBuffer;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
411 DeclarationNameInfo NameInfo;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
412 const TemplateArgumentListInfo *TemplateArgs;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
413 Actions.DecomposeUnqualifiedId(Name, TemplateArgsBuffer, NameInfo, TemplateArgs);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
414 DeclarationName DName = NameInfo.getName();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
415 II = DName.getAsIdentifierInfo();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
416 SourceLocation NameLoc = NameInfo.getLoc();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
417 LookupResult R(Actions, NameInfo,Actions.LookupOrdinaryName);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
418 Actions.LookupParsedName(R, getCurScope(), &SS, true);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
419
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
420 if (II && R.empty()) {
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
421 NamedDecl *D = Actions.ImplicitlyDefineFunction(NameLoc, *II, getCurScope());
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
422 if (D) R.addDecl(D);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
423 }
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
424 return Actions.BuildDeclarationNameExpr(SS, R, false);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
425 }
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
426
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
427 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
428 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
429 ExprResult Res;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
430 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
431 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
432 SourceLocation TemplateKWLoc;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
433 Name.setIdentifier(II,Loc);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
434 TemplateArgumentListInfo TemplateArgsBuffer;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
435 DeclarationNameInfo NameInfo;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
436 const TemplateArgumentListInfo *TemplateArgs;
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
437 Actions.DecomposeUnqualifiedId(Name, TemplateArgsBuffer, NameInfo, TemplateArgs);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
438 Res = Actions.MaybeConvertParenListExprToParenExpr(getCurScope(), Base);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
439 Base = Res.take();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
440 LookupResult R(Actions, NameInfo, Actions.LookupMemberName);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
441 ExprResult BaseResult = Actions.Owned(Base);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
442 Actions.LookupMemberExpr(R, BaseResult, IsArrow, Loc, SS, 0, TemplateArgs != 0);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
443 Base = BaseResult.take();
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
444 Sema::ActOnMemberAccessExtraArgs ExtraArgs = {getCurScope(), Name, 0, false};
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
445 return Actions.BuildMemberReferenceExpr(Base, Base->getType(), Loc, IsArrow, SS, TemplateKWLoc, 0, R, TemplateArgs,false, &ExtraArgs);
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
446
3e178477409f made some submethods for the methods which emit CbC statements.
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
447 }
45
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
448
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
449
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
450 /// 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
451 /// If the __CbC_env has been already defined, it doesn't create __CbC_env again.
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
452 void Parser::Create__CbC_envStruct(SourceLocation Loc, AccessSpecifier AS) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
453 ParsingDeclSpec SDS(*this);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
454 if (SDS.getSourceRange().isInvalid()) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
455 SDS.SetRangeStart(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
456 SDS.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
457 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
458 IdentifierInfo *Name = CreateIdentifierInfo(__CBC_STRUCT_NAME, __CBC_STRUCT_LENGTH, Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
459
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
460 // Check previous definition. If the __CbC_env has been already defined, we have not to create again.
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
461 LookupResult Previous(Actions, Name, Loc, Actions.LookupTagName, Actions.ForRedeclaration);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
462 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
463 return;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
464
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
465
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
466 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
467 DeclResult TagOrTempResult = true;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
468 bool Owned = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
469 bool IsDependent = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
470 ParsedAttributesWithRange attrs(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
471 MultiTemplateParamsArg TParams;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
472
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
473 TagOrTempResult = Actions.ActOnTag(getCurScope(), TagType, Sema::TUK_Definition, Loc,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
474 SDS.getTypeSpecScope(), Name, Loc, attrs.getList(), AS,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
475 SDS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
476 SourceLocation(), false, clang::TypeResult());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
477
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
478 Decl *TagDecl = TagOrTempResult.get();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
479 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
480 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
481 Actions.ActOnTagStartDefinition(getCurScope(), TagDecl);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
482 SmallVector<Decl *, 32> FieldDecls;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
483
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
484 bool isInvalid = false;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
485 const char *PrevSpec = 0;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
486 unsigned DiagID = 0;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
487
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
488 FieldDecls.push_back(Create__CbC_envBody(TagDecl, DeclSpec::TST_void, Loc, __CBC_STRUCT_POINTER_NAME, __CBC_STRUCT_POINTER_LENGTH));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
489 FieldDecls.push_back(Create__CbC_envBody(TagDecl, DeclSpec::TST_int, Loc, __CBC_STRUCT_ENV_NAME, __CBC_STRUCT_ENV_LENGTH));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
490
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
491 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
492 StructScope.Exit();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
493 Actions.ActOnTagFinishDefinition(getCurScope(), TagDecl,Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
494 bool Result = SDS.SetTypeSpecType(TagType, Loc,Loc.isValid() ? Loc : Loc, PrevSpec, DiagID, TagOrTempResult.get(), Owned);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
495
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
496 if (Result){
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
497 Diag(Loc, DiagID) << PrevSpec;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
498 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
499
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
500 SDS.Finish(Diags,PP);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
501 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS, SDS);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
502 SDS.complete(TheDecl);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
503 Actions.ConvertDeclToDeclGroup(TheDecl);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
504 if (isInvalid) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
505 assert(PrevSpec && "Method did not return previous specifier!");
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
506 assert(DiagID);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
507
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
508 if (DiagID == diag::ext_duplicate_declspec)
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
509 Diag(Tok, DiagID)
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
510 << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
511 else
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
512 Diag(Tok, DiagID) << PrevSpec;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
513 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
514 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
515
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
516 Decl* Parser::Create__CbC_envBody(Decl* TagDecl, DeclSpec::TST T, SourceLocation Loc, const char* Name, int NameLen){
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
517 const char *PrevSpec = 0;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
518 unsigned DiagID = 0;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
519 ParsingDeclSpec PDS(*this);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
520 if (PDS.getSourceRange().isInvalid()) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
521 PDS.SetRangeStart(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
522 PDS.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
523 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
524 PDS.SetTypeSpecType(T, Loc, PrevSpec, DiagID);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
525 PDS.SetRangeEnd(Loc);
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
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
528 PDS.Finish(Diags, PP);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
529 SourceLocation CommaLoc;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
530 ParsingFieldDeclarator DeclaratorInfo(*this, PDS);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
531 DeclaratorInfo.D.setCommaLoc(CommaLoc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
532 DeclaratorInfo.D.SetRangeEnd(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
533 DeclSpec DS(AttrFactory);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
534 DS.Finish(Diags,PP);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
535 DeclaratorInfo.D.SetIdentifier(CreateIdentifierInfo(Name, NameLen,Loc),Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
536
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
537
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
538 DeclaratorInfo.D.AddTypeInfo(DeclaratorChunk::getPointer(DS.getTypeQualifiers(), Loc,DS.getConstSpecLoc(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
539 DS.getVolatileSpecLoc(),DS.getRestrictSpecLoc()),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
540 DS.getAttributes(),SourceLocation());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
541 Decl *Field = Actions.ActOnField(getCurScope(), TagDecl,
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
542 DeclaratorInfo.D.getDeclSpec().getSourceRange().getBegin(),
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
543 DeclaratorInfo.D, DeclaratorInfo.BitfieldSize);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
544 DeclaratorInfo.complete(Field);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
545 return Field;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
546 }
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
547
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
548 IdentifierInfo* Parser::CreateIdentifierInfo(const char* Name, int NameLen, SourceLocation Loc) {
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
549 Token TokenForII;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
550 TokenForII.startToken();
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
551 TokenForII.setLocation(Loc);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
552 TokenForII.setLength(NameLen);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
553 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
554 TokenForII.setRawIdentifierData(Name);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
555 IdentifierInfo *II;
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
556 II = PP.getIdentifierInfo(StringRef(TokenForII.getRawIdentifierData(),TokenForII.getLength()));
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
557 TokenForII.setIdentifierInfo(II);
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
558 TokenForII.setKind(II->getTokenID());
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
559 return II;
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
9ebfb52ddd9b create declaration statement automatically for __CbC_environment
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
562
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
563 #endif