Skip to content

Commit c54f367

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

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/CppParser/Bootstrap/StmtCodeGenerators.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,19 @@ 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")
348+
{
349+
WriteLine("if (!S->isImplicitAccess())");
350+
WriteLineIndent(expr);
351+
}
352+
else
353+
{
354+
WriteLine(expr);
355+
}
356+
}
346357
else if (fieldName == "guidDecl")
347358
WriteLine($"_S->{fieldName} = S->getGuidDecl()->getNameAsString();");
348359
else if (typeName.Contains("Decl") || typeName.Contains("Method") ||

src/CppParser/ParseExpr.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
457457
_S->refersToMatrixElement = S->refersToMatrixElement();
458458
_S->hasPlaceholderType = S->hasPlaceholderType();
459459
_S->isIncomplete = S->isIncomplete();
460-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
460+
if (!S->isImplicitAccess())
461+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
461462
_S->rowIdx = static_cast<AST::Expr*>(WalkExpression(S->getRowIdx()));
462463
_S->columnIdx = static_cast<AST::Expr*>(WalkExpression(S->getColumnIdx()));
463464
_Expr = _S;
@@ -516,7 +517,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
516517
_S->isOrdinaryOrBitFieldObject = S->isOrdinaryOrBitFieldObject();
517518
_S->refersToMatrixElement = S->refersToMatrixElement();
518519
_S->hasPlaceholderType = S->hasPlaceholderType();
519-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
520+
if (!S->isImplicitAccess())
521+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
520522
_S->hasQualifier = S->hasQualifier();
521523
_S->hasTemplateKeyword = S->hasTemplateKeyword();
522524
_S->hasExplicitTemplateArgs = S->hasExplicitTemplateArgs();
@@ -1048,7 +1050,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
10481050
_S->isOrdinaryOrBitFieldObject = S->isOrdinaryOrBitFieldObject();
10491051
_S->refersToMatrixElement = S->refersToMatrixElement();
10501052
_S->hasPlaceholderType = S->hasPlaceholderType();
1051-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
1053+
if (!S->isImplicitAccess())
1054+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
10521055
_S->updater = static_cast<AST::InitListExpr*>(WalkExpression(S->getUpdater()));
10531056
_Expr = _S;
10541057
break;
@@ -1190,7 +1193,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
11901193
_S->isOrdinaryOrBitFieldObject = S->isOrdinaryOrBitFieldObject();
11911194
_S->refersToMatrixElement = S->refersToMatrixElement();
11921195
_S->hasPlaceholderType = S->hasPlaceholderType();
1193-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
1196+
if (!S->isImplicitAccess())
1197+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
11941198
_S->numElements = S->getNumElements();
11951199
_S->containsDuplicateElements = S->containsDuplicateElements();
11961200
_S->isArrow = S->isArrow();
@@ -2218,7 +2222,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
22182222
_S->isOrdinaryOrBitFieldObject = S->isOrdinaryOrBitFieldObject();
22192223
_S->refersToMatrixElement = S->refersToMatrixElement();
22202224
_S->hasPlaceholderType = S->hasPlaceholderType();
2221-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
2225+
if (!S->isImplicitAccess())
2226+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
22222227
_S->hasQualifier = S->hasQualifier();
22232228
_S->isArrow = S->isArrow();
22242229
_S->destroyedType = GetQualifiedType(S->getDestroyedType());
@@ -2426,7 +2431,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
24262431
_S->refersToMatrixElement = S->refersToMatrixElement();
24272432
_S->hasPlaceholderType = S->hasPlaceholderType();
24282433
_S->isImplicitAccess = S->isImplicitAccess();
2429-
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
2434+
if (!S->isImplicitAccess())
2435+
_S->base = static_cast<AST::Expr*>(WalkExpression(S->getBase()));
24302436
_S->baseType = GetQualifiedType(S->getBaseType());
24312437
_S->isArrow = S->isArrow();
24322438
_S->firstQualifierFoundInScope = static_cast<AST::Declaration*>(WalkDeclaration(S->getFirstQualifierFoundInScope()));

0 commit comments

Comments
 (0)