Skip to content

Commit b2786f8

Browse files
committed
Fix clang assert
1 parent 16fa166 commit b2786f8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/CppParser/Bootstrap/StmtCodeGenerators.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,20 @@ public override bool VisitProperty(Property property)
341341
WriteLine($"_S->{fieldName} = static_cast<AST::{typeName}>(" +
342342
$"WalkStatement(S->{methodName}()));");
343343
else if (typeName.Contains("Expr"))
344-
WriteLine($"_S->{fieldName} = static_cast<AST::{typeName}>(" +
345-
$"WalkExpression(S->{methodName}()));");
344+
{
345+
var expr = $"_S->{fieldName} = static_cast<AST::{typeName}>(WalkExpression(S->{methodName}()));";
346+
347+
if (fieldName == "base" && typeName is "CXXDependentScopeMemberExpr")
348+
{
349+
// Clang asserts that 'getBase()' is not called when 'isImplicitAccess()' returns true
350+
WriteLine("if (!S->isImplicitAccess())");
351+
WriteLineIndent(expr);
352+
}
353+
else
354+
{
355+
WriteLine(expr);
356+
}
357+
}
346358
else if (fieldName == "guidDecl")
347359
WriteLine($"_S->{fieldName} = S->getGuidDecl()->getNameAsString();");
348360
else if (typeName.Contains("Decl") || typeName.Contains("Method") ||

src/CppParser/ParseExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
24262426
_S->refersToMatrixElement = S->refersToMatrixElement();
24272427
_S->hasPlaceholderType = S->hasPlaceholderType();
24282428
_S->isImplicitAccess = S->isImplicitAccess();
2429-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
2429+
if (!S->isImplicitAccess())
2430+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
24302431
_S->baseType = GetQualifiedType(S->getBaseType());
24312432
_S->isArrow = S->isArrow();
24322433
_S->firstQualifierFoundInScope = static_cast<AST::Declaration*>(WalkDeclaration(S->getFirstQualifierFoundInScope()));

0 commit comments

Comments
 (0)