[llvm] r348505 - [PDB] Move some code around. NFC.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 09:49:15 PST 2018


Author: zturner
Date: Thu Dec  6 09:49:15 2018
New Revision: 348505

URL: http://llvm.org/viewvc/llvm-project?rev=348505&view=rev
Log:
[PDB] Move some code around.  NFC.

Added:
    llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
    llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
Modified:
    llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt

Added: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h?rev=348505&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h Thu Dec  6 09:49:15 2018
@@ -0,0 +1,57 @@
+//===- SymbolRecordHelpers.h ------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H
+#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H
+
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+
+namespace llvm {
+namespace codeview {
+/// Return true if this symbol opens a scope. This implies that the symbol has
+/// "parent" and "end" fields, which contain the offset of the S_END or
+/// S_INLINESITE_END record.
+inline bool symbolOpensScope(SymbolKind Kind) {
+  switch (Kind) {
+  case SymbolKind::S_GPROC32:
+  case SymbolKind::S_LPROC32:
+  case SymbolKind::S_LPROC32_ID:
+  case SymbolKind::S_GPROC32_ID:
+  case SymbolKind::S_BLOCK32:
+  case SymbolKind::S_SEPCODE:
+  case SymbolKind::S_THUNK32:
+  case SymbolKind::S_INLINESITE:
+  case SymbolKind::S_INLINESITE2:
+    return true;
+  default:
+    break;
+  }
+  return false;
+}
+
+/// Return true if this ssymbol ends a scope.
+inline bool symbolEndsScope(SymbolKind Kind) {
+  switch (Kind) {
+  case SymbolKind::S_END:
+  case SymbolKind::S_PROC_ID_END:
+  case SymbolKind::S_INLINESITE_END:
+    return true;
+  default:
+    break;
+  }
+  return false;
+}
+
+/// Given a symbol P for which symbolOpensScope(P) == true, return the
+/// corresponding end offset.
+uint32_t getScopeEndOffset(const CVSymbol &symbol);
+} // namespace codeview
+} // namespace llvm
+
+#endif

Modified: llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=348505&r1=348504&r2=348505&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt Thu Dec  6 09:49:15 2018
@@ -27,8 +27,9 @@ add_llvm_library(LLVMDebugInfoCodeView
   RecordSerialization.cpp
   SimpleTypeSerializer.cpp
   StringsAndChecksums.cpp
-  SymbolRecordMapping.cpp
   SymbolDumper.cpp
+  SymbolRecordHelpers.cpp
+  SymbolRecordMapping.cpp
   SymbolSerializer.cpp
   TypeDumpVisitor.cpp
   TypeIndex.cpp

Added: llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp?rev=348505&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp Thu Dec  6 09:49:15 2018
@@ -0,0 +1,53 @@
+//===- SymbolRecordHelpers.cpp ----------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+template <typename RecordT> RecordT createRecord(const CVSymbol &sym) {
+  RecordT record(static_cast<SymbolRecordKind>(sym.kind()));
+  cantFail(SymbolDeserializer::deserializeAs<RecordT>(sym, record));
+  return record;
+}
+
+uint32_t
+llvm::codeview::getScopeEndOffset(const llvm::codeview::CVSymbol &Sym) {
+  assert(symbolOpensScope(Sym.kind()));
+  switch (Sym.kind()) {
+  case SymbolKind::S_GPROC32:
+  case SymbolKind::S_LPROC32:
+  case SymbolKind::S_GPROC32_ID:
+  case SymbolKind::S_LPROC32_ID:
+  case SymbolKind::S_LPROC32_DPC:
+  case SymbolKind::S_LPROC32_DPC_ID: {
+    ProcSym Proc = createRecord<ProcSym>(Sym);
+    return Proc.End;
+  }
+  case SymbolKind::S_BLOCK32: {
+    BlockSym Block = createRecord<BlockSym>(Sym);
+    return Block.End;
+  }
+  case SymbolKind::S_THUNK32: {
+    Thunk32Sym Thunk = createRecord<Thunk32Sym>(Sym);
+    return Thunk.End;
+  }
+  case SymbolKind::S_INLINESITE: {
+    InlineSiteSym Site = createRecord<InlineSiteSym>(Sym);
+    return Site.End;
+  }
+  default:
+    assert(false && "Unknown record type");
+    return 0;
+  }
+}
\ No newline at end of file




More information about the llvm-commits mailing list