diff options
author | Alp Toker <alp@nuanti.com> | 2014-06-05 22:10:59 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-06-05 22:10:59 +0000 |
commit | fb8d02b179732b17897f1d4024583949a56b0bb5 (patch) | |
tree | 9773c072cdc1e0f4a6ccfba97f3ed6cda7f2d958 /clang/lib/CodeGen/ModuleBuilder.cpp | |
parent | 66f676e9e53aaaba12fd9848a94915346ab76b87 (diff) | |
download | llvm-fb8d02b179732b17897f1d4024583949a56b0bb5.zip llvm-fb8d02b179732b17897f1d4024583949a56b0bb5.tar.gz llvm-fb8d02b179732b17897f1d4024583949a56b0bb5.tar.bz2 |
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
Diffstat (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp')
-rw-r--r-- | clang/lib/CodeGen/ModuleBuilder.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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<FunctionDecl>(D)) { + if (FD->hasBody(FD)) + return FD; + } else if (auto TD = dyn_cast<TagDecl>(D)) { + if (auto Def = TD->getDefinition()) + return Def; + } + return D; + } + llvm::Module *ReleaseModule() override { return M.release(); } void Initialize(ASTContext &Context) override { |