clang  9.0.0svn
DynamicTypeInfo.h
Go to the documentation of this file.
1 //== DynamicTypeInfo.h - Runtime type information ----------------*- C++ -*--=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
9 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
10 
11 #include "clang/AST/Type.h"
12 
13 namespace clang {
14 namespace ento {
15 
16 /// Stores the currently inferred strictest bound on the runtime type
17 /// of a region in a given state along the analysis path.
19 private:
20  QualType T;
21  bool CanBeASubClass;
22 
23 public:
24 
26  DynamicTypeInfo(QualType WithType, bool CanBeSub = true)
27  : T(WithType), CanBeASubClass(CanBeSub) {}
28 
29  /// Return false if no dynamic type info is available.
30  bool isValid() const { return !T.isNull(); }
31 
32  /// Returns the currently inferred upper bound on the runtime type.
33  QualType getType() const { return T; }
34 
35  /// Returns false if the type information is precise (the type T is
36  /// the only type in the lattice), true otherwise.
37  bool canBeASubClass() const { return CanBeASubClass; }
38 
39  void Profile(llvm::FoldingSetNodeID &ID) const {
40  ID.Add(T);
41  ID.AddInteger((unsigned)CanBeASubClass);
42  }
43  bool operator==(const DynamicTypeInfo &X) const {
44  return T == X.T && CanBeASubClass == X.CanBeASubClass;
45  }
46 };
47 
48 } // end ento
49 } // end clang
50 
51 #endif
A (possibly-)qualified type.
Definition: Type.h:639
bool operator==(const DynamicTypeInfo &X) const
C Language Family Type Representation.
bool isValid() const
Return false if no dynamic type info is available.
DynamicTypeInfo(QualType WithType, bool CanBeSub=true)
QualType getType() const
Returns the currently inferred upper bound on the runtime type.
bool canBeASubClass() const
Returns false if the type information is precise (the type T is the only type in the lattice)...
Stores the currently inferred strictest bound on the runtime type of a region in a given state along ...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:704
Dataflow Directional Tag Classes.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:14015
void Profile(llvm::FoldingSetNodeID &ID) const