clang: lib/InstallAPI/HeaderFile.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10#include "llvm/TextAPI/Utils.h"

11

12using namespace llvm;

14

16 return llvm::Regex("/(.+)\\.framework/(.+)?Headers/(.+)");

17}

18

20

21 std::string Pattern = "/include/";

22 auto PathPrefix = FullPath.find(Pattern);

23 if (PathPrefix != StringRef::npos) {

24 PathPrefix += Pattern.size();

25 return FullPath.drop_front(PathPrefix).str();

26 }

27

28

31

32 if (Matches.size() != 4)

33 return std::nullopt;

34

35 return Matches[1].drop_front(Matches[1].rfind('/') + 1).str() + "/" +

36 Matches[3].str();

37}

38

40 return StringSwitch(sys::path::extension(Path))

41 .Cases(".h", ".H", ".hh", ".hpp", ".hxx", true)

42 .Default(false);

43}

44

47 std::error_code EC;

49 for (llvm::vfs::recursive_directory_iterator i(FS, Directory, EC), ie;

50 i != ie; i.increment(EC)) {

51 if (EC)

52 return errorCodeToError(EC);

53

54

55 if (FS.status(i->path()) == std::errc::no_such_file_or_directory)

56 continue;

57

58 StringRef Path = i->path();

60 Files.emplace_back(Path);

61 }

62

63 return Files;

64}

65

68

71 return false;

72

73 bool Match = Rule.match(Header.getPath());

74 if (Match)

75 FoundMatch = true;

76 return Match;

77}

78

81 auto Rule = MachO::createRegexFromGlob(GlobString);

82 if (!Rule)

83 return Rule.takeError();

84

85 return std::make_unique(GlobString, std::move(*Rule), Type);

86}

87

88}

llvm::MachO::PathSeq PathSeq

Implements support for file system lookup, file system caching, and directory search management.

llvm::vfs::FileSystem & getVirtualFileSystem() const

The base class of the type hierarchy.

The DirectoryScanner for collecting library files on the file system.

llvm::Expected< PathSeq > enumerateFiles(clang::FileManager &FM, StringRef Directory)

Given input directory, collect all header files.

std::optional< std::string > createIncludeHeaderName(const StringRef FullPath)

Assemble expected way header will be included by clients.

const Regex Rule("(.+)/(.+)\\.framework/")

bool isHeaderFile(StringRef Path)

Determine if Path is a header file.

Diagnostic wrappers for TextAPI types for error reporting.