This is an archive of the discontinued LLVM Phabricator instance.

Parse .h files as objective-c++ if we don't have a compile command.
ClosedPublic

Authored by sammccall on Apr 9 2018, 8:31 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Apr 9 2018, 8:31 AM

ObjC++ definitely seems like a nicer default. Unfortunately, we'll start getting ObjC++ completion results, which may be confusing. But that seems like a smaller evil.

Is there an easy way to add a regression test that checks we don't get any errors for headers without compile command with C++/ObjC++ code?

clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #141662)

Maybe use .equals_lower(".h") instead? Just in case.

Will try to add a test.

clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #141662)

.H is (unambiguously) c++, and will be treated as such by clang.

ilya-biryukov added inline comments.Apr 11 2018, 12:55 AM
clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #141662)

Wasn't aware of that convention, thanks.
In that case, LG

sammccall updated this revision to Diff 141957.Apr 11 2018, 1:33 AM

Add test, shave required yaks

Added a unit test, and cleaned up a couple of things to make it pass:

  • GlobalCompilationDatabase.h wasn't self-contained due to incomplete types
  • testPath() isn't very usable with subdirectories on windows
clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #141662)

Yeah .C/.H is rare these days I think. (But present in Driver/Types.cpp)

This revision is now accepted and ready to land.Apr 19 2018, 1:51 AM
This revision was automatically updated to reflect the committed changes.