blob: 6bea22ed592106493fffecb2d78df027fa13b147 [file] [log] [blame]
Daniel Dunbarfa0caca2008-10-24 22:12:41 +00001//===--- DependencyFile.cpp - Generate dependency file --------------------===//
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 code generates dependency files.
11//
12//===----------------------------------------------------------------------===//
13
Eli Friedman16b7b6f2009-05-19 04:14:29 +000014#include "clang/Frontend/Utils.h"
Chris Lattnerf1ca7d32009-01-27 07:57:44 +000015#include "clang/Basic/FileManager.h"
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +000016#include "clang/Basic/SourceManager.h"
17#include "clang/Frontend/DependencyOutputOptions.h"
18#include "clang/Frontend/FrontendDiagnostic.h"
19#include "clang/Lex/DirectoryLookup.h"
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +000020#include "clang/Lex/LexDiagnostic.h"
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +000021#include "clang/Lex/PPCallbacks.h"
22#include "clang/Lex/Preprocessor.h"
Ben Langmuircb69b572014-03-07 06:40:32 +000023#include "clang/Serialization/ASTReader.h"
Daniel Dunbarfa0caca2008-10-24 22:12:41 +000024#include "llvm/ADT/StringSet.h"
David Majnemerf0822fb2014-10-27 22:31:50 +000025#include "llvm/ADT/StringSwitch.h"
Benjamin Kramer33d43302013-06-13 14:26:04 +000026#include "llvm/Support/FileSystem.h"
Eli Friedmanf7ca26a2011-07-08 20:17:28 +000027#include "llvm/Support/Path.h"
Daniel Dunbar966c2e12008-10-27 20:01:06 +000028#include "llvm/Support/raw_ostream.h"
Daniel Dunbarfa0caca2008-10-24 22:12:41 +000029
30using namespace clang;
31
32namespace {
Ben Langmuir33c80902014-06-30 20:04:14 +000033struct DepCollectorPPCallbacks : public PPCallbacks {
34 DependencyCollector &DepCollector;
35 SourceManager &SM;
36 DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM)
37 : DepCollector(L), SM(SM) { }
38
39 void FileChanged(SourceLocation Loc, FileChangeReason Reason,
40 SrcMgr::CharacteristicKind FileType,
41 FileID PrevFID) override {
42 if (Reason != PPCallbacks::EnterFile)
43 return;
44
45 // Dependency generation really does want to go all the way to the
46 // file entry for a source location to find out what is depended on.
47 // We do not want #line markers to affect dependency generation!
48 const FileEntry *FE =
49 SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc)));
50 if (!FE)
51 return;
52
53 StringRef Filename = FE->getName();
54
55 // Remove leading "./" (or ".//" or "././" etc.)
56 while (Filename.size() > 2 && Filename[0] == '.' &&
57 llvm::sys::path::is_separator(Filename[1])) {
58 Filename = Filename.substr(1);
59 while (llvm::sys::path::is_separator(Filename[0]))
60 Filename = Filename.substr(1);
61 }
62
63 DepCollector.maybeAddDependency(Filename, /*FromModule*/false,
64 FileType != SrcMgr::C_User,
65 /*IsModuleFile*/false, /*IsMissing*/false);
66 }
67
68 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
69 StringRef FileName, bool IsAngled,
70 CharSourceRange FilenameRange, const FileEntry *File,
71 StringRef SearchPath, StringRef RelativePath,
72 const Module *Imported) override {
73 if (!File)
74 DepCollector.maybeAddDependency(FileName, /*FromModule*/false,
75 /*IsSystem*/false, /*IsModuleFile*/false,
76 /*IsMissing*/true);
77 // Files that actually exist are handled by FileChanged.
78 }
79
80 void EndOfMainFile() override {
81 DepCollector.finishedMainFile();
82 }
83};
84
85struct DepCollectorASTListener : public ASTReaderListener {
86 DependencyCollector &DepCollector;
87 DepCollectorASTListener(DependencyCollector &L) : DepCollector(L) { }
88 bool needsInputFileVisitation() override { return true; }
89 bool needsSystemInputFileVisitation() override {
90 return DepCollector.needSystemDependencies();
91 }
92 void visitModuleFile(StringRef Filename) override {
93 DepCollector.maybeAddDependency(Filename, /*FromModule*/true,
94 /*IsSystem*/false, /*IsModuleFile*/true,
95 /*IsMissing*/false);
96 }
97 bool visitInputFile(StringRef Filename, bool IsSystem,
98 bool IsOverridden) override {
99 if (IsOverridden)
100 return true;
101
102 DepCollector.maybeAddDependency(Filename, /*FromModule*/true, IsSystem,
103 /*IsModuleFile*/false, /*IsMissing*/false);
104 return true;
105 }
106};
107} // end anonymous namespace
108
109void DependencyCollector::maybeAddDependency(StringRef Filename, bool FromModule,
110 bool IsSystem, bool IsModuleFile,
111 bool IsMissing) {
David Blaikie61b86d42014-11-19 02:56:13 +0000112 if (Seen.insert(Filename).second &&
Ben Langmuir33c80902014-06-30 20:04:14 +0000113 sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing))
114 Dependencies.push_back(Filename);
115}
116
David Majnemerf0822fb2014-10-27 22:31:50 +0000117static bool isSpecialFilename(StringRef Filename) {
118 return llvm::StringSwitch<bool>(Filename)
119 .Case("<built-in>", true)
120 .Case("<stdin>", true)
121 .Default(false);
122}
123
Ben Langmuir33c80902014-06-30 20:04:14 +0000124bool DependencyCollector::sawDependency(StringRef Filename, bool FromModule,
125 bool IsSystem, bool IsModuleFile,
126 bool IsMissing) {
David Majnemerf0822fb2014-10-27 22:31:50 +0000127 return !isSpecialFilename(Filename) &&
128 (needSystemDependencies() || !IsSystem);
Ben Langmuir33c80902014-06-30 20:04:14 +0000129}
130
131DependencyCollector::~DependencyCollector() { }
132void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {
Craig Topperb8a70532014-09-10 04:53:53 +0000133 PP.addPPCallbacks(
134 llvm::make_unique<DepCollectorPPCallbacks>(*this, PP.getSourceManager()));
Ben Langmuir33c80902014-06-30 20:04:14 +0000135}
136void DependencyCollector::attachToASTReader(ASTReader &R) {
David Blaikie2721c322014-08-10 16:54:39 +0000137 R.addListener(llvm::make_unique<DepCollectorASTListener>(*this));
Ben Langmuir33c80902014-06-30 20:04:14 +0000138}
139
140namespace {
Ben Langmuircb69b572014-03-07 06:40:32 +0000141/// Private implementation for DependencyFileGenerator
142class DFGImpl : public PPCallbacks {
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000143 std::vector<std::string> Files;
144 llvm::StringSet<> FilesSet;
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000145 const Preprocessor *PP;
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000146 std::string OutputFile;
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000147 std::vector<std::string> Targets;
Eli Friedman33cd03c2009-05-19 03:35:57 +0000148 bool IncludeSystemHeaders;
149 bool PhonyTarget;
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +0000150 bool AddMissingHeaderDeps;
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000151 bool SeenMissingHeader;
Argyrios Kyrtzidis6d0753d2014-03-14 03:07:38 +0000152 bool IncludeModuleFiles;
Paul Robinsond7214a72015-04-27 18:14:32 +0000153 DependencyOutputFormat OutputFormat;
154
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000155private:
156 bool FileMatchesDepCriteria(const char *Filename,
Chris Lattner66a740e2008-10-27 01:19:25 +0000157 SrcMgr::CharacteristicKind FileType);
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000158 void OutputDependencyFile();
159
160public:
Ben Langmuircb69b572014-03-07 06:40:32 +0000161 DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions &Opts)
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000162 : PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +0000163 IncludeSystemHeaders(Opts.IncludeSystemHeaders),
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +0000164 PhonyTarget(Opts.UsePhonyTargets),
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000165 AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
Argyrios Kyrtzidis6d0753d2014-03-14 03:07:38 +0000166 SeenMissingHeader(false),
Paul Robinsond7214a72015-04-27 18:14:32 +0000167 IncludeModuleFiles(Opts.IncludeModuleFiles),
168 OutputFormat(Opts.OutputFormat) {}
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000169
Craig Topperafa7cb32014-03-13 06:07:04 +0000170 void FileChanged(SourceLocation Loc, FileChangeReason Reason,
171 SrcMgr::CharacteristicKind FileType,
172 FileID PrevFID) override;
173 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
174 StringRef FileName, bool IsAngled,
175 CharSourceRange FilenameRange, const FileEntry *File,
176 StringRef SearchPath, StringRef RelativePath,
177 const Module *Imported) override;
Daniel Dunbarcb9eaf52010-03-23 05:09:10 +0000178
Craig Topperafa7cb32014-03-13 06:07:04 +0000179 void EndOfMainFile() override {
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000180 OutputDependencyFile();
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000181 }
Ben Langmuircb69b572014-03-07 06:40:32 +0000182
183 void AddFilename(StringRef Filename);
184 bool includeSystemHeaders() const { return IncludeSystemHeaders; }
Argyrios Kyrtzidis6d0753d2014-03-14 03:07:38 +0000185 bool includeModuleFiles() const { return IncludeModuleFiles; }
Ben Langmuircb69b572014-03-07 06:40:32 +0000186};
187
188class DFGASTReaderListener : public ASTReaderListener {
189 DFGImpl &Parent;
190public:
191 DFGASTReaderListener(DFGImpl &Parent)
192 : Parent(Parent) { }
Craig Topperafa7cb32014-03-13 06:07:04 +0000193 bool needsInputFileVisitation() override { return true; }
194 bool needsSystemInputFileVisitation() override {
Ben Langmuircb69b572014-03-07 06:40:32 +0000195 return Parent.includeSystemHeaders();
196 }
Argyrios Kyrtzidis6d0753d2014-03-14 03:07:38 +0000197 void visitModuleFile(StringRef Filename) override;
Argyrios Kyrtzidis68ccbe02014-03-14 02:26:31 +0000198 bool visitInputFile(StringRef Filename, bool isSystem,
199 bool isOverridden) override;
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000200};
201}
202
Ben Langmuircb69b572014-03-07 06:40:32 +0000203DependencyFileGenerator::DependencyFileGenerator(void *Impl)
204: Impl(Impl) { }
205
206DependencyFileGenerator *DependencyFileGenerator::CreateAndAttachToPreprocessor(
207 clang::Preprocessor &PP, const clang::DependencyOutputOptions &Opts) {
208
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +0000209 if (Opts.Targets.empty()) {
Daniel Dunbar55b781f2009-11-11 21:44:00 +0000210 PP.getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT);
Craig Topper49a27902014-05-22 04:46:25 +0000211 return nullptr;
Daniel Dunbar89d1fdf2009-11-11 21:43:12 +0000212 }
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000213
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +0000214 // Disable the "file not found" diagnostic if the -MG option was given.
Eli Friedman3781a362011-08-30 23:07:51 +0000215 if (Opts.AddMissingHeaderDeps)
216 PP.SetSuppressIncludeNotFoundError(true);
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +0000217
Ben Langmuircb69b572014-03-07 06:40:32 +0000218 DFGImpl *Callback = new DFGImpl(&PP, Opts);
Craig Topperb8a70532014-09-10 04:53:53 +0000219 PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(Callback));
Ben Langmuircb69b572014-03-07 06:40:32 +0000220 return new DependencyFileGenerator(Callback);
221}
222
223void DependencyFileGenerator::AttachToASTReader(ASTReader &R) {
224 DFGImpl *I = reinterpret_cast<DFGImpl *>(Impl);
225 assert(I && "missing implementation");
David Blaikie2721c322014-08-10 16:54:39 +0000226 R.addListener(llvm::make_unique<DFGASTReaderListener>(*I));
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000227}
228
229/// FileMatchesDepCriteria - Determine whether the given Filename should be
230/// considered as a dependency.
Ben Langmuircb69b572014-03-07 06:40:32 +0000231bool DFGImpl::FileMatchesDepCriteria(const char *Filename,
232 SrcMgr::CharacteristicKind FileType) {
David Majnemerf0822fb2014-10-27 22:31:50 +0000233 if (isSpecialFilename(Filename))
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000234 return false;
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000235
Eli Friedman33cd03c2009-05-19 03:35:57 +0000236 if (IncludeSystemHeaders)
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000237 return true;
238
239 return FileType == SrcMgr::C_User;
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000240}
241
Ben Langmuircb69b572014-03-07 06:40:32 +0000242void DFGImpl::FileChanged(SourceLocation Loc,
243 FileChangeReason Reason,
244 SrcMgr::CharacteristicKind FileType,
245 FileID PrevFID) {
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000246 if (Reason != PPCallbacks::EnterFile)
247 return;
Mike Stump11289f42009-09-09 15:08:12 +0000248
Daniel Dunbar52e96cc2009-03-30 00:34:04 +0000249 // Dependency generation really does want to go all the way to the
250 // file entry for a source location to find out what is depended on.
251 // We do not want #line markers to affect dependency generation!
Chris Lattnerf1ca7d32009-01-27 07:57:44 +0000252 SourceManager &SM = PP->getSourceManager();
Mike Stump11289f42009-09-09 15:08:12 +0000253
Chris Lattner64d8fc22009-01-28 05:42:38 +0000254 const FileEntry *FE =
Chandler Carruth35f53202011-07-25 16:49:02 +0000255 SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc)));
Craig Topper49a27902014-05-22 04:46:25 +0000256 if (!FE) return;
Mike Stump11289f42009-09-09 15:08:12 +0000257
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000258 StringRef Filename = FE->getName();
Eli Friedmanf7ca26a2011-07-08 20:17:28 +0000259 if (!FileMatchesDepCriteria(Filename.data(), FileType))
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000260 return;
261
Eli Friedmanf7ca26a2011-07-08 20:17:28 +0000262 // Remove leading "./" (or ".//" or "././" etc.)
263 while (Filename.size() > 2 && Filename[0] == '.' &&
264 llvm::sys::path::is_separator(Filename[1])) {
265 Filename = Filename.substr(1);
266 while (llvm::sys::path::is_separator(Filename[0]))
267 Filename = Filename.substr(1);
268 }
269
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +0000270 AddFilename(Filename);
271}
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000272
Ben Langmuircb69b572014-03-07 06:40:32 +0000273void DFGImpl::InclusionDirective(SourceLocation HashLoc,
274 const Token &IncludeTok,
275 StringRef FileName,
276 bool IsAngled,
277 CharSourceRange FilenameRange,
278 const FileEntry *File,
279 StringRef SearchPath,
280 StringRef RelativePath,
281 const Module *Imported) {
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000282 if (!File) {
283 if (AddMissingHeaderDeps)
284 AddFilename(FileName);
285 else
286 SeenMissingHeader = true;
287 }
Peter Collingbourne77b0e7f22011-07-12 19:35:15 +0000288}
289
Ben Langmuircb69b572014-03-07 06:40:32 +0000290void DFGImpl::AddFilename(StringRef Filename) {
David Blaikie61b86d42014-11-19 02:56:13 +0000291 if (FilesSet.insert(Filename).second)
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000292 Files.push_back(Filename);
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000293}
294
Benjamin Kramerae611512013-04-02 13:38:48 +0000295/// PrintFilename - GCC escapes spaces, # and $, but apparently not ' or " or
Paul Robinsond7214a72015-04-27 18:14:32 +0000296/// other scary characters. NMake/Jom has a different set of scary characters,
297/// but wraps filespecs in double-quotes to avoid misinterpreting them;
298/// https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx for NMake info,
299/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
300/// for Windows file-naming info.
301static void PrintFilename(raw_ostream &OS, StringRef Filename,
302 DependencyOutputFormat OutputFormat) {
303 if (OutputFormat == DependencyOutputFormat::NMake) {
304 // Add quotes if needed. These are the characters listed as "special" to
305 // NMake, that are legal in a Windows filespec, and that could cause
306 // misinterpretation of the dependency string.
307 if (Filename.find_first_of(" #${}^!") != StringRef::npos)
308 OS << '\"' << Filename << '\"';
309 else
310 OS << Filename;
311 return;
312 }
Chris Lattner5df2a4e2011-02-17 02:14:49 +0000313 for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
Benjamin Kramerae611512013-04-02 13:38:48 +0000314 if (Filename[i] == ' ' || Filename[i] == '#')
Chris Lattner5df2a4e2011-02-17 02:14:49 +0000315 OS << '\\';
Benjamin Kramerae611512013-04-02 13:38:48 +0000316 else if (Filename[i] == '$') // $ is escaped by $$.
317 OS << '$';
Chris Lattner5df2a4e2011-02-17 02:14:49 +0000318 OS << Filename[i];
319 }
320}
321
Ben Langmuircb69b572014-03-07 06:40:32 +0000322void DFGImpl::OutputDependencyFile() {
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000323 if (SeenMissingHeader) {
Rafael Espindola2a008782014-01-10 21:32:14 +0000324 llvm::sys::fs::remove(OutputFile);
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000325 return;
326 }
327
Rafael Espindoladae941a2014-08-25 18:17:04 +0000328 std::error_code EC;
329 llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_Text);
330 if (EC) {
331 PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
332 << EC.message();
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000333 return;
334 }
335
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000336 // Write out the dependency targets, trying to avoid overly long
337 // lines when possible. We try our best to emit exactly the same
338 // dependency file as GCC (4.2), assuming the included files are the
339 // same.
340 const unsigned MaxColumns = 75;
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000341 unsigned Columns = 0;
342
343 for (std::vector<std::string>::iterator
344 I = Targets.begin(), E = Targets.end(); I != E; ++I) {
345 unsigned N = I->length();
346 if (Columns == 0) {
347 Columns += N;
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000348 } else if (Columns + N + 2 > MaxColumns) {
349 Columns = N + 2;
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000350 OS << " \\\n ";
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000351 } else {
352 Columns += N + 1;
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000353 OS << ' ';
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000354 }
Chris Lattner5df2a4e2011-02-17 02:14:49 +0000355 // Targets already quoted as needed.
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000356 OS << *I;
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000357 }
358
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000359 OS << ':';
Chris Lattnerfa5880e2009-01-11 19:28:34 +0000360 Columns += 1;
Mike Stump11289f42009-09-09 15:08:12 +0000361
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000362 // Now add each dependency in the order it was seen, but avoiding
363 // duplicates.
364 for (std::vector<std::string>::iterator I = Files.begin(),
365 E = Files.end(); I != E; ++I) {
366 // Start a new line if this would exceed the column limit. Make
367 // sure to leave space for a trailing " \" in case we need to
368 // break the line on the next iteration.
369 unsigned N = I->length();
370 if (Columns + (N + 1) + 2 > MaxColumns) {
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000371 OS << " \\\n ";
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000372 Columns = 2;
373 }
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000374 OS << ' ';
Paul Robinsond7214a72015-04-27 18:14:32 +0000375 PrintFilename(OS, *I, OutputFormat);
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000376 Columns += N + 1;
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000377 }
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000378 OS << '\n';
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000379
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000380 // Create phony targets if requested.
Fariborz Jahanian193f7832011-04-15 18:49:23 +0000381 if (PhonyTarget && !Files.empty()) {
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000382 // Skip the first entry, this is always the input file itself.
383 for (std::vector<std::string>::iterator I = Files.begin() + 1,
384 E = Files.end(); I != E; ++I) {
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000385 OS << '\n';
Paul Robinsond7214a72015-04-27 18:14:32 +0000386 PrintFilename(OS, *I, OutputFormat);
Peter Collingbourne0e7e3fc2011-11-21 00:01:14 +0000387 OS << ":\n";
Daniel Dunbar966c2e12008-10-27 20:01:06 +0000388 }
389 }
Daniel Dunbarfa0caca2008-10-24 22:12:41 +0000390}
391
Ben Langmuircb69b572014-03-07 06:40:32 +0000392bool DFGASTReaderListener::visitInputFile(llvm::StringRef Filename,
Argyrios Kyrtzidis68ccbe02014-03-14 02:26:31 +0000393 bool IsSystem, bool IsOverridden) {
Ben Langmuircb69b572014-03-07 06:40:32 +0000394 assert(!IsSystem || needsSystemInputFileVisitation());
Argyrios Kyrtzidis68ccbe02014-03-14 02:26:31 +0000395 if (IsOverridden)
396 return true;
397
Ben Langmuircb69b572014-03-07 06:40:32 +0000398 Parent.AddFilename(Filename);
399 return true;
400}
401
Argyrios Kyrtzidis6d0753d2014-03-14 03:07:38 +0000402void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename) {
403 if (Parent.includeModuleFiles())
404 Parent.AddFilename(Filename);
405}