From 3df2500a8197a17749ca5b9b4837f314c72a6985 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 20 Nov 2012 19:13:06 +0000 Subject: [PATCH] Be nice to the caller - lookup inside a DeclContext should work even for a const DeclContext, so do a const_cast in the source. git-svn-id: http://root.cern.ch/svn/root/trunk@47496 27541ba8-7e3a-0410-8455-c3a389f83636 --- include/cling/Utils/AST.h | 6 +++--- lib/Utils/AST.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/cling/Utils/AST.h b/include/cling/Utils/AST.h index b9192244..8cf845d5 100644 --- a/include/cling/Utils/AST.h +++ b/include/cling/Utils/AST.h @@ -116,7 +116,7 @@ namespace utils { /// static clang::NamespaceDecl* Namespace(clang::Sema* S, const char* Name, - clang::DeclContext* Within = 0); + const clang::DeclContext* Within = 0); ///\brief Quick lookup for a single named declaration in a given /// declaration context. @@ -129,7 +129,7 @@ namespace utils { /// static clang::NamedDecl* Named(clang::Sema* S, const char* Name, - clang::DeclContext* Within = 0); + const clang::DeclContext* Within = 0); ///\brief Quick lookup for a single namespace declaration in a given /// declaration context. @@ -143,7 +143,7 @@ namespace utils { /// static clang::NamedDecl* Named(clang::Sema* S, const clang::DeclarationName& Name, - clang::DeclContext* Within = 0); + const clang::DeclContext* Within = 0); }; } // end namespace utils diff --git a/lib/Utils/AST.cpp b/lib/Utils/AST.cpp index a86fb3c1..5b58f27e 100644 --- a/lib/Utils/AST.cpp +++ b/lib/Utils/AST.cpp @@ -466,14 +466,14 @@ namespace utils { } NamespaceDecl* Lookup::Namespace(Sema* S, const char* Name, - DeclContext* Within) { + const DeclContext* Within) { DeclarationName DName = &S->Context.Idents.get(Name); LookupResult R(*S, DName, SourceLocation(), Sema::LookupNestedNameSpecifierName); if (!Within) S->LookupName(R, S->TUScope); else - S->LookupQualifiedName(R, Within); + S->LookupQualifiedName(R, const_cast(Within)); if (R.empty()) return 0; @@ -483,19 +483,20 @@ namespace utils { return dyn_cast(R.getFoundDecl()); } - NamedDecl* Lookup::Named(Sema* S, const char* Name, DeclContext* Within) { + NamedDecl* Lookup::Named(Sema* S, const char* Name, + const DeclContext* Within) { DeclarationName DName = &S->Context.Idents.get(Name); return Lookup::Named(S, DName, Within); } NamedDecl* Lookup::Named(Sema* S, const DeclarationName& Name, - DeclContext* Within) { + const DeclContext* Within) { LookupResult R(*S, Name, SourceLocation(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); if (!Within) S->LookupName(R, S->TUScope); else - S->LookupQualifiedName(R, Within); + S->LookupQualifiedName(R, const_cast(Within)); if (R.empty()) return 0;