aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/NestedNameSpecifier.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-25 00:36:19 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-25 00:36:19 +0000
commitdc355713be51fcb4ee52d9fd6b4548ceff47fadf (patch)
treeeb1eee27bd2a2ddf32d520822adef83d7e982890 /lib/AST/NestedNameSpecifier.cpp
parent670d6ed9f058526af4c07724f7da50139e252a22 (diff)
Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the extremely-lossy NestedNameSpecifier/SourceRange pair it used to use, improving source-location information. Various infrastructure updates to support NestedNameSpecifierLoc: - AST/PCH (de-)serialization - Recursive AST visitor - libclang traversal (including the first tests of this functionality) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/NestedNameSpecifier.cpp')
-rw-r--r--lib/AST/NestedNameSpecifier.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index da12aa77dd..0689ae1c88 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -320,7 +320,7 @@ namespace {
}
}
-SourceRange NestedNameSpecifierLoc::getSourceRange() {
+SourceRange NestedNameSpecifierLoc::getSourceRange() const {
NestedNameSpecifierLoc First = *this;
while (NestedNameSpecifierLoc Prefix= First.getPrefix())
First = Prefix;
@@ -329,7 +329,7 @@ SourceRange NestedNameSpecifierLoc::getSourceRange() {
getLocalSourceRange().getEnd());
}
-SourceRange NestedNameSpecifierLoc::getLocalSourceRange() {
+SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const {
unsigned Offset = getDataLength(Qualifier->getPrefix());
switch (Qualifier->getKind()) {
case NestedNameSpecifier::Global:
@@ -354,3 +354,14 @@ SourceRange NestedNameSpecifierLoc::getLocalSourceRange() {
return SourceRange();
}
+
+TypeLoc NestedNameSpecifierLoc::getTypeLoc() const {
+ assert((Qualifier->getKind() == NestedNameSpecifier::TypeSpec ||
+ Qualifier->getKind() == NestedNameSpecifier::TypeSpecWithTemplate) &&
+ "Nested-name-specifier location is not a type");
+
+ // The "void*" that points at the TypeLoc data.
+ unsigned Offset = getDataLength(Qualifier->getPrefix());
+ void *TypeData = LoadPointer(Data, Offset);
+ return TypeLoc(Qualifier->getAsType(), TypeData);
+}