From fb8d02b179732b17897f1d4024583949a56b0bb5 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Thu, 5 Jun 2014 22:10:59 +0000 Subject: Implement -Wframe-larger-than backend diagnostic Add driver and frontend support for the GCC -Wframe-larger-than=bytes warning. This is the first GCC-compatible backend diagnostic built around LLVM's reporting feature. This commit adds infrastructure to perform reverse lookup from mangled names emitted after LLVM IR generation. We use that to resolve precise locations and originating AST functions, lambdas or block declarations to produce seamless codegen-guided diagnostics. An associated change, StringMap now maintains unique mangled name strings instead of allocating copies. This is a net memory saving in C++ and a small hit for C where we no longer reuse IdentifierInfo storage, pending further optimisation. llvm-svn: 210293 --- clang/lib/CodeGen/ModuleBuilder.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp') diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 78cb82d..e5bdae9 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -49,6 +49,21 @@ namespace { return M.get(); } + const Decl *GetDeclForMangledName(StringRef MangledName) override { + GlobalDecl Result; + if (!Builder->lookupRepresentativeDecl(MangledName, Result)) + return nullptr; + const Decl *D = Result.getCanonicalDecl().getDecl(); + if (auto FD = dyn_cast(D)) { + if (FD->hasBody(FD)) + return FD; + } else if (auto TD = dyn_cast(D)) { + if (auto Def = TD->getDefinition()) + return Def; + } + return D; + } + llvm::Module *ReleaseModule() override { return M.release(); } void Initialize(ASTContext &Context) override { -- cgit v1.1