Skip to content

Fix OOM in FormatDiagnostic #108187

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

Conversation

igelbox
Copy link
Contributor

@igelbox igelbox commented Sep 11, 2024

Resolves: #70930 (and probably latest comments from clangd/clangd#251)
by fixing racing for the shared DiagStorage value which caused messing with args inside the storage and then formatting the following message with getArgSInt(1) == 2:

def err_module_odr_violation_function : Error<
  "%q0 has different definitions in different modules; "
  "%select{definition in module '%2'|defined here}1 "
  "first difference is "

which causes HandleSelectModifier to go beyond the ArgumentLen so the recursive call to FormatDiagnostic was made with DiagStr > DiagEnd that leads to infinite while (DiagStr != DiagEnd).

The Main Idea:
Reuse the existing DiagStorageAllocator logic to make all DiagnosticBuilders having independent states.
Also, encapsulating the rest of state (e.g. ID and Loc) into DiagnosticBuilder.

TODO (if it will be requested by reviewer):

  • add a test (I have no idea how to turn a whole bunch of my proprietary code which leads clangd to OOM into a small public example.. probably I must try using this instead)
  • Diag.CurDiagID != diag::fatal_too_many_errors
  • ? get rid of DiagStorageAllocator at all and make DiagnosticBuilder having they own DiagnosticStorage coz it seems pretty small so should fit the stack for short-living DiagnosticBuilder instances

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@igelbox igelbox force-pushed the fix--race-condition-caused--infinity-cycle--memory-leak branch from f26c4f3 to aee4cf7 Compare September 11, 2024 11:51
@igelbox igelbox marked this pull request as ready for review September 11, 2024 13:02
@igelbox igelbox requested a review from Endilll as a code owner September 11, 2024 13:02
@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clang-tidy 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 labels Sep 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2024

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

@llvm/pr-subscribers-clang-driver

Author: Vakhurin Sergei (igelbox)

Changes

Resolves: #70930 (and probably latest comments from clangd/clangd#251)
by fixing racing for the shared DiagStorage value which caused messing with args inside the storage and then formatting the following message with getArgSInt(1) == 2:

def err_module_odr_violation_function : Error&lt;
  "%q0 has different definitions in different modules; "
  "%select{definition in module '%2'|defined here}1 "
  "first difference is "

which causes HandleSelectModifier to go beyond the ArgumentLen so the recursive call to FormatDiagnostic was made with DiagStr > DiagEnd that leads to infinite while (DiagStr != DiagEnd).

The Main Idea:
Reuse the existing DiagStorageAllocator logic to make all DiagnosticBuilders having independent states.
Also, encapsulating the rest of state (e.g. ID and Loc) into DiagnosticBuilder.

TODO (if it will be requested by reviewer):

  • add a test (I have no idea how to turn a whole bunch of my proprietary code which leads clangd to OOM into a small public example.. probably I must try using this instead)
  • Diag.CurDiagID != diag::fatal_too_many_errors
  • ? get rid of DiagStorageAllocator at all and make DiagnosticBuilder having they own DiagnosticStorage coz it seems pretty small so should fit the stack for short-living DiagnosticBuilder instances

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

15 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp (-2)
  • (modified) clang/include/clang/Basic/Diagnostic.h (+93-176)
  • (modified) clang/include/clang/Basic/DiagnosticIDs.h (+5-2)
  • (modified) clang/include/clang/Basic/PartialDiagnostic.h (+1-4)
  • (modified) clang/include/clang/Sema/Sema.h (+3-3)
  • (modified) clang/lib/Basic/Diagnostic.cpp (+43-43)
  • (modified) clang/lib/Basic/DiagnosticIDs.cpp (+11-11)
  • (modified) clang/lib/Basic/SourceManager.cpp (+4-19)
  • (modified) clang/lib/Frontend/Rewrite/FixItRewriter.cpp (+1-3)
  • (modified) clang/lib/Frontend/TextDiagnosticPrinter.cpp (+1-1)
  • (modified) clang/lib/Sema/Sema.cpp (+6-13)
  • (modified) clang/lib/Sema/SemaBase.cpp (+1-1)
  • (modified) clang/lib/Serialization/ASTReader.cpp (+5-10)
  • (modified) clang/unittests/Basic/DiagnosticTest.cpp (-4)
  • (modified) clang/unittests/Driver/DXCModeTest.cpp (-5)
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 200bb87a5ac3cb..4c75b422701148 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -380,7 +380,6 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
     ++Context.Stats.ErrorsIgnoredNOLINT;
     // Ignored a warning, should ignore related notes as well
     LastErrorWasIgnored = true;
-    Context.DiagEngine->Clear();
     for (const auto &Error : SuppressionErrors)
       Context.diag(Error);
     return;
@@ -457,7 +456,6 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
   if (Info.hasSourceManager())
     checkFilters(Info.getLocation(), Info.getSourceManager());
 
-  Context.DiagEngine->Clear();
   for (const auto &Error : SuppressionErrors)
     Context.diag(Error);
 }
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 0c7836c2ea569c..1eecab4f6e49a2 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -183,6 +183,41 @@ struct DiagnosticStorage {
   DiagnosticStorage() = default;
 };
 
+/// An allocator for DiagnosticStorage objects, which uses a small cache to
+/// objects, used to reduce malloc()/free() traffic for partial diagnostics.
+class DiagStorageAllocator {
+  static const unsigned NumCached = 16;
+  DiagnosticStorage Cached[NumCached];
+  DiagnosticStorage *FreeList[NumCached];
+  unsigned NumFreeListEntries;
+
+public:
+  DiagStorageAllocator();
+  ~DiagStorageAllocator();
+
+  /// Allocate new storage.
+  DiagnosticStorage *Allocate() {
+    if (NumFreeListEntries == 0)
+      return new DiagnosticStorage;
+
+    DiagnosticStorage *Result = FreeList[--NumFreeListEntries];
+    Result->NumDiagArgs = 0;
+    Result->DiagRanges.clear();
+    Result->FixItHints.clear();
+    return Result;
+  }
+
+  /// Free the given storage object.
+  void Deallocate(DiagnosticStorage *S) {
+    if (S >= Cached && S <= Cached + NumCached) {
+      FreeList[NumFreeListEntries++] = S;
+      return;
+    }
+
+    delete S;
+  }
+};
+
 /// Concrete class used by the front-end to report problems and issues.
 ///
 /// This massages the diagnostics (e.g. handling things like "report warnings
@@ -520,27 +555,6 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
   void *ArgToStringCookie = nullptr;
   ArgToStringFnTy ArgToStringFn;
 
-  /// ID of the "delayed" diagnostic, which is a (typically
-  /// fatal) diagnostic that had to be delayed because it was found
-  /// while emitting another diagnostic.
-  unsigned DelayedDiagID;
-
-  /// First string argument for the delayed diagnostic.
-  std::string DelayedDiagArg1;
-
-  /// Second string argument for the delayed diagnostic.
-  std::string DelayedDiagArg2;
-
-  /// Third string argument for the delayed diagnostic.
-  std::string DelayedDiagArg3;
-
-  /// Optional flag value.
-  ///
-  /// Some flags accept values, for instance: -Wframe-larger-than=<value> and
-  /// -Rpass=<value>. The content of this string is emitted after the flag name
-  /// and '='.
-  std::string FlagValue;
-
 public:
   explicit DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDs> Diags,
                              IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
@@ -945,50 +959,11 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
 
   void Report(const StoredDiagnostic &storedDiag);
 
-  /// Determine whethere there is already a diagnostic in flight.
-  bool isDiagnosticInFlight() const {
-    return CurDiagID != std::numeric_limits<unsigned>::max();
-  }
-
-  /// Set the "delayed" diagnostic that will be emitted once
-  /// the current diagnostic completes.
-  ///
-  ///  If a diagnostic is already in-flight but the front end must
-  ///  report a problem (e.g., with an inconsistent file system
-  ///  state), this routine sets a "delayed" diagnostic that will be
-  ///  emitted after the current diagnostic completes. This should
-  ///  only be used for fatal errors detected at inconvenient
-  ///  times. If emitting a delayed diagnostic causes a second delayed
-  ///  diagnostic to be introduced, that second delayed diagnostic
-  ///  will be ignored.
-  ///
-  /// \param DiagID The ID of the diagnostic being delayed.
-  ///
-  /// \param Arg1 A string argument that will be provided to the
-  /// diagnostic. A copy of this string will be stored in the
-  /// DiagnosticsEngine object itself.
-  ///
-  /// \param Arg2 A string argument that will be provided to the
-  /// diagnostic. A copy of this string will be stored in the
-  /// DiagnosticsEngine object itself.
-  ///
-  /// \param Arg3 A string argument that will be provided to the
-  /// diagnostic. A copy of this string will be stored in the
-  /// DiagnosticsEngine object itself.
-  void SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1 = "",
-                            StringRef Arg2 = "", StringRef Arg3 = "");
-
-  /// Clear out the current diagnostic.
-  void Clear() { CurDiagID = std::numeric_limits<unsigned>::max(); }
-
-  /// Return the value associated with this diagnostic flag.
-  StringRef getFlagValue() const { return FlagValue; }
-
 private:
   // This is private state used by DiagnosticBuilder.  We put it here instead of
   // in DiagnosticBuilder in order to keep DiagnosticBuilder a small lightweight
-  // object.  This implementation choice means that we can only have one
-  // diagnostic "in flight" at a time, but this seems to be a reasonable
+  // object.  This implementation choice means that we can only have a few
+  // diagnostics "in flight" at a time, but this seems to be a reasonable
   // tradeoff to keep these objects small.  Assertions verify that only one
   // diagnostic is in flight at a time.
   friend class Diagnostic;
@@ -997,18 +972,6 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
   friend class DiagnosticIDs;
   friend class PartialDiagnostic;
 
-  /// Report the delayed diagnostic.
-  void ReportDelayed();
-
-  /// The location of the current diagnostic that is in flight.
-  SourceLocation CurDiagLoc;
-
-  /// The ID of the current diagnostic that is in flight.
-  ///
-  /// This is set to std::numeric_limits<unsigned>::max() when there is no
-  /// diagnostic in flight.
-  unsigned CurDiagID;
-
   enum {
     /// The maximum number of arguments we can hold.
     ///
@@ -1018,7 +981,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
     MaxArguments = DiagnosticStorage::MaxArguments,
   };
 
-  DiagnosticStorage DiagStorage;
+  DiagStorageAllocator DiagAllocator;
 
   DiagnosticMapping makeUserMapping(diag::Severity Map, SourceLocation L) {
     bool isPragma = L.isValid();
@@ -1038,8 +1001,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
   /// Used to report a diagnostic that is finally fully formed.
   ///
   /// \returns true if the diagnostic was emitted, false if it was suppressed.
-  bool ProcessDiag() {
-    return Diags->ProcessDiag(*this);
+  bool ProcessDiag(const DiagnosticBuilder &DiagBuilder) {
+    return Diags->ProcessDiag(*this, DiagBuilder);
   }
 
   /// @name Diagnostic Emission
@@ -1054,14 +1017,10 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
   // Sema::Diag() patterns.
   friend class Sema;
 
-  /// Emit the current diagnostic and clear the diagnostic state.
+  /// Emit the diagnostic
   ///
   /// \param Force Emit the diagnostic regardless of suppression settings.
-  bool EmitCurrentDiagnostic(bool Force = false);
-
-  unsigned getCurrentDiagID() const { return CurDiagID; }
-
-  SourceLocation getCurrentDiagLoc() const { return CurDiagLoc; }
+  bool EmitDiagnostic(const DiagnosticBuilder &DB, bool Force = false);
 
   /// @}
 };
@@ -1114,40 +1073,7 @@ class DiagnosticErrorTrap {
 ///
 class StreamingDiagnostic {
 public:
-  /// An allocator for DiagnosticStorage objects, which uses a small cache to
-  /// objects, used to reduce malloc()/free() traffic for partial diagnostics.
-  class DiagStorageAllocator {
-    static const unsigned NumCached = 16;
-    DiagnosticStorage Cached[NumCached];
-    DiagnosticStorage *FreeList[NumCached];
-    unsigned NumFreeListEntries;
-
-  public:
-    DiagStorageAllocator();
-    ~DiagStorageAllocator();
-
-    /// Allocate new storage.
-    DiagnosticStorage *Allocate() {
-      if (NumFreeListEntries == 0)
-        return new DiagnosticStorage;
-
-      DiagnosticStorage *Result = FreeList[--NumFreeListEntries];
-      Result->NumDiagArgs = 0;
-      Result->DiagRanges.clear();
-      Result->FixItHints.clear();
-      return Result;
-    }
-
-    /// Free the given storage object.
-    void Deallocate(DiagnosticStorage *S) {
-      if (S >= Cached && S <= Cached + NumCached) {
-        FreeList[NumFreeListEntries++] = S;
-        return;
-      }
-
-      delete S;
-    }
-  };
+  using DiagStorageAllocator = clang::DiagStorageAllocator;
 
 protected:
   mutable DiagnosticStorage *DiagStorage = nullptr;
@@ -1236,11 +1162,6 @@ class StreamingDiagnostic {
 protected:
   StreamingDiagnostic() = default;
 
-  /// Construct with an external storage not owned by itself. The allocator
-  /// is a null pointer in this case.
-  explicit StreamingDiagnostic(DiagnosticStorage *Storage)
-      : DiagStorage(Storage) {}
-
   /// Construct with a storage allocator which will manage the storage. The
   /// allocator is not a null pointer in this case.
   explicit StreamingDiagnostic(DiagStorageAllocator &Alloc)
@@ -1271,9 +1192,26 @@ class StreamingDiagnostic {
 class DiagnosticBuilder : public StreamingDiagnostic {
   friend class DiagnosticsEngine;
   friend class PartialDiagnostic;
+  friend class Diagnostic;
 
   mutable DiagnosticsEngine *DiagObj = nullptr;
 
+  /// The location of the current diagnostic that is in flight.
+  SourceLocation CurDiagLoc;
+
+  /// The ID of the current diagnostic that is in flight.
+  ///
+  /// This is set to std::numeric_limits<unsigned>::max() when there is no
+  /// diagnostic in flight.
+  unsigned CurDiagID;
+
+  /// Optional flag value.
+  ///
+  /// Some flags accept values, for instance: -Wframe-larger-than=<value> and
+  /// -Rpass=<value>. The content of this string is emitted after the flag name
+  /// and '='.
+  mutable std::string FlagValue;
+
   /// Status variable indicating if this diagnostic is still active.
   ///
   // NOTE: This field is redundant with DiagObj (IsActive iff (DiagObj == 0)),
@@ -1287,16 +1225,8 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 
   DiagnosticBuilder() = default;
 
-  explicit DiagnosticBuilder(DiagnosticsEngine *diagObj)
-      : StreamingDiagnostic(&diagObj->DiagStorage), DiagObj(diagObj),
-        IsActive(true) {
-    assert(diagObj && "DiagnosticBuilder requires a valid DiagnosticsEngine!");
-    assert(DiagStorage &&
-           "DiagnosticBuilder requires a valid DiagnosticStorage!");
-    DiagStorage->NumDiagArgs = 0;
-    DiagStorage->DiagRanges.clear();
-    DiagStorage->FixItHints.clear();
-  }
+  DiagnosticBuilder(DiagnosticsEngine *diagObj, SourceLocation CurDiagLoc,
+                    unsigned CurDiagID);
 
 protected:
   /// Clear out the current diagnostic.
@@ -1322,7 +1252,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
     if (!isActive()) return false;
 
     // Process the diagnostic.
-    bool Result = DiagObj->EmitCurrentDiagnostic(IsForceEmit);
+    bool Result = DiagObj->EmitDiagnostic(*this, IsForceEmit);
 
     // This diagnostic is dead.
     Clear();
@@ -1333,13 +1263,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic() {
-    DiagObj = D.DiagObj;
-    DiagStorage = D.DiagStorage;
-    IsActive = D.IsActive;
-    IsForceEmit = D.IsForceEmit;
-    D.Clear();
-  }
+  DiagnosticBuilder(const DiagnosticBuilder &D);
 
   template <typename T> const DiagnosticBuilder &operator<<(const T &V) const {
     assert(isActive() && "Clients must not add to cleared diagnostic!");
@@ -1371,7 +1295,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
     return *this;
   }
 
-  void addFlagValue(StringRef V) const { DiagObj->FlagValue = std::string(V); }
+  void addFlagValue(StringRef V) const { FlagValue = std::string(V); }
 };
 
 struct AddFlagValue {
@@ -1546,12 +1470,7 @@ const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
 
 inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
                                                    unsigned DiagID) {
-  assert(CurDiagID == std::numeric_limits<unsigned>::max() &&
-         "Multiple diagnostics in flight at once!");
-  CurDiagLoc = Loc;
-  CurDiagID = DiagID;
-  FlagValue.clear();
-  return DiagnosticBuilder(this);
+  return DiagnosticBuilder(this, Loc, DiagID);
 }
 
 const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
@@ -1570,20 +1489,25 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
 /// currently in-flight diagnostic.
 class Diagnostic {
   const DiagnosticsEngine *DiagObj;
+  SourceLocation CurDiagLoc;
+  unsigned CurDiagID;
+  std::string FlagValue;
+  const DiagnosticStorage &DiagStorage;
   std::optional<StringRef> StoredDiagMessage;
 
 public:
-  explicit Diagnostic(const DiagnosticsEngine *DO) : DiagObj(DO) {}
-  Diagnostic(const DiagnosticsEngine *DO, StringRef storedDiagMessage)
-      : DiagObj(DO), StoredDiagMessage(storedDiagMessage) {}
+  Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder);
+  Diagnostic(const DiagnosticsEngine *DO, SourceLocation CurDiagLoc,
+             unsigned CurDiagID, const DiagnosticStorage &DiagStorage,
+             StringRef storedDiagMessage);
 
   const DiagnosticsEngine *getDiags() const { return DiagObj; }
-  unsigned getID() const { return DiagObj->CurDiagID; }
-  const SourceLocation &getLocation() const { return DiagObj->CurDiagLoc; }
+  unsigned getID() const { return CurDiagID; }
+  const SourceLocation &getLocation() const { return CurDiagLoc; }
   bool hasSourceManager() const { return DiagObj->hasSourceManager(); }
   SourceManager &getSourceManager() const { return DiagObj->getSourceManager();}
 
-  unsigned getNumArgs() const { return DiagObj->DiagStorage.NumDiagArgs; }
+  unsigned getNumArgs() const { return DiagStorage.NumDiagArgs; }
 
   /// Return the kind of the specified index.
   ///
@@ -1593,8 +1517,7 @@ class Diagnostic {
   /// \pre Idx < getNumArgs()
   DiagnosticsEngine::ArgumentKind getArgKind(unsigned Idx) const {
     assert(Idx < getNumArgs() && "Argument index out of range!");
-    return (DiagnosticsEngine::ArgumentKind)
-        DiagObj->DiagStorage.DiagArgumentsKind[Idx];
+    return (DiagnosticsEngine::ArgumentKind)DiagStorage.DiagArgumentsKind[Idx];
   }
 
   /// Return the provided argument string specified by \p Idx.
@@ -1602,7 +1525,7 @@ class Diagnostic {
   const std::string &getArgStdStr(unsigned Idx) const {
     assert(getArgKind(Idx) == DiagnosticsEngine::ak_std_string &&
            "invalid argument accessor!");
-    return DiagObj->DiagStorage.DiagArgumentsStr[Idx];
+    return DiagStorage.DiagArgumentsStr[Idx];
   }
 
   /// Return the specified C string argument.
@@ -1610,8 +1533,7 @@ class Diagnostic {
   const char *getArgCStr(unsigned Idx) const {
     assert(getArgKind(Idx) == DiagnosticsEngine::ak_c_string &&
            "invalid argument accessor!");
-    return reinterpret_cast<const char *>(
-        DiagObj->DiagStorage.DiagArgumentsVal[Idx]);
+    return reinterpret_cast<const char *>(DiagStorage.DiagArgumentsVal[Idx]);
   }
 
   /// Return the specified signed integer argument.
@@ -1619,7 +1541,7 @@ class Diagnostic {
   int64_t getArgSInt(unsigned Idx) const {
     assert(getArgKind(Idx) == DiagnosticsEngine::ak_sint &&
            "invalid argument accessor!");
-    return (int64_t)DiagObj->DiagStorage.DiagArgumentsVal[Idx];
+    return (int64_t)DiagStorage.DiagArgumentsVal[Idx];
   }
 
   /// Return the specified unsigned integer argument.
@@ -1627,7 +1549,7 @@ class Diagnostic {
   uint64_t getArgUInt(unsigned Idx) const {
     assert(getArgKind(Idx) == DiagnosticsEngine::ak_uint &&
            "invalid argument accessor!");
-    return DiagObj->DiagStorage.DiagArgumentsVal[Idx];
+    return DiagStorage.DiagArgumentsVal[Idx];
   }
 
   /// Return the specified IdentifierInfo argument.
@@ -1636,7 +1558,7 @@ class Diagnostic {
     assert(getArgKind(Idx) == DiagnosticsEngine::ak_identifierinfo &&
            "invalid argument accessor!");
     return reinterpret_cast<IdentifierInfo *>(
-        DiagObj->DiagStorage.DiagArgumentsVal[Idx]);
+        DiagStorage.DiagArgumentsVal[Idx]);
   }
 
   /// Return the specified non-string argument in an opaque form.
@@ -1644,37 +1566,32 @@ class Diagnostic {
   uint64_t getRawArg(unsigned Idx) const {
     assert(getArgKind(Idx) != DiagnosticsEngine::ak_std_string &&
            "invalid argument accessor!");
-    return DiagObj->DiagStorage.DiagArgumentsVal[Idx];
+    return DiagStorage.DiagArgumentsVal[Idx];
   }
 
   /// Return the number of source ranges associated with this diagnostic.
-  unsigned getNumRanges() const {
-    return DiagObj->DiagStorage.DiagRanges.size();
-  }
+  unsigned getNumRanges() const { return DiagStorage.DiagRanges.size(); }
 
   /// \pre Idx < getNumRanges()
   const CharSourceRange &getRange(unsigned Idx) const {
     assert(Idx < getNumRanges() && "Invalid diagnostic range index!");
-    return DiagObj->DiagStorage.DiagRanges[Idx];
+    return DiagStorage.DiagRanges[Idx];
   }
 
   /// Return an array reference for this diagnostic's ranges.
-  ArrayRef<CharSourceRange> getRanges() const {
-    return DiagObj->DiagStorage.DiagRanges;
-  }
+  ArrayRef<CharSourceRange> getRanges() const { return DiagStorage.DiagRanges; }
 
-  unsigned getNumFixItHints() const {
-    return DiagObj->DiagStorage.FixItHints.size();
-  }
+  unsigned getNumFixItHints() const { return DiagStorage.FixItHints.size(); }
 
   const FixItHint &getFixItHint(unsigned Idx) const {
     assert(Idx < getNumFixItHints() && "Invalid index!");
-    return DiagObj->DiagStorage.FixItHints[Idx];
+    return DiagStorage.FixItHints[Idx];
   }
 
-  ArrayRef<FixItHint> getFixItHints() const {
-    return DiagObj->DiagStorage.FixItHints;
-  }
+  ArrayRef<FixItHint> getFixItHints() const { return DiagStorage.FixItHints; }
+
+  /// Return the value associated with this diagnostic flag.
+  StringRef getFlagValue() const { return FlagValue; }
 
   /// Format this diagnostic into a string, substituting the
   /// formal arguments into the %0 slots.
diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index 8b976bdac6dc51..f16fea6e798a95 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -22,6 +22,7 @@
 
 namespace clang {
   class DiagnosticsEngine;
+  class DiagnosticBuilder;
   class SourceLocation;
 
   // Import the diagnostic enums themselves.
@@ -367,11 +368,13 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
   ///
   /// \returns \c true if the diagnostic was emitted, \c false if it was
   /// suppressed.
-  bool ProcessDiag(DiagnosticsEngine &Diag) const;
+  bool ProcessDiag(DiagnosticsEngine &Diag,
+                   const DiagnosticBuilder &DiagBuilder) const;
 
   /// Used to emit a diagnostic that is finally fully formed,
   /// ignoring suppression.
-  void EmitDiag(DiagnosticsEngine &Diag, Level DiagLevel) const;
+  void EmitDiag(DiagnosticsEngine &Diag, const DiagnosticBuilder &DiagBuilder,
+                Level DiagLevel) const;
 
   /// Whether the diagnostic may leave the AST in a state where some
   /// invariants can break.
diff --git a/clang/include/clang/Basic/PartialDiagnostic.h b/clang/include/clang/Basic/PartialDiagnostic.h
index 507d789c54ff9b..4bf6049d08fdb4 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -166,13 +166,10 @@ class PartialDiagnostic : public StreamingDiagnostic {
 
   void EmitToString(DiagnosticsEngine &Diags,
                     SmallVectorImpl<char> &Buf) const {
-    // FIXME: It should be possible to render a diagno...
[truncated]

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this! I'm not certain that there is a reasonable way to add test coverage for the changes, but if you can devise a test, that would be appreciated.

Have you run your changes with address and ub sanitizers to see if there are some uncaught edge cases?

The changes are mostly looking good to me, but more sets of eyes on the changes would be appreciated.

@igelbox
Copy link
Contributor Author

igelbox commented Sep 12, 2024

Have you run your changes with address and ub sanitizers to see if there are some uncaught edge cases?

Not quire sure I get the point about UB-sanitizers. I tested this changes against my proprietary code which caused the issue with OOM/infinite-loop and it works just fine. I can and will build the clangd with assertions enabled and test it against my codebase to try catching other cases.

@igelbox
Copy link
Contributor Author

igelbox commented Sep 12, 2024

I'm not certain that there is a reasonable way to add test coverage for the changes, but if you can devise a test, that would be appreciated.

I wonder there should be some tests like:

  • input = some source files
  • output = expected it compiles well and has no assertions fired

but not sure yet where to find such a tests-folder. I'm just a newbie in clang development workflow, so I wonder is someone more experienced would point me that.

@AaronBallman
Copy link
Collaborator

Have you run your changes with address and ub sanitizers to see if there are some uncaught edge cases?

Not quire sure I get the point about UB-sanitizers. I tested this changes against my proprietary code which caused the issue with OOM/infinite-loop and it works just fine. I can and will build the clangd with assertions enabled and test it against my codebase to try catching other cases.

Thanks! Mostly just trying to verify correctness given the breadth of changes; I didn't spot any UB, but it's easy for that to creep in.

I wonder there should be some tests like:

input = some source files
output = expected it compiles well and has no assertions fired

but not sure yet where to find such a tests-folder. I'm just a newbie in clang development workflow, so I wonder is someone more experienced would point me that.

Welcome! Most of our test coverage lives in clang/test/ and tests individual components of the compiler. It looks like there are some good reduced test cases in the linked issue, now that I look more closely at the conversations there. I would recommend taking #70930 (comment) and adding it as a test case to clang/test/PCH

@igelbox
Copy link
Contributor Author

igelbox commented Sep 13, 2024

Whew, managed to add both tests.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Do you need someone to land these changes on your behalf?

@igelbox
Copy link
Contributor Author

igelbox commented Sep 16, 2024

LGTM! Do you need someone to land these changes on your behalf?

I suppose so.. or what are my options? The Merge button isn't active of course.
I believe someone from maintainers would merge this PR and I will be so proud)

@AaronBallman AaronBallman merged commit e5d2556 into llvm:main Sep 16, 2024
7 checks passed
Copy link

@igelbox Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@AaronBallman
Copy link
Collaborator

LGTM! Do you need someone to land these changes on your behalf?

I suppose so.. or what are my options? The Merge button isn't active of course. I believe someone from maintainers would merge this PR and I will be so proud)

I've merged on your behalf (I sometime struggle to tell who has commit privileges and who doesn't), thank you!

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building clang-tools-extra,clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/7831

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
25.220 [479/635/5444] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/GuessTargetAndModeCompilationDatabase.cpp.o
25.262 [479/634/5445] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/DynamicAllocator.cpp.o
25.270 [479/633/5446] Building CXX object tools/clang/lib/Format/CMakeFiles/obj.clangFormat.dir/FormatTokenLexer.cpp.o
25.287 [479/632/5447] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/InterpStack.cpp.o
25.321 [479/631/5448] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/FileIndexRecord.cpp.o
25.332 [479/630/5449] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXLoadedDiagnostic.cpp.o
25.344 [479/629/5450] Building CXX object tools/clang/lib/Format/CMakeFiles/obj.clangFormat.dir/SortJavaScriptImports.cpp.o
25.476 [479/628/5451] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnostic.cpp.o
25.478 [479/627/5452] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o
25.539 [479/626/5453] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.16.0.1/bin/clang++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/lib/Frontend -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp:48:49: error: no member named 'getFlagValue' in 'clang::DiagnosticsEngine'
    llvm::StringRef optValue = info.getDiags()->getFlagValue();
                               ~~~~~~~~~~~~~~~  ^
1 error generated.
25.650 [479/625/5454] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/State.cpp.o
25.721 [479/624/5455] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Linux.cpp.o
25.787 [479/623/5456] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Value.cpp.o
25.851 [479/622/5457] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/Descriptor.cpp.o
25.896 [479/621/5458] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTTypeTraits.cpp.o
25.933 [479/620/5459] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CheckerRegistryData.cpp.o
25.955 [479/619/5460] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/OHOS.cpp.o
25.957 [479/618/5461] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/Preprocessor.cpp.o
25.967 [479/617/5462] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ScopeInfo.cpp.o
26.048 [479/616/5463] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticBuffer.cpp.o
26.067 [479/615/5464] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/QualTypeNames.cpp.o
26.079 [479/614/5465] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/LocateToolCompilationDatabase.cpp.o
26.098 [479/613/5466] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/Checker.cpp.o
26.110 [479/612/5467] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DeclarationName.cpp.o
26.121 [479/611/5468] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/MSP430.cpp.o
26.326 [479/610/5469] Building CXX object tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransformActions.cpp.o
26.344 [479/609/5470] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o
26.447 [479/608/5471] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/AMDGPU.cpp.o
26.512 [479/607/5472] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/HeaderSearch.cpp.o
26.529 [479/606/5473] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/SanitizerArgs.cpp.o
26.535 [479/605/5474] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/Randstruct.cpp.o
26.613 [479/604/5475] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/VerifyDiagnosticConsumer.cpp.o
26.675 [479/603/5476] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DeclTemplate.cpp.o
26.788 [479/602/5477] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/X86.cpp.o
26.831 [479/601/5478] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ExternalASTMerger.cpp.o
26.912 [479/600/5479] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/InterpFrame.cpp.o
26.956 [479/599/5480] Building CXX object tools/clang/lib/Format/CMakeFiles/obj.clangFormat.dir/WhitespaceManager.cpp.o
26.979 [479/598/5481] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBase.cpp.o
27.115 [479/597/5482] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/EvaluationResult.cpp.o
27.128 [479/596/5483] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexer.cpp.o
27.134 [479/595/5484] Building CXX object tools/clang/lib/InstallAPI/CMakeFiles/obj.clangInstallAPI.dir/DylibVerifier.cpp.o
27.303 [479/594/5485] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/CreateCheckerManager.cpp.o
27.324 [479/593/5486] Building CXX object tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/Dominators.cpp.o

@erichkeane
Copy link
Collaborator

@igelbox: That seems to be a problem with this patch! If it is something you cannot fix/get a review up for very quickly so we can accept/get it in, we'll have to revert this. Please let us know ASAP what you'd like to do.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-sles-build-only running on rocm-worker-hw-04-sles while building clang-tools-extra,clang at step 5 "compile-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/6654

Here is the relevant piece of the build log for the reference
Step 5 (compile-openmp) failure: build (failure)
...
                                       ^
270.853 [665/32/6236] Building CXX object tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/Runtime/ArrayConstructor.cpp.o
270.887 [664/32/6237] Building CXX object tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/Runtime/Allocatable.cpp.o
270.888 [663/32/6238] Building CXX object tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/Runtime/Intrinsics.cpp.o
270.914 [662/32/6239] Linking CXX static library lib/libclangStaticAnalyzerFrontend.a
270.925 [661/32/6240] Building CXX object tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/Runtime/Main.cpp.o
270.926 [660/32/6241] Building CXX object tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/Runtime/Numeric.cpp.o
271.099 [659/32/6242] Linking CXX executable bin/clang-import-test
271.115 [658/32/6243] Linking CXX static library lib/libclangFrontendTool.a
271.134 [657/32/6244] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
ccache /usr/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/flang/lib/Frontend -I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend -I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/include -Itools/flang/include -Iinclude -I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/include -isystem /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/../mlir/include -isystem tools/mlir/include -isystem tools/clang/include -isystem /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++1z -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend/TextDiagnosticPrinter.cpp
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend/TextDiagnosticPrinter.cpp: In function ‘void printRemarkOption(llvm::raw_ostream&, clang::DiagnosticsEngine::Level, const clang::Diagnostic&)’:
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend/TextDiagnosticPrinter.cpp:48:49: error: ‘const class clang::DiagnosticsEngine’ has no member named ‘getFlagValue’
     llvm::StringRef optValue = info.getDiags()->getFlagValue();
                                                 ^~~~~~~~~~~~
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-ctad-maybe-unsupported’
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-copy’
271.315 [657/31/6245] Building CXX object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
In file included from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/Type.h:31:0,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/DeclarationName.h:16,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/DeclBase.h:19,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/Decl.h:20,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/Mangle.h:16,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/tools/c-index-test/core_main.cpp:9:
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:70:18: warning: ‘clang::PointerAuthSchema::TheKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Kind’
   Kind TheKind : 2;
                  ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:74:58: warning: ‘clang::PointerAuthSchema::SelectedAuthenticationMode’ is too small to hold all values of ‘enum class clang::PointerAuthenticationMode’
   PointerAuthenticationMode SelectedAuthenticationMode : 2;
                                                          ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:75:39: warning: ‘clang::PointerAuthSchema::DiscriminationKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Discrimination’
   Discrimination DiscriminationKind : 2;
                                       ^
271.320 [657/30/6246] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnostic.cpp.o
271.364 [657/29/6247] Linking CXX executable bin/clang-extdef-mapping
271.371 [657/28/6248] Linking CXX executable bin/arcmt-test
271.434 [657/27/6249] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXString.cpp.o
In file included from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/Type.h:31:0,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/CanonicalType.h:17,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/ASTContext.h:18,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Frontend/ASTUnit.h:17,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/tools/libclang/CXString.cpp:18:
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:70:18: warning: ‘clang::PointerAuthSchema::TheKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Kind’
   Kind TheKind : 2;
                  ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:74:58: warning: ‘clang::PointerAuthSchema::SelectedAuthenticationMode’ is too small to hold all values of ‘enum class clang::PointerAuthenticationMode’
   PointerAuthenticationMode SelectedAuthenticationMode : 2;

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building clang-tools-extra,clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/6426

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
296.332 [658/82/6445] Building CXX object tools/llvm-cfi-verify/lib/CMakeFiles/obj.LLVMCFIVerify.dir/FileAnalysis.cpp.o
296.347 [658/81/6446] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/llvm-cov.cpp.o
296.349 [658/80/6447] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/gcov.cpp.o
296.368 [658/79/6448] Building CXX object tools/clang/lib/Format/CMakeFiles/obj.clangFormat.dir/UnwrappedLineParser.cpp.o
296.371 [658/78/6449] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageExporterJson.cpp.o
296.374 [658/77/6450] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CodeCoverage.cpp.o
296.384 [658/76/6451] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageFilters.cpp.o
296.386 [658/75/6452] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageExporterLcov.cpp.o
296.393 [658/74/6453] Linking CXX shared library lib/libHLFIRDialect.so.20.0git
296.397 [658/73/6454] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
/usr/local/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/flang/lib/Frontend -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/lib/Frontend -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/../mlir/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/mlir/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/clang/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/../clang/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fPIC  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp
../llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp:48:49: error: no member named 'getFlagValue' in 'clang::DiagnosticsEngine'
   48 |     llvm::StringRef optValue = info.getDiags()->getFlagValue();
      |                                ~~~~~~~~~~~~~~~  ^
1 error generated.
296.399 [658/72/6455] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageSummaryInfo.cpp.o
296.401 [658/71/6456] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/SourceCoverageViewHTML.cpp.o
296.403 [658/70/6457] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/SourceCoverageViewText.cpp.o
296.405 [658/69/6458] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/SourceCoverageView.cpp.o
296.408 [658/68/6459] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageReport.cpp.o
296.409 [658/67/6460] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/TestingSupport.cpp.o
296.675 [658/66/6461] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/RetainCountChecker/RetainCountChecker.cpp.o
296.690 [658/65/6462] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticBuffer.cpp.o
296.730 [658/64/6463] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/OSObjectCStyleCast.cpp.o
296.900 [658/63/6464] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/StdLibraryFunctionsChecker.cpp.o
297.193 [658/62/6465] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ShowEnabledWarnings.cpp.o
297.292 [658/61/6466] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/PointerIterationChecker.cpp.o
297.721 [658/60/6467] Linking CXX shared library lib/libFortranEvaluate.so.20.0git
297.812 [658/59/6468] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnostic.cpp.o
297.818 [658/58/6469] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/NumberObjectConversionChecker.cpp.o
297.941 [658/57/6470] Building CXX object tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o
298.056 [658/56/6471] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/ARCMigrate.cpp.o
298.243 [658/55/6472] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexUSRs.cpp.o
298.612 [658/54/6473] Building CXX object tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o
298.855 [658/53/6474] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
299.318 [658/52/6475] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXSourceLocation.cpp.o
299.372 [658/51/6476] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/Rewrite.cpp.o
299.553 [658/50/6477] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexInclusionStack.cpp.o
299.861 [658/49/6478] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/StreamChecker.cpp.o
299.966 [658/48/6479] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DeadStoresChecker.cpp.o
299.991 [658/47/6480] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXString.cpp.o
300.071 [658/46/6481] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexHigh.cpp.o
300.366 [658/45/6482] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexDiagnostic.cpp.o
300.542 [658/44/6483] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/CodeCompletion.cpp.o
300.627 [658/43/6484] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXStoredDiagnostic.cpp.o
300.640 [658/42/6485] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXComment.cpp.o
301.175 [658/41/6486] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/PointerSortingChecker.cpp.o
301.188 [658/40/6487] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o

AaronBallman added a commit that referenced this pull request Sep 16, 2024
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-5 while building clang-tools-extra,clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/5825

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
895.714 [1589/8/4301] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CompileCommandsTests.cpp.o
897.020 [1588/8/4302] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CallHierarchyTests.cpp.o
898.718 [1587/8/4303] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompletionStringsTests.cpp.o
898.754 [1586/8/4304] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigProviderTests.cpp.o
898.764 [1585/8/4305] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ClangdLSPServerTests.cpp.o
898.779 [1584/8/4306] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigYAMLTests.cpp.o
898.790 [1583/8/4307] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DecisionForestTests.cpp.o
898.804 [1582/8/4308] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DexTests.cpp.o
898.828 [1581/8/4309] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DraftStoreTests.cpp.o
899.633 [1580/8/4310] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o
FAILED: tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /opt/homebrew/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/clangd/unittests -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/clangd/unittests -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/clangd/../include-cleaner/include -I/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/clangd/../clang-tidy -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/include -I/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/include -I/Users/buildbot/buildbot-root/aarch64-darwin/build/include -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/include -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/clangd -I/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/clangd -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include -I/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googlemock/include -isystem /opt/homebrew/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -MF tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o.d -o tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -c /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:308:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
        Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
        ^   ~~~~~~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1807:50: note: expanded from macro 'EXPECT_TRUE'
#define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
                                                 ^~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1792:23: note: expanded from macro 'GTEST_EXPECT_TRUE'
  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
                      ^~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1493:38: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
          ::testing::AssertionResult(expression))                     \
                                     ^~~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'const clang::Diagnostic' for 1st argument
class Diagnostic {
      ^
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'clang::Diagnostic' for 1st argument
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/include/clang/Basic/Diagnostic.h:1496:3: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
  Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder);
  ^
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/include/clang/Basic/Diagnostic.h:1497:3: note: candidate constructor not viable: requires 5 arguments, but 1 was provided
  Diagnostic(const DiagnosticsEngine *DO, SourceLocation DiagLoc,
  ^
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:314:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
        Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
        ^   ~~~~~~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1811:52: note: expanded from macro 'EXPECT_FALSE'
#define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
                                                   ^~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1795:25: note: expanded from macro 'GTEST_EXPECT_FALSE'
  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
                        ^~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1493:38: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
          ::testing::AssertionResult(expression))                     \
                                     ^~~~~~~~~~
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'const clang::Diagnostic' for 1st argument
class Diagnostic {
      ^

AaronBallman added a commit that referenced this pull request Sep 16, 2024
Reverting due to build failures found in #108187
@AaronBallman
Copy link
Collaborator

I've reverted; @igelbox, you can create a new PR that addresses the failures found by post-commit CI and I'll review them.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder clangd-ubuntu-tsan running on clangd-ubuntu-clang while building clang-tools-extra,clang at step 6 "test-build-clangd-clangd-index-server-clangd-indexer-check-clangd".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/134/builds/5347

Here is the relevant piece of the build log for the reference
Step 6 (test-build-clangd-clangd-index-server-clangd-indexer-check-clangd) failure: test (failure)
...
9.199 [94/18/31] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CanonicalIncludesTests.cpp.o
9.202 [93/18/32] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CompileCommandsTests.cpp.o
9.203 [92/18/33] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigProviderTests.cpp.o
9.207 [91/18/34] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigYAMLTests.cpp.o
9.232 [90/18/35] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DraftStoreTests.cpp.o
9.234 [89/18/36] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DexTests.cpp.o
9.498 [88/18/37] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DecisionForestTests.cpp.o
9.574 [87/18/38] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/FileDistanceTests.cpp.o
10.933 [86/18/39] Building CXX object tools/clang/tools/extra/clangd/index/dex/dexp/CMakeFiles/dexp.dir/Dexp.cpp.o
17.758 [85/18/40] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o
FAILED: tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o 
ccache /usr/bin/clang++ -DCARES_STATICLIB -DGOOGLE_PROTOBUF_NO_RTTI=1 -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/unittests -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/unittests -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/../include-cleaner/include -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/../clang-tidy -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/include -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/include -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/llvm/include -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/unittests/../index/remote -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googletest/include -I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googlemock/include -isystem /usr/local/lib/grpc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -gline-tables-only -fsanitize=thread -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -std=c++17 -MD -MT tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -MF tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o.d -o tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -c /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:308:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
  308 |         Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
      |         ^   ~~~~~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1807:50: note: expanded from macro 'EXPECT_TRUE'
 1807 | #define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
      |                                                  ^~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1792:23: note: expanded from macro 'GTEST_EXPECT_TRUE'
 1792 |   GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
      |                       ^~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1493:38: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
 1493 |           ::testing::AssertionResult(expression))                     \
      |                                      ^~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'const Diagnostic' for 1st argument
 1487 | class Diagnostic {
      |       ^~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'Diagnostic' for 1st argument
 1487 | class Diagnostic {
      |       ^~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Basic/Diagnostic.h:1496:3: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
 1496 |   Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder);
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Basic/Diagnostic.h:1497:3: note: candidate constructor not viable: requires 5 arguments, but 1 was provided
 1497 |   Diagnostic(const DiagnosticsEngine *DO, SourceLocation DiagLoc,
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1498 |              unsigned DiagID, const DiagnosticStorage &DiagStorage,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1499 |              StringRef StoredDiagMessage);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:314:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
  314 |         Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
      |         ^   ~~~~~~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1811:52: note: expanded from macro 'EXPECT_FALSE'
 1811 | #define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
      |                                                    ^~~~~~~~~
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1795:25: note: expanded from macro 'GTEST_EXPECT_FALSE'
 1795 |   GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
      |                         ^~~~~~~~~

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder clang-aarch64-quick running on linaro-clang-aarch64-quick while building clang-tools-extra,clang at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/4601

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
[10/419] Building CXX object tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/AnalysisTest.cpp.o
[11/419] Building CXX object tools/clang/tools/extra/unittests/clang-apply-replacements/CMakeFiles/ClangApplyReplacementsTests.dir/ApplyReplacementsTest.cpp.o
[12/419] Linking CXX executable tools/clang/tools/extra/unittests/clang-apply-replacements/ClangApplyReplacementsTests
[13/419] Building CXX object tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/BitcodeTest.cpp.o
[14/419] Building CXX object tools/clang/tools/extra/unittests/clang-change-namespace/CMakeFiles/ClangChangeNamespaceTests.dir/ChangeNamespaceTests.cpp.o
[15/419] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/Annotations.cpp.o
[16/419] Building CXX object tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/GeneratorTest.cpp.o
[17/419] Building CXX object tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MDGeneratorTest.cpp.o
[18/419] Building CXX object tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/ClangDocTest.cpp.o
[19/419] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o
FAILED: tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang-tools-extra/clangd/unittests -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang-tools-extra/clangd/../include-cleaner/include -I/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/../clang-tidy -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/include -I/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/include -I/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/include -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/include -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang-tools-extra/clangd -I/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/third-party/unittest/googletest/include -I/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -MF tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o.d -o tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -c /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
../llvm/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:308:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
  308 |         Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
      |         ^   ~~~~~~~~~~~~~
../llvm/third-party/unittest/googletest/include/gtest/gtest.h:1807:50: note: expanded from macro 'EXPECT_TRUE'
 1807 | #define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
      |                                                  ^~~~~~~~~
../llvm/third-party/unittest/googletest/include/gtest/gtest.h:1792:23: note: expanded from macro 'GTEST_EXPECT_TRUE'
 1792 |   GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
      |                       ^~~~~~~~~
../llvm/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1493:38: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
 1493 |           ::testing::AssertionResult(expression))                     \
      |                                      ^~~~~~~~~~
../llvm/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'const Diagnostic' for 1st argument
 1487 | class Diagnostic {
      |       ^~~~~~~~~~
../llvm/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'Diagnostic' for 1st argument
 1487 | class Diagnostic {
      |       ^~~~~~~~~~
../llvm/clang/include/clang/Basic/Diagnostic.h:1496:3: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
 1496 |   Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder);
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm/clang/include/clang/Basic/Diagnostic.h:1497:3: note: candidate constructor not viable: requires 5 arguments, but 1 was provided
 1497 |   Diagnostic(const DiagnosticsEngine *DO, SourceLocation DiagLoc,
      |   ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1498 |              unsigned DiagID, const DiagnosticStorage &DiagStorage,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1499 |              StringRef StoredDiagMessage);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:314:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
  314 |         Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
      |         ^   ~~~~~~~~~~~~~
../llvm/third-party/unittest/googletest/include/gtest/gtest.h:1811:52: note: expanded from macro 'EXPECT_FALSE'
 1811 | #define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
      |                                                    ^~~~~~~~~
../llvm/third-party/unittest/googletest/include/gtest/gtest.h:1795:25: note: expanded from macro 'GTEST_EXPECT_FALSE'
 1795 |   GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
      |                         ^~~~~~~~~

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder clang-x86_64-debian-fast running on gribozavr4 while building clang-tools-extra,clang at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/7472

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/unittests/Analysis/FlowSensitive/ASTOpsTest.cpp:10:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/unittests/Analysis/FlowSensitive/TestingSupport.h:41:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Tooling/Tooling.h:35:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Frontend/FrontendAction.h:23:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Frontend/ASTUnit.h:28:
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Sema/CodeCompleteConsumer.h:338:31: warning: '@class' command should not be used in a comment attached to a non-class declaration [-Wdocumentation]
    /// Code completion in a @class forward declaration.
                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~
6 warnings generated.
28.965 [922/98/166] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o
FAILED: tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/clangd/unittests -I/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clangd/unittests -I/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clangd/../include-cleaner/include -I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/clangd/../clang-tidy -I/b/1/clang-x86_64-debian-fast/llvm.src/clang/include -I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/include -I/b/1/clang-x86_64-debian-fast/llvm.obj/include -I/b/1/clang-x86_64-debian-fast/llvm.src/llvm/include -I/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clangd -I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/clangd -I/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include -I/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googlemock/include -std=c++11 -Wdocumentation -Wno-documentation-deprecated-sync -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -std=c++17 -MD -MT tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -MF tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o.d -o tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ConfigCompileTests.cpp.o -c /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:308:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
        Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
        ^   ~~~~~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include/gtest/gtest.h:1807:50: note: expanded from macro 'EXPECT_TRUE'
#define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
                                                 ^~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include/gtest/gtest.h:1792:23: note: expanded from macro 'GTEST_EXPECT_TRUE'
  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
                      ^~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1493:38: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
          ::testing::AssertionResult(expression))                     \
                                     ^~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'const clang::Diagnostic' for 1st argument
class Diagnostic {
      ^
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'clang::Diagnostic' for 1st argument
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Basic/Diagnostic.h:1496:3: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
  Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder);
  ^
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Basic/Diagnostic.h:1497:3: note: candidate constructor not viable: requires 5 arguments, but 1 was provided
  Diagnostic(const DiagnosticsEngine *DO, SourceLocation DiagLoc,
  ^
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:314:9: error: no matching constructor for initialization of 'Diag' (aka 'clang::Diagnostic')
        Diag{&DiagEngine}, Conf.Diagnostics.Suppress, LangOptions()));
        ^   ~~~~~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include/gtest/gtest.h:1811:52: note: expanded from macro 'EXPECT_FALSE'
#define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
                                                   ^~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include/gtest/gtest.h:1795:25: note: expanded from macro 'GTEST_EXPECT_FALSE'
  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
                        ^~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/third-party/unittest/googletest/include/gtest/internal/gtest-internal.h:1493:38: note: expanded from macro 'GTEST_TEST_BOOLEAN_'
          ::testing::AssertionResult(expression))                     \
                                     ^~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Basic/Diagnostic.h:1487:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'clang::DiagnosticsEngine *' to 'const clang::Diagnostic' for 1st argument
class Diagnostic {
      ^

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 16, 2024

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building clang-tools-extra,clang at step 6 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/9025

Here is the relevant piece of the build log for the reference
Step 6 (build-unified-tree) failure: build (failure)
...
367.979 [2905/58/1650] Building CXX object tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ObjCMemberwiseInitializer.cpp.o
367.984 [2904/58/1651] Linking CXX executable bin/llvm-as
368.080 [2903/58/1652] Linking CXX executable bin/llvm-cat
368.096 [2902/58/1653] Linking CXX executable bin/llvm-cgdata
368.130 [2901/58/1654] Linking CXX executable tools/flang/unittests/Evaluate/logical.test
368.156 [2900/58/1655] Linking CXX executable tools/flang/unittests/Evaluate/real.test
368.164 [2899/58/1656] Building CXX object tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ScopifyEnum.cpp.o
368.333 [2898/58/1657] Linking CXX executable tools/flang/unittests/Evaluate/integer.test
368.414 [2897/58/1658] Linking CXX executable bin/llvm-cfi-verify
368.656 [2896/58/1659] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/build/buildbot/premerge-monolithic-linux/build/tools/flang/lib/Frontend -I/build/buildbot/premerge-monolithic-linux/llvm-project/flang/lib/Frontend -I/build/buildbot/premerge-monolithic-linux/llvm-project/flang/include -I/build/buildbot/premerge-monolithic-linux/build/tools/flang/include -I/build/buildbot/premerge-monolithic-linux/build/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include -isystem /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/../mlir/include -isystem /build/buildbot/premerge-monolithic-linux/build/tools/mlir/include -isystem /build/buildbot/premerge-monolithic-linux/build/tools/clang/include -isystem /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/../clang/include -gmlt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /build/buildbot/premerge-monolithic-linux/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp
/build/buildbot/premerge-monolithic-linux/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp:48:49: error: no member named 'getFlagValue' in 'clang::DiagnosticsEngine'
    llvm::StringRef optValue = info.getDiags()->getFlagValue();
                               ~~~~~~~~~~~~~~~  ^
1 error generated.
368.699 [2896/57/1660] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ParsedAST.cpp.o
368.710 [2896/56/1661] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnostic.cpp.o
368.721 [2896/55/1662] Generating obj.libclc.dir/nvptx--/generic/lib/math/clc_ldexp.cl.bc
368.738 [2896/54/1663] Generating obj.libclc.dir/nvptx--/generic/lib/math/clc_nextafter.cl.bc
368.755 [2896/53/1664] Generating obj.libclc.dir/nvptx--/generic/lib/math/clc_fmod.cl.bc
368.755 [2896/52/1665] Generating obj.libclc.dir/tahiti-amdgcn-mesa-mesa3d/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl.bc
368.761 [2896/51/1666] Linking CXX executable bin/lli
368.773 [2896/50/1667] Generating obj.libclc.dir/nvptx--/generic/lib/math/clc_hypot.cl.bc
368.775 [2896/49/1668] Linking CXX executable tools/flang/unittests/Evaluate/folding.test
368.987 [2896/48/1669] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticBuffer.cpp.o
369.033 [2896/47/1670] Generating obj.libclc.dir/tahiti-amdgcn-mesa-mesa3d/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl.bc
369.135 [2896/46/1671] Generating obj.libclc.dir/tahiti-amdgcn-mesa-mesa3d/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl.bc
369.161 [2896/45/1672] Building CXX object tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o
369.169 [2896/44/1673] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXSourceLocation.cpp.o
369.279 [2896/43/1674] Linking CXX executable bin/fir-opt
369.306 [2896/42/1675] Linking CXX executable bin/llc
369.307 [2896/41/1676] Linking CXX executable bin/dsymutil
369.323 [2896/40/1677] Generating obj.libclc.dir/nvptx--/generic/lib/math/clc_pow.cl.bc
369.467 [2896/39/1678] Building CXX object tools/clang/tools/extra/test/CMakeFiles/CTTestTidyModule.dir/clang-tidy/CTTestTidyModule.cpp.o
369.502 [2896/38/1679] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXStoredDiagnostic.cpp.o
369.533 [2896/37/1680] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXString.cpp.o
369.550 [2896/36/1681] Linking CXX executable bin/llvm-c-test
369.870 [2896/35/1682] Building CXX object tools/bolt/lib/Utils/CMakeFiles/LLVMBOLTUtils.dir/CommandLineOpts.cpp.o
369.898 [2896/34/1683] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXCursor.cpp.o
370.026 [2896/33/1684] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/Rewrite.cpp.o
370.120 [2896/32/1685] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o
370.190 [2896/31/1686] Building CXX object tools/clang/tools/extra/clangd/fuzzer/CMakeFiles/clangd-fuzzer.dir/clangd-fuzzer.cpp.o
370.411 [2896/30/1687] Building CXX object tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SpecialMembers.cpp.o
370.512 [2896/29/1688] Generating obj.libclc.dir/clspv64--/clspv-convert.cl.bc
370.765 [2896/28/1689] Building CXX object tools/clang/tools/extra/clangd/index/dex/dexp/CMakeFiles/dexp.dir/Dexp.cpp.o
370.853 [2896/27/1690] Generating obj.libclc.dir/clspv--/clspv-convert.cl.bc
370.921 [2896/26/1691] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexCodeCompletion.cpp.o
370.922 [2896/25/1692] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXType.cpp.o

AaronBallman pushed a commit that referenced this pull request Sep 18, 2024
Resolves: #70930 (and probably latest comments from clangd/clangd#251)
by fixing racing for the shared DiagStorage value which caused messing with args inside the storage and then formatting the following message with getArgSInt(1) == 2:

def err_module_odr_violation_function : Error<
  "%q0 has different definitions in different modules; "
  "%select{definition in module '%2'|defined here}1 "
  "first difference is "

which causes HandleSelectModifier to go beyond the ArgumentLen so the recursive call to FormatDiagnostic was made with DiagStr > DiagEnd that leads to infinite while (DiagStr != DiagEnd).

The Main Idea:
Reuse the existing DiagStorageAllocator logic to make all DiagnosticBuilders having independent states.
Also, encapsulating the rest of state (e.g. ID and Loc) into DiagnosticBuilder.

The last attempt failed -
#108187 (comment)
so was reverted - #108838
tmsri pushed a commit to tmsri/llvm-project that referenced this pull request Sep 19, 2024
Resolves: llvm#70930 (and probably latest comments from clangd/clangd#251)
by fixing racing for the shared DiagStorage value which caused messing with args inside the storage and then formatting the following message with getArgSInt(1) == 2:

def err_module_odr_violation_function : Error<
  "%q0 has different definitions in different modules; "
  "%select{definition in module '%2'|defined here}1 "
  "first difference is "

which causes HandleSelectModifier to go beyond the ArgumentLen so the recursive call to FormatDiagnostic was made with DiagStr > DiagEnd that leads to infinite while (DiagStr != DiagEnd).

The Main Idea:
Reuse the existing DiagStorageAllocator logic to make all DiagnosticBuilders having independent states.
Also, encapsulating the rest of state (e.g. ID and Loc) into DiagnosticBuilder.

The last attempt failed -
llvm#108187 (comment)
so was reverted - llvm#108838
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 Clang issues not falling into any other category clang-tidy clang-tools-extra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Multiple diagnostics in flight at once!" assert, and runaway memory usage in release builds, on C++20 testcase with PCH
6 participants