Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy)" #95299

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

vitalybuka
Copy link
Collaborator

Reverts #68620

Introduce or expose a memory leak and UB, see #68620

@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang:codegen clang:static analyzer labels Jun 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 12, 2024

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-modules
@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Vitaly Buka (vitalybuka)

Changes

Reverts llvm/llvm-project#68620

Introduce or expose a memory leak and UB, see llvm/llvm-project#68620


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

96 Files Affected:

  • (modified) clang-tools-extra/test/pp-trace/pp-trace-macro.cpp (-9)
  • (modified) clang/docs/LanguageExtensions.rst (-24)
  • (modified) clang/include/clang/AST/Expr.h (-160)
  • (modified) clang/include/clang/AST/RecursiveASTVisitor.h (-5)
  • (modified) clang/include/clang/AST/TextNodeDumper.h (-1)
  • (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (-3)
  • (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (-12)
  • (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2)
  • (modified) clang/include/clang/Basic/FileManager.h (+4-7)
  • (modified) clang/include/clang/Basic/StmtNodes.td (-1)
  • (modified) clang/include/clang/Basic/TokenKinds.def (-6)
  • (modified) clang/include/clang/Driver/Options.td (-6)
  • (modified) clang/include/clang/Frontend/PreprocessorOutputOptions.h (-3)
  • (modified) clang/include/clang/Lex/PPCallbacks.h (-54)
  • (removed) clang/include/clang/Lex/PPDirectiveParameter.h (-33)
  • (removed) clang/include/clang/Lex/PPEmbedParameters.h (-94)
  • (modified) clang/include/clang/Lex/Preprocessor.h (+2-69)
  • (modified) clang/include/clang/Lex/PreprocessorOptions.h (-3)
  • (modified) clang/include/clang/Parse/Parser.h (-3)
  • (modified) clang/include/clang/Sema/Sema.h (-4)
  • (modified) clang/include/clang/Serialization/ASTBitCodes.h (-3)
  • (modified) clang/lib/AST/Expr.cpp (-12)
  • (modified) clang/lib/AST/ExprClassification.cpp (-5)
  • (modified) clang/lib/AST/ExprConstant.cpp (+5-58)
  • (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+3-17)
  • (modified) clang/lib/AST/Interp/ByteCodeExprGen.h (-1)
  • (modified) clang/lib/AST/ItaniumMangle.cpp (-1)
  • (modified) clang/lib/AST/StmtPrinter.cpp (-4)
  • (modified) clang/lib/AST/StmtProfile.cpp (-2)
  • (modified) clang/lib/AST/TextNodeDumper.cpp (-5)
  • (modified) clang/lib/Basic/FileManager.cpp (+1-6)
  • (modified) clang/lib/Basic/IdentifierTable.cpp (+2-3)
  • (modified) clang/lib/CodeGen/CGExprAgg.cpp (+8-32)
  • (modified) clang/lib/CodeGen/CGExprConstant.cpp (+25-93)
  • (modified) clang/lib/CodeGen/CGExprScalar.cpp (-7)
  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-5)
  • (modified) clang/lib/Frontend/CompilerInvocation.cpp (-8)
  • (modified) clang/lib/Frontend/DependencyFile.cpp (-25)
  • (modified) clang/lib/Frontend/DependencyGraph.cpp (+1-23)
  • (modified) clang/lib/Frontend/InitPreprocessor.cpp (-8)
  • (modified) clang/lib/Frontend/PrintPreprocessedOutput.cpp (+7-115)
  • (modified) clang/lib/Lex/PPDirectives.cpp (+2-475)
  • (modified) clang/lib/Lex/PPExpressions.cpp (+13-36)
  • (modified) clang/lib/Lex/PPMacroExpansion.cpp (-111)
  • (modified) clang/lib/Lex/TokenConcatenation.cpp (+1-4)
  • (modified) clang/lib/Parse/ParseExpr.cpp (+1-36)
  • (modified) clang/lib/Parse/ParseInit.cpp (-32)
  • (modified) clang/lib/Parse/ParseTemplate.cpp (+12-29)
  • (modified) clang/lib/Sema/SemaExceptionSpec.cpp (-1)
  • (modified) clang/lib/Sema/SemaExpr.cpp (+3-14)
  • (modified) clang/lib/Sema/SemaInit.cpp (+13-100)
  • (modified) clang/lib/Sema/TreeTransform.h (-5)
  • (modified) clang/lib/Serialization/ASTReaderStmt.cpp (-15)
  • (modified) clang/lib/Serialization/ASTWriterStmt.cpp (-11)
  • (modified) clang/lib/StaticAnalyzer/Core/ExprEngine.cpp (-4)
  • (removed) clang/test/C/C2x/Inputs/bits.bin (-1)
  • (removed) clang/test/C/C2x/Inputs/boop.h (-1)
  • (removed) clang/test/C/C2x/Inputs/i.dat (-1)
  • (removed) clang/test/C/C2x/Inputs/jump.wav (-1)
  • (removed) clang/test/C/C2x/Inputs/s.dat (-1)
  • (removed) clang/test/C/C2x/n3017.c (-216)
  • (removed) clang/test/Preprocessor/Inputs/jk.txt (-1)
  • (removed) clang/test/Preprocessor/Inputs/media/art.txt (-9)
  • (removed) clang/test/Preprocessor/Inputs/media/empty ()
  • (removed) clang/test/Preprocessor/Inputs/null_byte.bin ()
  • (removed) clang/test/Preprocessor/Inputs/numbers.txt (-1)
  • (removed) clang/test/Preprocessor/Inputs/single_byte.txt (-1)
  • (removed) clang/test/Preprocessor/embed___has_embed.c (-60)
  • (removed) clang/test/Preprocessor/embed___has_embed_parsing_errors.c (-240)
  • (removed) clang/test/Preprocessor/embed___has_embed_supported.c (-24)
  • (removed) clang/test/Preprocessor/embed_art.c (-104)
  • (removed) clang/test/Preprocessor/embed_codegen.cpp (-84)
  • (removed) clang/test/Preprocessor/embed_constexpr.cpp (-97)
  • (removed) clang/test/Preprocessor/embed_dependencies.c (-20)
  • (removed) clang/test/Preprocessor/embed_ext_compat_diags.c (-16)
  • (removed) clang/test/Preprocessor/embed_feature_test.cpp (-7)
  • (removed) clang/test/Preprocessor/embed_file_not_found_chevron.c (-4)
  • (removed) clang/test/Preprocessor/embed_file_not_found_quote.c (-4)
  • (removed) clang/test/Preprocessor/embed_init.c (-29)
  • (removed) clang/test/Preprocessor/embed_parameter_if_empty.c (-24)
  • (removed) clang/test/Preprocessor/embed_parameter_limit.c (-94)
  • (removed) clang/test/Preprocessor/embed_parameter_offset.c (-89)
  • (removed) clang/test/Preprocessor/embed_parameter_prefix.c (-38)
  • (removed) clang/test/Preprocessor/embed_parameter_suffix.c (-39)
  • (removed) clang/test/Preprocessor/embed_parameter_unrecognized.c (-9)
  • (removed) clang/test/Preprocessor/embed_parsing_errors.c (-130)
  • (removed) clang/test/Preprocessor/embed_path_chevron.c (-8)
  • (removed) clang/test/Preprocessor/embed_path_quote.c (-8)
  • (removed) clang/test/Preprocessor/embed_preprocess_to_file.c (-39)
  • (removed) clang/test/Preprocessor/embed_single_entity.c (-7)
  • (removed) clang/test/Preprocessor/embed_weird.cpp (-98)
  • (modified) clang/test/Preprocessor/init-aarch64.c (-3)
  • (modified) clang/test/Preprocessor/init.c (-3)
  • (removed) clang/test/Preprocessor/single_byte.txt (-1)
  • (modified) clang/tools/libclang/CXCursor.cpp (-1)
  • (modified) clang/www/c_status.html (+1-1)
diff --git a/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp b/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
index 7c2a231101070..1d85607e86b7f 100644
--- a/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
+++ b/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
@@ -31,15 +31,6 @@ X
 // CHECK:        MacroNameTok: __STDC_UTF_32__
 // CHECK-NEXT:   MacroDirective: MD_Define
 // CHECK:      - Callback: MacroDefined
-// CHECK-NEXT:   MacroNameTok: __STDC_EMBED_NOT_FOUND__
-// CHECK-NEXT:   MacroDirective: MD_Define
-// CHECK:      - Callback: MacroDefined
-// CHECK-NEXT:   MacroNameTok: __STDC_EMBED_FOUND__
-// CHECK-NEXT:   MacroDirective: MD_Define
-// CHECK:      - Callback: MacroDefined
-// CHECK-NEXT:   MacroNameTok: __STDC_EMBED_EMPTY__
-// CHECK-NEXT:   MacroDirective: MD_Define
-// CHECK:      - Callback: MacroDefined
 // CHECK:      - Callback: MacroDefined
 // CHECK-NEXT:   MacroNameTok: MACRO
 // CHECK-NEXT:   MacroDirective: MD_Define
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 1b5db388301f7..a49e4122ffc10 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1502,7 +1502,6 @@ Attributes on Structured Bindings            __cpp_structured_bindings        C+
 Designated initializers (N494)                                                C99           C89
 Array & element qualification (N2607)                                         C23           C89
 Attributes (N2335)                                                            C23           C89
-``#embed`` (N3017)                                                            C23           C89, C++
 ============================================ ================================ ============= =============
 
 Type Trait Primitives
@@ -5665,26 +5664,3 @@ Compiling different TUs depending on these flags (including use of
 ``std::hardware_destructive_interference``)  with different compilers, macro
 definitions, or architecture flags will lead to ODR violations and should be
 avoided.
-
-``#embed`` Parameters
-=====================
-
-``clang::offset``
------------------
-The ``clang::offset`` embed parameter may appear zero or one time in the
-embed parameter sequence. Its preprocessor argument clause shall be present and
-have the form:
-
-..code-block: text
-
-  ( constant-expression )
-
-and shall be an integer constant expression. The integer constant expression
-shall not evaluate to a value less than 0. The token ``defined`` shall not
-appear within the constant expression.
-
-The offset will be used when reading the contents of the embedded resource to
-specify the starting offset to begin embedding from. The resources is treated
-as being empty if the specified offset is larger than the number of bytes in
-the resource. The offset will be applied *before* any ``limit`` parameters are
-applied.
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 352e4467ed9dd..f2bf667636dc9 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4799,166 +4799,6 @@ class SourceLocExpr final : public Expr {
   friend class ASTStmtReader;
 };
 
-/// Stores data related to a single #embed directive.
-struct EmbedDataStorage {
-  StringLiteral *Filename;
-  StringLiteral *BinaryData;
-  size_t getDataElementCount() const { return BinaryData->getByteLength(); }
-};
-
-/// Represents a reference to #emded data. By default, this references the whole
-/// range. Otherwise it represents a subrange of data imported by #embed
-/// directive. Needed to handle nested initializer lists with #embed directives.
-/// Example:
-///  struct S {
-///    int x, y;
-///  };
-///
-///  struct T {
-///    int x[2];
-///    struct S s
-///  };
-///
-///  struct T t[] = {
-///  #embed "data" // data contains 10 elements;
-///  };
-///
-/// The resulting semantic form of initializer list will contain (EE stands
-/// for EmbedExpr):
-///  { {EE(first two data elements), {EE(3rd element), EE(4th element) }},
-///  { {EE(5th and 6th element), {EE(7th element), EE(8th element) }},
-///  { {EE(9th and 10th element), { zeroinitializer }}}
-///
-/// EmbedExpr inside of a semantic initializer list and referencing more than
-/// one element can only appear for arrays of scalars.
-class EmbedExpr final : public Expr {
-  SourceLocation EmbedKeywordLoc;
-  IntegerLiteral *FakeChildNode = nullptr;
-  const ASTContext *Ctx = nullptr;
-  EmbedDataStorage *Data;
-  unsigned Begin = 0;
-  unsigned NumOfElements;
-
-public:
-  EmbedExpr(const ASTContext &Ctx, SourceLocation Loc, EmbedDataStorage *Data,
-            unsigned Begin, unsigned NumOfElements);
-  explicit EmbedExpr(EmptyShell Empty) : Expr(SourceLocExprClass, Empty) {}
-
-  SourceLocation getLocation() const { return EmbedKeywordLoc; }
-  SourceLocation getBeginLoc() const { return EmbedKeywordLoc; }
-  SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
-
-  StringLiteral *getFilenameStringLiteral() const { return Data->Filename; }
-  StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
-  EmbedDataStorage *getData() const { return Data; }
-
-  unsigned getStartingElementPos() const { return Begin; }
-  size_t getDataElementCount() const { return NumOfElements; }
-
-  // Allows accessing every byte of EmbedExpr data and iterating over it.
-  // An Iterator knows the EmbedExpr that it refers to, and an offset value
-  // within the data.
-  // Dereferencing an Iterator results in construction of IntegerLiteral AST
-  // node filled with byte of data of the corresponding EmbedExpr within offset
-  // that the Iterator currently has.
-  template <bool Const>
-  class ChildElementIter
-      : public llvm::iterator_facade_base<
-            ChildElementIter<Const>, std::random_access_iterator_tag,
-            std::conditional_t<Const, const IntegerLiteral *,
-                               IntegerLiteral *>> {
-    friend class EmbedExpr;
-
-    EmbedExpr *EExpr = nullptr;
-    unsigned long long CurOffset = ULLONG_MAX;
-    using BaseTy = typename ChildElementIter::iterator_facade_base;
-
-    ChildElementIter(EmbedExpr *E) : EExpr(E) {
-      if (E)
-        CurOffset = E->getStartingElementPos();
-    }
-
-  public:
-    ChildElementIter() : CurOffset(ULLONG_MAX) {}
-    typename BaseTy::reference operator*() const {
-      assert(EExpr && CurOffset != ULLONG_MAX &&
-             "trying to dereference an invalid iterator");
-      IntegerLiteral *N = EExpr->FakeChildNode;
-      StringRef DataRef = EExpr->Data->BinaryData->getBytes();
-      N->setValue(*EExpr->Ctx,
-                  llvm::APInt(N->getValue().getBitWidth(), DataRef[CurOffset],
-                              N->getType()->isSignedIntegerType()));
-      // We want to return a reference to the fake child node in the
-      // EmbedExpr, not the local variable N.
-      return const_cast<typename BaseTy::reference>(EExpr->FakeChildNode);
-    }
-    typename BaseTy::pointer operator->() const { return **this; }
-    using BaseTy::operator++;
-    ChildElementIter &operator++() {
-      assert(EExpr && "trying to increment an invalid iterator");
-      assert(CurOffset != ULLONG_MAX &&
-             "Already at the end of what we can iterate over");
-      if (++CurOffset >=
-          EExpr->getDataElementCount() + EExpr->getStartingElementPos()) {
-        CurOffset = ULLONG_MAX;
-        EExpr = nullptr;
-      }
-      return *this;
-    }
-    bool operator==(ChildElementIter Other) const {
-      return (EExpr == Other.EExpr && CurOffset == Other.CurOffset);
-    }
-  }; // class ChildElementIter
-
-public:
-  using fake_child_range = llvm::iterator_range<ChildElementIter<false>>;
-  using const_fake_child_range = llvm::iterator_range<ChildElementIter<true>>;
-
-  fake_child_range underlying_data_elements() {
-    return fake_child_range(ChildElementIter<false>(this),
-                            ChildElementIter<false>());
-  }
-
-  const_fake_child_range underlying_data_elements() const {
-    return const_fake_child_range(
-        ChildElementIter<true>(const_cast<EmbedExpr *>(this)),
-        ChildElementIter<true>());
-  }
-
-  child_range children() {
-    return child_range(child_iterator(), child_iterator());
-  }
-
-  const_child_range children() const {
-    return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-
-  static bool classof(const Stmt *T) {
-    return T->getStmtClass() == EmbedExprClass;
-  }
-
-  ChildElementIter<false> begin() { return ChildElementIter<false>(this); }
-
-  ChildElementIter<true> begin() const {
-    return ChildElementIter<true>(const_cast<EmbedExpr *>(this));
-  }
-
-  template <typename Call, typename... Targs>
-  bool doForEachDataElement(Call &&C, unsigned &StartingIndexInArray,
-                            Targs &&...Fargs) const {
-    for (auto It : underlying_data_elements()) {
-      if (!std::invoke(std::forward<Call>(C), const_cast<IntegerLiteral *>(It),
-                       StartingIndexInArray, std::forward<Targs>(Fargs)...))
-        return false;
-      StartingIndexInArray++;
-    }
-    return true;
-  }
-
-private:
-  friend class ASTStmtReader;
-};
-
 /// Describes an C or C++ initializer list.
 ///
 /// InitListExpr describes an initializer list, which can be used to
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 2785afd59bf21..aa55e2e7e8718 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2864,11 +2864,6 @@ DEF_TRAVERSE_STMT(ShuffleVectorExpr, {})
 DEF_TRAVERSE_STMT(ConvertVectorExpr, {})
 DEF_TRAVERSE_STMT(StmtExpr, {})
 DEF_TRAVERSE_STMT(SourceLocExpr, {})
-DEF_TRAVERSE_STMT(EmbedExpr, {
-  for (IntegerLiteral *IL : S->underlying_data_elements()) {
-    TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(IL);
-  }
-})
 
 DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index 39dd1f515c9eb..abfafcaef271b 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -409,7 +409,6 @@ class TextNodeDumper
   void VisitHLSLBufferDecl(const HLSLBufferDecl *D);
   void VisitOpenACCConstructStmt(const OpenACCConstructStmt *S);
   void VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S);
-  void VisitEmbedExpr(const EmbedExpr *S);
 };
 
 } // namespace clang
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index de758cbe679dc..1e44bc4ad09b6 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -275,9 +275,6 @@ def err_too_large_for_fixed_point : Error<
 def err_unimplemented_conversion_with_fixed_point_type : Error<
   "conversion between fixed point and %0 is not yet supported">;
 
-def err_requires_positive_value : Error<
-  "%select{invalid value '%0'; must be positive|value '%0' is too large}1">;
-
 // SEH
 def err_seh_expected_handler : Error<
   "expected '__except' or '__finally' block">;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 12d7b8c0205ee..25fbfe83fa2bc 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -436,14 +436,6 @@ def warn_cxx23_compat_warning_directive : Warning<
 def warn_c23_compat_warning_directive : Warning<
   "#warning is incompatible with C standards before C23">,
   InGroup<CPre23Compat>, DefaultIgnore;
-def ext_pp_embed_directive : ExtWarn<
-  "#embed is a %select{C23|Clang}0 extension">,
-  InGroup<C23>;
-def warn_compat_pp_embed_directive : Warning<
-  "#embed is incompatible with C standards before C23">,
-  InGroup<CPre23Compat>, DefaultIgnore;
-def err_pp_embed_dup_params : Error<
-  "cannot specify parameter '%0' twice in the same '#embed' directive">;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup<ExtraTokens>;
@@ -513,8 +505,6 @@ def err_pp_invalid_directive : Error<
   "invalid preprocessing directive%select{|, did you mean '#%1'?}0">;
 def warn_pp_invalid_directive : Warning<
   err_pp_invalid_directive.Summary>, InGroup<DiagGroup<"unknown-directives">>;
-def err_pp_unknown_parameter : Error<
-  "unknown%select{ | embed}0 preprocessor parameter '%1'">;
 def err_pp_directive_required : Error<
   "%0 must be used within a preprocessing directive">;
 def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
@@ -729,8 +719,6 @@ def err_pp_module_build_missing_end : Error<
   "no matching '#pragma clang module endbuild' for this '#pragma clang module build'">;
 
 def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
-def err_defined_in_pp_embed : Error<
-  "'defined' cannot appear within this context">;
 def err_paste_at_start : Error<
   "'##' cannot appear at start of macro expansion">;
 def err_paste_at_end : Error<"'##' cannot appear at end of macro expansion">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a104dfb766a98..193eae3bc41d6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1097,6 +1097,8 @@ def note_surrounding_namespace_starts_here : Note<
   "surrounding namespace with visibility attribute starts here">;
 def err_pragma_loop_invalid_argument_type : Error<
   "invalid argument of type %0; expected an integer type">;
+def err_pragma_loop_invalid_argument_value : Error<
+  "%select{invalid value '%0'; must be positive|value '%0' is too large}1">;
 def err_pragma_loop_compatibility : Error<
   "%select{incompatible|duplicate}0 directives '%1' and '%2'">;
 def err_pragma_loop_precedes_nonloop : Error<
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 527bbef24793e..e1f33d57a8980 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -286,15 +286,12 @@ class FileManager : public RefCountedBase<FileManager> {
   /// MemoryBuffer if successful, otherwise returning null.
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
   getBufferForFile(FileEntryRef Entry, bool isVolatile = false,
-                   bool RequiresNullTerminator = true,
-                   std::optional<int64_t> MaybeLimit = std::nullopt);
+                   bool RequiresNullTerminator = true);
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
   getBufferForFile(StringRef Filename, bool isVolatile = false,
-                   bool RequiresNullTerminator = true,
-                   std::optional<int64_t> MaybeLimit = std::nullopt) const {
-    return getBufferForFileImpl(Filename,
-                                /*FileSize=*/(MaybeLimit ? *MaybeLimit : -1),
-                                isVolatile, RequiresNullTerminator);
+                   bool RequiresNullTerminator = true) const {
+    return getBufferForFileImpl(Filename, /*FileSize=*/-1, isVolatile,
+                                RequiresNullTerminator);
   }
 
 private:
diff --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td
index c59a17be7808f..6ca08abdb14f0 100644
--- a/clang/include/clang/Basic/StmtNodes.td
+++ b/clang/include/clang/Basic/StmtNodes.td
@@ -204,7 +204,6 @@ def OpaqueValueExpr : StmtNode<Expr>;
 def TypoExpr : StmtNode<Expr>;
 def RecoveryExpr : StmtNode<Expr>;
 def BuiltinBitCastExpr : StmtNode<ExplicitCastExpr>;
-def EmbedExpr : StmtNode<Expr>;
 
 // Microsoft Extensions.
 def MSPropertyRefExpr : StmtNode<Expr>;
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 37d570ca5e75b..9c4b17465e18a 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -126,9 +126,6 @@ PPKEYWORD(error)
 // C99 6.10.6 - Pragma Directive.
 PPKEYWORD(pragma)
 
-// C23 & C++26 #embed
-PPKEYWORD(embed)
-
 // GNU Extensions.
 PPKEYWORD(import)
 PPKEYWORD(include_next)
@@ -1002,9 +999,6 @@ ANNOTATION(header_unit)
 // Annotation for end of input in clang-repl.
 ANNOTATION(repl_input_end)
 
-// Annotation for #embed
-ANNOTATION(embed)
-
 #undef PRAGMA_ANNOTATION
 #undef ANNOTATION
 #undef TESTING_KEYWORD
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..d44faa55c456f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -880,9 +880,6 @@ will be ignored}]>;
 def L : JoinedOrSeparate<["-"], "L">, Flags<[RenderJoined]>, Group<Link_Group>,
     Visibility<[ClangOption, FlangOption]>,
     MetaVarName<"<dir>">, HelpText<"Add directory to library search path">;
-def embed_dir_EQ : Joined<["--"], "embed-dir=">, Group<Preprocessor_Group>,
-    Visibility<[ClangOption, CC1Option]>, MetaVarName<"<dir>">,
-    HelpText<"Add directory to embed search path">;
 def MD : Flag<["-"], "MD">, Group<M_Group>,
     HelpText<"Write a depfile containing user and system headers">;
 def MMD : Flag<["-"], "MMD">, Group<M_Group>,
@@ -1476,9 +1473,6 @@ def dD : Flag<["-"], "dD">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>
 def dI : Flag<["-"], "dI">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Print include directives in -E mode in addition to normal output">,
   MarshallingInfoFlag<PreprocessorOutputOpts<"ShowIncludeDirectives">>;
-def dE : Flag<["-"], "dE">, Group<d_Group>, Visibility<[CC1Option]>,
-  HelpText<"Print embed directives in -E mode in addition to normal output">,
-  MarshallingInfoFlag<PreprocessorOutputOpts<"ShowEmbedDirectives">>;
 def dM : Flag<["-"], "dM">, Group<d_Group>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Print macro definitions in -E mode instead of normal output">;
 def dead__strip : Flag<["-"], "dead_strip">;
diff --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
index 654cf22f010f7..6e19cae33cf28 100644
--- a/clang/include/clang/Frontend/PreprocessorOutputOptions.h
+++ b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
@@ -32,8 +32,6 @@ class PreprocessorOutputOptions {
   LLVM_PREFERRED_TYPE(bool)
   unsigned ShowIncludeDirectives : 1;  ///< Print includes, imports etc. within preprocessed output.
   LLVM_PREFERRED_TYPE(bool)
-  unsigned ShowEmbedDirectives : 1; ///< Print embeds, etc. within preprocessed
-  LLVM_PREFERRED_TYPE(bool)
   unsigned RewriteIncludes : 1;    ///< Preprocess include directives only.
   LLVM_PREFERRED_TYPE(bool)
   unsigned RewriteImports  : 1;    ///< Include contents of transitively-imported modules.
@@ -53,7 +51,6 @@ class PreprocessorOutputOptions {
     ShowMacroComments = 0;
     ShowMacros = 0;
     ShowIncludeDirectives = 0;
-    ShowEmbedDirectives = 0;
     RewriteIncludes = 0;
     RewriteImports = 0;
     MinimizeWhitespace = 0;
diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h
index 46cc564086f1c..dfc74b52686f1 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -27,7 +27,6 @@ class IdentifierInfo;
 class MacroDefinition;
 class MacroDirective;
 class MacroArgs;
-struct LexEmbedParametersResult;
 
 /// This interface provides a way to observe the actions of the
 /// preprocessor as it does its thing.
@@ -84,34 +83,6 @@ class PPCallbacks {
                            const Token &FilenameTok,
                            SrcMgr::CharacteristicKind FileType) {}
 
-  /// Callback invoked whenever the preprocessor cannot find a file for an
-  /// embed directive.
-  ///
-  /// \param FileName The name of the file being included, as written in the
-  /// source code.
-  ///
-  /// \returns true to indicate that the preprocessor should skip this file
-  /// and not issue any diagnostic.
-  virtual bool EmbedFileNotFound(StringRef FileName) { return false; }
-
-  /// Callback invoked whenever an embed directive has been processed,
-  /// regardless of whether the embed will actually find a file.
-  ///
-  /// \param HashLoc The location of the '#' that starts the embed directive.
-  ///
-  /// \param FileName The...
[truncated]

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 12, 2024

@llvm/pr-subscribers-clang-driver

Author: Vitaly Buka (vitalybuka)

Changes

Reverts llvm/llvm-project#68620

Introduce or expose a memory leak and UB, see llvm/llvm-project#68620


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

96 Files Affected:

  • (modified) clang-tools-extra/test/pp-trace/pp-trace-macro.cpp (-9)
  • (modified) clang/docs/LanguageExtensions.rst (-24)
  • (modified) clang/include/clang/AST/Expr.h (-160)
  • (modified) clang/include/clang/AST/RecursiveASTVisitor.h (-5)
  • (modified) clang/include/clang/AST/TextNodeDumper.h (-1)
  • (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (-3)
  • (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (-12)
  • (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2)
  • (modified) clang/include/clang/Basic/FileManager.h (+4-7)
  • (modified) clang/include/clang/Basic/StmtNodes.td (-1)
  • (modified) clang/include/clang/Basic/TokenKinds.def (-6)
  • (modified) clang/include/clang/Driver/Options.td (-6)
  • (modified) clang/include/clang/Frontend/PreprocessorOutputOptions.h (-3)
  • (modified) clang/include/clang/Lex/PPCallbacks.h (-54)
  • (removed) clang/include/clang/Lex/PPDirectiveParameter.h (-33)
  • (removed) clang/include/clang/Lex/PPEmbedParameters.h (-94)
  • (modified) clang/include/clang/Lex/Preprocessor.h (+2-69)
  • (modified) clang/include/clang/Lex/PreprocessorOptions.h (-3)
  • (modified) clang/include/clang/Parse/Parser.h (-3)
  • (modified) clang/include/clang/Sema/Sema.h (-4)
  • (modified) clang/include/clang/Serialization/ASTBitCodes.h (-3)
  • (modified) clang/lib/AST/Expr.cpp (-12)
  • (modified) clang/lib/AST/ExprClassification.cpp (-5)
  • (modified) clang/lib/AST/ExprConstant.cpp (+5-58)
  • (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+3-17)
  • (modified) clang/lib/AST/Interp/ByteCodeExprGen.h (-1)
  • (modified) clang/lib/AST/ItaniumMangle.cpp (-1)
  • (modified) clang/lib/AST/StmtPrinter.cpp (-4)
  • (modified) clang/lib/AST/StmtProfile.cpp (-2)
  • (modified) clang/lib/AST/TextNodeDumper.cpp (-5)
  • (modified) clang/lib/Basic/FileManager.cpp (+1-6)
  • (modified) clang/lib/Basic/IdentifierTable.cpp (+2-3)
  • (modified) clang/lib/CodeGen/CGExprAgg.cpp (+8-32)
  • (modified) clang/lib/CodeGen/CGExprConstant.cpp (+25-93)
  • (modified) clang/lib/CodeGen/CGExprScalar.cpp (-7)
  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-5)
  • (modified) clang/lib/Frontend/CompilerInvocation.cpp (-8)
  • (modified) clang/lib/Frontend/DependencyFile.cpp (-25)
  • (modified) clang/lib/Frontend/DependencyGraph.cpp (+1-23)
  • (modified) clang/lib/Frontend/InitPreprocessor.cpp (-8)
  • (modified) clang/lib/Frontend/PrintPreprocessedOutput.cpp (+7-115)
  • (modified) clang/lib/Lex/PPDirectives.cpp (+2-475)
  • (modified) clang/lib/Lex/PPExpressions.cpp (+13-36)
  • (modified) clang/lib/Lex/PPMacroExpansion.cpp (-111)
  • (modified) clang/lib/Lex/TokenConcatenation.cpp (+1-4)
  • (modified) clang/lib/Parse/ParseExpr.cpp (+1-36)
  • (modified) clang/lib/Parse/ParseInit.cpp (-32)
  • (modified) clang/lib/Parse/ParseTemplate.cpp (+12-29)
  • (modified) clang/lib/Sema/SemaExceptionSpec.cpp (-1)
  • (modified) clang/lib/Sema/SemaExpr.cpp (+3-14)
  • (modified) clang/lib/Sema/SemaInit.cpp (+13-100)
  • (modified) clang/lib/Sema/TreeTransform.h (-5)
  • (modified) clang/lib/Serialization/ASTReaderStmt.cpp (-15)
  • (modified) clang/lib/Serialization/ASTWriterStmt.cpp (-11)
  • (modified) clang/lib/StaticAnalyzer/Core/ExprEngine.cpp (-4)
  • (removed) clang/test/C/C2x/Inputs/bits.bin (-1)
  • (removed) clang/test/C/C2x/Inputs/boop.h (-1)
  • (removed) clang/test/C/C2x/Inputs/i.dat (-1)
  • (removed) clang/test/C/C2x/Inputs/jump.wav (-1)
  • (removed) clang/test/C/C2x/Inputs/s.dat (-1)
  • (removed) clang/test/C/C2x/n3017.c (-216)
  • (removed) clang/test/Preprocessor/Inputs/jk.txt (-1)
  • (removed) clang/test/Preprocessor/Inputs/media/art.txt (-9)
  • (removed) clang/test/Preprocessor/Inputs/media/empty ()
  • (removed) clang/test/Preprocessor/Inputs/null_byte.bin ()
  • (removed) clang/test/Preprocessor/Inputs/numbers.txt (-1)
  • (removed) clang/test/Preprocessor/Inputs/single_byte.txt (-1)
  • (removed) clang/test/Preprocessor/embed___has_embed.c (-60)
  • (removed) clang/test/Preprocessor/embed___has_embed_parsing_errors.c (-240)
  • (removed) clang/test/Preprocessor/embed___has_embed_supported.c (-24)
  • (removed) clang/test/Preprocessor/embed_art.c (-104)
  • (removed) clang/test/Preprocessor/embed_codegen.cpp (-84)
  • (removed) clang/test/Preprocessor/embed_constexpr.cpp (-97)
  • (removed) clang/test/Preprocessor/embed_dependencies.c (-20)
  • (removed) clang/test/Preprocessor/embed_ext_compat_diags.c (-16)
  • (removed) clang/test/Preprocessor/embed_feature_test.cpp (-7)
  • (removed) clang/test/Preprocessor/embed_file_not_found_chevron.c (-4)
  • (removed) clang/test/Preprocessor/embed_file_not_found_quote.c (-4)
  • (removed) clang/test/Preprocessor/embed_init.c (-29)
  • (removed) clang/test/Preprocessor/embed_parameter_if_empty.c (-24)
  • (removed) clang/test/Preprocessor/embed_parameter_limit.c (-94)
  • (removed) clang/test/Preprocessor/embed_parameter_offset.c (-89)
  • (removed) clang/test/Preprocessor/embed_parameter_prefix.c (-38)
  • (removed) clang/test/Preprocessor/embed_parameter_suffix.c (-39)
  • (removed) clang/test/Preprocessor/embed_parameter_unrecognized.c (-9)
  • (removed) clang/test/Preprocessor/embed_parsing_errors.c (-130)
  • (removed) clang/test/Preprocessor/embed_path_chevron.c (-8)
  • (removed) clang/test/Preprocessor/embed_path_quote.c (-8)
  • (removed) clang/test/Preprocessor/embed_preprocess_to_file.c (-39)
  • (removed) clang/test/Preprocessor/embed_single_entity.c (-7)
  • (removed) clang/test/Preprocessor/embed_weird.cpp (-98)
  • (modified) clang/test/Preprocessor/init-aarch64.c (-3)
  • (modified) clang/test/Preprocessor/init.c (-3)
  • (removed) clang/test/Preprocessor/single_byte.txt (-1)
  • (modified) clang/tools/libclang/CXCursor.cpp (-1)
  • (modified) clang/www/c_status.html (+1-1)
diff --git a/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp b/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
index 7c2a231101070..1d85607e86b7f 100644
--- a/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
+++ b/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
@@ -31,15 +31,6 @@ X
 // CHECK:        MacroNameTok: __STDC_UTF_32__
 // CHECK-NEXT:   MacroDirective: MD_Define
 // CHECK:      - Callback: MacroDefined
-// CHECK-NEXT:   MacroNameTok: __STDC_EMBED_NOT_FOUND__
-// CHECK-NEXT:   MacroDirective: MD_Define
-// CHECK:      - Callback: MacroDefined
-// CHECK-NEXT:   MacroNameTok: __STDC_EMBED_FOUND__
-// CHECK-NEXT:   MacroDirective: MD_Define
-// CHECK:      - Callback: MacroDefined
-// CHECK-NEXT:   MacroNameTok: __STDC_EMBED_EMPTY__
-// CHECK-NEXT:   MacroDirective: MD_Define
-// CHECK:      - Callback: MacroDefined
 // CHECK:      - Callback: MacroDefined
 // CHECK-NEXT:   MacroNameTok: MACRO
 // CHECK-NEXT:   MacroDirective: MD_Define
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 1b5db388301f7..a49e4122ffc10 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1502,7 +1502,6 @@ Attributes on Structured Bindings            __cpp_structured_bindings        C+
 Designated initializers (N494)                                                C99           C89
 Array & element qualification (N2607)                                         C23           C89
 Attributes (N2335)                                                            C23           C89
-``#embed`` (N3017)                                                            C23           C89, C++
 ============================================ ================================ ============= =============
 
 Type Trait Primitives
@@ -5665,26 +5664,3 @@ Compiling different TUs depending on these flags (including use of
 ``std::hardware_destructive_interference``)  with different compilers, macro
 definitions, or architecture flags will lead to ODR violations and should be
 avoided.
-
-``#embed`` Parameters
-=====================
-
-``clang::offset``
------------------
-The ``clang::offset`` embed parameter may appear zero or one time in the
-embed parameter sequence. Its preprocessor argument clause shall be present and
-have the form:
-
-..code-block: text
-
-  ( constant-expression )
-
-and shall be an integer constant expression. The integer constant expression
-shall not evaluate to a value less than 0. The token ``defined`` shall not
-appear within the constant expression.
-
-The offset will be used when reading the contents of the embedded resource to
-specify the starting offset to begin embedding from. The resources is treated
-as being empty if the specified offset is larger than the number of bytes in
-the resource. The offset will be applied *before* any ``limit`` parameters are
-applied.
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 352e4467ed9dd..f2bf667636dc9 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4799,166 +4799,6 @@ class SourceLocExpr final : public Expr {
   friend class ASTStmtReader;
 };
 
-/// Stores data related to a single #embed directive.
-struct EmbedDataStorage {
-  StringLiteral *Filename;
-  StringLiteral *BinaryData;
-  size_t getDataElementCount() const { return BinaryData->getByteLength(); }
-};
-
-/// Represents a reference to #emded data. By default, this references the whole
-/// range. Otherwise it represents a subrange of data imported by #embed
-/// directive. Needed to handle nested initializer lists with #embed directives.
-/// Example:
-///  struct S {
-///    int x, y;
-///  };
-///
-///  struct T {
-///    int x[2];
-///    struct S s
-///  };
-///
-///  struct T t[] = {
-///  #embed "data" // data contains 10 elements;
-///  };
-///
-/// The resulting semantic form of initializer list will contain (EE stands
-/// for EmbedExpr):
-///  { {EE(first two data elements), {EE(3rd element), EE(4th element) }},
-///  { {EE(5th and 6th element), {EE(7th element), EE(8th element) }},
-///  { {EE(9th and 10th element), { zeroinitializer }}}
-///
-/// EmbedExpr inside of a semantic initializer list and referencing more than
-/// one element can only appear for arrays of scalars.
-class EmbedExpr final : public Expr {
-  SourceLocation EmbedKeywordLoc;
-  IntegerLiteral *FakeChildNode = nullptr;
-  const ASTContext *Ctx = nullptr;
-  EmbedDataStorage *Data;
-  unsigned Begin = 0;
-  unsigned NumOfElements;
-
-public:
-  EmbedExpr(const ASTContext &Ctx, SourceLocation Loc, EmbedDataStorage *Data,
-            unsigned Begin, unsigned NumOfElements);
-  explicit EmbedExpr(EmptyShell Empty) : Expr(SourceLocExprClass, Empty) {}
-
-  SourceLocation getLocation() const { return EmbedKeywordLoc; }
-  SourceLocation getBeginLoc() const { return EmbedKeywordLoc; }
-  SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
-
-  StringLiteral *getFilenameStringLiteral() const { return Data->Filename; }
-  StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
-  EmbedDataStorage *getData() const { return Data; }
-
-  unsigned getStartingElementPos() const { return Begin; }
-  size_t getDataElementCount() const { return NumOfElements; }
-
-  // Allows accessing every byte of EmbedExpr data and iterating over it.
-  // An Iterator knows the EmbedExpr that it refers to, and an offset value
-  // within the data.
-  // Dereferencing an Iterator results in construction of IntegerLiteral AST
-  // node filled with byte of data of the corresponding EmbedExpr within offset
-  // that the Iterator currently has.
-  template <bool Const>
-  class ChildElementIter
-      : public llvm::iterator_facade_base<
-            ChildElementIter<Const>, std::random_access_iterator_tag,
-            std::conditional_t<Const, const IntegerLiteral *,
-                               IntegerLiteral *>> {
-    friend class EmbedExpr;
-
-    EmbedExpr *EExpr = nullptr;
-    unsigned long long CurOffset = ULLONG_MAX;
-    using BaseTy = typename ChildElementIter::iterator_facade_base;
-
-    ChildElementIter(EmbedExpr *E) : EExpr(E) {
-      if (E)
-        CurOffset = E->getStartingElementPos();
-    }
-
-  public:
-    ChildElementIter() : CurOffset(ULLONG_MAX) {}
-    typename BaseTy::reference operator*() const {
-      assert(EExpr && CurOffset != ULLONG_MAX &&
-             "trying to dereference an invalid iterator");
-      IntegerLiteral *N = EExpr->FakeChildNode;
-      StringRef DataRef = EExpr->Data->BinaryData->getBytes();
-      N->setValue(*EExpr->Ctx,
-                  llvm::APInt(N->getValue().getBitWidth(), DataRef[CurOffset],
-                              N->getType()->isSignedIntegerType()));
-      // We want to return a reference to the fake child node in the
-      // EmbedExpr, not the local variable N.
-      return const_cast<typename BaseTy::reference>(EExpr->FakeChildNode);
-    }
-    typename BaseTy::pointer operator->() const { return **this; }
-    using BaseTy::operator++;
-    ChildElementIter &operator++() {
-      assert(EExpr && "trying to increment an invalid iterator");
-      assert(CurOffset != ULLONG_MAX &&
-             "Already at the end of what we can iterate over");
-      if (++CurOffset >=
-          EExpr->getDataElementCount() + EExpr->getStartingElementPos()) {
-        CurOffset = ULLONG_MAX;
-        EExpr = nullptr;
-      }
-      return *this;
-    }
-    bool operator==(ChildElementIter Other) const {
-      return (EExpr == Other.EExpr && CurOffset == Other.CurOffset);
-    }
-  }; // class ChildElementIter
-
-public:
-  using fake_child_range = llvm::iterator_range<ChildElementIter<false>>;
-  using const_fake_child_range = llvm::iterator_range<ChildElementIter<true>>;
-
-  fake_child_range underlying_data_elements() {
-    return fake_child_range(ChildElementIter<false>(this),
-                            ChildElementIter<false>());
-  }
-
-  const_fake_child_range underlying_data_elements() const {
-    return const_fake_child_range(
-        ChildElementIter<true>(const_cast<EmbedExpr *>(this)),
-        ChildElementIter<true>());
-  }
-
-  child_range children() {
-    return child_range(child_iterator(), child_iterator());
-  }
-
-  const_child_range children() const {
-    return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-
-  static bool classof(const Stmt *T) {
-    return T->getStmtClass() == EmbedExprClass;
-  }
-
-  ChildElementIter<false> begin() { return ChildElementIter<false>(this); }
-
-  ChildElementIter<true> begin() const {
-    return ChildElementIter<true>(const_cast<EmbedExpr *>(this));
-  }
-
-  template <typename Call, typename... Targs>
-  bool doForEachDataElement(Call &&C, unsigned &StartingIndexInArray,
-                            Targs &&...Fargs) const {
-    for (auto It : underlying_data_elements()) {
-      if (!std::invoke(std::forward<Call>(C), const_cast<IntegerLiteral *>(It),
-                       StartingIndexInArray, std::forward<Targs>(Fargs)...))
-        return false;
-      StartingIndexInArray++;
-    }
-    return true;
-  }
-
-private:
-  friend class ASTStmtReader;
-};
-
 /// Describes an C or C++ initializer list.
 ///
 /// InitListExpr describes an initializer list, which can be used to
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 2785afd59bf21..aa55e2e7e8718 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2864,11 +2864,6 @@ DEF_TRAVERSE_STMT(ShuffleVectorExpr, {})
 DEF_TRAVERSE_STMT(ConvertVectorExpr, {})
 DEF_TRAVERSE_STMT(StmtExpr, {})
 DEF_TRAVERSE_STMT(SourceLocExpr, {})
-DEF_TRAVERSE_STMT(EmbedExpr, {
-  for (IntegerLiteral *IL : S->underlying_data_elements()) {
-    TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(IL);
-  }
-})
 
 DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index 39dd1f515c9eb..abfafcaef271b 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -409,7 +409,6 @@ class TextNodeDumper
   void VisitHLSLBufferDecl(const HLSLBufferDecl *D);
   void VisitOpenACCConstructStmt(const OpenACCConstructStmt *S);
   void VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S);
-  void VisitEmbedExpr(const EmbedExpr *S);
 };
 
 } // namespace clang
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index de758cbe679dc..1e44bc4ad09b6 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -275,9 +275,6 @@ def err_too_large_for_fixed_point : Error<
 def err_unimplemented_conversion_with_fixed_point_type : Error<
   "conversion between fixed point and %0 is not yet supported">;
 
-def err_requires_positive_value : Error<
-  "%select{invalid value '%0'; must be positive|value '%0' is too large}1">;
-
 // SEH
 def err_seh_expected_handler : Error<
   "expected '__except' or '__finally' block">;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 12d7b8c0205ee..25fbfe83fa2bc 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -436,14 +436,6 @@ def warn_cxx23_compat_warning_directive : Warning<
 def warn_c23_compat_warning_directive : Warning<
   "#warning is incompatible with C standards before C23">,
   InGroup<CPre23Compat>, DefaultIgnore;
-def ext_pp_embed_directive : ExtWarn<
-  "#embed is a %select{C23|Clang}0 extension">,
-  InGroup<C23>;
-def warn_compat_pp_embed_directive : Warning<
-  "#embed is incompatible with C standards before C23">,
-  InGroup<CPre23Compat>, DefaultIgnore;
-def err_pp_embed_dup_params : Error<
-  "cannot specify parameter '%0' twice in the same '#embed' directive">;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<
   "extra tokens at end of #%0 directive">, InGroup<ExtraTokens>;
@@ -513,8 +505,6 @@ def err_pp_invalid_directive : Error<
   "invalid preprocessing directive%select{|, did you mean '#%1'?}0">;
 def warn_pp_invalid_directive : Warning<
   err_pp_invalid_directive.Summary>, InGroup<DiagGroup<"unknown-directives">>;
-def err_pp_unknown_parameter : Error<
-  "unknown%select{ | embed}0 preprocessor parameter '%1'">;
 def err_pp_directive_required : Error<
   "%0 must be used within a preprocessing directive">;
 def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
@@ -729,8 +719,6 @@ def err_pp_module_build_missing_end : Error<
   "no matching '#pragma clang module endbuild' for this '#pragma clang module build'">;
 
 def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
-def err_defined_in_pp_embed : Error<
-  "'defined' cannot appear within this context">;
 def err_paste_at_start : Error<
   "'##' cannot appear at start of macro expansion">;
 def err_paste_at_end : Error<"'##' cannot appear at end of macro expansion">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a104dfb766a98..193eae3bc41d6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1097,6 +1097,8 @@ def note_surrounding_namespace_starts_here : Note<
   "surrounding namespace with visibility attribute starts here">;
 def err_pragma_loop_invalid_argument_type : Error<
   "invalid argument of type %0; expected an integer type">;
+def err_pragma_loop_invalid_argument_value : Error<
+  "%select{invalid value '%0'; must be positive|value '%0' is too large}1">;
 def err_pragma_loop_compatibility : Error<
   "%select{incompatible|duplicate}0 directives '%1' and '%2'">;
 def err_pragma_loop_precedes_nonloop : Error<
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 527bbef24793e..e1f33d57a8980 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -286,15 +286,12 @@ class FileManager : public RefCountedBase<FileManager> {
   /// MemoryBuffer if successful, otherwise returning null.
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
   getBufferForFile(FileEntryRef Entry, bool isVolatile = false,
-                   bool RequiresNullTerminator = true,
-                   std::optional<int64_t> MaybeLimit = std::nullopt);
+                   bool RequiresNullTerminator = true);
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
   getBufferForFile(StringRef Filename, bool isVolatile = false,
-                   bool RequiresNullTerminator = true,
-                   std::optional<int64_t> MaybeLimit = std::nullopt) const {
-    return getBufferForFileImpl(Filename,
-                                /*FileSize=*/(MaybeLimit ? *MaybeLimit : -1),
-                                isVolatile, RequiresNullTerminator);
+                   bool RequiresNullTerminator = true) const {
+    return getBufferForFileImpl(Filename, /*FileSize=*/-1, isVolatile,
+                                RequiresNullTerminator);
   }
 
 private:
diff --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td
index c59a17be7808f..6ca08abdb14f0 100644
--- a/clang/include/clang/Basic/StmtNodes.td
+++ b/clang/include/clang/Basic/StmtNodes.td
@@ -204,7 +204,6 @@ def OpaqueValueExpr : StmtNode<Expr>;
 def TypoExpr : StmtNode<Expr>;
 def RecoveryExpr : StmtNode<Expr>;
 def BuiltinBitCastExpr : StmtNode<ExplicitCastExpr>;
-def EmbedExpr : StmtNode<Expr>;
 
 // Microsoft Extensions.
 def MSPropertyRefExpr : StmtNode<Expr>;
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 37d570ca5e75b..9c4b17465e18a 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -126,9 +126,6 @@ PPKEYWORD(error)
 // C99 6.10.6 - Pragma Directive.
 PPKEYWORD(pragma)
 
-// C23 & C++26 #embed
-PPKEYWORD(embed)
-
 // GNU Extensions.
 PPKEYWORD(import)
 PPKEYWORD(include_next)
@@ -1002,9 +999,6 @@ ANNOTATION(header_unit)
 // Annotation for end of input in clang-repl.
 ANNOTATION(repl_input_end)
 
-// Annotation for #embed
-ANNOTATION(embed)
-
 #undef PRAGMA_ANNOTATION
 #undef ANNOTATION
 #undef TESTING_KEYWORD
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..d44faa55c456f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -880,9 +880,6 @@ will be ignored}]>;
 def L : JoinedOrSeparate<["-"], "L">, Flags<[RenderJoined]>, Group<Link_Group>,
     Visibility<[ClangOption, FlangOption]>,
     MetaVarName<"<dir>">, HelpText<"Add directory to library search path">;
-def embed_dir_EQ : Joined<["--"], "embed-dir=">, Group<Preprocessor_Group>,
-    Visibility<[ClangOption, CC1Option]>, MetaVarName<"<dir>">,
-    HelpText<"Add directory to embed search path">;
 def MD : Flag<["-"], "MD">, Group<M_Group>,
     HelpText<"Write a depfile containing user and system headers">;
 def MMD : Flag<["-"], "MMD">, Group<M_Group>,
@@ -1476,9 +1473,6 @@ def dD : Flag<["-"], "dD">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>
 def dI : Flag<["-"], "dI">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Print include directives in -E mode in addition to normal output">,
   MarshallingInfoFlag<PreprocessorOutputOpts<"ShowIncludeDirectives">>;
-def dE : Flag<["-"], "dE">, Group<d_Group>, Visibility<[CC1Option]>,
-  HelpText<"Print embed directives in -E mode in addition to normal output">,
-  MarshallingInfoFlag<PreprocessorOutputOpts<"ShowEmbedDirectives">>;
 def dM : Flag<["-"], "dM">, Group<d_Group>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Print macro definitions in -E mode instead of normal output">;
 def dead__strip : Flag<["-"], "dead_strip">;
diff --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
index 654cf22f010f7..6e19cae33cf28 100644
--- a/clang/include/clang/Frontend/PreprocessorOutputOptions.h
+++ b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
@@ -32,8 +32,6 @@ class PreprocessorOutputOptions {
   LLVM_PREFERRED_TYPE(bool)
   unsigned ShowIncludeDirectives : 1;  ///< Print includes, imports etc. within preprocessed output.
   LLVM_PREFERRED_TYPE(bool)
-  unsigned ShowEmbedDirectives : 1; ///< Print embeds, etc. within preprocessed
-  LLVM_PREFERRED_TYPE(bool)
   unsigned RewriteIncludes : 1;    ///< Preprocess include directives only.
   LLVM_PREFERRED_TYPE(bool)
   unsigned RewriteImports  : 1;    ///< Include contents of transitively-imported modules.
@@ -53,7 +51,6 @@ class PreprocessorOutputOptions {
     ShowMacroComments = 0;
     ShowMacros = 0;
     ShowIncludeDirectives = 0;
-    ShowEmbedDirectives = 0;
     RewriteIncludes = 0;
     RewriteImports = 0;
     MinimizeWhitespace = 0;
diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h
index 46cc564086f1c..dfc74b52686f1 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -27,7 +27,6 @@ class IdentifierInfo;
 class MacroDefinition;
 class MacroDirective;
 class MacroArgs;
-struct LexEmbedParametersResult;
 
 /// This interface provides a way to observe the actions of the
 /// preprocessor as it does its thing.
@@ -84,34 +83,6 @@ class PPCallbacks {
                            const Token &FilenameTok,
                            SrcMgr::CharacteristicKind FileType) {}
 
-  /// Callback invoked whenever the preprocessor cannot find a file for an
-  /// embed directive.
-  ///
-  /// \param FileName The name of the file being included, as written in the
-  /// source code.
-  ///
-  /// \returns true to indicate that the preprocessor should skip this file
-  /// and not issue any diagnostic.
-  virtual bool EmbedFileNotFound(StringRef FileName) { return false; }
-
-  /// Callback invoked whenever an embed directive has been processed,
-  /// regardless of whether the embed will actually find a file.
-  ///
-  /// \param HashLoc The location of the '#' that starts the embed directive.
-  ///
-  /// \param FileName The...
[truncated]

@vitalybuka
Copy link
Collaborator Author

The patch is large, so I'll take another look, if there is a trivial fix.
So please approve without merging.

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 7b8038426c52d5fee9c2f4cfe3e747e3a2b8efec 2f331308fcdc9c0d94644b673b61cbe478b6ed6f -- clang-tools-extra/test/pp-trace/pp-trace-macro.cpp clang/include/clang/AST/Expr.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/AST/TextNodeDumper.h clang/include/clang/Basic/FileManager.h clang/include/clang/Frontend/PreprocessorOutputOptions.h clang/include/clang/Lex/PPCallbacks.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Lex/PreprocessorOptions.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/Expr.cpp clang/lib/AST/ExprClassification.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/Basic/FileManager.cpp clang/lib/Basic/IdentifierTable.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/DependencyFile.cpp clang/lib/Frontend/DependencyGraph.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/lib/Frontend/PrintPreprocessedOutput.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPExpressions.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/TokenConcatenation.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseInit.cpp clang/lib/Parse/ParseTemplate.cpp clang/lib/Sema/SemaExceptionSpec.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/lib/StaticAnalyzer/Core/ExprEngine.cpp clang/test/Preprocessor/init-aarch64.c clang/test/Preprocessor/init.c clang/tools/libclang/CXCursor.cpp
View the diff from clang-format here.
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d5057452ce..0c4e2ff508 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11270,8 +11270,8 @@ bool ArrayExprEvaluator::VisitCXXParenListOrInitListExpr(
   Subobject.addArray(Info, ExprToVisit, CAT);
   for (unsigned Index = 0; Index != NumEltsToInit; ++Index) {
     const Expr *Init = Index < Args.size() ? Args[Index] : ArrayFiller;
-    if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
-                         Info, Subobject, Init) ||
+    if (!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, Subobject,
+                         Init) ||
         !HandleLValueArrayAdjustment(Info, Init, Subobject,
                                      CAT->getElementType(), 1)) {
       if (!Info.noteFailure())
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index feea84544d..f6524c4f69 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -425,8 +425,8 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
   // collisions (if there were, the switch below would complain about duplicate
   // case values).  Note that this depends on 'if' being null terminated.
 
-#define HASH(LEN, FIRST, THIRD) \
-  (LEN << 5) + (((FIRST-'a') + (THIRD-'a')) & 31)
+#define HASH(LEN, FIRST, THIRD)                                                \
+  (LEN << 5) + (((FIRST - 'a') + (THIRD - 'a')) & 31)
 #define CASE(LEN, FIRST, THIRD, NAME) \
   case HASH(LEN, FIRST, THIRD): \
     return memcmp(Name, #NAME, LEN) ? tok::pp_not_keyword : tok::pp_ ## NAME
@@ -440,7 +440,7 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
   CASE( 4, 'e', 'i', elif);
   CASE( 4, 'e', 's', else);
   CASE( 4, 'l', 'n', line);
-  CASE( 4, 's', 'c', sccs);
+  CASE(4, 's', 'c', sccs);
   CASE( 5, 'e', 'd', endif);
   CASE( 5, 'e', 'r', error);
   CASE( 5, 'i', 'e', ident);
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index b2a5ceeeae..fc2a909d86 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -588,7 +588,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,
       // Tell the cleanup that it needs to destroy up to this
       // element.  TODO: some of these stores can be trivially
       // observed to be unnecessary.
-      if (endOfInit.isValid()) Builder.CreateStore(element, endOfInit);
+      if (endOfInit.isValid())
+        Builder.CreateStore(element, endOfInit);
     }
 
     LValue elementLV = CGF.MakeAddrLValue(
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 0712f40fd8..a5eea77a87 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1270,7 +1270,7 @@ public:
     }
 
     // Copy initializer elements.
-    SmallVector<llvm::Constant*, 16> Elts;
+    SmallVector<llvm::Constant *, 16> Elts;
     if (fillC && fillC->isNullValue())
       Elts.reserve(NumInitableElts + 1);
     else
diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp
index 20e5f233e2..4dd7dc9f15 100644
--- a/clang/lib/Frontend/DependencyGraph.cpp
+++ b/clang/lib/Frontend/DependencyGraph.cpp
@@ -43,7 +43,7 @@ private:
 public:
   DependencyGraphCallback(const Preprocessor *_PP, StringRef OutputFile,
                           StringRef SysRoot)
-    : PP(_PP), OutputFile(OutputFile.str()), SysRoot(SysRoot.str()) { }
+      : PP(_PP), OutputFile(OutputFile.str()), SysRoot(SysRoot.str()) {}
 
   void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
                           StringRef FileName, bool IsAngled,
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index a26d2c3ab8..2c248fc5f4 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -11,11 +11,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Frontend/Utils.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Pragma.h"
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 332e1179f0..a0e1869894 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7290,8 +7290,8 @@ Sema::BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
     }
   }
 
-  InitListExpr *E = new (Context) InitListExpr(Context, LBraceLoc, InitArgList,
-                                               RBraceLoc);
+  InitListExpr *E =
+      new (Context) InitListExpr(Context, LBraceLoc, InitArgList, RBraceLoc);
   E->setType(Context.VoidTy); // FIXME: just a place holder for now.
   return E;
 }
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7244f3ef4e..23883ad3ef 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -2051,9 +2051,8 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity,
     if (maxElementsKnown && elementIndex == maxElements)
       break;
 
-    InitializedEntity ElementEntity =
-      InitializedEntity::InitializeElement(SemaRef.Context, StructuredIndex,
-                                           Entity);
+    InitializedEntity ElementEntity = InitializedEntity::InitializeElement(
+        SemaRef.Context, StructuredIndex, Entity);
     // Check this element.
     CheckSubElementType(ElementEntity, IList, elementType, Index,
                         StructuredList, StructuredIndex);
@@ -9070,8 +9069,8 @@ ExprResult InitializationSequence::Perform(Sema &S,
           : Kind.isExplicitCast()   ? CheckedConversionKind::OtherCast
                                     : CheckedConversionKind::Implicit;
       ExprResult CurInitExprRes =
-        S.PerformImplicitConversion(CurInit.get(), Step->Type, *Step->ICS,
-                                    getAssignmentAction(Entity), CCK);
+          S.PerformImplicitConversion(CurInit.get(), Step->Type, *Step->ICS,
+                                      getAssignmentAction(Entity), CCK);
       if (CurInitExprRes.isInvalid())
         return ExprError();
 

@vitalybuka
Copy link
Collaborator Author

I guess I will proceed with revert, I don't know meaning that failed assert in the test, and expected ownership of EmbedAnnotationData is not clear to me.

@vitalybuka vitalybuka merged commit 682d461 into main Jun 12, 2024
13 of 16 checks passed
@vitalybuka vitalybuka deleted the revert-68620-thephd/embed-speed branch June 12, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang:static analyzer clang Clang issues not falling into any other category clang-tools-extra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants