Utils.h revision 87c300738174924453648c3b2d6f366c8284fac4
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 "llvm/ADT/StringRef.h"
18#include "llvm/Support/raw_ostream.h"
19
20namespace llvm {
21class Triple;
22}
23
24namespace clang {
25class ASTConsumer;
26class Decl;
27class DependencyOutputOptions;
28class Diagnostic;
29class DiagnosticOptions;
30class HeaderSearch;
31class HeaderSearchOptions;
32class IdentifierTable;
33class LangOptions;
34class Preprocessor;
35class PreprocessorOptions;
36class PreprocessorOutputOptions;
37class SourceManager;
38class Stmt;
39class TargetInfo;
40class FrontendOptions;
41
42/// Normalize \arg File for use in a user defined #include directive (in the
43/// predefines buffer).
44std::string NormalizeDashIncludePath(llvm::StringRef File);
45
46/// Apply the header search options to get given HeaderSearch object.
47void ApplyHeaderSearchOptions(HeaderSearch &HS,
48                              const HeaderSearchOptions &HSOpts,
49                              const LangOptions &Lang,
50                              const llvm::Triple &triple);
51
52/// InitializePreprocessor - Initialize the preprocessor getting it and the
53/// environment ready to process a single file.
54void InitializePreprocessor(Preprocessor &PP,
55                            const PreprocessorOptions &PPOpts,
56                            const HeaderSearchOptions &HSOpts,
57                            const FrontendOptions &FEOpts);
58
59/// ProcessWarningOptions - Initialize the diagnostic client and process the
60/// warning options specified on the command line.
61void ProcessWarningOptions(Diagnostic &Diags, const DiagnosticOptions &Opts);
62
63/// DoPrintPreprocessedInput - Implement -E mode.
64void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS,
65                              const PreprocessorOutputOptions &Opts);
66
67/// CheckDiagnostics - Gather the expected diagnostics and check them.
68bool CheckDiagnostics(Preprocessor &PP);
69
70/// AttachDependencyFileGen - Create a dependency file generator, and attach
71/// it to the given preprocessor.  This takes ownership of the output stream.
72void AttachDependencyFileGen(Preprocessor &PP,
73                             const DependencyOutputOptions &Opts);
74
75/// CacheTokens - Cache tokens for use with PCH. Note that this requires
76/// a seekable stream.
77void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
78
79}  // end namespace clang
80
81#endif
82