@@ -5741,128 +5741,218 @@ void Tokenizer::dump(std::ostream &out) const
5741
5741
// The idea is not that this will be readable for humans. It's a
5742
5742
// data dump that 3rd party tools could load and get useful info from.
5743
5743
5744
+ std::string outs;
5745
+
5744
5746
std::set<const Library::Container*> containers;
5745
5747
5746
5748
// tokens..
5747
- out << " <tokenlist>" << std::endl;
5749
+ outs += " <tokenlist>" ;
5750
+ outs += ' \n ' ;
5748
5751
for (const Token *tok = list.front (); tok; tok = tok->next ()) {
5749
- out << " <token id=\" " << tok << " \" file=\" " << ErrorLogger::toxml (list.file (tok)) << " \" linenr=\" " << tok->linenr () << " \" column=\" " << tok->column () << " \" " ;
5750
- out << " str=\" " << ErrorLogger::toxml (tok->str ()) << ' \" ' ;
5751
- out << " scope=\" " << tok->scope () << ' \" ' ;
5752
+ outs += " <token id=\" " ;
5753
+ outs += ptr_to_string (tok);
5754
+ outs += " \" file=\" " ;
5755
+ outs += ErrorLogger::toxml (list.file (tok)); // TODO: hot spot
5756
+ outs += " \" linenr=\" " ;
5757
+ outs += std::to_string (tok->linenr ());
5758
+ outs += " \" column=\" " ;
5759
+ outs += std::to_string (tok->column ());
5760
+ outs += " \" " ;
5761
+
5762
+ outs += " str=\" " ;
5763
+ outs += ErrorLogger::toxml (tok->str ()); // TODO: hot spot
5764
+ outs += ' \" ' ;
5765
+
5766
+ outs += " scope=\" " ;
5767
+ outs += ptr_to_string (tok->scope ());
5768
+ outs += ' \" ' ;
5752
5769
if (tok->isName ()) {
5753
- out << " type=\" name\" " ;
5770
+ outs += " type=\" name\" " ;
5754
5771
if (tok->isUnsigned ())
5755
- out << " isUnsigned=\" true\" " ;
5772
+ outs += " isUnsigned=\" true\" " ;
5756
5773
else if (tok->isSigned ())
5757
- out << " isSigned=\" true\" " ;
5774
+ outs += " isSigned=\" true\" " ;
5758
5775
} else if (tok->isNumber ()) {
5759
- out << " type=\" number\" " ;
5776
+ outs += " type=\" number\" " ;
5760
5777
if (MathLib::isInt (tok->str ()))
5761
- out << " isInt=\" true\" " ;
5778
+ outs += " isInt=\" true\" " ;
5762
5779
if (MathLib::isFloat (tok->str ()))
5763
- out << " isFloat=\" true\" " ;
5764
- } else if (tok->tokType () == Token::eString)
5765
- out << " type=\" string\" strlen=\" " << Token::getStrLength (tok) << ' \" ' ;
5780
+ outs += " isFloat=\" true\" " ;
5781
+ } else if (tok->tokType () == Token::eString) {
5782
+ outs += " type=\" string\" strlen=\" " ;
5783
+ outs += std::to_string (Token::getStrLength (tok));
5784
+ outs += ' \" ' ;
5785
+ }
5766
5786
else if (tok->tokType () == Token::eChar)
5767
- out << " type=\" char\" " ;
5787
+ outs += " type=\" char\" " ;
5768
5788
else if (tok->isBoolean ())
5769
- out << " type=\" boolean\" " ;
5789
+ outs += " type=\" boolean\" " ;
5770
5790
else if (tok->isOp ()) {
5771
- out << " type=\" op\" " ;
5791
+ outs += " type=\" op\" " ;
5772
5792
if (tok->isArithmeticalOp ())
5773
- out << " isArithmeticalOp=\" true\" " ;
5793
+ outs += " isArithmeticalOp=\" true\" " ;
5774
5794
else if (tok->isAssignmentOp ())
5775
- out << " isAssignmentOp=\" true\" " ;
5795
+ outs += " isAssignmentOp=\" true\" " ;
5776
5796
else if (tok->isComparisonOp ())
5777
- out << " isComparisonOp=\" true\" " ;
5797
+ outs += " isComparisonOp=\" true\" " ;
5778
5798
else if (tok->tokType () == Token::eLogicalOp)
5779
- out << " isLogicalOp=\" true\" " ;
5799
+ outs += " isLogicalOp=\" true\" " ;
5780
5800
}
5781
5801
if (tok->isCast ())
5782
- out << " isCast=\" true\" " ;
5802
+ outs += " isCast=\" true\" " ;
5783
5803
if (tok->isExternC ())
5784
- out << " externLang=\" C\" " ;
5804
+ outs += " externLang=\" C\" " ;
5785
5805
if (tok->isExpandedMacro ())
5786
- out << " isExpandedMacro=\" true\" " ;
5806
+ outs += " isExpandedMacro=\" true\" " ;
5787
5807
if (tok->isRemovedVoidParameter ())
5788
- out << " isRemovedVoidParameter=\" true\" " ;
5808
+ outs += " isRemovedVoidParameter=\" true\" " ;
5789
5809
if (tok->isSplittedVarDeclComma ())
5790
- out << " isSplittedVarDeclComma=\" true\" " ;
5810
+ outs += " isSplittedVarDeclComma=\" true\" " ;
5791
5811
if (tok->isSplittedVarDeclEq ())
5792
- out << " isSplittedVarDeclEq=\" true\" " ;
5812
+ outs += " isSplittedVarDeclEq=\" true\" " ;
5793
5813
if (tok->isImplicitInt ())
5794
- out << " isImplicitInt=\" true\" " ;
5814
+ outs += " isImplicitInt=\" true\" " ;
5795
5815
if (tok->isComplex ())
5796
- out << " isComplex=\" true\" " ;
5816
+ outs += " isComplex=\" true\" " ;
5797
5817
if (tok->isRestrict ())
5798
- out << " isRestrict=\" true\" " ;
5799
- if (tok->link ())
5800
- out << " link=\" " << tok->link () << ' \" ' ;
5801
- if (tok->varId () > 0 )
5802
- out << " varId=\" " << MathLib::toString (tok->varId ()) << ' \" ' ;
5803
- if (tok->exprId () > 0 )
5804
- out << " exprId=\" " << MathLib::toString (tok->exprId ()) << ' \" ' ;
5805
- if (tok->variable ())
5806
- out << " variable=\" " << tok->variable () << ' \" ' ;
5807
- if (tok->function ())
5808
- out << " function=\" " << tok->function () << ' \" ' ;
5809
- if (!tok->values ().empty ())
5810
- out << " values=\" " << &tok->values () << ' \" ' ;
5811
- if (tok->type ())
5812
- out << " type-scope=\" " << tok->type ()->classScope << ' \" ' ;
5813
- if (tok->astParent ())
5814
- out << " astParent=\" " << tok->astParent () << ' \" ' ;
5815
- if (tok->astOperand1 ())
5816
- out << " astOperand1=\" " << tok->astOperand1 () << ' \" ' ;
5817
- if (tok->astOperand2 ())
5818
- out << " astOperand2=\" " << tok->astOperand2 () << ' \" ' ;
5819
- if (!tok->originalName ().empty ())
5820
- out << " originalName=\" " << tok->originalName () << ' \" ' ;
5818
+ outs += " isRestrict=\" true\" " ;
5819
+ if (tok->link ()) {
5820
+ outs += " link=\" " ;
5821
+ outs += ptr_to_string (tok->link ());
5822
+ outs += ' \" ' ;
5823
+ }
5824
+ if (tok->varId () > 0 ) {
5825
+ outs += " varId=\" " ;
5826
+ outs += MathLib::toString (tok->varId ());
5827
+ outs += ' \" ' ;
5828
+ }
5829
+ if (tok->exprId () > 0 ) {
5830
+ outs += " exprId=\" " ;
5831
+ outs += MathLib::toString (tok->exprId ());
5832
+ outs += ' \" ' ;
5833
+ }
5834
+ if (tok->variable ()) {
5835
+ outs += " variable=\" " ;
5836
+ outs += ptr_to_string (tok->variable ());
5837
+ outs += ' \" ' ;
5838
+ }
5839
+ if (tok->function ()) {
5840
+ outs += " function=\" " ;
5841
+ outs += ptr_to_string (tok->function ());
5842
+ outs += ' \" ' ;
5843
+ }
5844
+ if (!tok->values ().empty ()) {
5845
+ outs += " values=\" " ;
5846
+ outs += ptr_to_string (&tok->values ());
5847
+ outs += ' \" ' ;
5848
+ }
5849
+ if (tok->type ()) {
5850
+ outs += " type-scope=\" " ;
5851
+ outs += ptr_to_string (tok->type ()->classScope );
5852
+ outs += ' \" ' ;
5853
+ }
5854
+ if (tok->astParent ()) {
5855
+ outs += " astParent=\" " ;
5856
+ outs += ptr_to_string (tok->astParent ());
5857
+ outs += ' \" ' ;
5858
+ }
5859
+ if (tok->astOperand1 ()) {
5860
+ outs += " astOperand1=\" " ;
5861
+ outs += ptr_to_string (tok->astOperand1 ());
5862
+ outs += ' \" ' ;
5863
+ }
5864
+ if (tok->astOperand2 ()) {
5865
+ outs += " astOperand2=\" " ;
5866
+ outs += ptr_to_string (tok->astOperand2 ());
5867
+ outs += ' \" ' ;
5868
+ }
5869
+ if (!tok->originalName ().empty ()) {
5870
+ outs += " originalName=\" " ;
5871
+ outs += tok->originalName ();
5872
+ outs += ' \" ' ;
5873
+ }
5821
5874
if (tok->valueType ()) {
5822
5875
const std::string vt = tok->valueType ()->dump ();
5823
- if (!vt.empty ())
5824
- out << ' ' << vt;
5876
+ if (!vt.empty ()) {
5877
+ outs += ' ' ;
5878
+ outs += vt;
5879
+ }
5825
5880
containers.insert (tok->valueType ()->container );
5826
5881
}
5827
5882
if (!tok->varId () && tok->scope ()->isExecutable () && Token::Match (tok, " %name% (" )) {
5828
5883
if (mSettings ->library .isnoreturn (tok))
5829
- out << " noreturn=\" true\" " ;
5884
+ outs += " noreturn=\" true\" " ;
5830
5885
}
5831
5886
5832
- out << " />" << std::endl;
5887
+ outs += " />" ;
5888
+ outs += ' \n ' ;
5833
5889
}
5834
- out << " </tokenlist>" << std::endl;
5890
+ outs += " </tokenlist>" ;
5891
+ outs += ' \n ' ;
5892
+
5893
+ out << outs;
5894
+ outs.clear ();
5835
5895
5896
+ // TODO: hot spot
5836
5897
mSymbolDatabase ->printXml (out);
5837
5898
5838
5899
containers.erase (nullptr );
5839
5900
if (!containers.empty ()) {
5840
- out << " <containers>\n " ;
5901
+ outs += " <containers>" ;
5902
+ outs += ' \n ' ;
5841
5903
for (const Library::Container* c: containers) {
5842
- out << " <container id=\" " << c << " \" array-like-index-op=\" "
5843
- << (c->arrayLike_indexOp ? " true" : " false" ) << " \" "
5844
- << " std-string-like=\" " << (c->stdStringLike ? " true" : " false" ) << " \" />\n " ;
5904
+ outs += " <container id=\" " ;
5905
+ outs += ptr_to_string (c);
5906
+ outs += " \" array-like-index-op=\" " ;
5907
+ outs += (c->arrayLike_indexOp ? " true" : " false" );
5908
+ outs += " \" " ;
5909
+ outs += " std-string-like=\" " ;
5910
+ outs +=(c->stdStringLike ? " true" : " false" );
5911
+ outs += " \" />" ;
5912
+ outs += ' \n ' ;
5845
5913
}
5846
- out << " </containers>\n " ;
5914
+ outs += " </containers>" ;
5915
+ outs += ' \n ' ;
5847
5916
}
5848
5917
5849
5918
if (list.front ())
5850
5919
list.front ()->printValueFlow (true , out);
5851
5920
5852
5921
if (!mTypedefInfo .empty ()) {
5853
- out << " <typedef-info>" << std::endl;
5922
+ outs += " <typedef-info>" ;
5923
+ outs += ' \n ' ;
5854
5924
for (const TypedefInfo &typedefInfo: mTypedefInfo ) {
5855
- out << " <info"
5856
- << " name=\" " << typedefInfo.name << " \" "
5857
- << " file=\" " << typedefInfo.filename << " \" "
5858
- << " line=\" " << typedefInfo.lineNumber << " \" "
5859
- << " column=\" " << typedefInfo.column << " \" "
5860
- << " used=\" " << (typedefInfo.used ?1 :0 ) << " \" "
5861
- << " />" << std::endl;
5925
+ outs += " <info" ;
5926
+
5927
+ outs += " name=\" " ;
5928
+ outs += typedefInfo.name ;
5929
+ outs += " \" " ;
5930
+
5931
+ outs += " file=\" " ;
5932
+ outs += typedefInfo.filename ;
5933
+ outs += " \" " ;
5934
+
5935
+ outs += " line=\" " ;
5936
+ outs += std::to_string (typedefInfo.lineNumber );
5937
+ outs += " \" " ;
5938
+
5939
+ outs += " column=\" " ;
5940
+ outs += std::to_string (typedefInfo.column );
5941
+ outs += " \" " ;
5942
+
5943
+ outs += " used=\" " ;
5944
+ outs += std::to_string (typedefInfo.used ?1 :0 );
5945
+ outs += " \" " ;
5946
+
5947
+ outs += " />" ;
5948
+ outs += ' \n ' ;
5862
5949
}
5863
- out << " </typedef-info>" << std::endl;
5950
+ outs += " </typedef-info>" ;
5951
+ outs += ' \n ' ;
5864
5952
}
5865
- out << mTemplateSimplifier ->dump ();
5953
+ outs += mTemplateSimplifier ->dump ();
5954
+
5955
+ out << outs;
5866
5956
}
5867
5957
5868
5958
void Tokenizer::simplifyHeadersAndUnusedTemplates ()
0 commit comments