diff options
Diffstat (limited to 'lib/Expr/Parser.cpp')
-rw-r--r-- | lib/Expr/Parser.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp index 854f6d52..e914cb80 100644 --- a/lib/Expr/Parser.cpp +++ b/lib/Expr/Parser.cpp @@ -331,6 +331,8 @@ namespace { MaxErrors(~0u), NumErrors(0) {} + virtual ~ParserImpl(); + /// Initialize - Initialize the parsing state. This must be called /// prior to the start of parsing. void Initialize() { @@ -1561,6 +1563,36 @@ void ParserImpl::Error(const char *Message, const Token &At) { llvm::errs() << '\n'; } +ParserImpl::~ParserImpl() { + // Free identifiers + // + // Note the Identifiers are not disjoint across the symbol + // tables so we need to keep track of what has freed to + // avoid doing a double free. + std::set<const Identifier*> freedNodes; + for (IdentifierTabTy::iterator pi = IdentifierTab.begin(), + pe = IdentifierTab.end(); + pi != pe; ++pi) { + const Identifier* id = pi->second; + if (freedNodes.insert(id).second) + delete id; + } + for (ExprSymTabTy::iterator pi = ExprSymTab.begin(), + pe = ExprSymTab.end(); + pi != pe; ++pi) { + const Identifier* id = pi->first; + if (freedNodes.insert(id).second) + delete id; + } + for (VersionSymTabTy::iterator pi = VersionSymTab.begin(), + pe = VersionSymTab.end(); + pi != pe; ++pi) { + const Identifier* id = pi->first; + if (freedNodes.insert(id).second) + delete id; + } +} + // AST API // FIXME: Move out of parser. |