[all-commits] [llvm/llvm-project] 32c8da: [lldb] Don't infinite loop in SemaSourceWithPriori...
Raphael Isemann via All-commits
all-commits at lists.llvm.org
Wed Sep 9 01:06:39 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 32c8da41dc0cb99651823a1a21130c2cbdf688e1
https://github.com/llvm/llvm-project/commit/32c8da41dc0cb99651823a1a21130c2cbdf688e1
Author: Raphael Isemann <teemperor at gmail.com>
Date: 2020-09-09 (Wed, 09 Sep 2020)
Changed paths:
M lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
A lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/Makefile
A lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
A lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/main.cpp
A lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/module.modulemap
A lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/vector
A lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/libc_header.h
Log Message:
-----------
[lldb] Don't infinite loop in SemaSourceWithPriorities::CompleteType when trying to complete a forward decl
SemaSourceWithPriorities is a special SemaSource that wraps our normal LLDB
ExternalASTSource and the ASTReader (which is used for the C++ module loading).
It's only active when the `import-std-module` setting is turned on.
The `CompleteType` function there in `SemaSourceWithPriorities` is looping over
all ExternalASTSources and asks each to complete the type. However, that loop is
in another loop that keeps doing that until the type is complete. If that
function is ever called on a type that is a forward decl then that causes LLDB
to go into an infinite loop.
I remember I added that second loop and the comment because I thought I saw a
similar pattern in some other Clang code, but after some grepping I can't find
that code anywhere and it seems the rest of the code base only calls
CompleteType once (It would also be kinda silly to have calling it multiple
times). So it seems that's just a silly mistake.
The is implicitly tested by importing `std::pair`, but I also added a simpler
dedicated test that creates a dummy libc++ module with some forward declarations
and then imports them into the scratch AST context. At some point the
ASTImporter will check if one of the forward decls could be completed by the
ExternalASTSource, which will cause the `SemaSourceWithPriorities` to go into an
infinite loop once it receives the `CompleteType` call.
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D87289
More information about the All-commits
mailing list