Author Topic: C++ References (Ctrl-/)  (Read 8581 times)

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
C++ References (Ctrl-/)
« on: October 11, 2006, 03:40:14 pm »
Sometimes it almost feels like Slick is doing a "Find in Files" with the "Match case" / " Match Word" options rather than searching for actual references to a symbol.

For instance, I've got an interface with:

interface Stuff {
   ...
   HRESULT Save(Args);
};

...

value->Save(blah);

I went to "Save", Press Ctrl-/, and off it went.  But some of the matches it gave me were odd, for instance these matched:

interface OtherStuffDoesNotDeriveFromStuff {
   HRESULT Save(DifferentArgs);
};

Had several instances of the above, since "Save" is a very common name in the interfaces I'm dealing with today.

interface YetAnotherInterface {
...
  HRESULT EndEdit([in]VARIANT_BOOL Save);
...
};

Just some nitpicking on a rainy Wednesday, at least here :)

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2326
  • Hero Points: 307
Re: C++ References (Ctrl-/)
« Reply #1 on: October 12, 2006, 02:12:22 pm »
1) I will have to investigate this [in] attribute syntax.  This is causing the definition of "EndEdit()" to be parsed incorrectly.  Yippee, another non-standard Visual C++ language extension.  What version of VC++ are you using?

2) Are you sure the other declarations of "Save()" were parsed correctly?  I suppose it's safe to assume that you are using quite a bit of preprocessing in this code.  Go to the "Defs" tab and switch to "Sort by line numbers" and verify that the declarations were parsed as you expect.

3) How is "value" declared?  The references engine tries to do the right thing in terms of symbol analysis, but if (because of preprocessing), we can not parse the declaration of a symbol, it's pretty impossible to ascertain it's type.  This is what I expect is happening here, you are asking for references to Save(), but we have never heard of "value" or the type of "value" because the real C++ is washed out by preprocessing, so we do the best we can and show you all the "fuzzy" matches on Save we can find.  Something to look for, if a reference is marked with a question mark, it's because our tagging engine wasn't sure about it.

hs2

  • Senior Community Member
  • Posts: 2732
  • Hero Points: 284
Re: C++ References (Ctrl-/)
« Reply #2 on: October 12, 2006, 04:46:32 pm »
Hello Dennis,

dunno the 'braced' version of  [in], but have a look here:
http://windowssdk.msdn.microsoft.com/en-us/library/aa383701.aspx
and you could read sth. about 'Standard Annotation Language (SAL)'. Standard ?? Yes, M$ Standard !!
I think that every newly created public M$ header contains that.
E.g. the KMDF - WDK headers using this notation and especially there it really makes sense (also used by code analyzer/verifier).
Besides the 'native' notation ('_in') there are - of course - further macro-macros ('IN') ...
Isn't it great ?
Unfortunately I've to issue a 'request for implemenation' b/c it's standard and it's there...

HS2

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2326
  • Hero Points: 307
Re: C++ References (Ctrl-/)
« Reply #3 on: October 12, 2006, 06:08:47 pm »
It may be preferable in this case to use the "IN" macro instead of the un-C++ syntax [in], because then you could just set up the preprocessing to define "IN" to the empty string in SlickEdit and you would be able to work around some of the parsing problems (in your own code, at least).  I will file a feature request to support the goofy bracketted syntax.

hs2

  • Senior Community Member
  • Posts: 2732
  • Hero Points: 284
Re: C++ References (Ctrl-/)
« Reply #4 on: October 12, 2006, 06:45:07 pm »
Thanks a lot Dennis !
Until now I was just too lazy adding the dummy macros.
When I had tiny problems w/ that (tagging) I was in much more urgent/important troubles.
(my 'find-word-or-selection-in-project' macro did it anyway)
Maybe next time when it' s raining...

I didn't found any ref. to the goofy [in] - is it std. or not ?

HS2

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
Re: C++ References (Ctrl-/)
« Reply #5 on: October 12, 2006, 07:21:35 pm »
Dennis, hs2

[in] ain't C++ standard, but it's standard IDL, and it looks like SE decided to parse that.  :)

I'll check for the other two questions when I've put out the fires...

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
Re: C++ References (Ctrl-/)
« Reply #6 on: October 13, 2006, 02:23:16 pm »
Denis,

There are indeed quite a few "?" in the tagging symbols.  For instance, for these:

        virtual HRESULT STDMETHODCALLTYPE Save(
            /* [in] */ Structure __RPC_FAR *Parameters) = 0;

        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Save )(
            DataDocument __RPC_FAR * This,
            /* [in] */ Structure __RPC_FAR *Parameters);

I've tried adding defines for:

HRESULT -> "unsigned long"
STDMETHODCALLTYPE -> ""
__RPC_FAR -> ""

and it still shows up as empty.  (STDMETHODCALLTYPE should be __stdcall, but it's not like it matters much for this)

In fact, I must have something horrendously wrong with my setup, because the 2nd instance above shouldn't even have been listed in the references, as it's actually layout in a header file like this:

#if defined(__cplusplus) && !defined(CINTERFACE)
   ... first instance
#else
   ... second instance
#endif

Under C preprocessing, I've got __cplusplus set to 1, and CINTERFACE set to 'undef'

Steph

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
Re: C++ References (Ctrl-/)
« Reply #7 on: October 13, 2006, 11:10:59 pm »
Dennis,

Another instance of weird reference matchings.  Maybe I don't quite grasp what a 'reference' is supposed to be...  This time I don't think there are any funny things going on:

struct CFooStruct
{
   BSTRInstance   foo1;
   BSTRInstance   foo2;
   BSTRInstance   foo3;

   BSTRInstance   shelfCode;   
   bool           boFoo;

   inline CFooStruct() : boFoo(true) {}
};

this one of the matches that came up:

class CSomeDataClass : public CSomeOtherClass  // unrelated to CFooStruct
{
public:
...
   HRESULT GetStuff(const BSTRInstance& key,
      const BSTRInstance& shelfCode, bool* pboOptDone) const;
...
};

Is it supposed to match the argument name, even though it's definitely not a reference to CFooStruct.shelfCode?

BTW, they're in the same header file, and I don't see any "?".  HRESULT is defined as "unsigned long" in the C Preprocessing options, and BSTRInstance is a class with no base class, or funky macros.

Steph.

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
Re: C++ References (Ctrl-/)
« Reply #8 on: October 24, 2006, 04:24:47 pm »
ping.

So, am I using the feature wrong?  Is there anything else I can do to help pinpoint the problem, if it is a problem?

Stephane

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2326
  • Hero Points: 307
Re: C++ References (Ctrl-/)
« Reply #9 on: October 25, 2006, 12:07:49 am »
Hi,

I have finally made my way around to this, and verified that both test cases were indeed bugs in 11.0.2.  THANK YOU for reporting these -- good test cases make a world of difference.  I also fixed another test case which had been irritating me (see below).  A hotfix for 11.0.2 will be available through SlickEdit support tomorrow.

int mint;
#define DOUBLEMINT(mint)  (mint+mint)
int byGum() {
   return mint;
}

--Dennis

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
Re: C++ References (Ctrl-/)
« Reply #10 on: October 25, 2006, 02:04:47 pm »
Wow, excellent news.  I wasn't expecting a hotfix hot for it, something for 12.0 or 11.0.3, but hey if you've got it, I'll take it :)

Thanks Dennis

srouleau

  • Community Member
  • Posts: 68
  • Hero Points: 4
Re: C++ References (Ctrl-/)
« Reply #11 on: October 27, 2006, 11:24:42 pm »
Dennis,

I've installed the hotfix and briefly played around with it.  Aside from the [in] notation of IDL files, which I wasn't expecting to be fixed anyway, all occurences of this Ctrl-/ problem I've reported appear to have been fixed.

Good work man, have a hero point on me!

hs2

  • Senior Community Member
  • Posts: 2732
  • Hero Points: 284
Re: C++ References (Ctrl-/)
« Reply #12 on: October 28, 2006, 08:33:06 pm »
/signed (and my HP++)

HS2