[PATCH] D31697: Check for null before using TUScope

Kim Gräsman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 2 03:53:22 PDT 2017


kimgr added a comment.

> only for the function templates that use Microsoft intrinsics (e.g. _BitScanForward in TrailingZerosCounter<T>.)
>  So there's something in the parsing of builtins/intrinsics that requires TUScope to be non-null.

For posterity, this was misdiagnosed on my part. It turns out the pp conditionals in MathExtras.h select the GCC-style intrinsics for Clang, even in MS compat mode (because `_MSC_VER` is consistently checked *after* `__has_builtin` and friends).

So the problem is really with GCC builtins inside function templates. Here's a minimal repro:

  template <class T>
  int myctz(unsigned int value) {
   return __builtin_ctz(value);
  }


https://reviews.llvm.org/D31697





More information about the cfe-commits mailing list