Decl.cpp (200583) | Decl.cpp (201361) |
---|---|
1//===--- Decl.cpp - Declaration AST Node Implementation -------------------===// 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//===----------------------------------------------------------------------===// --- 5 unchanged lines hidden (view full) --- 14#include "clang/AST/Decl.h" 15#include "clang/AST/DeclCXX.h" 16#include "clang/AST/DeclObjC.h" 17#include "clang/AST/DeclTemplate.h" 18#include "clang/AST/ASTContext.h" 19#include "clang/AST/TypeLoc.h" 20#include "clang/AST/Stmt.h" 21#include "clang/AST/Expr.h" | 1//===--- Decl.cpp - Declaration AST Node Implementation -------------------===// 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//===----------------------------------------------------------------------===// --- 5 unchanged lines hidden (view full) --- 14#include "clang/AST/Decl.h" 15#include "clang/AST/DeclCXX.h" 16#include "clang/AST/DeclObjC.h" 17#include "clang/AST/DeclTemplate.h" 18#include "clang/AST/ASTContext.h" 19#include "clang/AST/TypeLoc.h" 20#include "clang/AST/Stmt.h" 21#include "clang/AST/Expr.h" |
22#include "clang/AST/ExprCXX.h" |
|
22#include "clang/AST/PrettyPrinter.h" 23#include "clang/Basic/Builtins.h" 24#include "clang/Basic/IdentifierTable.h" 25#include "clang/Parse/DeclSpec.h" 26#include "llvm/Support/ErrorHandling.h" 27#include <vector> 28 29using namespace clang; --- 56 unchanged lines hidden (view full) --- 86 87ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC, 88 SourceLocation L, IdentifierInfo *Id, 89 QualType T, TypeSourceInfo *TInfo, 90 StorageClass S, Expr *DefArg) { 91 return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, TInfo, S, DefArg); 92} 93 | 23#include "clang/AST/PrettyPrinter.h" 24#include "clang/Basic/Builtins.h" 25#include "clang/Basic/IdentifierTable.h" 26#include "clang/Parse/DeclSpec.h" 27#include "llvm/Support/ErrorHandling.h" 28#include <vector> 29 30using namespace clang; --- 56 unchanged lines hidden (view full) --- 87 88ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC, 89 SourceLocation L, IdentifierInfo *Id, 90 QualType T, TypeSourceInfo *TInfo, 91 StorageClass S, Expr *DefArg) { 92 return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, TInfo, S, DefArg); 93} 94 |
95Expr *ParmVarDecl::getDefaultArg() { 96 assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!"); 97 assert(!hasUninstantiatedDefaultArg() && 98 "Default argument is not yet instantiated!"); 99 100 Expr *Arg = getInit(); 101 if (CXXExprWithTemporaries *E = dyn_cast_or_null<CXXExprWithTemporaries>(Arg)) 102 return E->getSubExpr(); 103 104 return Arg; 105} 106 107unsigned ParmVarDecl::getNumDefaultArgTemporaries() const { 108 if (const CXXExprWithTemporaries *E = 109 dyn_cast<CXXExprWithTemporaries>(getInit())) 110 return E->getNumTemporaries(); 111 112 return 0; 113} 114 115CXXTemporary *ParmVarDecl::getDefaultArgTemporary(unsigned i) { 116 assert(getNumDefaultArgTemporaries() && 117 "Default arguments does not have any temporaries!"); 118 119 CXXExprWithTemporaries *E = cast<CXXExprWithTemporaries>(getInit()); 120 return E->getTemporary(i); 121} 122 |
|
94SourceRange ParmVarDecl::getDefaultArgRange() const { 95 if (const Expr *E = getInit()) 96 return E->getSourceRange(); 97 98 if (hasUninstantiatedDefaultArg()) 99 return getUninstantiatedDefaultArg()->getSourceRange(); 100 101 return SourceRange(); --- 76 unchanged lines hidden (view full) --- 178} 179 180TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, 181 SourceLocation L, IdentifierInfo *Id, 182 TypeSourceInfo *TInfo) { 183 return new (C) TypedefDecl(DC, L, Id, TInfo); 184} 185 | 123SourceRange ParmVarDecl::getDefaultArgRange() const { 124 if (const Expr *E = getInit()) 125 return E->getSourceRange(); 126 127 if (hasUninstantiatedDefaultArg()) 128 return getUninstantiatedDefaultArg()->getSourceRange(); 129 130 return SourceRange(); --- 76 unchanged lines hidden (view full) --- 207} 208 209TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, 210 SourceLocation L, IdentifierInfo *Id, 211 TypeSourceInfo *TInfo) { 212 return new (C) TypedefDecl(DC, L, Id, TInfo); 213} 214 |
215// Anchor TypedefDecl's vtable here. 216TypedefDecl::~TypedefDecl() {} 217 |
|
186EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, 187 IdentifierInfo *Id, SourceLocation TKL, 188 EnumDecl *PrevDecl) { 189 EnumDecl *Enum = new (C) EnumDecl(DC, L, Id, PrevDecl, TKL); 190 C.getTypeDeclType(Enum, PrevDecl); 191 return Enum; 192} 193 --- 227 unchanged lines hidden (view full) --- 421 std::vector<std::string> Names; 422 std::string QualName; 423 const DeclContext *Ctx = getDeclContext(); 424 425 if (Ctx->isFunctionOrMethod()) 426 return getNameAsString(); 427 428 while (Ctx) { | 218EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, 219 IdentifierInfo *Id, SourceLocation TKL, 220 EnumDecl *PrevDecl) { 221 EnumDecl *Enum = new (C) EnumDecl(DC, L, Id, PrevDecl, TKL); 222 C.getTypeDeclType(Enum, PrevDecl); 223 return Enum; 224} 225 --- 227 unchanged lines hidden (view full) --- 453 std::vector<std::string> Names; 454 std::string QualName; 455 const DeclContext *Ctx = getDeclContext(); 456 457 if (Ctx->isFunctionOrMethod()) 458 return getNameAsString(); 459 460 while (Ctx) { |
429 if (Ctx->isFunctionOrMethod()) 430 // FIXME: That probably will happen, when D was member of local 431 // scope class/struct/union. How do we handle this case? 432 break; 433 | |
434 if (const ClassTemplateSpecializationDecl *Spec 435 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) { 436 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs(); 437 std::string TemplateArgsStr 438 = TemplateSpecializationType::PrintTemplateArgumentList( 439 TemplateArgs.getFlatArgumentList(), 440 TemplateArgs.flat_size(), 441 P); 442 Names.push_back(Spec->getIdentifier()->getNameStart() + TemplateArgsStr); | 461 if (const ClassTemplateSpecializationDecl *Spec 462 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) { 463 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs(); 464 std::string TemplateArgsStr 465 = TemplateSpecializationType::PrintTemplateArgumentList( 466 TemplateArgs.getFlatArgumentList(), 467 TemplateArgs.flat_size(), 468 P); 469 Names.push_back(Spec->getIdentifier()->getNameStart() + TemplateArgsStr); |
470 } else if (const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(Ctx)) { 471 if (ND->isAnonymousNamespace()) 472 Names.push_back("<anonymous namespace>"); 473 else 474 Names.push_back(ND->getNameAsString()); 475 } else if (const RecordDecl *RD = dyn_cast<RecordDecl>(Ctx)) { 476 if (!RD->getIdentifier()) { 477 std::string RecordString = "<anonymous "; 478 RecordString += RD->getKindName(); 479 RecordString += ">"; 480 Names.push_back(RecordString); 481 } else { 482 Names.push_back(RD->getNameAsString()); 483 } 484 } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Ctx)) { 485 std::string Proto = FD->getNameAsString(); 486 487 const FunctionProtoType *FT = 0; 488 if (FD->hasWrittenPrototype()) 489 FT = dyn_cast<FunctionProtoType>(FD->getType()->getAs<FunctionType>()); 490 491 Proto += "("; 492 if (FT) { 493 llvm::raw_string_ostream POut(Proto); 494 unsigned NumParams = FD->getNumParams(); 495 for (unsigned i = 0; i < NumParams; ++i) { 496 if (i) 497 POut << ", "; 498 std::string Param; 499 FD->getParamDecl(i)->getType().getAsStringInternal(Param, P); 500 POut << Param; 501 } 502 503 if (FT->isVariadic()) { 504 if (NumParams > 0) 505 POut << ", "; 506 POut << "..."; 507 } 508 } 509 Proto += ")"; 510 511 Names.push_back(Proto); |
|
443 } else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx)) 444 Names.push_back(ND->getNameAsString()); 445 else 446 break; 447 448 Ctx = Ctx->getParent(); 449 } 450 --- 850 unchanged lines hidden --- | 512 } else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx)) 513 Names.push_back(ND->getNameAsString()); 514 else 515 break; 516 517 Ctx = Ctx->getParent(); 518 } 519 --- 850 unchanged lines hidden --- |