[PATCH] D124262: compile commands header to source heuristic lower-cases filenames before inferring file types

Ishaan Gandhi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 22 07:36:50 PDT 2022

ishaangandhi created this revision.
ishaangandhi added reviewers: nridge, sammccall.
Herald added subscribers: usaxena95, kadircet.
Herald added a project: All.
ishaangandhi requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This leads to ".C" files being rewritten as ".c" files and being inferred to be "c" files as opposed to "c++" files.

See https://github.com/clangd/clangd/issues/1108 for the original bug report.

  rG LLVM Github Monorepo



Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -329,7 +329,7 @@
       StringRef Path = Strings.save(StringRef(OriginalPaths[I]).lower());
       Paths.emplace_back(Path, I);
-      Types.push_back(foldType(guessType(Path)));
+      Types.push_back(foldType(guessType(StringRef(OriginalPaths[I]))));
       Stems.emplace_back(sys::path::stem(Path), I);
       auto Dir = ++sys::path::rbegin(Path), DirEnd = sys::path::rend(Path);
       for (int J = 0; J < DirectorySegmentsIndexed && Dir != DirEnd; ++J, ++Dir)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124262.424474.patch
Type: text/x-patch
Size: 718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220422/0a1c1c15/attachment.bin>

More information about the cfe-commits mailing list