aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend/InitHeaderSearch.h
blob: a90b4eaf9e2b50a7ee782aa8dfbeca33a4d304f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//===--- InitHeaderSearch.h - Initialize header search paths ----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the InitHeaderSearch class.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_FRONTEND_INIT_HEADER_SEARCH_H_
#define LLVM_CLANG_FRONTEND_INIT_HEADER_SEARCH_H_

#include "clang/Lex/DirectoryLookup.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include <string>
#include <vector>

namespace clang {

class HeaderSearch;
class LangOptions;

/// InitHeaderSearch - This class makes it easier to set the search paths of
///  a HeaderSearch object. InitHeaderSearch stores several search path lists
///  internally, which can be sent to a HeaderSearch object in one swoop.
class InitHeaderSearch {
  std::vector<DirectoryLookup> IncludeGroup[4];
  HeaderSearch& Headers;
  bool Verbose;
  std::string isysroot;

public:
  /// InitHeaderSearch::IncludeDirGroup - Identifies the several search path
  ///  lists stored internally.
  enum IncludeDirGroup {
    Quoted = 0,     //< `#include ""` paths. Thing `gcc -iquote`.
    Angled,         //< Paths for both `#include ""` and `#include <>`. (`-I`)
    System,         //< Like Angled, but marks system directories.
    After           //< Like System, but searched after the system directories.
  };

  InitHeaderSearch(HeaderSearch &HS,
      bool verbose = false, const std::string &iSysroot = "")
    : Headers(HS), Verbose(verbose), isysroot(iSysroot) {}

  /// AddPath - Add the specified path to the specified group list.
  void AddPath(const llvm::StringRef &Path, IncludeDirGroup Group,
               bool isCXXAware, bool isUserSupplied,
               bool isFramework, bool IgnoreSysRoot = false);

  /// AddEnvVarPaths - Add a list of paths from an environment variable to a
  ///  header search list.
  void AddEnvVarPaths(const char *Name);

  /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to suport a gnu
  ///  libstdc++.
  void AddGnuCPlusPlusIncludePaths(const std::string &Base, const char *Dir32,
                                   const char *Dir64,
                                   const llvm::Triple &triple);

  /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to suport a MinGW
  ///  libstdc++.
  void AddMinGWCPlusPlusIncludePaths(const std::string &Base,
                                     const char *Arch,
                                     const char *Version);

  /// AddDefaultEnvVarPaths - Adds list of paths from default environment
  ///  variables such as CPATH.
  void AddDefaultEnvVarPaths(const LangOptions &Lang);

  /// AddDefaultSystemIncludePaths - Adds the default system include paths so
  ///  that e.g. stdio.h is found.
  void AddDefaultSystemIncludePaths(const LangOptions &Lang,
                                    const llvm::Triple &triple);

  /// Realize - Merges all search path lists into one list and send it to
  /// HeaderSearch.
  void Realize();
};

} // end namespace clang

#endif