diff options
author | Fangrui Song <i@maskray.me> | 2022-10-28 20:35:29 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-10-28 20:35:29 -0700 |
commit | ff9576f74514b836e1ba0268409a2ecb919d7118 (patch) | |
tree | c90e3a46e811cdb0e6acddd8d27a2e3e0dd6a5da /clang/lib/Frontend/DependencyFile.cpp | |
parent | 1c42c2a9dc23e0260c485f89f80159d5af7fcefd (diff) | |
download | llvm-ff9576f74514b836e1ba0268409a2ecb919d7118.zip llvm-ff9576f74514b836e1ba0268409a2ecb919d7118.tar.gz llvm-ff9576f74514b836e1ba0268409a2ecb919d7118.tar.bz2 |
[Frontend] Fix -MP when main file is <stdin>
rC220726 had a bug: `echo "<cstdlib>" | clang -M -MP -x c++ - 2>/dev/null`
(used by glibc/configure.ac find_cxx_header) omitted a `cstdlib:` line. Instead
of filtering out `<stdin>` in `Dependencies`, retain it (so that the number of
entries does not change whether or not main file is `<stdin>`) and filter the
`PhonyTarget` output.
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 06ddb0f..930d5b4 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -160,10 +160,7 @@ bool DependencyCollector::addDependency(StringRef Filename) { } static bool isSpecialFilename(StringRef Filename) { - return llvm::StringSwitch<bool>(Filename) - .Case("<built-in>", true) - .Case("<stdin>", true) - .Default(false); + return Filename == "<built-in>"; } bool DependencyCollector::sawDependency(StringRef Filename, bool FromModule, @@ -356,6 +353,8 @@ void DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) { // duplicates. ArrayRef<std::string> Files = getDependencies(); for (StringRef File : Files) { + if (File == "<stdin>") + continue; // Start a new line if this would exceed the column limit. Make // sure to leave space for a trailing " \" in case we need to // break the line on the next iteration. |