clang-tools
15.0.0git
llvm-project
clang-tools-extra
clangd
support
Path.h
Go to the documentation of this file.
1
//===--- Path.h - Helper typedefs --------------------------------*- 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_CLANGD_SUPPORT_PATH_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_PATH_H
11
12
#include "llvm/ADT/StringRef.h"
13
#include "llvm/Support/Path.h"
14
#include <string>
15
16
/// Whether current platform treats paths case insensitively.
17
#if defined(_WIN32) || defined(__APPLE__)
18
#define CLANGD_PATH_CASE_INSENSITIVE
19
#endif
20
21
namespace
clang
{
22
namespace
clangd {
23
24
/// A typedef to represent a file path. Used solely for more descriptive
25
/// signatures.
26
using
Path
= std::string;
27
/// A typedef to represent a ref to file path. Used solely for more descriptive
28
/// signatures.
29
using
PathRef
= llvm::StringRef;
30
31
// For platforms where paths are case-insensitive (but case-preserving),
32
// we need to do case-insensitive comparisons and use lowercase keys.
33
// FIXME: Make Path a real class with desired semantics instead.
34
std::string
maybeCaseFoldPath
(
PathRef
Path
);
35
bool
pathEqual
(
PathRef
,
PathRef
);
36
37
/// Checks if \p Ancestor is a proper ancestor of \p Path. This is just a
38
/// smarter lexical prefix match, e.g: foo/bar/baz doesn't start with foo/./bar.
39
/// Both \p Ancestor and \p Path must be absolute.
40
bool
pathStartsWith
(
41
PathRef
Ancestor,
PathRef
Path
,
42
llvm::sys::path::Style Style = llvm::sys::path::Style::native);
43
44
/// Variant of parent_path that operates only on absolute paths.
45
/// Unlike parent_path doesn't consider C: a parent of C:\.
46
PathRef
absoluteParent
(
PathRef
Path
);
47
}
// namespace clangd
48
}
// namespace clang
49
50
#endif
clang::clangd::Path
std::string Path
A typedef to represent a file path.
Definition:
Path.h:26
clang::clangd::pathEqual
bool pathEqual(PathRef A, PathRef B)
Definition:
Path.cpp:19
clang::clangd::maybeCaseFoldPath
std::string maybeCaseFoldPath(PathRef Path)
Definition:
Path.cpp:18
clang::clangd::pathStartsWith
bool pathStartsWith(PathRef Ancestor, PathRef Path, llvm::sys::path::Style Style)
Checks if Ancestor is a proper ancestor of Path.
Definition:
Path.cpp:36
clang::clangd::PathRef
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition:
Path.h:29
clang::clangd::absoluteParent
PathRef absoluteParent(PathRef Path)
Variant of parent_path that operates only on absolute paths.
Definition:
Path.cpp:22
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
Generated on Thu Jun 23 2022 17:22:53 for clang-tools by
1.8.17