diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-03-29 23:47:40 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-03-29 23:47:40 +0000 |
commit | b1631d9161ced5a90ec345aaa809ce971a77cf55 (patch) | |
tree | af5aca393b4e0d242ce51844fceb8b3dd20f738b /clang/lib/Frontend/ModuleDependencyCollector.cpp | |
parent | b81f1e0db354f87fde110a51d8def6e6910c7cdf (diff) | |
download | bcm5719-llvm-b1631d9161ced5a90ec345aaa809ce971a77cf55.tar.gz bcm5719-llvm-b1631d9161ced5a90ec345aaa809ce971a77cf55.zip |
[CrashReproducer] Cleanup and move functionality around in ModuleDependencyCollector. NFC
- Make ModuleDependencyCollector use the DependencyCollector interface
- Move some methods from ModuleDependencyListener to ModuleDependencyCollector
in order to share common functionality with other future possible
callbacks.
llvm-svn: 264808
Diffstat (limited to 'clang/lib/Frontend/ModuleDependencyCollector.cpp')
-rw-r--r-- | clang/lib/Frontend/ModuleDependencyCollector.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp index 1f187b12604..fc3958f601a 100644 --- a/clang/lib/Frontend/ModuleDependencyCollector.cpp +++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp @@ -25,17 +25,16 @@ namespace { /// Private implementation for ModuleDependencyCollector class ModuleDependencyListener : public ASTReaderListener { ModuleDependencyCollector &Collector; - llvm::StringMap<std::string> SymLinkMap; - - bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result); - std::error_code copyToRoot(StringRef Src); public: ModuleDependencyListener(ModuleDependencyCollector &Collector) : Collector(Collector) {} bool needsInputFileVisitation() override { return true; } bool needsSystemInputFileVisitation() override { return true; } bool visitInputFile(StringRef Filename, bool IsSystem, bool IsOverridden, - bool IsExplicitModule) override; + bool IsExplicitModule) override { + Collector.addFile(Filename); + return true; + } }; } @@ -57,7 +56,7 @@ void ModuleDependencyCollector::writeFileMap() { std::error_code EC; llvm::raw_fd_ostream OS(Dest, EC, llvm::sys::fs::F_Text); if (EC) { - setHasErrors(); + HasErrors = true; return; } VFSWriter.write(OS); @@ -81,8 +80,8 @@ static bool real_path(StringRef SrcPath, SmallVectorImpl<char> &RealPath) { #endif } -bool ModuleDependencyListener::getRealPath(StringRef SrcPath, - SmallVectorImpl<char> &Result) { +bool ModuleDependencyCollector::getRealPath(StringRef SrcPath, + SmallVectorImpl<char> &Result) { using namespace llvm::sys; SmallString<256> RealPath; StringRef FileName = path::filename(SrcPath); @@ -105,7 +104,7 @@ bool ModuleDependencyListener::getRealPath(StringRef SrcPath, return true; } -std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) { +std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src) { using namespace llvm::sys; // We need an absolute path to append to the root. @@ -131,7 +130,7 @@ std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) { !StringRef(CanonicalPath).equals(RealPath); // Build the destination path. - SmallString<256> Dest = Collector.getDest(); + SmallString<256> Dest = getDest(); path::append(Dest, path::relative_path(HasRemovedSymlinkComponent ? RealPath : CanonicalPath)); @@ -145,18 +144,15 @@ std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) { // Use the canonical path under the root for the file mapping. Also create // an additional entry for the real path. - Collector.addFileMapping(CanonicalPath, Dest); + addFileMapping(CanonicalPath, Dest); if (HasRemovedSymlinkComponent) - Collector.addFileMapping(RealPath, Dest); + addFileMapping(RealPath, Dest); return std::error_code(); } -bool ModuleDependencyListener::visitInputFile(StringRef Filename, bool IsSystem, - bool IsOverridden, - bool IsExplicitModule) { - if (Collector.insertSeen(Filename)) +void ModuleDependencyCollector::addFile(StringRef Filename) { + if (insertSeen(Filename)) if (copyToRoot(Filename)) - Collector.setHasErrors(); - return true; + HasErrors = true; } |