[PATCH] D93787: [analyzer] Fix crash caused by accessing empty map

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 25 14:40:51 PST 2020


steakhal added a reviewer: steakhal.
steakhal requested changes to this revision.
steakhal added a comment.
This revision now requires changes to proceed.

This form of macro expansion is obsolete - I hope that the community agrees on this.
Crashes for many more cases then just the one you mentioned. Its a really hard and bugrone to mimic the preprocessor, thus we seek to substitute this with the clang's preprocessor implementation.
I recommend pushing an XFAIL lit test demonstrating the current limitation (without your proposed fix), while we can show that this will pass after we accept my patches.
For the record those are in an early phase at D93222 <https://reviews.llvm.org/D93222>.



================
Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:1241
           if (TheTok.getIdentifierInfo() == VariadicParamII) {
-            TStream.injectRange(PrevParamMap.at(VariadicParamII));
+            if (PrevParamMap.find(VariadicParamII) != PrevParamMap.end())
+              TStream.injectRange(PrevParamMap.at(VariadicParamII));
----------------
Btw this lookup supposed to be successful. Always. Which suggests me that there are even more logic bug lurking there.
Without using 'at' here we wouldn't notice it, which is lucky.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93787/new/

https://reviews.llvm.org/D93787



More information about the cfe-commits mailing list