2009-03-31 06:58:21 +08:00
|
|
|
//===--- TemplateName.h - C++ Template Name Representation-------*- 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 TemplateName interface and subclasses.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/AST/TemplateName.h"
|
|
|
|
#include "clang/AST/DeclTemplate.h"
|
|
|
|
#include "clang/AST/NestedNameSpecifier.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
TemplateDecl *TemplateName::getAsTemplateDecl() const {
|
|
|
|
if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>())
|
|
|
|
return Template;
|
|
|
|
|
|
|
|
if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
|
|
|
|
return QTN->getTemplateDecl();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TemplateName::isDependent() const {
|
|
|
|
if (TemplateDecl *Template = getAsTemplateDecl()) {
|
|
|
|
// FIXME: We don't yet have a notion of dependent
|
|
|
|
// declarations. When we do, check that. This hack won't last
|
|
|
|
// long!.
|
|
|
|
return isa<TemplateTemplateParmDecl>(Template);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-04-01 08:28:59 +08:00
|
|
|
void TemplateName::print(llvm::raw_ostream &OS, bool SuppressNNS) const {
|
2009-03-31 06:58:21 +08:00
|
|
|
if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>())
|
|
|
|
OS << Template->getIdentifier()->getName();
|
|
|
|
else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) {
|
2009-04-01 08:28:59 +08:00
|
|
|
if (!SuppressNNS)
|
|
|
|
QTN->getQualifier()->print(OS);
|
2009-03-31 06:58:21 +08:00
|
|
|
if (QTN->hasTemplateKeyword())
|
|
|
|
OS << "template ";
|
|
|
|
OS << QTN->getTemplateDecl()->getIdentifier()->getName();
|
|
|
|
} else if (DependentTemplateName *DTN = getAsDependentTemplateName()) {
|
2009-04-01 08:28:59 +08:00
|
|
|
if (!SuppressNNS)
|
|
|
|
DTN->getQualifier()->print(OS);
|
2009-03-31 06:58:21 +08:00
|
|
|
OS << "template ";
|
|
|
|
OS << DTN->getName()->getName();
|
|
|
|
}
|
|
|
|
}
|
2009-04-01 02:38:02 +08:00
|
|
|
|
2009-04-01 04:22:05 +08:00
|
|
|
void TemplateName::dump() const {
|
|
|
|
print(llvm::errs());
|
2009-04-01 02:38:02 +08:00
|
|
|
}
|