[all-commits] [llvm/llvm-project] 047872: [clang] Prevent that Decl::dump on a CXXRecordDecl...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Mon Sep 7 03:32:24 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0478720157f6413fad7595b8eff9c70d2d99b637
      https://github.com/llvm/llvm-project/commit/0478720157f6413fad7595b8eff9c70d2d99b637
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2020-09-07 (Mon, 07 Sep 2020)

  Changed paths:
    M clang/lib/AST/TextNodeDumper.cpp
    M clang/test/AST/ast-dump-lambda.cpp
    M clang/test/AST/ast-dump-records.cpp
    A clang/unittests/AST/ASTDumpTest.cpp
    M clang/unittests/AST/CMakeLists.txt

  Log Message:
  -----------
  [clang] Prevent that Decl::dump on a CXXRecordDecl deserialises further declarations.

Decl::dump is primarily used for debugging to visualise the current state of a
declaration. Usually Decl::dump just displays the current state of the Decl and
doesn't actually change any of its state, however since commit
457226e02a6e8533eaaa864a3fd7c8eeccd2bf58 the method actually started loading
additional declarations from the ExternalASTSource. This causes that calling
Decl::dump during a debugging session now actually does permanent changes to the
AST and will cause the debugged program run to deviate from the original run.

The change that caused this behaviour is the addition of
`hasConstexprDestructor` (which is called from the TextNodeDumper) which
performs a lookup into the current CXXRecordDecl to find the destructor. All
other similar methods just return their respective bit in the DefinitionData
(which obviously doesn't have such side effects).

This just changes the node printer to emit "unknown_constexpr" in case a
CXXRecordDecl is dumped that could potentially call into the ExternalASTSource
instead of the usually empty string/"constexpr". For CXXRecordDecls that can
safely be dumped the old behaviour is preserved

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D80878




More information about the All-commits mailing list