File tree Expand file tree Collapse file tree 3 files changed +20
-15
lines changed Expand file tree Collapse file tree 3 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -236,9 +236,7 @@ class SourceFile final : public FileUnit {
236
236
}
237
237
238
238
// / Add a hoisted declaration. See Decl::isHoisted().
239
- void addHoistedDecl (Decl *d) {
240
- Hoisted.push_back (d);
241
- }
239
+ void addHoistedDecl (Decl *d);
242
240
243
241
// / Retrieves an immutable view of the list of top-level decls in this file.
244
242
ArrayRef<Decl *> getTopLevelDecls () const ;
Original file line number Diff line number Diff line change @@ -2337,6 +2337,12 @@ bool SourceFile::hasDelayedBodyParsing() const {
2337
2337
return true ;
2338
2338
}
2339
2339
2340
+ // / Add a hoisted declaration. See Decl::isHoisted().
2341
+ void SourceFile::addHoistedDecl (Decl *d) {
2342
+ assert (d->isHoisted ());
2343
+ Hoisted.push_back (d);
2344
+ }
2345
+
2340
2346
ArrayRef<Decl *> SourceFile::getTopLevelDecls () const {
2341
2347
auto &ctx = getASTContext ();
2342
2348
auto *mutableThis = const_cast <SourceFile *>(this );
Original file line number Diff line number Diff line change @@ -104,30 +104,24 @@ namespace {
104
104
template <typename T>
105
105
ParserResult<T>
106
106
fixupParserResult (T *D) {
107
- if (movedToTopLevel ()) {
108
- D->setHoisted ();
109
- SF->addHoistedDecl (D);
110
- getDebuggerClient ()->didGlobalize (D);
111
- }
107
+ if (movedToTopLevel ())
108
+ hoistDecl (D);
112
109
return ParserResult<T>(D);
113
110
}
114
111
115
112
template <typename T>
116
113
ParserResult<T>
117
114
fixupParserResult (ParserStatus Status, T *D) {
118
- if (movedToTopLevel ()) {
119
- D->setHoisted ();
120
- SF->addHoistedDecl (D);
121
- getDebuggerClient ()->didGlobalize (D);
122
- }
115
+ if (movedToTopLevel ())
116
+ hoistDecl (D);
123
117
return makeParserResult (Status, D);
124
118
}
125
119
126
120
// The destructor doesn't need to do anything, the CC's destructor will
127
121
// pop the context if we set it.
128
122
~DebuggerContextChange () {}
129
- protected:
130
-
123
+
124
+ private:
131
125
DebuggerClient *getDebuggerClient () {
132
126
ModuleDecl *M = P.CurDeclContext ->getParentModule ();
133
127
return M->getDebugClient ();
@@ -152,6 +146,13 @@ namespace {
152
146
SF = P.CurDeclContext ->getParentSourceFile ();
153
147
CC.emplace (P, SF);
154
148
}
149
+
150
+ template <typename T>
151
+ void hoistDecl (T *D) {
152
+ D->setHoisted ();
153
+ SF->addHoistedDecl (D);
154
+ getDebuggerClient ()->didGlobalize (D);
155
+ }
155
156
};
156
157
} // end anonymous namespace
157
158
You can’t perform that action at this time.
0 commit comments