]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/Utils.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / tools / clang / include / clang / Frontend / Utils.h
1 //===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This header contains miscellaneous utilities for various front-end actions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_FRONTEND_UTILS_H
15 #define LLVM_CLANG_FRONTEND_UTILS_H
16
17 #include "clang/Basic/Diagnostic.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include "llvm/Support/raw_ostream.h"
22 #include "clang/Basic/Diagnostic.h"
23
24 namespace llvm {
25 class Triple;
26 }
27
28 namespace clang {
29 class ASTConsumer;
30 class CompilerInstance;
31 class CompilerInvocation;
32 class Decl;
33 class DependencyOutputOptions;
34 class DiagnosticsEngine;
35 class DiagnosticOptions;
36 class FileManager;
37 class HeaderSearch;
38 class HeaderSearchOptions;
39 class IdentifierTable;
40 class LangOptions;
41 class Preprocessor;
42 class PreprocessorOptions;
43 class PreprocessorOutputOptions;
44 class SourceManager;
45 class Stmt;
46 class TargetInfo;
47 class FrontendOptions;
48
49 /// Normalize \arg File for use in a user defined #include directive (in the
50 /// predefines buffer).
51 std::string NormalizeDashIncludePath(StringRef File,
52                                      FileManager &FileMgr);
53
54 /// Apply the header search options to get given HeaderSearch object.
55 void ApplyHeaderSearchOptions(HeaderSearch &HS,
56                               const HeaderSearchOptions &HSOpts,
57                               const LangOptions &Lang,
58                               const llvm::Triple &triple);
59
60 /// InitializePreprocessor - Initialize the preprocessor getting it and the
61 /// environment ready to process a single file.
62 void InitializePreprocessor(Preprocessor &PP,
63                             const PreprocessorOptions &PPOpts,
64                             const HeaderSearchOptions &HSOpts,
65                             const FrontendOptions &FEOpts);
66
67 /// ProcessWarningOptions - Initialize the diagnostic client and process the
68 /// warning options specified on the command line.
69 void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts);
70
71 /// DoPrintPreprocessedInput - Implement -E mode.
72 void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,
73                               const PreprocessorOutputOptions &Opts);
74
75 /// AttachDependencyFileGen - Create a dependency file generator, and attach
76 /// it to the given preprocessor.  This takes ownership of the output stream.
77 void AttachDependencyFileGen(Preprocessor &PP,
78                              const DependencyOutputOptions &Opts);
79
80 /// AttachHeaderIncludeGen - Create a header include list generator, and attach
81 /// it to the given preprocessor.
82 ///
83 /// \param ShowAllHeaders - If true, show all header information instead of just
84 /// headers following the predefines buffer. This is useful for making sure
85 /// includes mentioned on the command line are also reported, but differs from
86 /// the default behavior used by -H.
87 /// \param OutputPath - If non-empty, a path to write the header include
88 /// information to, instead of writing to stderr.
89 void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false,
90                             StringRef OutputPath = "",
91                             bool ShowDepth = true);
92
93 /// CacheTokens - Cache tokens for use with PCH. Note that this requires
94 /// a seekable stream.
95 void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
96
97 /// createInvocationFromCommandLine - Construct a compiler invocation object for
98 /// a command line argument vector.
99 ///
100 /// \return A CompilerInvocation, or 0 if none was built for the given
101 /// argument vector.
102 CompilerInvocation *
103 createInvocationFromCommandLine(ArrayRef<const char *> Args,
104                             llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
105                                 llvm::IntrusiveRefCntPtr<DiagnosticsEngine>());
106
107 }  // end namespace clang
108
109 #endif