@@ -414,9 +414,11 @@ namespace clangimport {
414414
415415std::string clangimport::AstNode::getSpelling () const
416416{
417- if (mJsonObject .count (" name" ) == 0 )
418- return {};
419- return mJsonObject .at (" name" ).get <std::string>();
417+ if (mJsonObject .count (" opcode" ) > 0 )
418+ return mJsonObject .at (" opcode" ).get <std::string>();
419+ if (mJsonObject .count (" name" ) > 0 )
420+ return mJsonObject .at (" name" ).get <std::string>();
421+ return {};
420422}
421423
422424std::string clangimport::AstNode::getQualType () const
@@ -751,7 +753,7 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
751753 }
752754 if (mKind == BinaryOperator) {
753755 Token *tok1 = getChild (0 )->createTokens (tokenList);
754- Token *binop = addtoken (tokenList, mJsonObject . at ( " opcode " ). get <std::string> ());
756+ Token *binop = addtoken (tokenList, getSpelling ());
755757 Token *tok2 = children[1 ]->createTokens (tokenList);
756758 binop->astOperand1 (tok1);
757759 binop->astOperand2 (tok2);
@@ -1249,16 +1251,16 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
12491251 return addtoken (tokenList, getSpelling ());
12501252 }
12511253 if (mKind == UnaryOperator) {
1252- const std::string& opcode = mJsonObject . at ( " opcode " ). get <std::string> ();
1254+ const std::string& spelling = getSpelling ();
12531255 const bool postfix = mJsonObject .count (" isPostfix" ) > 0 && mJsonObject .at (" isPostfix" ).get <bool >();
12541256 if (postfix) {
12551257 Token* tok = getChild (0 )->createTokens (tokenList);
1256- Token *unaryOp = addtoken (tokenList, opcode );
1258+ Token *unaryOp = addtoken (tokenList, spelling );
12571259 setValueType (unaryOp);
12581260 unaryOp->astOperand1 (tok);
12591261 return unaryOp;
12601262 } else {
1261- Token *unaryOp = addtoken (tokenList, opcode );
1263+ Token *unaryOp = addtoken (tokenList, spelling );
12621264 setValueType (unaryOp);
12631265 unaryOp->astOperand1 (getChild (0 )->createTokens (tokenList));
12641266 return unaryOp;
0 commit comments