aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/NestedNameSpecifier.cpp
blob: 318c05fe7ca9628d2cf121390c7d01e71311779b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//===--- NestedNameSpecifier.cpp - C++ nested name specifiers -----*- C++ -*-=//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the NestedNameSpecifier class, which represents
//  a C++ nested-name-specifier.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Type.h"
using namespace clang;

DeclContext *
NestedNameSpecifier::computeDeclContext(ASTContext &Context) const {
  // The simple case: we're storing a DeclContext
  if ((Data & 0x01) == 0)
    return reinterpret_cast<DeclContext *>(Data);

  Type *T = getAsType();
  if (!T)
    return 0;

  // Retrieve the DeclContext associated with this type.
  const TagType *TagT = T->getAsTagType();
  assert(TagT && "No DeclContext from a non-tag type");
  return TagT->getDecl();
}