Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 1 | //===--- 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 Friedman | b09f6e1 | 2009-05-19 04:14:29 +0000 | [diff] [blame] | 14 | #include "clang/Frontend/Utils.h" |
Chris Lattner | b9c3f96 | 2009-01-27 07:57:44 +0000 | [diff] [blame] | 15 | #include "clang/Basic/FileManager.h" |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 16 | #include "clang/Basic/SourceManager.h" |
| 17 | #include "clang/Frontend/DependencyOutputOptions.h" |
| 18 | #include "clang/Frontend/FrontendDiagnostic.h" |
| 19 | #include "clang/Lex/DirectoryLookup.h" |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 20 | #include "clang/Lex/LexDiagnostic.h" |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 21 | #include "clang/Lex/PPCallbacks.h" |
| 22 | #include "clang/Lex/Preprocessor.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 23 | #include "clang/Serialization/ASTReader.h" |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/StringSet.h" |
Benjamin Kramer | 0b21490 | 2013-06-13 14:26:04 +0000 | [diff] [blame] | 25 | #include "llvm/Support/FileSystem.h" |
Eli Friedman | a6e023c | 2011-07-08 20:17:28 +0000 | [diff] [blame] | 26 | #include "llvm/Support/Path.h" |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 27 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 28 | |
| 29 | using namespace clang; |
| 30 | |
| 31 | namespace { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 32 | /// Private implementation for DependencyFileGenerator |
| 33 | class DFGImpl : public PPCallbacks { |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 34 | std::vector<std::string> Files; |
| 35 | llvm::StringSet<> FilesSet; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 36 | const Preprocessor *PP; |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 37 | std::string OutputFile; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 38 | std::vector<std::string> Targets; |
Eli Friedman | b5c8f8b | 2009-05-19 03:35:57 +0000 | [diff] [blame] | 39 | bool IncludeSystemHeaders; |
| 40 | bool PhonyTarget; |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 41 | bool AddMissingHeaderDeps; |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 42 | bool SeenMissingHeader; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 43 | bool IncludeModuleFiles; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 44 | private: |
| 45 | bool FileMatchesDepCriteria(const char *Filename, |
Chris Lattner | 9d72851 | 2008-10-27 01:19:25 +0000 | [diff] [blame] | 46 | SrcMgr::CharacteristicKind FileType); |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 47 | void OutputDependencyFile(); |
| 48 | |
| 49 | public: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 50 | DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions &Opts) |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 51 | : PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets), |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 52 | IncludeSystemHeaders(Opts.IncludeSystemHeaders), |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 53 | PhonyTarget(Opts.UsePhonyTargets), |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 54 | AddMissingHeaderDeps(Opts.AddMissingHeaderDeps), |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 55 | SeenMissingHeader(false), |
| 56 | IncludeModuleFiles(Opts.IncludeModuleFiles) {} |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 57 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 58 | void FileChanged(SourceLocation Loc, FileChangeReason Reason, |
| 59 | SrcMgr::CharacteristicKind FileType, |
| 60 | FileID PrevFID) override; |
| 61 | void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, |
| 62 | StringRef FileName, bool IsAngled, |
| 63 | CharSourceRange FilenameRange, const FileEntry *File, |
| 64 | StringRef SearchPath, StringRef RelativePath, |
| 65 | const Module *Imported) override; |
Daniel Dunbar | dbd8209 | 2010-03-23 05:09:10 +0000 | [diff] [blame] | 66 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 67 | void EndOfMainFile() override { |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 68 | OutputDependencyFile(); |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 69 | } |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 70 | |
| 71 | void AddFilename(StringRef Filename); |
| 72 | bool includeSystemHeaders() const { return IncludeSystemHeaders; } |
| 73 | bool includeModuleFiles() const { return IncludeModuleFiles; } |
| 74 | }; |
| 75 | |
| 76 | class DFGASTReaderListener : public ASTReaderListener { |
| 77 | DFGImpl &Parent; |
| 78 | public: |
| 79 | DFGASTReaderListener(DFGImpl &Parent) |
| 80 | : Parent(Parent) { } |
| 81 | bool needsInputFileVisitation() override { return true; } |
| 82 | bool needsSystemInputFileVisitation() override { |
| 83 | return Parent.includeSystemHeaders(); |
| 84 | } |
| 85 | void visitModuleFile(StringRef Filename) override; |
| 86 | bool visitInputFile(StringRef Filename, bool isSystem, |
| 87 | bool isOverridden) override; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 88 | }; |
| 89 | } |
| 90 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 91 | DependencyFileGenerator::DependencyFileGenerator(void *Impl) |
| 92 | : Impl(Impl) { } |
| 93 | |
| 94 | DependencyFileGenerator *DependencyFileGenerator::CreateAndAttachToPreprocessor( |
| 95 | clang::Preprocessor &PP, const clang::DependencyOutputOptions &Opts) { |
| 96 | |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 97 | if (Opts.Targets.empty()) { |
Daniel Dunbar | ca11f61 | 2009-11-11 21:44:00 +0000 | [diff] [blame] | 98 | PP.getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT); |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 99 | return nullptr; |
Daniel Dunbar | 0e0bae8 | 2009-11-11 21:43:12 +0000 | [diff] [blame] | 100 | } |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 101 | |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 102 | // Disable the "file not found" diagnostic if the -MG option was given. |
Eli Friedman | f84139a | 2011-08-30 23:07:51 +0000 | [diff] [blame] | 103 | if (Opts.AddMissingHeaderDeps) |
| 104 | PP.SetSuppressIncludeNotFoundError(true); |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 105 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 106 | DFGImpl *Callback = new DFGImpl(&PP, Opts); |
| 107 | PP.addPPCallbacks(Callback); // PP owns the Callback |
| 108 | return new DependencyFileGenerator(Callback); |
| 109 | } |
| 110 | |
| 111 | void DependencyFileGenerator::AttachToASTReader(ASTReader &R) { |
| 112 | DFGImpl *I = reinterpret_cast<DFGImpl *>(Impl); |
| 113 | assert(I && "missing implementation"); |
| 114 | R.addListener(new DFGASTReaderListener(*I)); |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /// FileMatchesDepCriteria - Determine whether the given Filename should be |
| 118 | /// considered as a dependency. |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 119 | bool DFGImpl::FileMatchesDepCriteria(const char *Filename, |
| 120 | SrcMgr::CharacteristicKind FileType) { |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 121 | if (strcmp("<built-in>", Filename) == 0) |
| 122 | return false; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 123 | |
Eli Friedman | b5c8f8b | 2009-05-19 03:35:57 +0000 | [diff] [blame] | 124 | if (IncludeSystemHeaders) |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 125 | return true; |
| 126 | |
| 127 | return FileType == SrcMgr::C_User; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 130 | void DFGImpl::FileChanged(SourceLocation Loc, |
| 131 | FileChangeReason Reason, |
| 132 | SrcMgr::CharacteristicKind FileType, |
| 133 | FileID PrevFID) { |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 134 | if (Reason != PPCallbacks::EnterFile) |
| 135 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 136 | |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 137 | // Dependency generation really does want to go all the way to the |
| 138 | // file entry for a source location to find out what is depended on. |
| 139 | // We do not want #line markers to affect dependency generation! |
Chris Lattner | b9c3f96 | 2009-01-27 07:57:44 +0000 | [diff] [blame] | 140 | SourceManager &SM = PP->getSourceManager(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 141 | |
Chris Lattner | e86e4cd0 | 2009-01-28 05:42:38 +0000 | [diff] [blame] | 142 | const FileEntry *FE = |
Chandler Carruth | 4027853 | 2011-07-25 16:49:02 +0000 | [diff] [blame] | 143 | SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc))); |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 144 | if (!FE) return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 145 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 146 | StringRef Filename = FE->getName(); |
Eli Friedman | a6e023c | 2011-07-08 20:17:28 +0000 | [diff] [blame] | 147 | if (!FileMatchesDepCriteria(Filename.data(), FileType)) |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 148 | return; |
| 149 | |
Eli Friedman | a6e023c | 2011-07-08 20:17:28 +0000 | [diff] [blame] | 150 | // Remove leading "./" (or ".//" or "././" etc.) |
| 151 | while (Filename.size() > 2 && Filename[0] == '.' && |
| 152 | llvm::sys::path::is_separator(Filename[1])) { |
| 153 | Filename = Filename.substr(1); |
| 154 | while (llvm::sys::path::is_separator(Filename[0])) |
| 155 | Filename = Filename.substr(1); |
| 156 | } |
| 157 | |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 158 | AddFilename(Filename); |
| 159 | } |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 160 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 161 | void DFGImpl::InclusionDirective(SourceLocation HashLoc, |
| 162 | const Token &IncludeTok, |
| 163 | StringRef FileName, |
| 164 | bool IsAngled, |
| 165 | CharSourceRange FilenameRange, |
| 166 | const FileEntry *File, |
| 167 | StringRef SearchPath, |
| 168 | StringRef RelativePath, |
| 169 | const Module *Imported) { |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 170 | if (!File) { |
| 171 | if (AddMissingHeaderDeps) |
| 172 | AddFilename(FileName); |
| 173 | else |
| 174 | SeenMissingHeader = true; |
| 175 | } |
Peter Collingbourne | bb52786 | 2011-07-12 19:35:15 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 178 | void DFGImpl::AddFilename(StringRef Filename) { |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 179 | if (FilesSet.insert(Filename)) |
| 180 | Files.push_back(Filename); |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Benjamin Kramer | ddc15c4 | 2013-04-02 13:38:48 +0000 | [diff] [blame] | 183 | /// PrintFilename - GCC escapes spaces, # and $, but apparently not ' or " or |
| 184 | /// other scary characters. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 185 | static void PrintFilename(raw_ostream &OS, StringRef Filename) { |
Chris Lattner | 9d50634 | 2011-02-17 02:14:49 +0000 | [diff] [blame] | 186 | for (unsigned i = 0, e = Filename.size(); i != e; ++i) { |
Benjamin Kramer | ddc15c4 | 2013-04-02 13:38:48 +0000 | [diff] [blame] | 187 | if (Filename[i] == ' ' || Filename[i] == '#') |
Chris Lattner | 9d50634 | 2011-02-17 02:14:49 +0000 | [diff] [blame] | 188 | OS << '\\'; |
Benjamin Kramer | ddc15c4 | 2013-04-02 13:38:48 +0000 | [diff] [blame] | 189 | else if (Filename[i] == '$') // $ is escaped by $$. |
| 190 | OS << '$'; |
Chris Lattner | 9d50634 | 2011-02-17 02:14:49 +0000 | [diff] [blame] | 191 | OS << Filename[i]; |
| 192 | } |
| 193 | } |
| 194 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 195 | void DFGImpl::OutputDependencyFile() { |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 196 | if (SeenMissingHeader) { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 197 | llvm::sys::fs::remove(OutputFile); |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 198 | return; |
| 199 | } |
| 200 | |
| 201 | std::string Err; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 202 | llvm::raw_fd_ostream OS(OutputFile.c_str(), Err, llvm::sys::fs::F_Text); |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 203 | if (!Err.empty()) { |
| 204 | PP->getDiagnostics().Report(diag::err_fe_error_opening) |
| 205 | << OutputFile << Err; |
| 206 | return; |
| 207 | } |
| 208 | |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 209 | // Write out the dependency targets, trying to avoid overly long |
| 210 | // lines when possible. We try our best to emit exactly the same |
| 211 | // dependency file as GCC (4.2), assuming the included files are the |
| 212 | // same. |
| 213 | const unsigned MaxColumns = 75; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 214 | unsigned Columns = 0; |
| 215 | |
| 216 | for (std::vector<std::string>::iterator |
| 217 | I = Targets.begin(), E = Targets.end(); I != E; ++I) { |
| 218 | unsigned N = I->length(); |
| 219 | if (Columns == 0) { |
| 220 | Columns += N; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 221 | } else if (Columns + N + 2 > MaxColumns) { |
| 222 | Columns = N + 2; |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 223 | OS << " \\\n "; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 224 | } else { |
| 225 | Columns += N + 1; |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 226 | OS << ' '; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 227 | } |
Chris Lattner | 9d50634 | 2011-02-17 02:14:49 +0000 | [diff] [blame] | 228 | // Targets already quoted as needed. |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 229 | OS << *I; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 232 | OS << ':'; |
Chris Lattner | 02fbb25 | 2009-01-11 19:28:34 +0000 | [diff] [blame] | 233 | Columns += 1; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 234 | |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 235 | // Now add each dependency in the order it was seen, but avoiding |
| 236 | // duplicates. |
| 237 | for (std::vector<std::string>::iterator I = Files.begin(), |
| 238 | E = Files.end(); I != E; ++I) { |
| 239 | // Start a new line if this would exceed the column limit. Make |
| 240 | // sure to leave space for a trailing " \" in case we need to |
| 241 | // break the line on the next iteration. |
| 242 | unsigned N = I->length(); |
| 243 | if (Columns + (N + 1) + 2 > MaxColumns) { |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 244 | OS << " \\\n "; |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 245 | Columns = 2; |
| 246 | } |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 247 | OS << ' '; |
| 248 | PrintFilename(OS, *I); |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 249 | Columns += N + 1; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 250 | } |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 251 | OS << '\n'; |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 252 | |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 253 | // Create phony targets if requested. |
Fariborz Jahanian | ccad3db | 2011-04-15 18:49:23 +0000 | [diff] [blame] | 254 | if (PhonyTarget && !Files.empty()) { |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 255 | // Skip the first entry, this is always the input file itself. |
| 256 | for (std::vector<std::string>::iterator I = Files.begin() + 1, |
| 257 | E = Files.end(); I != E; ++I) { |
Peter Collingbourne | 1b91ab4 | 2011-11-21 00:01:14 +0000 | [diff] [blame] | 258 | OS << '\n'; |
| 259 | PrintFilename(OS, *I); |
| 260 | OS << ":\n"; |
Daniel Dunbar | 7e9f1f7 | 2008-10-27 20:01:06 +0000 | [diff] [blame] | 261 | } |
| 262 | } |
Daniel Dunbar | 750c358 | 2008-10-24 22:12:41 +0000 | [diff] [blame] | 263 | } |
| 264 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 265 | bool DFGASTReaderListener::visitInputFile(llvm::StringRef Filename, |
| 266 | bool IsSystem, bool IsOverridden) { |
| 267 | assert(!IsSystem || needsSystemInputFileVisitation()); |
| 268 | if (IsOverridden) |
| 269 | return true; |
| 270 | |
| 271 | Parent.AddFilename(Filename); |
| 272 | return true; |
| 273 | } |
| 274 | |
| 275 | void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename) { |
| 276 | if (Parent.includeModuleFiles()) |
| 277 | Parent.AddFilename(Filename); |
| 278 | } |