[PATCH] D116377: [libTooling] Adds more support for constructing object access expressions.

Andy Soffer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 7 07:50:55 PST 2022


asoffer added inline comments.


================
Comment at: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp:73
+      cxxRecordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
+  const auto QuacksLikeASmartPointer = cxxRecordDecl(
+      hasMethod(cxxMethodDecl(hasOverloadedOperatorName("->"),
----------------
Naming nit: This could be confusing for anyone not familiar with the "duck typing" idiom.
BehavesLikeASmartPointer?


================
Comment at: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp:78
+                              returns(qualType(references(type()))))));
+  const auto SmartPointer = qualType(hasDeclaration(
+      cxxRecordDecl(anyOf(KnownSmartPointer, QuacksLikeASmartPointer))));
----------------
I think std::optional satisfies these requirements but should not be considered a smart-pointer.


================
Comment at: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp:79
+  const auto SmartPointer = qualType(hasDeclaration(
+      cxxRecordDecl(anyOf(KnownSmartPointer, QuacksLikeASmartPointer))));
+  return match(SmartPointer, Ty, Context).size() > 0;
----------------
The known smart pointers quack like smart pointers, so this is redundant, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116377



More information about the cfe-commits mailing list