clang-tools 19.0.0git
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
21namespace clang {
22namespace clangd {
23
24/// A typedef to represent a file path. Used solely for more descriptive
25/// signatures.
26using Path = std::string;
27/// A typedef to represent a ref to file path. Used solely for more descriptive
28/// signatures.
29using 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.
34std::string maybeCaseFoldPath(PathRef Path);
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.
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:\.
47} // namespace clangd
48} // namespace clang
49
50#endif
std::string maybeCaseFoldPath(PathRef Path)
Definition: Path.cpp:18
bool pathEqual(PathRef A, PathRef B)
Definition: Path.cpp:19
std::string Path
A typedef to represent a file path.
Definition: Path.h:26
bool pathStartsWith(PathRef Ancestor, PathRef Path, llvm::sys::path::Style Style)
Checks if Ancestor is a proper ancestor of Path.
Definition: Path.cpp:36
PathRef absoluteParent(PathRef Path)
Variant of parent_path that operates only on absolute paths.
Definition: Path.cpp:22
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:29
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//