clang-tools  14.0.0git
HeaderSourceSwitch.h
Go to the documentation of this file.
1 //===--- HeaderSourceSwitch.h - ----------------------------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_HEADERSOURCESWITCH_H
10 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_HEADERSOURCESWITCH_H
11 
12 #include "ParsedAST.h"
13 #include "llvm/ADT/Optional.h"
14 
15 namespace clang {
16 namespace clangd {
17 
18 /// Given a header file, returns the best matching source file, and vice visa.
19 /// It only uses the filename heuristics to do the inference.
20 llvm::Optional<Path> getCorrespondingHeaderOrSource(
21  PathRef OriginalFile, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
22 
23 /// Given a header file, returns the best matching source file, and vice visa.
24 /// The heuristics incorporate with the AST and the index (if provided).
25 llvm::Optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
26  ParsedAST &AST,
27  const SymbolIndex *Index);
28 
29 /// Returns all indexable decls that are present in the main file of the AST.
30 /// Exposed for unittests.
31 std::vector<const Decl *> getIndexableLocalDecls(ParsedAST &AST);
32 
33 } // namespace clangd
34 } // namespace clang
35 
36 #endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_HEADERSOURCESWITCH_H
clang::clangd::getIndexableLocalDecls
std::vector< const Decl * > getIndexableLocalDecls(ParsedAST &AST)
Returns all indexable decls that are present in the main file of the AST.
Definition: HeaderSourceSwitch.cpp:124
Index
const SymbolIndex * Index
Definition: Dexp.cpp:99
clang::clangd::PathRef
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:29
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::getCorrespondingHeaderOrSource
llvm::Optional< Path > getCorrespondingHeaderOrSource(PathRef OriginalFile, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS)
Given a header file, returns the best matching source file, and vice visa.
Definition: HeaderSourceSwitch.cpp:19
ParsedAST.h