[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 4 09:48:44 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/test/AST/Interp/literals.cpp:849
+    static_assert(strings_match(__func__, "foo"));
+    static_assert(strings_match(__PRETTY_FUNCTION__, "void PredefinedExprs::foo()"));
+  }
----------------
tbaeder wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > You should add coverage for the others as well:
> > > ```
> > >   enum IdentKind {
> > >     Func,
> > >     Function,
> > >     LFunction, // Same as Function, but as wide string.
> > >     FuncDName,
> > >     FuncSig,
> > >     LFuncSig, // Same as FuncSig, but as wide string
> > >     PrettyFunction,
> > >     /// The same as PrettyFunction, except that the
> > >     /// 'virtual' keyword is omitted for virtual member functions.
> > >     PrettyFunctionNoVirtual
> > >   };
> > > ```
> > > (you can handle the wide string variants by making `strings_match` into a template.)
> > These don't seem to exist in C++14 onwards:
> > ```
> > array.cpp:1238:33: error: use of undeclared identifier '__FUNCDNAME__'
> >  1238 |     static_assert(strings_match(__FUNCDNAME__, "foo"), "");
> >       |                                 ^
> > array.cpp:1239:33: error: use of undeclared identifier '__FUNCSIG__'
> >  1239 |     static_assert(strings_match(__FUNCSIG__, "foo"), "");
> >       |                                 ^
> > array.cpp:1240:33: error: use of undeclared identifier '__LFUNCSIG__'
> >  1240 |     static_assert(strings_match(__LFUNCSIG__, "foo"), "");
> >       |                                 ^
> > array.cpp:1241:33: error: use of undeclared identifier '__LFUNCTION__'
> >  1241 |     static_assert(strings_match(__LFUNCTION__, "foo"), "");
> >       |                                 ^
> > array.cpp:1244:33: error: use of undeclared identifier '__PRETTY_FUNCTION_NO_VIRTUAL__'
> >  1244 |     static_assert(strings_match(__PRETTY_FUNCTION_NO_VIRTUAL__, "void PredefinedExprs::foo()"), "");
> >       |                                 ^
> > 5 errors generated.
> > ```
> > ... but I can't use a while loop (or any kind of loop, I think?) before C++14 :)
> e
They exist, but you need to enable `-fms-extensions` for them: https://godbolt.org/z/E94snrMd9


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

https://reviews.llvm.org/D148689



More information about the cfe-commits mailing list