1 //===--- FrontendActions.cpp ----------------------------------------------===//
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 #include "clang/Frontend/FrontendActions.h"
11 #include "clang/AST/ASTConsumer.h"
12 #include "clang/Basic/FileManager.h"
13 #include "clang/Frontend/ASTConsumers.h"
14 #include "clang/Frontend/ASTUnit.h"
15 #include "clang/Frontend/CompilerInstance.h"
16 #include "clang/Frontend/FrontendDiagnostic.h"
17 #include "clang/Frontend/Utils.h"
18 #include "clang/Lex/HeaderSearch.h"
19 #include "clang/Lex/Pragma.h"
20 #include "clang/Lex/Preprocessor.h"
21 #include "clang/Parse/Parser.h"
22 #include "clang/Serialization/ASTReader.h"
23 #include "clang/Serialization/ASTWriter.h"
24 #include "llvm/Support/FileSystem.h"
25 #include "llvm/Support/MemoryBuffer.h"
26 #include "llvm/Support/raw_ostream.h"
28 #include <system_error>
30 using namespace clang;
32 //===----------------------------------------------------------------------===//
34 //===----------------------------------------------------------------------===//
36 std::unique_ptr<ASTConsumer>
37 InitOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
38 return llvm::make_unique<ASTConsumer>();
41 void InitOnlyAction::ExecuteAction() {
44 //===----------------------------------------------------------------------===//
45 // AST Consumer Actions
46 //===----------------------------------------------------------------------===//
48 std::unique_ptr<ASTConsumer>
49 ASTPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
50 if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile))
51 return CreateASTPrinter(OS, CI.getFrontendOpts().ASTDumpFilter);
55 std::unique_ptr<ASTConsumer>
56 ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
57 return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
58 CI.getFrontendOpts().ASTDumpDecls,
59 CI.getFrontendOpts().ASTDumpLookups);
62 std::unique_ptr<ASTConsumer>
63 ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
64 return CreateASTDeclNodeLister();
67 std::unique_ptr<ASTConsumer>
68 ASTViewAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
69 return CreateASTViewer();
72 std::unique_ptr<ASTConsumer>
73 DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI,
75 return CreateDeclContextPrinter();
78 std::unique_ptr<ASTConsumer>
79 GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
81 std::string OutputFile;
83 ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile);
87 if (!CI.getFrontendOpts().RelocatablePCH)
89 return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(), OutputFile,
90 nullptr, Sysroot, OS);
93 raw_ostream *GeneratePCHAction::ComputeASTConsumerArguments(
94 CompilerInstance &CI, StringRef InFile, std::string &Sysroot,
95 std::string &OutputFile) {
96 Sysroot = CI.getHeaderSearchOpts().Sysroot;
97 if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
98 CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
102 // We use createOutputFile here because this is exposed via libclang, and we
103 // must disable the RemoveFileOnSignal behavior.
104 // We use a temporary to avoid race conditions.
106 CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
107 /*RemoveFileOnSignal=*/false, InFile,
108 /*Extension=*/"", /*useTemporary=*/true);
112 OutputFile = CI.getFrontendOpts().OutputFile;
116 std::unique_ptr<ASTConsumer>
117 GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
120 std::string OutputFile;
122 ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile);
126 return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(), OutputFile,
127 Module, Sysroot, OS);
130 static SmallVectorImpl<char> &
131 operator+=(SmallVectorImpl<char> &Includes, StringRef RHS) {
132 Includes.append(RHS.begin(), RHS.end());
136 static std::error_code addHeaderInclude(StringRef HeaderName,
137 SmallVectorImpl<char> &Includes,
138 const LangOptions &LangOpts,
140 if (IsExternC && LangOpts.CPlusPlus)
141 Includes += "extern \"C\" {\n";
143 Includes += "#import \"";
145 Includes += "#include \"";
147 Includes += HeaderName;
150 if (IsExternC && LangOpts.CPlusPlus)
152 return std::error_code();
155 /// \brief Collect the set of header includes needed to construct the given
156 /// module and update the TopHeaders file set of the module.
158 /// \param Module The module we're collecting includes from.
160 /// \param Includes Will be augmented with the set of \#includes or \#imports
161 /// needed to load all of the named headers.
162 static std::error_code
163 collectModuleHeaderIncludes(const LangOptions &LangOpts, FileManager &FileMgr,
164 ModuleMap &ModMap, clang::Module *Module,
165 SmallVectorImpl<char> &Includes) {
166 // Don't collect any headers for unavailable modules.
167 if (!Module->isAvailable())
168 return std::error_code();
170 // Add includes for each of these headers.
171 for (Module::Header &H : Module->Headers[Module::HK_Normal]) {
172 Module->addTopHeader(H.Entry);
173 // Use the path as specified in the module map file. We'll look for this
174 // file relative to the module build directory (the directory containing
175 // the module map file) so this will find the same file that we found
176 // while parsing the module map.
177 if (std::error_code Err = addHeaderInclude(H.NameAsWritten, Includes,
178 LangOpts, Module->IsExternC))
181 // Note that Module->PrivateHeaders will not be a TopHeader.
183 if (Module::Header UmbrellaHeader = Module->getUmbrellaHeader()) {
184 Module->addTopHeader(UmbrellaHeader.Entry);
185 if (Module->Parent) {
186 // Include the umbrella header for submodules.
187 if (std::error_code Err = addHeaderInclude(UmbrellaHeader.NameAsWritten,
192 } else if (Module::DirectoryName UmbrellaDir = Module->getUmbrellaDir()) {
193 // Add all of the headers we find in this subdirectory.
195 SmallString<128> DirNative;
196 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
197 for (llvm::sys::fs::recursive_directory_iterator Dir(DirNative, EC),
199 Dir != DirEnd && !EC; Dir.increment(EC)) {
200 // Check whether this entry has an extension typically associated with
202 if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
203 .Cases(".h", ".H", ".hh", ".hpp", true)
207 const FileEntry *Header = FileMgr.getFile(Dir->path());
208 // FIXME: This shouldn't happen unless there is a file system race. Is
209 // that worth diagnosing?
213 // If this header is marked 'unavailable' in this module, don't include
215 if (ModMap.isHeaderUnavailableInModule(Header, Module))
218 // Compute the relative path from the directory to this file.
219 SmallVector<StringRef, 16> Components;
220 auto PathIt = llvm::sys::path::rbegin(Dir->path());
221 for (int I = 0; I != Dir.level() + 1; ++I, ++PathIt)
222 Components.push_back(*PathIt);
223 SmallString<128> RelativeHeader(UmbrellaDir.NameAsWritten);
224 for (auto It = Components.rbegin(), End = Components.rend(); It != End;
226 llvm::sys::path::append(RelativeHeader, *It);
228 // Include this header as part of the umbrella directory.
229 Module->addTopHeader(Header);
230 if (std::error_code Err = addHeaderInclude(RelativeHeader, Includes,
231 LangOpts, Module->IsExternC))
239 // Recurse into submodules.
240 for (clang::Module::submodule_iterator Sub = Module->submodule_begin(),
241 SubEnd = Module->submodule_end();
242 Sub != SubEnd; ++Sub)
243 if (std::error_code Err = collectModuleHeaderIncludes(
244 LangOpts, FileMgr, ModMap, *Sub, Includes))
247 return std::error_code();
250 bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
251 StringRef Filename) {
252 // Find the module map file.
253 const FileEntry *ModuleMap = CI.getFileManager().getFile(Filename);
255 CI.getDiagnostics().Report(diag::err_module_map_not_found)
260 // Parse the module map file.
261 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
262 if (HS.loadModuleMapFile(ModuleMap, IsSystem))
265 if (CI.getLangOpts().CurrentModule.empty()) {
266 CI.getDiagnostics().Report(diag::err_missing_module_name);
268 // FIXME: Eventually, we could consider asking whether there was just
269 // a single module described in the module map, and use that as a
270 // default. Then it would be fairly trivial to just "compile" a module
271 // map with a single module (the common case).
275 // If we're being run from the command-line, the module build stack will not
276 // have been filled in yet, so complete it now in order to allow us to detect
278 SourceManager &SourceMgr = CI.getSourceManager();
279 if (SourceMgr.getModuleBuildStack().empty())
280 SourceMgr.pushModuleBuildStack(CI.getLangOpts().CurrentModule,
281 FullSourceLoc(SourceLocation(), SourceMgr));
283 // Dig out the module definition.
284 Module = HS.lookupModule(CI.getLangOpts().CurrentModule,
285 /*AllowSearch=*/false);
287 CI.getDiagnostics().Report(diag::err_missing_module)
288 << CI.getLangOpts().CurrentModule << Filename;
293 // Check whether we can build this module at all.
294 clang::Module::Requirement Requirement;
295 clang::Module::UnresolvedHeaderDirective MissingHeader;
296 if (!Module->isAvailable(CI.getLangOpts(), CI.getTarget(), Requirement,
298 if (MissingHeader.FileNameLoc.isValid()) {
299 CI.getDiagnostics().Report(MissingHeader.FileNameLoc,
300 diag::err_module_header_missing)
301 << MissingHeader.IsUmbrella << MissingHeader.FileName;
303 CI.getDiagnostics().Report(diag::err_module_unavailable)
304 << Module->getFullModuleName()
305 << Requirement.second << Requirement.first;
311 if (ModuleMapForUniquing && ModuleMapForUniquing != ModuleMap) {
312 Module->IsInferred = true;
313 HS.getModuleMap().setInferredModuleAllowedBy(Module, ModuleMapForUniquing);
315 ModuleMapForUniquing = ModuleMap;
318 FileManager &FileMgr = CI.getFileManager();
320 // Collect the set of #includes we need to build the module.
321 SmallString<256> HeaderContents;
322 std::error_code Err = std::error_code();
323 if (Module::Header UmbrellaHeader = Module->getUmbrellaHeader())
324 Err = addHeaderInclude(UmbrellaHeader.NameAsWritten, HeaderContents,
325 CI.getLangOpts(), Module->IsExternC);
327 Err = collectModuleHeaderIncludes(
328 CI.getLangOpts(), FileMgr,
329 CI.getPreprocessor().getHeaderSearchInfo().getModuleMap(), Module,
333 CI.getDiagnostics().Report(diag::err_module_cannot_create_includes)
334 << Module->getFullModuleName() << Err.message();
338 // Inform the preprocessor that includes from within the input buffer should
339 // be resolved relative to the build directory of the module map file.
340 CI.getPreprocessor().setMainFileDir(Module->Directory);
342 std::unique_ptr<llvm::MemoryBuffer> InputBuffer =
343 llvm::MemoryBuffer::getMemBufferCopy(HeaderContents,
344 Module::getModuleInputBufferName());
345 // Ownership of InputBuffer will be transferred to the SourceManager.
346 setCurrentInput(FrontendInputFile(InputBuffer.release(), getCurrentFileKind(),
351 raw_ostream *GenerateModuleAction::ComputeASTConsumerArguments(
352 CompilerInstance &CI, StringRef InFile, std::string &Sysroot,
353 std::string &OutputFile) {
354 // If no output file was provided, figure out where this module would go
355 // in the module cache.
356 if (CI.getFrontendOpts().OutputFile.empty()) {
357 HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
358 CI.getFrontendOpts().OutputFile =
359 HS.getModuleFileName(CI.getLangOpts().CurrentModule,
360 ModuleMapForUniquing->getName());
363 // We use createOutputFile here because this is exposed via libclang, and we
364 // must disable the RemoveFileOnSignal behavior.
365 // We use a temporary to avoid race conditions.
367 CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
368 /*RemoveFileOnSignal=*/false, InFile,
369 /*Extension=*/"", /*useTemporary=*/true,
370 /*CreateMissingDirectories=*/true);
374 OutputFile = CI.getFrontendOpts().OutputFile;
378 std::unique_ptr<ASTConsumer>
379 SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
380 return llvm::make_unique<ASTConsumer>();
383 std::unique_ptr<ASTConsumer>
384 DumpModuleInfoAction::CreateASTConsumer(CompilerInstance &CI,
386 return llvm::make_unique<ASTConsumer>();
389 std::unique_ptr<ASTConsumer>
390 VerifyPCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
391 return llvm::make_unique<ASTConsumer>();
394 void VerifyPCHAction::ExecuteAction() {
395 CompilerInstance &CI = getCompilerInstance();
396 bool Preamble = CI.getPreprocessorOpts().PrecompiledPreambleBytes.first != 0;
397 const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
398 std::unique_ptr<ASTReader> Reader(
399 new ASTReader(CI.getPreprocessor(), CI.getASTContext(),
400 Sysroot.empty() ? "" : Sysroot.c_str(),
401 /*DisableValidation*/ false,
402 /*AllowPCHWithCompilerErrors*/ false,
403 /*AllowConfigurationMismatch*/ true,
404 /*ValidateSystemInputs*/ true));
406 Reader->ReadAST(getCurrentFile(),
407 Preamble ? serialization::MK_Preamble
408 : serialization::MK_PCH,
410 ASTReader::ARR_ConfigurationMismatch);
414 /// \brief AST reader listener that dumps module information for a module
416 class DumpModuleInfoListener : public ASTReaderListener {
417 llvm::raw_ostream &Out;
420 DumpModuleInfoListener(llvm::raw_ostream &Out) : Out(Out) { }
422 #define DUMP_BOOLEAN(Value, Text) \
423 Out.indent(4) << Text << ": " << (Value? "Yes" : "No") << "\n"
425 bool ReadFullVersionInformation(StringRef FullVersion) override {
428 << (FullVersion == getClangFullRepositoryVersion()? "this"
430 << " Clang: " << FullVersion << "\n";
431 return ASTReaderListener::ReadFullVersionInformation(FullVersion);
434 void ReadModuleName(StringRef ModuleName) override {
435 Out.indent(2) << "Module name: " << ModuleName << "\n";
437 void ReadModuleMapFile(StringRef ModuleMapPath) override {
438 Out.indent(2) << "Module map file: " << ModuleMapPath << "\n";
441 bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
442 bool AllowCompatibleDifferences) override {
443 Out.indent(2) << "Language options:\n";
444 #define LANGOPT(Name, Bits, Default, Description) \
445 DUMP_BOOLEAN(LangOpts.Name, Description);
446 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
447 Out.indent(4) << Description << ": " \
448 << static_cast<unsigned>(LangOpts.get##Name()) << "\n";
449 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
450 Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
451 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
452 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
453 #include "clang/Basic/LangOptions.def"
457 bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
458 bool AllowCompatibleDifferences) override {
459 Out.indent(2) << "Target options:\n";
460 Out.indent(4) << " Triple: " << TargetOpts.Triple << "\n";
461 Out.indent(4) << " CPU: " << TargetOpts.CPU << "\n";
462 Out.indent(4) << " ABI: " << TargetOpts.ABI << "\n";
464 if (!TargetOpts.FeaturesAsWritten.empty()) {
465 Out.indent(4) << "Target features:\n";
466 for (unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size();
468 Out.indent(6) << TargetOpts.FeaturesAsWritten[I] << "\n";
475 bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
476 bool Complain) override {
477 Out.indent(2) << "Diagnostic options:\n";
478 #define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
479 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
480 Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
481 #define VALUE_DIAGOPT(Name, Bits, Default) \
482 Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
483 #include "clang/Basic/DiagnosticOptions.def"
485 Out.indent(4) << "Diagnostic flags:\n";
486 for (const std::string &Warning : DiagOpts->Warnings)
487 Out.indent(6) << "-W" << Warning << "\n";
488 for (const std::string &Remark : DiagOpts->Remarks)
489 Out.indent(6) << "-R" << Remark << "\n";
494 bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
495 StringRef SpecificModuleCachePath,
496 bool Complain) override {
497 Out.indent(2) << "Header search options:\n";
498 Out.indent(4) << "System root [-isysroot=]: '" << HSOpts.Sysroot << "'\n";
499 Out.indent(4) << "Module Cache: '" << SpecificModuleCachePath << "'\n";
500 DUMP_BOOLEAN(HSOpts.UseBuiltinIncludes,
501 "Use builtin include directories [-nobuiltininc]");
502 DUMP_BOOLEAN(HSOpts.UseStandardSystemIncludes,
503 "Use standard system include directories [-nostdinc]");
504 DUMP_BOOLEAN(HSOpts.UseStandardCXXIncludes,
505 "Use standard C++ include directories [-nostdinc++]");
506 DUMP_BOOLEAN(HSOpts.UseLibcxx,
507 "Use libc++ (rather than libstdc++) [-stdlib=]");
511 bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
513 std::string &SuggestedPredefines) override {
514 Out.indent(2) << "Preprocessor options:\n";
515 DUMP_BOOLEAN(PPOpts.UsePredefines,
516 "Uses compiler/target-specific predefines [-undef]");
517 DUMP_BOOLEAN(PPOpts.DetailedRecord,
518 "Uses detailed preprocessing record (for indexing)");
520 if (!PPOpts.Macros.empty()) {
521 Out.indent(4) << "Predefined macros:\n";
524 for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
525 I = PPOpts.Macros.begin(), IEnd = PPOpts.Macros.end();
532 Out << I->first << "\n";
540 void DumpModuleInfoAction::ExecuteAction() {
541 // Set up the output file.
542 std::unique_ptr<llvm::raw_fd_ostream> OutFile;
543 StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
544 if (!OutputFileName.empty() && OutputFileName != "-") {
546 OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
547 llvm::sys::fs::F_Text));
549 llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
551 Out << "Information for module file '" << getCurrentFile() << "':\n";
552 DumpModuleInfoListener Listener(Out);
553 ASTReader::readASTFileControlBlock(getCurrentFile(),
554 getCompilerInstance().getFileManager(),
558 //===----------------------------------------------------------------------===//
559 // Preprocessor Actions
560 //===----------------------------------------------------------------------===//
562 void DumpRawTokensAction::ExecuteAction() {
563 Preprocessor &PP = getCompilerInstance().getPreprocessor();
564 SourceManager &SM = PP.getSourceManager();
566 // Start lexing the specified input file.
567 const llvm::MemoryBuffer *FromFile = SM.getBuffer(SM.getMainFileID());
568 Lexer RawLex(SM.getMainFileID(), FromFile, SM, PP.getLangOpts());
569 RawLex.SetKeepWhitespaceMode(true);
572 RawLex.LexFromRawLexer(RawTok);
573 while (RawTok.isNot(tok::eof)) {
574 PP.DumpToken(RawTok, true);
575 llvm::errs() << "\n";
576 RawLex.LexFromRawLexer(RawTok);
580 void DumpTokensAction::ExecuteAction() {
581 Preprocessor &PP = getCompilerInstance().getPreprocessor();
582 // Start preprocessing the specified input file.
584 PP.EnterMainSourceFile();
587 PP.DumpToken(Tok, true);
588 llvm::errs() << "\n";
589 } while (Tok.isNot(tok::eof));
592 void GeneratePTHAction::ExecuteAction() {
593 CompilerInstance &CI = getCompilerInstance();
594 raw_pwrite_stream *OS = CI.createDefaultOutputFile(true, getCurrentFile());
598 CacheTokens(CI.getPreprocessor(), OS);
601 void PreprocessOnlyAction::ExecuteAction() {
602 Preprocessor &PP = getCompilerInstance().getPreprocessor();
604 // Ignore unknown pragmas.
608 // Start parsing the specified input file.
609 PP.EnterMainSourceFile();
612 } while (Tok.isNot(tok::eof));
615 void PrintPreprocessedAction::ExecuteAction() {
616 CompilerInstance &CI = getCompilerInstance();
617 // Output file may need to be set to 'Binary', to avoid converting Unix style
618 // line feeds (<LF>) to Microsoft style line feeds (<CR><LF>).
620 // Look to see what type of line endings the file uses. If there's a
621 // CRLF, then we won't open the file up in binary mode. If there is
622 // just an LF or CR, then we will open the file up in binary mode.
623 // In this fashion, the output format should match the input format, unless
624 // the input format has inconsistent line endings.
626 // This should be a relatively fast operation since most files won't have
627 // all of their source code on a single line. However, that is still a
628 // concern, so if we scan for too long, we'll just assume the file should
629 // be opened in binary mode.
630 bool BinaryMode = true;
631 bool InvalidFile = false;
632 const SourceManager& SM = CI.getSourceManager();
633 const llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getMainFileID(),
636 const char *cur = Buffer->getBufferStart();
637 const char *end = Buffer->getBufferEnd();
638 const char *next = (cur != end) ? cur + 1 : end;
640 // Limit ourselves to only scanning 256 characters into the source
641 // file. This is mostly a sanity check in case the file has no
642 // newlines whatsoever.
643 if (end - cur > 256) end = cur + 256;
646 if (*cur == 0x0D) { // CR
647 if (*next == 0x0A) // CRLF
651 } else if (*cur == 0x0A) // LF
658 raw_ostream *OS = CI.createDefaultOutputFile(BinaryMode, getCurrentFile());
661 DoPrintPreprocessedInput(CI.getPreprocessor(), OS,
662 CI.getPreprocessorOutputOpts());
665 void PrintPreambleAction::ExecuteAction() {
666 switch (getCurrentFileKind()) {
677 case IK_PreprocessedC:
678 case IK_PreprocessedCuda:
679 case IK_PreprocessedCXX:
680 case IK_PreprocessedObjC:
681 case IK_PreprocessedObjCXX:
684 // We can't do anything with these.
688 CompilerInstance &CI = getCompilerInstance();
689 auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
692 Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).first;
693 llvm::outs().write((*Buffer)->getBufferStart(), Preamble);