Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
2679a884
Commit
2679a884
authored
15 years ago
by
Daniel Dunbar
Browse files
Options
Downloads
Patches
Plain Diff
Move a function which returns a class outside of extern C scope.
llvm-svn: 86439
parent
a7979467
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
clang/tools/CIndex/CIndex.cpp
+64
-65
64 additions, 65 deletions
clang/tools/CIndex/CIndex.cpp
with
64 additions
and
65 deletions
clang/tools/CIndex/CIndex.cpp
+
64
−
65
View file @
2679a884
...
...
@@ -353,6 +353,70 @@ const llvm::sys::Path& CIndexer::getClangPath() {
}
static
SourceLocation
getLocationFromCursor
(
CXCursor
C
,
SourceManager
&
SourceMgr
,
NamedDecl
*
ND
)
{
if
(
clang_isReference
(
C
.
kind
))
{
switch
(
C
.
kind
)
{
case
CXCursor_ObjCClassRef
:
{
if
(
isa
<
ObjCInterfaceDecl
>
(
ND
))
{
// FIXME: This is a hack (storing the parent decl in the stmt slot).
NamedDecl
*
parentDecl
=
static_cast
<
NamedDecl
*>
(
C
.
stmt
);
return
parentDecl
->
getLocation
();
}
ObjCCategoryDecl
*
OID
=
dyn_cast
<
ObjCCategoryDecl
>
(
ND
);
assert
(
OID
&&
"clang_getCursorLine(): Missing category decl"
);
return
OID
->
getClassInterface
()
->
getLocation
();
}
case
CXCursor_ObjCSuperClassRef
:
{
ObjCInterfaceDecl
*
OID
=
dyn_cast
<
ObjCInterfaceDecl
>
(
ND
);
assert
(
OID
&&
"clang_getCursorLine(): Missing interface decl"
);
return
OID
->
getSuperClassLoc
();
}
case
CXCursor_ObjCProtocolRef
:
{
ObjCProtocolDecl
*
OID
=
dyn_cast
<
ObjCProtocolDecl
>
(
ND
);
assert
(
OID
&&
"clang_getCursorLine(): Missing protocol decl"
);
return
OID
->
getLocation
();
}
case
CXCursor_ObjCSelectorRef
:
{
ObjCMessageExpr
*
OME
=
dyn_cast
<
ObjCMessageExpr
>
(
static_cast
<
Stmt
*>
(
C
.
stmt
));
assert
(
OME
&&
"clang_getCursorLine(): Missing message expr"
);
return
OME
->
getLeftLoc
();
/* FIXME: should be a range */
}
case
CXCursor_VarRef
:
case
CXCursor_FunctionRef
:
case
CXCursor_EnumConstantRef
:
{
DeclRefExpr
*
DRE
=
dyn_cast
<
DeclRefExpr
>
(
static_cast
<
Stmt
*>
(
C
.
stmt
));
assert
(
DRE
&&
"clang_getCursorLine(): Missing decl ref expr"
);
return
DRE
->
getLocation
();
}
default
:
return
SourceLocation
();
}
}
else
{
// We have a declaration or a definition.
SourceLocation
SLoc
;
switch
(
ND
->
getKind
())
{
case
Decl
::
ObjCInterface
:
{
SLoc
=
dyn_cast
<
ObjCInterfaceDecl
>
(
ND
)
->
getClassLoc
();
break
;
}
case
Decl
::
ObjCProtocol
:
{
SLoc
=
ND
->
getLocation
();
/* FIXME: need to get the name location. */
break
;
}
default
:
{
SLoc
=
ND
->
getLocation
();
break
;
}
}
if
(
SLoc
.
isInvalid
())
return
SourceLocation
();
return
SourceMgr
.
getSpellingLoc
(
SLoc
);
// handles macro instantiations.
}
}
extern
"C"
{
CXIndex
clang_createIndex
(
int
excludeDeclarationsFromPCH
,
...
...
@@ -862,71 +926,6 @@ CXDecl clang_getCursorDecl(CXCursor C)
return
0
;
}
static
SourceLocation
getLocationFromCursor
(
CXCursor
C
,
SourceManager
&
SourceMgr
,
NamedDecl
*
ND
)
{
if
(
clang_isReference
(
C
.
kind
))
{
switch
(
C
.
kind
)
{
case
CXCursor_ObjCClassRef
:
{
if
(
isa
<
ObjCInterfaceDecl
>
(
ND
))
{
// FIXME: This is a hack (storing the parent decl in the stmt slot).
NamedDecl
*
parentDecl
=
static_cast
<
NamedDecl
*>
(
C
.
stmt
);
return
parentDecl
->
getLocation
();
}
ObjCCategoryDecl
*
OID
=
dyn_cast
<
ObjCCategoryDecl
>
(
ND
);
assert
(
OID
&&
"clang_getCursorLine(): Missing category decl"
);
return
OID
->
getClassInterface
()
->
getLocation
();
}
case
CXCursor_ObjCSuperClassRef
:
{
ObjCInterfaceDecl
*
OID
=
dyn_cast
<
ObjCInterfaceDecl
>
(
ND
);
assert
(
OID
&&
"clang_getCursorLine(): Missing interface decl"
);
return
OID
->
getSuperClassLoc
();
}
case
CXCursor_ObjCProtocolRef
:
{
ObjCProtocolDecl
*
OID
=
dyn_cast
<
ObjCProtocolDecl
>
(
ND
);
assert
(
OID
&&
"clang_getCursorLine(): Missing protocol decl"
);
return
OID
->
getLocation
();
}
case
CXCursor_ObjCSelectorRef
:
{
ObjCMessageExpr
*
OME
=
dyn_cast
<
ObjCMessageExpr
>
(
static_cast
<
Stmt
*>
(
C
.
stmt
));
assert
(
OME
&&
"clang_getCursorLine(): Missing message expr"
);
return
OME
->
getLeftLoc
();
/* FIXME: should be a range */
}
case
CXCursor_VarRef
:
case
CXCursor_FunctionRef
:
case
CXCursor_EnumConstantRef
:
{
DeclRefExpr
*
DRE
=
dyn_cast
<
DeclRefExpr
>
(
static_cast
<
Stmt
*>
(
C
.
stmt
));
assert
(
DRE
&&
"clang_getCursorLine(): Missing decl ref expr"
);
return
DRE
->
getLocation
();
}
default
:
return
SourceLocation
();
}
}
else
{
// We have a declaration or a definition.
SourceLocation
SLoc
;
switch
(
ND
->
getKind
())
{
case
Decl
::
ObjCInterface
:
{
SLoc
=
dyn_cast
<
ObjCInterfaceDecl
>
(
ND
)
->
getClassLoc
();
break
;
}
case
Decl
::
ObjCProtocol
:
{
SLoc
=
ND
->
getLocation
();
/* FIXME: need to get the name location. */
break
;
}
default
:
{
SLoc
=
ND
->
getLocation
();
break
;
}
}
if
(
SLoc
.
isInvalid
())
return
SourceLocation
();
return
SourceMgr
.
getSpellingLoc
(
SLoc
);
// handles macro instantiations.
}
}
unsigned
clang_getCursorLine
(
CXCursor
C
)
{
assert
(
C
.
decl
&&
"CXCursor has null decl"
);
...
...
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