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 {
236236 }
237237
238238 // / Add a hoisted declaration. See Decl::isHoisted().
239- void addHoistedDecl (Decl *d) {
240- Hoisted.push_back (d);
241- }
239+ void addHoistedDecl (Decl *d);
242240
243241 // / Retrieves an immutable view of the list of top-level decls in this file.
244242 ArrayRef<Decl *> getTopLevelDecls () const ;
Original file line number Diff line number Diff line change @@ -2337,6 +2337,12 @@ bool SourceFile::hasDelayedBodyParsing() const {
23372337 return true ;
23382338}
23392339
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+
23402346ArrayRef<Decl *> SourceFile::getTopLevelDecls () const {
23412347 auto &ctx = getASTContext ();
23422348 auto *mutableThis = const_cast <SourceFile *>(this );
Original file line number Diff line number Diff line change @@ -104,30 +104,24 @@ namespace {
104104 template <typename T>
105105 ParserResult<T>
106106 fixupParserResult (T *D) {
107- if (movedToTopLevel ()) {
108- D->setHoisted ();
109- SF->addHoistedDecl (D);
110- getDebuggerClient ()->didGlobalize (D);
111- }
107+ if (movedToTopLevel ())
108+ hoistDecl (D);
112109 return ParserResult<T>(D);
113110 }
114111
115112 template <typename T>
116113 ParserResult<T>
117114 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);
123117 return makeParserResult (Status, D);
124118 }
125119
126120 // The destructor doesn't need to do anything, the CC's destructor will
127121 // pop the context if we set it.
128122 ~DebuggerContextChange () {}
129- protected:
130-
123+
124+ private:
131125 DebuggerClient *getDebuggerClient () {
132126 ModuleDecl *M = P.CurDeclContext ->getParentModule ();
133127 return M->getDebugClient ();
@@ -152,6 +146,13 @@ namespace {
152146 SF = P.CurDeclContext ->getParentSourceFile ();
153147 CC.emplace (P, SF);
154148 }
149+
150+ template <typename T>
151+ void hoistDecl (T *D) {
152+ D->setHoisted ();
153+ SF->addHoistedDecl (D);
154+ getDebuggerClient ()->didGlobalize (D);
155+ }
155156 };
156157} // end anonymous namespace
157158
You can’t perform that action at this time.
0 commit comments