1 //===--- PreprocessorOptionms.h ---------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
11 #define LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
13 #include "llvm/ADT/StringRef.h"
28 /// PreprocessorOptions - This class is used for passing the various options
29 /// used in preprocessor initialization to InitializePreprocessor().
30 class PreprocessorOptions {
32 std::vector<std::pair<std::string, bool/*isUndef*/> > Macros;
33 std::vector<std::string> Includes;
34 std::vector<std::string> MacroIncludes;
36 unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler
37 /// and target specific predefines.
39 unsigned DetailedRecord : 1; /// Whether we should maintain a detailed
40 /// record of all macro definitions and
43 /// The implicit PCH included at the start of the translation unit, or empty.
44 std::string ImplicitPCHInclude;
46 /// The implicit PTH input included at the start of the translation unit, or
48 std::string ImplicitPTHInclude;
50 /// If given, a PTH cache file to use for speeding up header parsing.
51 std::string TokenCache;
53 /// \brief The set of file remappings, which take existing files on
54 /// the system (the first part of each pair) and gives them the
55 /// contents of other files on the system (the second part of each
57 std::vector<std::pair<std::string, std::string> > RemappedFiles;
59 /// \brief The set of file-to-buffer remappings, which take existing files
60 /// on the system (the first part of each pair) and gives them the contents
61 /// of the specified memory buffer (the second part of each pair).
62 std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >
65 typedef std::vector<std::pair<std::string, std::string> >::const_iterator
66 remapped_file_iterator;
67 remapped_file_iterator remapped_file_begin() const {
68 return RemappedFiles.begin();
70 remapped_file_iterator remapped_file_end() const {
71 return RemappedFiles.end();
74 typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >::
75 const_iterator remapped_file_buffer_iterator;
76 remapped_file_buffer_iterator remapped_file_buffer_begin() const {
77 return RemappedFileBuffers.begin();
79 remapped_file_buffer_iterator remapped_file_buffer_end() const {
80 return RemappedFileBuffers.end();
84 PreprocessorOptions() : UsePredefines(true), DetailedRecord(false) {}
86 void addMacroDef(llvm::StringRef Name) {
87 Macros.push_back(std::make_pair(Name, false));
89 void addMacroUndef(llvm::StringRef Name) {
90 Macros.push_back(std::make_pair(Name, true));
92 void addRemappedFile(llvm::StringRef From, llvm::StringRef To) {
93 RemappedFiles.push_back(std::make_pair(From, To));
95 void addRemappedFile(llvm::StringRef From, const llvm::MemoryBuffer * To) {
96 RemappedFileBuffers.push_back(std::make_pair(From, To));
100 } // end namespace clang