Appendix A Entity and Reference Kinds

## C Reference Kinds

This section lists the general categories of C/C++ reference kinds (and their inverse relations).

The following sections provide details for related groups of C/C++ reference kinds. Each grouping includes both "forward" and "backward" references (call and callby, for example).

Each group of reference kinds is presented in a table format, showing the fullname, the literal name, and from the provided code samples, the entity performing the reference (scope) and the entity being referenced. The scope and entity noted are the entities returned by calls to udbReferenceScope() and udbReferenceEntity(), respectively.

### C Base and Derive Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Private Base | Udb_cPrivateBase | D | B
C Private Derive | Udb_cPrivateDerive | B | D
C Protected Base | Udb_cProtectedBase | D | B
C Protected Derive | Udb_cProtectedDerive | B | D
C Public Base | Udb_cPublicBase | D | B
C Public Derive | Udb_cPublicDerive | B | D
C Virtual Private Base | Udb_cVirtualPrivateBase | D | V
C Virtual Private Derive | Udb_cVirtualPrivateDerive | V | D
C Virtual Protected Base | Udb_cVirtualProtectedBase | D | V
C Virtual Protected Derive | Udb_cVirtualProtectedDerive | V | D
C Virtual Public Base | Udb_cVirtualPublicBase | D | V
C Virtual Public Derive | Udb_cVirtualPublicDerive | V | D

Base and Derive reference kinds may be public, protected, or private. Only public code samples are shown here. The following code sample illustrates class D which is derived from base class B. The public declaration indicates that all public functionality of class B can be accessed from class D.

     class D : public B{
     ...
     };

A base class may also be virtual. Again, only public derivation is shown here. V is the virtual base class from which D is derived.

     class  V {
       public:
         virtual void f();
         virtual void g();
     };

     class D : virtual public V{
       public:
         virtual void g();
     };

### C Call and Callby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference | Entity being referenced
C Asm Call | Udb_cAsmCall | func | func1
C Asm Callby | Udb_cAsmCallby | func1 | func
C Call | Udb_cCall | func | func1
C Callby | Udb_cCallby | func1 | func
C Inactive Call | Udb_cInactiveCall | func | func1
C Inactive Callby | Udb_cInactiveCallby | func1 | func

Asm Call and Asm Callby indicates a reference in assembly code to a known C/C++ function. The function's name must already be declared at the point of the usage.

     extern int func1();
     int func() {
        _asm op1 _func1;
        _asm op1 _func2;
     }

Call and Callby reference kinds indicate a reference to a known C/C++ function. The function's name must already be declared at the point of the usage.

     extern int func1(void);
     int func() {
        func1();
        func2();
     }

Inactive Call or Inactive Callby reference kinds indicate a reference to a known C/C++ function in an inactive region of code.

     int func() {
     #if 0
        func1();
     #endif
     }

### C Declare and Declarein Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Declare | Udb_cDeclare | func | i
C Declarein | Udb_cDeclarein | file.c | ext_func

Declare and Declarein reference kinds indicate the declaration of an entity.

     extern int ext_func( char ) ;
     int func (void) {
       int i;
       ...
     }

### C Define and Definein Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Define | Udb_cDefine | ifile.c func func | func c i
C Definein | Udb_cDefinein | func c i | file.c func func

Define and Definein reference kinds indicate the definition of an entity.

     int func (char c) {
       int i;
       ...
     }

### C Friend and Friendby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Friend | Udb_cFriend | C | F
C Friendby | Udb_cFriendby | F | C

Friend and Friendby reference kinds indicate the granting of friendship to a class or member function.

A friend class:

     class C {
       public:
       private:
          friend class F;
     };

A friend function:

     class F {
       public:
        void f();
     };

     class C {
       public:
       private:
         friend void F::f();
     };

### C Include and Includeby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Include | Udb_cInclude | file.c | my_includes.h
C Includeby | Udb_cIncludeby | my_includes.h | file.c

Include and Includeby references indicate a reference to an include file.

     #include "my_includes.h"

### C Modify and Modifyby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Modify | Udb_cModify | func | i
C Modifyby | Udb_cModifyby | i | func

A Modify or Modifyby indicates a reference where a variable is modified without an explicit assignment statement. The variable is both used and set at the same reference location.

     int func(int i) {
       i++;            // modify
       ...}

### C Set and Setby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Set | Udb_cSet | func func | i j
C Setby | Udb_cSetby | i j | func func

A Set or Setby reference indicates any explicit assignment of a variable.

     int func(int i) {
       int j;
       i = i + 1;      // i is both use and set
       j = i;          // j is set, i is use
     }

### C Typed and Typedby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Typed | Udb_cTyped | b | BYTE
C Typedby | Udb_cTypedby | BYTE | b

A Typed or Typedby reference indicates a reference to a known typedef variable.

     typedef unsigned char   BYTE;
     BYTE b;

### C Use and Useby Kinds

Reference KIND FULlName | Reference Kind LITERAL name | Scope (entity performing reference) | Entity being referenced
C Asm Use | Udb_cAsmUse | func | var1
C Asm Useby | Udb_cAsmUseby | var1 | func
C Inactive Use | Udb_cInactiveUse | func | var1
C Inactive Useby | Udb_cInactiveUseby | var1 | func
C Use | Udb_cUse | func | var1
C Useby | Udb_cUseby | var1 | func
C Use Ptr | Udb_cUsePtr | main_func | funcCB
C Useby Ptr | Udb_cUsebyPtr | funcCB | main_func

Asm Use and Asm Useby indicates a reference in assembly code to a known C/C++ variable. The variable's name must already be declared at the point of the usage.

     extern int var1;
     int func() {
        _asm op1 _var1;   // var1 is known; use
        _asm op1 _var2;   // var2 is not known; not a use
     }

Inactive Use and Inactive Useby indicates a reference in an inactive region of code to a known C/C++ variable. The variable's name must already be declared at the point of the usage.

     extern int var1;
     int func() {
        int local_var;
     #if 0
        local_var = var1;  // inactive use of var1
     #endif
     }

An ordinary Use or Useby indicates a reference in an active region of (non-assembler) code to a known C/C++ variable. The variable's name must already be declared at the point of the usage.

     extern int var1;
     int func() {
        int local_var;
        local_var = var1;  // use of var1
     }

An Use Ptr or Useby Ptr indicates a reference to a known function pointer.

     extern int funcCB (int);
     static void func2( int(*)() );

     void func2(int(*)() cb) {
       (void)cb(1);
       return;
     }
     int main_func() {
        func2(funcCB);   // both Use Ptr and Useby Ptr
     }

Scientific Toolworks, Inc. http://www.scitools.com Voice: (802) 763-2995 Fax: (802) 763-3066 support@scitools.com sales@scitools.com