diff --git a/include/cling/Utils/AST.h b/include/cling/Utils/AST.h index 30e0d309..ba0529a8 100644 --- a/include/cling/Utils/AST.h +++ b/include/cling/Utils/AST.h @@ -189,7 +189,7 @@ namespace utils { ///\param[in] Name - The name we are looking up. ///\param[in] Within - The context within the lookup is done. If 0 the /// TranslationUnitDecl is used. - ///\returns the found result (if single) or 0. + ///\returns the found NamespaceDecl or 0. /// clang::NamespaceDecl* Namespace(clang::Sema* S, const char* Name, @@ -202,7 +202,7 @@ namespace utils { ///\param[in] Name - The name we are looking up. ///\param[in] Within - The context within the lookup is done. If 0 the /// TranslationUnitDecl is used. - ///\returns the found result (if single) or 0. + ///\returns the found result if single, -1 if multiple or 0 if not found. /// clang::NamedDecl* Named(clang::Sema* S, const char* Name, @@ -216,7 +216,7 @@ namespace utils { /// DeclarationName.h (faster at runtime). ///\param[in] Within - The context within the lookup is done. If 0 the /// TranslationUnitDecl is used. - ///\returns the found result (if single) or 0. + ///\returns the found result if single, -1 if multiple or 0 if not found. /// clang::NamedDecl* Named(clang::Sema* S, const clang::DeclarationName& Name, diff --git a/lib/Utils/AST.cpp b/lib/Utils/AST.cpp index 076a85d9..e8dc24da 100644 --- a/lib/Utils/AST.cpp +++ b/lib/Utils/AST.cpp @@ -1180,8 +1180,9 @@ namespace utils { R.resolveKind(); - return R.getFoundDecl(); - + if (R.isSingleResult()) + return R.getFoundDecl(); + return (clang::NamedDecl*)-1; } static NestedNameSpecifier*