[all-commits] [llvm/llvm-project] 721476: [clang] Fix a crash during code completion
Adam Czachorowski via All-commits
all-commits at lists.llvm.org
Mon Jun 7 04:38:00 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 721476e6b2119a93033903109b54f429b6e8c91b
https://github.com/llvm/llvm-project/commit/721476e6b2119a93033903109b54f429b6e8c91b
Author: Adam Czachorowski <adamcz at google.com>
Date: 2021-06-07 (Mon, 07 Jun 2021)
Changed paths:
M clang/lib/Sema/SemaLookup.cpp
Log Message:
-----------
[clang] Fix a crash during code completion
During code completion, lookupInDeclContext() calls
CodeCompletionDeclConsumer::FoundDecl(),which can mutate StoredDeclsMap,
over which lookupInDeclContext() iterates. This can lead to invalidation
of iterators and an assert()-crash.
Example code where this happens:
#include <list>
int main() {
std::list<int>;
std::^
}
with code completion on ^ with -std=c++20.
I do not have a repro case that does not need standard library.
This fix stores pointers to NamedDecls in a temporary vector, then
visits them outside of the main loop, when StoredDeclsMap iterators are
gone.
Differential Revision: https://reviews.llvm.org/D103472
More information about the All-commits
mailing list