Skip to content

Commit

Permalink
Fixed shadowing issue in getFortranDefs and other shadowing cases
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Apr 9, 2020
1 parent 7464fdd commit bc83eb6
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 211 deletions.
4 changes: 2 additions & 2 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ function(set_project_warnings project_name)
set(GCC_WARNINGS
-Wall
-Wextra # reasonable and standard
#-Wshadow # warn the user if a variable declaration shadows one from a
# # parent context
-Wshadow # warn the user if a variable declaration shadows one from a
# parent context
$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>
# warn the user if a class with virtual functions has a
# non-virtual destructor. This helps catch hard to
Expand Down
9 changes: 5 additions & 4 deletions src/clangparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES);
//printf("source %s ----------\n%s\n-------------\n\n",
// fileName,p->source.data());
uint numUnsavedFiles = filesInTranslationUnit.count()+1;
int numUnsavedFiles = filesInTranslationUnit.count()+1;
p->numFiles = numUnsavedFiles;
p->sources = new QCString[numUnsavedFiles];
p->ufs = new CXUnsavedFile[numUnsavedFiles];
Expand All @@ -285,7 +285,7 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
p->ufs[0].Contents = p->sources[0].data();
p->ufs[0].Length = p->sources[0].length();
QStrListIterator it(filesInTranslationUnit);
uint i=1;
int i=1;
for (it.toFirst();it.current() && i<numUnsavedFiles;++it,i++)
{
p->fileMapping.insert(it.current(),new uint(i));
Expand All @@ -300,7 +300,7 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
argv, argc, p->ufs, numUnsavedFiles,
CXTranslationUnit_DetailedPreprocessingRecord);
// free arguments
for (int i=0;i<argc;++i)
for (i=0;i<argc;++i)
{
free(argv[i]);
}
Expand All @@ -312,7 +312,8 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
determineInputFilesInSameTu(filesInTranslationUnit);

// show any warnings that the compiler produced
for (uint i=0, n=clang_getNumDiagnostics(p->tu); i!=n; ++i)
int n=clang_getNumDiagnostics(p->tu);
for (i=0; i!=n; ++i)
{
CXDiagnostic diag = clang_getDiagnostic(p->tu, i);
CXString string = clang_formatDiagnostic(diag,
Expand Down
4 changes: 2 additions & 2 deletions src/code.l
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
auto it = std::find_if(fn->begin(),
fn->end(),
[&sfd=yyextra->sourceFileDef]
(const auto &fd)
{ return sfd->isIncluded(fd->absFilePath()); });
(const auto &lfd)
{ return sfd->isIncluded(lfd->absFilePath()); });
found = it!=fn->end();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5825,7 +5825,7 @@ static void addMemberSpecialization(const Entry *root,

//-------------------------------------------------------------------------------------------

static void addOverloaded(const Entry *root,MemberName *mn,ClassDef *cd,
static void addOverloaded(const Entry *root,MemberName *mn,
const QCString &funcType,const QCString &funcName,const QCString &funcArgs,
const QCString &funcDecl,const QCString &exceptions,uint64 spec)
{
Expand Down Expand Up @@ -6249,7 +6249,7 @@ static void findMember(const Entry *root,
}
else if (overloaded) // check if the function belongs to only one class
{
addOverloaded(root,mn,cd,funcType,funcName,funcArgs,funcDecl,exceptions,spec);
addOverloaded(root,mn,funcType,funcName,funcArgs,funcDecl,exceptions,spec);
}
else // unrelated function with the same name as a member
{
Expand Down
25 changes: 13 additions & 12 deletions src/fortrancode.l
Original file line number Diff line number Diff line change
Expand Up @@ -434,22 +434,23 @@ static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName
searches for definition of function memberName
@param memberName the name of the function/variable
@param moduleName name of enclosing module or null, if global entry
@param md the entry, if found or null
@param usedict array of data of USE-statement
@returns true, if found
@returns MemberDef pointer, if found, or nullptr otherwise
*/
static bool getFortranDefs(const QCString &memberName, const QCString &moduleName,
MemberDef *&md, UseSDict *usedict=0)
static MemberDef *getFortranDefs(const QCString &memberName, const QCString &moduleName,
UseSDict *usedict=0)
{
if (memberName.isEmpty()) return FALSE; /* empty name => nothing to link */
if (memberName.isEmpty()) return nullptr; /* empty name => nothing to link */

// look in local variables
QListIterator<Scope> it(scopeStack);
Scope *scope;
for (it.toLast();(scope=it.current());--it)
{
if (scope->localVars.find(memberName) && (!scope->externalVars.find(memberName)))
return FALSE;
{
return nullptr;
}
}

// search for function
Expand Down Expand Up @@ -479,12 +480,12 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam
{ // found function in global scope
if(cd == 0)
{ // Skip if bound to type
return TRUE;
return md.get();
}
}
else if (moduleName == nspace->name())
{ // found in local scope
return TRUE;
return md.get();
}
else
{ // else search in used modules
Expand All @@ -497,7 +498,7 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam
if (only.isEmpty())
{
//cout << " found in module " << usedModuleName << " entry " << memberName << endl;
return TRUE; // whole module used
return md.get(); // whole module used
}
else
{
Expand All @@ -506,7 +507,7 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam
//cout << " search in only: " << usedModuleName << ":: " << memberName << "==" << (*it)<< endl;
if (memberName == *lit)
{
return TRUE; // found in ONLY-part of use list
return md.get(); // found in ONLY-part of use list
}
}
}
Expand All @@ -515,7 +516,7 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam
} // if linkable
} // for
}
return FALSE;
return nullptr;
}

/**
Expand All @@ -540,7 +541,7 @@ static bool getLink(UseSDict *usedict, // dictionary with used modules
MemberDef *md=0;
QCString memberName= removeRedundantWhiteSpace(memberText);

if (getFortranDefs(memberName, currentModule, md, usedict) && md->isLinkable())
if ((md=getFortranDefs(memberName, currentModule, usedict)) && md->isLinkable())
{
if (md->isVariable() && (md->getLanguage()!=SrcLangExt_Fortran)) return FALSE; // Non Fortran variables aren't handled yet,
// see also linkifyText in util.cpp
Expand Down
11 changes: 5 additions & 6 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex)
ol.pushGeneratorState();
ol.disable(OutputGenerator::Html);
}
static bool fullPathNames = Config_getBool(FULL_PATH_NAMES);
bool fullPathNames = Config_getBool(FULL_PATH_NAMES);
startIndexHierarchy(ol,0);
if (fullPathNames)
{
Expand All @@ -780,11 +780,10 @@ static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex)
{
for (const auto &fd : *fn)
{
static bool fullPathNames = Config_getBool(FULL_PATH_NAMES);
if (!fullPathNames || fd->getDirDef()==0) // top level file
{
bool doc,src;
doc = fileVisibleInIndex(fd.get(),src);
bool src;
bool doc = fileVisibleInIndex(fd.get(),src);
QCString reference, outputBase;
if (doc)
{
Expand Down Expand Up @@ -2021,8 +2020,8 @@ class AlphaIndexTableRows : public QList<AlphaIndexTableCell>
class AlphaIndexTableRowsIterator : public QListIterator<AlphaIndexTableCell>
{
public:
AlphaIndexTableRowsIterator(const AlphaIndexTableRows &list) :
QListIterator<AlphaIndexTableCell>(list) {}
AlphaIndexTableRowsIterator(const AlphaIndexTableRows &list_) :
QListIterator<AlphaIndexTableCell>(list_) {}
};

/** Class representing the columns in the alphabetical class index. */
Expand Down
4 changes: 2 additions & 2 deletions src/pre.l
Original file line number Diff line number Diff line change
Expand Up @@ -1791,8 +1791,8 @@ static FileState *checkAndOpenFile(yyscan_t yyscanner,const QCString &fileName,b
alreadyIncluded = std::any_of(
state->includeStack.begin(),
state->includeStack.end(),
[absName](const std::unique_ptr<FileState> &fs)
{ return fs->fileName==absName; }
[absName](const std::unique_ptr<FileState> &lfs)
{ return lfs->fileName==absName; }
);

if (alreadyIncluded)
Expand Down
Loading

0 comments on commit bc83eb6

Please sign in to comment.