summaryrefslogtreecommitdiffstats
path: root/src/pre.l
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-06-17 18:49:11 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-06-17 18:49:11 (GMT)
commitd0f24b762e23b1b0c069209978aa403acc027cdf (patch)
tree0d4d9deffeb4d0b2a809b1807dc52d88bf5d80e9 /src/pre.l
parent46672f1e6ea2c63e54c0fc8420d6ebdaca958478 (diff)
downloadDoxygen-d0f24b762e23b1b0c069209978aa403acc027cdf.zip
Doxygen-d0f24b762e23b1b0c069209978aa403acc027cdf.tar.gz
Doxygen-d0f24b762e23b1b0c069209978aa403acc027cdf.tar.bz2
Multi-threaded parsing: added locks around global data
Diffstat (limited to 'src/pre.l')
-rw-r--r--src/pre.l28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/pre.l b/src/pre.l
index b78908f..4ec76ab 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -360,6 +360,11 @@ void DefineManager::DefinesPerFile::collectDefines(
*
* global state
*/
+#if MULTITHREADED_INPUT
+static std::mutex g_allIncludesMutex;
+static std::mutex g_addIncludeRelationMutex;
+static std::mutex g_macroDefinitionsMutex;
+#endif
static StringUnorderedSet g_allIncludes;
static DefineManager g_defineManager;
@@ -1804,6 +1809,10 @@ static FileState *checkAndOpenFile(yyscan_t yyscanner,const QCString &fileName,b
// global guard
if (state->curlyCount==0) // not #include inside { ... }
{
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_allIncludesMutex);
+#endif
+
if (g_allIncludes.find(absName.data())!=g_allIncludes.end())
{
alreadyIncluded = TRUE;
@@ -2854,7 +2863,12 @@ static void addMacroDefinition(yyscan_t yyscanner)
{
define->definition = litTextStripped;
}
- Doxygen::macroDefinitions.push_back(std::move(define));
+ {
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_macroDefinitionsMutex);
+#endif
+ Doxygen::macroDefinitions.push_back(std::move(define));
+ }
}
static inline void outputChar(yyscan_t yyscanner,char c)
@@ -2959,6 +2973,9 @@ static void readIncludeFile(yyscan_t yyscanner,const QCString &inc)
}
if (oldFileDef)
{
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_addIncludeRelationMutex);
+#endif
// add include dependency to the file in which the #include was found
bool ambig;
// change to absolute name for bug 641336
@@ -2973,6 +2990,9 @@ static void readIncludeFile(yyscan_t yyscanner,const QCString &inc)
}
else if (state->inputFileDef)
{
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_addIncludeRelationMutex);
+#endif
state->inputFileDef->addIncludeDependency(0,absIncFileName,localInclude,state->isImported,TRUE);
}
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -3002,6 +3022,9 @@ static void readIncludeFile(yyscan_t yyscanner,const QCString &inc)
//printf(" calling findFile(%s) alreadyInc=%d\n",incFileName.data(),alreadyIncluded);
if (oldFileDef)
{
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_addIncludeRelationMutex);
+#endif
bool ambig;
// change to absolute name for bug 641336
@@ -3018,6 +3041,9 @@ static void readIncludeFile(yyscan_t yyscanner,const QCString &inc)
}
else if (state->inputFileDef)
{
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_addIncludeRelationMutex);
+#endif
state->inputFileDef->addIncludeDependency(0,absIncFileName,localInclude,state->isImported,TRUE);
}
if (Debug::isFlagSet(Debug::Preprocessor))