diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-21 09:14:44 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-21 09:14:44 +0000 |
commit | c02ab4c76d7f8e672cda266436d64dd23bd2ad26 (patch) | |
tree | 90d40d1c154a9e21e2d4adb38d06d534982f6023 /lib/CodeGen/Mangle.cpp | |
parent | c074771f7ff302dd96e2caa3c29ab6c94bef9f3b (diff) |
Mangler: Strengthen invariants, MangleContext::mangleName should only be called on var or function decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index cb27f5c931..a4b2fce7c1 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -169,18 +169,15 @@ bool CXXNameMangler::mangle(const NamedDecl *D) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) return mangleFunctionDecl(FD); - if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { - if (!Context.getASTContext().getLangOptions().CPlusPlus || - isInCLinkageSpecification(D) || - D->getDeclContext()->isTranslationUnit()) - return false; - - Out << "_Z"; - mangleName(VD); - return true; - } + const VarDecl *VD = cast<VarDecl>(D); + if (!Context.getASTContext().getLangOptions().CPlusPlus || + isInCLinkageSpecification(D) || + D->getDeclContext()->isTranslationUnit()) + return false; - return false; + Out << "_Z"; + mangleName(VD); + return true; } void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) { @@ -1298,10 +1295,10 @@ void CXXNameMangler::addSubstitution(uintptr_t Ptr) { /// name. bool MangleContext::mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &Res) { - assert(!isa<CXXConstructorDecl>(D) && - "Use mangleCXXCtor for constructor decls!"); - assert(!isa<CXXDestructorDecl>(D) && - "Use mangleCXXDtor for destructor decls!"); + assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) && + "Invalid mangleName() call, argument is not a variable or function!"); + assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) && + "Invalid mangleName() call on 'structor decl!"); PrettyStackTraceDecl CrashInfo(D, SourceLocation(), getASTContext().getSourceManager(), |