[PATCH] D154257: [clang] Fix leak in LoadFromCommandLineWorkingDirectory unit test

Ben Langmuir via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 30 14:12:48 PDT 2023


benlangmuir accepted this revision.
benlangmuir added a comment.

Gotta love `return AST.release()` being passed directly back into `std::unique_ptr<ASTUnit>(...)`.  Thanks for fixing!



================
Comment at: clang/tools/libclang/CIndex.cpp:3965
       unsaved_files);
-  std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCommandLine(
+  auto Unit = ASTUnit::LoadFromCommandLine(
       Args->data(), Args->data() + Args->size(),
----------------
Nit: the style guidance for `auto` in llvm is "type is already obvious from the context".  Since I don't think that's obvious here (in particular, this code would have compiled with the raw pointer return type), and the type name will not be verbose, I think we should keep `std::unique_ptr<ASTUnit>`.  Same for the other calls below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154257



More information about the cfe-commits mailing list