[cfe-commits] r82703 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/Frontend/ASTConsumers.h lib/Frontend/ASTConsumers.cpp tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Fri Sep 25 23:41:04 PDT 2009


On Thu, Sep 24, 2009 at 11:54 AM, Anders Carlsson <andersca at mac.com> wrote:
> Author: andersca
> Date: Thu Sep 24 13:54:49 2009
> New Revision: 82703
>
> URL: http://llvm.org/viewvc/llvm-project?rev=82703&view=rev
> Log:
> Add a -dump-record-layouts argument to clang-cc.
>
> Modified:
>    cfe/trunk/clang.xcodeproj/project.pbxproj
>    cfe/trunk/include/clang/Frontend/ASTConsumers.h
>    cfe/trunk/lib/Frontend/ASTConsumers.cpp
>    cfe/trunk/tools/clang-cc/clang-cc.cpp
>
> Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=82703&r1=82702&r2=82703&view=diff
>
> ==============================================================================
> --- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
> +++ cfe/trunk/clang.xcodeproj/project.pbxproj Thu Sep 24 13:54:49 2009
> @@ -342,7 +342,7 @@
>                1A2193CC0F45EEB700C0713D /* Mangle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = Mangle.cpp; path = lib/CodeGen/Mangle.cpp; sourceTree = "<group>"; tabWidth = 2; };
>                1A2193CD0F45EEB700C0713D /* Mangle.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = Mangle.h; path = lib/CodeGen/Mangle.h; sourceTree = "<group>"; tabWidth = 2; };
>                1A2A54A40FD1DD1C00F4CE45 /* AnalysisConsumer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AnalysisConsumer.cpp; path = lib/Frontend/AnalysisConsumer.cpp; sourceTree = "<group>"; };
> -               1A2A54A50FD1DD1C00F4CE45 /* ASTConsumers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTConsumers.cpp; path = lib/Frontend/ASTConsumers.cpp; sourceTree = "<group>"; };
> +               1A2A54A50FD1DD1C00F4CE45 /* ASTConsumers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = ASTConsumers.cpp; path = lib/Frontend/ASTConsumers.cpp; sourceTree = "<group>"; tabWidth = 2; };
>                1A2A54A60FD1DD1C00F4CE45 /* Backend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Backend.cpp; path = lib/Frontend/Backend.cpp; sourceTree = "<group>"; };
>                1A2A54A70FD1DD1C00F4CE45 /* CacheTokens.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CacheTokens.cpp; path = lib/Frontend/CacheTokens.cpp; sourceTree = "<group>"; };
>                1A2A54A80FD1DD1C00F4CE45 /* DependencyFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DependencyFile.cpp; path = lib/Frontend/DependencyFile.cpp; sourceTree = "<group>"; };
>
> Modified: cfe/trunk/include/clang/Frontend/ASTConsumers.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTConsumers.h?rev=82703&r1=82702&r2=82703&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/ASTConsumers.h (original)
> +++ cfe/trunk/include/clang/Frontend/ASTConsumers.h Thu Sep 24 13:54:49 2009
> @@ -57,6 +57,10 @@
>  // to stderr; this is intended for debugging.
>  ASTConsumer *CreateDeclContextPrinter();
>
> +// RecordLayout dumper: prints out the record layout information for all records
> +// in the translation unit; this is intended for debugging.
> +ASTConsumer *CreateRecordLayoutDumper();
> +
>  // ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code.
>  // This is considered experimental, and only works with Apple's ObjC runtime.
>  ASTConsumer *CreateObjCRewriter(const std::string &InFile,
>
> Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=82703&r1=82702&r2=82703&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
> +++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Thu Sep 24 13:54:49 2009
> @@ -20,6 +20,7 @@
>  #include "clang/AST/AST.h"
>  #include "clang/AST/ASTConsumer.h"
>  #include "clang/AST/ASTContext.h"
> +#include "clang/AST/RecordLayout.h"
>  #include "clang/AST/PrettyPrinter.h"
>  #include "clang/CodeGen/ModuleBuilder.h"
>  #include "llvm/Module.h"
> @@ -419,6 +420,55 @@
>  }
>
>  //===----------------------------------------------------------------------===//
> +/// RecordLayoutDumper - C++ Record Layout Dumping.
> +namespace {
> +class RecordLayoutDumper : public ASTConsumer {
> +  llvm::raw_ostream& Out;
> +
> +  // FIXME: Maybe this be useful in ASTContext.cpp.
> +  void DumpRecordLayout(const CXXRecordDecl *RD, ASTContext &C) {
> +    const ASTRecordLayout &Info = C.getASTRecordLayout(RD);
> +
> +    Out << RD->getKindName() << ' ' << RD->getQualifiedNameAsString() << '\n';
> +    Out << "  sizeof=" << Info.getSize() / 8;
> +    Out << ", dsize=" << Info.getDataSize() / 8;
> +    Out << ", align=" << Info.getAlignment() / 8 << '\n';
> +    Out << "  nvsize=" << Info.getNonVirtualSize() / 8;
> +    Out << ", nvalign=" << Info.getNonVirtualAlign() / 8 << '\n';
> +    Out << '\n';
> +  }

I think this should just be a .dump() on ASTRecordLayout, which is the
FIXME I presume.

 - Daniel




More information about the cfe-commits mailing list