1 //===--- Path.h - Helper typedefs --------------------------------*- C++-*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_PATH_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_PATH_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/Path.h"
16 /// Whether current platform treats paths case insensitively.
17 #if defined(_WIN32) || defined(__APPLE__)
18 #define CLANGD_PATH_CASE_INSENSITIVE
24 /// A typedef to represent a file path. Used solely for more descriptive
26 using Path
= std::string
;
27 /// A typedef to represent a ref to file path. Used solely for more descriptive
29 using PathRef
= llvm::StringRef
;
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
);
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
);
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
);