MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / ValueType

Class ValueType

addons/cppcheckdata.py:162–220  ·  view source on GitHub ↗

ValueType class. Contains (promoted) type information for each node in the AST. Attributes: type nonstd/pod/record/smart-pointer/container/iterator/void/bool/char/short/wchar_t/int/long/long long/unknown int/float/double/long double sign signed/unsig

Source from the content-addressed store, hash-verified

160 )
161
162class ValueType:
163 """
164 ValueType class. Contains (promoted) type information for each node in the AST.
165
166 Attributes:
167 type nonstd/pod/record/smart-pointer/container/iterator/void/bool/char/short/wchar_t/int/long/long long/unknown int/float/double/long double
168 sign signed/unsigned
169 bits bit count for bit-fields, otherwise None
170 pointer
171 constness
172 reference
173 typeScopeId
174 originalTypeName bool/const char */long/char */size_t/int/double/std::string/..
175
176 """
177 #symboldatabase.cpp/ValueType::dump
178
179 type = None
180 sign = None
181 bits = None
182 constness = 0
183 pointer = 0
184 typeScopeId = None
185 typeScope = None
186 originalTypeName = None
187
188 def __init__(self, element):
189 self.type = element.get('valueType-type')
190 self.sign = element.get('valueType-sign')
191 self.bits = element.get('valueType-bits', None)
192 self.bits = int(self.bits) if self.bits else None
193 self.pointer = int(element.get('valueType-pointer', 0))
194 self.constness = int(element.get('valueType-constness', 0))
195 self.reference = element.get('valueType-reference')
196 self.typeScopeId = element.get('valueType-typeScope')
197 self.originalTypeName = element.get('valueType-originalTypeName')
198 #valueType-containerId TODO add
199
200
201 def __repr__(self):
202 attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName",
203 "constness", "pointer"]
204 return "{}({})".format(
205 "ValueType",
206 ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
207 )
208
209
210 def setId(self, IdMap):
211 self.typeScope = IdMap[self.typeScopeId]
212
213 def isIntegral(self):
214 return self.type in {'bool', 'char', 'short', 'int', 'long', 'long long'}
215
216 def isFloat(self):
217 return self.type in {'float', 'double', 'long double'}
218
219 def isEnum(self):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected