~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to clang/lib/AST/ASTContext.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
406
406
  
407
407
}
408
408
 
 
409
comments::FullComment *ASTContext::getLocalCommentForDeclUncached(const Decl *D) const {
 
410
  const RawComment *RC = getRawCommentForDeclNoCache(D);
 
411
  return RC ? RC->parse(*this, 0, D) : 0;
 
412
}
 
413
 
409
414
comments::FullComment *ASTContext::getCommentForDecl(
410
415
                                              const Decl *D,
411
416
                                              const Preprocessor *PP) const {
 
417
  if (D->isInvalidDecl())
 
418
    return NULL;
412
419
  D = adjustDeclToTemplate(D);
413
420
  
414
421
  const Decl *Canonical = D->getCanonicalDecl();
442
449
        if (comments::FullComment *FC = getCommentForDecl(Overridden[i], PP))
443
450
          return cloneFullComment(FC, D);
444
451
    }
445
 
    else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
 
452
    else if (const TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
446
453
      // Attach any tag type's documentation to its typedef if latter
447
454
      // does not have one of its own.
448
455
      QualType QT = TD->getUnderlyingType();
451
458
          if (comments::FullComment *FC = getCommentForDecl(TD, PP))
452
459
            return cloneFullComment(FC, D);
453
460
    }
 
461
    else if (const ObjCInterfaceDecl *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
 
462
      while (IC->getSuperClass()) {
 
463
        IC = IC->getSuperClass();
 
464
        if (comments::FullComment *FC = getCommentForDecl(IC, PP))
 
465
          return cloneFullComment(FC, D);
 
466
      }
 
467
    }
 
468
    else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(D)) {
 
469
      if (const ObjCInterfaceDecl *IC = CD->getClassInterface())
 
470
        if (comments::FullComment *FC = getCommentForDecl(IC, PP))
 
471
          return cloneFullComment(FC, D);
 
472
    }
 
473
    else if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
 
474
      if (!(RD = RD->getDefinition()))
 
475
        return NULL;
 
476
      // Check non-virtual bases.
 
477
      for (CXXRecordDecl::base_class_const_iterator I =
 
478
           RD->bases_begin(), E = RD->bases_end(); I != E; ++I) {
 
479
        if (I->isVirtual() || (I->getAccessSpecifier() != AS_public))
 
480
          continue;
 
481
        QualType Ty = I->getType();
 
482
        if (Ty.isNull())
 
483
          continue;
 
484
        if (const CXXRecordDecl *NonVirtualBase = Ty->getAsCXXRecordDecl()) {
 
485
          if (!(NonVirtualBase= NonVirtualBase->getDefinition()))
 
486
            continue;
 
487
        
 
488
          if (comments::FullComment *FC = getCommentForDecl((NonVirtualBase), PP))
 
489
            return cloneFullComment(FC, D);
 
490
        }
 
491
      }
 
492
      // Check virtual bases.
 
493
      for (CXXRecordDecl::base_class_const_iterator I =
 
494
           RD->vbases_begin(), E = RD->vbases_end(); I != E; ++I) {
 
495
        if (I->getAccessSpecifier() != AS_public)
 
496
          continue;
 
497
        QualType Ty = I->getType();
 
498
        if (Ty.isNull())
 
499
          continue;
 
500
        if (const CXXRecordDecl *VirtualBase = Ty->getAsCXXRecordDecl()) {
 
501
          if (!(VirtualBase= VirtualBase->getDefinition()))
 
502
            continue;
 
503
          if (comments::FullComment *FC = getCommentForDecl((VirtualBase), PP))
 
504
            return cloneFullComment(FC, D);
 
505
        }
 
506
      }
 
507
    }
454
508
    return NULL;
455
509
  }
456
510
  
850
904
  InitBuiltinType(Int128Ty,            BuiltinType::Int128);
851
905
  InitBuiltinType(UnsignedInt128Ty,    BuiltinType::UInt128);
852
906
 
853
 
  if (LangOpts.CPlusPlus && LangOpts.WChar) { // C++ 3.9.1p5
854
 
    if (TargetInfo::isTypeSigned(Target.getWCharType()))
855
 
      InitBuiltinType(WCharTy,           BuiltinType::WChar_S);
856
 
    else  // -fshort-wchar makes wchar_t be unsigned.
857
 
      InitBuiltinType(WCharTy,           BuiltinType::WChar_U);
858
 
  } else // C99 (or C++ using -fno-wchar)
859
 
    WCharTy = getFromTargetType(Target.getWCharType());
 
907
  // C++ 3.9.1p5
 
908
  if (TargetInfo::isTypeSigned(Target.getWCharType()))
 
909
    InitBuiltinType(WCharTy,           BuiltinType::WChar_S);
 
910
  else  // -fshort-wchar makes wchar_t be unsigned.
 
911
    InitBuiltinType(WCharTy,           BuiltinType::WChar_U);
 
912
  if (LangOpts.CPlusPlus && LangOpts.WChar)
 
913
    WideCharTy = WCharTy;
 
914
  else {
 
915
    // C99 (or C++ using -fno-wchar).
 
916
    WideCharTy = getFromTargetType(Target.getWCharType());
 
917
  }
860
918
 
861
919
  WIntTy = getFromTargetType(Target.getWIntType());
862
920
 
1236
1294
        T = getBaseElementType(arrayType);
1237
1295
      }
1238
1296
      Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
 
1297
      if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
 
1298
        if (VD->hasGlobalStorage())
 
1299
          Align = std::max(Align, getTargetInfo().getMinGlobalAlign());
 
1300
      }
1239
1301
    }
1240
1302
 
1241
1303
    // Fields can be subject to extra alignment constraints, like if
1288
1350
  return sizeAndAlign;
1289
1351
}
1290
1352
 
 
1353
/// getConstantArrayInfoInChars - Performing the computation in CharUnits
 
1354
/// instead of in bits prevents overflowing the uint64_t for some large arrays.
 
1355
std::pair<CharUnits, CharUnits>
 
1356
static getConstantArrayInfoInChars(const ASTContext &Context,
 
1357
                                   const ConstantArrayType *CAT) {
 
1358
  std::pair<CharUnits, CharUnits> EltInfo =
 
1359
      Context.getTypeInfoInChars(CAT->getElementType());
 
1360
  uint64_t Size = CAT->getSize().getZExtValue();
 
1361
  assert((Size == 0 || static_cast<uint64_t>(EltInfo.first.getQuantity()) <=
 
1362
              (uint64_t)(-1)/Size) &&
 
1363
         "Overflow in array type char size evaluation");
 
1364
  uint64_t Width = EltInfo.first.getQuantity() * Size;
 
1365
  unsigned Align = EltInfo.second.getQuantity();
 
1366
  Width = llvm::RoundUpToAlignment(Width, Align);
 
1367
  return std::make_pair(CharUnits::fromQuantity(Width),
 
1368
                        CharUnits::fromQuantity(Align));
 
1369
}
 
1370
 
1291
1371
std::pair<CharUnits, CharUnits>
1292
1372
ASTContext::getTypeInfoInChars(const Type *T) const {
 
1373
  if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(T))
 
1374
    return getConstantArrayInfoInChars(*this, CAT);
1293
1375
  std::pair<uint64_t, unsigned> Info = getTypeInfo(T);
1294
1376
  return std::make_pair(toCharUnitsFromBits(Info.first),
1295
1377
                        toCharUnitsFromBits(Info.second));
1550
1632
 
1551
1633
  case Type::Auto: {
1552
1634
    const AutoType *A = cast<AutoType>(T);
1553
 
    assert(A->isDeduced() && "Cannot request the size of a dependent type");
 
1635
    assert(!A->getDeducedType().isNull() &&
 
1636
           "cannot request the size of an undeduced or dependent auto type");
1554
1637
    return getTypeInfo(A->getDeducedType().getTypePtr());
1555
1638
  }
1556
1639
 
1644
1727
/// getTypeSizeInChars - Return the size of the specified type, in characters.
1645
1728
/// This method does not work on incomplete types.
1646
1729
CharUnits ASTContext::getTypeSizeInChars(QualType T) const {
1647
 
  return toCharUnitsFromBits(getTypeSize(T));
 
1730
  return getTypeInfoInChars(T).first;
1648
1731
}
1649
1732
CharUnits ASTContext::getTypeSizeInChars(const Type *T) const {
1650
 
  return toCharUnitsFromBits(getTypeSize(T));
 
1733
  return getTypeInfoInChars(T).first;
1651
1734
}
1652
1735
 
1653
1736
/// getTypeAlignInChars - Return the ABI-specified alignment of a type, in 
1677
1760
  return ABIAlign;
1678
1761
}
1679
1762
 
 
1763
/// getAlignOfGlobalVar - Return the alignment in bits that should be given
 
1764
/// to a global variable of the specified type.
 
1765
unsigned ASTContext::getAlignOfGlobalVar(QualType T) const {
 
1766
  return std::max(getTypeAlign(T), getTargetInfo().getMinGlobalAlign());
 
1767
}
 
1768
 
 
1769
/// getAlignOfGlobalVarInChars - Return the alignment in characters that
 
1770
/// should be given to a global variable of the specified type.
 
1771
CharUnits ASTContext::getAlignOfGlobalVarInChars(QualType T) const {
 
1772
  return toCharUnitsFromBits(getAlignOfGlobalVar(T));
 
1773
}
 
1774
 
1680
1775
/// DeepCollectObjCIvars -
1681
1776
/// This routine first collects all declared, but not synthesized, ivars in
1682
1777
/// super class and then collects all ivars, including those synthesized for
1987
2082
  return cast<FunctionType>(Result.getTypePtr());
1988
2083
}
1989
2084
 
 
2085
void ASTContext::adjustDeducedFunctionResultType(FunctionDecl *FD,
 
2086
                                                 QualType ResultType) {
 
2087
  FD = FD->getMostRecentDecl();
 
2088
  while (true) {
 
2089
    const FunctionProtoType *FPT = FD->getType()->castAs<FunctionProtoType>();
 
2090
    FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
 
2091
    FD->setType(getFunctionType(ResultType, FPT->getArgTypes(), EPI));
 
2092
    if (FunctionDecl *Next = FD->getPreviousDecl())
 
2093
      FD = Next;
 
2094
    else
 
2095
      break;
 
2096
  }
 
2097
  if (ASTMutationListener *L = getASTMutationListener())
 
2098
    L->DeducedReturnType(FD, ResultType);
 
2099
}
 
2100
 
1990
2101
/// getComplexType - Return the uniqued reference to the type for a complex
1991
2102
/// number with the specified element type.
1992
2103
QualType ASTContext::getComplexType(QualType T) const {
3515
3626
  return QualType(Ty, 0);
3516
3627
}
3517
3628
 
3518
 
/// getAutoType - We only unique auto types after they've been deduced.
3519
 
QualType ASTContext::getAutoType(QualType DeducedType) const {
 
3629
/// getAutoType - Return the uniqued reference to the 'auto' type which has been
 
3630
/// deduced to the given type, or to the canonical undeduced 'auto' type, or the
 
3631
/// canonical deduced-but-dependent 'auto' type.
 
3632
QualType ASTContext::getAutoType(QualType DeducedType, bool IsDecltypeAuto,
 
3633
                                 bool IsDependent) const {
 
3634
  if (DeducedType.isNull() && !IsDecltypeAuto && !IsDependent)
 
3635
    return getAutoDeductType();
 
3636
 
 
3637
  // Look in the folding set for an existing type.
3520
3638
  void *InsertPos = 0;
3521
 
  if (!DeducedType.isNull()) {
3522
 
    // Look in the folding set for an existing type.
3523
 
    llvm::FoldingSetNodeID ID;
3524
 
    AutoType::Profile(ID, DeducedType);
3525
 
    if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos))
3526
 
      return QualType(AT, 0);
3527
 
  }
 
3639
  llvm::FoldingSetNodeID ID;
 
3640
  AutoType::Profile(ID, DeducedType, IsDecltypeAuto, IsDependent);
 
3641
  if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos))
 
3642
    return QualType(AT, 0);
3528
3643
 
3529
 
  AutoType *AT = new (*this, TypeAlignment) AutoType(DeducedType);
 
3644
  AutoType *AT = new (*this, TypeAlignment) AutoType(DeducedType,
 
3645
                                                     IsDecltypeAuto,
 
3646
                                                     IsDependent);
3530
3647
  Types.push_back(AT);
3531
3648
  if (InsertPos)
3532
3649
    AutoTypes.InsertNode(AT, InsertPos);
3564
3681
/// getAutoDeductType - Get type pattern for deducing against 'auto'.
3565
3682
QualType ASTContext::getAutoDeductType() const {
3566
3683
  if (AutoDeductTy.isNull())
3567
 
    AutoDeductTy = getAutoType(QualType());
3568
 
  assert(!AutoDeductTy.isNull() && "can't build 'auto' pattern");
 
3684
    AutoDeductTy = QualType(
 
3685
      new (*this, TypeAlignment) AutoType(QualType(), /*decltype(auto)*/false,
 
3686
                                          /*dependent*/false),
 
3687
      0);
3569
3688
  return AutoDeductTy;
3570
3689
}
3571
3690
 
4195
4314
  if (E->isTypeDependent() || E->isValueDependent())
4196
4315
    return QualType();
4197
4316
  
4198
 
  FieldDecl *Field = E->getBitField();
 
4317
  FieldDecl *Field = E->getSourceBitField(); // FIXME: conditional bit-fields?
4199
4318
  if (!Field)
4200
4319
    return QualType();
4201
4320
 
4828
4947
 
4829
4948
  if (PD->isReadOnly()) {
4830
4949
    S += ",R";
 
4950
    if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy)
 
4951
      S += ",C";
 
4952
    if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain)
 
4953
      S += ",&";
4831
4954
  } else {
4832
4955
    switch (PD->getSetterKind()) {
4833
4956
    case ObjCPropertyDecl::Assign: break;
5338
5461
    // FIXME. We should do a better job than gcc.
5339
5462
    return;
5340
5463
 
 
5464
  case Type::Auto:
 
5465
    // We could see an undeduced auto type here during error recovery.
 
5466
    // Just ignore it.
 
5467
    return;
 
5468
 
5341
5469
#define ABSTRACT_TYPE(KIND, BASE)
5342
5470
#define TYPE(KIND, BASE)
5343
5471
#define DEPENDENT_TYPE(KIND, BASE) \
5893
6021
  return VaListTypeDecl;
5894
6022
}
5895
6023
 
 
6024
static TypedefDecl *
 
6025
CreateSystemZBuiltinVaListDecl(const ASTContext *Context) {
 
6026
  // typedef struct __va_list_tag {
 
6027
  RecordDecl *VaListTagDecl;
 
6028
  VaListTagDecl = CreateRecordDecl(*Context, TTK_Struct,
 
6029
                                   Context->getTranslationUnitDecl(),
 
6030
                                   &Context->Idents.get("__va_list_tag"));
 
6031
  VaListTagDecl->startDefinition();
 
6032
 
 
6033
  const size_t NumFields = 4;
 
6034
  QualType FieldTypes[NumFields];
 
6035
  const char *FieldNames[NumFields];
 
6036
 
 
6037
  //   long __gpr;
 
6038
  FieldTypes[0] = Context->LongTy;
 
6039
  FieldNames[0] = "__gpr";
 
6040
 
 
6041
  //   long __fpr;
 
6042
  FieldTypes[1] = Context->LongTy;
 
6043
  FieldNames[1] = "__fpr";
 
6044
 
 
6045
  //   void *__overflow_arg_area;
 
6046
  FieldTypes[2] = Context->getPointerType(Context->VoidTy);
 
6047
  FieldNames[2] = "__overflow_arg_area";
 
6048
 
 
6049
  //   void *__reg_save_area;
 
6050
  FieldTypes[3] = Context->getPointerType(Context->VoidTy);
 
6051
  FieldNames[3] = "__reg_save_area";
 
6052
 
 
6053
  // Create fields
 
6054
  for (unsigned i = 0; i < NumFields; ++i) {
 
6055
    FieldDecl *Field = FieldDecl::Create(const_cast<ASTContext &>(*Context),
 
6056
                                         VaListTagDecl,
 
6057
                                         SourceLocation(),
 
6058
                                         SourceLocation(),
 
6059
                                         &Context->Idents.get(FieldNames[i]),
 
6060
                                         FieldTypes[i], /*TInfo=*/0,
 
6061
                                         /*BitWidth=*/0,
 
6062
                                         /*Mutable=*/false,
 
6063
                                         ICIS_NoInit);
 
6064
    Field->setAccess(AS_public);
 
6065
    VaListTagDecl->addDecl(Field);
 
6066
  }
 
6067
  VaListTagDecl->completeDefinition();
 
6068
  QualType VaListTagType = Context->getRecordType(VaListTagDecl);
 
6069
  Context->VaListTagTy = VaListTagType;
 
6070
 
 
6071
  // } __va_list_tag;
 
6072
  TypedefDecl *VaListTagTypedefDecl
 
6073
    = TypedefDecl::Create(const_cast<ASTContext &>(*Context),
 
6074
                          Context->getTranslationUnitDecl(),
 
6075
                          SourceLocation(), SourceLocation(),
 
6076
                          &Context->Idents.get("__va_list_tag"),
 
6077
                          Context->getTrivialTypeSourceInfo(VaListTagType));
 
6078
  QualType VaListTagTypedefType =
 
6079
    Context->getTypedefType(VaListTagTypedefDecl);
 
6080
 
 
6081
  // typedef __va_list_tag __builtin_va_list[1];
 
6082
  llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
 
6083
  QualType VaListTagArrayType
 
6084
    = Context->getConstantArrayType(VaListTagTypedefType,
 
6085
                                      Size, ArrayType::Normal,0);
 
6086
  TypeSourceInfo *TInfo
 
6087
    = Context->getTrivialTypeSourceInfo(VaListTagArrayType);
 
6088
  TypedefDecl *VaListTypedefDecl
 
6089
    = TypedefDecl::Create(const_cast<ASTContext &>(*Context),
 
6090
                          Context->getTranslationUnitDecl(),
 
6091
                          SourceLocation(), SourceLocation(),
 
6092
                          &Context->Idents.get("__builtin_va_list"),
 
6093
                          TInfo);
 
6094
 
 
6095
  return VaListTypedefDecl;
 
6096
}
 
6097
 
5896
6098
static TypedefDecl *CreateVaListDecl(const ASTContext *Context,
5897
6099
                                     TargetInfo::BuiltinVaListKind Kind) {
5898
6100
  switch (Kind) {
5910
6112
    return CreatePNaClABIBuiltinVaListDecl(Context);
5911
6113
  case TargetInfo::AAPCSABIBuiltinVaList:
5912
6114
    return CreateAAPCSABIBuiltinVaListDecl(Context);
 
6115
  case TargetInfo::SystemZBuiltinVaList:
 
6116
    return CreateSystemZBuiltinVaListDecl(Context);
5913
6117
  }
5914
6118
 
5915
6119
  llvm_unreachable("Unhandled __builtin_va_list type kind");
6979
7183
#include "clang/AST/TypeNodes.def"
6980
7184
    llvm_unreachable("Non-canonical and dependent types shouldn't get here");
6981
7185
 
 
7186
  case Type::Auto:
6982
7187
  case Type::LValueReference:
6983
7188
  case Type::RValueReference:
6984
7189
  case Type::MemberPointer:
7286
7491
 
7287
7492
ASTMutationListener::~ASTMutationListener() { }
7288
7493
 
 
7494
void ASTMutationListener::DeducedReturnType(const FunctionDecl *FD,
 
7495
                                            QualType ReturnType) {}
7289
7496
 
7290
7497
//===----------------------------------------------------------------------===//
7291
7498
//                          Builtin Type Computation
7587
7794
}
7588
7795
 
7589
7796
GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) {
 
7797
  if (!FD->isExternallyVisible())
 
7798
    return GVA_Internal;
 
7799
 
7590
7800
  GVALinkage External = GVA_StrongExternal;
7591
 
 
7592
 
  Linkage L = FD->getLinkage();
7593
 
  switch (L) {
7594
 
  case NoLinkage:
7595
 
  case InternalLinkage:
7596
 
  case UniqueExternalLinkage:
7597
 
    return GVA_Internal;
7598
 
    
7599
 
  case ExternalLinkage:
7600
 
    switch (FD->getTemplateSpecializationKind()) {
7601
 
    case TSK_Undeclared:
7602
 
    case TSK_ExplicitSpecialization:
7603
 
      External = GVA_StrongExternal;
7604
 
      break;
7605
 
 
7606
 
    case TSK_ExplicitInstantiationDefinition:
7607
 
      return GVA_ExplicitTemplateInstantiation;
7608
 
 
7609
 
    case TSK_ExplicitInstantiationDeclaration:
7610
 
    case TSK_ImplicitInstantiation:
7611
 
      External = GVA_TemplateInstantiation;
7612
 
      break;
7613
 
    }
 
7801
  switch (FD->getTemplateSpecializationKind()) {
 
7802
  case TSK_Undeclared:
 
7803
  case TSK_ExplicitSpecialization:
 
7804
    External = GVA_StrongExternal;
 
7805
    break;
 
7806
 
 
7807
  case TSK_ExplicitInstantiationDefinition:
 
7808
    return GVA_ExplicitTemplateInstantiation;
 
7809
 
 
7810
  case TSK_ExplicitInstantiationDeclaration:
 
7811
  case TSK_ImplicitInstantiation:
 
7812
    External = GVA_TemplateInstantiation;
 
7813
    break;
7614
7814
  }
7615
7815
 
7616
7816
  if (!FD->isInlined())
7640
7840
}
7641
7841
 
7642
7842
GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) {
 
7843
  if (!VD->isExternallyVisible())
 
7844
    return GVA_Internal;
 
7845
 
7643
7846
  // If this is a static data member, compute the kind of template
7644
7847
  // specialization. Otherwise, this variable is not part of a
7645
7848
  // template.
7647
7850
  if (VD->isStaticDataMember())
7648
7851
    TSK = VD->getTemplateSpecializationKind();
7649
7852
 
7650
 
  Linkage L = VD->getLinkage();
7651
 
 
7652
 
  switch (L) {
7653
 
  case NoLinkage:
7654
 
  case InternalLinkage:
7655
 
  case UniqueExternalLinkage:
7656
 
    return GVA_Internal;
7657
 
 
7658
 
  case ExternalLinkage:
7659
 
    switch (TSK) {
7660
 
    case TSK_Undeclared:
7661
 
    case TSK_ExplicitSpecialization:
7662
 
      return GVA_StrongExternal;
7663
 
 
7664
 
    case TSK_ExplicitInstantiationDeclaration:
7665
 
      llvm_unreachable("Variable should not be instantiated");
7666
 
      // Fall through to treat this like any other instantiation.
7667
 
        
7668
 
    case TSK_ExplicitInstantiationDefinition:
7669
 
      return GVA_ExplicitTemplateInstantiation;
7670
 
 
7671
 
    case TSK_ImplicitInstantiation:
7672
 
      return GVA_TemplateInstantiation;      
7673
 
    }
 
7853
  switch (TSK) {
 
7854
  case TSK_Undeclared:
 
7855
  case TSK_ExplicitSpecialization:
 
7856
    return GVA_StrongExternal;
 
7857
 
 
7858
  case TSK_ExplicitInstantiationDeclaration:
 
7859
    llvm_unreachable("Variable should not be instantiated");
 
7860
  // Fall through to treat this like any other instantiation.
 
7861
 
 
7862
  case TSK_ExplicitInstantiationDefinition:
 
7863
    return GVA_ExplicitTemplateInstantiation;
 
7864
 
 
7865
  case TSK_ImplicitInstantiation:
 
7866
    return GVA_TemplateInstantiation;
7674
7867
  }
7675
7868
 
7676
7869
  llvm_unreachable("Invalid Linkage!");
7806
7999
void ASTContext::addUnnamedTag(const TagDecl *Tag) {
7807
8000
  // FIXME: This mangling should be applied to function local classes too
7808
8001
  if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl() ||
7809
 
      !isa<CXXRecordDecl>(Tag->getParent()) || Tag->getLinkage() != ExternalLinkage)
 
8002
      !isa<CXXRecordDecl>(Tag->getParent()) ||
 
8003
      !Tag->isExternallyVisible())
7810
8004
    return;
7811
8005
 
7812
8006
  std::pair<llvm::DenseMap<const DeclContext *, unsigned>::iterator, bool> P =