1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//  This header contains miscellaneous utilities for various front-end actions.
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_CLANG_FRONTEND_UTILS_H
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_CLANG_FRONTEND_UTILS_H
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "clang/Basic/Diagnostic.h"
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "clang/Basic/VirtualFileSystem.h"
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/IntrusiveRefCntPtr.h"
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h"
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringSet.h"
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Option/OptSpecifier.h"
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <utility>
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass raw_fd_ostream;
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Triple;
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace opt {
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ArgList;
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace clang {
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ASTConsumer;
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ASTReader;
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass CompilerInstance;
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass CompilerInvocation;
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Decl;
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass DependencyOutputOptions;
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass DiagnosticsEngine;
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass DiagnosticOptions;
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ExternalSemaSource;
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass FileManager;
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass HeaderSearch;
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass HeaderSearchOptions;
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass IdentifierTable;
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass LangOptions;
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass PCHContainerReader;
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Preprocessor;
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass PreprocessorOptions;
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass PreprocessorOutputOptions;
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SourceManager;
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Stmt;
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetInfo;
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass FrontendOptions;
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Apply the header search options to get given HeaderSearch object.
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid ApplyHeaderSearchOptions(HeaderSearch &HS,
60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const HeaderSearchOptions &HSOpts,
61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const LangOptions &Lang,
62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const llvm::Triple &triple);
63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// InitializePreprocessor - Initialize the preprocessor getting it and the
65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// environment ready to process a single file.
66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts,
67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            const PCHContainerReader &PCHContainerRdr,
68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            const FrontendOptions &FEOpts);
69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// DoPrintPreprocessedInput - Implement -E mode.
71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,
72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const PreprocessorOutputOptions &Opts);
73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// An interface for collecting the dependencies of a compilation. Users should
75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// use \c attachToPreprocessor and \c attachToASTReader to get all of the
76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// dependencies.
77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// FIXME: Migrate DependencyFileGen and DependencyGraphGen to use this
78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// interface.
79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass DependencyCollector {
80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void attachToPreprocessor(Preprocessor &PP);
82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void attachToASTReader(ASTReader &R);
83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  llvm::ArrayRef<std::string> getDependencies() const { return Dependencies; }
84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Called when a new file is seen. Return true if \p Filename should be added
86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to the list of dependencies.
87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The default implementation ignores <built-in> and system files.
89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool sawDependency(StringRef Filename, bool FromModule,
90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                             bool IsSystem, bool IsModuleFile, bool IsMissing);
91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Called when the end of the main file is reached.
92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void finishedMainFile() { }
93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if system files should be passed to sawDependency().
94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool needSystemDependencies() { return false; }
95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual ~DependencyCollector();
96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic: // implementation detail
98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Add a dependency \p Filename if it has not been seen before and
99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sawDependency() returns true.
100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem,
101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          bool IsModuleFile, bool IsMissing);
102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  llvm::StringSet<> Seen;
104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::vector<std::string> Dependencies;
105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Builds a depdenency file when attached to a Preprocessor (for includes) and
108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// ASTReader (for module imports), and writes it out at the end of processing
109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// a source file.  Users should attach to the ast reader whenever a module is
110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// loaded.
111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass DependencyFileGenerator {
112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void *Impl; // Opaque implementation
113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  DependencyFileGenerator(void *Impl);
114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static DependencyFileGenerator *CreateAndAttachToPreprocessor(
116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Preprocessor &PP, const DependencyOutputOptions &Opts);
117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void AttachToASTReader(ASTReader &R);
118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Collects the dependencies for imported modules into a directory.  Users
121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// should attach to the AST reader whenever a module is loaded.
122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ModuleDependencyCollector : public DependencyCollector {
123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::string DestDir;
124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool HasErrors = false;
125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  llvm::StringSet<> Seen;
126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  vfs::YAMLVFSWriter VFSWriter;
127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  llvm::StringMap<std::string> SymLinkMap;
129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result);
131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::error_code copyToRoot(StringRef Src, StringRef Dst = "");
132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  StringRef getDest() { return DestDir; }
134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void addFile(StringRef Filename, StringRef FileDst = "");
136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void addFileMapping(StringRef VPath, StringRef RPath) {
137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    VFSWriter.addFileMapping(VPath, RPath);
138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void attachToPreprocessor(Preprocessor &PP) override;
141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void attachToASTReader(ASTReader &R) override;
142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void writeFileMap();
144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasErrors() { return HasErrors; }
145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ModuleDependencyCollector(std::string DestDir)
146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : DestDir(std::move(DestDir)) {}
147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ~ModuleDependencyCollector() { writeFileMap(); }
148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// AttachDependencyGraphGen - Create a dependency graph generator, and attach
151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// it to the given preprocessor.
152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              StringRef SysRoot);
154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// AttachHeaderIncludeGen - Create a header include list generator, and attach
156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// it to the given preprocessor.
157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param DepOpts - Options controlling the output.
159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param ShowAllHeaders - If true, show all header information instead of just
160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// headers following the predefines buffer. This is useful for making sure
161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// includes mentioned on the command line are also reported, but differs from
162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the default behavior used by -H.
163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param OutputPath - If non-empty, a path to write the header include
164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// information to, instead of writing to stderr.
165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param ShowDepth - Whether to indent to show the nesting of the includes.
166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param MSStyle - Whether to print in cl.exe /showIncludes style.
167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid AttachHeaderIncludeGen(Preprocessor &PP,
168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            const DependencyOutputOptions &DepOpts,
169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            bool ShowAllHeaders = false,
170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            StringRef OutputPath = "",
171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            bool ShowDepth = true, bool MSStyle = false);
172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Cache tokens for use with PCH. Note that this requires a seekable stream.
174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid CacheTokens(Preprocessor &PP, raw_pwrite_stream *OS);
175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// The ChainedIncludesSource class converts headers to chained PCHs in
177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// memory, mainly for testing.
178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotIntrusiveRefCntPtr<ExternalSemaSource>
179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team RobotcreateChainedIncludesSource(CompilerInstance &CI,
180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            IntrusiveRefCntPtr<ExternalSemaSource> &Reader);
181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// createInvocationFromCommandLine - Construct a compiler invocation object for
183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// a command line argument vector.
184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \return A CompilerInvocation, or 0 if none was built for the given
186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// argument vector.
187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstd::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(
188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ArrayRef<const char *> Args,
189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        IntrusiveRefCntPtr<DiagnosticsEngine>(),
191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Return the value of the last argument as an integer, or a default. If Diags
194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// is non-null, emits an error if the argument is given, but non-integral.
195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotint getLastArgIntValue(const llvm::opt::ArgList &Args,
196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       llvm::opt::OptSpecifier Id, int Default,
197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       DiagnosticsEngine *Diags = nullptr);
198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline int getLastArgIntValue(const llvm::opt::ArgList &Args,
200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              llvm::opt::OptSpecifier Id, int Default,
201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              DiagnosticsEngine &Diags) {
202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getLastArgIntValue(Args, Id, Default, &Diags);
203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotuint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               llvm::opt::OptSpecifier Id, uint64_t Default,
207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               DiagnosticsEngine *Diags = nullptr);
208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      llvm::opt::OptSpecifier Id,
211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      uint64_t Default,
212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      DiagnosticsEngine &Diags) {
213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getLastArgUInt64Value(Args, Id, Default, &Diags);
214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// When Clang->getFrontendOpts().DisableFree is set we don't delete some of the
217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// global objects, but we don't want LeakDetectors to complain, so we bury them
218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// in a globally visible array.
219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid BuryPointer(const void *Ptr);
220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate <typename T> void BuryPointer(std::unique_ptr<T> Ptr) {
221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  BuryPointer(Ptr.release());
222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace clang
225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif
227