llvm-project
35 строк · 973.0 Байт
1//===-- MakeSuport.cpp --------------------------------------------------*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "clang/Basic/MakeSupport.h"10
11void clang::quoteMakeTarget(StringRef Target, SmallVectorImpl<char> &Res) {12for (unsigned i = 0, e = Target.size(); i != e; ++i) {13switch (Target[i]) {14case ' ':15case '\t':16// Escape the preceding backslashes17for (int j = i - 1; j >= 0 && Target[j] == '\\'; --j)18Res.push_back('\\');19
20// Escape the space/tab21Res.push_back('\\');22break;23case '$':24Res.push_back('$');25break;26case '#':27Res.push_back('\\');28break;29default:30break;31}32
33Res.push_back(Target[i]);34}35}
36