Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
8452c6a6
Commit
8452c6a6
authored
5 years ago
by
Sergey Linev
Browse files
Options
Downloads
Patches
Plain Diff
[metacling] provide method to check default constructor
parent
5ae3632b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/clingutils/res/TClingUtils.h
+4
-0
4 additions, 0 deletions
core/clingutils/res/TClingUtils.h
core/clingutils/src/TClingUtils.cxx
+22
-12
22 additions, 12 deletions
core/clingutils/src/TClingUtils.cxx
core/metacling/src/TClingClassInfo.cxx
+7
-11
7 additions, 11 deletions
core/metacling/src/TClingClassInfo.cxx
with
33 additions
and
23 deletions
core/clingutils/res/TClingUtils.h
+
4
−
0
View file @
8452c6a6
...
@@ -354,6 +354,10 @@ enum class EIOCtorCategory : short {kAbsent, kDefault, kIOPtrType, kIORefType, k
...
@@ -354,6 +354,10 @@ enum class EIOCtorCategory : short {kAbsent, kDefault, kIOPtrType, kIORefType, k
//______________________________________________________________________________
//______________________________________________________________________________
EIOCtorCategory
CheckConstructor
(
const
clang
::
CXXRecordDecl
*
,
const
RConstructorType
&
,
const
cling
::
Interpreter
&
interp
);
EIOCtorCategory
CheckConstructor
(
const
clang
::
CXXRecordDecl
*
,
const
RConstructorType
&
,
const
cling
::
Interpreter
&
interp
);
//______________________________________________________________________________
bool
CheckDefaultConstructor
(
const
clang
::
CXXRecordDecl
*
,
const
cling
::
Interpreter
&
interp
);
//______________________________________________________________________________
//______________________________________________________________________________
const
clang
::
FunctionDecl
*
ClassInfo__HasMethod
(
const
clang
::
DeclContext
*
cl
,
char
const
*
,
const
cling
::
Interpreter
&
interp
);
const
clang
::
FunctionDecl
*
ClassInfo__HasMethod
(
const
clang
::
DeclContext
*
cl
,
char
const
*
,
const
cling
::
Interpreter
&
interp
);
...
...
This diff is collapsed.
Click to expand it.
core/clingutils/src/TClingUtils.cxx
+
22
−
12
View file @
8452c6a6
...
@@ -987,6 +987,25 @@ int ROOT::TMetaUtils::ElementStreamer(std::ostream& finalString,
...
@@ -987,6 +987,25 @@ int ROOT::TMetaUtils::ElementStreamer(std::ostream& finalString,
return
0
;
return
0
;
}
}
////////////////////////////////////////////////////////////////////////////////
/// Checks if default constructor exists and accessible
bool
ROOT
::
TMetaUtils
::
CheckDefaultConstructor
(
const
clang
::
CXXRecordDecl
*
cl
,
const
cling
::
Interpreter
&
interpreter
)
{
clang
::
CXXRecordDecl
*
ncCl
=
const_cast
<
clang
::
CXXRecordDecl
*>
(
cl
);
// We may induce template instantiation
cling
::
Interpreter
::
PushTransactionRAII
clingRAII
(
const_cast
<
cling
::
Interpreter
*>
(
&
interpreter
));
if
(
auto
*
Ctor
=
interpreter
.
getCI
()
->
getSema
().
LookupDefaultConstructor
(
ncCl
))
{
if
(
Ctor
->
getAccess
()
==
clang
::
AS_public
&&
!
Ctor
->
isDeleted
())
{
return
true
;
}
}
return
false
;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
ROOT
::
TMetaUtils
::
EIOCtorCategory
ROOT
::
TMetaUtils
::
CheckConstructor
(
const
clang
::
CXXRecordDecl
*
cl
,
ROOT
::
TMetaUtils
::
EIOCtorCategory
ROOT
::
TMetaUtils
::
CheckConstructor
(
const
clang
::
CXXRecordDecl
*
cl
,
...
@@ -995,19 +1014,10 @@ ROOT::TMetaUtils::EIOCtorCategory ROOT::TMetaUtils::CheckConstructor(const clang
...
@@ -995,19 +1014,10 @@ ROOT::TMetaUtils::EIOCtorCategory ROOT::TMetaUtils::CheckConstructor(const clang
{
{
const
char
*
arg
=
ioctortype
.
GetName
();
const
char
*
arg
=
ioctortype
.
GetName
();
if
(
ioctortype
.
GetType
()
==
0
&&
(
arg
==
0
||
arg
[
0
]
==
'\0'
))
{
if
(
ioctortype
.
GetType
()
==
nullptr
&&
(
arg
==
0
||
arg
[
0
]
==
'\0'
))
{
// We are looking for a constructor with zero non-default arguments.
// We are looking for a constructor with zero non-default arguments.
clang
::
CXXRecordDecl
*
ncCl
=
const_cast
<
clang
::
CXXRecordDecl
*>
(
cl
);
// We may induce template instantiation
cling
::
Interpreter
::
PushTransactionRAII
clingRAII
(
const_cast
<
cling
::
Interpreter
*>
(
&
interpreter
));
if
(
auto
*
Ctor
=
interpreter
.
getCI
()
->
getSema
().
LookupDefaultConstructor
(
ncCl
))
{
return
CheckDefaultConstructor
(
cl
,
interpreter
)
?
EIOCtorCategory
::
kDefault
:
EIOCtorCategory
::
kAbsent
;
if
(
Ctor
->
getAccess
()
==
clang
::
AS_public
&&
!
Ctor
->
isDeleted
())
{
return
EIOCtorCategory
::
kDefault
;
}
}
return
EIOCtorCategory
::
kAbsent
;
}
}
for
(
auto
iter
=
cl
->
ctor_begin
(),
end
=
cl
->
ctor_end
();
for
(
auto
iter
=
cl
->
ctor_begin
(),
end
=
cl
->
ctor_end
();
...
@@ -1075,7 +1085,7 @@ const clang::CXXMethodDecl *GetMethodWithProto(const clang::Decl* cinfo,
...
@@ -1075,7 +1085,7 @@ const clang::CXXMethodDecl *GetMethodWithProto(const clang::Decl* cinfo,
namespace
ROOT
{
namespace
ROOT
{
namespace
TMetaUtils
{
namespace
TMetaUtils
{
RConstructorType
::
RConstructorType
(
const
char
*
type_of_arg
,
const
cling
::
Interpreter
&
interp
)
:
fArgTypeName
(
type_of_arg
),
fArgType
(
0
)
RConstructorType
::
RConstructorType
(
const
char
*
type_of_arg
,
const
cling
::
Interpreter
&
interp
)
:
fArgTypeName
(
type_of_arg
),
fArgType
(
nullptr
)
{
{
const
cling
::
LookupHelper
&
lh
=
interp
.
getLookupHelper
();
const
cling
::
LookupHelper
&
lh
=
interp
.
getLookupHelper
();
// We can not use findScope since the type we are given are usually,
// We can not use findScope since the type we are given are usually,
...
...
This diff is collapsed.
Click to expand it.
core/metacling/src/TClingClassInfo.cxx
+
7
−
11
View file @
8452c6a6
...
@@ -684,21 +684,17 @@ ROOT::TMetaUtils::EIOCtorCategory TClingClassInfo::HasDefaultConstructor(bool ch
...
@@ -684,21 +684,17 @@ ROOT::TMetaUtils::EIOCtorCategory TClingClassInfo::HasDefaultConstructor(bool ch
if
(
!
CRD
)
if
(
!
CRD
)
return
EIOCtorCategory
::
kAbsent
;
return
EIOCtorCategory
::
kAbsent
;
const
RConstructorType
ioctortype_dflt
(
""
,
*
fInterp
);
if
(
checkio
)
{
auto
kind
=
CheckConstructor
(
CRD
,
ioctortype_dflt
,
*
fInterp
);
if
(
checkio
&&
(
kind
==
EIOCtorCategory
::
kAbsent
))
{
const
RConstructorType
ioctortype_io
(
"TRootIOCtor"
,
*
fInterp
);
const
RConstructorType
ioctortype_io
(
"TRootIOCtor"
,
*
fInterp
);
kind
=
CheckConstructor
(
CRD
,
ioctortype_io
,
*
fInterp
);
auto
kind
=
CheckConstructor
(
CRD
,
ioctortype_io
,
*
fInterp
);
if
(
kind
!=
EIOCtorCategory
::
kAbsent
)
return
kind
;
if
(
kind
==
EIOCtorCategory
::
kAbsent
)
{
const
RConstructorType
ioctortype_io2
(
"__void__"
,
*
fInterp
);
const
RConstructorType
ioctortype_io2
(
"__void__"
,
*
fInterp
);
if
(
CheckConstructor
(
CRD
,
ioctortype_io2
,
*
fInterp
)
==
EIOCtorCategory
::
kIORefType
)
if
(
CheckConstructor
(
CRD
,
ioctortype_io2
,
*
fInterp
)
==
EIOCtorCategory
::
kIORefType
)
return
EIOCtorCategory
::
kIOVoidType
;
kind
=
EIOCtorCategory
::
kIOVoidType
;
}
}
}
return
kind
;
return
CheckDefaultConstructor
(
CRD
,
*
fInterp
)
?
EIOCtorCategory
::
kDefault
:
EIOCtorCategory
::
kAbsent
;
}
}
bool
TClingClassInfo
::
HasMethod
(
const
char
*
name
)
const
bool
TClingClassInfo
::
HasMethod
(
const
char
*
name
)
const
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment