mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
The general strategy here is to force use of a thunk when we want to use default arguments, and have Clang generate uses of the default arguments on its side of the thunk. To support this, change the key type used in `clang_decls` from being just a `Decl*` to being a pair of `Decl*` and number of parameters in the case of function decls. Import distinct `SemIR::Function`s for each number of parameters that's used, and corresponding distinct thunks. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/sem_ir/clang_decl.h"
|
|
|
|
#include "clang/AST/DeclBase.h"
|
|
#include "clang/AST/TextNodeDumper.h"
|
|
#include "common/ostream.h"
|
|
#include "common/raw_string_ostream.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
auto ClangDeclKey::Print(llvm::raw_ostream& out) const -> void {
|
|
RawStringOstream decl_stream;
|
|
auto policy = decl->getASTContext().getPrintingPolicy();
|
|
policy.TerseOutput = true;
|
|
if (isa<clang::TranslationUnitDecl>(decl)) {
|
|
decl_stream << "<translation unit>";
|
|
} else {
|
|
decl->print(decl_stream, policy);
|
|
}
|
|
|
|
if (num_params != -1) {
|
|
out << "{decl: \"" << FormatEscaped(decl_stream.TakeStr())
|
|
<< "\", num_params: " << num_params << "}";
|
|
} else {
|
|
out << "\"" << FormatEscaped(decl_stream.TakeStr()) << "\"";
|
|
}
|
|
}
|
|
|
|
auto ClangDecl::Print(llvm::raw_ostream& out) const -> void {
|
|
out << "{key: " << key << ", inst_id: " << inst_id << "}";
|
|
}
|
|
|
|
} // namespace Carbon::SemIR
|