~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/TableGen/ClangASTNodesEmitter.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=== ClangASTNodesEmitter.cpp - Generate Clang AST node tables -*- C++ -*-===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// These tablegen backends emit Clang AST node tables
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#include "ClangASTNodesEmitter.h"
 
15
#include <set>
 
16
using namespace llvm;
 
17
 
 
18
//===----------------------------------------------------------------------===//
 
19
// Statement Node Tables (.inc file) generation.
 
20
//===----------------------------------------------------------------------===//
 
21
 
 
22
// Returns the first and last non-abstract subrecords
 
23
// Called recursively to ensure that nodes remain contiguous
 
24
std::pair<Record *, Record *> ClangASTNodesEmitter::EmitNode(
 
25
                                                           const ChildMap &Tree,
 
26
                                                           raw_ostream &OS,
 
27
                                                           Record *Base) {
 
28
  std::string BaseName = macroName(Base->getName());
 
29
 
 
30
  ChildIterator i = Tree.lower_bound(Base), e = Tree.upper_bound(Base);
 
31
 
 
32
  Record *First = 0, *Last = 0;
 
33
  // This might be the pseudo-node for Stmt; don't assume it has an Abstract
 
34
  // bit
 
35
  if (Base->getValue("Abstract") && !Base->getValueAsBit("Abstract"))
 
36
    First = Last = Base;
 
37
 
 
38
  for (; i != e; ++i) {
 
39
    Record *R = i->second;
 
40
    bool Abstract = R->getValueAsBit("Abstract");
 
41
    std::string NodeName = macroName(R->getName());
 
42
 
 
43
    OS << "#ifndef " << NodeName << "\n";
 
44
    OS << "#  define " << NodeName << "(Type, Base) "
 
45
        << BaseName << "(Type, Base)\n";
 
46
    OS << "#endif\n";
 
47
 
 
48
    if (Abstract)
 
49
      OS << "ABSTRACT_" << macroName(Root.getName()) << "(" << NodeName << "("
 
50
          << R->getName() << ", " << baseName(*Base) << "))\n";
 
51
    else
 
52
      OS << NodeName << "(" << R->getName() << ", "
 
53
          << baseName(*Base) << ")\n";
 
54
 
 
55
    if (Tree.find(R) != Tree.end()) {
 
56
      const std::pair<Record *, Record *> &Result
 
57
        = EmitNode(Tree, OS, R);
 
58
      if (!First && Result.first)
 
59
        First = Result.first;
 
60
      if (Result.second)
 
61
        Last = Result.second;
 
62
    } else {
 
63
      if (!Abstract) {
 
64
        Last = R;
 
65
 
 
66
        if (!First)
 
67
          First = R;
 
68
      }
 
69
    }
 
70
 
 
71
    OS << "#undef " << NodeName << "\n\n";
 
72
  }
 
73
 
 
74
  if (First) {
 
75
    assert (Last && "Got a first node but not a last node for a range!");
 
76
    if (Base == &Root)
 
77
      OS << "LAST_" << macroName(Root.getName()) << "_RANGE(";
 
78
    else
 
79
      OS << macroName(Root.getName()) << "_RANGE(";
 
80
    OS << Base->getName() << ", " << First->getName() << ", "
 
81
       << Last->getName() << ")\n\n";
 
82
  }
 
83
 
 
84
  return std::make_pair(First, Last);
 
85
}
 
86
 
 
87
void ClangASTNodesEmitter::run(raw_ostream &OS) {
 
88
  // Write the preamble
 
89
  OS << "#ifndef ABSTRACT_" << macroName(Root.getName()) << "\n";
 
90
  OS << "#  define ABSTRACT_" << macroName(Root.getName()) << "(Type) Type\n";
 
91
  OS << "#endif\n";
 
92
 
 
93
  OS << "#ifndef " << macroName(Root.getName()) << "_RANGE\n";
 
94
  OS << "#  define "
 
95
     << macroName(Root.getName()) << "_RANGE(Base, First, Last)\n";
 
96
  OS << "#endif\n\n";
 
97
 
 
98
  OS << "#ifndef LAST_" << macroName(Root.getName()) << "_RANGE\n";
 
99
  OS << "#  define LAST_" 
 
100
     << macroName(Root.getName()) << "_RANGE(Base, First, Last) " 
 
101
     << macroName(Root.getName()) << "_RANGE(Base, First, Last)\n";
 
102
  OS << "#endif\n\n";
 
103
 
 
104
  // Emit statements
 
105
  const std::vector<Record*> Stmts
 
106
    = Records.getAllDerivedDefinitions(Root.getName());
 
107
 
 
108
  ChildMap Tree;
 
109
 
 
110
  for (unsigned i = 0, e = Stmts.size(); i != e; ++i) {
 
111
    Record *R = Stmts[i];
 
112
 
 
113
    if (R->getValue("Base"))
 
114
      Tree.insert(std::make_pair(R->getValueAsDef("Base"), R));
 
115
    else
 
116
      Tree.insert(std::make_pair(&Root, R));
 
117
  }
 
118
 
 
119
  EmitNode(Tree, OS, &Root);
 
120
 
 
121
  OS << "#undef " << macroName(Root.getName()) << "\n";
 
122
  OS << "#undef " << macroName(Root.getName()) << "_RANGE\n";
 
123
  OS << "#undef LAST_" << macroName(Root.getName()) << "_RANGE\n";
 
124
  OS << "#undef ABSTRACT_" << macroName(Root.getName()) << "\n";
 
125
}
 
126
 
 
127
void ClangDeclContextEmitter::run(raw_ostream &OS) {
 
128
  // FIXME: Find a .td file format to allow for this to be represented better.
 
129
 
 
130
  OS << "#ifndef DECL_CONTEXT\n";
 
131
  OS << "#  define DECL_CONTEXT(DECL)\n";
 
132
  OS << "#endif\n";
 
133
  
 
134
  OS << "#ifndef DECL_CONTEXT_BASE\n";
 
135
  OS << "#  define DECL_CONTEXT_BASE(DECL) DECL_CONTEXT(DECL)\n";
 
136
  OS << "#endif\n";
 
137
  
 
138
  typedef std::set<Record*> RecordSet;
 
139
  typedef std::vector<Record*> RecordVector;
 
140
  
 
141
  RecordVector DeclContextsVector
 
142
    = Records.getAllDerivedDefinitions("DeclContext");
 
143
  RecordVector Decls = Records.getAllDerivedDefinitions("Decl");
 
144
  RecordSet DeclContexts (DeclContextsVector.begin(), DeclContextsVector.end());
 
145
   
 
146
  for (RecordVector::iterator i = Decls.begin(), e = Decls.end(); i != e; ++i) {
 
147
    Record *R = *i;
 
148
 
 
149
    if (R->getValue("Base")) {
 
150
      Record *B = R->getValueAsDef("Base");
 
151
      if (DeclContexts.find(B) != DeclContexts.end()) {
 
152
        OS << "DECL_CONTEXT_BASE(" << B->getName() << ")\n";
 
153
        DeclContexts.erase(B);
 
154
      }
 
155
    }
 
156
  }
 
157
 
 
158
  for (RecordSet::iterator i = DeclContexts.begin(), e = DeclContexts.end();
 
159
       i != e; ++i) {
 
160
    OS << "DECL_CONTEXT(" << (*i)->getName() << ")\n";
 
161
  }
 
162
 
 
163
  OS << "#undef DECL_CONTEXT\n";
 
164
  OS << "#undef DECL_CONTEXT_BASE\n";
 
165
}