diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-11-06 23:31:56 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-11-06 23:31:56 +0000 |
commit | bed356a9eae0d45b878410b5c42d6ff278bb0c83 (patch) | |
tree | 74bfb4f49e1a0d034c3c987b601da6255145959f /clang/lib/AST/Expr.cpp | |
parent | 695c3325af3ef877c4632bb6ea5af04f2062ff1b (diff) | |
download | bcm5719-llvm-bed356a9eae0d45b878410b5c42d6ff278bb0c83.tar.gz bcm5719-llvm-bed356a9eae0d45b878410b5c42d6ff278bb0c83.zip |
[-fms-extensions] Add support for __FUNCDNAME__
Summary:
Similar to __FUNCTION__, MSVC exposes the name of the enclosing mangled
function name via __FUNCDNAME__. This implementation is very naive and
unoptimized, it is expected that __FUNCDNAME__ would be used rarely in
practice.
Reviewers: rnk, rsmith, thakis
CC: cfe-commits, silvas
Differential Revision: http://llvm-reviews.chandlerc.com/D2109
llvm-svn: 194181
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 38f5e2f4887..e467883288b 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -20,6 +20,7 @@ #include "clang/AST/EvaluatedExprVisitor.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/Mangle.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/Basic/Builtins.h" @@ -478,6 +479,30 @@ SourceLocation DeclRefExpr::getLocEnd() const { std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) { ASTContext &Context = CurrentDecl->getASTContext(); + if (IT == PredefinedExpr::FuncDName) { + if (const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) { + OwningPtr<MangleContext> MC; + MC.reset(Context.createMangleContext()); + + if (MC->shouldMangleDeclName(ND)) { + SmallString<256> Buffer; + llvm::raw_svector_ostream Out(Buffer); + if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(ND)) + MC->mangleCXXCtor(CD, Ctor_Base, Out); + else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(ND)) + MC->mangleCXXDtor(DD, Dtor_Base, Out); + else + MC->mangleName(ND, Out); + + Out.flush(); + if (!Buffer.empty() && Buffer.front() == '\01') + return Buffer.substr(1); + return Buffer.str(); + } else + return ND->getIdentifier()->getName(); + } + return ""; + } if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) { if (IT != PrettyFunction && IT != PrettyFunctionNoVirtual) return FD->getNameAsString(); |