Skip to content

[lldb] Only warn about 'auto' types in the log instead of stderr #3139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,10 +1157,20 @@ CompilerType TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
// to fix any issues we run into.
if (!type_name.empty()) {
std::string type_name_str = type_name.str();
Host::SystemLog(Host::eSystemLogError,
"error: need to add support for DW_TAG_base_type '%s' "
"encoded with DW_ATE = 0x%x, bit_size = %u\n",
type_name_str.c_str(), dw_ate, bit_size);
// GCC and newer Clang versions emit 'auto' types. This isn't supported yet,
// but we should also not spam the stderr with warnings, so instead log
// these special types. See rdar://71352569
if (type_name_str == "auto") {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES));
LLDB_LOGF(log, "error: need to add support for DW_TAG_base_type '%s' "
"encoded with DW_ATE = 0x%x, bit_size = %u\n",
type_name_str.c_str(), dw_ate, bit_size);
} else {
Host::SystemLog(Host::eSystemLogError,
"error: need to add support for DW_TAG_base_type '%s' "
"encoded with DW_ATE = 0x%x, bit_size = %u\n",
type_name_str.c_str(), dw_ate, bit_size);
}
} else {
Host::SystemLog(Host::eSystemLogError, "error: need to add support for "
"DW_TAG_base_type encoded with "
Expand Down
12 changes: 12 additions & 0 deletions lldb/test/Shell/Expr/Inputs/auto.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
struct Foo {
auto i();
};

auto Foo::i() {
return 1;
}

int main() {
Foo f;
f.i();
}
14 changes: 14 additions & 0 deletions lldb/test/Shell/Expr/TestAutoErr.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# RUN: %clangxx_host %p/Inputs/auto.cpp -std=c++14 -g -o %t

# Test for emitted 'auto' types: rdar://71352569

# The warning shouldn't appear in the stderr output.
# RUN: %lldb -o "expr Foo f" %t -b 2>&1 | FileCheck --check-prefix=NO_OUT %s
# But the warning should be in the log.
# We add the log enable command here as an argument as the channel names
# matches the word 'LLDB' and our sanity check substitution will kick in and
# warn us about using the word 'LLDB' instead of '%lldb" in a run invocation.
# RUN: %lldb -s %p/enable_log -o "expr Foo f" %t -b | FileCheck %s

# CHECK: error: need to add support for DW_TAG_base_type 'auto'
# NO_OUT-NOT: error: need to add support for DW_TAG_base_type 'auto'
1 change: 1 addition & 0 deletions lldb/test/Shell/Expr/enable_log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
log enable lldb types