[PATCH] D88964: [clangd] Add a missing include-fixer test for incomplete_type, NFC.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 04:35:14 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4e27220c2a1: [clangd] Add a missing include-fixer test for incomplete_type, NFC. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88964/new/
https://reviews.llvm.org/D88964
Files:
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -708,9 +708,11 @@
int main() {
ns::X *x;
x$access[[->]]f();
+ auto& $type[[[]]a] = *x;
}
)cpp");
auto TU = TestTU::withCode(Test.code());
+ TU.ExtraArgs.push_back("-std=c++17");
auto Index = buildIndexWithSymbol(
{SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
TU.ExternalIndex = Index.get();
@@ -731,7 +733,13 @@
"member access into incomplete type 'ns::X'"),
DiagName("incomplete_member_access"),
WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Add include \"x.h\" for symbol ns::X")))));
+ "Add include \"x.h\" for symbol ns::X"))),
+ AllOf(
+ Diag(Test.range("type"),
+ "incomplete type 'ns::X' where a complete type is required"),
+ DiagName("incomplete_type"),
+ WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+ "Add include \"x.h\" for symbol ns::X")))));
}
TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -68,10 +68,10 @@
std::vector<Fix> IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) const {
switch (Info.getID()) {
- case diag::err_incomplete_type:
- case diag::err_incomplete_member_access:
- case diag::err_incomplete_base_class:
case diag::err_incomplete_nested_name_spec:
+ case diag::err_incomplete_base_class:
+ case diag::err_incomplete_member_access:
+ case diag::err_incomplete_type:
// Incomplete type diagnostics should have a QualType argument for the
// incomplete type.
for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88964.296924.patch
Type: text/x-patch
Size: 2205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201008/2ded16c4/attachment.bin>
More information about the cfe-commits
mailing list