xref: /llvm-project/clang/lib/Frontend/InitPreprocessor.cpp (revision 80110179f49de99e52e5167568b151c1ab420b96)
1 //===--- InitPreprocessor.cpp - PP initialization code. ---------*- 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 file implements the clang::InitializePreprocessor function.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/Frontend/InitPreprocessor.h"
15 #include "clang/Basic/TargetInfo.h"
16 #include "clang/Lex/Preprocessor.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/System/Path.h"
20 
21 namespace clang {
22 
23 // Append a #define line to Buf for Macro.  Macro should be of the form XXX,
24 // in which case we emit "#define XXX 1" or "XXX=Y z W" in which case we emit
25 // "#define XXX Y z W".  To get a #define with no value, use "XXX=".
26 static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) {
27   const char *Command = "#define ";
28   Buf.insert(Buf.end(), Command, Command+strlen(Command));
29   if (const char *Equal = strchr(Macro, '=')) {
30     // Turn the = into ' '.
31     Buf.insert(Buf.end(), Macro, Equal);
32     Buf.push_back(' ');
33 
34     // Per GCC -D semantics, the macro ends at \n if it exists.
35     const char *End = strpbrk(Equal, "\n\r");
36     if (End) {
37       fprintf(stderr, "warning: macro '%s' contains embedded newline, text "
38               "after the newline is ignored.\n",
39               std::string(Macro, Equal).c_str());
40     } else {
41       End = Equal+strlen(Equal);
42     }
43 
44     Buf.insert(Buf.end(), Equal+1, End);
45   } else {
46     // Push "macroname 1".
47     Buf.insert(Buf.end(), Macro, Macro+strlen(Macro));
48     Buf.push_back(' ');
49     Buf.push_back('1');
50   }
51   Buf.push_back('\n');
52 }
53 
54 // Append a #undef line to Buf for Macro.  Macro should be of the form XXX
55 // and we emit "#undef XXX".
56 static void UndefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) {
57   // Push "macroname".
58   const char *Command = "#undef ";
59   Buf.insert(Buf.end(), Command, Command+strlen(Command));
60   Buf.insert(Buf.end(), Macro, Macro+strlen(Macro));
61   Buf.push_back('\n');
62 }
63 
64 /// Add the quoted name of an implicit include file.
65 static void AddQuotedIncludePath(std::vector<char> &Buf,
66                                  const std::string &File) {
67   // Implicit include paths should be resolved relative to the current
68   // working directory first, and then use the regular header search
69   // mechanism. The proper way to handle this is to have the
70   // predefines buffer located at the current working directory, but
71   // it has not file entry. For now, workaround this by using an
72   // absolute path if we find the file here, and otherwise letting
73   // header search handle it.
74   llvm::sys::Path Path(File);
75   Path.makeAbsolute();
76   if (!Path.exists())
77     Path = File;
78 
79   // Escape double quotes etc.
80   Buf.push_back('"');
81   std::string EscapedFile = Lexer::Stringify(Path.str());
82   Buf.insert(Buf.end(), EscapedFile.begin(), EscapedFile.end());
83   Buf.push_back('"');
84 }
85 
86 /// AddImplicitInclude - Add an implicit #include of the specified file to the
87 /// predefines buffer.
88 static void AddImplicitInclude(std::vector<char> &Buf,
89                                const std::string &File) {
90   const char *Inc = "#include ";
91   Buf.insert(Buf.end(), Inc, Inc+strlen(Inc));
92   AddQuotedIncludePath(Buf, File);
93   Buf.push_back('\n');
94 }
95 
96 static void AddImplicitIncludeMacros(std::vector<char> &Buf,
97                                      const std::string &File) {
98   const char *Inc = "#__include_macros ";
99   Buf.insert(Buf.end(), Inc, Inc+strlen(Inc));
100   AddQuotedIncludePath(Buf, File);
101   Buf.push_back('\n');
102   // Marker token to stop the __include_macros fetch loop.
103   const char *Marker = "##\n"; // ##?
104   Buf.insert(Buf.end(), Marker, Marker+strlen(Marker));
105 }
106 
107 /// AddImplicitIncludePTH - Add an implicit #include using the original file
108 ///  used to generate a PTH cache.
109 static void AddImplicitIncludePTH(std::vector<char> &Buf, Preprocessor &PP,
110   const std::string& ImplicitIncludePTH) {
111   PTHManager *P = PP.getPTHManager();
112   assert(P && "No PTHManager.");
113   const char *OriginalFile = P->getOriginalSourceFile();
114 
115   if (!OriginalFile) {
116     assert(!ImplicitIncludePTH.empty());
117     fprintf(stderr, "error: PTH file '%s' does not designate an original "
118             "source header file for -include-pth\n",
119             ImplicitIncludePTH.c_str());
120     exit (1);
121   }
122 
123   AddImplicitInclude(Buf, OriginalFile);
124 }
125 
126 /// PickFP - This is used to pick a value based on the FP semantics of the
127 /// specified FP model.
128 template <typename T>
129 static T PickFP(const llvm::fltSemantics *Sem, T IEEESingleVal,
130                 T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal,
131                 T IEEEQuadVal) {
132   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle)
133     return IEEESingleVal;
134   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEdouble)
135     return IEEEDoubleVal;
136   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::x87DoubleExtended)
137     return X87DoubleExtendedVal;
138   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble)
139     return PPCDoubleDoubleVal;
140   assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad);
141   return IEEEQuadVal;
142 }
143 
144 static void DefineFloatMacros(std::vector<char> &Buf, const char *Prefix,
145                               const llvm::fltSemantics *Sem) {
146   const char *DenormMin, *Epsilon, *Max, *Min;
147   DenormMin = PickFP(Sem, "1.40129846e-45F", "4.9406564584124654e-324",
148                      "3.64519953188247460253e-4951L",
149                      "4.94065645841246544176568792868221e-324L",
150                      "6.47517511943802511092443895822764655e-4966L");
151   int Digits = PickFP(Sem, 6, 15, 18, 31, 33);
152   Epsilon = PickFP(Sem, "1.19209290e-7F", "2.2204460492503131e-16",
153                    "1.08420217248550443401e-19L",
154                    "4.94065645841246544176568792868221e-324L",
155                    "1.92592994438723585305597794258492732e-34L");
156   int HasInifinity = 1, HasQuietNaN = 1;
157   int MantissaDigits = PickFP(Sem, 24, 53, 64, 106, 113);
158   int Min10Exp = PickFP(Sem, -37, -307, -4931, -291, -4931);
159   int Max10Exp = PickFP(Sem, 38, 308, 4932, 308, 4932);
160   int MinExp = PickFP(Sem, -125, -1021, -16381, -968, -16381);
161   int MaxExp = PickFP(Sem, 128, 1024, 16384, 1024, 16384);
162   Min = PickFP(Sem, "1.17549435e-38F", "2.2250738585072014e-308",
163                "3.36210314311209350626e-4932L",
164                "2.00416836000897277799610805135016e-292L",
165                "3.36210314311209350626267781732175260e-4932L");
166   Max = PickFP(Sem, "3.40282347e+38F", "1.7976931348623157e+308",
167                "1.18973149535723176502e+4932L",
168                "1.79769313486231580793728971405301e+308L",
169                "1.18973149535723176508575932662800702e+4932L");
170 
171   char MacroBuf[100];
172   sprintf(MacroBuf, "__%s_DENORM_MIN__=%s", Prefix, DenormMin);
173   DefineBuiltinMacro(Buf, MacroBuf);
174   sprintf(MacroBuf, "__%s_DIG__=%d", Prefix, Digits);
175   DefineBuiltinMacro(Buf, MacroBuf);
176   sprintf(MacroBuf, "__%s_EPSILON__=%s", Prefix, Epsilon);
177   DefineBuiltinMacro(Buf, MacroBuf);
178   sprintf(MacroBuf, "__%s_HAS_INFINITY__=%d", Prefix, HasInifinity);
179   DefineBuiltinMacro(Buf, MacroBuf);
180   sprintf(MacroBuf, "__%s_HAS_QUIET_NAN__=%d", Prefix, HasQuietNaN);
181   DefineBuiltinMacro(Buf, MacroBuf);
182   sprintf(MacroBuf, "__%s_MANT_DIG__=%d", Prefix, MantissaDigits);
183   DefineBuiltinMacro(Buf, MacroBuf);
184   sprintf(MacroBuf, "__%s_MAX_10_EXP__=%d", Prefix, Max10Exp);
185   DefineBuiltinMacro(Buf, MacroBuf);
186   sprintf(MacroBuf, "__%s_MAX_EXP__=%d", Prefix, MaxExp);
187   DefineBuiltinMacro(Buf, MacroBuf);
188   sprintf(MacroBuf, "__%s_MAX__=%s", Prefix, Max);
189   DefineBuiltinMacro(Buf, MacroBuf);
190   sprintf(MacroBuf, "__%s_MIN_10_EXP__=(%d)", Prefix, Min10Exp);
191   DefineBuiltinMacro(Buf, MacroBuf);
192   sprintf(MacroBuf, "__%s_MIN_EXP__=(%d)", Prefix, MinExp);
193   DefineBuiltinMacro(Buf, MacroBuf);
194   sprintf(MacroBuf, "__%s_MIN__=%s", Prefix, Min);
195   DefineBuiltinMacro(Buf, MacroBuf);
196   sprintf(MacroBuf, "__%s_HAS_DENORM__=1", Prefix);
197   DefineBuiltinMacro(Buf, MacroBuf);
198 }
199 
200 
201 /// DefineTypeSize - Emit a macro to the predefines buffer that declares a macro
202 /// named MacroName with the max value for a type with width 'TypeWidth' a
203 /// signedness of 'isSigned' and with a value suffix of 'ValSuffix' (e.g. LL).
204 static void DefineTypeSize(const char *MacroName, unsigned TypeWidth,
205                            const char *ValSuffix, bool isSigned,
206                            std::vector<char> &Buf) {
207   char MacroBuf[60];
208   long long MaxVal;
209   if (isSigned)
210     MaxVal = (1LL << (TypeWidth - 1)) - 1;
211   else
212     MaxVal = ~0LL >> (64-TypeWidth);
213 
214   sprintf(MacroBuf, "%s=%llu%s", MacroName, MaxVal, ValSuffix);
215   DefineBuiltinMacro(Buf, MacroBuf);
216 }
217 
218 static void DefineType(const char *MacroName, TargetInfo::IntType Ty,
219                        std::vector<char> &Buf) {
220   char MacroBuf[60];
221   sprintf(MacroBuf, "%s=%s", MacroName, TargetInfo::getTypeName(Ty));
222   DefineBuiltinMacro(Buf, MacroBuf);
223 }
224 
225 
226 static void InitializePredefinedMacros(const TargetInfo &TI,
227                                        const LangOptions &LangOpts,
228                                        std::vector<char> &Buf) {
229   char MacroBuf[60];
230   // Compiler version introspection macros.
231   DefineBuiltinMacro(Buf, "__llvm__=1");   // LLVM Backend
232   DefineBuiltinMacro(Buf, "__clang__=1");  // Clang Frontend
233 
234   // Currently claim to be compatible with GCC 4.2.1-5621.
235   DefineBuiltinMacro(Buf, "__GNUC_MINOR__=2");
236   DefineBuiltinMacro(Buf, "__GNUC_PATCHLEVEL__=1");
237   DefineBuiltinMacro(Buf, "__GNUC__=4");
238   DefineBuiltinMacro(Buf, "__GXX_ABI_VERSION=1002");
239   DefineBuiltinMacro(Buf, "__VERSION__=\"4.2.1 Compatible Clang Compiler\"");
240 
241 
242   // Initialize language-specific preprocessor defines.
243 
244   // These should all be defined in the preprocessor according to the
245   // current language configuration.
246   if (!LangOpts.Microsoft)
247     DefineBuiltinMacro(Buf, "__STDC__=1");
248   if (LangOpts.AsmPreprocessor)
249     DefineBuiltinMacro(Buf, "__ASSEMBLER__=1");
250 
251   if (!LangOpts.CPlusPlus) {
252     if (LangOpts.C99)
253       DefineBuiltinMacro(Buf, "__STDC_VERSION__=199901L");
254     else if (!LangOpts.GNUMode && LangOpts.Digraphs)
255       DefineBuiltinMacro(Buf, "__STDC_VERSION__=199409L");
256   }
257 
258   // Standard conforming mode?
259   if (!LangOpts.GNUMode)
260     DefineBuiltinMacro(Buf, "__STRICT_ANSI__=1");
261 
262   if (LangOpts.CPlusPlus0x)
263     DefineBuiltinMacro(Buf, "__GXX_EXPERIMENTAL_CXX0X__");
264 
265   if (LangOpts.Freestanding)
266     DefineBuiltinMacro(Buf, "__STDC_HOSTED__=0");
267   else
268     DefineBuiltinMacro(Buf, "__STDC_HOSTED__=1");
269 
270   if (LangOpts.ObjC1) {
271     DefineBuiltinMacro(Buf, "__OBJC__=1");
272     if (LangOpts.ObjCNonFragileABI) {
273       DefineBuiltinMacro(Buf, "__OBJC2__=1");
274       DefineBuiltinMacro(Buf, "OBJC_ZEROCOST_EXCEPTIONS=1");
275       DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
276     }
277 
278     if (LangOpts.getGCMode() != LangOptions::NonGC)
279       DefineBuiltinMacro(Buf, "__OBJC_GC__=1");
280 
281     if (LangOpts.NeXTRuntime)
282       DefineBuiltinMacro(Buf, "__NEXT_RUNTIME__=1");
283   }
284 
285   // darwin_constant_cfstrings controls this. This is also dependent
286   // on other things like the runtime I believe.  This is set even for C code.
287   DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
288 
289   if (LangOpts.ObjC2)
290     DefineBuiltinMacro(Buf, "OBJC_NEW_PROPERTIES");
291 
292   if (LangOpts.ObjCSenderDispatch)
293     DefineBuiltinMacro(Buf, "__OBJC_SENDER_AWARE_DISPATCH__");
294 
295   if (LangOpts.PascalStrings)
296     DefineBuiltinMacro(Buf, "__PASCAL_STRINGS__");
297 
298   if (LangOpts.Blocks) {
299     DefineBuiltinMacro(Buf, "__block=__attribute__((__blocks__(byref)))");
300     DefineBuiltinMacro(Buf, "__BLOCKS__=1");
301   }
302 
303   if (LangOpts.CPlusPlus) {
304     DefineBuiltinMacro(Buf, "__DEPRECATED=1");
305     DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
306     DefineBuiltinMacro(Buf, "__GNUG__=4");
307     DefineBuiltinMacro(Buf, "__GXX_WEAK__=1");
308     if (LangOpts.GNUMode)
309       DefineBuiltinMacro(Buf, "__cplusplus=1");
310     else
311       // C++ [cpp.predefined]p1:
312       //   The name_ _cplusplusis defined to the value199711Lwhen compiling a
313       //   C++ translation unit.
314       DefineBuiltinMacro(Buf, "__cplusplus=199711L");
315     DefineBuiltinMacro(Buf, "__private_extern__=extern");
316     // Ugly hack to work with GNU libstdc++.
317     DefineBuiltinMacro(Buf, "_GNU_SOURCE=1");
318   }
319 
320   // Filter out some microsoft extensions when trying to parse in ms-compat
321   // mode.
322   if (LangOpts.Microsoft) {
323     DefineBuiltinMacro(Buf, "__int8=__INT8_TYPE__");
324     DefineBuiltinMacro(Buf, "__int16=__INT16_TYPE__");
325     DefineBuiltinMacro(Buf, "__int32=__INT32_TYPE__");
326     DefineBuiltinMacro(Buf, "__int64=__INT64_TYPE__");
327   }
328 
329   if (LangOpts.Optimize)
330     DefineBuiltinMacro(Buf, "__OPTIMIZE__=1");
331   if (LangOpts.OptimizeSize)
332     DefineBuiltinMacro(Buf, "__OPTIMIZE_SIZE__=1");
333 
334   // Initialize target-specific preprocessor defines.
335 
336   // Define type sizing macros based on the target properties.
337   assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
338   DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");
339 
340   unsigned IntMaxWidth;
341   const char *IntMaxSuffix;
342   if (TI.getIntMaxType() == TargetInfo::SignedLongLong) {
343     IntMaxWidth = TI.getLongLongWidth();
344     IntMaxSuffix = "LL";
345   } else if (TI.getIntMaxType() == TargetInfo::SignedLong) {
346     IntMaxWidth = TI.getLongWidth();
347     IntMaxSuffix = "L";
348   } else {
349     assert(TI.getIntMaxType() == TargetInfo::SignedInt);
350     IntMaxWidth = TI.getIntWidth();
351     IntMaxSuffix = "";
352   }
353 
354   DefineTypeSize("__SCHAR_MAX__", TI.getCharWidth(), "", true, Buf);
355   DefineTypeSize("__SHRT_MAX__", TI.getShortWidth(), "", true, Buf);
356   DefineTypeSize("__INT_MAX__", TI.getIntWidth(), "", true, Buf);
357   DefineTypeSize("__LONG_MAX__", TI.getLongWidth(), "L", true, Buf);
358   DefineTypeSize("__LONG_LONG_MAX__", TI.getLongLongWidth(), "LL", true, Buf);
359   DefineTypeSize("__WCHAR_MAX__", TI.getWCharWidth(), "", true, Buf);
360   DefineTypeSize("__INTMAX_MAX__", IntMaxWidth, IntMaxSuffix, true, Buf);
361 
362   DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Buf);
363   DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Buf);
364   DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Buf);
365   DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Buf);
366   DefineType("__SIZE_TYPE__", TI.getSizeType(), Buf);
367   DefineType("__WCHAR_TYPE__", TI.getWCharType(), Buf);
368   // FIXME: TargetInfo hookize __WINT_TYPE__.
369   DefineBuiltinMacro(Buf, "__WINT_TYPE__=int");
370 
371   DefineFloatMacros(Buf, "FLT", &TI.getFloatFormat());
372   DefineFloatMacros(Buf, "DBL", &TI.getDoubleFormat());
373   DefineFloatMacros(Buf, "LDBL", &TI.getLongDoubleFormat());
374 
375   // Define a __POINTER_WIDTH__ macro for stdint.h.
376   sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0));
377   DefineBuiltinMacro(Buf, MacroBuf);
378 
379   if (!LangOpts.CharIsSigned)
380     DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");
381 
382   // Define fixed-sized integer types for stdint.h
383   assert(TI.getCharWidth() == 8 && "unsupported target types");
384   assert(TI.getShortWidth() == 16 && "unsupported target types");
385   DefineBuiltinMacro(Buf, "__INT8_TYPE__=char");
386   DefineBuiltinMacro(Buf, "__INT16_TYPE__=short");
387 
388   if (TI.getIntWidth() == 32)
389     DefineBuiltinMacro(Buf, "__INT32_TYPE__=int");
390   else {
391     assert(TI.getLongLongWidth() == 32 && "unsupported target types");
392     DefineBuiltinMacro(Buf, "__INT32_TYPE__=long long");
393   }
394 
395   // 16-bit targets doesn't necessarily have a 64-bit type.
396   if (TI.getLongLongWidth() == 64)
397     DefineType("__INT64_TYPE__", TI.getInt64Type(), Buf);
398 
399   // Add __builtin_va_list typedef.
400   {
401     const char *VAList = TI.getVAListDeclaration();
402     Buf.insert(Buf.end(), VAList, VAList+strlen(VAList));
403     Buf.push_back('\n');
404   }
405 
406   if (const char *Prefix = TI.getUserLabelPrefix()) {
407     sprintf(MacroBuf, "__USER_LABEL_PREFIX__=%s", Prefix);
408     DefineBuiltinMacro(Buf, MacroBuf);
409   }
410 
411   // Build configuration options.  FIXME: these should be controlled by
412   // command line options or something.
413   DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");
414 
415   if (LangOpts.GNUInline)
416     DefineBuiltinMacro(Buf, "__GNUC_GNU_INLINE__=1");
417   else
418     DefineBuiltinMacro(Buf, "__GNUC_STDC_INLINE__=1");
419 
420   if (LangOpts.NoInline)
421     DefineBuiltinMacro(Buf, "__NO_INLINE__=1");
422 
423   if (unsigned PICLevel = LangOpts.PICLevel) {
424     sprintf(MacroBuf, "__PIC__=%d", PICLevel);
425     DefineBuiltinMacro(Buf, MacroBuf);
426 
427     sprintf(MacroBuf, "__pic__=%d", PICLevel);
428     DefineBuiltinMacro(Buf, MacroBuf);
429   }
430 
431   // Macros to control C99 numerics and <float.h>
432   DefineBuiltinMacro(Buf, "__FLT_EVAL_METHOD__=0");
433   DefineBuiltinMacro(Buf, "__FLT_RADIX__=2");
434   sprintf(MacroBuf, "__DECIMAL_DIG__=%d",
435           PickFP(&TI.getLongDoubleFormat(), -1/*FIXME*/, 17, 21, 33, 36));
436   DefineBuiltinMacro(Buf, MacroBuf);
437 
438   if (LangOpts.getStackProtectorMode() == LangOptions::SSPOn)
439     DefineBuiltinMacro(Buf, "__SSP__=1");
440   else if (LangOpts.getStackProtectorMode() == LangOptions::SSPReq)
441     DefineBuiltinMacro(Buf, "__SSP_ALL__=2");
442 
443   // Get other target #defines.
444   TI.getTargetDefines(LangOpts, Buf);
445 }
446 
447 /// InitializePreprocessor - Initialize the preprocessor getting it and the
448 /// environment ready to process a single file. This returns true on error.
449 ///
450 bool InitializePreprocessor(Preprocessor &PP,
451                             const PreprocessorInitOptions& InitOpts) {
452   std::vector<char> PredefineBuffer;
453 
454   const char *LineDirective = "# 1 \"<built-in>\" 3\n";
455   PredefineBuffer.insert(PredefineBuffer.end(),
456                          LineDirective, LineDirective+strlen(LineDirective));
457 
458   // Install things like __POWERPC__, __GNUC__, etc into the macro table.
459   InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
460                              PredefineBuffer);
461 
462   // Add on the predefines from the driver.  Wrap in a #line directive to report
463   // that they come from the command line.
464   LineDirective = "# 1 \"<command line>\" 1\n";
465   PredefineBuffer.insert(PredefineBuffer.end(),
466                          LineDirective, LineDirective+strlen(LineDirective));
467 
468   // Process #define's and #undef's in the order they are given.
469   for (PreprocessorInitOptions::macro_iterator I = InitOpts.macro_begin(),
470        E = InitOpts.macro_end(); I != E; ++I) {
471     if (I->second)  // isUndef
472       UndefineBuiltinMacro(PredefineBuffer, I->first.c_str());
473     else
474       DefineBuiltinMacro(PredefineBuffer, I->first.c_str());
475   }
476 
477   // If -imacros are specified, include them now.  These are processed before
478   // any -include directives.
479   for (PreprocessorInitOptions::imacro_iterator I = InitOpts.imacro_begin(),
480        E = InitOpts.imacro_end(); I != E; ++I)
481     AddImplicitIncludeMacros(PredefineBuffer, *I);
482 
483   // Process -include directives.
484   for (PreprocessorInitOptions::include_iterator I = InitOpts.include_begin(),
485        E = InitOpts.include_end(); I != E; ++I) {
486     if (I->second) // isPTH
487       AddImplicitIncludePTH(PredefineBuffer, PP, I->first);
488     else
489       AddImplicitInclude(PredefineBuffer, I->first);
490   }
491 
492   // Null terminate PredefinedBuffer and add it.
493   PredefineBuffer.push_back(0);
494   PP.setPredefines(&PredefineBuffer[0]);
495 
496   // Once we've read this, we're done.
497   return false;
498 }
499 
500 } // namespace clang
501