mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibCpp: Handle circular imports gracefully
This patch prevents CppComprehensionEngine from endlessly looping when there's a circular #include in the code. We now keep track of the set of currently processed files, and will not re-process a file if it already exists in this set. When we're done with processing a file it is removed from this set. The pragma once directive is not yet implemented, but regardless a mechanism that prevents #include loops even in the absence of pragma once is desired.
This commit is contained in:
parent
68d895eb7c
commit
9ae98bc81b
2 changed files with 11 additions and 0 deletions
|
@ -140,6 +140,11 @@ private:
|
|||
void for_each_included_document_recursive(const DocumentData&, Func) const;
|
||||
|
||||
HashMap<String, OwnPtr<DocumentData>> m_documents;
|
||||
|
||||
// A document's path will be in this set if we're currently processing it.
|
||||
// A document is added to this set when we start processing it (e.g because it was #included) and removed when we're done.
|
||||
// We use this to prevent circular #includes from looping indefinitely.
|
||||
HashTable<String> m_unfinished_documents;
|
||||
};
|
||||
|
||||
template<typename Func>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue