llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-systemz

Author: Sean Perry (perry-ca)

<details>
<summary>Changes</summary>

This is adding the support for `#pragma map` from the z/OS system headers and 
for XL compatibility.  The pragma is very similar to asm labels and `#pragma 
redefine_extname` with the exceptions:
- asm labels can be applied to non C linkage in C++.  pragma map is limited to 
C linkage
- it has more diagnostics than redefine_extname.

The syntax is like:
```c
#pragma map (func, "new-name")
int func(int);
```
I have limited the scope to the -fzos-extension option but can easily remove 
that.

---

Patch is 53.00 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/243723.diff


35 Files Affected:

- (modified) clang/docs/LanguageExtensions.md (+26) 
- (modified) clang/docs/ReleaseNotes.md (+4) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+6) 
- (modified) clang/include/clang/Basic/TokenKinds.def (+3) 
- (modified) clang/include/clang/Parse/Parser.h (+8) 
- (modified) clang/include/clang/Sema/ExternalSemaSource.h (+10) 
- (modified) clang/include/clang/Sema/MultiplexExternalSemaSource.h (+11) 
- (modified) clang/include/clang/Sema/Sema.h (+14) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+9) 
- (modified) clang/lib/Parse/ParsePragma.cpp (+76-5) 
- (modified) clang/lib/Parse/ParseStmt.cpp (+8) 
- (modified) clang/lib/Parse/Parser.cpp (+3) 
- (modified) clang/lib/Sema/MultiplexExternalSemaSource.cpp (+6) 
- (modified) clang/lib/Sema/Sema.cpp (+23) 
- (modified) clang/lib/Sema/SemaAttr.cpp (+74) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+33) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+41) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+28) 
- (added) clang/test/CodeGen/SystemZ/pragma-map-conflict.c (+21) 
- (added) clang/test/CodeGen/SystemZ/pragma-map-escape.c (+31) 
- (added) clang/test/CodeGen/SystemZ/pragma-map-noproto.c (+19) 
- (added) clang/test/CodeGen/SystemZ/pragma-map-proto.c (+18) 
- (added) clang/test/CodeGen/SystemZ/pragma-map.c (+65) 
- (added) clang/test/CodeGen/SystemZ/pragma-map.cpp (+187) 
- (added) clang/test/PCH/pragma-map.c (+50) 
- (added) clang/test/PCH/pragma-map.h (+18) 
- (added) clang/test/Parser/pragma-map.c (+15) 
- (added) clang/test/Parser/pragma-map.cpp (+10) 
- (added) clang/test/Sema/pragma-map-conflict.c (+16) 
- (added) clang/test/Sema/pragma-map-conflict.cpp (+20) 
- (added) clang/test/Sema/pragma-map.c (+56) 
- (added) clang/test/Sema/pragma-map.cpp (+79) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h (+7) 


``````````diff
diff --git a/clang/docs/LanguageExtensions.md b/clang/docs/LanguageExtensions.md
index cf453ac2e3b69b..240527c4b174ca 100644
--- a/clang/docs/LanguageExtensions.md
+++ b/clang/docs/LanguageExtensions.md
@@ -1128,6 +1128,32 @@ generated saying the pragma didn't resolve to a 
declaration. For example:
 int func(double) { return 0; } // warning: failed to resolve '#pragma export' 
to a declaration
 ```
 
+### #pragma map
+
+Clang supports the map pragma as a way to change the name of a declaration
+within the source to another name for external symbols.  This pragma is 
provided
+mainly for compatibility with the z/OS system headers.  This pragma behaves
+as if the declaration had an asm label.  The syntax for the pragma is:
+
+```c++
+#pragma map ( name , string-literal )
+```
+
+where `name` is the name used in the source code.  This can be an external 
function or
+variable declared or defined within the translation unit and `string-literal` 
is a
+string literal that is the external name for the declaration.  The string 
literal is
+encoded in IBM-1047.
+
+The pragma is only applied to declarations with external linkage and the 
declaration needs
+to have "C" linkage in C++.  A warning will be generated if the pragma is 
applied to a
+declaration that does not have external linkage or no declaration was found 
for the
+name by the end of the translation unit.
+
+The pragma must appear before the first use of the declaration in the pragma.
+
+Pragma map and asm label can not be specified for the same declaration with 
different
+external names.
+
 ## Overflow behavior types
 
 Clang provides an extension that allows developers to annotate integer types
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index f2397bc8dcd594..e47064bd35bba4 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -1526,6 +1526,10 @@ documentation](CIR/index.md) for more information 
regarding ClangIR's status and
 
 #### SystemZ Support
 
+- Add support for `#pragma map` for z/OS.  This pragma is used by the z/OS
+  system headers to define the external name for declarations in the 
translation
+  unit.  This is very similar to asm labels and `#pragma redefine_extname`.
+
 ### DWARF Support in Clang
 
 ### Floating Point Support in Clang
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 2be6ff8344cd6d..deaddc85aed48d 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1095,6 +1095,8 @@ def warn_pragma_missing_argument : Warning<
   "missing argument to '#pragma %0'%select{|; expected %2}1">, 
InGroup<IgnoredPragmas>;
 def warn_pragma_invalid_argument : Warning<
   "unexpected argument '%0' to '#pragma %1'%select{|; expected %3}2">, 
InGroup<IgnoredPragmas>;
+def warn_pragma_ignore_args : Warning<
+  "argument list in '#pragma %0' - ignoring">, InGroup<IgnoredPragmas>;
 
 def err_pragma_misplaced_in_decl : Error<"this pragma cannot appear in %0 
declaration">;
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index dff45a081f2e8c..98c5a09a7a08e6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1300,6 +1300,9 @@ def note_surrounding_namespace_starts_here : Note<
 def warn_failed_to_resolve_pragma : Warning<
   "failed to resolve '#pragma %0' to a declaration">,
   InGroup<IgnoredPragmas>;
+def warn_pragma_different_asm_label : Warning<
+  "#pragma map has conflicting asm label; not applied to %0">,
+  InGroup<IgnoredPragmas>;
 def warn_pragma_not_applied : Warning<
   "#pragma %0 is applicable to symbols with external linkage only; "
   "not applied to %1">,
@@ -1307,6 +1310,9 @@ def warn_pragma_not_applied : Warning<
 def warn_pragma_not_applied_to_defined_symbol : Warning<
   "#pragma %0 can only applied before a symbol is defined">,
   InGroup<IgnoredPragmas>;
+def warn_pragma_not_applied_to_used_symbol : Warning<
+  "#pragma %0 can only applied to unused symbols">,
+  InGroup<IgnoredPragmas>;
 def err_pragma_loop_invalid_argument_type : Error<
   "invalid argument of type %0; expected an integer type">;
 def err_pragma_loop_compatibility : Error<
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 802947e31cbc18..a667a71663ae9b 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -902,6 +902,9 @@ PRAGMA_ANNOTATION(pragma_attribute)
 // Annotation for C/C++ #pragma export(ident)
 PRAGMA_ANNOTATION(pragma_export)
 
+// Annotation for #pragma map(ident, str-lit)
+PRAGMA_ANNOTATION(pragma_map)
+
 // Annotation for the riscv pragma directives - #pragma clang riscv intrinsic 
...
 PRAGMA_ANNOTATION(pragma_riscv)
 
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 5c1cf9b687291e..2dc8ea69feea63 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -7199,6 +7199,7 @@ class Parser : public CodeCompletionHandler {
   std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
   std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
   std::unique_ptr<PragmaHandler> ExportHandler;
+  std::unique_ptr<PragmaHandler> MapHandler;
   std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
 
   /// Initialize all pragma handlers.
@@ -7322,10 +7323,17 @@ class Parser : public CodeCompletionHandler {
 
   void zOSHandlePragmaHelper(tok::TokenKind);
 
+  bool zOSParseParameterList(StringRef PragmaName,
+                             std::optional<SmallVector<QualType, 4>> 
&TypeList);
+
   /// Handle the annotation token produced for
   /// #pragma export ...
   void HandlePragmaExport();
 
+  /// Handle the annotation token produced for
+  /// #pragma map ...
+  void HandlePragmaMap();
+
   ///@}
 
   //
diff --git a/clang/include/clang/Sema/ExternalSemaSource.h 
b/clang/include/clang/Sema/ExternalSemaSource.h
index 022294e9dbee32..992323c058b128 100644
--- a/clang/include/clang/Sema/ExternalSemaSource.h
+++ b/clang/include/clang/Sema/ExternalSemaSource.h
@@ -173,6 +173,16 @@ class ExternalSemaSource : public ExternalASTSource {
   virtual void ReadExtnameUndeclaredIdentifiers(
       SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &EI) {}
 
+  /// Read the set of #pragma map'd, undeclared identifiers known to the
+  /// external Sema source.
+  ///
+  /// The external source should append its own #pragma map'd, undeclared
+  /// identifiers to the given vector. Note that this routine may be invoked
+  /// multiple times; the external source should take care not to introduce the
+  /// same identifiers repeatedly.
+  virtual void ReadMappedUndeclaredIdentifiers(
+      SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &MI) {}
+
   /// Read the set of used vtables known to the external Sema source.
   ///
   /// The external source should append its own used vtables to the given
diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h 
b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index ad75a1d97d4182..f9149f172b232b 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -334,6 +334,17 @@ class MultiplexExternalSemaSource : public 
ExternalSemaSource {
       SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &EI)
       override;
 
+  /// Read the set of #pragma map'd, undeclared identifiers known to the
+  /// external Sema source.
+  ///
+  /// The external source should append its own #pragma map'd, undeclared
+  /// identifiers to the given vector. Note that this routine may be invoked
+  /// multiple times; the external source should take care not to introduce the
+  /// same identifiers repeatedly.
+  void ReadMappedUndeclaredIdentifiers(
+      SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &MI)
+      override;
+
   /// Read the set of used vtables known to the external Sema source.
   ///
   /// The external source should append its own used vtables to the given
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bc8793c4b7a533..f7ea610ad65fe3 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -968,6 +968,9 @@ class Sema final : public SemaBase {
   /// source.
   void LoadExternalExtnameUndeclaredIdentifiers();
 
+  /// Load #pragma map'd undeclared identifiers from the external source.
+  void LoadExternalMappedUndeclaredIdentifiers();
+
   /// Determine if VD, which must be a variable or function, is an external
   /// symbol that nonetheless can't be referenced from outside this translation
   /// unit because its type has no linkage and it's not extern "C".
@@ -2403,12 +2406,22 @@ class Sema final : public SemaBase {
     bool Used;
   };
 
+  struct PendingPragmaMapInfo : public PendingPragmaInfo {
+    AsmLabelAttr *Attr; // The attribute to attach.
+  };
+
   llvm::DenseMap<IdentifierInfo *, PendingPragmaInfo> PendingExportedNames;
 
+  llvm::DenseMap<IdentifierInfo *, PendingPragmaMapInfo> PendingMappedNames;
+
   /// ActonPragmaExport - called on well-formed '\#pragma export'.
   void ActOnPragmaExport(IdentifierInfo *IdentId, SourceLocation ExportNameLoc,
                          Scope *curScope);
 
+  /// ActOnPragmaMap - called on well-formed '\#pragma map'.
+  void ActOnPragmaMap(IdentifierInfo *IdentId, SourceLocation NameLoc,
+                      Scope *curScope, const StringRef MappedName);
+
   /// Only called on function definitions; if there is a pragma in scope
   /// with the effect of a range-based optnone, consider marking the function
   /// with attribute optnone.
@@ -4034,6 +4047,7 @@ class Sema final : public SemaBase {
   void warnOnCTypeHiddenInCPlusPlus(const NamedDecl *D);
 
   void ProcessPragmaExport(DeclaratorDecl *newDecl);
+  void ProcessPragmaMap(DeclaratorDecl *NewDecl);
 
   Decl *ActOnDeclarator(Scope *S, Declarator &D);
 
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 04cc0c5af89d15..3a3b90ea481645 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -754,6 +754,9 @@ enum ASTRecordTypes {
 
   /// Record code for the OpenMP 'requires' directives seen in the TU.
   OMP_REQUIRES_DECLS = 81,
+
+  /// Record code for #pragma map'd undeclared identifiers.
+  MAPPED_UNDECLARED_IDENTIFIERS = 82,
 };
 
 /// Record types used within a source manager block.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 275383d40cf808..53f5a863021113 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -944,6 +944,11 @@ class ASTReader : public ExternalPreprocessorSource,
   /// triplets in the order of C name, asm name, and source location.
   SmallVector<serialization::IdentifierID, 64> ExtnameUndeclaredIdentifiers;
 
+  /// A snapshot of Sema's #pragma map'd undeclared identifier tracking. Note
+  /// that this vector has 3n entries, being triplets in the order of C name,
+  /// mapped name, and source location.
+  SmallVector<serialization::IdentifierID, 64> MappedUndeclaredIdentifiers;
+
   /// The IDs of type aliases for ext_vectors that exist in the chain.
   ///
   /// Used by Sema for finding sugared names for ext_vectors in diagnostics.
@@ -2335,6 +2340,10 @@ class ASTReader : public ExternalPreprocessorSource,
       SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &ExtnameIDs)
       override;
 
+  void ReadMappedUndeclaredIdentifiers(
+      SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &MappedIDs)
+      override;
+
   void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
 
   void ReadPendingInstantiations(
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index dd05bd3c21442a..166e0a8432b923 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -395,6 +395,12 @@ struct PragmaExportHandler : public PragmaHandler {
                     Token &FirstToken) override;
 };
 
+struct PragmaMapHandler : public PragmaHandler {
+  PragmaMapHandler() : PragmaHandler("map") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
+                    Token &FirstToken) override;
+};
+
 struct PragmaRISCVHandler : public PragmaHandler {
   PragmaRISCVHandler(Sema &Actions)
       : PragmaHandler("riscv"), Actions(Actions) {}
@@ -562,6 +568,8 @@ void Parser::initializePragmaHandlers() {
   if (getLangOpts().ZOSExt) {
     ExportHandler = std::make_unique<PragmaExportHandler>();
     PP.AddPragmaHandler(ExportHandler.get());
+    MapHandler = std::make_unique<PragmaMapHandler>();
+    PP.AddPragmaHandler(MapHandler.get());
   }
 
   if (getTargetInfo().getTriple().isRISCV()) {
@@ -702,6 +710,8 @@ void Parser::resetPragmaHandlers() {
   if (getLangOpts().ZOSExt) {
     PP.RemovePragmaHandler(ExportHandler.get());
     ExportHandler.reset();
+    PP.RemovePragmaHandler(MapHandler.get());
+    MapHandler.reset();
   }
 
   if (getTargetInfo().getTriple().isRISCV()) {
@@ -1412,8 +1422,6 @@ bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
 void Parser::zOSHandlePragmaHelper(tok::TokenKind PragmaKind) {
   assert(Tok.is(PragmaKind));
 
-  StringRef PragmaName = "export";
-
   using namespace clang::charinfo;
   auto *TheTokens = static_cast<std::pair<std::unique_ptr<Token[]>, size_t> *>(
       Tok.getAnnotationValue());
@@ -1429,6 +1437,11 @@ void Parser::zOSHandlePragmaHelper(tok::TokenKind 
PragmaKind) {
   });
 
   do {
+    const bool IsPragmaMap = PragmaKind == tok::annot_pragma_map;
+    StringRef PragmaName = IsPragmaMap ? "map" : "export";
+    const bool AcceptCxxAndFunctionIdents =
+        IsPragmaMap && PP.getLangOpts().CPlusPlus;
+
     PP.Lex(Tok);
     if (Tok.isNot(tok::l_paren)) {
       PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
@@ -1447,6 +1460,41 @@ void Parser::zOSHandlePragmaHelper(tok::TokenKind 
PragmaKind) {
     SourceLocation IdentNameLoc = Tok.getLocation();
     PP.Lex(Tok);
 
+    if (AcceptCxxAndFunctionIdents && Tok.is(tok::l_paren)) {
+      SourceLocation LparenLoc = Tok.getLocation();
+      PP.Lex(Tok);
+      if (!SkipUntil(tok::r_paren)) {
+        PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
+            << PragmaName;
+        return;
+      }
+      PP.Diag(LparenLoc, diag::warn_pragma_ignore_args) << PragmaName;
+    }
+
+    // If we are parsing string literal for this pragma.
+    StringLiteral *MappedName = nullptr;
+    if (IsPragmaMap) {
+      if (Tok.isNot(tok::comma)) {
+        PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_comma)
+            << PragmaName;
+        return;
+      }
+      PP.Lex(Tok);
+
+      if (Tok.isNot(tok::string_literal)) {
+        PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_string)
+            << PragmaName;
+        return;
+      }
+
+      ExprResult StringResult = ParseStringLiteralExpression(
+          /*AllowUserDefinedLiteral=*/false,
+          /*Unevaluated=*/false, CA_ToLiteralEncodingForAsm);
+      if (StringResult.isInvalid())
+        return; // Already diagnosed.
+      MappedName = cast<StringLiteral>(StringResult.get());
+    }
+
     if (Tok.isNot(tok::r_paren)) {
       PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
           << PragmaName;
@@ -1454,14 +1502,26 @@ void Parser::zOSHandlePragmaHelper(tok::TokenKind 
PragmaKind) {
     }
 
     PP.Lex(Tok);
-    Actions.ActOnPragmaExport(IdentName, IdentNameLoc, getCurScope());
+    if (IsPragmaMap) {
+      assert(MappedName && "MappedName was not set.");
+      if (MappedName->getLength() != 0)
+        Actions.ActOnPragmaMap(IdentName, IdentNameLoc, getCurScope(),
+                               MappedName->getString());
+    } else
+      Actions.ActOnPragmaExport(IdentName, IdentNameLoc, getCurScope());
 
     // Because export is also a C++ keyword, we also check for that.
     if (Tok.is(tok::identifier) || Tok.is(tok::kw_export)) {
-      PragmaName = Tok.getIdentifierInfo()->getName();
-      if (PragmaName != "export")
+      StringRef TokenName = Tok.getIdentifierInfo()->getName();
+      if (TokenName == "map")
+        PragmaKind = tok::annot_pragma_map;
+      else if (TokenName == "export")
+        PragmaKind = tok::annot_pragma_export;
+      else {
         PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
             << PragmaName;
+        return;
+      }
     } else if (Tok.isNot(tok::eof)) {
       PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
           << PragmaName;
@@ -1471,12 +1531,16 @@ void Parser::zOSHandlePragmaHelper(tok::TokenKind 
PragmaKind) {
   return;
 }
 
+/// Handle #pragma export.
 void Parser::HandlePragmaExport() {
   assert(Tok.is(tok::annot_pragma_export));
 
   zOSHandlePragmaHelper(tok::annot_pragma_export);
 }
 
+/// Handle #pragma map.
+void Parser::HandlePragmaMap() { zOSHandlePragmaHelper(tok::annot_pragma_map); 
}
+
 static std::string PragmaLoopHintString(Token PragmaName, Token Option) {
   StringRef Str = PragmaName.getIdentifierInfo()->getName();
   std::string ClangLoopStr("clang loop ");
@@ -4231,6 +4295,13 @@ void PragmaExportHandler::HandlePragma(Preprocessor &PP,
                                        Token &FirstToken) {
   zOSPragmaHandlerHelper(PP, FirstToken, tok::annot_pragma_export);
 }
+//
+/// Handle #pragma map.
+void PragmaMapHandler::HandlePragma(Preprocessor &PP,
+                                    PragmaIntroducer Introducer,
+                                    Token &FirstToken) {
+  zOSPragmaHandlerHelper(PP, FirstToken, tok::annot_pragma_map);
+}
 
 // Handle '#pragma clang riscv intrinsic vector'.
 //        '#pragma clang riscv intrinsic sifive_vector'.
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 4c3c4e5117813d..260266baf8f35f 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -537,6 +537,11 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
     ProhibitAttributes(GNUAttrs);
     HandlePragmaExport();
     return StmtEmpty();
+  case tok::annot_pragma_map:
+    ProhibitAttributes(CXX11Attrs);
+    ProhibitAttributes(GNUAttrs);
+    HandlePragmaMap();
+    return StmtEmpty();
   }
 
   // If we reached this code, the statement must end in a semicolon.
@@ -1076,6 +1081,9 @@ void Parser::ParseCompoundStatementLeadingPragmas() {
     case tok::annot_pragma_export:
       HandlePragmaExport();
       break;
+    case tok::annot_pragma_map:
+      HandlePragmaMap();
+      break;
     default:
       checkForPragmas = false;
       break;
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index fbfc632c47e45b..30cdaef5a44a6a 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -821,6 +821,9 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
   case tok::annot_pragma_export:
     HandlePragmaExport();
     return nullptr;
+  case tok::annot_pragma_map:
+    HandlePragmaMap();
+    return nullptr;
   case tok::semi:
     // Either a C++11 empty-declaration or attribute-declaration.
     SingleDecl =
diff --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp 
b/clang/lib/Sema/MultiplexExternalSemaSource.cpp
index bf2b19e143a4d8..827d3b04c777bf 100644
--- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp
+++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -326,6 +326,12 @@ void 
MultiplexExternalSemaSource::ReadExtnameUndeclaredIdentifiers(
     Sources[i]->ReadExtnameUndeclaredIdentifiers(EI);
 }
 
+void MultiplexExternalSemaSource::ReadMappedUndeclaredIdentifiers(
+    SmallVectorImpl<std::pair<IdentifierInfo *, AsmLabelAttr *>> &MI) {
+  for (size_t i = 0; i < Sources.size(); ++i)
+    Sources[i]->ReadMappedUndeclaredIdentifiers(MI);
+}
+
 void MultiplexExternalSemaSource::ReadUsedVTables(
                                   SmallVectorImpl<ExternalVTableUse> &VTables) 
{
   for(size_t i = 0; i < Sources.size(); ++i)
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index ebc8b85cf8a628..e7b814294594a1 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/243723
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to