From e00dc16dbe35dc2ce9c9c915b3a0d9fc699a8e24 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Wed, 19 Oct 2022 16:21:10 -0700 Subject: [PATCH] [tblgen-lsp-server] Fix various ASAN issues * Properly use virtual destructors for index symbols * Clear the index before initializing it --- mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp index 42e321f..5a4d3b2 100644 --- a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp +++ b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp @@ -142,6 +142,7 @@ struct TableGenIndexSymbol { TableGenIndexSymbol(const llvm::RecordVal *value) : definition(value), defLoc(lsp::convertTokenLocToRange(value->getLoc())) {} + virtual ~TableGenIndexSymbol() = default; // The main definition of the symbol. PointerUnion definition; @@ -156,6 +157,7 @@ struct TableGenIndexSymbol { struct TableGenRecordSymbol : public TableGenIndexSymbol { TableGenRecordSymbol(const llvm::Record *record) : TableGenIndexSymbol(record) {} + ~TableGenRecordSymbol() override = default; static bool classof(const TableGenIndexSymbol *symbol) { return symbol->definition.is(); @@ -171,6 +173,7 @@ struct TableGenRecordValSymbol : public TableGenIndexSymbol { TableGenRecordValSymbol(const llvm::Record *record, const llvm::RecordVal *value) : TableGenIndexSymbol(value), record(record) {} + ~TableGenRecordValSymbol() override = default; static bool classof(const TableGenIndexSymbol *symbol) { return symbol->definition.is(); @@ -241,6 +244,9 @@ private: } // namespace void TableGenIndex::initialize(const llvm::RecordKeeper &records) { + intervalMap.clear(); + defToSymbol.clear(); + auto insertRef = [&](TableGenIndexSymbol *sym, SMRange refLoc, bool isDef = false) { const char *startLoc = refLoc.Start.getPointer(); -- 2.7.4