Doxygen
Loading...
Searching...
No Matches
symbolresolver.cpp File Reference
#include <unordered_map>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include "symbolresolver.h"
#include "util.h"
#include "doxygen.h"
#include "namespacedef.h"
#include "config.h"
#include "defargs.h"
#include "trace.h"
Include dependency graph for symbolresolver.cpp:

Go to the source code of this file.

Classes

struct  CacheStatistics
struct  CacheStatsWrapper
class  AccessStack
 Helper class representing the stack of items considered while resolving the scope. More...
struct  AccessStack::AccessElem
 Element in the stack. More...
struct  SymbolResolver::Private

Macros

#define AUTO_TRACE(...)
#define AUTO_TRACE_ADD(...)
#define AUTO_TRACE_EXIT(...)

Typedefs

using LookupCache = Cache<std::string,LookupInfo>
using VisitedKeys = StringVector
using VisitedNamespaceKeys = StringVector
using VisitedNamespaces = std::unordered_map<std::string,const Definition *>

Functions

static void mergeStatistics (CacheStatistics &stats, LookupCache &cache)
static size_t getCacheSize ()
static LookupCachegetTypeLookupCache ()
static LookupCachegetSymbolLookupCache ()
static bool isCodeSymbol (Definition::DefType defType)
static int computeIdealCacheParam (size_t v)

Variables

static std::recursive_mutex g_cacheTypedefMutex
static CacheStatistics g_typeCacheStatistics
static CacheStatistics g_symbolCacheStatistics
THREAD_LOCAL std::unordered_map< std::string, std::pair< QCString, const MemberDef * > > g_substMap

Macro Definition Documentation

◆ AUTO_TRACE

#define AUTO_TRACE ( ...)
Value:
(void)0

Definition at line 34 of file symbolresolver.cpp.

◆ AUTO_TRACE_ADD

#define AUTO_TRACE_ADD ( ...)
Value:
(void)0

Definition at line 35 of file symbolresolver.cpp.

◆ AUTO_TRACE_EXIT

#define AUTO_TRACE_EXIT ( ...)
Value:
(void)0

Definition at line 36 of file symbolresolver.cpp.

Typedef Documentation

◆ LookupCache

using LookupCache = Cache<std::string,LookupInfo>

Definition at line 53 of file symbolresolver.cpp.

◆ VisitedKeys

Definition at line 163 of file symbolresolver.cpp.

◆ VisitedNamespaceKeys

Definition at line 164 of file symbolresolver.cpp.

◆ VisitedNamespaces

using VisitedNamespaces = std::unordered_map<std::string,const Definition *>

Definition at line 165 of file symbolresolver.cpp.

Function Documentation

◆ computeIdealCacheParam()

int computeIdealCacheParam ( size_t v)
static

Definition at line 1833 of file symbolresolver.cpp.

1834{
1835 //printf("computeIdealCacheParam(v=%u)\n",v);
1836
1837 int r=0;
1838 while (v!=0)
1839 {
1840 v >>= 1;
1841 r++;
1842 }
1843 // r = log2(v)
1844
1845 // convert to a valid cache size value
1846 return std::max(0,std::min(r-16,9));
1847}

Referenced by SymbolResolver::showCacheUsage().

◆ getCacheSize()

size_t getCacheSize ( )
static

Definition at line 79 of file symbolresolver.cpp.

80{
81 int cacheSize = Config_getInt(LOOKUP_CACHE_SIZE);
82 if (cacheSize<0) cacheSize=0;
83 if (cacheSize>9) cacheSize=9;
84 return 65536u << cacheSize;
85}
#define Config_getInt(name)
Definition config.h:34

References Config_getInt.

Referenced by getSymbolLookupCache(), and getTypeLookupCache().

◆ getSymbolLookupCache()

LookupCache & getSymbolLookupCache ( )
static

Definition at line 93 of file symbolresolver.cpp.

94{
96 return wrapper.cache();
97}
#define THREAD_LOCAL
Definition doxygen.h:30
static size_t getCacheSize()
static CacheStatistics g_symbolCacheStatistics

References g_symbolCacheStatistics, getCacheSize(), and THREAD_LOCAL.

Referenced by SymbolResolver::resolveSymbol(), and SymbolResolver::showCacheUsage().

◆ getTypeLookupCache()

LookupCache & getTypeLookupCache ( )
static

◆ isCodeSymbol()

◆ mergeStatistics()

void mergeStatistics ( CacheStatistics & stats,
LookupCache & cache )
static

Definition at line 55 of file symbolresolver.cpp.

56{
57 std::lock_guard lock(stats.mutex);
58 stats.size = std::max(stats.size, cache.size());
59 stats.capacity = std::max(stats.capacity, cache.capacity());
60 stats.hits = std::max(stats.hits, cache.hits());
61 stats.misses = std::max(stats.misses, cache.misses());
62}
size_t capacity() const
Returns the maximum number of values that can be stored in the cache.
Definition cache.h:132
size_t size() const
Returns the number of values stored in the cache.
Definition cache.h:126
uint64_t misses() const
Returns how many of the find() calls did not found a value in the cache.
Definition cache.h:144
uint64_t hits() const
Returns how many of the find() calls did find a value in the cache.
Definition cache.h:138

References Cache< K, V >::capacity(), CacheStatistics::capacity, Cache< K, V >::hits(), CacheStatistics::hits, Cache< K, V >::misses(), CacheStatistics::misses, CacheStatistics::mutex, Cache< K, V >::size(), and CacheStatistics::size.

Referenced by SymbolResolver::showCacheUsage(), and CacheStatsWrapper::~CacheStatsWrapper().

Variable Documentation

◆ g_cacheTypedefMutex

std::recursive_mutex g_cacheTypedefMutex
static

Definition at line 39 of file symbolresolver.cpp.

Referenced by SymbolResolver::Private::newResolveTypedef().

◆ g_substMap

THREAD_LOCAL std::unordered_map<std::string, std::pair<QCString,const MemberDef *> > g_substMap

Definition at line 99 of file symbolresolver.cpp.

Referenced by SymbolResolver::Private::substTypedef().

◆ g_symbolCacheStatistics

CacheStatistics g_symbolCacheStatistics
static

Definition at line 51 of file symbolresolver.cpp.

Referenced by getSymbolLookupCache(), and SymbolResolver::showCacheUsage().

◆ g_typeCacheStatistics

CacheStatistics g_typeCacheStatistics
static

Definition at line 50 of file symbolresolver.cpp.

Referenced by getTypeLookupCache(), and SymbolResolver::showCacheUsage().