2012-12-18 22:30:41 +08:00
|
|
|
//===--- ASTCommon.cpp - Common stuff for ASTReader/ASTWriter----*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-12-18 22:30:41 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines common functions that both ASTReader and ASTWriter use.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ASTCommon.h"
|
2014-08-28 09:33:39 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2013-01-21 23:25:38 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2012-12-18 22:30:41 +08:00
|
|
|
#include "clang/Basic/IdentifierTable.h"
|
|
|
|
#include "clang/Serialization/ASTDeserializationListener.h"
|
2018-02-26 23:16:42 +08:00
|
|
|
#include "llvm/Support/DJB.h"
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
// Give ASTDeserializationListener's VTable a home.
|
2015-10-20 21:23:58 +08:00
|
|
|
ASTDeserializationListener::~ASTDeserializationListener() { }
|
2012-12-18 22:30:41 +08:00
|
|
|
|
|
|
|
serialization::TypeIdx
|
|
|
|
serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
|
|
|
|
unsigned ID = 0;
|
|
|
|
switch (BT->getKind()) {
|
2015-09-15 20:18:29 +08:00
|
|
|
case BuiltinType::Void:
|
|
|
|
ID = PREDEF_TYPE_VOID_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Bool:
|
|
|
|
ID = PREDEF_TYPE_BOOL_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Char_U:
|
|
|
|
ID = PREDEF_TYPE_CHAR_U_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UChar:
|
|
|
|
ID = PREDEF_TYPE_UCHAR_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UShort:
|
|
|
|
ID = PREDEF_TYPE_USHORT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UInt:
|
|
|
|
ID = PREDEF_TYPE_UINT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ULong:
|
|
|
|
ID = PREDEF_TYPE_ULONG_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ULongLong:
|
|
|
|
ID = PREDEF_TYPE_ULONGLONG_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UInt128:
|
|
|
|
ID = PREDEF_TYPE_UINT128_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Char_S:
|
|
|
|
ID = PREDEF_TYPE_CHAR_S_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SChar:
|
|
|
|
ID = PREDEF_TYPE_SCHAR_ID;
|
|
|
|
break;
|
2012-12-18 22:30:41 +08:00
|
|
|
case BuiltinType::WChar_S:
|
2015-09-15 20:18:29 +08:00
|
|
|
case BuiltinType::WChar_U:
|
|
|
|
ID = PREDEF_TYPE_WCHAR_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Short:
|
|
|
|
ID = PREDEF_TYPE_SHORT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Int:
|
|
|
|
ID = PREDEF_TYPE_INT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Long:
|
|
|
|
ID = PREDEF_TYPE_LONG_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::LongLong:
|
|
|
|
ID = PREDEF_TYPE_LONGLONG_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Int128:
|
|
|
|
ID = PREDEF_TYPE_INT128_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Half:
|
|
|
|
ID = PREDEF_TYPE_HALF_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Float:
|
|
|
|
ID = PREDEF_TYPE_FLOAT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Double:
|
|
|
|
ID = PREDEF_TYPE_DOUBLE_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::LongDouble:
|
|
|
|
ID = PREDEF_TYPE_LONGDOUBLE_ID;
|
|
|
|
break;
|
2018-06-05 00:07:52 +08:00
|
|
|
case BuiltinType::ShortAccum:
|
|
|
|
ID = PREDEF_TYPE_SHORT_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Accum:
|
|
|
|
ID = PREDEF_TYPE_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::LongAccum:
|
|
|
|
ID = PREDEF_TYPE_LONG_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UShortAccum:
|
|
|
|
ID = PREDEF_TYPE_USHORT_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UAccum:
|
|
|
|
ID = PREDEF_TYPE_UACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ULongAccum:
|
|
|
|
ID = PREDEF_TYPE_ULONG_ACCUM_ID;
|
|
|
|
break;
|
2018-06-14 22:53:51 +08:00
|
|
|
case BuiltinType::ShortFract:
|
|
|
|
ID = PREDEF_TYPE_SHORT_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Fract:
|
|
|
|
ID = PREDEF_TYPE_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::LongFract:
|
|
|
|
ID = PREDEF_TYPE_LONG_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UShortFract:
|
|
|
|
ID = PREDEF_TYPE_USHORT_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UFract:
|
|
|
|
ID = PREDEF_TYPE_UFRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ULongFract:
|
|
|
|
ID = PREDEF_TYPE_ULONG_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatShortAccum:
|
|
|
|
ID = PREDEF_TYPE_SAT_SHORT_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatAccum:
|
|
|
|
ID = PREDEF_TYPE_SAT_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatLongAccum:
|
|
|
|
ID = PREDEF_TYPE_SAT_LONG_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatUShortAccum:
|
|
|
|
ID = PREDEF_TYPE_SAT_USHORT_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatUAccum:
|
|
|
|
ID = PREDEF_TYPE_SAT_UACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatULongAccum:
|
|
|
|
ID = PREDEF_TYPE_SAT_ULONG_ACCUM_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatShortFract:
|
|
|
|
ID = PREDEF_TYPE_SAT_SHORT_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatFract:
|
|
|
|
ID = PREDEF_TYPE_SAT_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatLongFract:
|
|
|
|
ID = PREDEF_TYPE_SAT_LONG_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatUShortFract:
|
|
|
|
ID = PREDEF_TYPE_SAT_USHORT_FRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatUFract:
|
|
|
|
ID = PREDEF_TYPE_SAT_UFRACT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::SatULongFract:
|
|
|
|
ID = PREDEF_TYPE_SAT_ULONG_FRACT_ID;
|
|
|
|
break;
|
2017-09-08 23:15:00 +08:00
|
|
|
case BuiltinType::Float16:
|
|
|
|
ID = PREDEF_TYPE_FLOAT16_ID;
|
|
|
|
break;
|
2016-05-09 16:52:33 +08:00
|
|
|
case BuiltinType::Float128:
|
|
|
|
ID = PREDEF_TYPE_FLOAT128_ID;
|
|
|
|
break;
|
2015-09-15 20:18:29 +08:00
|
|
|
case BuiltinType::NullPtr:
|
|
|
|
ID = PREDEF_TYPE_NULLPTR_ID;
|
|
|
|
break;
|
2018-05-01 13:02:45 +08:00
|
|
|
case BuiltinType::Char8:
|
|
|
|
ID = PREDEF_TYPE_CHAR8_ID;
|
|
|
|
break;
|
2015-09-15 20:18:29 +08:00
|
|
|
case BuiltinType::Char16:
|
|
|
|
ID = PREDEF_TYPE_CHAR16_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Char32:
|
|
|
|
ID = PREDEF_TYPE_CHAR32_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Overload:
|
|
|
|
ID = PREDEF_TYPE_OVERLOAD_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::BoundMember:
|
|
|
|
ID = PREDEF_TYPE_BOUND_MEMBER;
|
|
|
|
break;
|
|
|
|
case BuiltinType::PseudoObject:
|
|
|
|
ID = PREDEF_TYPE_PSEUDO_OBJECT;
|
|
|
|
break;
|
|
|
|
case BuiltinType::Dependent:
|
|
|
|
ID = PREDEF_TYPE_DEPENDENT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::UnknownAny:
|
|
|
|
ID = PREDEF_TYPE_UNKNOWN_ANY;
|
|
|
|
break;
|
2012-12-18 22:30:41 +08:00
|
|
|
case BuiltinType::ARCUnbridgedCast:
|
2015-09-15 20:18:29 +08:00
|
|
|
ID = PREDEF_TYPE_ARC_UNBRIDGED_CAST;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ObjCId:
|
|
|
|
ID = PREDEF_TYPE_OBJC_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ObjCClass:
|
|
|
|
ID = PREDEF_TYPE_OBJC_CLASS;
|
|
|
|
break;
|
|
|
|
case BuiltinType::ObjCSel:
|
|
|
|
ID = PREDEF_TYPE_OBJC_SEL;
|
|
|
|
break;
|
2016-04-08 21:40:33 +08:00
|
|
|
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
|
|
|
|
case BuiltinType::Id: \
|
|
|
|
ID = PREDEF_TYPE_##Id##_ID; \
|
2015-09-15 20:18:29 +08:00
|
|
|
break;
|
2016-04-13 16:33:41 +08:00
|
|
|
#include "clang/Basic/OpenCLImageTypes.def"
|
2018-11-08 19:25:41 +08:00
|
|
|
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
|
|
|
|
case BuiltinType::Id: \
|
|
|
|
ID = PREDEF_TYPE_##Id##_ID; \
|
|
|
|
break;
|
|
|
|
#include "clang/Basic/OpenCLExtensionTypes.def"
|
2015-09-15 20:18:29 +08:00
|
|
|
case BuiltinType::OCLSampler:
|
|
|
|
ID = PREDEF_TYPE_SAMPLER_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::OCLEvent:
|
|
|
|
ID = PREDEF_TYPE_EVENT_ID;
|
|
|
|
break;
|
2015-09-15 19:18:52 +08:00
|
|
|
case BuiltinType::OCLClkEvent:
|
|
|
|
ID = PREDEF_TYPE_CLK_EVENT_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::OCLQueue:
|
|
|
|
ID = PREDEF_TYPE_QUEUE_ID;
|
|
|
|
break;
|
|
|
|
case BuiltinType::OCLReserveID:
|
|
|
|
ID = PREDEF_TYPE_RESERVE_ID_ID;
|
|
|
|
break;
|
2019-08-09 16:52:54 +08:00
|
|
|
#define SVE_TYPE(Name, Id, SingletonId) \
|
|
|
|
case BuiltinType::Id: \
|
|
|
|
ID = PREDEF_TYPE_##Id##_ID; \
|
|
|
|
break;
|
|
|
|
#include "clang/Basic/AArch64SVEACLETypes.def"
|
2020-10-29 02:14:48 +08:00
|
|
|
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
|
|
|
|
case BuiltinType::Id: \
|
|
|
|
ID = PREDEF_TYPE_##Id##_ID; \
|
|
|
|
break;
|
|
|
|
#include "clang/Basic/PPCTypes.def"
|
2012-12-18 22:30:41 +08:00
|
|
|
case BuiltinType::BuiltinFn:
|
2015-09-15 20:18:29 +08:00
|
|
|
ID = PREDEF_TYPE_BUILTIN_FN;
|
|
|
|
break;
|
[Matrix] Implement matrix index expressions ([][]).
This patch implements matrix index expressions
(matrix[RowIdx][ColumnIdx]).
It does so by introducing a new MatrixSubscriptExpr(Base, RowIdx, ColumnIdx).
MatrixSubscriptExprs are built in 2 steps in ActOnMatrixSubscriptExpr. First,
if the base of a subscript is of matrix type, we create a incomplete
MatrixSubscriptExpr(base, idx, nullptr). Second, if the base is an incomplete
MatrixSubscriptExpr, we create a complete
MatrixSubscriptExpr(base->getBase(), base->getRowIdx(), idx)
Similar to vector elements, it is not possible to take the address of
a MatrixSubscriptExpr.
For CodeGen, a new MatrixElt type is added to LValue, which is very
similar to VectorElt. The only difference is that we may need to cast
the type of the base from an array to a vector type when accessing it.
Reviewers: rjmccall, anemet, Bigcheese, rsmith, martong
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D76791
2020-06-02 02:42:03 +08:00
|
|
|
case BuiltinType::IncompleteMatrixIdx:
|
|
|
|
ID = PREDEF_TYPE_INCOMPLETE_MATRIX_IDX;
|
|
|
|
break;
|
2015-09-15 20:18:29 +08:00
|
|
|
case BuiltinType::OMPArraySection:
|
|
|
|
ID = PREDEF_TYPE_OMP_ARRAY_SECTION;
|
|
|
|
break;
|
[OPENMP50]Add basic support for array-shaping operation.
Summary:
Added basic representation and parsing/sema handling of array-shaping
operations. Array shaping expression is an expression of form ([s0]..[sn])base,
where s0, ..., sn must be a positive integer, base - a pointer. This
expression is a kind of cast operation that converts pointer expression
into an array-like kind of expression.
Reviewers: rjmccall, rsmith, jdoerfert
Subscribers: guansong, arphaman, cfe-commits, caomhin, kkwli0
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74144
2020-02-05 22:33:05 +08:00
|
|
|
case BuiltinType::OMPArrayShaping:
|
|
|
|
ID = PREDEF_TYPE_OMP_ARRAY_SHAPING;
|
|
|
|
break;
|
2020-04-02 03:06:38 +08:00
|
|
|
case BuiltinType::OMPIterator:
|
|
|
|
ID = PREDEF_TYPE_OMP_ITERATOR;
|
|
|
|
break;
|
[ARM] Add __bf16 as new Bfloat16 C Type
Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:
https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new bfloat IR type.
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij
Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli
Reviewed By: SjoerdMeijer
Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, danielkiss, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76077
2020-06-05 07:20:02 +08:00
|
|
|
case BuiltinType::BFloat16:
|
|
|
|
ID = PREDEF_TYPE_BFLOAT16_ID;
|
|
|
|
break;
|
2012-12-18 22:30:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TypeIdx(ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned serialization::ComputeHash(Selector Sel) {
|
|
|
|
unsigned N = Sel.getNumArgs();
|
|
|
|
if (N == 0)
|
|
|
|
++N;
|
|
|
|
unsigned R = 5381;
|
|
|
|
for (unsigned I = 0; I != N; ++I)
|
|
|
|
if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(I))
|
2018-02-26 23:16:42 +08:00
|
|
|
R = llvm::djbHash(II->getName(), R);
|
2012-12-18 22:30:41 +08:00
|
|
|
return R;
|
|
|
|
}
|
2013-01-21 23:25:38 +08:00
|
|
|
|
2013-01-23 01:08:30 +08:00
|
|
|
const DeclContext *
|
|
|
|
serialization::getDefinitiveDeclContext(const DeclContext *DC) {
|
2013-01-21 23:25:38 +08:00
|
|
|
switch (DC->getDeclKind()) {
|
|
|
|
// These entities may have multiple definitions.
|
|
|
|
case Decl::TranslationUnit:
|
2015-03-07 08:04:49 +08:00
|
|
|
case Decl::ExternCContext:
|
2013-01-21 23:25:38 +08:00
|
|
|
case Decl::Namespace:
|
|
|
|
case Decl::LinkageSpec:
|
2016-09-09 07:14:54 +08:00
|
|
|
case Decl::Export:
|
2014-05-22 13:54:18 +08:00
|
|
|
return nullptr;
|
2013-01-21 23:25:38 +08:00
|
|
|
|
|
|
|
// C/C++ tag types can only be defined in one place.
|
|
|
|
case Decl::Enum:
|
|
|
|
case Decl::Record:
|
|
|
|
if (const TagDecl *Def = cast<TagDecl>(DC)->getDefinition())
|
|
|
|
return Def;
|
2014-05-22 13:54:18 +08:00
|
|
|
return nullptr;
|
2013-01-21 23:25:38 +08:00
|
|
|
|
|
|
|
// FIXME: These can be defined in one place... except special member
|
|
|
|
// functions and out-of-line definitions.
|
|
|
|
case Decl::CXXRecord:
|
|
|
|
case Decl::ClassTemplateSpecialization:
|
|
|
|
case Decl::ClassTemplatePartialSpecialization:
|
2014-05-22 13:54:18 +08:00
|
|
|
return nullptr;
|
2013-01-21 23:25:38 +08:00
|
|
|
|
|
|
|
// Each function, method, and block declaration is its own DeclContext.
|
|
|
|
case Decl::Function:
|
|
|
|
case Decl::CXXMethod:
|
|
|
|
case Decl::CXXConstructor:
|
|
|
|
case Decl::CXXDestructor:
|
|
|
|
case Decl::CXXConversion:
|
|
|
|
case Decl::ObjCMethod:
|
|
|
|
case Decl::Block:
|
2013-04-17 03:37:38 +08:00
|
|
|
case Decl::Captured:
|
2013-01-21 23:25:38 +08:00
|
|
|
// Objective C categories, category implementations, and class
|
|
|
|
// implementations can only be defined in one place.
|
|
|
|
case Decl::ObjCCategory:
|
|
|
|
case Decl::ObjCCategoryImpl:
|
|
|
|
case Decl::ObjCImplementation:
|
2013-01-23 01:08:30 +08:00
|
|
|
return DC;
|
2013-01-21 23:25:38 +08:00
|
|
|
|
|
|
|
case Decl::ObjCProtocol:
|
|
|
|
if (const ObjCProtocolDecl *Def
|
|
|
|
= cast<ObjCProtocolDecl>(DC)->getDefinition())
|
|
|
|
return Def;
|
2014-05-22 13:54:18 +08:00
|
|
|
return nullptr;
|
2013-01-21 23:25:38 +08:00
|
|
|
|
|
|
|
// FIXME: These are defined in one place, but properties in class extensions
|
|
|
|
// end up being back-patched into the main interface. See
|
|
|
|
// Sema::HandlePropertyInClassExtension for the offending code.
|
|
|
|
case Decl::ObjCInterface:
|
2014-05-22 13:54:18 +08:00
|
|
|
return nullptr;
|
|
|
|
|
2013-01-21 23:25:38 +08:00
|
|
|
default:
|
|
|
|
llvm_unreachable("Unhandled DeclContext in AST reader");
|
|
|
|
}
|
2018-02-26 23:16:42 +08:00
|
|
|
|
2013-01-23 01:08:30 +08:00
|
|
|
llvm_unreachable("Unhandled decl kind");
|
2013-01-22 00:16:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool serialization::isRedeclarableDeclKind(unsigned Kind) {
|
|
|
|
switch (static_cast<Decl::Kind>(Kind)) {
|
2015-03-07 08:04:49 +08:00
|
|
|
case Decl::TranslationUnit:
|
|
|
|
case Decl::ExternCContext:
|
|
|
|
// Special case of a "merged" declaration.
|
|
|
|
return true;
|
|
|
|
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::Namespace:
|
2014-09-04 07:11:22 +08:00
|
|
|
case Decl::NamespaceAlias:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::Typedef:
|
|
|
|
case Decl::TypeAlias:
|
|
|
|
case Decl::Enum:
|
|
|
|
case Decl::Record:
|
|
|
|
case Decl::CXXRecord:
|
|
|
|
case Decl::ClassTemplateSpecialization:
|
|
|
|
case Decl::ClassTemplatePartialSpecialization:
|
2013-08-06 09:03:05 +08:00
|
|
|
case Decl::VarTemplateSpecialization:
|
|
|
|
case Decl::VarTemplatePartialSpecialization:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::Function:
|
2017-02-18 04:05:37 +08:00
|
|
|
case Decl::CXXDeductionGuide:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::CXXMethod:
|
|
|
|
case Decl::CXXConstructor:
|
|
|
|
case Decl::CXXDestructor:
|
|
|
|
case Decl::CXXConversion:
|
2013-10-23 10:17:46 +08:00
|
|
|
case Decl::UsingShadow:
|
P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:
Replace inheriting constructors implementation with new approach, voted into
C++ last year as a DR against C++11.
Instead of synthesizing a set of derived class constructors for each inherited
base class constructor, we make the constructors of the base class visible to
constructor lookup in the derived class, using the normal rules for
using-declarations.
For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived
class that tracks the requisite additional information. We create shadow
constructors (not found by name lookup) in the derived class to model the
actual initialization, and have a new expression node,
CXXInheritedCtorInitExpr, to model the initialization of a base class from such
a constructor. (This initialization is special because it performs real perfect
forwarding of arguments.)
In cases where argument forwarding is not possible (for inalloca calls,
variadic calls, and calls with callee parameter cleanup), the shadow inheriting
constructor is not emitted and instead we directly emit the initialization code
into the caller of the inherited constructor.
Note that this new model is not perfectly compatible with the old model in some
corner cases. In particular:
* if B inherits a private constructor from A, and C uses that constructor to
construct a B, then we previously required that A befriends B and B
befriends C, but the new rules require A to befriend C directly, and
* if a derived class has its own constructors (and so its implicit default
constructor is suppressed), it may still inherit a default constructor from
a base class
llvm-svn: 274049
2016-06-29 03:03:57 +08:00
|
|
|
case Decl::ConstructorUsingShadow:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::Var:
|
|
|
|
case Decl::FunctionTemplate:
|
|
|
|
case Decl::ClassTemplate:
|
2013-08-06 09:03:05 +08:00
|
|
|
case Decl::VarTemplate:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::TypeAliasTemplate:
|
|
|
|
case Decl::ObjCProtocol:
|
|
|
|
case Decl::ObjCInterface:
|
2013-02-23 01:15:32 +08:00
|
|
|
case Decl::Empty:
|
2013-01-22 00:16:40 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// Never redeclarable.
|
|
|
|
case Decl::UsingDirective:
|
|
|
|
case Decl::Label:
|
|
|
|
case Decl::UnresolvedUsingTypename:
|
|
|
|
case Decl::TemplateTypeParm:
|
|
|
|
case Decl::EnumConstant:
|
|
|
|
case Decl::UnresolvedUsingValue:
|
|
|
|
case Decl::IndirectField:
|
|
|
|
case Decl::Field:
|
2013-04-16 15:28:30 +08:00
|
|
|
case Decl::MSProperty:
|
Rework how UuidAttr, CXXUuidofExpr, and GUID template arguments and constants are represented.
Summary:
Previously, we treated CXXUuidofExpr as quite a special case: it was the
only kind of expression that could be a canonical template argument, it
could be a constant lvalue base object, and so on. In addition, we
represented the UUID value as a string, whose source form we did not
preserve faithfully, and that we partially parsed in multiple different
places.
With this patch, we create an MSGuidDecl object to represent the
implicit object of type 'struct _GUID' created by a UuidAttr. Each
UuidAttr holds a pointer to its 'struct _GUID' and its original
(as-written) UUID string. A non-value-dependent CXXUuidofExpr behaves
like a DeclRefExpr denoting that MSGuidDecl object. We cache an APValue
representation of the GUID on the MSGuidDecl and use it from constant
evaluation where needed.
This allows removing a lot of the special-case logic to handle these
expressions. Unfortunately, many parts of Clang assume there are only
a couple of interesting kinds of ValueDecl, so the total amount of
special-case logic is not really reduced very much.
This fixes a few bugs and issues:
* PR38490: we now support reading from GUID objects returned from
__uuidof during constant evaluation.
* Our Itanium mangling for a non-instantiation-dependent template
argument involving __uuidof no longer depends on which CXXUuidofExpr
template argument we happened to see first.
* We now predeclare ::_GUID, and permit use of __uuidof without
any header inclusion, better matching MSVC's behavior. We do not
predefine ::__s_GUID, though; that seems like a step too far.
* Our IR representation for GUID constants now uses the correct IR type
wherever possible. We will still fall back to using the
{i32, i16, i16, [8 x i8]}
layout if a definition of struct _GUID is not available. This is not
ideal: in principle the two layouts could have different padding.
Reviewers: rnk, jdoerfert
Subscribers: arphaman, cfe-commits, aeubanks
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78171
2020-04-12 13:15:29 +08:00
|
|
|
case Decl::MSGuid:
|
2020-09-21 14:16:08 +08:00
|
|
|
case Decl::TemplateParamObject:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::ObjCIvar:
|
|
|
|
case Decl::ObjCAtDefsField:
|
|
|
|
case Decl::NonTypeTemplateParm:
|
|
|
|
case Decl::TemplateTemplateParm:
|
|
|
|
case Decl::Using:
|
2016-12-21 05:35:28 +08:00
|
|
|
case Decl::UsingPack:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::ObjCMethod:
|
|
|
|
case Decl::ObjCCategory:
|
|
|
|
case Decl::ObjCCategoryImpl:
|
|
|
|
case Decl::ObjCImplementation:
|
|
|
|
case Decl::ObjCProperty:
|
|
|
|
case Decl::ObjCCompatibleAlias:
|
|
|
|
case Decl::LinkageSpec:
|
2016-09-09 07:14:54 +08:00
|
|
|
case Decl::Export:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::ObjCPropertyImpl:
|
2016-03-03 01:28:48 +08:00
|
|
|
case Decl::PragmaComment:
|
2016-03-03 03:28:54 +08:00
|
|
|
case Decl::PragmaDetectMismatch:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::FileScopeAsm:
|
|
|
|
case Decl::AccessSpec:
|
|
|
|
case Decl::Friend:
|
|
|
|
case Decl::FriendTemplate:
|
|
|
|
case Decl::StaticAssert:
|
|
|
|
case Decl::Block:
|
2013-04-17 03:37:38 +08:00
|
|
|
case Decl::Captured:
|
2013-01-22 00:16:40 +08:00
|
|
|
case Decl::ClassScopeFunctionSpecialization:
|
|
|
|
case Decl::Import:
|
2013-03-22 14:34:35 +08:00
|
|
|
case Decl::OMPThreadPrivate:
|
2019-03-08 01:54:44 +08:00
|
|
|
case Decl::OMPAllocate:
|
2018-09-26 12:28:39 +08:00
|
|
|
case Decl::OMPRequires:
|
2016-02-11 13:35:55 +08:00
|
|
|
case Decl::OMPCapturedExpr:
|
2016-03-03 13:21:39 +08:00
|
|
|
case Decl::OMPDeclareReduction:
|
2019-02-02 04:25:04 +08:00
|
|
|
case Decl::OMPDeclareMapper:
|
2015-11-04 11:40:30 +08:00
|
|
|
case Decl::BuiltinTemplate:
|
2016-07-23 07:36:59 +08:00
|
|
|
case Decl::Decomposition:
|
|
|
|
case Decl::Binding:
|
2019-07-11 05:25:49 +08:00
|
|
|
case Decl::Concept:
|
2019-11-17 18:41:55 +08:00
|
|
|
case Decl::LifetimeExtendedTemporary:
|
2020-01-18 15:11:43 +08:00
|
|
|
case Decl::RequiresExprBody:
|
2013-01-22 00:16:40 +08:00
|
|
|
return false;
|
2014-09-04 07:11:22 +08:00
|
|
|
|
|
|
|
// These indirectly derive from Redeclarable<T> but are not actually
|
|
|
|
// redeclarable.
|
|
|
|
case Decl::ImplicitParam:
|
|
|
|
case Decl::ParmVar:
|
Parsing, semantic analysis, and AST for Objective-C type parameters.
Produce type parameter declarations for Objective-C type parameters,
and attach lists of type parameters to Objective-C classes,
categories, forward declarations, and extensions as
appropriate. Perform semantic analysis of type bounds for type
parameters, both in isolation and across classes/categories/extensions
to ensure consistency.
Also handle (de-)serialization of Objective-C type parameter lists,
along with sundry other things one must do to add a new declaration to
Clang.
Note that Objective-C type parameters are typedef name declarations,
like typedefs and C++11 type aliases, in support of type erasure.
Part of rdar://problem/6294649.
llvm-svn: 241541
2015-07-07 11:57:15 +08:00
|
|
|
case Decl::ObjCTypeParam:
|
2014-09-04 07:11:22 +08:00
|
|
|
return false;
|
2013-01-22 00:16:40 +08:00
|
|
|
}
|
2013-01-21 23:25:38 +08:00
|
|
|
|
2013-01-22 00:16:40 +08:00
|
|
|
llvm_unreachable("Unhandled declaration kind");
|
2013-01-21 23:25:38 +08:00
|
|
|
}
|
2014-08-28 09:33:39 +08:00
|
|
|
|
|
|
|
bool serialization::needsAnonymousDeclarationNumber(const NamedDecl *D) {
|
2015-02-07 11:11:11 +08:00
|
|
|
// Friend declarations in dependent contexts aren't anonymous in the usual
|
|
|
|
// sense, but they cannot be found by name lookup in their semantic context
|
|
|
|
// (or indeed in any context), so we treat them as anonymous.
|
|
|
|
//
|
|
|
|
// This doesn't apply to friend tag decls; Sema makes those available to name
|
|
|
|
// lookup in the surrounding context.
|
|
|
|
if (D->getFriendObjectKind() &&
|
|
|
|
D->getLexicalDeclContext()->isDependentContext() && !isa<TagDecl>(D)) {
|
|
|
|
// For function templates and class templates, the template is numbered and
|
|
|
|
// not its pattern.
|
|
|
|
if (auto *FD = dyn_cast<FunctionDecl>(D))
|
|
|
|
return !FD->getDescribedFunctionTemplate();
|
|
|
|
if (auto *RD = dyn_cast<CXXRecordDecl>(D))
|
|
|
|
return !RD->getDescribedClassTemplate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-04 10:25:38 +08:00
|
|
|
// At block scope, we number everything that we need to deduplicate, since we
|
|
|
|
// can't just use name matching to keep things lined up.
|
|
|
|
// FIXME: This is only necessary for an inline function or a template or
|
|
|
|
// similar.
|
|
|
|
if (D->getLexicalDeclContext()->isFunctionOrMethod()) {
|
|
|
|
if (auto *VD = dyn_cast<VarDecl>(D))
|
|
|
|
return VD->isStaticLocal();
|
|
|
|
// FIXME: What about CapturedDecls (and declarations nested within them)?
|
|
|
|
return isa<TagDecl>(D) || isa<BlockDecl>(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, we only care about anonymous class members / block-scope decls.
|
|
|
|
// FIXME: We need to handle lambdas and blocks within inline / templated
|
|
|
|
// variables too.
|
2017-10-11 15:47:54 +08:00
|
|
|
if (D->getDeclName() || !isa<CXXRecordDecl>(D->getLexicalDeclContext()))
|
2014-08-28 09:33:39 +08:00
|
|
|
return false;
|
|
|
|
return isa<TagDecl>(D) || isa<FieldDecl>(D);
|
|
|
|
}
|