blob: 318c05fe7ca9628d2cf121390c7d01e71311779b [file] [log] [blame]
Douglas Gregore4e5b052009-03-19 00:18:19 +00001//===--- NestedNameSpecifier.cpp - C++ nested name specifiers -----*- 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 file defines the NestedNameSpecifier class, which represents
11// a C++ nested-name-specifier.
12//
13//===----------------------------------------------------------------------===//
14#include "clang/AST/NestedNameSpecifier.h"
15#include "clang/AST/ASTContext.h"
16#include "clang/AST/Decl.h"
17#include "clang/AST/Type.h"
18using namespace clang;
19
20DeclContext *
21NestedNameSpecifier::computeDeclContext(ASTContext &Context) const {
22 // The simple case: we're storing a DeclContext
23 if ((Data & 0x01) == 0)
24 return reinterpret_cast<DeclContext *>(Data);
25
26 Type *T = getAsType();
27 if (!T)
28 return 0;
29
30 // Retrieve the DeclContext associated with this type.
31 const TagType *TagT = T->getAsTagType();
32 assert(TagT && "No DeclContext from a non-tag type");
33 return TagT->getDecl();
34}