Daniel Dunbar | 775bee7 | 2009-11-11 10:07:22 +0000 | [diff] [blame] | 1 | //===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===// |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Eli Friedman | b09f6e1 | 2009-05-19 04:14:29 +0000 | [diff] [blame] | 10 | // This header contains miscellaneous utilities for various front-end actions. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Eli Friedman | b09f6e1 | 2009-05-19 04:14:29 +0000 | [diff] [blame] | 14 | #ifndef LLVM_CLANG_FRONTEND_UTILS_H |
| 15 | #define LLVM_CLANG_FRONTEND_UTILS_H |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | |
Ted Kremenek | ae36076 | 2007-12-03 22:06:55 +0000 | [diff] [blame] | 17 | #include <vector> |
| 18 | #include <string> |
| 19 | |
Eli Friedman | f54fce8 | 2009-05-19 01:02:07 +0000 | [diff] [blame] | 20 | namespace llvm { |
Daniel Dunbar | 2cdafa8 | 2009-11-09 23:02:47 +0000 | [diff] [blame] | 21 | class Triple; |
Eli Friedman | f54fce8 | 2009-05-19 01:02:07 +0000 | [diff] [blame] | 22 | class raw_ostream; |
| 23 | class raw_fd_ostream; |
| 24 | } |
| 25 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 26 | namespace clang { |
Ted Kremenek | 4457978 | 2007-09-25 18:37:20 +0000 | [diff] [blame] | 27 | class ASTConsumer; |
Argyrios Kyrtzidis | 53d4c14 | 2009-06-25 18:22:41 +0000 | [diff] [blame] | 28 | class Decl; |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 29 | class DependencyOutputOptions; |
Daniel Dunbar | 8863b98 | 2009-11-07 04:20:15 +0000 | [diff] [blame] | 30 | class Diagnostic; |
Daniel Dunbar | 2cdafa8 | 2009-11-09 23:02:47 +0000 | [diff] [blame] | 31 | class HeaderSearch; |
| 32 | class HeaderSearchOptions; |
Daniel Dunbar | 8863b98 | 2009-11-07 04:20:15 +0000 | [diff] [blame] | 33 | class IdentifierTable; |
| 34 | class LangOptions; |
| 35 | class MinimalAction; |
| 36 | class Preprocessor; |
| 37 | class PreprocessorOptions; |
Daniel Dunbar | 775bee7 | 2009-11-11 10:07:22 +0000 | [diff] [blame] | 38 | class PreprocessorOutputOptions; |
Daniel Dunbar | 8863b98 | 2009-11-07 04:20:15 +0000 | [diff] [blame] | 39 | class SourceManager; |
Argyrios Kyrtzidis | 53d4c14 | 2009-06-25 18:22:41 +0000 | [diff] [blame] | 40 | class Stmt; |
Daniel Dunbar | 8863b98 | 2009-11-07 04:20:15 +0000 | [diff] [blame] | 41 | class TargetInfo; |
| 42 | |
Daniel Dunbar | 2cdafa8 | 2009-11-09 23:02:47 +0000 | [diff] [blame] | 43 | /// Apply the header search options to get given HeaderSearch object. |
Daniel Dunbar | 5814e65 | 2009-11-11 21:44:21 +0000 | [diff] [blame] | 44 | void ApplyHeaderSearchOptions(HeaderSearch &HS, |
| 45 | const HeaderSearchOptions &HSOpts, |
| 46 | const LangOptions &Lang, |
Daniel Dunbar | 2cdafa8 | 2009-11-09 23:02:47 +0000 | [diff] [blame] | 47 | const llvm::Triple &triple); |
| 48 | |
Daniel Dunbar | 8863b98 | 2009-11-07 04:20:15 +0000 | [diff] [blame] | 49 | /// InitializePreprocessor - Initialize the preprocessor getting it and the |
| 50 | /// environment ready to process a single file. |
Daniel Dunbar | 8863b98 | 2009-11-07 04:20:15 +0000 | [diff] [blame] | 51 | void InitializePreprocessor(Preprocessor &PP, |
Daniel Dunbar | 961c76e | 2009-11-11 21:44:42 +0000 | [diff] [blame] | 52 | const PreprocessorOptions &PPOpts, |
| 53 | const HeaderSearchOptions &HSOpts); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 54 | |
Sebastian Redl | 63a9e0f | 2009-03-06 17:41:35 +0000 | [diff] [blame] | 55 | /// ProcessWarningOptions - Initialize the diagnostic client and process the |
| 56 | /// warning options specified on the command line. |
Eli Friedman | 0eeb86e | 2009-05-19 01:17:04 +0000 | [diff] [blame] | 57 | bool ProcessWarningOptions(Diagnostic &Diags, |
| 58 | std::vector<std::string> &Warnings, |
| 59 | bool Pedantic, bool PedanticErrors, |
| 60 | bool NoWarnings); |
Sebastian Redl | 63a9e0f | 2009-03-06 17:41:35 +0000 | [diff] [blame] | 61 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 62 | /// DoPrintPreprocessedInput - Implement -E mode. |
Eli Friedman | 12d3b1d | 2009-05-19 03:06:47 +0000 | [diff] [blame] | 63 | void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS, |
Daniel Dunbar | 29cf746 | 2009-11-11 10:07:44 +0000 | [diff] [blame] | 64 | const PreprocessorOutputOptions &Opts); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 65 | |
Chris Lattner | b57e3d4 | 2008-05-08 06:52:13 +0000 | [diff] [blame] | 66 | /// RewriteMacrosInInput - Implement -rewrite-macros mode. |
Eli Friedman | f54fce8 | 2009-05-19 01:02:07 +0000 | [diff] [blame] | 67 | void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS); |
Chris Lattner | b13c5ee | 2008-10-12 05:29:20 +0000 | [diff] [blame] | 68 | |
Eli Friedman | f54fce8 | 2009-05-19 01:02:07 +0000 | [diff] [blame] | 69 | /// RewriteMacrosInInput - A simple test for the TokenRewriter class. |
| 70 | void DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 71 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 72 | /// CreatePrintParserActionsAction - Return the actions implementation that |
| 73 | /// implements the -parse-print-callbacks option. |
Eli Friedman | f54fce8 | 2009-05-19 01:02:07 +0000 | [diff] [blame] | 74 | MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP, |
| 75 | llvm::raw_ostream* OS); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 76 | |
Argyrios Kyrtzidis | 14d4140 | 2008-06-13 12:15:34 +0000 | [diff] [blame] | 77 | /// CheckDiagnostics - Gather the expected diagnostics and check them. |
| 78 | bool CheckDiagnostics(Preprocessor &PP); |
| 79 | |
Eli Friedman | b5c8f8b | 2009-05-19 03:35:57 +0000 | [diff] [blame] | 80 | /// AttachDependencyFileGen - Create a dependency file generator, and attach |
| 81 | /// it to the given preprocessor. This takes ownership of the output stream. |
Daniel Dunbar | ca11f61 | 2009-11-11 21:44:00 +0000 | [diff] [blame] | 82 | void AttachDependencyFileGen(Preprocessor &PP, |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 83 | const DependencyOutputOptions &Opts); |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 84 | |
Eli Friedman | f54fce8 | 2009-05-19 01:02:07 +0000 | [diff] [blame] | 85 | /// CacheTokens - Cache tokens for use with PCH. Note that this requires |
| 86 | /// a seekable stream. |
Daniel Dunbar | ca11f61 | 2009-11-11 21:44:00 +0000 | [diff] [blame] | 87 | void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 88 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 89 | } // end namespace clang |
| 90 | |
| 91 | #endif |