]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/PreprocessorOptions.h
Merge ACPICA 20100806.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Frontend / PreprocessorOptions.h
1 //===--- PreprocessorOptionms.h ---------------------------------*- 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 #ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
11 #define LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
12
13 #include "llvm/ADT/StringRef.h"
14 #include <cassert>
15 #include <string>
16 #include <utility>
17 #include <vector>
18
19 namespace llvm {
20   class MemoryBuffer;
21 }
22
23 namespace clang {
24
25 class Preprocessor;
26 class LangOptions;
27
28 /// PreprocessorOptions - This class is used for passing the various options
29 /// used in preprocessor initialization to InitializePreprocessor().
30 class PreprocessorOptions {
31 public:
32   std::vector<std::pair<std::string, bool/*isUndef*/> > Macros;
33   std::vector<std::string> Includes;
34   std::vector<std::string> MacroIncludes;
35
36   unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler
37                               /// and target specific predefines.
38
39   unsigned DetailedRecord : 1; /// Whether we should maintain a detailed
40                                /// record of all macro definitions and
41                                /// instantiations.
42   
43   /// The implicit PCH included at the start of the translation unit, or empty.
44   std::string ImplicitPCHInclude;
45
46   /// The implicit PTH input included at the start of the translation unit, or
47   /// empty.
48   std::string ImplicitPTHInclude;
49
50   /// If given, a PTH cache file to use for speeding up header parsing.
51   std::string TokenCache;
52
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
56   /// pair).
57   std::vector<std::pair<std::string, std::string> >  RemappedFiles;
58
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 *> > 
63     RemappedFileBuffers;
64   
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();
69   }
70   remapped_file_iterator remapped_file_end() const { 
71     return RemappedFiles.end();
72   }
73
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();
78   }
79   remapped_file_buffer_iterator remapped_file_buffer_end() const {
80     return RemappedFileBuffers.end();
81   }
82   
83 public:
84   PreprocessorOptions() : UsePredefines(true), DetailedRecord(false) {}
85
86   void addMacroDef(llvm::StringRef Name) {
87     Macros.push_back(std::make_pair(Name, false));
88   }
89   void addMacroUndef(llvm::StringRef Name) {
90     Macros.push_back(std::make_pair(Name, true));
91   }
92   void addRemappedFile(llvm::StringRef From, llvm::StringRef To) {
93     RemappedFiles.push_back(std::make_pair(From, To));
94   }
95   void addRemappedFile(llvm::StringRef From, const llvm::MemoryBuffer * To) {
96     RemappedFileBuffers.push_back(std::make_pair(From, To));
97   }
98 };
99
100 } // end namespace clang
101
102 #endif