Skip to content

Commit

Permalink
LLVMMisc.cpp: Check if identifier exists in SymbolTable
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Paulo de Souza <[email protected]>
  • Loading branch information
marcosps committed Jul 31, 2024
1 parent 4309abc commit 95b5227
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libcextract/LLVMMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ DeclContextLookupResult Get_Decl_From_Symtab(ASTUnit *ast, const IdentifierInfo
DeclContextLookupResult Get_Decl_From_Symtab(ASTUnit *ast, const StringRef &name)
{
IdentifierTable &symtab = ast->getPreprocessor().getIdentifierTable();
IdentifierInfo &info = symtab.get(name);
return Get_Decl_From_Symtab(ast, &info);
auto info = symtab.find(name);
/* Return an empty DeclContextLookupResult if the identifier is not found */
if (info == symtab.end())
return DeclContextLookupResult();

return Get_Decl_From_Symtab(ast, info->getValue());
}

0 comments on commit 95b5227

Please sign in to comment.