From ccc1608a8147586ff7ae2f4c3dba51ae3fc2e7aa Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Wed, 9 Apr 2014 18:33:27 +0300 Subject: [PATCH] Fixed a regression in the new parser causing a crash on enums with empty names. --- src/CppParser/AST.cpp | 6 ++++-- tests/Basic/Basic.h | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CppParser/AST.cpp b/src/CppParser/AST.cpp index c544e93d..3dcc038d 100644 --- a/src/CppParser/AST.cpp +++ b/src/CppParser/AST.cpp @@ -13,6 +13,10 @@ template static std::vector split(const T & str, const T & delimiters) { std::vector v; + if (str.length() == 0) { + v.push_back(str); + return v; + } typename T::size_type start = 0; auto pos = str.find_first_of(delimiters, start); while(pos != T::npos) { @@ -238,8 +242,6 @@ Class* DeclarationContext::FindClass(const std::string& Name, bool IsComplete, Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create) { - if (Name.empty()) return nullptr; - auto entries = split(Name, "::"); if (entries.size() == 1) diff --git a/tests/Basic/Basic.h b/tests/Basic/Basic.h index 9f7ad357..39746873 100644 --- a/tests/Basic/Basic.h +++ b/tests/Basic/Basic.h @@ -288,3 +288,9 @@ public: int A; float B; }; + +template +struct EmptyNamedNestedEnum +{ + enum { Value = 10 }; +};