summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
authorAmjad Aboud <amjad.aboud@intel.com>2017-02-09 22:07:24 +0000
committerAmjad Aboud <amjad.aboud@intel.com>2017-02-09 22:07:24 +0000
commit546bc1103b682c4ea66116ddaf0fc6fdf0a8bdd5 (patch)
treeaab363349d875697db614ab98a7324d01b777a5c /clang/lib/CodeGen/CodeGenAction.cpp
parentef089bdb4ba4dbeee0cd519a352fee93f3a8f09c (diff)
downloadbcm5719-llvm-546bc1103b682c4ea66116ddaf0fc6fdf0a8bdd5.tar.gz
bcm5719-llvm-546bc1103b682c4ea66116ddaf0fc6fdf0a8bdd5.zip
[DebugInfo] Added support to Clang FE for generating debug info for preprocessor macros.
Added "-fdebug-macro" flag (and "-fno-debug-macro" flag) to enable (and to disable) emitting macro debug info. Added CC1 "-debug-info-macro" flag that enables emitting macro debug info. Differential Revision: https://reviews.llvm.org/D16135 llvm-svn: 294637
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 3828c5e1701..89a7c7c727b 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -10,6 +10,7 @@
#include "clang/CodeGen/CodeGenAction.h"
#include "CodeGenModule.h"
#include "CoverageMappingGen.h"
+#include "MacroPPCallbacks.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
@@ -97,6 +98,8 @@ namespace clang {
return std::unique_ptr<llvm::Module>(Gen->ReleaseModule());
}
+ CodeGenerator *getCodeGenerator() { return Gen.get(); }
+
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override {
Gen->HandleCXXStaticMemberVarInstantiation(VD);
}
@@ -830,6 +833,17 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
BEConsumer = Result.get();
+
+ // Enable generating macro debug info only when debug info is not disabled and
+ // also macro debug info is enabled.
+ if (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo &&
+ CI.getCodeGenOpts().MacroDebugInfo) {
+ std::unique_ptr<PPCallbacks> Callbacks =
+ llvm::make_unique<MacroPPCallbacks>(BEConsumer->getCodeGenerator(),
+ CI.getPreprocessor());
+ CI.getPreprocessor().addPPCallbacks(std::move(Callbacks));
+ }
+
return std::move(Result);
}
OpenPOWER on IntegriCloud