List Info

Thread: Re: Definition/Declaration/Use usage




Re: Definition/Declaration/Use usage
country flaguser name
Germany
2007-08-28 08:50:26
"int i" is a Declaration ,and a Definition, so 
Declaration::declarationIsDefinition() returns true

"i = 2" The first part, the "i" is a Use
of the Declaration above
"int j = i+1;" The first part is a
Declaration+Definition of "j", the "i"
is a 
use of the Declaration above.

The only cases where a Declaration is not a Definition in
C++ is in case of 
functions declared without definition. That's the only use
of 
the "Definition" class in C++.


To the redeclaration:
The du-chain can contain as many declarations of a name as
you wish, it 
probably just isn't useful.

As I've written to Aleix, the most logical solution would
be:
- Always test if the variable is already declared by using
findDeclarations.
  - If it is, create a Use.
  - If it is not, create a Declaration.

That way foo=myobject1() would be a declaration, and
foo=myobject2() would be 
a use.

It of course depends on the language whether it's logical.

You could also simply create declarations all the time, and
always only use 
the last declaration found. That might make the du-chain
significantly slower 
and bigger though, depends on the amout of duplication.

greetings, David

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Definition/Declaration/Use usage
user name
2007-08-28 09:22:31
On 28.08.07 15:50:26, David Nolden wrote:
> To the redeclaration:
> The du-chain can contain as many declarations of a name
as you wish, it 
> probably just isn't useful.
> 
> As I've written to Aleix, the most logical solution
would be:
> - Always test if the variable is already declared by
using findDeclarations.
>   - If it is, create a Use.
>   - If it is not, create a Declaration.
> 
> That way foo=myobject1() would be a declaration, and
foo=myobject2() would be 
> a use.
> 
> It of course depends on the language whether it's
logical.

Well, the reason why I'm thinking about having
"re-declaration" is that
this variable may change its type. Now I don't have the API
docs at hand
at the moment, but doesn't the declaration carry the type of
the
declared entity (i.e. variable)? Or is that completely
separated?

Andreas

-- 
You will meet an important person who will help you advance
professionally.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )