clang 24.0.0git
TextEncoding.cpp
Go to the documentation of this file.
1//===--- TextEncoding.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
11#include "llvm/Support/TextEncoding.h"
12
13using namespace clang;
14
15llvm::TextEncodingConverter *
17 switch (Action) {
19 return ToLiteralEncodingConverter.get();
20 default:
21 return nullptr;
22 }
23}
24
25std::error_code
27 const clang::LangOptions &Opts) {
28 using namespace llvm;
29
30 const char *UTF8 = "UTF-8";
31 TE.LiteralEncoding =
32 Opts.LiteralEncoding.empty() ? UTF8 : Opts.LiteralEncoding.c_str();
33
34 // Create converter between internal and literal encoding specified
35 // in fexec-charset option.
36 if (TE.LiteralEncoding == UTF8)
37 return std::error_code();
38 ErrorOr<TextEncodingConverter> ErrorOrConverter =
39 llvm::TextEncodingConverter::create(UTF8, TE.LiteralEncoding);
40 if (ErrorOrConverter)
41 TE.ToLiteralEncodingConverter =
42 std::make_unique<TextEncodingConverter>(std::move(*ErrorOrConverter));
43 else
44 return ErrorOrConverter.getError();
45 return std::error_code();
46}
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::string LiteralEncoding
Name of the literal encoding to convert the internal encoding to.
static std::error_code setConvertersFromOptions(TextEncoding &TE, const clang::LangOptions &Opts)
llvm::TextEncodingConverter * getConverter(ConversionAction Action) const
The JSON file list parser is used to communicate input to InstallAPI.
ConversionAction
@ CA_ToLiteralEncoding
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30