blob: 60c0f226ef54f19e62476e11e396c79bcbbba098 [file] [log] [blame]
Daniel Dunbar775bee72009-11-11 10:07:22 +00001//===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===//
Reid Spencer5f016e22007-07-11 17:01:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
Eli Friedmanb09f6e12009-05-19 04:14:29 +000010// This header contains miscellaneous utilities for various front-end actions.
Reid Spencer5f016e22007-07-11 17:01:13 +000011//
12//===----------------------------------------------------------------------===//
13
Eli Friedmanb09f6e12009-05-19 04:14:29 +000014#ifndef LLVM_CLANG_FRONTEND_UTILS_H
15#define LLVM_CLANG_FRONTEND_UTILS_H
Reid Spencer5f016e22007-07-11 17:01:13 +000016
Ted Kremenekae360762007-12-03 22:06:55 +000017#include <vector>
18#include <string>
19
Eli Friedmanf54fce82009-05-19 01:02:07 +000020namespace llvm {
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000021class Triple;
Eli Friedmanf54fce82009-05-19 01:02:07 +000022class raw_ostream;
23class raw_fd_ostream;
24}
25
Reid Spencer5f016e22007-07-11 17:01:13 +000026namespace clang {
Ted Kremenek44579782007-09-25 18:37:20 +000027class ASTConsumer;
Argyrios Kyrtzidis53d4c142009-06-25 18:22:41 +000028class Decl;
Daniel Dunbar0e0bae82009-11-11 21:43:12 +000029class DependencyOutputOptions;
Daniel Dunbar8863b982009-11-07 04:20:15 +000030class Diagnostic;
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000031class HeaderSearch;
32class HeaderSearchOptions;
Daniel Dunbar8863b982009-11-07 04:20:15 +000033class IdentifierTable;
34class LangOptions;
35class MinimalAction;
36class Preprocessor;
37class PreprocessorOptions;
Daniel Dunbar775bee72009-11-11 10:07:22 +000038class PreprocessorOutputOptions;
Daniel Dunbar8863b982009-11-07 04:20:15 +000039class SourceManager;
Argyrios Kyrtzidis53d4c142009-06-25 18:22:41 +000040class Stmt;
Daniel Dunbar8863b982009-11-07 04:20:15 +000041class TargetInfo;
42
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000043/// Apply the header search options to get given HeaderSearch object.
Daniel Dunbar5814e652009-11-11 21:44:21 +000044void ApplyHeaderSearchOptions(HeaderSearch &HS,
45 const HeaderSearchOptions &HSOpts,
46 const LangOptions &Lang,
Daniel Dunbar2cdafa82009-11-09 23:02:47 +000047 const llvm::Triple &triple);
48
Daniel Dunbar8863b982009-11-07 04:20:15 +000049/// InitializePreprocessor - Initialize the preprocessor getting it and the
50/// environment ready to process a single file.
Daniel Dunbar8863b982009-11-07 04:20:15 +000051void InitializePreprocessor(Preprocessor &PP,
Daniel Dunbar961c76e2009-11-11 21:44:42 +000052 const PreprocessorOptions &PPOpts,
53 const HeaderSearchOptions &HSOpts);
Reid Spencer5f016e22007-07-11 17:01:13 +000054
Sebastian Redl63a9e0f2009-03-06 17:41:35 +000055/// ProcessWarningOptions - Initialize the diagnostic client and process the
56/// warning options specified on the command line.
Eli Friedman0eeb86e2009-05-19 01:17:04 +000057bool ProcessWarningOptions(Diagnostic &Diags,
58 std::vector<std::string> &Warnings,
59 bool Pedantic, bool PedanticErrors,
60 bool NoWarnings);
Sebastian Redl63a9e0f2009-03-06 17:41:35 +000061
Reid Spencer5f016e22007-07-11 17:01:13 +000062/// DoPrintPreprocessedInput - Implement -E mode.
Eli Friedman12d3b1d2009-05-19 03:06:47 +000063void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS,
Daniel Dunbar29cf7462009-11-11 10:07:44 +000064 const PreprocessorOutputOptions &Opts);
Reid Spencer5f016e22007-07-11 17:01:13 +000065
Chris Lattnerb57e3d42008-05-08 06:52:13 +000066/// RewriteMacrosInInput - Implement -rewrite-macros mode.
Eli Friedmanf54fce82009-05-19 01:02:07 +000067void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS);
Chris Lattnerb13c5ee2008-10-12 05:29:20 +000068
Eli Friedmanf54fce82009-05-19 01:02:07 +000069/// RewriteMacrosInInput - A simple test for the TokenRewriter class.
70void DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS);
Mike Stump1eb44332009-09-09 15:08:12 +000071
Reid Spencer5f016e22007-07-11 17:01:13 +000072/// CreatePrintParserActionsAction - Return the actions implementation that
73/// implements the -parse-print-callbacks option.
Eli Friedmanf54fce82009-05-19 01:02:07 +000074MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP,
75 llvm::raw_ostream* OS);
Reid Spencer5f016e22007-07-11 17:01:13 +000076
Argyrios Kyrtzidis14d41402008-06-13 12:15:34 +000077/// CheckDiagnostics - Gather the expected diagnostics and check them.
78bool CheckDiagnostics(Preprocessor &PP);
79
Eli Friedmanb5c8f8b2009-05-19 03:35:57 +000080/// AttachDependencyFileGen - Create a dependency file generator, and attach
81/// it to the given preprocessor. This takes ownership of the output stream.
Daniel Dunbarca11f612009-11-11 21:44:00 +000082void AttachDependencyFileGen(Preprocessor &PP,
Daniel Dunbar0e0bae82009-11-11 21:43:12 +000083 const DependencyOutputOptions &Opts);
Daniel Dunbar750c3582008-10-24 22:12:41 +000084
Eli Friedmanf54fce82009-05-19 01:02:07 +000085/// CacheTokens - Cache tokens for use with PCH. Note that this requires
86/// a seekable stream.
Daniel Dunbarca11f612009-11-11 21:44:00 +000087void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
Reid Spencer5f016e22007-07-11 17:01:13 +000088
Reid Spencer5f016e22007-07-11 17:01:13 +000089} // end namespace clang
90
91#endif