diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-08-24 13:51:09 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-08-24 13:51:09 +0000 |
commit | 898e66bf5e75fd71c358aa13b88d90ac5b5213bd (patch) | |
tree | 43b6e6640258acc74c56b962ed43f16ee02b2955 /include/clang/Basic | |
parent | 5cce8b32d1e5c32a60afc262c88dbecacf3986cc (diff) |
[refactor] Add the AST source selection component
This commit adds the base AST source selection component to the refactoring
library. AST selection is represented using a tree of SelectedASTNode values.
Each selected node gets its own selection kind, which can actually be None even
in the middle of tree (e.g. statement in a macro whose child is in a macro
argument). The initial version constructs a "raw" selection tree, without
applying filters and canonicalisation operations to the nodes.
Differential Revision: https://reviews.llvm.org/D35012
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/SourceLocation.h | 5 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index 6afec33445..991cb78695 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -172,6 +172,11 @@ public: return getFromRawEncoding((unsigned)(uintptr_t)Encoding); } + static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End) { + return Start.isValid() && Start.isFileID() && End.isValid() && + End.isFileID(); + } + void print(raw_ostream &OS, const SourceManager &SM) const; std::string printToString(const SourceManager &SM) const; void dump(const SourceManager &SM) const; diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index ed3f8dfa86..40eb1c9f6c 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -1520,6 +1520,14 @@ public: return LHSLoaded; } + /// Return true if the Point is within Start and End. + bool isPointWithin(SourceLocation Location, SourceLocation Start, + SourceLocation End) const { + return Location == Start || Location == End || + (isBeforeInTranslationUnit(Start, Location) && + isBeforeInTranslationUnit(Location, End)); + } + // Iterators over FileInfos. typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*> ::const_iterator fileinfo_iterator; |