[PATCH] D105457: [clang] Refactor AST printing tests to share more infrastructure

Douglas Yung via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 14 13:33:09 PDT 2021


dyung added a comment.

In D105457#2877971 <https://reviews.llvm.org/D105457#2877971>, @dblaikie wrote:

> In D105457#2876511 <https://reviews.llvm.org/D105457#2876511>, @dyung wrote:
>
>> If it helps, I have so far been able to reduce the file to this which still shows the failure when compiled with gcc 7.5:
>
> Could you provide the preprocessed input file - maybe that run through creduce could be helpful.

I did originally run it through cvise, but wasn't sure if it would be useful since it cut out everything except for what was causing one of the two failures. But if it helps, here is what it reduced to:

  namespace std {
  template <bool> using __bool_constant = int;
  template <typename> struct is_base_of;
  template <typename> using remove_reference_t = int;
  template <bool> using enable_if_t = int;
  template <typename> struct iterator_traits;
  struct _Any_data;
  enum _Manager_operation {};
  template <typename> class function;
  class _Function_base {
  public:
    template <typename> class _Base_manager {
    public:
      static bool _M_manager(_Any_data &, const _Any_data &, _Manager_operation) {
      }
    };
    typedef bool (*_Manager_type)(_Any_data &, const _Any_data &,
                                  _Manager_operation);
    _Manager_type _M_manager;
  };
  template <typename, typename> class _Function_handler;
  template <typename _Res, typename _Functor, typename... _ArgTypes>
  class _Function_handler<_Res(_ArgTypes...), _Functor>
      : public _Function_base::_Base_manager<_Functor> {};
  template <typename _Res, typename... _ArgTypes>
  class function<_Res(_ArgTypes...)> : _Function_base {
    template <typename, typename> using _Requires = int;
  public:
    template <typename _Functor,
              typename = _Requires<__bool_constant<!bool()>, void>,
              typename = _Requires<int, void>>
    function(_Functor);
  };
  template <typename _Res, typename... _ArgTypes>
  template <typename _Functor, typename, typename>
  function<_Res(_ArgTypes...)>::function(_Functor) {
    _M_manager = _Function_handler<_Res(), _Functor>::_M_manager;
  }
  } // namespace std
  template <typename IterTy>
  void hasNItems(
      IterTy Begin = [] {},
      std::enable_if_t<std::is_base_of<std::iterator_traits<
          std::remove_reference_t<decltype(Begin)>>>::valuevoid> = [] {},
      std::enable_if_t<std::is_base_of<std::iterator_traits<
          std::remove_reference_t<decltype(Begin)>>>::valuevoid> = [] {});
  class StringRef {
  public:
    StringRef(char *);
  };
  namespace clang {
  class Stmt anything();
  template <typename> using NodeFilter = std::function<bool()>;
  template <typename NodeType, typename Matcher>
  void PrintedNodeMatches(
      Matcher, NodeFilter<NodeType> = [](const NodeType *) {});
  } // namespace clang
  using namespace clang;
  enum StdVer { CXX98 };
  template <typename Matcher> void PrintedStmtMatches(Matcher NodeMatch) {
    PrintedNodeMatches<Stmt>(NodeMatch);
  }
  template <typename T>
  void PrintedStmtCXXMatches(StdVer, StringRef, T NodeMatch, StringRef) {
    PrintedStmtMatches(NodeMatch);
    PrintedStmtCXXMatches(CXX98, "", 0, "");
  }
  void StmtPrinter_TestCXXConversionDeclImplicit_TestTestBody() {
    PrintedStmtCXXMatches(CXX98, "", anything, "");
  }

Compiled with gcc 7.5 and optimizations yields the following output:

  dyung at frogstar:~/sandbox/StmtPrinterTest$ gcc -O2 -Wno-write-strings StmtPrinterTest.preproc.cpp
  /tmp/ccLNKEkE.s: Assembler messages:
  /tmp/ccLNKEkE.s:14: Error: symbol `_ZNSt14_Function_base13_Base_managerIN5clangUlPKNS1_4StmtEE2_EE10_M_managerERSt9_Any_dataRKS7_St18_Manager_operation' is already defined


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105457



More information about the cfe-commits mailing list