data: complex typename parsing

Added DataType class that can be constructed with a clang::qualType.
DataType keeps an internal QualifierList and ModifierStack.
This commit is contained in:
malte_langkabel
2014-07-09 11:00:35 +02:00
parent f6e6c93f71
commit 78704b6407
20 changed files with 410 additions and 28 deletions
+5 -17
View File
@@ -3,6 +3,8 @@
#include "data/parser/cxx/ASTBodyVisitor.h"
#include "data/parser/ParseLocation.h"
#include "data/parser/ParseVariable.h"
#include "utility/utilityClang.h"
#include "data/type/DataType.h"
ASTVisitor::ASTVisitor(clang::ASTContext* context, std::shared_ptr<ParserClient> client)
: m_context(context)
@@ -327,24 +329,10 @@ std::vector<ParseVariable> ASTVisitor::getParameters(clang::FunctionDecl* declar
return parameters;
}
std::string ASTVisitor::getTypeName(const clang::QualType& type) const
std::string ASTVisitor::getTypeName(const clang::QualType& qualType) const
{
std::string typeName = type.getUnqualifiedType().getAsString();
// Remove keywords from type.
std::string keyword;
size_t pos = typeName.find_first_of(' ');
if (pos != std::string::npos)
{
keyword = typeName.substr(0, pos);
}
if (keyword == "class" || keyword == "struct" || keyword == "enum")
{
typeName = typeName.substr(pos + 1);
}
return typeName;
DataType dataType(qualType);
return dataType.getRawTypeName();
}
ParserClient::AccessType ASTVisitor::convertAccessType(clang::AccessSpecifier access) const
+1 -1
View File
@@ -47,7 +47,7 @@ private:
ParseLocation getParseLocation(const clang::SourceRange& sourceRange) const;
ParseVariable getParseVariable(clang::ValueDecl* declaration) const;
std::vector<ParseVariable> getParameters(clang::FunctionDecl* declaration) const;
std::string getTypeName(const clang::QualType& type) const;
std::string getTypeName(const clang::QualType& qualType) const;
ParserClient::AccessType convertAccessType(clang::AccessSpecifier) const;
clang::ASTContext* m_context;