diff --git a/InsightsHelpers.cpp b/InsightsHelpers.cpp index 5a8ad1aa..fcbd284a 100644 --- a/InsightsHelpers.cpp +++ b/InsightsHelpers.cpp @@ -1040,6 +1040,9 @@ std::string GetTypeNameAsParameter(const QualType& t, std::string_view varName, const bool isAutoType = (nullptr != dyn_cast_or_null(t.getTypePtrOrNull())); const auto pointerToArrayBaseType = isAutoType ? t->getContainedAutoType()->getDeducedType() : t; const bool isPointerToArray = HasTypeWithSubType(pointerToArrayBaseType); + // Only treat this as an array if it is a top-level arry. Typdef's et all can hide the arrayness. + const bool isRawArrayType = + t->isArrayType() and not(isa(t) or isa(t) or isa(t)); std::string typeName = details::GetName(t, unqualified); @@ -1053,7 +1056,7 @@ std::string GetTypeNameAsParameter(const QualType& t, std::string_view varName, return {}; }; - if(t->isArrayType() and not t->isLValueReferenceType()) { + if(isRawArrayType and not t->isLValueReferenceType()) { const auto space = getSpaceOrEmpty(" ["sv); InsertBefore(typeName, "["sv, StrCat(space, varName)); @@ -1113,7 +1116,7 @@ std::string GetTypeNameAsParameter(const QualType& t, std::string_view varName, typeName += StrCat(" "sv, varName); } - } else if(not t->isArrayType() and not varName.empty()) { + } else if(not isRawArrayType and not varName.empty()) { typeName += StrCat(" "sv, varName); } diff --git a/tests/ArrayInTypedefTest.cpp b/tests/ArrayInTypedefTest.cpp new file mode 100644 index 00000000..0603bdec --- /dev/null +++ b/tests/ArrayInTypedefTest.cpp @@ -0,0 +1,13 @@ +namespace test { +typedef int jmp_buf[30]; + +jmp_buf a; +} + + +test::jmp_buf x; + + +using test::jmp_buf; + +jmp_buf t; diff --git a/tests/ArrayInTypedefTest.expect b/tests/ArrayInTypedefTest.expect new file mode 100644 index 00000000..b9bd40be --- /dev/null +++ b/tests/ArrayInTypedefTest.expect @@ -0,0 +1,16 @@ +namespace test +{ + using jmp_buf = int[30]; + jmp_buf a; + +} + + +test::jmp_buf x; + + + +using test::jmp_buf; + +test::jmp_buf t; + diff --git a/tests/Issue543.cpp b/tests/Issue543.cpp new file mode 100644 index 00000000..7235396a --- /dev/null +++ b/tests/Issue543.cpp @@ -0,0 +1,21 @@ +#include +#include +std::jmp_buf jump_buffer; + +void foo() { + printf("foo: Entered\n"); + longjmp(jump_buffer, 1); // Jump back to where setjmp was called + printf("foo: This won't be executed\n"); +} + +int main() { + if (setjmp(jump_buffer) == 0) { + printf("main: Calling foo\n"); + foo(); + } else { + printf("main: Jumped back from foo\n"); + } + + printf("main: Exiting\n"); + return 0; +} diff --git a/tests/Issue543.expect b/tests/Issue543.expect new file mode 100644 index 00000000..925fe76a --- /dev/null +++ b/tests/Issue543.expect @@ -0,0 +1,26 @@ +#include +#include +std::jmp_buf jump_buffer; + + +void foo() +{ + printf("foo: Entered\n"); + longjmp(jump_buffer, 1); + printf("foo: This won't be executed\n"); +} + + +int main() +{ + if(setjmp(jump_buffer) == 0) { + printf("main: Calling foo\n"); + foo(); + } else { + printf("main: Jumped back from foo\n"); + } + + printf("main: Exiting\n"); + return 0; +} +