diff --git a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp --- a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp +++ b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp @@ -772,7 +772,10 @@ MaxSuffixComponents; }) != SystemHeaderMap->keys().end()); - StdSuffixHeaderMapping = SystemHeaderMap; + // FIXME: Suffix mapping contains invalid entries for C, so only enable it for + // CPP. + if (Language.CPlusPlus) + StdSuffixHeaderMapping = SystemHeaderMap; } } // namespace clangd diff --git a/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp b/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp --- a/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp +++ b/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp @@ -21,6 +21,10 @@ CI.addSystemHeadersMapping(Language); // Usual standard library symbols are mapped correctly. EXPECT_EQ("", CI.mapHeader("path/stdio.h", "printf")); + // Suffix mapping isn't available for C, instead of mapping to ` we + // just leave the header as-is. + EXPECT_EQ("include/stdio.h", + CI.mapHeader("include/stdio.h", "unknown_symbol")); } TEST(CanonicalIncludesTest, CXXStandardLibrary) {