Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][deps] Fix handling of -MT in module command-line
Follow-up to 6626f6f, this fixes the handling of -MT * If no targets are provided, we need to invent one since cc1 expects the driver to have handled it. The default is to use -o, quoting as necessary for a make target. * Fix the splitting for empty string, which was incorrectly treated as {""} instead of {}. * Add a way to test this behaviour in clang-scan-deps. Differential Revision: https://reviews.llvm.org/D129607
- Loading branch information
1 parent
94e0f8e
commit 3ce78cb
Showing
8 changed files
with
99 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===- MakeSupport.h - Make Utilities ---------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_BASIC_MAKESUPPORT_H | ||
#define LLVM_CLANG_BASIC_MAKESUPPORT_H | ||
|
||
#include "clang/Basic/LLVM.h" | ||
#include "llvm/ADT/StringRef.h" | ||
|
||
namespace clang { | ||
|
||
/// Quote target names for inclusion in GNU Make dependency files. | ||
/// Only the characters '$', '#', ' ', '\t' are quoted. | ||
void quoteMakeTarget(StringRef Target, SmallVectorImpl<char> &Res); | ||
|
||
} // namespace clang | ||
|
||
#endif // LLVM_CLANG_BASIC_MAKESUPPORT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//===-- MakeSuport.cpp --------------------------------------------------*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "clang/Basic/MakeSupport.h" | ||
|
||
void clang::quoteMakeTarget(StringRef Target, SmallVectorImpl<char> &Res) { | ||
for (unsigned i = 0, e = Target.size(); i != e; ++i) { | ||
switch (Target[i]) { | ||
case ' ': | ||
case '\t': | ||
// Escape the preceding backslashes | ||
for (int j = i - 1; j >= 0 && Target[j] == '\\'; --j) | ||
Res.push_back('\\'); | ||
|
||
// Escape the space/tab | ||
Res.push_back('\\'); | ||
break; | ||
case '$': | ||
Res.push_back('$'); | ||
break; | ||
case '#': | ||
Res.push_back('\\'); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
Res.push_back(Target[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters