[clangd] Add isHeaderFile helper.
authorHaojian Wu <hokein.wu@gmail.com>
Wed, 13 Nov 2019 15:30:07 +0000 (16:30 +0100)
committerHaojian Wu <hokein.wu@gmail.com>
Fri, 15 Nov 2019 15:18:27 +0000 (16:18 +0100)
commit509efe5d8edee5637b26fcb645978325de0a7283
tree05eea32a0fcdee7a1f6d3c8c7297e4773d69e2ca
parente3d5ff5a0b102febcddd9d58f24f18b00d4ecb4e
[clangd] Add isHeaderFile helper.

Summary:
we have a few places using `ASTCtx.getLangOpts().IsHeaderFile` to
determine a header file, but it relies on "-x c-header" compiler flag,
if the compilation command doesn't have this flag, we will get a false
positive. We are encountering this issue in bazel build system.

To solve this problem, we infer the file from file name, actual changes will
come in follow-ups.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70235
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp