/3rd_party/llvm/include/llvm/Analysis/FindUsedTypes.h

https://code.google.com/p/softart/ · C++ Header · 66 lines · 27 code · 13 blank · 26 comment · 0 complexity · 68ee5b2afad5e690653093f5e2123ddd MD5 · raw file

  1. //===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- 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. // This pass is used to seek out all of the types in use by the program.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
  14. #define LLVM_ANALYSIS_FINDUSEDTYPES_H
  15. #include "llvm/ADT/SetVector.h"
  16. #include "llvm/Pass.h"
  17. namespace llvm {
  18. class Type;
  19. class Value;
  20. class FindUsedTypes : public ModulePass {
  21. SetVector<Type *> UsedTypes;
  22. public:
  23. static char ID; // Pass identification, replacement for typeid
  24. FindUsedTypes() : ModulePass(ID) {
  25. initializeFindUsedTypesPass(*PassRegistry::getPassRegistry());
  26. }
  27. /// getTypes - After the pass has been run, return the set containing all of
  28. /// the types used in the module.
  29. ///
  30. const SetVector<Type *> &getTypes() const { return UsedTypes; }
  31. /// Print the types found in the module. If the optional Module parameter is
  32. /// passed in, then the types are printed symbolically if possible, using the
  33. /// symbol table from the module.
  34. ///
  35. void print(raw_ostream &o, const Module *M) const;
  36. private:
  37. /// IncorporateType - Incorporate one type and all of its subtypes into the
  38. /// collection of used types.
  39. ///
  40. void IncorporateType(Type *Ty);
  41. /// IncorporateValue - Incorporate all of the types used by this value.
  42. ///
  43. void IncorporateValue(const Value *V);
  44. public:
  45. /// run - This incorporates all types used by the specified module
  46. bool runOnModule(Module &M);
  47. /// getAnalysisUsage - We do not modify anything.
  48. virtual void getAnalysisUsage(AnalysisUsage &AU) const {
  49. AU.setPreservesAll();
  50. }
  51. };
  52. } // End llvm namespace
  53. #endif