clang 23.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
12using namespace clang;
13
14llvm::TextEncodingConverter *
16 switch (Action) {
18 return ToLiteralEncodingConverter;
19 default:
20 return nullptr;
21 }
22}
23
24std::error_code
26 const clang::LangOptions &Opts) {
27 using namespace llvm;
28
29 const char *UTF8 = "UTF-8";
30 TE.LiteralEncoding =
31 Opts.LiteralEncoding.empty() ? UTF8 : Opts.LiteralEncoding.c_str();
32
33 // Create converter between internal and literal encoding specified
34 // in fexec-charset option.
35 if (TE.LiteralEncoding == UTF8)
36 return std::error_code();
37 ErrorOr<TextEncodingConverter> ErrorOrConverter =
38 llvm::TextEncodingConverter::create(UTF8, TE.LiteralEncoding);
39 if (ErrorOrConverter)
40 TE.ToLiteralEncodingConverter =
41 new TextEncodingConverter(std::move(*ErrorOrConverter));
42 else
43 return ErrorOrConverter.getError();
44 return std::error_code();
45}
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