logic: c language support
* re-added gui for c project setup * ASTVisitor now visits RecordDecls instead of CXXRecordDecls * prevented endless recursion when parsing struct that is defined in functions signature.
This commit is contained in:
@@ -50,7 +50,7 @@ bool ASTVisitor::VisitTypedefDecl(clang::TypedefDecl* declaration)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* declaration)
|
||||
bool ASTVisitor::VisitRecordDecl(clang::RecordDecl* declaration)
|
||||
{
|
||||
if (isLocatedInUnparsedProjectFile(declaration))
|
||||
{
|
||||
@@ -74,18 +74,21 @@ bool ASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* declaration)
|
||||
}
|
||||
|
||||
if ((declaration->isClass() || declaration->isStruct()) &&
|
||||
declaration->hasDefinition() && declaration->getDefinition() == declaration && declaration->getNumBases())
|
||||
declaration->isThisDeclarationADefinition())
|
||||
{
|
||||
for (const clang::CXXBaseSpecifier& it : declaration->bases())
|
||||
if (clang::CXXRecordDecl* cxxDecl = clang::dyn_cast_or_null<clang::CXXRecordDecl>(declaration))
|
||||
{
|
||||
m_client->onInheritanceParsed(
|
||||
getParseLocation(it.getSourceRange()),
|
||||
utility::getDeclNameHierarchy(declaration),
|
||||
utility::qualTypeToDataType(it.getType())->getTypeNameHierarchy(),
|
||||
convertAccessType(it.getAccessSpecifier())
|
||||
);
|
||||
for (const clang::CXXBaseSpecifier& it : cxxDecl->bases())
|
||||
{
|
||||
m_client->onInheritanceParsed(
|
||||
getParseLocation(it.getSourceRange()),
|
||||
utility::getDeclNameHierarchy(declaration),
|
||||
utility::qualTypeToDataType(it.getType())->getTypeNameHierarchy(),
|
||||
convertAccessType(it.getAccessSpecifier())
|
||||
);
|
||||
|
||||
// TODO: check for template class and add arguments!
|
||||
// TODO: check for template class and add arguments!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1004,17 +1007,21 @@ ParseLocation ASTVisitor::getParseLocationOfFunctionBody(const clang::FunctionDe
|
||||
return ParseLocation();
|
||||
}
|
||||
|
||||
ParseLocation ASTVisitor::getParseLocationOfRecordBody(clang::CXXRecordDecl* decl) const
|
||||
ParseLocation ASTVisitor::getParseLocationOfRecordBody(clang::RecordDecl* decl) const
|
||||
{
|
||||
if (decl->hasDefinition() && decl->isThisDeclarationADefinition())
|
||||
|
||||
if (decl->isThisDeclarationADefinition())
|
||||
{
|
||||
clang::SourceRange range;
|
||||
clang::ClassTemplateDecl* templateDecl = decl->getDescribedClassTemplate();
|
||||
if (templateDecl)
|
||||
if (clang::CXXRecordDecl* cxxDecl = clang::dyn_cast_or_null<clang::CXXRecordDecl>(decl))
|
||||
{
|
||||
range = templateDecl->getSourceRange();
|
||||
clang::ClassTemplateDecl* templateDecl = cxxDecl->getDescribedClassTemplate();
|
||||
if (templateDecl)
|
||||
{
|
||||
range = templateDecl->getSourceRange();
|
||||
}
|
||||
}
|
||||
else
|
||||
if (range.isInvalid())
|
||||
{
|
||||
range = decl->getDefinition()->getSourceRange();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
virtual bool VisitStmt(const clang::Stmt* statement); // avoid visiting
|
||||
|
||||
virtual bool VisitTypedefDecl(clang::TypedefDecl* declaration); // typedefs
|
||||
virtual bool VisitCXXRecordDecl(clang::CXXRecordDecl* declaration); // structs, classes and inheritance
|
||||
virtual bool VisitRecordDecl(clang::RecordDecl* declaration);
|
||||
virtual bool VisitVarDecl(clang::VarDecl* declaration); // global variables and static fields
|
||||
virtual bool VisitFieldDecl(clang::FieldDecl* declaration); // fields
|
||||
virtual bool VisitFunctionDecl(clang::FunctionDecl* declaration); // functions
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
ParseLocation getParseLocationForTokensInRange(const clang::SourceRange& range) const;
|
||||
ParseLocation getParseLocationForNamedDecl(const clang::NamedDecl* decl) const;
|
||||
ParseLocation getParseLocationOfFunctionBody(const clang::FunctionDecl* decl) const;
|
||||
ParseLocation getParseLocationOfRecordBody(clang::CXXRecordDecl* decl) const;
|
||||
ParseLocation getParseLocationOfRecordBody(clang::RecordDecl* decl) const;
|
||||
|
||||
ParseTypeUsage getParseTypeUsage(const clang::TypeLoc& typeLoc, const clang::QualType& type) const;
|
||||
ParseTypeUsage getParseTypeUsage(const clang::TypeLoc& typeLoc, const std::shared_ptr<DataType> type) const;
|
||||
|
||||
@@ -210,6 +210,7 @@ std::shared_ptr<NameElement> CxxDeclNameResolver::getDeclName()
|
||||
}
|
||||
|
||||
CxxTypeNameResolver typenNameResolver(getIgnoredContextDecls());
|
||||
typenNameResolver.ignoreContextDecl(functionDecl);
|
||||
std::string returnTypeString = typenNameResolver.qualTypeToDataType(functionDecl->getReturnType())->getFullTypeName();
|
||||
|
||||
std::string parameterString = "(";
|
||||
|
||||
Reference in New Issue
Block a user