[clang] [clang][AST] Add public wrapper getOpcodeStr to UnaryOperator (PR #230692)

Chen Miao via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 18:03:48 PDT 2026


================
@@ -2399,6 +2399,8 @@ class UnaryOperator final
   /// corresponds to, e.g. "sizeof" or "[pre]++"
   static StringRef getOpcodeStr(Opcode Op);
 
+  StringRef getOpcodeStr() const { return getOpcodeStr(getOpcode()); }
----------------
ChenMiaoi wrote:

IMO, adding this convenience overload without updating existing call sites offers limited practical benefit. 

Could you also update the corresponding `UnaryOperator` calls, for example in `clangd/DumpAST.cpp` and `ASTMatchersInternal.h`, to match the `BinaryOperator` usage? That would simplify existing code and make the value of the new overload more apparent.

https://github.com/llvm/llvm-project/pull/230692


More information about the cfe-commits mailing list