From 78e394b43448ee4113a0b7fa09a33f2726b8a125 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 27 Oct 2014 22:31:50 +0000 Subject: [PATCH] Frontend: Don't include stdin in the dependency list for an object file GCC doesn't do this and it semes weird to include a file that we can't open. This fixes PR21362. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220726 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/DependencyFile.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp index 22ed38fc12..08d66c7094 100644 --- a/lib/Frontend/DependencyFile.cpp +++ b/lib/Frontend/DependencyFile.cpp @@ -22,6 +22,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Serialization/ASTReader.h" #include "llvm/ADT/StringSet.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -113,10 +114,18 @@ void DependencyCollector::maybeAddDependency(StringRef Filename, bool FromModule Dependencies.push_back(Filename); } +static bool isSpecialFilename(StringRef Filename) { + return llvm::StringSwitch(Filename) + .Case("", true) + .Case("", true) + .Default(false); +} + bool DependencyCollector::sawDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing) { - return Filename != "" && (needSystemDependencies() || !IsSystem); + return !isSpecialFilename(Filename) && + (needSystemDependencies() || !IsSystem); } DependencyCollector::~DependencyCollector() { } @@ -218,7 +227,7 @@ void DependencyFileGenerator::AttachToASTReader(ASTReader &R) { /// considered as a dependency. bool DFGImpl::FileMatchesDepCriteria(const char *Filename, SrcMgr::CharacteristicKind FileType) { - if (strcmp("", Filename) == 0) + if (isSpecialFilename(Filename)) return false; if (IncludeSystemHeaders) -- 2.40.0