maybeMangleDeclName should take GlobalDecl. This enforces integrity.

This commit is contained in:
Vassil Vassilev 2013-10-24 13:14:19 -05:00 committed by sftnight
parent 9b352aa828
commit a97a2811c9
2 changed files with 9 additions and 5 deletions

View File

@ -15,6 +15,7 @@ namespace clang {
class Expr;
class DeclContext;
class DeclarationName;
class GlobalDecl;
class FunctionDecl;
class IntegerLiteral;
class NamedDecl;
@ -41,12 +42,12 @@ namespace utils {
///
static bool IsWrapper(const clang::NamedDecl* ND);
///\brief Get the mangled name of a NamedDecl.
///\brief Get the mangled name of a GlobalDecl.
///
///\param [in] D - try to mangle this decl's name.
///\param [in] GD - try to mangle this decl's name.
///\param [out] mangledName - put the mangled name in here.
///
static void maybeMangleDeclName(const clang::NamedDecl* D,
static void maybeMangleDeclName(const clang::GlobalDecl& GD,
std::string& mangledName);

View File

@ -8,6 +8,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/Lookup.h"
#include "clang/AST/DeclTemplate.h"
@ -43,12 +44,14 @@ namespace utils {
.startswith(Synthesize::UniquePrefix);
}
void Analyze::maybeMangleDeclName(const clang::NamedDecl* D,
std::string& mangledName) {
void Analyze::maybeMangleDeclName(const clang::GlobalDecl& GD,
std::string& mangledName) {
///Get the mangled name of a NamedDecl.
///
///D - mangle this decl's name
///mangledName - put the mangled name in here
clang::NamedDecl* D
= cast<NamedDecl>(const_cast<clang::Decl*>(GD.getDecl()));
llvm::OwningPtr<MangleContext> mangleCtx;
mangleCtx.reset(D->getASTContext().createMangleContext());
if (mangleCtx->shouldMangleDeclName(D)) {