| //===-- 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]); | |
| } | |
| } |