[clang-tools-extra] a4e2722 - [clangd] Add a missing include-fixer test for incomplete_type, NFC.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 04:35:10 PDT 2020
Author: Haojian Wu
Date: 2020-10-08T13:33:38+02:00
New Revision: a4e27220c2a1046616556b8aadb0ae8f5e0255be
URL: https://github.com/llvm/llvm-project/commit/a4e27220c2a1046616556b8aadb0ae8f5e0255be
DIFF: https://github.com/llvm/llvm-project/commit/a4e27220c2a1046616556b8aadb0ae8f5e0255be.diff
LOG: [clangd] Add a missing include-fixer test for incomplete_type, NFC.
Also sort the list to make it easier to verify with the implementation
code.
Differential Revision: https://reviews.llvm.org/D88964
Added:
Modified:
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/IncludeFixer.cpp b/clang-tools-extra/clangd/IncludeFixer.cpp
index 7704ccb82c0f..0fd8db0d1167 100644
--- a/clang-tools-extra/clangd/IncludeFixer.cpp
+++ b/clang-tools-extra/clangd/IncludeFixer.cpp
@@ -68,10 +68,10 @@ class VisitedContextCollector : public VisibleDeclConsumer {
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) {
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 8fd1fe385a1c..e80a135c0a99 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -708,9 +708,11 @@ class Y : $base[[public ns::X]] {};
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 @@ int main() {
"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) {
More information about the cfe-commits
mailing list