]> granicus.if.org Git - clang/commitdiff
Add '#pragma clang __debug module_map module.name' to dump the module
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 18 Apr 2019 00:57:01 +0000 (00:57 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 18 Apr 2019 00:57:01 +0000 (00:57 +0000)
map being used for the module 'module.name'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358632 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/Pragma.cpp

index fa8a797366c2ac507b60e026d66459d62138ed56..5c567f21320959abbd01a6dba5aaba8d16a89190 100644 (file)
@@ -561,6 +561,8 @@ def warn_pragma_debug_unexpected_command : Warning<
   "unexpected debug command '%0'">, InGroup<IgnoredPragmas>;
 def warn_pragma_debug_missing_argument : Warning<
   "missing argument to debug command '%0'">, InGroup<IgnoredPragmas>;
+def warn_pragma_debug_unknown_module : Warning<
+  "unknown module '%0'">, InGroup<IgnoredPragmas>;
 // #pragma module
 def err_pp_expected_module_name : Error<
   "expected %select{identifier after '.' in |}0module name">;
index 1c87f3ecc0900cb63abf982fcf72f3c8b74ef688..ba1b73e7f4ba93656f2882f18bc5a09bd067ecb1 100644 (file)
@@ -1010,7 +1010,7 @@ struct PragmaDebugHandler : public PragmaHandler {
   PragmaDebugHandler() : PragmaHandler("__debug") {}
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
-                    Token &DepToken) override {
+                    Token &DebugToken) override {
     Token Tok;
     PP.LexUnexpandedToken(Tok);
     if (Tok.isNot(tok::identifier)) {
@@ -1072,6 +1072,22 @@ struct PragmaDebugHandler : public PragmaHandler {
       else
         PP.Diag(MacroName, diag::warn_pragma_debug_missing_argument)
             << II->getName();
+    } else if (II->isStr("module_map")) {
+      llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 8>
+          ModuleName;
+      if (LexModuleName(PP, Tok, ModuleName))
+        return;
+      ModuleMap &MM = PP.getHeaderSearchInfo().getModuleMap();
+      Module *M = nullptr;
+      for (auto IIAndLoc : ModuleName) {
+        M = MM.lookupModuleQualified(IIAndLoc.first->getName(), M);
+        if (!M) {
+          PP.Diag(IIAndLoc.second, diag::warn_pragma_debug_unknown_module)
+              << IIAndLoc.first;
+          return;
+        }
+      }
+      M->dump();
     } else if (II->isStr("overflow_stack")) {
       DebugOverflowStack();
     } else if (II->isStr("handle_crash")) {