flok99

Untitled

Dec 5th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. TypeLoc buildTypeLoc(ASTContext *const c, const QualType qt)
  2. {
  3.        TypeLocBuilder tlb;
  4.        return tlb.getTypeLocInContext(*c, qt);
  5. }
  6.  
  7. SourceRange getQualTypeSourceRange(ASTContext *const c, const QualType qt)
  8. {
  9.       return buildTypeLoc(c, qt).getSourceRange();
  10. }
  11.  
  12. for(clang::ASTUnit::top_level_iterator dit = au -> top_level_begin(); dit != au -> top_level_end(); dit++) {
  13.         if (isa<VarDecl>(*dit)) {
  14.                 const VarDecl *vd = static_cast<const VarDecl *>(*dit);
  15.  
  16.                 SourceRange sr = getQualTypeSourceRange(&au -> getASTContext(), vd -> getType());
  17.         }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment