data: fixed parsing errors.

* (quick) fixed all the crashes that occurred when parsing the own source code.
This commit is contained in:
malte_langkabel
2015-02-12 14:01:43 +01:00
parent 0d53e69d21
commit 115b19c266
5 changed files with 136 additions and 89 deletions
+5 -11
View File
@@ -1,16 +1,10 @@
template <typename T = int, typename U = int>
template <typename T>
class TemplateTestClass
{
void run(T param);
};
template<typename T>
class TemplateTestClass<int, T>
template <typename T>
void TemplateTestClass<T>::run(T param)
{
int foo;
};
template<>
class TemplateTestClass<float, float>
{
int foo;
};
}
+1 -2
View File
@@ -2,7 +2,6 @@
int main()
{
TemplateTestClass<int, int> t2;
// TemplateTestClass<float, float> t3;
TemplateTestClass<int> t2;
return 0;
}
+23 -23
View File
@@ -1,26 +1,4 @@
ConfigManager.cpp ERROR: value path/to/nowhere is not present in config.
Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies.
Edge.cpp ERROR: Edge usage can't go from Node undefined to Node undefined
Edge.cpp ERROR: Edge usage can't go from Node undefined to Node undefined
Edge.cpp ERROR: Edge usage can't go from Node undefined to Node undefined
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
Storage.cpp INFO: method: A::getCount <input.cc 8:13 8:20>
Storage.cpp INFO: global usage: A::getCount -> A::count <input.cc 10:10 10:14>
Storage.cpp INFO: method: A::process <input.cc 14:15 14:21>
Storage.cpp INFO: field: A::count <input.cc 17:13 17:17>
Storage.cpp INFO: class: B <input.cc 20:7 20:7>
Storage.cpp INFO: inheritance: B : A <input.cc 21:4 21:11>
Storage.cpp INFO: method: B::process <input.cc 24:15 24:21>
Storage.cpp INFO: override: A::process -> B::process < 0:0 0:0>
Storage.cpp INFO: type usage: B::process -> int <input.cc 26:3 26:5>
Storage.cpp INFO: function: main <input.cc 30:5 30:8>
Storage.cpp INFO: type usage: main -> B <input.cc 32:2 32:2>
Storage.cpp INFO: call: main -> B::B <input.cc 32:4 32:4>
Storage.cpp INFO: call: main -> A::getCount <input.cc 34:9 34:21>
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
@@ -54,6 +32,28 @@ SearchMatch.cpp INFO:
237 A::A
^^^^
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
Storage.cpp INFO: method: A::getCount <input.cc 8:13 8:20>
Storage.cpp INFO: global usage: A::getCount -> A::count <input.cc 10:10 10:14>
Storage.cpp INFO: method: A::process <input.cc 14:15 14:21>
Storage.cpp INFO: field: A::count <input.cc 17:13 17:17>
Storage.cpp INFO: class: B <input.cc 20:7 20:7>
Storage.cpp INFO: inheritance: B : A <input.cc 21:4 21:11>
Storage.cpp INFO: method: B::process <input.cc 24:15 24:21>
Storage.cpp INFO: override: A::process -> B::process < 0:0 0:0>
Storage.cpp INFO: type usage: B::process -> int <input.cc 26:3 26:5>
Storage.cpp INFO: function: main <input.cc 30:5 30:8>
Storage.cpp INFO: type usage: main -> B <input.cc 32:2 32:2>
Storage.cpp INFO: call: main -> B::B <input.cc 32:4 32:4>
Storage.cpp INFO: call: main -> A::getCount <input.cc 34:9 34:21>
Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies.
Edge.cpp ERROR: Edge usage can't go from Node undefined to Node undefined
Edge.cpp ERROR: Edge usage can't go from Node undefined to Node undefined
Edge.cpp ERROR: Edge usage can't go from Node undefined to Node undefined
Settings.cpp WARNING: File for Settings not found.
ConfigManager.cpp ERROR: value Bool is not present in config.
ConfigManager.cpp ERROR: value Int is not present in config.
@@ -69,6 +69,7 @@ ConfigManager.cpp ERROR: value Int is not present in config.
ConfigManager.cpp ERROR: value Float is not present in config.
ConfigManager.cpp ERROR: value String is not present in config.
ConfigManager.cpp ERROR: value NewBool is not present in config.
Graph.cpp ERROR: Can't remove member edge, without removing the child node.
Storage.cpp INFO: typedef: type -> int <file.cpp 1:1 1:1>
Storage.cpp INFO: class: Class <file.cpp 1:1 1:1>
Storage.cpp INFO: struct: Struct <file.cpp 1:1 1:1>
@@ -124,7 +125,6 @@ Storage.cpp INFO: call: main -> isTrue <file.cpp 1:0 1:0>
Storage.cpp INFO: function: isTrue <file.h 1:0 1:0>
Storage.cpp INFO: function: main <file.cpp 1:0 1:0>
Storage.cpp INFO: call: main -> isTrue <file.cpp 1:0 1:0>
Graph.cpp ERROR: Can't remove member edge, without removing the child node.
TextAccess.cpp WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 3 > 2
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
+12 -5
View File
@@ -494,12 +494,19 @@ void ASTVisitor::VisitCXXConstructExprInDeclBody(clang::FunctionDecl* decl, clan
if (parentStmt && parentStmt->getStmtClass() == clang::Stmt::DeclStmtClass)
{
clang::DeclStmt* declStmt = clang::dyn_cast<clang::DeclStmt>(parentStmt);
clang::Decl* decl = declStmt->getSingleDecl();
if (clang::isa<clang::NamedDecl>(decl))
if (declStmt->isSingleDecl())
{
clang::NamedDecl* namedDecl = clang::dyn_cast<clang::NamedDecl>(decl);
int variableNameLength = namedDecl->getName().size();
endLocationOffset = variableNameLength - 1;
clang::Decl* decl = declStmt->getSingleDecl();
if (clang::isa<clang::NamedDecl>(decl))
{
clang::NamedDecl* namedDecl = clang::dyn_cast<clang::NamedDecl>(decl);
int variableNameLength = namedDecl->getName().size();
endLocationOffset = variableNameLength - 1;
}
}
else
{
// TODO: maybe we should handle this case... it occurs when parsing a for-each loop
}
}
}
+95 -48
View File
@@ -21,83 +21,130 @@ namespace utility
DataTypeQualifierList qualifierList;
DataTypeModifierStack modifierStack;
while (true)
bool needsRefinement = true;
while (needsRefinement)
{
const clang::Type* type = qualType.getTypePtr();
if (type->getAs<clang::TypedefType>())
clang::Type::TypeClass tk = type->getTypeClass();
switch (type->getTypeClass())
{
typeNameHerarchy.push_back(utility::substrAfter(qualType.getAsString(), ' '));
break;
}
else if (type->isPointerType())
{
std::shared_ptr<DataTypeModifier> modifier = std::make_shared<DataTypeModifierPointer>();
if (qualType.isConstQualified())
case clang::Type::Paren:
{
modifier->addQualifier(DataTypeQualifierList::QUALIFIER_CONST);
qualType = type->getAs<clang::ParenType>()->getInnerType();
// what about qualifiers and modifiers
break;
}
modifierStack.push(modifier);
qualType = type->getPointeeType();
}
else if (type->isArrayType())
{
std::shared_ptr<DataTypeModifier> modifier = std::make_shared<DataTypeModifierArray>();
if (qualType.isConstQualified())
case clang::Type::Typedef:
{
modifier->addQualifier(DataTypeQualifierList::QUALIFIER_CONST);
typeNameHerarchy = getDeclNameHierarchy(type->getAs<clang::TypedefType>()->getDecl());
needsRefinement = false;
break;
}
modifierStack.push(modifier);
case clang::Type::Pointer:
{
std::shared_ptr<DataTypeModifier> modifier = std::make_shared<DataTypeModifierPointer>();
if (qualType.isConstQualified())
{
modifier->addQualifier(DataTypeQualifierList::QUALIFIER_CONST);
}
modifierStack.push(modifier);
qualType = clang::dyn_cast<clang::ArrayType>(type)->getElementType();
}
else if (type->isReferenceType())
{
std::shared_ptr<DataTypeModifier> modifier = std::make_shared<DataTypeModifierReference>();
// references can not be const qualified
modifierStack.push(modifier);
qualType = type->getPointeeType();
break;
}
case clang::Type::ConstantArray:
case clang::Type::VariableArray:
case clang::Type::DependentSizedArray:
case clang::Type::IncompleteArray:
{
std::shared_ptr<DataTypeModifier> modifier = std::make_shared<DataTypeModifierArray>();
if (qualType.isConstQualified())
{
modifier->addQualifier(DataTypeQualifierList::QUALIFIER_CONST);
}
modifierStack.push(modifier);
qualType = type->getPointeeType();
}
else
{
const clang::Type* type = qualType.getUnqualifiedType().getTypePtr();
qualType = clang::dyn_cast<clang::ArrayType>(type)->getElementType();
break;
}
case clang::Type::LValueReference:
case clang::Type::RValueReference:
{
std::shared_ptr<DataTypeModifier> modifier = std::make_shared<DataTypeModifierReference>();
// references can not be const qualified
modifierStack.push(modifier);
if (clang::isa<clang::ElaboratedType>(type)) // get the real type here
qualType = type->getPointeeType();
break;
}
case clang::Type::Elaborated:
{
const clang::ElaboratedType* et = clang::dyn_cast<clang::ElaboratedType>(type);
type = et->getNamedType().getUnqualifiedType().getTypePtr();
qualType = et->getNamedType();
break;
}
if (clang::isa<clang::TagType>(type))
case clang::Type::Enum:
case clang::Type::Record:
{
typeNameHerarchy = getDeclNameHierarchy(clang::dyn_cast<clang::TagType>(type)->getDecl());
typeNameHerarchy = getDeclNameHierarchy(type->getAs<clang::TagType>()->getDecl());
needsRefinement = false;
break;
}
else
case clang::Type::Builtin:
case clang::Type::TemplateSpecialization:
{
clang::PrintingPolicy pp = clang::PrintingPolicy(clang::LangOptions());
pp.SuppressTagKeyword = true; // value "true": for a class A it prints "A" instead of "class A"
pp.Bool = true; // value "true": prints bool type as "bool" instead of "_Bool"
std::string typeName = qualType.getUnqualifiedType().getAsString(pp);
typeNameHerarchy.push_back(typeName);
needsRefinement = false;
break;
}
case clang::Type::TemplateTypeParm:
{
clang::PrintingPolicy pp = clang::PrintingPolicy(clang::LangOptions());
pp.SuppressTagKeyword = true; // value "true": for a class A it prints "A" instead of "class A"
pp.Bool = true; // value "true": prints bool type as "bool" instead of "_Bool"
std::string typeName = qualType.getUnqualifiedType().getAsString(pp);
if (type->isTemplateTypeParmType())
clang::TemplateTypeParmDecl* templateTypeParmDecl = clang::dyn_cast<clang::TemplateTypeParmType>(qualType)->getDecl();
typeNameHerarchy = getContextNameHierarchy(templateTypeParmDecl->getDeclContext());
if (typeNameHerarchy.size() == 0)
{
clang::TemplateTypeParmDecl* templateTypeParmDecl = clang::dyn_cast<clang::TemplateTypeParmType>(qualType.getUnqualifiedType())->getDecl();
if (templateTypeParmDecl)
{
typeNameHerarchy = getContextNameHierarchy(templateTypeParmDecl->getDeclContext());
typeNameHerarchy.back() += "::" + typeName;
}
int gogo = 0;
typeNameHerarchy.push_back(typeName); // HOT: fix this one! definition of template function outside of class scope!
}
else
{
typeNameHerarchy.push_back(typeName);
typeNameHerarchy.back() += "::" + typeName;
}
needsRefinement = false;
break;
}
case clang::Type::SubstTemplateTypeParm:
{
const clang::SubstTemplateTypeParmType* substType = type->getAs<clang::SubstTemplateTypeParmType>();
qualType = substType->getReplacementType();
break;
}
default:
{
LOG_ERROR(std::string("Unhandled kind of type encountered: ") + type->getTypeClassName());
clang::PrintingPolicy pp = clang::PrintingPolicy(clang::LangOptions());
pp.SuppressTagKeyword = true; // value "true": for a class A it prints "A" instead of "class A"
pp.Bool = true; // value "true": prints bool type as "bool" instead of "_Bool"
std::string typeName = qualType.getUnqualifiedType().getAsString(pp);
typeNameHerarchy.push_back(typeName);
needsRefinement = false;
break;
}
break;
}
}
if (qualType.isConstQualified())
{
qualifierList.addQualifier(DataTypeQualifierList::QUALIFIER_CONST);