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
a150b147
Commit
a150b147
authored
10 years ago
by
Vassil Vassilev
Browse files
Options
Downloads
Patches
Plain Diff
Extract out common implementation.
parent
3b3c5a26
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
interpreter/cling/lib/Interpreter/Value.cpp
+21
-31
21 additions, 31 deletions
interpreter/cling/lib/Interpreter/Value.cpp
with
21 additions
and
31 deletions
interpreter/cling/lib/Interpreter/Value.cpp
+
21
−
31
View file @
a150b147
...
...
@@ -262,6 +262,25 @@ void* Value::GetDtorWrapperPtr(const clang::RecordDecl* RD) const {
false
/*withAccessControl*/
);
}
static
bool
hasViableCandidateToCall
(
clang
::
LookupResult
&
R
,
clang
::
QualType
Ty
)
{
using
namespace
clang
;
ASTContext
&
C
=
R
.
getSema
().
getASTContext
();
if
(
!
R
.
empty
()
&&
Ty
->
isPointerType
())
{
// Check if among the candidates there are functions with the same type:
const
UnresolvedSetImpl
&
unresolved
=
R
.
asUnresolvedSet
();
// FIXME: Find a way to use the 'proper' overload checks.
for
(
UnresolvedSetImpl
::
const_iterator
I
=
unresolved
.
begin
(),
E
=
unresolved
.
end
();
I
<
E
;
++
I
)
{
if
(
FunctionDecl
*
FD
=
dyn_cast
<
FunctionDecl
>
(
*
I
))
if
(
C
.
hasSameUnqualifiedType
(
FD
->
getParamDecl
(
0
)
->
getType
(),
Ty
))
return
true
;
}
}
return
false
;
}
void
Value
::
print
(
llvm
::
raw_ostream
&
Out
)
const
{
// Try to find user defined printing functions:
// cling::printType(const void* const p, TY* const u, const Value& V) and
...
...
@@ -288,22 +307,7 @@ void* Value::GetDtorWrapperPtr(const clang::RecordDecl* RD) const {
std
::
string
typeStr
;
std
::
string
valueStr
;
bool
hasViablePrintTypeCandidate
=
false
;
if
(
!
R
.
empty
()
&&
ValueTy
->
isPointerType
())
{
// Check if among the candidates there are functions with the same type:
const
UnresolvedSetImpl
&
unresolved
=
R
.
asUnresolvedSet
();
// FIXME: Find a way to use the 'proper' overload checks.
for
(
UnresolvedSetImpl
::
const_iterator
I
=
unresolved
.
begin
(),
E
=
unresolved
.
end
();
I
<
E
;
++
I
)
{
if
(
FunctionDecl
*
FD
=
dyn_cast
<
FunctionDecl
>
(
*
I
))
if
(
C
.
hasSameUnqualifiedType
(
FD
->
getParamDecl
(
0
)
->
getType
(),
ValueTy
)){
hasViablePrintTypeCandidate
=
true
;
break
;
}
}
}
if
(
hasViablePrintTypeCandidate
)
{
if
(
hasViableCandidateToCall
(
R
,
ValueTy
))
{
// There is such a routine call it:
std
::
stringstream
printTypeSS
;
printTypeSS
<<
"cling::printType("
;
...
...
@@ -357,21 +361,7 @@ void* Value::GetDtorWrapperPtr(const clang::RecordDecl* RD) const {
// will be needed by evaluate.
}
bool
hasViablePrintValueCandidate
=
false
;
if
(
!
R
.
empty
()
&&
ValueTy
->
isPointerType
())
{
// Check if among the candidates there are functions with the same type:
const
UnresolvedSetImpl
&
unresolved
=
R
.
asUnresolvedSet
();
// FIXME: Find a way to use the 'proper' overload checks.
for
(
UnresolvedSetImpl
::
const_iterator
I
=
unresolved
.
begin
(),
E
=
unresolved
.
end
();
I
<
E
;
++
I
)
{
if
(
FunctionDecl
*
FD
=
dyn_cast
<
FunctionDecl
>
(
*
I
))
if
(
C
.
hasSameUnqualifiedType
(
FD
->
getParamDecl
(
0
)
->
getType
(),
ValueTy
)){
hasViablePrintValueCandidate
=
true
;
break
;
}
}
}
if
(
hasViablePrintValueCandidate
)
{
if
(
hasViableCandidateToCall
(
R
,
ValueTy
))
{
// There is such a routine call it:
std
::
stringstream
printValueSS
;
printValueSS
<<
"cling::printValue("
;
...
...
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