[PATCH] D86135: [analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 28 05:51:18 PDT 2020


martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:896-898
+    RawLexer.reset(new Lexer(SM.getLocForStartOfFile(LocInfo.first), LangOpts,
+                             MB->getBufferStart(), MacroNameTokenPos,
+                             MB->getBufferEnd()));
----------------
Szelethus wrote:
> steakhal wrote:
> > I'm always puzzled if I see a naked `new`.
> > Couldn't we use the assignment operator and `std::make_unique` here?
> Wait, isn't it naked if its //not// surrounded by smart pointer stuff? In any case, explicit calls to operator `new` and `delete` are indeed discouraged by the [[http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly | core guidelines]].
It is not enough to call a smart pointer's constructor with a result of a naked new. Because after the allocation of the object, the object's constructor itself could throw (well, not in LLVM :D) and this could happen before acquiring the ownership by the smart pointer, bumm, we have a leak.


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

https://reviews.llvm.org/D86135



More information about the cfe-commits mailing list