clang  20.0.0git
Library.cpp
Go to the documentation of this file.
1 //===- Library.cpp --------------------------------------------------------===//
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 
10 
11 using namespace llvm;
12 namespace clang::installapi {
13 
14 const Regex Rule("(.+)/(.+)\\.framework/");
15 StringRef Library::getFrameworkNameFromInstallName(StringRef InstallName) {
16  assert(InstallName.contains(".framework") && "expected a framework");
18  Rule.match(InstallName, &Match);
19  if (Match.empty())
20  return "";
21  return Match.back();
22 }
23 
24 StringRef Library::getName() const {
25  assert(!IsUnwrappedDylib && "expected a framework");
26  StringRef Path = BaseDirectory;
27 
28  // Return the framework name extracted from path.
29  while (!Path.empty()) {
30  if (Path.ends_with(".framework"))
31  return sys::path::filename(Path);
32  Path = sys::path::parent_path(Path);
33  }
34 
35  // Otherwise, return the name of the BaseDirectory.
36  Path = BaseDirectory;
37  return sys::path::filename(Path.rtrim("/"));
38 }
39 
40 } // namespace clang::installapi
IndirectLocalPath & Path
static std::string getName(const CallEvent &Call)
The DirectoryScanner for collecting library files on the file system.
Definition: Context.h:20
const Regex Rule("(.+)/(.+)\\.framework/")
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30