[PATCH] D149816: [clang][Interp] Implement __builtin_strcmp

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 11 09:28:05 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:22-23
+
+static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
+                                   InterpFrame *Frame) {
+  const Pointer &A = getParam<Pointer>(Frame, 0);
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > Thought: it would be nice if we could hoist as much of this implementation as we can into a helper function so that we can share most of the guts with `__builtin_memcmp()` as well.
> > 
> > Also, it would be good to generalize this so it works for `__builtin_wcscmp()` and `__builtin_wmemcmp()` as well.
> Definitely, but I think it makes more sense to do that when we implement those functions.
I guess I was mostly wondering why we don't generalize that now given that we know the need exists. In fact, it seems like you could be handling `__builtin_strncmp` and others at the same time with one generalized implementation.


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

https://reviews.llvm.org/D149816



More information about the cfe-commits mailing list