ABataev updated this revision to Diff 101262.
ABataev added a comment.
Herald added a subscriber: jholewinski.
Added different kinds of ImplicitParamDecl.
https://reviews.llvm.org/D33735
Files:
include/clang/AST/Decl.h
lib/AST/ASTImporter.cpp
lib/AST/Decl.cpp
lib/AST/DeclObjC.cpp
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGCXXABI.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDeclCXX.cpp
lib/CodeGen/CGException.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGObjC.cpp
lib/CodeGen/CGOpenMPRuntime.cpp
lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
lib/CodeGen/CGStmtOpenMP.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/MicrosoftCXXABI.cpp
lib/Sema/SemaStmt.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CodeGen/captured-statements.c
test/CodeGenCXX/captured-statements.cpp
Index: test/CodeGenCXX/captured-statements.cpp
===================================================================
--- test/CodeGenCXX/captured-statements.cpp
+++ test/CodeGenCXX/captured-statements.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
@@ -194,3 +194,18 @@
void call_test_captured_linkage() {
test_captured_linkage();
}
+
+// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
Index: test/CodeGen/captured-statements.c
===================================================================
--- test/CodeGen/captured-statements.c
+++ test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
@@ -98,3 +98,8 @@
// CHECK-GLOBALS: load i32, i32* @global
// CHECK-GLOBALS: load i32, i32* @
// CHECK-GLOBALS: load i32, i32* @e
+
+// CHECK-GLOBALS-NOT: DIFlagObjectPointer
+// CHECK-1-NOT: DIFlagObjectPointer
+// CHECK-2-NOT: DIFlagObjectPointer
+// CHECK-3-NOT: DIFlagObjectPointer
Index: lib/Serialization/ASTWriterDecl.cpp
===================================================================
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -967,6 +967,7 @@
void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
VisitVarDecl(D);
+ Record.push_back(D->getParameterKind());
Code = serialization::DECL_IMPLICIT_PARAM;
}
Index: lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1278,6 +1278,8 @@
void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
VisitVarDecl(PD);
+ PD->ParamKind =
+ static_cast<ImplicitParamDecl::ImplicitParamKind>(Record.readInt());
}
void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
Index: lib/Sema/SemaStmt.cpp
===================================================================
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -3956,8 +3956,9 @@
DeclContext *DC = CapturedDecl::castToDeclContext(CD);
IdentifierInfo *ParamName = &Context.Idents.get("__context");
QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
- ImplicitParamDecl *Param
- = ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
+ ImplicitParamDecl *Param =
+ ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType,
+ ImplicitParamDecl::IPK_CapturedContext);
DC->addDecl(Param);
CD->setContextParam(0, Param);
@@ -3992,15 +3993,17 @@
"null type has been found already for '__context' parameter");
IdentifierInfo *ParamName = &Context.Idents.get("__context");
QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
- ImplicitParamDecl *Param
- = ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
+ ImplicitParamDecl *Param =
+ ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType,
+ ImplicitParamDecl::IPK_CapturedContext);
DC->addDecl(Param);
CD->setContextParam(ParamNum, Param);
ContextIsFound = true;
} else {
IdentifierInfo *ParamName = &Context.Idents.get(I->first);
- ImplicitParamDecl *Param
- = ImplicitParamDecl::Create(Context, DC, Loc, ParamName, I->second);
+ ImplicitParamDecl *Param =
+ ImplicitParamDecl::Create(Context, DC, Loc, ParamName, I->second,
+ ImplicitParamDecl::IPK_CapturedContext);
DC->addDecl(Param);
CD->setParam(ParamNum, Param);
}
@@ -4011,7 +4014,8 @@
IdentifierInfo *ParamName = &Context.Idents.get("__context");
QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
ImplicitParamDecl *Param =
- ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
+ ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType,
+ ImplicitParamDecl::IPK_CapturedContext);
DC->addDecl(Param);
CD->setContextParam(ParamNum, Param);
}
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===================================================================
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1413,11 +1413,10 @@
const CXXMethodDecl *MD = cast<CXXMethodDecl>(CGF.CurGD.getDecl());
assert(isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD));
if (isa<CXXConstructorDecl>(MD) && MD->getParent()->getNumVBases()) {
- ImplicitParamDecl *IsMostDerived
- = ImplicitParamDecl::Create(Context, nullptr,
- CGF.CurGD.getDecl()->getLocation(),
- &Context.Idents.get("is_most_derived"),
- Context.IntTy);
+ ImplicitParamDecl *IsMostDerived =
+ ImplicitParamDecl::Create(Context, Context.IntTy);
+ IsMostDerived->setLocation(CGF.CurGD.getDecl()->getLocation());
+ IsMostDerived->setDeclName(&Context.Idents.get("is_most_derived"));
// The 'most_derived' parameter goes second if the ctor is variadic and last
// if it's not. Dtors can't be variadic.
const FunctionProtoType *FPT = MD->getType()->castAs<FunctionProtoType>();
@@ -1427,11 +1426,10 @@
Params.push_back(IsMostDerived);
getStructorImplicitParamDecl(CGF) = IsMostDerived;
} else if (isDeletingDtor(CGF.CurGD)) {
- ImplicitParamDecl *ShouldDelete
- = ImplicitParamDecl::Create(Context, nullptr,
- CGF.CurGD.getDecl()->getLocation(),
- &Context.Idents.get("should_call_delete"),
- Context.IntTy);
+ ImplicitParamDecl *ShouldDelete =
+ ImplicitParamDecl::Create(Context, Context.IntTy);
+ ShouldDelete->setLocation(CGF.CurGD.getDecl()->getLocation());
+ ShouldDelete->setDeclName(&Context.Idents.get("should_call_delete"));
Params.push_back(ShouldDelete);
getStructorImplicitParamDecl(CGF) = ShouldDelete;
}
@@ -3874,19 +3872,18 @@
// Following the 'this' pointer is a reference to the source object that we
// are copying from.
- ImplicitParamDecl SrcParam(
- getContext(), nullptr, SourceLocation(), &getContext().Idents.get("src"),
- getContext().getLValueReferenceType(RecordTy,
- /*SpelledAsLValue=*/true));
+ ImplicitParamDecl SrcParam(getContext(), getContext().getLValueReferenceType(
+ RecordTy,
+ /*SpelledAsLValue=*/true));
+ SrcParam.setDeclName(&getContext().Idents.get("src"));
if (IsCopy)
FunctionArgs.push_back(&SrcParam);
// Constructors for classes which utilize virtual bases have an additional
// parameter which indicates whether or not it is being delegated to by a more
// derived constructor.
- ImplicitParamDecl IsMostDerived(getContext(), nullptr, SourceLocation(),
- &getContext().Idents.get("is_most_derived"),
- getContext().IntTy);
+ ImplicitParamDecl IsMostDerived(getContext(), getContext().IntTy);
+ IsMostDerived.setDeclName(&getContext().Idents.get("is_most_derived"));
// Only add the parameter to the list if thie class has virtual bases.
if (RD->getNumVBases() > 0)
FunctionArgs.push_back(&IsMostDerived);
Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1408,9 +1408,9 @@
// FIXME: avoid the fake decl
QualType T = Context.getPointerType(Context.VoidPtrTy);
- ImplicitParamDecl *VTTDecl
- = ImplicitParamDecl::Create(Context, nullptr, MD->getLocation(),
- &Context.Idents.get("vtt"), T);
+ ImplicitParamDecl *VTTDecl = ImplicitParamDecl::Create(
+ Context, nullptr, MD->getLocation(), &Context.Idents.get("vtt"), T,
+ ImplicitParamDecl::IPK_CXXVTT);
Params.insert(Params.begin() + 1, VTTDecl);
getStructorImplicitParamDecl(CGF) = VTTDecl;
}
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1083,10 +1083,9 @@
if (!Param->hasAttr<PassObjectSizeAttr>())
continue;
- IdentifierInfo *NoID = nullptr;
- auto *Implicit = ImplicitParamDecl::Create(
- getContext(), Param->getDeclContext(), Param->getLocation(), NoID,
- getContext().getSizeType());
+ auto *Implicit =
+ ImplicitParamDecl::Create(getContext(), getContext().getSizeType());
+ Implicit->setLocation(Param->getLocation());
SizeArguments[Param] = Implicit;
Args.push_back(Implicit);
}
Index: lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -281,8 +281,10 @@
ArgType =
getCanonicalParamType(getContext(), ArgType.getNonReferenceType());
}
- Args.push_back(ImplicitParamDecl::Create(getContext(), nullptr,
- FD->getLocation(), II, ArgType));
+ auto *IPD = ImplicitParamDecl::Create(getContext(), ArgType);
+ IPD->setLocation(FD->getLocation());
+ IPD->setDeclName(II);
+ Args.push_back(IPD);
++I;
}
Args.append(
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===================================================================
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -1252,24 +1252,19 @@
auto Int32Ty = C.getIntTypeForBitwidth(32, /* Signed */ true);
// Destination of the copy.
- ImplicitParamDecl ReduceListArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl ReduceListArg(C, C.VoidPtrTy);
// Base address of the scratchpad array, with each element storing a
// Reduce list per team.
- ImplicitParamDecl ScratchPadArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl ScratchPadArg(C, C.VoidPtrTy);
// A source index into the scratchpad array.
- ImplicitParamDecl IndexArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, Int32Ty);
+ ImplicitParamDecl IndexArg(C, Int32Ty);
// Row width of an element in the scratchpad array, typically
// the number of teams.
- ImplicitParamDecl WidthArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, Int32Ty);
+ ImplicitParamDecl WidthArg(C, Int32Ty);
// If should_reduce == 1, then it's load AND reduce,
// If should_reduce == 0 (or otherwise), then it only loads (+ copy).
// The latter case is used for initialization.
- ImplicitParamDecl ShouldReduceArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, Int32Ty);
+ ImplicitParamDecl ShouldReduceArg(C, Int32Ty);
FunctionArgList Args;
Args.push_back(&ReduceListArg);
@@ -1381,20 +1376,16 @@
auto Int32Ty = C.getIntTypeForBitwidth(32, /* Signed */ true);
// Source of the copy.
- ImplicitParamDecl ReduceListArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl ReduceListArg(C, C.VoidPtrTy);
// Base address of the scratchpad array, with each element storing a
// Reduce list per team.
- ImplicitParamDecl ScratchPadArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl ScratchPadArg(C, C.VoidPtrTy);
// A destination index into the scratchpad array, typically the team
// identifier.
- ImplicitParamDecl IndexArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, Int32Ty);
+ ImplicitParamDecl IndexArg(C, Int32Ty);
// Row width of an element in the scratchpad array, typically
// the number of teams.
- ImplicitParamDecl WidthArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, Int32Ty);
+ ImplicitParamDecl WidthArg(C, Int32Ty);
FunctionArgList Args;
Args.push_back(&ReduceListArg);
@@ -1475,12 +1466,10 @@
// ReduceList: thread local Reduce list.
// At the stage of the computation when this function is called, partially
// aggregated values reside in the first lane of every active warp.
- ImplicitParamDecl ReduceListArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl ReduceListArg(C, C.VoidPtrTy);
// NumWarps: number of warps active in the parallel region. This could
// be smaller than 32 (max warps in a CTA) for partial block reduction.
- ImplicitParamDecl NumWarpsArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr,
+ ImplicitParamDecl NumWarpsArg(C,
C.getIntTypeForBitwidth(32, /* Signed */ true));
FunctionArgList Args;
Args.push_back(&ReduceListArg);
@@ -1723,17 +1712,13 @@
auto &C = CGM.getContext();
// Thread local Reduce list used to host the values of data to be reduced.
- ImplicitParamDecl ReduceListArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl ReduceListArg(C, C.VoidPtrTy);
// Current lane id; could be logical.
- ImplicitParamDecl LaneIDArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.ShortTy);
+ ImplicitParamDecl LaneIDArg(C, C.ShortTy);
// Offset of the remote source lane relative to the current lane.
- ImplicitParamDecl RemoteLaneOffsetArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.ShortTy);
+ ImplicitParamDecl RemoteLaneOffsetArg(C, C.ShortTy);
// Algorithm version. This is expected to be known at compile time.
- ImplicitParamDecl AlgoVerArg(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.ShortTy);
+ ImplicitParamDecl AlgoVerArg(C, C.ShortTy);
FunctionArgList Args;
Args.push_back(&ReduceListArg);
Args.push_back(&LaneIDArg);
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -746,10 +746,8 @@
auto &C = CGM.getContext();
QualType PtrTy = C.getPointerType(Ty).withRestrict();
FunctionArgList Args;
- ImplicitParamDecl OmpOutParm(C, /*DC=*/nullptr, Out->getLocation(),
- /*Id=*/nullptr, PtrTy);
- ImplicitParamDecl OmpInParm(C, /*DC=*/nullptr, In->getLocation(),
- /*Id=*/nullptr, PtrTy);
+ ImplicitParamDecl OmpOutParm(C, PtrTy);
+ ImplicitParamDecl OmpInParm(C, PtrTy);
Args.push_back(&OmpOutParm);
Args.push_back(&OmpInParm);
auto &FnInfo =
@@ -1808,8 +1806,7 @@
// threadprivate copy of the variable VD
CodeGenFunction CtorCGF(CGM);
FunctionArgList Args;
- ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, CGM.getContext().VoidPtrTy);
+ ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy);
Args.push_back(&Dst);
auto &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(
@@ -1839,8 +1836,7 @@
// of the variable VD
CodeGenFunction DtorCGF(CGM);
FunctionArgList Args;
- ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, CGM.getContext().VoidPtrTy);
+ ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy);
Args.push_back(&Dst);
auto &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(
@@ -2191,10 +2187,8 @@
auto &C = CGM.getContext();
// void copy_func(void *LHSArg, void *RHSArg);
FunctionArgList Args;
- ImplicitParamDecl LHSArg(C, /*DC=*/nullptr, SourceLocation(), /*Id=*/nullptr,
- C.VoidPtrTy);
- ImplicitParamDecl RHSArg(C, /*DC=*/nullptr, SourceLocation(), /*Id=*/nullptr,
- C.VoidPtrTy);
+ ImplicitParamDecl LHSArg(C, C.VoidPtrTy);
+ ImplicitParamDecl RHSArg(C, C.VoidPtrTy);
Args.push_back(&LHSArg);
Args.push_back(&RHSArg);
auto &CGFI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, Args);
@@ -2785,8 +2779,7 @@
const RegionCodeGenTy &Codegen) {
auto &C = CGM.getContext();
FunctionArgList Args;
- ImplicitParamDecl DummyPtr(C, /*DC=*/nullptr, SourceLocation(),
- /*Id=*/nullptr, C.VoidPtrTy);
+ ImplicitParamDecl DummyPtr(C, C.VoidPtrTy);
Args.push_back(&DummyPtr);
CodeGenFunction CGF(CGM);
@@ -2888,8 +2881,9 @@
// Create a variable to drive the registration and unregistration of the
// descriptor, so we can reuse the logic that emits Ctors and Dtors.
auto *IdentInfo = &C.Idents.get(".omp_offloading.reg_unreg_var");
- ImplicitParamDecl RegUnregVar(C, C.getTranslationUnitDecl(), SourceLocation(),
- IdentInfo, C.CharTy);
+ ImplicitParamDecl RegUnregVar(C, C.CharTy);
+ RegUnregVar.setDeclName(IdentInfo);
+ RegUnregVar.setDeclContext(C.getTranslationUnitDecl());
auto *UnRegFn = createOffloadingBinaryDescriptorFunction(
CGM, ".omp_offloading.descriptor_unreg",
@@ -3319,10 +3313,8 @@
llvm::Value *TaskPrivatesMap) {
auto &C = CGM.getContext();
FunctionArgList Args;
- ImplicitParamDecl GtidArg(C, /*DC=*/nullptr, Loc, /*Id=*/nullptr, KmpInt32Ty);
- ImplicitParamDecl TaskTypeArg(C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr,
- KmpTaskTWithPrivatesPtrQTy.withRestrict());
+ ImplicitParamDecl GtidArg(C, KmpInt32Ty);
+ ImplicitParamDecl TaskTypeArg(C, KmpTaskTWithPrivatesPtrQTy.withRestrict());
Args.push_back(&GtidArg);
Args.push_back(&TaskTypeArg);
auto &TaskEntryFnInfo =
@@ -3413,10 +3405,8 @@
QualType KmpTaskTWithPrivatesQTy) {
auto &C = CGM.getContext();
FunctionArgList Args;
- ImplicitParamDecl GtidArg(C, /*DC=*/nullptr, Loc, /*Id=*/nullptr, KmpInt32Ty);
- ImplicitParamDecl TaskTypeArg(C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr,
- KmpTaskTWithPrivatesPtrQTy.withRestrict());
+ ImplicitParamDecl GtidArg(C, KmpInt32Ty);
+ ImplicitParamDecl TaskTypeArg(C, KmpTaskTWithPrivatesPtrQTy.withRestrict());
Args.push_back(&GtidArg);
Args.push_back(&TaskTypeArg);
FunctionType::ExtInfo Info;
@@ -3471,37 +3461,39 @@
auto &C = CGM.getContext();
FunctionArgList Args;
ImplicitParamDecl TaskPrivatesArg(
- C, /*DC=*/nullptr, Loc, /*Id=*/nullptr,
- C.getPointerType(PrivatesQTy).withConst().withRestrict());
+ C, C.getPointerType(PrivatesQTy).withConst().withRestrict());
Args.push_back(&TaskPrivatesArg);
llvm::DenseMap<const VarDecl *, unsigned> PrivateVarsPos;
unsigned Counter = 1;
for (auto *E: PrivateVars) {
- Args.push_back(ImplicitParamDecl::Create(
- C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr, C.getPointerType(C.getPointerType(E->getType()))
- .withConst()
- .withRestrict()));
+ auto *IPD = ImplicitParamDecl::Create(
+ C, C.getPointerType(C.getPointerType(E->getType()))
+ .withConst()
+ .withRestrict());
+ IPD->setLocation(Loc);
+ Args.push_back(IPD);
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
PrivateVarsPos[VD] = Counter;
++Counter;
}
for (auto *E : FirstprivateVars) {
- Args.push_back(ImplicitParamDecl::Create(
- C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr, C.getPointerType(C.getPointerType(E->getType()))
- .withConst()
- .withRestrict()));
+ auto *IPD = ImplicitParamDecl::Create(
+ C, C.getPointerType(C.getPointerType(E->getType()))
+ .withConst()
+ .withRestrict());
+ IPD->setLocation(Loc);
+ Args.push_back(IPD);
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
PrivateVarsPos[VD] = Counter;
++Counter;
}
for (auto *E: LastprivateVars) {
- Args.push_back(ImplicitParamDecl::Create(
- C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr, C.getPointerType(C.getPointerType(E->getType()))
- .withConst()
- .withRestrict()));
+ auto *IPD = ImplicitParamDecl::Create(
+ C, C.getPointerType(C.getPointerType(E->getType()))
+ .withConst()
+ .withRestrict());
+ IPD->setLocation(Loc);
+ Args.push_back(IPD);
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
PrivateVarsPos[VD] = Counter;
++Counter;
@@ -3661,12 +3653,9 @@
ArrayRef<PrivateDataTy> Privates, bool WithLastIter) {
auto &C = CGM.getContext();
FunctionArgList Args;
- ImplicitParamDecl DstArg(C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr, KmpTaskTWithPrivatesPtrQTy);
- ImplicitParamDecl SrcArg(C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr, KmpTaskTWithPrivatesPtrQTy);
- ImplicitParamDecl LastprivArg(C, /*DC=*/nullptr, Loc,
- /*Id=*/nullptr, C.IntTy);
+ ImplicitParamDecl DstArg(C, KmpTaskTWithPrivatesPtrQTy);
+ ImplicitParamDecl SrcArg(C, KmpTaskTWithPrivatesPtrQTy);
+ ImplicitParamDecl LastprivArg(C, C.IntTy);
Args.push_back(&DstArg);
Args.push_back(&SrcArg);
Args.push_back(&LastprivArg);
@@ -4278,10 +4267,8 @@
// void reduction_func(void *LHSArg, void *RHSArg);
FunctionArgList Args;
- ImplicitParamDecl LHSArg(C, /*DC=*/nullptr, SourceLocation(), /*Id=*/nullptr,
- C.VoidPtrTy);
- ImplicitParamDecl RHSArg(C, /*DC=*/nullptr, SourceLocation(), /*Id=*/nullptr,
- C.VoidPtrTy);
+ ImplicitParamDecl LHSArg(C, C.VoidPtrTy);
+ ImplicitParamDecl RHSArg(C, C.VoidPtrTy);
Args.push_back(&LHSArg);
Args.push_back(&RHSArg);
auto &CGFI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, Args);
Index: lib/CodeGen/CGObjC.cpp
===================================================================
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -3246,10 +3246,12 @@
SrcTy = C.getPointerType(SrcTy);
FunctionArgList args;
- ImplicitParamDecl dstDecl(getContext(), FD, SourceLocation(), nullptr,DestTy);
- args.push_back(&dstDecl);
- ImplicitParamDecl srcDecl(getContext(), FD, SourceLocation(), nullptr, SrcTy);
- args.push_back(&srcDecl);
+ ImplicitParamDecl DstDecl(getContext(), DestTy);
+ DstDecl.setDeclContext(FD);
+ args.push_back(&DstDecl);
+ ImplicitParamDecl SrcDecl(getContext(), SrcTy);
+ SrcDecl.setDeclContext(FD);
+ args.push_back(&SrcDecl);
const CGFunctionInfo &FI =
CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args);
@@ -3265,12 +3267,12 @@
StartFunction(FD, C.VoidTy, Fn, FI, args);
- DeclRefExpr DstExpr(&dstDecl, false, DestTy,
+ DeclRefExpr DstExpr(&DstDecl, false, DestTy,
VK_RValue, SourceLocation());
UnaryOperator DST(&DstExpr, UO_Deref, DestTy->getPointeeType(),
VK_LValue, OK_Ordinary, SourceLocation());
- DeclRefExpr SrcExpr(&srcDecl, false, SrcTy,
+ DeclRefExpr SrcExpr(&SrcDecl, false, SrcTy,
VK_RValue, SourceLocation());
UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(),
VK_LValue, OK_Ordinary, SourceLocation());
@@ -3327,10 +3329,12 @@
SrcTy = C.getPointerType(SrcTy);
FunctionArgList args;
- ImplicitParamDecl dstDecl(getContext(), FD, SourceLocation(), nullptr,DestTy);
- args.push_back(&dstDecl);
- ImplicitParamDecl srcDecl(getContext(), FD, SourceLocation(), nullptr, SrcTy);
- args.push_back(&srcDecl);
+ ImplicitParamDecl DstDecl(getContext(), DestTy);
+ DstDecl.setDeclContext(FD);
+ args.push_back(&DstDecl);
+ ImplicitParamDecl SrcDecl(getContext(), SrcTy);
+ SrcDecl.setDeclContext(FD);
+ args.push_back(&SrcDecl);
const CGFunctionInfo &FI =
CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args);
@@ -3345,7 +3349,7 @@
StartFunction(FD, C.VoidTy, Fn, FI, args);
- DeclRefExpr SrcExpr(&srcDecl, false, SrcTy,
+ DeclRefExpr SrcExpr(&SrcDecl, false, SrcTy,
VK_RValue, SourceLocation());
UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(),
@@ -3371,7 +3375,7 @@
CXXConstExpr->getConstructionKind(),
SourceRange());
- DeclRefExpr DstExpr(&dstDecl, false, DestTy,
+ DeclRefExpr DstExpr(&DstDecl, false, DestTy,
VK_RValue, SourceLocation());
RValue DV = EmitAnyExpr(&DstExpr);
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2847,10 +2847,8 @@
void CodeGenFunction::EmitCfiCheckFail() {
SanitizerScope SanScope(this);
FunctionArgList Args;
- ImplicitParamDecl ArgData(getContext(), nullptr, SourceLocation(), nullptr,
- getContext().VoidPtrTy);
- ImplicitParamDecl ArgAddr(getContext(), nullptr, SourceLocation(), nullptr,
- getContext().VoidPtrTy);
+ ImplicitParamDecl ArgData(getContext(), getContext().VoidPtrTy);
+ ImplicitParamDecl ArgAddr(getContext(), getContext().VoidPtrTy);
Args.push_back(&ArgData);
Args.push_back(&ArgAddr);
Index: lib/CodeGen/CGException.cpp
===================================================================
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -1648,19 +1648,22 @@
// All SEH finally functions take two parameters. Win64 filters take two
// parameters. Win32 filters take no parameters.
if (IsFilter) {
- Args.push_back(ImplicitParamDecl::Create(
- getContext(), nullptr, StartLoc,
- &getContext().Idents.get("exception_pointers"),
- getContext().VoidPtrTy));
+ auto *IPD =
+ ImplicitParamDecl::Create(getContext(), getContext().VoidPtrTy);
+ IPD->setLocation(StartLoc);
+ IPD->setDeclName(&getContext().Idents.get("exception_pointers"));
+ Args.push_back(IPD);
} else {
- Args.push_back(ImplicitParamDecl::Create(
- getContext(), nullptr, StartLoc,
- &getContext().Idents.get("abnormal_termination"),
- getContext().UnsignedCharTy));
+ auto *IPD =
+ ImplicitParamDecl::Create(getContext(), getContext().UnsignedCharTy);
+ IPD->setLocation(StartLoc);
+ IPD->setDeclName(&getContext().Idents.get("abnormal_termination"));
+ Args.push_back(IPD);
}
- Args.push_back(ImplicitParamDecl::Create(
- getContext(), nullptr, StartLoc,
- &getContext().Idents.get("frame_pointer"), getContext().VoidPtrTy));
+ auto *IPD = ImplicitParamDecl::Create(getContext(), getContext().VoidPtrTy);
+ IPD->setLocation(StartLoc);
+ IPD->setDeclName(&getContext().Idents.get("frame_pointer"));
+ Args.push_back(IPD);
}
QualType RetTy = IsFilter ? getContext().LongTy : getContext().VoidTy;
Index: lib/CodeGen/CGDeclCXX.cpp
===================================================================
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -603,9 +603,8 @@
Address addr, QualType type, Destroyer *destroyer,
bool useEHCleanupForArray, const VarDecl *VD) {
FunctionArgList args;
- ImplicitParamDecl dst(getContext(), nullptr, SourceLocation(), nullptr,
- getContext().VoidPtrTy);
- args.push_back(&dst);
+ ImplicitParamDecl Dst(getContext(), getContext().VoidPtrTy);
+ args.push_back(&Dst);
const CGFunctionInfo &FI =
CGM.getTypes().arrangeBuiltinFunctionDeclaration(getContext().VoidTy, args);
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3465,13 +3465,13 @@
unsigned AddressSpace = CGM.getContext().getTargetAddressSpace(VD->getType());
AppendAddressSpaceXDeref(AddressSpace, Expr);
- // If this is the first argument and it is implicit then
- // give it an object pointer flag.
- // FIXME: There has to be a better way to do this, but for static
- // functions there won't be an implicit param at arg1 and
- // otherwise it is 'self' or 'this'.
- if (isa<ImplicitParamDecl>(VD) && ArgNo && *ArgNo == 1)
- Flags |= llvm::DINode::FlagObjectPointer;
+ // If this is implicit parameter and has IPK_CXXThis or IPK_ObjCSelf attribute
+ // then give it an object pointer flag.
+ if (auto *IPD = dyn_cast<ImplicitParamDecl>(VD)) {
+ if (IPD->getParameterKind() == ImplicitParamDecl::IPK_CXXThis ||
+ IPD->getParameterKind() == ImplicitParamDecl::IPK_ObjCSelf)
+ Flags |= llvm::DINode::FlagObjectPointer;
+ }
// Note: Older versions of clang used to emit byval references with an extra
// DW_OP_deref, because they referenced the IR arg directly instead of
@@ -3582,8 +3582,9 @@
// Self is passed along as an implicit non-arg variable in a
// block. Mark it as the object pointer.
- if (isa<ImplicitParamDecl>(VD) && VD->getName() == "self")
- Ty = CreateSelfType(VD->getType(), Ty);
+ if (auto *IPD = dyn_cast<ImplicitParamDecl>(VD))
+ if (IPD->getParameterKind() == ImplicitParamDecl::IPK_ObjCSelf)
+ Ty = CreateSelfType(VD->getType(), Ty);
// Get location information.
unsigned Line = getLineNumber(VD->getLocation());
Index: lib/CodeGen/CGCXXABI.cpp
===================================================================
--- lib/CodeGen/CGCXXABI.cpp
+++ lib/CodeGen/CGCXXABI.cpp
@@ -159,10 +159,10 @@
// FIXME: I'm not entirely sure I like using a fake decl just for code
// generation. Maybe we can come up with a better way?
- ImplicitParamDecl *ThisDecl
- = ImplicitParamDecl::Create(CGM.getContext(), nullptr, MD->getLocation(),
- &CGM.getContext().Idents.get("this"),
- MD->getThisType(CGM.getContext()));
+ ImplicitParamDecl *ThisDecl = ImplicitParamDecl::Create(
+ CGM.getContext(), nullptr, MD->getLocation(),
+ &CGM.getContext().Idents.get("this"), MD->getThisType(CGM.getContext()),
+ ImplicitParamDecl::IPK_CXXThis);
params.push_back(ThisDecl);
CGF.CXXABIThisDecl = ThisDecl;
Index: lib/CodeGen/CGBlocks.cpp
===================================================================
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -903,9 +903,7 @@
} else {
// Fake up a new variable so that EmitScalarInit doesn't think
// we're referring to the variable in its own initializer.
- ImplicitParamDecl blockFieldPseudoVar(getContext(), /*DC*/ nullptr,
- SourceLocation(), /*name*/ nullptr,
- type);
+ ImplicitParamDecl BlockFieldPseudoVar(getContext(), type);
// We use one of these or the other depending on whether the
// reference is nested.
@@ -919,7 +917,7 @@
// attributed to a reasonable location - otherwise it may be attributed to
// locations of subexpressions in the initialization.
LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
- EmitExprAsInit(&l2r, &blockFieldPseudoVar,
+ EmitExprAsInit(&l2r, &BlockFieldPseudoVar,
MakeAddrLValue(blockField, type, BaseInfo),
/*captured by init*/ false);
}
@@ -1264,9 +1262,10 @@
IdentifierInfo *II = &CGM.getContext().Idents.get(".block_descriptor");
- ImplicitParamDecl selfDecl(getContext(), const_cast<BlockDecl*>(blockDecl),
- SourceLocation(), II, selfTy);
- args.push_back(&selfDecl);
+ ImplicitParamDecl SelfDecl(getContext(), const_cast<BlockDecl *>(blockDecl),
+ SourceLocation(), II, selfTy,
+ ImplicitParamDecl::IPK_ObjCSelf);
+ args.push_back(&SelfDecl);
// Now add the rest of the parameters.
args.append(blockDecl->param_begin(), blockDecl->param_end());
@@ -1499,12 +1498,10 @@
ASTContext &C = getContext();
FunctionArgList args;
- ImplicitParamDecl dstDecl(getContext(), nullptr, SourceLocation(), nullptr,
- C.VoidPtrTy);
- args.push_back(&dstDecl);
- ImplicitParamDecl srcDecl(getContext(), nullptr, SourceLocation(), nullptr,
- C.VoidPtrTy);
- args.push_back(&srcDecl);
+ ImplicitParamDecl DstDecl(getContext(), C.VoidPtrTy);
+ args.push_back(&DstDecl);
+ ImplicitParamDecl SrcDecl(getContext(), C.VoidPtrTy);
+ args.push_back(&SrcDecl);
const CGFunctionInfo &FI =
CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args);
@@ -1536,11 +1533,11 @@
auto AL = ApplyDebugLocation::CreateArtificial(*this);
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
- Address src = GetAddrOfLocalVar(&srcDecl);
+ Address src = GetAddrOfLocalVar(&SrcDecl);
src = Address(Builder.CreateLoad(src), blockInfo.BlockAlign);
src = Builder.CreateBitCast(src, structPtrTy, "block.source");
- Address dst = GetAddrOfLocalVar(&dstDecl);
+ Address dst = GetAddrOfLocalVar(&DstDecl);
dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
@@ -1676,9 +1673,8 @@
ASTContext &C = getContext();
FunctionArgList args;
- ImplicitParamDecl srcDecl(getContext(), nullptr, SourceLocation(), nullptr,
- C.VoidPtrTy);
- args.push_back(&srcDecl);
+ ImplicitParamDecl SrcDecl(getContext(), C.VoidPtrTy);
+ args.push_back(&SrcDecl);
const CGFunctionInfo &FI =
CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args);
@@ -1709,7 +1705,7 @@
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
- Address src = GetAddrOfLocalVar(&srcDecl);
+ Address src = GetAddrOfLocalVar(&SrcDecl);
src = Address(Builder.CreateLoad(src), blockInfo.BlockAlign);
src = Builder.CreateBitCast(src, structPtrTy, "block");
@@ -1918,13 +1914,11 @@
QualType R = Context.VoidTy;
FunctionArgList args;
- ImplicitParamDecl dst(CGF.getContext(), nullptr, SourceLocation(), nullptr,
- Context.VoidPtrTy);
- args.push_back(&dst);
+ ImplicitParamDecl Dst(CGF.getContext(), Context.VoidPtrTy);
+ args.push_back(&Dst);
- ImplicitParamDecl src(CGF.getContext(), nullptr, SourceLocation(), nullptr,
- Context.VoidPtrTy);
- args.push_back(&src);
+ ImplicitParamDecl Src(CGF.getContext(), Context.VoidPtrTy);
+ args.push_back(&Src);
const CGFunctionInfo &FI =
CGF.CGM.getTypes().arrangeBuiltinFunctionDeclaration(R, args);
@@ -1955,15 +1949,15 @@
llvm::Type *byrefPtrType = byrefInfo.Type->getPointerTo(0);
// dst->x
- Address destField = CGF.GetAddrOfLocalVar(&dst);
+ Address destField = CGF.GetAddrOfLocalVar(&Dst);
destField = Address(CGF.Builder.CreateLoad(destField),
byrefInfo.ByrefAlignment);
destField = CGF.Builder.CreateBitCast(destField, byrefPtrType);
destField = CGF.emitBlockByrefAddress(destField, byrefInfo, false,
"dest-object");
// src->x
- Address srcField = CGF.GetAddrOfLocalVar(&src);
+ Address srcField = CGF.GetAddrOfLocalVar(&Src);
srcField = Address(CGF.Builder.CreateLoad(srcField),
byrefInfo.ByrefAlignment);
srcField = CGF.Builder.CreateBitCast(srcField, byrefPtrType);
@@ -1995,9 +1989,8 @@
QualType R = Context.VoidTy;
FunctionArgList args;
- ImplicitParamDecl src(CGF.getContext(), nullptr, SourceLocation(), nullptr,
- Context.VoidPtrTy);
- args.push_back(&src);
+ ImplicitParamDecl Src(CGF.getContext(), Context.VoidPtrTy);
+ args.push_back(&Src);
const CGFunctionInfo &FI =
CGF.CGM.getTypes().arrangeBuiltinFunctionDeclaration(R, args);
@@ -2026,7 +2019,7 @@
CGF.StartFunction(FD, R, Fn, FI, args);
if (generator.needsDispose()) {
- Address addr = CGF.GetAddrOfLocalVar(&src);
+ Address addr = CGF.GetAddrOfLocalVar(&Src);
addr = Address(CGF.Builder.CreateLoad(addr), byrefInfo.ByrefAlignment);
auto byrefPtrType = byrefInfo.Type->getPointerTo(0);
addr = CGF.Builder.CreateBitCast(addr, byrefPtrType);
Index: lib/AST/DeclObjC.cpp
===================================================================
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1070,20 +1070,20 @@
bool selfIsPseudoStrong, selfIsConsumed;
QualType selfTy =
getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
- ImplicitParamDecl *self
- = ImplicitParamDecl::Create(Context, this, SourceLocation(),
- &Context.Idents.get("self"), selfTy);
- setSelfDecl(self);
+ ImplicitParamDecl *Self = ImplicitParamDecl::Create(
+ Context, this, SourceLocation(), &Context.Idents.get("self"), selfTy,
+ ImplicitParamDecl::IPK_ObjCSelf);
+ setSelfDecl(Self);
if (selfIsConsumed)
- self->addAttr(NSConsumedAttr::CreateImplicit(Context));
+ Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
if (selfIsPseudoStrong)
- self->setARCPseudoStrong(true);
+ Self->setARCPseudoStrong(true);
- setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
- &Context.Idents.get("_cmd"),
- Context.getObjCSelType()));
+ setCmdDecl(ImplicitParamDecl::Create(
+ Context, this, SourceLocation(), &Context.Idents.get("_cmd"),
+ Context.getObjCSelType(), ImplicitParamDecl::IPK_ObjCCmd));
}
ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
Index: lib/AST/Decl.cpp
===================================================================
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -4107,15 +4107,18 @@
ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation IdLoc,
- IdentifierInfo *Id,
- QualType Type) {
- return new (C, DC) ImplicitParamDecl(C, DC, IdLoc, Id, Type);
+ IdentifierInfo *Id, QualType Type,
+ ImplicitParamKind ParamKind) {
+ return new (C, DC) ImplicitParamDecl(C, DC, IdLoc, Id, Type, ParamKind);
+}
+
+ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, QualType Type) {
+ return new (C, nullptr) ImplicitParamDecl(C, Type);
}
ImplicitParamDecl *ImplicitParamDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) ImplicitParamDecl(C, nullptr, SourceLocation(), nullptr,
- QualType());
+ return new (C, ID) ImplicitParamDecl(C, QualType());
}
FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2465,7 +2465,7 @@
ImplicitParamDecl *ToParm
= ImplicitParamDecl::Create(Importer.getToContext(), DC,
Loc, Name.getAsIdentifierInfo(),
- T);
+ T, D->getParameterKind());
return Importer.Imported(D, ToParm);
}
Index: include/clang/AST/Decl.h
===================================================================
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1375,21 +1375,58 @@
};
class ImplicitParamDecl : public VarDecl {
+public:
+ /// Defines the kind of the implicit parameter: is this an implicit parameter
+ /// with pointer to 'this', 'self' or something else.
+ enum ImplicitParamKind {
+ IPK_ObjCSelf, /// Parameter for Objective-C 'self' argument
+ IPK_ObjCCmd, /// Parameter for Objective-C '_cmd' argument
+ IPK_CXXThis, /// Parameter for C++ 'this' argument
+ IPK_CXXVTT, /// Parameter for C++ virtual table pointers
+ IPK_CapturedContext, /// Parameter for captured context
+ IPK_GeneralParam, /// General implicit parameter
+ };
+
+private:
+ friend class ASTDeclReader;
+
+ /// Whether this parameter represents implicit 'this'|'self' argument in
+ /// member functions.
+ ImplicitParamKind ParamKind;
void anchor() override;
+
public:
+ /// Create non-general implicit parameter.
static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation IdLoc, IdentifierInfo *Id,
- QualType T);
+ QualType T, ImplicitParamKind ParamKind);
+ /// Create general implicit parameter without name and source location.
+ static ImplicitParamDecl *Create(ASTContext &C, QualType T);
static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID);
ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc,
- IdentifierInfo *Id, QualType Type)
- : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
- /*tinfo*/ nullptr, SC_None) {
+ IdentifierInfo *Id, QualType Type,
+ ImplicitParamKind ParamKind)
+ : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
+ /*tinfo*/ nullptr, SC_None),
+ ParamKind(ParamKind) {
+ assert(ParamKind != IPK_GeneralParam &&
+ "Unexpected implicit parameter kind.");
+ setImplicit();
+ }
+
+ ImplicitParamDecl(ASTContext &C, QualType Type)
+ : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(),
+ SourceLocation(), /*Id=*/nullptr, Type,
+ /*tinfo*/ nullptr, SC_None),
+ ParamKind(IPK_GeneralParam) {
setImplicit();
}
+ /// Returns true if the parameter represents implicit 'this' or 'self'
+ /// argument in member functions.
+ ImplicitParamKind getParameterKind() const { return ParamKind; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == ImplicitParam; }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits