[clang] 0b94525 - Revert "[libclang] Expose completion result kind in `CXCompletionResult`"

2022-11-14 Thread Muhammad Omair Javaid via cfe-commits

Author: Muhammad Omair Javaid
Date: 2022-11-14T12:27:11+04:00
New Revision: 0b94525ddcfc069941a20abcbe447e659ffb6e33

URL: 
https://github.com/llvm/llvm-project/commit/0b94525ddcfc069941a20abcbe447e659ffb6e33
DIFF: 
https://github.com/llvm/llvm-project/commit/0b94525ddcfc069941a20abcbe447e659ffb6e33.diff

LOG: Revert "[libclang] Expose completion result kind in `CXCompletionResult`"

This reverts commit 97105e5bf70fae5d9902081e917fd178b57f1717.
It breaks clang-armv8-quick buildbot:
https://lab.llvm.org/buildbot/#/builders/245/builds/761

Added: 


Modified: 
clang/include/clang-c/Index.h
clang/test/Index/arc-complete.m
clang/test/Index/code-completion.cpp
clang/test/Index/complete-at-directives.m
clang/test/Index/complete-at-exprstmt.m
clang/test/Index/complete-declarators.cpp
clang/test/Index/complete-declarators.m
clang/test/Index/complete-exprs.c
clang/test/Index/complete-exprs.cpp
clang/test/Index/complete-exprs.m
clang/test/Index/complete-lambdas.cpp
clang/test/Index/complete-lambdas.mm
clang/test/Index/complete-memfunc-cvquals.cpp
clang/test/Index/complete-method-decls.m
clang/test/Index/complete-modules.m
clang/test/Index/complete-preprocessor.m
clang/test/Index/complete-recovery.m
clang/test/Index/complete-stmt.c
clang/test/Index/complete-super.cpp
clang/test/Index/complete-synthesized.m
clang/test/Index/complete-type-factors.m
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CIndexCodeCompletion.cpp
clang/tools/libclang/libclang.map

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 74c859bf785a5..e0f6f1c73549f 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2080,23 +2080,6 @@ enum CXCursorKind {
   CXCursor_OverloadCandidate = 700
 };
 
-/**
- * Describes the kind of result generated.
- */
-enum CXCompletionResultKind {
-  /** Refers to a declaration. */
-  CXCompletionResult_Declaration = 0,
-
-  /** Refers to a keyword or symbol. */
-  CXCompletionResult_Keyword = 1,
-
-  /** Refers to a macro. */
-  CXCompletionResult_Macro = 2,
-
-  /** Refers to a precomputed pattern. */
-  CXCompletionResult_Pattern = 3
-};
-
 /**
  * A cursor representing some element in the abstract syntax tree for
  * a translation unit.
@@ -4605,8 +4588,6 @@ CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit 
TU, CXToken *Tokens,
  */
 
 /* for debug/testing */
-CINDEX_LINKAGE CXString
-clang_getCompletionResultKindSpelling(enum CXCompletionResultKind Kind);
 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
@@ -4650,17 +4631,12 @@ typedef void *CXCompletionString;
  * A single result of code completion.
  */
 typedef struct {
-  /**
-   * The kind of this completion result.
-   * Useful to distinguish between declarations and keywords.
-   */
-  enum CXCompletionResultKind ResultKind;
-
   /**
* The kind of entity that this completion refers to.
*
-   * The cursor kind will be a macro or a declaration (one of the *Decl cursor
-   * kinds), describing the entity that the completion is referring to.
+   * The cursor kind will be a macro, keyword, or a declaration (one of the
+   * *Decl cursor kinds), describing the entity that the completion is
+   * referring to.
*
* \todo In the future, we would like to provide a full cursor, to allow
* the client to extract additional information from declaration.

diff  --git a/clang/test/Index/arc-complete.m b/clang/test/Index/arc-complete.m
index c3fb6f3dcafb1..328983c441ecf 100644
--- a/clang/test/Index/arc-complete.m
+++ b/clang/test/Index/arc-complete.m
@@ -8,9 +8,9 @@ void test(id x) {
 
 // RUN: c-index-test -code-completion-at=%s:4:4 %s -fobjc-arc 
-fobjc-nonfragile-abi | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: macro definition:{TypedText __autoreleasing} (70)
-// CHECK-CC1: Pattern:{TypedText __bridge}{HorizontalSpace  }{Placeholder 
type}{RightParen )}{Placeholder expression} (40)
-// CHECK-CC1: Pattern:{TypedText __bridge_retained}{HorizontalSpace  
}{Placeholder CF type}{RightParen )}{Placeholder expression} (40)
-// CHECK-CC1: Pattern:{TypedText __bridge_transfer}{HorizontalSpace  
}{Placeholder Objective-C type}{RightParen )}{Placeholder expression} (40)
+// CHECK-CC1: NotImplemented:{TypedText __bridge}{HorizontalSpace  
}{Placeholder type}{RightParen )}{Placeholder expression} (40)
+// CHECK-CC1: NotImplemented:{TypedText __bridge_retained}{HorizontalSpace  
}{Placeholder CF type}{RightParen )}{Placeholder expression} (40)
+// CHECK-CC1: NotImplemented:{TypedText __bridge_transfer}{HorizontalSpace  
}{Placeholder Objective-C type}{RightParen )}{Placeholder e

[PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-11-14 Thread Muhammad Omair Javaid via Phabricator via cfe-commits
omjavaid reopened this revision.
omjavaid added a comment.
This revision is now accepted and ready to land.

Hi this broke https://lab.llvm.org/buildbot/#/builders/245/builds/761
I have reverted the change to make the buildbot green.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136844/new/

https://reviews.llvm.org/D136844

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137040: [clangd] Add heuristic for dropping snippet when completing member function pointer

2022-11-14 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders added a comment.

In D137040#3924115 , @nridge wrote:

> Thanks!

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137040/new/

https://reviews.llvm.org/D137040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] dd46a08 - Move the isSelfContainedHeader function from clangd to libtooling.

2022-11-14 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-11-14T09:40:45+01:00
New Revision: dd46a08008f76d6ac9fcc6a9e748b113bea3c758

URL: 
https://github.com/llvm/llvm-project/commit/dd46a08008f76d6ac9fcc6a9e748b113bea3c758
DIFF: 
https://github.com/llvm/llvm-project/commit/dd46a08008f76d6ac9fcc6a9e748b113bea3c758.diff

LOG: Move the isSelfContainedHeader function from clangd to libtooling.

We plan to reuse it in the include-cleaner library, this patch moves
this functionality from clangd to libtooling, so that this piece of code can be
shared among all clang tools.

Differential Revision: https://reviews.llvm.org/D137697

Added: 
clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
clang/unittests/Tooling/HeaderAnalysisTest.cpp

Modified: 
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang/lib/Tooling/Inclusions/CMakeLists.txt
clang/unittests/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/Headers.cpp 
b/clang-tools-extra/clangd/Headers.cpp
index cbfeb637e2fc1..f276f5bd8c6c1 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -15,6 +15,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -121,12 +122,10 @@ class IncludeStructure::RecordHeaders : public 
PPCallbacks,
 // isSelfContainedHeader only returns true once the full header-guard
 // structure has been seen, i.e. when exiting the *outer* copy of the
 // file. So last result wins.
-if (isSelfContainedHeader(FE, PrevFID, SM, HeaderInfo))
-  Out->NonSelfContained.erase(
-  *Out->getID(SM.getFileEntryForID(PrevFID)));
+if (tooling::isSelfContainedHeader(FE, SM, HeaderInfo))
+  Out->NonSelfContained.erase(*Out->getID(FE));
 else
-  Out->NonSelfContained.insert(
-  *Out->getID(SM.getFileEntryForID(PrevFID)));
+  Out->NonSelfContained.insert(*Out->getID(FE));
   }
   break;
 }

diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 5928541635e67..5913db5405a34 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -1183,58 +1183,5 @@ bool isProtoFile(SourceLocation Loc, const SourceManager 
&SM) {
   return SM.getBufferData(FID).startswith(ProtoHeaderComment);
 }
 
-namespace {
-
-// Is Line an #if or #ifdef directive?
-// FIXME: This makes headers with #ifdef LINUX/WINDOWS/MACOS marked as non
-// self-contained and is probably not what we want.
-bool isIf(llvm::StringRef Line) {
-  Line = Line.ltrim();
-  if (!Line.consume_front("#"))
-return false;
-  Line = Line.ltrim();
-  return Line.startswith("if");
-}
-
-// Is Line an #error directive mentioning includes?
-bool isErrorAboutInclude(llvm::StringRef Line) {
-  Line = Line.ltrim();
-  if (!Line.consume_front("#"))
-return false;
-  Line = Line.ltrim();
-  if (!Line.startswith("error"))
-return false;
-  return Line.contains_insensitive(
-  "includ"); // Matches "include" or "including".
-}
-
-// Heuristically headers that only want to be included via an umbrella.
-bool isDontIncludeMeHeader(llvm::StringRef Content) {
-  llvm::StringRef Line;
-  // Only sniff up to 100 lines or 10KB.
-  Content = Content.take_front(100 * 100);
-  for (unsigned I = 0; I < 100 && !Content.empty(); ++I) {
-std::tie(Line, Content) = Content.split('\n');
-if (isIf(Line) && isErrorAboutInclude(Content.split('\n').first))
-  return true;
-  }
-  return false;
-}
-
-} // namespace
-
-bool isSelfContainedHeader(const FileEntry *FE, FileID FID,
-   const SourceManager &SM, HeaderSearch &HeaderInfo) {
-  // FIXME: Should files that have been #import'd be considered
-  // self-contained? That's really a property of the includer,
-  // not of the file.
-  if (!HeaderInfo.isFileMultipleIncludeGuarded(FE) &&
-  !HeaderInfo.hasFileBeenImported(FE))
-return false;
-  // This pattern indicates that a header can't be used without
-  // particular preprocessor state, usually set up by another header.
-  return !isDontIncludeMeHeader(SM.getBufferData(FID));
-}
-
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/SourceCode.h 
b/clang-tools-extra/clangd/SourceCode.h
index faed27d7c8c4e..70d1ebe9b0990 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -325,11 +325,6 @@ bool isHeaderFile(llvm::StringRef FileName,
 /// Returns true if the given location is in a generated pr

[PATCH] D137697: Move the isSelfContained function from clangd to libtooling.

2022-11-14 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd46a08008f7: Move the isSelfContainedHeader function from 
clangd to libtooling. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137697/new/

https://reviews.llvm.org/D137697

Files:
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
  clang/lib/Tooling/Inclusions/CMakeLists.txt
  clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/HeaderAnalysisTest.cpp

Index: clang/unittests/Tooling/HeaderAnalysisTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/HeaderAnalysisTest.cpp
@@ -0,0 +1,66 @@
+//===- unittest/Tooling/HeaderAnalysisTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Testing/TestAST.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+
+TEST(HeaderAnalysisTest, IsSelfContained) {
+  TestInputs Inputs;
+  Inputs.Code = R"cpp(
+  #include "headerguard.h"
+  #include "pragmaonce.h"
+  #import "imported.h"
+
+  #include "bad.h"
+  #include "unguarded.h"
+  )cpp";
+
+  Inputs.ExtraFiles["headerguard.h"] = R"cpp(
+  #ifndef HEADER_H
+  #define HEADER_H
+
+  #endif HEADER_H
+  )cpp";
+  Inputs.ExtraFiles["pragmaonce.h"] = R"cpp(
+  #pragma once
+  )cpp";
+  Inputs.ExtraFiles["imported.h"] = "";
+
+  Inputs.ExtraFiles["unguarded.h"] = "";
+  Inputs.ExtraFiles["bad.h"] = R"cpp(
+  #pragma once
+
+  #if defined(INSIDE_H)
+  #error "Only ... can be included directly"
+  #endif
+  )cpp";
+
+  TestAST AST(Inputs);
+  const auto &SM = AST.sourceManager();
+  auto &FM = SM.getFileManager();
+  auto &HI = AST.preprocessor().getHeaderSearchInfo();
+  auto getFileID = [&](llvm::StringRef FileName) {
+return SM.translateFile(FM.getFile(FileName).get());
+  };
+  EXPECT_TRUE(isSelfContainedHeader(getFileID("headerguard.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileID("pragmaonce.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileID("imported.h"), SM, HI));
+
+  EXPECT_FALSE(isSelfContainedHeader(getFileID("unguarded.h"), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(getFileID("bad.h"), SM, HI));
+}
+
+} // namespace
+} // namespace tooling
+} // namespace clang
Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -16,6 +16,7 @@
   DiagnosticsYamlTest.cpp
   ExecutionTest.cpp
   FixItTest.cpp
+  HeaderAnalysisTest.cpp
   HeaderIncludesTest.cpp
   StandardLibraryTest.cpp
   LexicallyOrderedRecursiveASTVisitorTest.cpp
Index: clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
===
--- /dev/null
+++ clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
@@ -0,0 +1,67 @@
+//===--- HeaderAnalysis.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/HeaderSearch.h"
+
+namespace clang::tooling {
+namespace {
+
+// Is Line an #if or #ifdef directive?
+// FIXME: This makes headers with #ifdef LINUX/WINDOWS/MACOS marked as non
+// self-contained and is probably not what we want.
+bool isIf(llvm::StringRef Line) {
+  Line = Line.ltrim();
+  if (!Line.consume_front("#"))
+return false;
+  Line = Line.ltrim();
+  return Line.startswith("if");
+}
+
+// Is Line an #error directive mentioning includes?
+bool isErrorAboutInclude(llvm::StringRef Line) {
+  Line = Line.ltrim();
+  if (!Line.consume_front("#"))
+return false;
+  Line = Line.ltrim();
+  if (!Line.startswith("error"))
+return false;
+  return Line.contains_insensitive(
+  "includ"); // Matches "include" or "including".
+}
+
+// Heuristically headers that only want to be included via an umbrella.
+bool isDontIncludeMeHeader(llvm::MemoryBufferRef Buffer) {
+  StringRef Content = Buffer.

[PATCH] D137698: [include-cleaner] Add self-contained file support for PragmaIncludes.

2022-11-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 475067.
hokein marked 3 inline comments as done.
hokein added a comment.

rebase and address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137698/new/

https://reviews.llvm.org/D137698

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/CMakeLists.txt
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -17,6 +17,10 @@
 namespace {
 using testing::UnorderedElementsAre;
 
+std::string guard(const llvm::StringRef Code) {
+  return "#pragma once\n" + Code.str();
+}
+
 TEST(FindIncludeHeaders, IWYU) {
   TestInputs Inputs;
   PragmaIncludes PI;
@@ -38,20 +42,24 @@
 #include "header1.h"
 #include "header2.h"
   )cpp";
-  Inputs.ExtraFiles["header1.h"] = R"cpp(
+  Inputs.ExtraFiles["header1.h"] = guard(R"cpp(
 // IWYU pragma: private, include "path/public.h"
-  )cpp";
-  Inputs.ExtraFiles["header2.h"] = R"cpp(
+  )cpp");
+  Inputs.ExtraFiles["header2.h"] = guard(R"cpp(
 #include "detail1.h" // IWYU pragma: export
 
 // IWYU pragma: begin_exports
 #include "detail2.h"
 // IWYU pragma: end_exports
 
+#include "imp.inc"
+
 #include "normal.h"
-  )cpp";
+
+  )cpp");
   Inputs.ExtraFiles["normal.h"] = Inputs.ExtraFiles["detail1.h"] =
-  Inputs.ExtraFiles["detail2.h"] = "";
+  Inputs.ExtraFiles["detail2.h"] = guard("");
+  Inputs.ExtraFiles["imp.inc"] = "";
   TestAST AST(Inputs);
   const auto &SM = AST.sourceManager();
   auto &FM = SM.getFileManager();
@@ -70,6 +78,9 @@
   EXPECT_THAT(findHeaders(SourceLocFromFile("detail2.h"), SM, PI),
   UnorderedElementsAre(Header(FM.getFile("header2.h").get()),
Header(FM.getFile("detail2.h").get(;
+  // header2.h is the first #includer for the  non self-contained header imp.inc
+  EXPECT_THAT(findHeaders(SourceLocFromFile("imp.inc"), SM, PI),
+  UnorderedElementsAre(Header(FM.getFile("header2.h").get(;
 
   EXPECT_THAT(findHeaders(SourceLocFromFile("normal.h"), SM, PI),
   UnorderedElementsAre(Header(FM.getFile("normal.h").get(;
Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -28,6 +28,10 @@
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
+std::string guard(const llvm::StringRef Code) {
+  return "#pragma once\n" + Code.str();
+}
+
 TEST(WalkUsed, Basic) {
   // FIXME: Have a fixture for setting up tests.
   llvm::Annotations Code(R"cpp(
@@ -40,14 +44,14 @@
   }
   )cpp");
   TestInputs Inputs(Code.code());
-  Inputs.ExtraFiles["header.h"] = R"cpp(
+  Inputs.ExtraFiles["header.h"] = guard(R"cpp(
   void foo();
   namespace std { class vector {}; }
-  )cpp";
-  Inputs.ExtraFiles["private.h"] = R"cpp(
+  )cpp");
+  Inputs.ExtraFiles["private.h"] = guard(R"cpp(
 // IWYU pragma: private, include "path/public.h"
 class Private {};
-  )cpp";
+  )cpp");
 
   PragmaIncludes PI;
   Inputs.MakeAction = [&PI] {
Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -16,6 +16,8 @@
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+
 
 namespace clang::include_cleaner {
 namespace {
@@ -118,12 +120,25 @@
 class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
 public:
   RecordPragma(const CompilerInstance &CI, PragmaIncludes *Out)
-  : SM(CI.getSourceManager()), Out(Out), UniqueStrings(Arena) {}
+  : SM(CI.getSourceManager()),
+HeaderInfo(CI.getPreprocessor().getHeaderSearchInfo()), Out(Out),
+UniqueStrings(Arena) {}
 
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override {
 InMainFile = SM.isWrittenInMainFile(Loc);
+
+if (Reason == PPCallbacks::ExitFile) {
+  // At file exit time HeaderSearchInfo is valid and can be used to
+  // determine whether the file was a self-contained header or not.
+  if (const FileEntry *FE = SM.getFileEntryForID(Prev

[PATCH] D137677: [include-cleaner] add macro symbols and implicit refs to HTML report

2022-11-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 475068.
sammccall added a comment.

format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137677/new/

https://reviews.llvm.org/D137677

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/AnalysisInternal.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -61,19 +61,19 @@
/*Line=*/1, /*Col=*/1);
   };
 
-  EXPECT_THAT(findHeaders(SourceLocFromFile("header1.h"), SM, PI),
+  EXPECT_THAT(findHeaders(SourceLocFromFile("header1.h"), SM, &PI),
   UnorderedElementsAre(Header("\"path/public.h\"")));
 
-  EXPECT_THAT(findHeaders(SourceLocFromFile("detail1.h"), SM, PI),
+  EXPECT_THAT(findHeaders(SourceLocFromFile("detail1.h"), SM, &PI),
   UnorderedElementsAre(Header(FM.getFile("header2.h").get()),
Header(FM.getFile("detail1.h").get(;
-  EXPECT_THAT(findHeaders(SourceLocFromFile("detail2.h"), SM, PI),
+  EXPECT_THAT(findHeaders(SourceLocFromFile("detail2.h"), SM, &PI),
   UnorderedElementsAre(Header(FM.getFile("header2.h").get()),
Header(FM.getFile("detail2.h").get(;
 
-  EXPECT_THAT(findHeaders(SourceLocFromFile("normal.h"), SM, PI),
+  EXPECT_THAT(findHeaders(SourceLocFromFile("normal.h"), SM, &PI),
   UnorderedElementsAre(Header(FM.getFile("normal.h").get(;
 }
 
 } // namespace
 } // namespace clang::include_cleaner
\ No newline at end of file
Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -72,7 +72,7 @@
 
   auto &SM = AST.sourceManager();
   llvm::DenseMap> OffsetToProviders;
-  walkUsed(TopLevelDecls, /*MacroRefs=*/{}, PI, SM,
+  walkUsed(TopLevelDecls, /*MacroRefs=*/{}, &PI, SM,
[&](const SymbolReference &Ref, llvm::ArrayRef Providers) {
  auto [FID, Offset] = SM.getDecomposedLoc(Ref.RefLocation);
  EXPECT_EQ(FID, SM.getMainFileID());
@@ -113,11 +113,10 @@
   Symbol Answer =
   Macro{&Idents.get("ANSWER"), SM.getComposedLoc(HdrID, Hdr.point())};
   llvm::DenseMap> OffsetToProviders;
-  PragmaIncludes PI;
   walkUsed(/*ASTRoots=*/{}, /*MacroRefs=*/
{SymbolReference{SM.getComposedLoc(SM.getMainFileID(), Main.point()),
 Answer, RefType::Explicit}},
-   PI, SM,
+   /*PI=*/nullptr, SM,
[&](const SymbolReference &Ref, llvm::ArrayRef Providers) {
  auto [FID, Offset] = SM.getDecomposedLoc(Ref.RefLocation);
  EXPECT_EQ(FID, SM.getMainFileID());
Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -47,6 +47,15 @@
 
 class HTMLReportAction : public clang::ASTFrontendAction {
   RecordedAST AST;
+  RecordedPP PP;
+  PragmaIncludes PI;
+
+  void ExecuteAction() override {
+auto &P = getCompilerInstance().getPreprocessor();
+P.addPPCallbacks(PP.record(P));
+PI.record(getCompilerInstance());
+ASTFrontendAction::ExecuteAction();
+  }
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef File) override {
@@ -62,7 +71,7 @@
   exit(1);
 }
 writeHTMLReport(AST.Ctx->getSourceManager().getMainFileID(), AST.Roots,
-*AST.Ctx, OS);
+PP.MacroReferences, *AST.Ctx, &PI, OS);
   }
 };
 
Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -18,10 +18,10 @@
   switch (S.kind()) {
   case Symbol::Declaration:
 if (const auto *ND = llvm::dyn_cast(&S.declaration()))
-  return OS << ND->getNameAsString();
+  return OS << ND->getQualifiedNameAsString();
 return OS << S.declaration().getDeclKindName();
   case Symbol::Macro:
-  

[PATCH] D137677: [include-cleaner] add macro symbols and implicit refs to HTML report

2022-11-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Updated the demo link, PTAL (significant changes since last review)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137677/new/

https://reviews.llvm.org/D137677

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137768: [opt][clang] Enable using -module-summary with -S / -emit-llvm

2022-11-14 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov updated this revision to Diff 475082.
alexander-shaposhnikov added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137768/new/

https://reviews.llvm.org/D137768

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/split-lto-unit.c
  llvm/include/llvm/IR/IRPrintingPasses.h
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/IRPrintingPasses.cpp
  llvm/test/Bitcode/thinlto-function-summary.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -443,16 +443,16 @@
 MPM.addPass(NewPMCheckDebugifyPass(false, "", &DIStatsMap));
   if (VerifyDIPreserve)
 MPM.addPass(NewPMCheckDebugifyPass(
-false, "", nullptr, DebugifyMode::OriginalDebugInfo, &DebugInfoBeforePass,
-VerifyDIPreserveExport));
+false, "", nullptr, DebugifyMode::OriginalDebugInfo,
+&DebugInfoBeforePass, VerifyDIPreserveExport));
 
   // Add any relevant output pass at the end of the pipeline.
   switch (OK) {
   case OK_NoOutput:
 break; // No output pass needed.
   case OK_OutputAssembly:
-MPM.addPass(
-PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
+MPM.addPass(PrintModulePass(
+Out->os(), "", ShouldPreserveAssemblyUseListOrder, EmitSummaryIndex));
 break;
   case OK_OutputBitcode:
 MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder,
Index: llvm/test/Bitcode/thinlto-function-summary.ll
===
--- llvm/test/Bitcode/thinlto-function-summary.ll
+++ llvm/test/Bitcode/thinlto-function-summary.ll
@@ -31,6 +31,8 @@
 
 
 ; RUN: opt -passes=name-anon-globals -module-summary < %s | llvm-dis | FileCheck %s
+; RUN: opt -passes=name-anon-globals -module-summary -S < %s | FileCheck %s
+; RUN: opt -passes=name-anon-globals -module-summary -S < %s | llvm-as | llvm-dis | FileCheck %s
 ; Check that this round-trips correctly.
 
 ; ModuleID = ''
Index: llvm/lib/IR/IRPrintingPasses.cpp
===
--- llvm/lib/IR/IRPrintingPasses.cpp
+++ llvm/lib/IR/IRPrintingPasses.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PrintPasses.h"
@@ -24,19 +25,20 @@
 
 PrintModulePass::PrintModulePass() : OS(dbgs()) {}
 PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
- bool ShouldPreserveUseListOrder)
+ bool ShouldPreserveUseListOrder,
+ bool EmitSummaryIndex)
 : OS(OS), Banner(Banner),
-  ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
+  ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
+  EmitSummaryIndex(EmitSummaryIndex) {}
 
-PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
+PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
   if (llvm::isFunctionInPrintList("*")) {
 if (!Banner.empty())
   OS << Banner << "\n";
 M.print(OS, nullptr, ShouldPreserveUseListOrder);
-  }
-  else {
+  } else {
 bool BannerPrinted = false;
-for(const auto &F : M.functions()) {
+for (const auto &F : M.functions()) {
   if (llvm::isFunctionInPrintList(F.getName())) {
 if (!BannerPrinted && !Banner.empty()) {
   OS << Banner << "\n";
@@ -46,6 +48,16 @@
   }
 }
   }
+
+  ModuleSummaryIndex *Index =
+  EmitSummaryIndex ? &(AM.getResult(M))
+   : nullptr;
+  if (Index) {
+if (Index->modulePaths().empty())
+  Index->addModule("", 0);
+Index->print(OS);
+  }
+
   return PreservedAnalyses::all();
 }
 
Index: llvm/lib/IR/CMakeLists.txt
===
--- llvm/lib/IR/CMakeLists.txt
+++ llvm/lib/IR/CMakeLists.txt
@@ -76,6 +76,7 @@
   intrinsics_gen
 
   LINK_COMPONENTS
+  Analysis
   BinaryFormat
   Remarks
   Support
Index: llvm/include/llvm/IR/IRPrintingPasses.h
===
--- llvm/include/llvm/IR/IRPrintingPasses.h
+++ llvm/include/llvm/IR/IRPrintingPasses.h
@@ -58,11 +58,13 @@
   raw_ostream &OS;
   std::string Banner;
   bool ShouldPreserveUseListOrder;
+  bool EmitSummaryIndex;
 
 public:
   PrintModulePass();
   PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
-  bool ShouldPreserveUseListOrder = false);
+  bool ShouldPreserveUseListOrder = false,
+  bool EmitSummaryIndex = false);
 
   PreservedAnalyses run(Module &M, AnalysisManager &);
   static bool isRequired() { return t

[PATCH] D137927: Adapt unittests for isSelfContainedHeader to API

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: hokein, kadircet.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The function now takes a FileEntry instead of a FileID.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137927

Files:
  clang/unittests/Tooling/HeaderAnalysisTest.cpp


Index: clang/unittests/Tooling/HeaderAnalysisTest.cpp
===
--- clang/unittests/Tooling/HeaderAnalysisTest.cpp
+++ clang/unittests/Tooling/HeaderAnalysisTest.cpp
@@ -50,15 +50,15 @@
   const auto &SM = AST.sourceManager();
   auto &FM = SM.getFileManager();
   auto &HI = AST.preprocessor().getHeaderSearchInfo();
-  auto getFileID = [&](llvm::StringRef FileName) {
-return SM.translateFile(FM.getFile(FileName).get());
+  auto getFileEntry = [&](llvm::StringRef FileName) {
+return FM.getFile(FileName).get();
   };
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("headerguard.h"), SM, HI));
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("pragmaonce.h"), SM, HI));
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("imported.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileEntry("headerguard.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileEntry("pragmaonce.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileEntry("imported.h"), SM, HI));
 
-  EXPECT_FALSE(isSelfContainedHeader(getFileID("unguarded.h"), SM, HI));
-  EXPECT_FALSE(isSelfContainedHeader(getFileID("bad.h"), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(getFileEntry("unguarded.h"), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(getFileEntry("bad.h"), SM, HI));
 }
 
 } // namespace


Index: clang/unittests/Tooling/HeaderAnalysisTest.cpp
===
--- clang/unittests/Tooling/HeaderAnalysisTest.cpp
+++ clang/unittests/Tooling/HeaderAnalysisTest.cpp
@@ -50,15 +50,15 @@
   const auto &SM = AST.sourceManager();
   auto &FM = SM.getFileManager();
   auto &HI = AST.preprocessor().getHeaderSearchInfo();
-  auto getFileID = [&](llvm::StringRef FileName) {
-return SM.translateFile(FM.getFile(FileName).get());
+  auto getFileEntry = [&](llvm::StringRef FileName) {
+return FM.getFile(FileName).get();
   };
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("headerguard.h"), SM, HI));
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("pragmaonce.h"), SM, HI));
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("imported.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileEntry("headerguard.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileEntry("pragmaonce.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(getFileEntry("imported.h"), SM, HI));
 
-  EXPECT_FALSE(isSelfContainedHeader(getFileID("unguarded.h"), SM, HI));
-  EXPECT_FALSE(isSelfContainedHeader(getFileID("bad.h"), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(getFileEntry("unguarded.h"), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(getFileEntry("bad.h"), SM, HI));
 }
 
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137697: Move the isSelfContained function from clangd to libtooling.

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

@hokein it seems the unit test wasn't updated for the last-minute API change, 
which breaks `check-all` for me. I've posted https://reviews.llvm.org/D137927, 
could you take a look if that change is correct?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137697/new/

https://reviews.llvm.org/D137697

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5c4ae8a - Update the wrong isSelfContainedHeader API usage in the test.

2022-11-14 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-11-14T11:10:55+01:00
New Revision: 5c4ae8a86a865e622e2c663666c0c139334b5da2

URL: 
https://github.com/llvm/llvm-project/commit/5c4ae8a86a865e622e2c663666c0c139334b5da2
DIFF: 
https://github.com/llvm/llvm-project/commit/5c4ae8a86a865e622e2c663666c0c139334b5da2.diff

LOG: Update the wrong isSelfContainedHeader API usage in the test.

Added: 


Modified: 
clang/unittests/Tooling/HeaderAnalysisTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/HeaderAnalysisTest.cpp 
b/clang/unittests/Tooling/HeaderAnalysisTest.cpp
index 1a121e7bf0a48..37a4c3ffb483e 100644
--- a/clang/unittests/Tooling/HeaderAnalysisTest.cpp
+++ b/clang/unittests/Tooling/HeaderAnalysisTest.cpp
@@ -50,15 +50,12 @@ TEST(HeaderAnalysisTest, IsSelfContained) {
   const auto &SM = AST.sourceManager();
   auto &FM = SM.getFileManager();
   auto &HI = AST.preprocessor().getHeaderSearchInfo();
-  auto getFileID = [&](llvm::StringRef FileName) {
-return SM.translateFile(FM.getFile(FileName).get());
-  };
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("headerguard.h"), SM, HI));
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("pragmaonce.h"), SM, HI));
-  EXPECT_TRUE(isSelfContainedHeader(getFileID("imported.h"), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(FM.getFile("headerguard.h").get(), SM, 
HI));
+  EXPECT_TRUE(isSelfContainedHeader(FM.getFile("pragmaonce.h").get(), SM, HI));
+  EXPECT_TRUE(isSelfContainedHeader(FM.getFile("imported.h").get(), SM, HI));
 
-  EXPECT_FALSE(isSelfContainedHeader(getFileID("unguarded.h"), SM, HI));
-  EXPECT_FALSE(isSelfContainedHeader(getFileID("bad.h"), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(FM.getFile("unguarded.h").get(), SM, HI));
+  EXPECT_FALSE(isSelfContainedHeader(FM.getFile("bad.h").get(), SM, HI));
 }
 
 } // namespace



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137697: Move the isSelfContained function from clangd to libtooling.

2022-11-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D137697#3924305 , @Hahnfeld wrote:

> @hokein it seems the unit test wasn't updated for the last-minute API change, 
> which breaks `check-all` for me. I've posted 
> https://reviews.llvm.org/D137927, could you take a look if that change is 
> correct?

oops, thanks, and your analysis is right! (I landed a fix in 
5c4ae8a86a865e622e2c663666c0c139334b5da2 
 before 
reading your email, sorry).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137697/new/

https://reviews.llvm.org/D137697

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137927: Adapt unittests for isSelfContainedHeader to API

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld abandoned this revision.
Hahnfeld added a comment.

Fixed in https://reviews.llvm.org/rG5c4ae8a86a865e622e2c663666c0c139334b5da2


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137927/new/

https://reviews.llvm.org/D137927

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137697: Move the isSelfContained function from clangd to libtooling.

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

No worries, thanks for fixing so quickly! I just happened to pull in the wrong 
moment...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137697/new/

https://reviews.llvm.org/D137697

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

> Sorry, I don't understand well. Could you rewrite the reproducer in the style 
> I wrote? And in what cases it works fine?

Okay, let me try to restate: I can reproduce the problem in ROOT/Cling which is 
an *interpreter* built on top of LLVM and CLang. The moment I put the same code 
(basically in the style that you wrote it) into standalone Clang, all is fine 
and I cannot reproduce the crash. Sorry if that was confusing in the beginning, 
but I've tried to make this clear from the start that I cannot actually 
reproduce this in pure Clang.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137787/new/

https://reviews.llvm.org/D137787

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137677: [include-cleaner] add macro symbols and implicit refs to HTML report

2022-11-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

The new UI looks good.




Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:24
   UsedSymbolCB CB) {
+  // This is duplicated in HTMLReport.cpp, changes should be mirrored there.
   tooling::stdlib::Recognizer Recognizer;

nit: mention the `writeHTMLReport` function explicitly.



Comment at: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp:355
+walkAST(*Root, [&](SourceLocation Loc, const NamedDecl &D, RefType T) {
+  R.addRef(SymbolReference{Loc, D, T});
 });

We need a special logic (`if (auto SS = Recognizer(&ND)) {...}`) for the stdlib 
symbols, otherwise, they will be treated as normal Decl symbols.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137677/new/

https://reviews.llvm.org/D137677

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:3302
+  void ParseOpenMPClauses(OpenMPDirectiveKind DKind,
+  SmallVector *Clauses,
+  SourceLocation Loc);

`SmallVectorImpl &`



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1656-1657
+OMPAtClause *AtC = CKind == OMPC_at ? cast(Clause) : nullptr;
+if (CKind == OMPC_at && AtC->getAtKind() == OMPC_AT_execution)
+  Diag(AtC->getAtKindKwLoc(), diag::err_omp_unexpected_execution_modifier);
+if (Tok.is(tok::annot_pragma_openmp_end)) {

Better to diagnose it in Sema


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137714: Do not merge traps in functions annotated optnone

2022-11-14 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 475104.
hnrklssn marked an inline comment as done.
hnrklssn added a comment.

Add explicit labels to FileCheck checks


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137714/new/

https://reviews.llvm.org/D137714

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/ubsan-trap-debugloc.c


Index: clang/test/CodeGen/ubsan-trap-debugloc.c
===
--- clang/test/CodeGen/ubsan-trap-debugloc.c
+++ clang/test/CodeGen/ubsan-trap-debugloc.c
@@ -2,9 +2,23 @@
 
 
 void foo(volatile int a) {
+  // CHECK-LABEL: @foo
   // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC:![0-9]+]]
   a = a + 1;
   a = a + 1;
 }
 
+void bar(volatile int a) __attribute__((optnone)) {
+  // CHECK-LABEL: @bar
+  // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC2:![0-9]+]]
+  // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC3:![0-9]+]]
+  a = a + 1;
+  a = a + 1;
+}
+
+// With optimisations enabled the traps are merged and need to share a debug 
location
 // CHECK: [[LOC]] = !DILocation(line: 0
+
+// With optimisations disabled the traps are not merged and retain accurate 
debug locations
+// CHECK: [[LOC2]] = !DILocation(line: 15, column: 9
+// CHECK: [[LOC3]] = !DILocation(line: 16, column: 9
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3545,7 +3545,8 @@
 TrapBBs.resize(CheckHandlerID + 1);
   llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
 
-  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
+  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB ||
+  (CurCodeDecl && CurCodeDecl->hasAttr())) {
 TrapBB = createBasicBlock("trap");
 Builder.CreateCondBr(Checked, Cont, TrapBB);
 EmitBlock(TrapBB);


Index: clang/test/CodeGen/ubsan-trap-debugloc.c
===
--- clang/test/CodeGen/ubsan-trap-debugloc.c
+++ clang/test/CodeGen/ubsan-trap-debugloc.c
@@ -2,9 +2,23 @@
 
 
 void foo(volatile int a) {
+  // CHECK-LABEL: @foo
   // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC:![0-9]+]]
   a = a + 1;
   a = a + 1;
 }
 
+void bar(volatile int a) __attribute__((optnone)) {
+  // CHECK-LABEL: @bar
+  // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC2:![0-9]+]]
+  // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC3:![0-9]+]]
+  a = a + 1;
+  a = a + 1;
+}
+
+// With optimisations enabled the traps are merged and need to share a debug location
 // CHECK: [[LOC]] = !DILocation(line: 0
+
+// With optimisations disabled the traps are not merged and retain accurate debug locations
+// CHECK: [[LOC2]] = !DILocation(line: 15, column: 9
+// CHECK: [[LOC3]] = !DILocation(line: 16, column: 9
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3545,7 +3545,8 @@
 TrapBBs.resize(CheckHandlerID + 1);
   llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
 
-  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
+  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB ||
+  (CurCodeDecl && CurCodeDecl->hasAttr())) {
 TrapBB = createBasicBlock("trap");
 Builder.CreateCondBr(Checked, Cont, TrapBB);
 EmitBlock(TrapBB);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Trass3r via Phabricator via cfe-commits
Trass3r added inline comments.



Comment at: clang/CMakeLists.txt:417
 
-add_definitions( -D_GNU_SOURCE )
-

Found when building with clang-cl. It's already handled correctly in the llvm 
config file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Aaron Ballman via cfe-commits
On Sat, Nov 12, 2022 at 7:43 PM Paul Eggert  wrote:
>
> On 2022-11-11 07:11, Aaron Ballman wrote:
> > We believe the runtime behavior is sufficiently dangerous to
> > warrant a conservative view that any call to a function will be a call
> > that gets executed at runtime, hence a definitive signature mismatch
> > is something we feel comfortable diagnosing (in some form) by default.
>
> As long as these diagnostics by default do not cause the compiler to
> exit with nonzero status, we should be OK with Autoconf-generated
> 'configure' scripts. Although there will be problems with people who run
> "./configure CFLAGS='-Werror'", that sort of usage has always been
> problematic and unsupported by Autoconf, so we can simply continue to
> tell people "don't do that".

That's good to know, but is a problem more generally -- we are
strengthening more diagnostics to be warnings that are treated as an
error by default. This gives our users the best experience in terms of
diagnostic behavior -- they're clearly alerted to serious issues in
their code (either issues of conformance, like with use of implicit
int or implicit function decls in C99 or later, or issues of security
like statically known instances of UB), but they still have the chance
to downgrade the diagnostic back into a warning (good as a temporary
solution to start migrating code) or disable the diagnostic entirely
(good if you plan to never update your compiler version but otherwise
not recommended). Some of these diagnostics are expected to change to
be error-only diagnostics in the future, so this strengthening helps
to set user expectations as well.

That's why it's generally a problem when autoconf relies on invalid
language constructs -- it creates a tension between the autoconf uses
and improving the C ecosystem.  The autoconf uses aren't always
unreasonable, but are very much a special case scenario compared to
general C development. I suspect that as the security posture of the C
language and its implementations improves in response to recent
concerns around suitability of the language
(https://media.defense.gov/2022/Nov/10/2003112742/-1/-1/0/CSI_SOFTWARE_MEMORY_SAFETY.PDF),
this tension will come up more frequently.

~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137920: [nfc] Mark classes final as reported by -Wsuggest-final-types

2022-11-14 Thread Trass3r via Phabricator via cfe-commits
Trass3r updated this revision to Diff 475114.
Trass3r added a comment.

fix build


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137920/new/

https://reviews.llvm.org/D137920

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Pragma.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/SemaInternal.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/lib/Driver/ToolChains/CSKYToolChain.h
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Lanai.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/NaCl.h
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/PPCFreeBSD.h
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/lib/Driver/ToolChains/SPIRV.h
  clang/lib/Driver/ToolChains/VEToolchain.h
  clang/lib/Frontend/MultiplexConsumer.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
  llvm/include/llvm/CodeGen/GlobalISel/GISelKnownBits.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
  llvm/include/llvm/Object/COFF.h
  llvm/include/llvm/Object/MachO.h
  llvm/include/llvm/Object/Wasm.h
  llvm/include/llvm/Object/XCOFFObjectFile.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/include/llvm/TableGen/Record.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/lib/Target/AArch64/AArch64FrameLowering.h
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/utils/TableGen/DAGISelMatcher.h
  llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
  llvm/utils/TableGen/GlobalISel/GIMatchTree.h

Index: llvm/utils/TableGen/GlobalISel/GIMatchTree.h
===
--- llvm/utils/TableGen/GlobalISel/GIMatchTree.h
+++ llvm/utils/TableGen/GlobalISel/GIMatchTree.h
@@ -553,7 +553,7 @@
 ///   result is that the cases that don't match the superset will match the
 ///   subset rule, while the ones that do match the superset will match either
 ///   (which one is algorithm dependent but will usually be the superset).
-class GIMatchTreeOpcodePartitioner : public GIMatchTreePartitioner {
+class GIMatchTreeOpcodePartitioner final : public GIMatchTreePartitioner {
   unsigned InstrID;
   DenseMap InstrToPartition;
   std::vector PartitionToInstr;
@@ -582,7 +582,7 @@
  StringRef Indent) const override;
 };
 
-class GIMatchTreeVRegDefPartitioner : public GIMatchTreePartitioner {
+class GIMatchTreeVRegDefPartitioner final : public GIMatchTreePartitioner {
   unsigned NewInstrID = -1;
   unsigned InstrID;
   unsigned OpIdx;
Index: llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
===
--- llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
+++ llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
@@ -80,7 +80,7 @@
 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 };
 
-class GIMatchDagOpcodePredicate : public GIMatchDagPredicate {
+class GIMatchDagOpcodePredicate final : public GIMatchDagPredicate {
   const CodeGenInstruction &Instr;
 
 public:
@@ -100,7 +100,7 @@
 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 };
 
-class GIMatchDagOneOfOpcodesPredicate : public GIMatchDagPredicate {
+class GIMatchDagOneOfOpcodesPredicate final : public GIMatchDagPredicate {
   SmallVector Instrs;
 
 public:
@@ -123,7 +123,7 @@
 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 };
 
-class GIMatchDagSameMOPredicate : public GIMatchDagPredicate {
+class GIMatchDagSameMOPredicate final : public GIMat

[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D137787#3924341 , @Hahnfeld wrote:

>> Sorry, I don't understand well. Could you rewrite the reproducer in the 
>> style I wrote? And in what cases it works fine?
>
> Okay, let me try to restate: I can reproduce the problem in ROOT/Cling which 
> is an *interpreter* built on top of LLVM and CLang. The moment I put the same 
> code (basically in the style that you wrote it) into standalone Clang, all is 
> fine and I cannot reproduce the crash. Sorry if that was confusing in the 
> beginning, but I've tried to make this clear from the start that I cannot 
> actually reproduce this in pure Clang.

Thanks, I got your point. But a test is really necessary here. Since it is 
completely possible that the problem happens in earlier steps and it only shows 
in this assertion. And it will be pretty bad in this case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137787/new/

https://reviews.llvm.org/D137787

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137939: [CGObjC] Open cleanup scope before SaveAndRestore CurrentFuncletPad and push CatchRetScope early

2022-11-14 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz created this revision.
sgraenitz added reviewers: theraven, rnk.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Pushing the `CatchRetScope` early causes cleanups for catch parameters to be 
emitted in the basic block of the catch handler instead of the `catchret.dest` 
block. This is important because the latter is not part of the catchpad and 
this caused code truncations due to ARC PreISel intrinsics in WinEHPrepare.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137939

Files:
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/test/CodeGenObjCXX/arc-exceptions-seh.mm

Index: clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
===
--- clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
+++ clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
@@ -7,23 +7,42 @@
 // funclet tokens for llvm.objc.retain and llvm.objc.storeStrong and that they
 // refer to their catchpad's SSA value.
 
-@class Ety;
-void opaque(void);
-void test_catch_with_objc_intrinsic(void) {
+void do_something();
+void may_throw(id);
+
+void try_catch_with_objc_intrinsic() {
+  id ex;
   @try {
-opaque();
-  } @catch (Ety *ex) {
-// Destroy ex when leaving catchpad. This emits calls to intrinsic functions
-// llvm.objc.retain and llvm.objc.storeStrong
+may_throw(ex);
+  } @catch (id ex_caught) {
+do_something();
+may_throw(ex_caught);
   }
 }
 
-// CHECK-LABEL: define{{.*}} void {{.*}}test_catch_with_objc_intrinsic
-//...
-// CHECK:   catch.dispatch:
-// CHECK-NEXT:[[CATCHSWITCH:%[0-9]+]] = catchswitch within none
-//...
-// CHECK:   catch:
-// CHECK-NEXT:[[CATCHPAD:%[0-9]+]] = catchpad within [[CATCHSWITCH]]
-// CHECK: {{%[0-9]+}} = call {{.*}} @llvm.objc.retain{{.*}} [ "funclet"(token [[CATCHPAD]]) ]
-// CHECK: call {{.*}} @llvm.objc.storeStrong{{.*}} [ "funclet"(token [[CATCHPAD]]) ]
+// CHECK-LABEL:   try_catch_with_objc_intrinsic
+//
+// CHECK: catch.dispatch:
+// CHECK-NEXT:  [[CATCHSWITCH:%[0-9]+]] = catchswitch within none [label %catch]
+//
+// All calls within a catchpad must have funclet tokens that refer to the
+// enclosing catchpad:
+// CHECK: catch:
+// CHECK-NEXT:  [[CATCHPAD:%[0-9]+]] = catchpad within [[CATCHSWITCH]]
+// CHECK:   call
+// CHECK:   @llvm.objc.retain
+// CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
+// CHECK:   call
+// CHECK:   do_something
+// CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
+// CHECK:   call
+// CHECK:   may_throw
+// CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
+// CHECK:   call
+// CHECK:   @llvm.objc.storeStrong
+// CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
+// CHECK:   catchret from [[CATCHPAD]] to label %catchret.dest
+//
+// This block exists and it's empty:
+// CHECK: catchret.dest:
+// CHECK-NEXT:  br label %eh.cont
Index: clang/lib/CodeGen/CGObjCRuntime.cpp
===
--- clang/lib/CodeGen/CGObjCRuntime.cpp
+++ clang/lib/CodeGen/CGObjCRuntime.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/StmtObjC.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/CodeGen/CodeGenABITypes.h"
+#include "llvm/IR/Instruction.h"
 #include "llvm/Support/SaveAndRestore.h"
 
 using namespace clang;
@@ -227,13 +228,18 @@
 CatchHandler &Handler = Handlers[I];
 
 CGF.EmitBlock(Handler.Block);
-llvm::CatchPadInst *CPI = nullptr;
-SaveAndRestore RestoreCurrentFuncletPad(CGF.CurrentFuncletPad);
-if (useFunclets)
-  if ((CPI = dyn_cast_or_null(Handler.Block->getFirstNonPHI( {
+
+CodeGenFunction::LexicalScope Cleanups(CGF, Handler.Body->getSourceRange());
+SaveAndRestore RevertAfterScope(CGF.CurrentFuncletPad);
+if (useFunclets) {
+  llvm::Instruction *CPICandidate = Handler.Block->getFirstNonPHI();
+  if (auto *CPI = dyn_cast_or_null(CPICandidate)) {
 CGF.CurrentFuncletPad = CPI;
 CPI->setOperand(2, CGF.getExceptionSlot().getPointer());
+CGF.EHStack.pushCleanup(NormalCleanup, CPI);
   }
+}
+
 llvm::Value *RawExn = CGF.getExceptionFromSlot();
 
 // Enter the catch.
@@ -241,8 +247,6 @@
 if (beginCatchFn)
   Exn = CGF.EmitNounwindRuntimeCall(beginCatchFn, RawExn, "exn.adjusted");
 
-CodeGenFunction::LexicalScope cleanups(CGF, Handler.Body->getSourceRange());
-
 if (endCatchFn) {
   // Add a cleanup to leave the catch.
   bool EndCatchMightThrow = (Handler.Variable == nullptr);
@@ -260,15 +264,13 @@
   CGF.EmitAutoVarDecl(*CatchParam);
   EmitInitOfCatchParam(CGF, CastExn, CatchParam);
 }
-if (CPI)
-CGF.EHStack.pushCleanup(NormalCleanup, CPI);
 
 CGF.ObjCEHValueStack.push_back(Exn);
 CGF.EmitStmt(Handler.Body);
 CGF.ObjCE

[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-11-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added subscribers: vitalybuka, glider, rsmith.
lebedev.ri added a comment.

Can someone from @Sanitizers please comment? :) @vitalybuka ? @glider ? @rsmith 
 ?

In D137381#3923911 , @MaskRay wrote:

> I think improving diagnostic is useful but `-fsanitize=` is probably not a 
> good place.



> Instrumenting call sites with `callq   __ubsan_handle_exception_escape@PLT` 
> wastes code size.

Can you please explain why replacing one call with another somehow makes things 
worse?

> The functionality is better handled somewhere in libc++abi personality 
> related code

That would not be helpful, i'm not using libc++.
It seems obviously wrong to me to require every used C++ ABI library
to implement "some improvements", instead, you know,
the clang irgen + clang ubsan lib.

If we do this, we have native source location info for the location of the call 
site
out of which the exception has escaped, that causes the "abort".
I do not know if that will be possible with less native approach.

The reason i'm doing this, is because recently i had to deal with a few of 
these bugs,
and i never got any kind of backtrace, so the situation can't not be made 
better.

> with possible improvement to exception handling related LLVM IR.



>   void bar(); void foo() { bar(); }
>
> `clang++ -fno-exceptions -fsanitize=exception-escape -c b.cc` does not 
> instrument the potentially-throwing-and-propagating `bar()` so an error 
> cannot be caught.

i'm only looking at `-fexceptions` side of things, i'm not sure how
mixing `-fno-exceptions` and `-fexceptions` code is supposed to work.
It is not oblivious to me why not dealing with some other situation
means we can't deal with the situation we can deal with.

> However, for `-fno-exceptions` code, instrumenting every call site is going 
> to greatly increase code size and suppress optimizations.

Citation needed/define "greatly"?
We have a single "termination" landing pad per function,
and we seem to end up with just a single extra `jmp` per call.
https://godbolt.org/z/Td3jWM1oh

But yes, that's the known and expected nature of sanitization.

> I wish that I capture the compiler and runtime behavior well in 
> https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#compiler-behavior.
>  
> https://discourse.llvm.org/t/catching-exceptions-while-unwinding-through-fno-exceptions-code/57151
>  is a proposal to improve the diagnostics.

Thanks. That explains current behavior, but does not tell why it must be 
enshrined and never changed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137381/new/

https://reviews.llvm.org/D137381

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137720: Migrate getOrCreateInternalVariable from Clang to OMPIRBuilder.

2022-11-14 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 475125.
TIFitis marked 2 inline comments as done.
TIFitis added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137720/new/

https://reviews.llvm.org/D137720

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3866,7 +3866,7 @@
   Value *Ident = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
   Value *ThreadId = getOrCreateThreadID(Ident);
   Constant *ThreadPrivateCache =
-  getOrCreateOMPInternalVariable(Int8PtrPtr, Name);
+  getOrCreateInternalVariable(Int8PtrPtr, Name.str());
   llvm::Value *Args[] = {Ident, ThreadId, Pointer, Size, ThreadPrivateCache};
 
   Function *Fn =
@@ -3963,18 +3963,10 @@
   return OS.str().str();
 }
 
-Constant *OpenMPIRBuilder::getOrCreateOMPInternalVariable(
-llvm::Type *Ty, const llvm::Twine &Name, unsigned AddressSpace) {
-  // TODO: Replace the twine arg with stringref to get rid of the conversion
-  // logic. However This is taken from current implementation in clang as is.
-  // Since this method is used in many places exclusively for OMP internal use
-  // we will keep it as is for temporarily until we move all users to the
-  // builder and then, if possible, fix it everywhere in one go.
-  SmallString<256> Buffer;
-  llvm::raw_svector_ostream Out(Buffer);
-  Out << Name;
-  StringRef RuntimeName = Out.str();
-  auto &Elem = *InternalVars.try_emplace(RuntimeName, nullptr).first;
+GlobalVariable *
+OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name,
+ unsigned AddressSpace) {
+  auto &Elem = *InternalVars.try_emplace(Name, nullptr).first;
   if (Elem.second) {
 assert(cast(Elem.second->getType())
->isOpaqueOrPointeeTypeMatches(Ty) &&
@@ -3984,20 +3976,19 @@
 // variable for possibly changing that to internal or private, or maybe
 // create different versions of the function for different OMP internal
 // variables.
-Elem.second = new llvm::GlobalVariable(
-M, Ty, /*IsConstant*/ false, llvm::GlobalValue::CommonLinkage,
-llvm::Constant::getNullValue(Ty), Elem.first(),
-/*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
-AddressSpace);
+Elem.second = new GlobalVariable(
+M, Ty, /*IsConstant=*/false, GlobalValue::CommonLinkage,
+Constant::getNullValue(Ty), Elem.first(),
+/*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal, AddressSpace);
   }
 
-  return Elem.second;
+  return cast(&*Elem.second);
 }
 
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
 }
 
 GlobalVariable *
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1462,15 +1462,6 @@
StringRef FirstSeparator,
StringRef Separator);
 
-  /// Gets (if variable with the given name already exist) or creates
-  /// internal global variable with the specified Name. The created variable has
-  /// linkage CommonLinkage by default and is initialized by null value.
-  /// \param Ty Type of the global variable. If it is exist already the type
-  /// must be the same.
-  /// \param Name Name of the variable.
-  Constant *getOrCreateOMPInternalVariable(Type *Ty, const Twine &Name,
-   unsigned AddressSpace = 0);
-
   /// Returns corresponding lock object for the specified critical region
   /// name. If the lock object does not exist it is created, otherwise the
   /// reference to the existing copy is returned.
@@ -1726,6 +1717,15 @@
   void
   loadOffloadInfoMetadata(Module &M,
   OffloadEntriesInfoManager &OffloadEntriesInfoManager);
+
+  /// Gets (if variable with the given name already exist) or creates
+  /// internal global variable with the specified Name. The created variable has
+  /// linkage CommonLinkage by default and is initialized by null value.
+  /// \param Ty Type of the global variable. If it is exist already the type
+  /// must be the same.
+  /// \param Name Name of the variable.
+  GlobalVariable *getOrCreateInternalVariable(Type *Ty, const St

[PATCH] D137720: Migrate getOrCreateInternalVariable from Clang to OMPIRBuilder.

2022-11-14 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:1729
+  const llvm::StringRef &Name,
+  unsigned AddressSpace = 0);
 };

jdoerfert wrote:
> No `llvm::`. Can you check your future patches for these things, please.
> StringRef is passed by value not reference.
Sure. The current code was inconsistent so I wasn't sure and went with the 
standard practice of explicitly describing namespace in header files and 
removed them from cpp files. I'll remove from both going forward :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137720/new/

https://reviews.llvm.org/D137720

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137939: [CGObjC] Open cleanup scope before SaveAndRestore CurrentFuncletPad and push CatchRetScope early

2022-11-14 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

The approach follows the C++ try/catch implementation in 
clang/lib/CodeGen/CGException.cpp 
.
 I think this is the correct solution for what I attempted to fix with D134866 
 in the backend before.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137939/new/

https://reviews.llvm.org/D137939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Yes, I fully agree that having a test is desirable, I just didn't manage so 
far. Maybe it takes somebody with deep AST knowledge to explain under what 
circumstances `DtorDecl->getParent()` is *not* the canonical `Decl`. Maybe this 
could help crafting a test case, even outside of modules maybe


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137787/new/

https://reviews.llvm.org/D137787

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137942: [CGObjC] Add run line for release mode in test arc-exceptions-seh.mm (NFC)

2022-11-14 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz created this revision.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In release mode the updated `arc-exceptions-seh.mm` test fails and needs 
`-enable-objc-arc-opts=false` to skip ObjC ARC optimizations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137942

Files:
  clang/test/CodeGenObjCXX/arc-exceptions-seh.mm


Index: clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
===
--- clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
+++ clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
@@ -1,11 +1,12 @@
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck 
%s --check-prefixes=CHECK,CHECK-O0
+// RUN: %clang_cc1 -O2 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -mllvm 
-enable-objc-arc-opts=false -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-O2
 
 // WinEH requires funclet tokens on nounwind intrinsics if they can lower to
 // regular function calls in the course of IR transformations.
 //
 // This is the case for ObjC ARC runtime intrinsics. Test that clang emits the
-// funclet tokens for llvm.objc.retain and llvm.objc.storeStrong and that they
-// refer to their catchpad's SSA value.
+// funclet tokens for llvm.objc.* calls inside catchpads and that they refer to
+// their catchpad's SSA value.
 
 void do_something();
 void may_throw(id);
@@ -39,10 +40,12 @@
 // CHECK:   may_throw
 // CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
 // CHECK:   call
-// CHECK:   @llvm.objc.storeStrong
+// CHECK-O0:@llvm.objc.storeStrong
+// CHECK-O2:@llvm.objc.release
 // CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
-// CHECK:   catchret from [[CATCHPAD]] to label %catchret.dest
+// CHECK-O0:catchret from [[CATCHPAD]] to label %catchret.dest
+// CHECK-O2:catchret from [[CATCHPAD]] to label %eh.cont
 //
-// This block exists and it's empty:
-// CHECK: catchret.dest:
-// CHECK-NEXT:  br label %eh.cont
+// In debug mode, this block exists and it's empty:
+// CHECK-O0:  catchret.dest:
+// CHECK-O0-NEXT:   br label %eh.cont


Index: clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
===
--- clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
+++ clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
@@ -1,11 +1,12 @@
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O0
+// RUN: %clang_cc1 -O2 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -mllvm -enable-objc-arc-opts=false -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O2
 
 // WinEH requires funclet tokens on nounwind intrinsics if they can lower to
 // regular function calls in the course of IR transformations.
 //
 // This is the case for ObjC ARC runtime intrinsics. Test that clang emits the
-// funclet tokens for llvm.objc.retain and llvm.objc.storeStrong and that they
-// refer to their catchpad's SSA value.
+// funclet tokens for llvm.objc.* calls inside catchpads and that they refer to
+// their catchpad's SSA value.
 
 void do_something();
 void may_throw(id);
@@ -39,10 +40,12 @@
 // CHECK:   may_throw
 // CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
 // CHECK:   call
-// CHECK:   @llvm.objc.storeStrong
+// CHECK-O0:@llvm.objc.storeStrong
+// CHECK-O2:@llvm.objc.release
 // CHECK:   [ "funclet"(token [[CATCHPAD]]) ]
-// CHECK:   catchret from [[CATCHPAD]] to label %catchret.dest
+// CHECK-O0:catchret from [[CATCHPAD]] to label %catchret.dest
+// CHECK-O2:catchret from [[CATCHPAD]] to label %eh.cont
 //
-// This block exists and it's empty:
-// CHECK: catchret.dest:
-// CHECK-NEXT:  br label %eh.cont
+// In debug mode, this block exists and it's empty:
+// CHECK-O0:  catchret.dest:
+// CHECK-O0-NEXT:   br label %eh.cont
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137943: [clangd] Mark "override" and "final" as keywords

2022-11-14 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

... in semantic highlighting.
These specifiers are keywords for all intents and purposes, except that
they are not, for backward compatibility. As a result, they cannot be
identified by simple lexing (since e.g. variables with these names can
legally be declared), which means they should be semantic tokens.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137943

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -864,7 +864,13 @@
 const char *$LocalVariable_def_readonly[[s]] = 
$LocalVariable_readonly_static[[__func__]];
 }
   )cpp",
+  // override and final
+  R"cpp(
+class $Class_def_abstract[[Base]] { virtual void 
$Method_decl_abstract_virtual[[m]]() = 0; };
+class $Class_def[[Derived]] : public $Class_abstract[[Base]] { void 
$Method_decl_virtual[[m]]() $Keyword[[override]]; };
+class $Class_def[[MoreDerived]] : public $Class[[Derived]] { void 
$Method_decl_virtual[[m]]() $Keyword[[final]]; };
   // Issue 1222: readonly modifier for generic parameter
+  )cpp",
   R"cpp(
 template 
 auto $Function_def[[foo]](const $TemplateParameter[[T]] 
$Parameter_def_readonly[[template_type]], 
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -49,6 +49,7 @@
   Concept,
   Primitive,
   Macro,
+  Keyword,
 
   // This one is different from the other kinds as it's a line style
   // rather than a token style.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -809,6 +809,18 @@
 return true;
   }
 
+  bool VisitAttr(Attr *A) {
+switch (A->getKind()) {
+case attr::Override:
+case attr::Final:
+  H.addToken(A->getLocation(), HighlightingKind::Keyword);
+  break;
+default:
+  break;
+}
+return true;
+  }
+
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
 H.addToken(L.getNameLoc(), HighlightingKind::Type)
 .addModifier(HighlightingModifier::DependentName)
@@ -985,6 +997,8 @@
 return OS << "Primitive";
   case HighlightingKind::Macro:
 return OS << "Macro";
+  case HighlightingKind::Keyword:
+return OS << "Keyword";
   case HighlightingKind::InactiveCode:
 return OS << "InactiveCode";
   }
@@ -1119,6 +1133,8 @@
 return "type";
   case HighlightingKind::Macro:
 return "macro";
+  case HighlightingKind::Keyword:
+return "keyword";
   case HighlightingKind::InactiveCode:
 return "comment";
   }


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -864,7 +864,13 @@
 const char *$LocalVariable_def_readonly[[s]] = $LocalVariable_readonly_static[[__func__]];
 }
   )cpp",
+  // override and final
+  R"cpp(
+class $Class_def_abstract[[Base]] { virtual void $Method_decl_abstract_virtual[[m]]() = 0; };
+class $Class_def[[Derived]] : public $Class_abstract[[Base]] { void $Method_decl_virtual[[m]]() $Keyword[[override]]; };
+class $Class_def[[MoreDerived]] : public $Class[[Derived]] { void $Method_decl_virtual[[m]]() $Keyword[[final]]; };
   // Issue 1222: readonly modifier for generic parameter
+  )cpp",
   R"cpp(
 template 
 auto $Function_def[[foo]](const $TemplateParameter[[T]] $Parameter_def_readonly[[template_type]], 
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -49,6 +49,7 @@
   Concept,
   Primitive,
   Macro,
+  Keyword,
 
   // This one is different from the other kinds as it's a line style
   // rather than a token style.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===

[clang] 5c67cf0 - Add clang_CXXMethod_isMoveAssignmentOperator to libclang

2022-11-14 Thread Luca Di Sera via cfe-commits

Author: Luca Di Sera
Date: 2022-11-14T15:21:36+01:00
New Revision: 5c67cf0a7fdc00c9b9c55578b770e768f5618bed

URL: 
https://github.com/llvm/llvm-project/commit/5c67cf0a7fdc00c9b9c55578b770e768f5618bed
DIFF: 
https://github.com/llvm/llvm-project/commit/5c67cf0a7fdc00c9b9c55578b770e768f5618bed.diff

LOG: Add clang_CXXMethod_isMoveAssignmentOperator to libclang

The new method is a wrapper of `CXXMethodDecl::isMoveAssignmentOperator` and
can be used to recognized move-assignment operators in libclang.

An export for the function, together with its documentation, was added to
"clang/include/clang-c/Index.h" with an implementation provided in
"clang/tools/libclang/CIndex.cpp". The implementation was based on
similar `clang_CXXMethod.*` implementations, following the same
structure but calling `CXXMethodDecl::isMoveAssignmentOperator` for its
main logic.

The new symbol was further added to "clang/tools/libclang/libclang.map"
to be exported, under the LLVM16 tag.

"clang/tools/c-index-test/c-index-test.c" was modified to print a
specific tag, "(move-assignment operator)", for cursors that are
recognized by `clang_CXXMethod_isMoveAssignmentOperator`.
A new regression test file,
"clang/test/Index/move-assignment-operator.cpp", was added to ensure
whether the correct constructs were recognized or not by the new function.

The "clang/test/Index/get-cursor.cpp" regression test file was updated
as it was affected by the new "(move-assignment operator)" tag.

A binding for the new function was added to libclang's python's
bindings, in "clang/bindings/python/clang/cindex.py", adding a new
method for `Cursor`, `is_move_assignment_operator_method`.
An accompanying test was added to
`clang/bindings/python/tests/cindex/test_cursor.py`, testing the new
function with the same methodology as the corresponding libclang test.

The current release note, `clang/docs/ReleaseNotes.rst`, was modified to
report the new addition under the "libclang" section.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D137246

Added: 
clang/test/Index/move-assignment-operator.cpp

Modified: 
clang/bindings/python/clang/cindex.py
clang/bindings/python/tests/cindex/test_cursor.py
clang/docs/ReleaseNotes.rst
clang/include/clang-c/Index.h
clang/test/Index/get-cursor.cpp
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.map

Removed: 




diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 99dcbb341dfe..2e32ce2ba6d0 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1504,6 +1504,31 @@ class Bar {
 """
 return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self)
 
+def is_move_assignment_operator_method(self):
+"""Returnrs True if the cursor refers to a move-assignment operator.
+
+A move-assignment operator `X::operator=` is a non-static,
+non-template member function of _class_ `X` with exactly one
+parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
+volatile X&&`.
+
+
+That is, for example, the `operator=` in:
+
+   class Foo {
+   bool operator=(const volatile Foo&&);
+   };
+
+Is a move-assignment operator, while the `operator=` in:
+
+   class Bar {
+   bool operator=(const int&&);
+   };
+
+Is not.
+"""
+return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self)
+
 def is_mutable_field(self):
 """Returns True if the cursor refers to a C++ field that is declared
 'mutable'.
@@ -3465,6 +3490,10 @@ def cursor(self):
[Cursor],
bool),
 
+  ("clang_CXXMethod_isMoveAssignmentOperator",
+   [Cursor],
+   bool),
+
   ("clang_CXXMethod_isPureVirtual",
[Cursor],
bool),

diff  --git a/clang/bindings/python/tests/cindex/test_cursor.py 
b/clang/bindings/python/tests/cindex/test_cursor.py
index ef875e972474..198352080c69 100644
--- a/clang/bindings/python/tests/cindex/test_cursor.py
+++ b/clang/bindings/python/tests/cindex/test_cursor.py
@@ -219,6 +219,64 @@ def test_is_default_method(self):
 self.assertTrue(xc.is_default_method())
 self.assertFalse(yc.is_default_method())
 
+def test_is_move_assignment_operator_method(self):
+"""Ensure Cursor.is_move_assignment_operator_method works."""
+source_with_move_assignment_operators = """
+struct Foo {
+   // Those are move-assignment operators
+   bool operator=(const Foo&&);
+   bool operator=(Foo&&);
+   bool operator=(volatile Foo&&);
+   bool operator=(const volatile Foo&&);
+
+// Positive-check that the recognition works for templated classes too
+template 
+class Bar {
+bool operator=(const Bar&&)

[PATCH] D137246: Add clang_CXXMethod_isMoveAssignmentOperator to libclang

2022-11-14 Thread Luca Di sera via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c67cf0a7fdc: Add clang_CXXMethod_isMoveAssignmentOperator 
to libclang (authored by diseraluca).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137246/new/

https://reviews.llvm.org/D137246

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/test/Index/get-cursor.cpp
  clang/test/Index/move-assignment-operator.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/libclang.map

Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -411,6 +411,7 @@
 clang_getNonReferenceType;
 clang_CXXMethod_isDeleted;
 clang_CXXMethod_isCopyAssignmentOperator;
+clang_CXXMethod_isMoveAssignmentOperator;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8917,6 +8917,17 @@
   return (Method && Method->isCopyAssignmentOperator()) ? 1 : 0;
 }
 
+unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXMethodDecl *Method =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+
+  return (Method && Method->isMoveAssignmentOperator()) ? 1 : 0;
+}
+
 unsigned clang_CXXRecord_isAbstract(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -912,6 +912,8 @@
   printf(" (pure)");
 if (clang_CXXMethod_isCopyAssignmentOperator(Cursor))
   printf(" (copy-assignment operator)");
+if (clang_CXXMethod_isMoveAssignmentOperator(Cursor))
+  printf(" (move-assignment operator)");
 if (clang_CXXRecord_isAbstract(Cursor))
   printf(" (abstract)");
 if (clang_EnumDecl_isScoped(Cursor))
Index: clang/test/Index/move-assignment-operator.cpp
===
--- /dev/null
+++ clang/test/Index/move-assignment-operator.cpp
@@ -0,0 +1,45 @@
+struct Foo {
+// Those are move-assignment operators
+bool operator=(const Foo&&);
+bool operator=(Foo&&);
+bool operator=(volatile Foo&&);
+bool operator=(const volatile Foo&&);
+
+// Those are not move-assignment operators
+template
+bool operator=(const T&&);
+bool operator=(const bool&&);
+bool operator=(char&&);
+bool operator=(volatile unsigned int&&);
+bool operator=(const volatile unsigned char&&);
+bool operator=(int);
+bool operator=(Foo);
+};
+
+// Positive-check that the recognition works for templated classes too
+template 
+class Bar {
+bool operator=(const Bar&&);
+bool operator=(Bar&&);
+bool operator=(volatile Bar&&);
+bool operator=(const volatile Bar&&);
+};
+
+// RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
+// CHECK: StructDecl=Foo:1:8 (Definition) [type=Foo] [typekind=Record] [isPOD=0]
+// CHECK: CXXMethod=operator=:3:10 (move-assignment operator) [type=bool (const Foo &&)] [typekind=FunctionProto] [canonicaltype=bool (const Foo &&)] [canonicaltypekind=FunctionProto] [resulttype=bool] [resulttypekind=Bool] [args= [const Foo &&] [RValueReference]] [isPOD=0] [isAnonRecDecl=0]
+// CHECK: CXXMethod=operator=:4:10 (move-assignment operator) [type=bool (Foo &&)] [typekind=FunctionProto] [canonicaltype=bool (Foo &&)] [canonicaltypekind=FunctionProto] [resulttype=bool] [resulttypekind=Bool] [args= [Foo &&] [RValueReference]] [isPOD=0] [isAnonRecDecl=0]
+// CHECK: CXXMethod=operator=:5:10 (move-assignment operator) [type=bool (volatile Foo &&)] [typekind=FunctionProto] [canonicaltype=bool (volatile Foo &&)] [canonicaltypekind=FunctionProto] [resulttype=bool] [resulttypekind=Bool] [args= [volatile Foo &&] [RValueReference]] [isPOD=0] [isAnonRecDecl=0]
+// CHECK: CXXMethod=operator=:6:10 (move-assignment operator) [type=bool (const volatile Foo &&)] [typekind=FunctionProto] [canonicaltype=bool (const volatile Foo &&)] [canonicaltypekind=FunctionProto] [resulttype=bool] [resulttypekind=Bool] [args= [const volatile Foo &&] [RValueReference]] [isPOD=0] [isAnonRecDecl=0]
+// CHECK: FunctionTemplate=operator=:10:10 [type=bool (const T &&)] [typekind=FunctionProto] [canonicaltype=bool (const type-parameter-0-0 &&)] [canonicaltypekind=FunctionProto] [resulttype=bool] [resulttypekind=B

[PATCH] D137246: Add clang_CXXMethod_isMoveAssignmentOperator to libclang

2022-11-14 Thread Luca Di sera via Phabricator via cfe-commits
diseraluca added a comment.

In D137246#3919795 , @aaron.ballman 
wrote:

> In D137246#3911881 , @diseraluca 
> wrote:
>
>> I finally had some time to look into the pre-merge failure. I couldn't 
>> replicate it on my machine by following 
>> https://buildkite.com/llvm-project/premerge-checks/builds/119952#01843856-e8c7-4709-89c6-d52d0286862a
>>  .
>>
>> Looking at the log it does not seem related to the patch, I think it might 
>> be a flaky failing.
>> Is there a way to rerun the pre-merge checks?
>
> Yeah, that looks like a flaky test. You can restart CI by clicking the 
> "Restart Build" link on the Harbormaster instance, I believe 
> (https://reviews.llvm.org/harbormaster/build/296625/). If all else fails, you 
> can usually rebase the patch on main and upload the new patch.
>
> LGTM!

Thank you for the explanation! I've landed this one as it seemed safe enough 
and testing locally brought nothing up. I'll be sure to be around to check if 
anything fails because of it, albeit I expect it will not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137246/new/

https://reviews.llvm.org/D137246

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

I think this looks OK.  What kind of errors were you seeing before this fix?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2022-11-14 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz created this revision.
sgraenitz added reviewers: gottesmm, rjmccall, rnk.
Herald added a subscriber: hiraditya.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

When optimizing retain-release-sequences we insert (and delete) ObjC runtime 
calls. These calls need a funclet operand bundle that refers to the enclosing 
funclet pad whenever they are inserted in a WinEH funclet. WinEH funclets can 
contain multiple basic blocks. In order to find the enclosing funclet pad, we 
have to calculate the funclet coloring first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137944

Files:
  clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/test/Transforms/ObjCARC/funclet-catchpad.ll

Index: llvm/test/Transforms/ObjCARC/funclet-catchpad.ll
===
--- /dev/null
+++ llvm/test/Transforms/ObjCARC/funclet-catchpad.ll
@@ -0,0 +1,40 @@
+; RUN: opt -mtriple=x86_64-windows-msvc -passes=objc-arc -S < %s | FileCheck %s
+
+; Check that funclet tokens are preserved
+;
+; CHECK-LABEL:  catch:
+; CHECK:  %1 = catchpad within %0
+; CHECK:  %2 = tail call ptr @llvm.objc.retain(ptr %exn) #0 [ "funclet"(token %1) ]
+; CHECK:  call void @llvm.objc.release(ptr %exn) #0 [ "funclet"(token %1) ]
+; CHECK:  catchret from %1 to label %eh.cont
+
+define void @try_catch_with_objc_intrinsic() personality ptr @__CxxFrameHandler3 {
+entry:
+  %exn.slot = alloca ptr, align 8
+  invoke void @may_throw(ptr null) to label %eh.cont unwind label %catch.dispatch
+
+catch.dispatch:   ; preds = %entry
+  %0 = catchswitch within none [label %catch] unwind to caller
+
+eh.cont:  ; preds = %catch, %entry
+  ret void
+
+catch:; preds = %catch.dispatch
+  %1 = catchpad within %0 [ptr null, i32 0, ptr %exn.slot]
+  br label %if.then
+
+if.then:  ; preds = %catch
+  %exn = load ptr, ptr null, align 8
+  %2 = call ptr @llvm.objc.retain(ptr %exn) [ "funclet"(token %1) ]
+  call void @may_throw(ptr %exn)
+  call void @llvm.objc.release(ptr %exn) [ "funclet"(token %1) ]
+  catchret from %1 to label %eh.cont
+}
+
+declare void @may_throw(ptr)
+declare i32 @__CxxFrameHandler3(...)
+
+declare ptr @llvm.objc.retain(ptr) #0
+declare void @llvm.objc.release(ptr) #0
+
+attributes #0 = { nounwind }
Index: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
===
--- llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -546,7 +546,9 @@
   void MoveCalls(Value *Arg, RRInfo &RetainsToMove, RRInfo &ReleasesToMove,
  BlotMapVector &Retains,
  DenseMap &Releases,
- SmallVectorImpl &DeadInsts, Module *M);
+ SmallVectorImpl &DeadInsts,
+ const DenseMap &BlockColors,
+ Module *M);
 
   bool PairUpRetainsAndReleases(DenseMap &BBStates,
 BlotMapVector &Retains,
@@ -559,7 +561,7 @@
 
   bool PerformCodePlacement(DenseMap &BBStates,
 BlotMapVector &Retains,
-DenseMap &Releases, Module *M);
+DenseMap &Releases, Function &F);
 
   void OptimizeWeakCalls(Function &F);
 
@@ -756,6 +758,18 @@
 
   return CallInst::Create(&CI, OpBundles);
 }
+
+void addOpBundleForFunclet(BasicBlock *BB,
+   const DenseMap &BlockColors,
+   SmallVectorImpl &OpBundles) {
+  if (!BlockColors.empty()) {
+const ColorVector &CV = BlockColors.find(BB)->second;
+assert(CV.size() == 1 && "non-unique color for block!");
+BasicBlock *EHPadBB = CV.front();
+if (auto *EHPad = dyn_cast(EHPadBB->getFirstNonPHI()))
+  OpBundles.emplace_back("funclet", EHPad);
+  }
+}
 }
 
 /// Visit each call, one at a time, and make simplifications without doing any
@@ -1757,12 +1771,12 @@
 }
 
 /// Move the calls in RetainsToMove and ReleasesToMove.
-void ObjCARCOpt::MoveCalls(Value *Arg, RRInfo &RetainsToMove,
-   RRInfo &ReleasesToMove,
-   BlotMapVector &Retains,
-   DenseMap &Releases,
-   SmallVectorImpl &DeadInsts,
-   Module *M) {
+void ObjCARCOpt::MoveCalls(
+Value *Arg, RRInfo &RetainsToMove, RRInfo &ReleasesToMove,
+BlotMapVector &Retains,
+DenseMap &Releases,
+SmallVectorImpl &DeadInsts,
+const DenseMap &BlockColors, Module *M) {
   Type *ArgTy = Arg->getType();
   Type *ParamTy = PointerType::getUnqual(Type::getInt8Ty(ArgTy->getContext()));
 
@@ -1773,7 +1787,9 @@
 Value *MyArg = ArgTy == ParamTy 

[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2022-11-14 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

There was a similar effort for CleanupPads in the past: 
https://reviews.llvm.org/rG8b342680bf62722e5099074e8bd23491c71d92b3


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137944/new/

https://reviews.llvm.org/D137944

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2022-11-14 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

There doesn't seem to be a 1-to-1 relationship between deleted and inserted 
retain/release calls and thus we don't attempt to preserve bundle operands in 
general.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137944/new/

https://reviews.llvm.org/D137944

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

I only came across it when testing a PCH build.
https://github.com/Trass3r/llvm-project/actions/runs/3423679621/jobs/5702548183

  Warning: (1,9): warning: definition of macro '_GNU_SOURCE' does not 
match definition in precompiled header [-Wclang-cl-pch]

It was set for clang but not for llvm when building with clang-cl.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-14 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D137787#3924727 , @Hahnfeld wrote:

> Yes, I fully agree that having a test is desirable, I just didn't manage so 
> far. Maybe it takes somebody with deep AST knowledge to explain under what 
> circumstances `DtorDecl->getParent()` is *not* the canonical `Decl`. Maybe 
> this could help crafting a test case, even outside of modules maybe

Modules can be "activated" at a random point of the translation unit. This 
would have influence of which `Decl*` becomes the canonical declaration as this 
is usually the first seen declaration. We have seen such issues over time with 
the modules system where depending on time when we load the module; the version 
of the standard library; the modulemap organization, etc. I am inclined to say 
this change somewhat makes sense to me as it seems somewhat consistent with 
what we've seen over the years but there are several questions I'd like to ask:

- Is the failure also not reproducible with clang9 (on which is based cling)?
- Is the failure also not reproducible with clang9 built on top of the 
downstream patches?

I believe if you can reduce the headers further it would make it easier to 
figure out in which context this assertion needs to be relaxed. Sorry for not 
being very helpful here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137787/new/

https://reviews.llvm.org/D137787

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-14 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: rsmith.
v.g.vassilev added a comment.

Usually @rsmith has something up in the sleeve in these situations ;)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137787/new/

https://reviews.llvm.org/D137787

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137948: [clang][dataflow] Add widening API and implement it for built-in boolean model.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, gribozavr2, sgatev.
Herald added subscribers: martong, rnkovacs.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

- Adds API support for widening of lattice elements and environments,
- Updates the algorithm to apply widening where appropriate,
- Implements widening for boolean values. In the process, moves the unsoundness 
of comparison from the default implementation of 
`Environment::ValueModel::compare` to model-specific handling inside 
`DataflowEnvironment::equivalentTo`. This change is intended to clarify the 
source and location of unsoundess.

This patch is a replacement for, and was based substantially on, 
https://reviews.llvm.org/D131645.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137948

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -9,7 +9,6 @@
 #include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
@@ -63,7 +62,7 @@
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  bool ApplyBuiltinTransfer = true,
  llvm::StringRef TargetFun = "target") {
-  runDataflow(Code, Match,
+  runDataflow(Code, std::move(Match),
   {ApplyBuiltinTransfer ? TransferOptions{}
 : llvm::Optional()},
   Std, TargetFun);
@@ -3255,8 +3254,7 @@
 
 TEST(TransferTest, LoopWithAssignmentConverges) {
   std::string Code = R"(
-
-bool &foo();
+bool foo();
 
 void target() {
do {
@@ -3285,9 +3283,45 @@
   });
 }
 
-TEST(TransferTest, LoopWithReferenceAssignmentConverges) {
+TEST(TransferTest, LoopWithStagedAssignments) {
   std::string Code = R"(
+bool foo();
+
+void target() {
+  bool Bar = false;
+  bool Err = false;
+  while (foo()) {
+if (Bar)
+  Err = true;
+Bar = true;
+/*[[p]]*/
+  }
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+const ValueDecl *ErrDecl = findValueDecl(ASTCtx, "Err");
+ASSERT_THAT(ErrDecl, NotNull());
+
+auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None));
+auto &ErrVal = *cast(Env.getValue(*ErrDecl, SkipPast::None));
+EXPECT_TRUE(Env.flowConditionImplies(BarVal));
+// An unsound analysis, for example only evaluating the loop once, can
+// conclude that `Err` is false. So, we test that this conclusion is not
+// reached.
+EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(ErrVal)));
+  });
+}
 
+TEST(TransferTest, LoopWithReferenceAssignmentConverges) {
+  std::string Code = R"(
 bool &foo();
 
 void target() {
@@ -3299,9 +,8 @@
   } while (true);
 }
   )";
-  // The key property that we are verifying is implicit in `runDataflow` --
-  // namely, that the analysis succeeds, rather than hitting the maximum number
-  // of iterations.
+  // The key property that we are verifying is that the analysis succeeds,
+  // rather than hitting the maximum number of iterations.
   runDataflow(
   Code,
   [](const llvm::StringMap> &Results,
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -23,6 +23,7 @@
 #include "clang/Analysis/Analyses/PostOrderCFGView.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
+#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
 #include "clang/Analysis/FlowSensitive/Transfer.h

[PATCH] D137768: [opt][clang] Enable using -module-summary /-flto=thin with -S / -emit-llvm

2022-11-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm, thanks! One small suggestion below.




Comment at: clang/lib/CodeGen/BackendUtil.cpp:988
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);

I'd go ahead and move this extra file emission under the EmitBC case, since it 
is also a BC file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137768/new/

https://reviews.llvm.org/D137768

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In D137787#3924857 , @v.g.vassilev 
wrote:

> - Is the failure also not reproducible with clang9 (on which is based cling)?
> - Is the failure also not reproducible with clang9 built on top of the 
> downstream patches?

The failure *only* happens with downstream llvm13 (not with clang9) on exactly 
one test for exactly one version of libstdc++. However, all attempts to 
reproduce it with clang13 + our downstream patches have failed so far...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137787/new/

https://reviews.llvm.org/D137787

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137874: clang/AMDGPU: Use Support's wrapper around getenv

2022-11-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137874/new/

https://reviews.llvm.org/D137874

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-14 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 475164.
gedare added a comment.

- fixup: replace EXPECT_EQ with verifyFormat
- fixup: port other EXPECT_EQ to verifyFormat


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137762/new/

https://reviews.llvm.org/D137762

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7210,53 +7210,59 @@
   // Check that AllowAllArgumentsOnNextLine is respected for both BAS_DontAlign
   // and BAS_Align.
   FormatStyle Style = getLLVMStyleWithColumns(35);
-  StringRef Input = "functionCall(paramA, paramB, paramC);\n"
-"void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
+  verifyFormat("functionCall(paramA, paramB,\n"
   "paramC);\n"
   "void functionDecl(int A, int B,\n"
-  "int C);"),
-format(Input, Style));
+  "int C);",
+   Style);
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
+  verifyFormat("functionCall(paramA, paramB,\n"
   " paramC);\n"
   "void functionDecl(int A, int B,\n"
-  "  int C);"),
-format(Input, Style));
-  // However, BAS_AlwaysBreak should take precedence over
+  "  int C);",
+   Style);
+  // However, BAS_AlwaysBreak and BAS_BlockIndent should take precedence over
   // AllowAllArgumentsOnNextLine.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  EXPECT_EQ(StringRef("functionCall(\n"
+  verifyFormat("functionCall(\n"
   "paramA, paramB, paramC);\n"
   "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  "int A, int B, int C);",
+   Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  verifyFormat("functionCall(\n"
+  "paramA, paramB, paramC\n"
+  ");\n"
+  "void functionDecl(\n"
+  "int A, int B, int C\n"
+  ");",
+   Style);
 
   // When AllowAllArgumentsOnNextLine is set, we prefer breaking before the
   // first argument.
   Style.AllowAllArgumentsOnNextLine = true;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  EXPECT_EQ(StringRef("functionCall(\n"
+  verifyFormat("functionCall(\n"
   "paramA, paramB, paramC);\n"
   "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  "int A, int B, int C);",
+   Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
+  verifyFormat("functionCall(paramA, paramB,\n"
   " paramC);\n"
   "void functionDecl(int A, int B,\n"
-  "  int C);"),
-format(Input, Style));
+  "  int C);",
+   Style);
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(\n"
+  verifyFormat("functionCall(\n"
   "paramA, paramB, paramC);\n"
   "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  "int A, int B, int C);",
+   Style);
 }
 
 TEST_F(FormatTest, BreakBeforeInlineASMColon) {
@@ -8435,6 +8441,54 @@
   "(a, )) &&\n"
   ");",
   Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat("void aa(\n"
+   "aaa ,\n"
+   "a aaa,\n"
+   "a\n"
+   ") {}",
+   Style);
+  verifyFormat("SomeLongVariableName->someVeryLongFunctionName(\n"
+   "aaa a,\n"
+   "aaa aa

[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-14 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 475165.
gedare added a comment.

- fixup: unit test formatting


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137762/new/

https://reviews.llvm.org/D137762

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7210,53 +7210,59 @@
   // Check that AllowAllArgumentsOnNextLine is respected for both BAS_DontAlign
   // and BAS_Align.
   FormatStyle Style = getLLVMStyleWithColumns(35);
-  StringRef Input = "functionCall(paramA, paramB, paramC);\n"
-"void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  "paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   "paramC);\n"
+   "void functionDecl(int A, int B,\n"
+   "int C);",
+   Style);
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  " paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "  int C);"),
-format(Input, Style));
-  // However, BAS_AlwaysBreak should take precedence over
+  verifyFormat("functionCall(paramA, paramB,\n"
+   " paramC);\n"
+   "void functionDecl(int A, int B,\n"
+   "  int C);",
+   Style);
+  // However, BAS_AlwaysBreak and BAS_BlockIndent should take precedence over
   // AllowAllArgumentsOnNextLine.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  EXPECT_EQ(StringRef("functionCall(\n"
-  "paramA, paramB, paramC);\n"
-  "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC);\n"
+   "void functionDecl(\n"
+   "int A, int B, int C);",
+   Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC\n"
+   ");\n"
+   "void functionDecl(\n"
+   "int A, int B, int C\n"
+   ");",
+   Style);
 
   // When AllowAllArgumentsOnNextLine is set, we prefer breaking before the
   // first argument.
   Style.AllowAllArgumentsOnNextLine = true;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  EXPECT_EQ(StringRef("functionCall(\n"
-  "paramA, paramB, paramC);\n"
-  "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC);\n"
+   "void functionDecl(\n"
+   "int A, int B, int C);",
+   Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  " paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "  int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   " paramC);\n"
+   "void functionDecl(int A, int B,\n"
+   "  int C);",
+   Style);
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(\n"
-  "paramA, paramB, paramC);\n"
-  "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC);\n"
+   "void functionDecl(\n"
+   "int A, int B, int C);",
+   Style);
 }
 
 TEST_F(FormatTest, BreakBeforeInlineASMColon) {
@@ -8435,6 +8441,52 @@
   "(a, )) &&\n"
   ");",
   Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat("void a

[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

Thanks could you also commit it?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137269: [Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms.

2022-11-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Heads-up: This very visibly broke web page rendering in Chromium (but only when 
using LTO) (https://crbug.com/1383873) . Not clear yet if this exposed UB on 
our end or not.

One thing that we did notice is that adding `-fno-global-isel` to cflags and 
ldflags only had an effect when manually blowing away the thinlto cache. Maybe 
whatever decides when to invalidate the thinlto cache needs to learn to 
invalidate it when the `-global-isel` flag changes?




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7218-7219
+  CmdArgs.push_back("-global-isel=1");
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-global-isel-abort=0");
+}

aemerson wrote:
> arsenm wrote:
> > Why abort=0? I can understand abort=1 or 2
> Abort=1 would mean the compiler crashes on fallback, and `2` would mean we 
> emit diagnostics, neither of which we want for an on-by-default configuration.
Any reason why we pass different flags to ld's LTO than to cc1?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137269/new/

https://reviews.llvm.org/D137269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 780c539 - [RISCV] Implement assembler support for XVentanaCondOps

2022-11-14 Thread Philip Reames via cfe-commits

Author: Philip Reames
Date: 2022-11-14T09:01:54-08:00
New Revision: 780c53984449e14f50e2418de993bbf560f54bfc

URL: 
https://github.com/llvm/llvm-project/commit/780c53984449e14f50e2418de993bbf560f54bfc
DIFF: 
https://github.com/llvm/llvm-project/commit/780c53984449e14f50e2418de993bbf560f54bfc.diff

LOG: [RISCV] Implement assembler support for XVentanaCondOps

This change provides an implementation of the XVentanaCondOps vendor extension. 
This extension is defined in version 1.0.0 of the VTx-family custom 
instructions specification 
(https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdf)
 by Ventana Micro Systems.

In addition to the technical contribution, this change is intended to be a test 
case for our vendor extension policy.

Once this lands, I plan to use this extension to prototype selection lowering 
to conditional moves. There's an RVI proposal in flight, and the expectation is 
that lowering to these and the new RVI instructions is likely to be 
substantially similar.

Differential Revision: https://reviews.llvm.org/D137350

Added: 
llvm/lib/Target/RISCV/RISCVInstrInfoXVentana.td
llvm/test/MC/RISCV/XVentanaCondOps-valid.s

Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVSubtarget.h
llvm/test/CodeGen/RISCV/attributes.ll

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 2d4aed24002e0..5d43b3f520ba9 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -41,6 +41,7 @@
 // CHECK-NOT: __riscv_zicboz
 // CHECK-NOT: __riscv_svnapot
 // CHECK-NOT: __riscv_svinval
+// CHECK-NOT: __riscv_xventanacondops
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
@@ -432,3 +433,7 @@
 // RUN: %clang -target riscv64 -march=rv64isvinval -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SVINVAL-EXT %s
 // CHECK-SVINVAL-EXT: __riscv_svinval 100{{$}}
+
+// RUN: %clang -target riscv64 -march=rv64ixventanacondops -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-XVENTANACONDOPS-EXT %s
+// CHECK-XVENTANACONDOPS-EXT: __riscv_xventanacondops 100{{$}}

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 6506d750b8748..aa39935153973 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -149,14 +149,17 @@ To use an experimental extension from `clang`, you must 
add `-menable-experiment
 Vendor Extensions
 =
 
-Vendor extensions are extensions which are not standardized by RISC-V 
International, and are instead defined by a hardware vendor.  At the moment, 
LLVM does not support any vendor extensions for RISC-V, but we expect this to 
change in the future.
-
-The term vendor extension roughly parallels the definition of a `non-standard` 
extension from Section 1.3 of the Volume I: RISC-V Unprivileged ISA 
specification.  In particular, we expect to eventually accept both `custom` 
extensions and `non-conforming` extensions.
+Vendor extensions are extensions which are not standardized by RISC-V 
International, and are instead defined by a hardware vendor.  The term vendor 
extension roughly parallels the definition of a `non-standard` extension from 
Section 1.3 of the Volume I: RISC-V Unprivileged ISA specification.  In 
particular, we expect to eventually accept both `custom` extensions and 
`non-conforming` extensions.
 
 Inclusion of a vendor extension will be considered on a case by case basis.  
All proposals should be brought to the bi-weekly RISCV sync calls for 
discussion.  For a general idea of the factors likely to be considered, please 
see the `Clang documentation `_.
 
 It is our intention to follow the naming conventions described in 
`riscv-non-isa/riscv-toolchain-conventions 
`_.
  Exceptions to this naming will need to be strongly motivated.
 
+The current vendor extensions supported are:
+
+``XVentanaCondOps``
+  LLVM implements `version 1.0.0 of the VTx-family custom instructions 
specification 
`_
 by Ventana Micro Systems.  All instructions are prefixed with `vt.` as 
described in the specification, and the riscv-toolchai-convention document 
linked above.  These instructions are only available for riscv64 at this time.
+
 
 S

[PATCH] D137350: [RISCV] Implement assembler support for XVentanaCondOps

2022-11-14 Thread Philip Reames via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG780c53984449: [RISCV] Implement assembler support for 
XVentanaCondOps (authored by reames).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137350/new/

https://reviews.llvm.org/D137350

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoXVentana.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/XVentanaCondOps-valid.s

Index: llvm/test/MC/RISCV/XVentanaCondOps-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/XVentanaCondOps-valid.s
@@ -0,0 +1,22 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+xventanacondops -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+xventanacondops < %s \
+# RUN: | llvm-objdump --mattr=+xventanacondops -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: vt.maskc zero, zero, zero
+# CHECK-ASM: encoding: [0x7b,0x60,0x00,0x00]
+vt.maskc x0, x0, x0
+
+# CHECK-ASM-AND-OBJ: vt.maskcn zero, zero, zero
+# CHECK-ASM: encoding: [0x7b,0x70,0x00,0x00]
+vt.maskcn x0, x0, x0
+
+# CHECK-ASM-AND-OBJ: vt.maskc ra, sp, gp
+# CHECK-ASM: encoding: [0xfb,0x60,0x31,0x00]
+vt.maskc x1, x2, x3
+
+# CHECK-ASM-AND-OBJ: vt.maskcn ra, sp, gp
+# CHECK-ASM: encoding: [0xfb,0x70,0x31,0x00]
+vt.maskcn x1, x2, x3
+
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -76,6 +76,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zicbop %s -o - | FileCheck --check-prefix=RV64ZICBOP %s
 ; RUN: llc -mtriple=riscv64 -mattr=+svnapot %s -o - | FileCheck --check-prefix=RV64SVNAPOT %s
 ; RUN: llc -mtriple=riscv64 -mattr=+svinval %s -o - | FileCheck --check-prefix=RV64SVINVAL %s
+; RUN: llc -mtriple=riscv64 -mattr=+xventanacondops %s -o - | FileCheck --check-prefix=RV64XVENTANACONDOPS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zawrs %s -o - | FileCheck --check-prefix=RV64ZAWRS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-ztso %s -o - | FileCheck --check-prefix=RV64ZTSO %s
 
@@ -157,6 +158,7 @@
 ; RV64ZICBOP: .attribute 5, "rv64i2p0_zicbop1p0"
 ; RV64SVNAPOT: .attribute 5, "rv64i2p0_svnapot1p0"
 ; RV64SVINVAL: .attribute 5, "rv64i2p0_svinval1p0"
+; RV64XVENTANACONDOPS: .attribute 5, "rv64i2p0_xventanacondops1p0"
 ; RV64ZTSO: .attribute 5, "rv64i2p0_ztso0p1"
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/RISCVSubtarget.h
===
--- llvm/lib/Target/RISCV/RISCVSubtarget.h
+++ llvm/lib/Target/RISCV/RISCVSubtarget.h
@@ -90,6 +90,7 @@
   bool HasStdExtZmmul = false;
   bool HasStdExtZawrs = false;
   bool HasStdExtZtso = false;
+  bool HasVendorXVentanaCondOps = false;
   bool HasRV32 = false;
   bool HasRV64 = false;
   bool IsRV32E = false;
@@ -190,6 +191,7 @@
   bool hasStdExtZawrs() const { return HasStdExtZawrs; }
   bool hasStdExtZmmul() const { return HasStdExtZmmul; }
   bool hasStdExtZtso() const { return HasStdExtZtso; }
+  bool hasVendorXVentanaCondOps() const { return HasVendorXVentanaCondOps; }
   bool is64Bit() const { return HasRV64; }
   bool isRV32E() const { return IsRV32E; }
   bool enableLinkerRelax() const { return EnableLinkerRelax; }
Index: llvm/lib/Target/RISCV/RISCVInstrInfoXVentana.td
===
--- /dev/null
+++ llvm/lib/Target/RISCV/RISCVInstrInfoXVentana.td
@@ -0,0 +1,29 @@
+//===-- RISCVInstrInfoXVentana.td --*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the vendor extensions defined by Ventana Micro Systems.
+//
+//===--===//
+
+//===--===//
+// XVentanaCondOps
+//===--===//
+
+let Predicates = [IsRV64, HasVendorXVentanaCondOps], hasSideEffects = 0,
+  mayLoad = 0, mayStore = 0, isCodeGenOnly = 0, DecoderNamespace = "Ventana" in
+class VTMaskedMove funct3, string opcodestr>
+: RVInstR<0b

[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D137917#3925161 , @Trass3r wrote:

> Thanks could you also commit it?

Sure, what name and email should I use for you when committing?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124823: [OpenMPIRBuilder] Introduce OMPRegionInfo managing the stack of OpenMP region constructs.

2022-11-14 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: dcaballe.
Herald added subscribers: Moerafaat, zero9178.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124823/new/

https://reviews.llvm.org/D124823

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 87f652d - Migrate getOrCreateInternalVariable from Clang to OMPIRBuilder.

2022-11-14 Thread Akash Banerjee via cfe-commits

Author: Akash Banerjee
Date: 2022-11-14T17:18:10Z
New Revision: 87f652d31f6dcb493e4e3290d694e52c092cecb1

URL: 
https://github.com/llvm/llvm-project/commit/87f652d31f6dcb493e4e3290d694e52c092cecb1
DIFF: 
https://github.com/llvm/llvm-project/commit/87f652d31f6dcb493e4e3290d694e52c092cecb1.diff

LOG: Migrate getOrCreateInternalVariable from Clang to OMPIRBuilder.

This patch removes getOrCreateInternalVariable from Clang OMP CodeGen and 
replaces it's uses with OMPBuilder::getOrCreateInternalVariable. Also refactors 
OMPBuilder::getOrCreateInternalVariable to change type of name from Twine to 
StringRef

Differential Revision: https://reviews.llvm.org/D137720

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b87e69b641a63..4d226bbacb98f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1644,7 +1644,7 @@ Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const 
VarDecl *VD) {
 QualType PtrTy = CGM.getContext().getPointerType(VD->getType());
 llvm::Type *LlvmPtrTy = CGM.getTypes().ConvertTypeForMem(PtrTy);
 if (!Ptr) {
-  Ptr = getOrCreateInternalVariable(LlvmPtrTy, PtrName);
+  Ptr = OMPBuilder.getOrCreateInternalVariable(LlvmPtrTy, PtrName);
 
   auto *GV = cast(Ptr);
   GV->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
@@ -1664,8 +1664,8 @@ CGOpenMPRuntime::getOrCreateThreadPrivateCache(const 
VarDecl *VD) {
  !CGM.getContext().getTargetInfo().isTLSSupported());
   // Lookup the entry, lazily creating it if necessary.
   std::string Suffix = getName({"cache", ""});
-  return getOrCreateInternalVariable(
-  CGM.Int8PtrPtrTy, Twine(CGM.getMangledName(VD)).concat(Suffix));
+  return OMPBuilder.getOrCreateInternalVariable(
+  CGM.Int8PtrPtrTy, Twine(CGM.getMangledName(VD)).concat(Suffix).str());
 }
 
 Address CGOpenMPRuntime::getAddrOfThreadPrivate(CodeGenFunction &CGF,
@@ -1969,8 +1969,8 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   StringRef Name) {
   std::string Suffix = getName({"artificial", ""});
   llvm::Type *VarLVType = CGF.ConvertTypeForMem(VarType);
-  llvm::GlobalVariable *GAddr =
-  getOrCreateInternalVariable(VarLVType, Twine(Name).concat(Suffix));
+  llvm::GlobalVariable *GAddr = OMPBuilder.getOrCreateInternalVariable(
+  VarLVType, Twine(Name).concat(Suffix).str());
   if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
   CGM.getTarget().isTLSSupported()) {
 GAddr->setThreadLocal(/*Val=*/true);
@@ -1984,8 +1984,9 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(GAddr, CGM.VoidPtrTy),
   CGF.Builder.CreateIntCast(CGF.getTypeSize(VarType), CGM.SizeTy,
 /*isSigned=*/false),
-  getOrCreateInternalVariable(
-  CGM.VoidPtrPtrTy, Twine(Name).concat(Suffix).concat(CacheSuffix))};
+  OMPBuilder.getOrCreateInternalVariable(
+  CGM.VoidPtrPtrTy,
+  Twine(Name).concat(Suffix).concat(CacheSuffix).str())};
   return Address(
   CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   CGF.EmitRuntimeCall(
@@ -2130,30 +2131,10 @@ Address 
CGOpenMPRuntime::emitThreadIDAddress(CodeGenFunction &CGF,
   return ThreadIDTemp;
 }
 
-llvm::GlobalVariable *CGOpenMPRuntime::getOrCreateInternalVariable(
-llvm::Type *Ty, const llvm::Twine &Name, unsigned AddressSpace) {
-  SmallString<256> Buffer;
-  llvm::raw_svector_ostream Out(Buffer);
-  Out << Name;
-  StringRef RuntimeName = Out.str();
-  auto &Elem = *InternalVars.try_emplace(RuntimeName, nullptr).first;
-  if (Elem.second) {
-assert(Elem.second->getType()->isOpaqueOrPointeeTypeMatches(Ty) &&
-   "OMP internal variable has 
diff erent type than requested");
-return &*Elem.second;
-  }
-
-  return Elem.second = new llvm::GlobalVariable(
- CGM.getModule(), Ty, /*IsConstant*/ false,
- llvm::GlobalValue::CommonLinkage, 
llvm::Constant::getNullValue(Ty),
- Elem.first(), /*InsertBefore=*/nullptr,
- llvm::GlobalValue::NotThreadLocal, AddressSpace);
-}
-
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  return OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
 }
 
 namespace {
@@ -10402,7 +10383,7 @@ void 
CGOpenMPRuntime::registerTargetGlobalVariab

[PATCH] D137720: Migrate getOrCreateInternalVariable from Clang to OMPIRBuilder.

2022-11-14 Thread Akash Banerjee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG87f652d31f6d: Migrate getOrCreateInternalVariable from Clang 
to OMPIRBuilder. (authored by TIFitis).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137720/new/

https://reviews.llvm.org/D137720

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3866,7 +3866,7 @@
   Value *Ident = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
   Value *ThreadId = getOrCreateThreadID(Ident);
   Constant *ThreadPrivateCache =
-  getOrCreateOMPInternalVariable(Int8PtrPtr, Name);
+  getOrCreateInternalVariable(Int8PtrPtr, Name.str());
   llvm::Value *Args[] = {Ident, ThreadId, Pointer, Size, ThreadPrivateCache};
 
   Function *Fn =
@@ -3963,18 +3963,10 @@
   return OS.str().str();
 }
 
-Constant *OpenMPIRBuilder::getOrCreateOMPInternalVariable(
-llvm::Type *Ty, const llvm::Twine &Name, unsigned AddressSpace) {
-  // TODO: Replace the twine arg with stringref to get rid of the conversion
-  // logic. However This is taken from current implementation in clang as is.
-  // Since this method is used in many places exclusively for OMP internal use
-  // we will keep it as is for temporarily until we move all users to the
-  // builder and then, if possible, fix it everywhere in one go.
-  SmallString<256> Buffer;
-  llvm::raw_svector_ostream Out(Buffer);
-  Out << Name;
-  StringRef RuntimeName = Out.str();
-  auto &Elem = *InternalVars.try_emplace(RuntimeName, nullptr).first;
+GlobalVariable *
+OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name,
+ unsigned AddressSpace) {
+  auto &Elem = *InternalVars.try_emplace(Name, nullptr).first;
   if (Elem.second) {
 assert(cast(Elem.second->getType())
->isOpaqueOrPointeeTypeMatches(Ty) &&
@@ -3984,20 +3976,19 @@
 // variable for possibly changing that to internal or private, or maybe
 // create different versions of the function for different OMP internal
 // variables.
-Elem.second = new llvm::GlobalVariable(
-M, Ty, /*IsConstant*/ false, llvm::GlobalValue::CommonLinkage,
-llvm::Constant::getNullValue(Ty), Elem.first(),
-/*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
-AddressSpace);
+Elem.second = new GlobalVariable(
+M, Ty, /*IsConstant=*/false, GlobalValue::CommonLinkage,
+Constant::getNullValue(Ty), Elem.first(),
+/*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal, AddressSpace);
   }
 
-  return Elem.second;
+  return cast(&*Elem.second);
 }
 
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
 }
 
 GlobalVariable *
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1462,15 +1462,6 @@
StringRef FirstSeparator,
StringRef Separator);
 
-  /// Gets (if variable with the given name already exist) or creates
-  /// internal global variable with the specified Name. The created variable has
-  /// linkage CommonLinkage by default and is initialized by null value.
-  /// \param Ty Type of the global variable. If it is exist already the type
-  /// must be the same.
-  /// \param Name Name of the variable.
-  Constant *getOrCreateOMPInternalVariable(Type *Ty, const Twine &Name,
-   unsigned AddressSpace = 0);
-
   /// Returns corresponding lock object for the specified critical region
   /// name. If the lock object does not exist it is created, otherwise the
   /// reference to the existing copy is returned.
@@ -1726,6 +1717,15 @@
   void
   loadOffloadInfoMetadata(Module &M,
   OffloadEntriesInfoManager &OffloadEntriesInfoManager);
+
+  /// Gets (if variable with the given name already exist) or creates
+  /// internal global variable with the specified Name. The created variable has
+  /// linkage CommonLinkage by default and is initialized by null value.
+  /// \param Ty Type of the global variable. If it is exist already the type
+  /// must be the same.
+  /// \param Name Name of the variable.
+  Gl

[PATCH] D137649: [Clang][OpenMP] Warn and discard write to host for const variable

2022-11-14 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LGTM, others feel free to comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137649/new/

https://reviews.llvm.org/D137649

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 475177.
jyu2 added a comment.

Thanks Alexey!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/error_ast_print.cpp
  clang/test/OpenMP/error_message.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -301,6 +301,9 @@
   let clangClass = "OMPAtomicDefaultMemOrderClause";
   let flangClass = "OmpAtomicDefaultMemOrderClause";
 }
+def OMPC_At : Clause<"at"> {
+  let clangClass = "OMPAtClause";
+}
 def OMPC_Allocate : Clause<"allocate"> {
   let clangClass = "OMPAllocateClause";
   let flangClass = "OmpAllocateClause";
@@ -527,7 +530,11 @@
 }
 def OMP_TaskYield : Directive<"taskyield"> {}
 def OMP_Barrier : Directive<"barrier"> {}
-def OMP_Error : Directive<"error"> {}
+def OMP_Error : Directive<"error"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+}
 def OMP_TaskWait : Directive<"taskwait"> {
   let allowedClauses = [
 VersionedClause
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1868,6 +1868,7 @@
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
+CHECK_SIMPLE_CLAUSE(At, OMPC_at)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
 CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2443,6 +2443,8 @@
 void OMPClauseEnqueue::VisitOMPAtomicDefaultMemOrderClause(
 const OMPAtomicDefaultMemOrderClause *) {}
 
+void OMPClauseEnqueue::VisitOMPAtClause(const OMPAtClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }
Index: clang/test/OpenMP/error_message.cpp
===
--- clang/test/OpenMP/error_message.cpp
+++ clang/test/OpenMP/error_message.cpp
@@ -7,19 +7,19 @@
   if (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 if (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   while (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   do
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc)
   ;
   do {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } while (argc);
   switch (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
@@ -28,47 +28,75 @@
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   }
   switch (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   case 1:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 break;
   default: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } break;
   }
   for (;;)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 for (;;) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 label:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 label1 : {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 if (1)
   label2:
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 
+// expected-error@+1 {{ERROR}}
+#pragma omp error at() // expected-error {{expected 'compilation' or 'execution' in OpenMP clause 'at'}}
+
+// exp

[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:3302
+  void ParseOpenMPClauses(OpenMPDirectiveKind DKind,
+  SmallVector *Clauses,
+  SourceLocation Loc);

ABataev wrote:
> `SmallVectorImpl &`
Thanks!! Changed.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1656-1657
+OMPAtClause *AtC = CKind == OMPC_at ? cast(Clause) : nullptr;
+if (CKind == OMPC_at && AtC->getAtKind() == OMPC_AT_execution)
+  Diag(AtC->getAtKindKwLoc(), diag::err_omp_unexpected_execution_modifier);
+if (Tok.is(tok::annot_pragma_openmp_end)) {

ABataev wrote:
> Better to diagnose it in Sema
Move to Sema!!  Changed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cbcf123 - [LegacyPM] Remove cl::opts controlling optimization pass manager passes

2022-11-14 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-11-14T09:38:17-08:00
New Revision: cbcf123af293ee56876cce16dac83c3008478dae

URL: 
https://github.com/llvm/llvm-project/commit/cbcf123af293ee56876cce16dac83c3008478dae
DIFF: 
https://github.com/llvm/llvm-project/commit/cbcf123af293ee56876cce16dac83c3008478dae.diff

LOG: [LegacyPM] Remove cl::opts controlling optimization pass manager passes

Move these to the new PM if they're used there.

Part of removing the legacy pass manager for optimization pipeline.

Reland with UseNewGVN usage in clang removed.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D137915

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index eb444c829381f..41f9ce3a009da 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -83,7 +83,6 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Scalar/JumpThreading.h"
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
-#include "llvm/Transforms/Scalar/NewGVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/Debugify.h"
@@ -101,7 +100,6 @@ using namespace llvm;
 
 namespace llvm {
 extern cl::opt DebugInfoCorrelate;
-extern cl::opt RunNewGVN;
 
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(
@@ -676,10 +674,7 @@ static void addSanitizers(const Triple &TargetTriple,
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
   FPM.addPass(JumpThreadingPass());
-  if (RunNewGVN)
-FPM.addPass(NewGVNPass());
-  else
-FPM.addPass(GVNPass());
+  FPM.addPass(GVNPass());
   FPM.addPass(InstCombinePass());
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
 }

diff  --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index b32d53d8dfaf8..f978b2cefe9e3 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -134,11 +134,11 @@ static cl::opt UseInlineAdvisor(
 "enable-ml-inliner", cl::init(InliningAdvisorMode::Default), cl::Hidden,
 cl::desc("Enable ML policy for inliner. Currently trained for -Oz only"),
 cl::values(clEnumValN(InliningAdvisorMode::Default, "default",
-  "Heuristics-based inliner version."),
+  "Heuristics-based inliner version"),
clEnumValN(InliningAdvisorMode::Development, "development",
-  "Use development mode (runtime-loadable model)."),
+  "Use development mode (runtime-loadable model)"),
clEnumValN(InliningAdvisorMode::Release, "release",
-  "Use release mode (AOT-compiled model).")));
+  "Use release mode (AOT-compiled model)")));
 
 static cl::opt EnableSyntheticCounts(
 "enable-npm-synthetic-counts", cl::Hidden,
@@ -161,7 +161,7 @@ static cl::opt 
EnableModuleInliner("enable-module-inliner",
 static cl::opt PerformMandatoryInliningsFirst(
 "mandatory-inlining-first", cl::init(true), cl::Hidden,
 cl::desc("Perform mandatory inlinings module-wide, before performing "
- "inlining."));
+ "inlining"));
 
 static cl::opt EnableO3NonTrivialUnswitching(
 "enable-npm-O3-nontrivial-unswitch", cl::init(true), cl::Hidden,
@@ -190,6 +190,99 @@ static cl::opt EnableGlobalAnalyses(
 "enable-global-analyses", cl::init(true), cl::Hidden,
 cl::desc("Enable inter-procedural analyses"));
 
+static cl::opt
+RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden,
+   cl::desc("Run Partial inlinining pass"));
+
+static cl::opt ExtraVectorizerPasses(
+"extra-vectorizer-passes", cl::init(false), cl::Hidden,
+cl::desc("Run cleanup optimization passes after vectorization"));
+
+static cl::opt RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
+   cl::desc("Run the NewGVN pass"));
+
+static cl::opt EnableLoopInterchange(
+"enable-loopinterchange", cl::init(false), cl::Hidden,
+cl::desc("Enable the experimental LoopInterchange Pass"));
+
+static cl::opt EnableUnrollAndJam("enable-unroll-and-jam",
+cl::init(false), cl::Hidden,
+cl::desc("Enable Unroll And Jam 
Pass"));
+
+static cl::opt EnableLoopFlatten("enable-loop-flatten", cl::init(false),
+   cl::Hidden,
+   cl::desc("Enable the 

[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

`Andreas Hollandt `


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11293
+   SourceLocation EndLoc,
+   bool InExContext = true);
   /// Called on well-formed '\#pragma omp barrier'.

Why do you need this flag?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11035-11037
+  for (auto *AC :
+   OMPExecutableDirective::getClausesOfKind(Clauses))
+AtC = AC;

Why do you need a loop here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128457: [clangd] Add new IncludeType to IncludeHeaderWithReferences

2022-11-14 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 475180.
dgoldman added a comment.

Run clang format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128457/new/

https://reviews.llvm.org/D128457

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp

Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -53,8 +53,16 @@
 IncludeHeaders:
   - Header:'include1'
 References:7
+Directives:  [ Include ]
   - Header:'include2'
 References:3
+Directives:  [ Import ]
+  - Header:'include3'
+References:2
+Directives:  [ Include, Import ]
+  - Header:'include4'
+References:1
+Directives:  [ ]
 ...
 ---
 !Symbol
@@ -114,8 +122,11 @@
 
 MATCHER_P(id, I, "") { return arg.ID == cantFail(SymbolID::fromStr(I)); }
 MATCHER_P(qName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
-MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") {
-  return (arg.IncludeHeader == IncludeHeader) && (arg.References == References);
+MATCHER_P3(IncludeHeaderWithRefAndDirectives, IncludeHeader, References,
+   SupportedDirectives, "") {
+  return (arg.IncludeHeader == IncludeHeader) &&
+ (arg.References == References) &&
+ (arg.SupportedDirectives == SupportedDirectives);
 }
 
 auto readIndexFile(llvm::StringRef Text) {
@@ -148,9 +159,14 @@
   EXPECT_EQ(static_cast(Sym1.Flags), 129);
   EXPECT_TRUE(Sym1.Flags & Symbol::IndexedForCodeCompletion);
   EXPECT_FALSE(Sym1.Flags & Symbol::Deprecated);
-  EXPECT_THAT(Sym1.IncludeHeaders,
-  UnorderedElementsAre(IncludeHeaderWithRef("include1", 7u),
-   IncludeHeaderWithRef("include2", 3u)));
+  EXPECT_THAT(
+  Sym1.IncludeHeaders,
+  UnorderedElementsAre(
+  IncludeHeaderWithRefAndDirectives("include1", 7u, Symbol::Include),
+  IncludeHeaderWithRefAndDirectives("include2", 3u, Symbol::Import),
+  IncludeHeaderWithRefAndDirectives("include3", 2u,
+Symbol::Include | Symbol::Import),
+  IncludeHeaderWithRefAndDirectives("include4", 1u, Symbol::Invalid)));
 
   EXPECT_THAT(Sym2, qName("clang::Foo2"));
   EXPECT_EQ(Sym2.Signature, "-sig");
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -567,9 +567,9 @@
   L.Name = "left";
   R.Name = "right";
   L.ID = R.ID = SymbolID("hello");
-  L.IncludeHeaders.emplace_back("common", 1);
-  R.IncludeHeaders.emplace_back("common", 1);
-  R.IncludeHeaders.emplace_back("new", 1);
+  L.IncludeHeaders.emplace_back("common", 1, Symbol::Include);
+  R.IncludeHeaders.emplace_back("common", 1, Symbol::Include);
+  R.IncludeHeaders.emplace_back("new", 1, Symbol::Include);
 
   // Both have no definition.
   Symbol M = mergeSymbol(L, R);
@@ -615,7 +615,7 @@
 std::move(DynData), DynSize);
 
   SymbolSlab::Builder StaticB;
-  S.IncludeHeaders.push_back({"", 0});
+  S.IncludeHeaders.push_back({"", 0, Symbol::Include});
   StaticB.insert(S);
   auto StaticIndex =
   MemIndex::build(std::move(StaticB).build(), RefSlab(), RelationSlab());
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1071,7 +1071,7 @@
 Sym.Flags |= Symbol::IndexedForCodeCompletion;
 Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
 Sym.Definition.FileURI = S.DeclaringFile.c_str();
-Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1, Symbol::Include);
 Slab.insert(Sym);
   }
   return MemIndex::build(std::move(Slab).build(), RefSlab(), RelationSlab());
@@ -1129,7 +1129,7 @@
   Symbol Sym = enm("X")

[PATCH] D137269: [Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms.

2022-11-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> One thing that we did notice is that adding `-fno-global-isel` to cflags and 
> ldflags only had an effect when manually blowing away the thinlto cache. 
> Maybe whatever decides when to invalidate the thinlto cache needs to learn to 
> invalidate it when the `-global-isel` flag changes?

Looks like we'll have to do D134013  for the 
Mach-O and COFF lld ports as well. I'll make a CL for that. Thanks to @hans for 
pointing that out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137269/new/

https://reviews.llvm.org/D137269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137960: [Lexer] Speedup LexTokenInternal

2022-11-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: lattner, nikic.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Only reset "NeedsCleaning" flag in case of re-entrant call.
Do not needlessly blank IdentifierInfo. This information will be set
once the token type is picked.

This yields a nice 1% speedup when pre-processing sqlite amalgamation
through:

valgrind --tool=callgrind ./bin/clang -E sqlite3.c -o/dev/null


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137960

Files:
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -3516,10 +3516,8 @@
 /// token, not a normal token, as such, it is an internal interface.  It 
assumes
 /// that the Flags of result have been cleared before calling this.
 bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
-LexNextToken:
-  // New token, can't need cleaning yet.
-  Result.clearFlag(Token::NeedsCleaning);
-  Result.setIdentifierInfo(nullptr);
+LexStart:
+  assert(!Result.needsCleaning() && "Result doesn't need cleaning");
 
   // CurPtr - Cache BufferPtr in an automatic variable.
   const char *CurPtr = BufferPtr;
@@ -4141,8 +4139,9 @@
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else if (Char == '|') {
   // If this is '|||' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
   Kind = tok::pipepipe;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
@@ -4170,8 +4169,9 @@
 Char = getCharAndSize(CurPtr, SizeTmp);
 if (Char == '=') {
   // If this is '' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
 
   Kind = tok::equalequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
@@ -4301,6 +4301,10 @@
 
   // We parsed the directive; lex a token with the new state.
   return false;
+
+LexNextToken:
+  Result.clearFlag(Token::NeedsCleaning);
+  goto LexStart;
 }
 
 const char *Lexer::convertDependencyDirectiveToken(


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -3516,10 +3516,8 @@
 /// token, not a normal token, as such, it is an internal interface.  It assumes
 /// that the Flags of result have been cleared before calling this.
 bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
-LexNextToken:
-  // New token, can't need cleaning yet.
-  Result.clearFlag(Token::NeedsCleaning);
-  Result.setIdentifierInfo(nullptr);
+LexStart:
+  assert(!Result.needsCleaning() && "Result doesn't need cleaning");
 
   // CurPtr - Cache BufferPtr in an automatic variable.
   const char *CurPtr = BufferPtr;
@@ -4141,8 +4139,9 @@
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else if (Char == '|') {
   // If this is '|||' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
   Kind = tok::pipepipe;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
@@ -4170,8 +4169,9 @@
 Char = getCharAndSize(CurPtr, SizeTmp);
 if (Char == '=') {
   // If this is '' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
 
   Kind = tok::equalequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
@@ -4301,6 +4301,10 @@
 
   // We parsed the directive; lex a token with the new state.
   return false;
+
+LexNextToken:
+  Result.clearFlag(Token::NeedsCleaning);
+  goto LexStart;
 }
 
 const char *Lexer::convertDependencyDirectiveToken(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137960: [Lexer] Speedup LexTokenInternal

2022-11-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Compile time tracker record : 
https://llvm-compile-time-tracker.com/compare.php?from=f71d32a0eea47b3d2bb43d6be15cf09d47ef6971&to=b4df7d2a01aacd29ae539b04e72b3667e2362aa1&stat=instructions:u
The cost of preprocessing is hidden by the optimization time, but -O0 gives an 
hint of the expected speedup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137960/new/

https://reviews.llvm.org/D137960

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137885: [modules] Support zstd in .pcm file

2022-11-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:1456
+  const llvm::compression::Format F =
+  Blob.size() >= 2 && memcmp(Blob.data(), "\x1f\x8b", 2) == 0
+  ? llvm::compression::Format::Zlib

Worth a comment about this magic number?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137885/new/

https://reviews.llvm.org/D137885

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475187.
francii added a comment.
Herald added a subscriber: ormris.

Removed check for sysroot, it is not needed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 CodeGenOpts.InstrumentFunctionEntryBare ||
 CodeGenOpts.InstrumentFunctionsAfterInlining ||
-CodeGenOpts.InstrumentForProfil

[PATCH] D137962: [clang][Tooling] Make the filename behaviour consistent

2022-11-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

Dotdots were removed only when converting a relative path to absolute
one. This patch makes the behaviour consistent for absolute file paths by
removing them in that case as well. Also updates the documentation to mention
the behaviour.

Fixes https://github.com/clangd/clangd/issues/1317


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137962

Files:
  clang/docs/JSONCompilationDatabase.rst
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -92,16 +92,32 @@
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
+  llvm::sys::path::native("//net/dir/file3", PathStorage);
+  expected_files.push_back(std::string(PathStorage.str()));
   EXPECT_EQ(expected_files,
-getAllFiles("[{\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"../file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file2\"}]",
+getAllFiles(R"json(
+[
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "file1"
+  },
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "../file1"
+  },
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "file2"
+  },
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "//net/dir/foo/../file3"
+  }
+])json",
 ErrorMessage, JSONCommandLineSyntax::Gnu))
   << ErrorMessage;
 }
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -426,6 +426,7 @@
   llvm::sys::path::native(AbsolutePath, NativeFilePath);
 } else {
   llvm::sys::path::native(FileName, NativeFilePath);
+  llvm::sys::path::remove_dots(NativeFilePath, /*remove_dot_dot=*/ true);
 }
 auto Cmd = CompileCommandRef(Directory, File, *Command, Output);
 IndexByFile[NativeFilePath].push_back(Cmd);
Index: clang/docs/JSONCompilationDatabase.rst
===
--- clang/docs/JSONCompilationDatabase.rst
+++ clang/docs/JSONCompilationDatabase.rst
@@ -86,7 +86,8 @@
compilation step. This is used by tools as the key into the
compilation database. There can be multiple command objects for the
same file, for example if the same source file is compiled with
-   different configurations.
+   different configurations. ``dot`` (./) ``dotdot`` (../) in the path is
+   stripped lexically.
 -  **arguments:** The compile command argv as list of strings.
This should run the compilation step for the translation unit ``file``.
``arguments[0]`` should be the executable name, such as ``clang++``.


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -92,16 +92,32 @@
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
+  llvm::sys::path::native("//net/dir/file3", PathStorage);
+  expected_files.push_back(std::string(PathStorage.str()));
   EXPECT_EQ(expected_files,
-getAllFiles("[{\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"../file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file2\

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475194.
francii added a comment.

Fix mixup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475196.
francii added a comment.

Add profiled libraries check AIX


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L/lib/profiled"
+// CHECK-LD32-PROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L/lib/profiled"
+// CHECK-LD64-PROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475197.
francii added a comment.

Remove check for -p


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Paul Eggert via cfe-commits

On 2022-11-14 04:41, Aaron Ballman wrote:

it's generally a problem when autoconf relies on invalid
language constructs


Autoconf *must* rely on invalid language constructs, if only to test 
whether the language constructs work. And Clang therefore must be 
careful about how it diagnoses invalid constructs. Clang shouldn't 
willy-nilly change the way it reports invalid constructs, as that can 
break Autoconf.



issues of security
like statically known instances of UB


It's fine to report those; I'm not saying don't report them. All I'm 
saying is that Clang should be careful about *how* it reports them.


At the very least if there are going to be changes in this area, the 
Clang developers should notify Autoconf (and presumably other) 
downstream users of the changes, and provide a supported way to get the 
old behavior for reporting, and give downstream time to adapt.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475203.
francii added a comment.

Add sysroot to test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Florian Weimer via cfe-commits
* Paul Eggert:

> On 2022-11-14 04:41, Aaron Ballman wrote:
>> it's generally a problem when autoconf relies on invalid
>> language constructs
>
> Autoconf *must* rely on invalid language constructs, if only to test
> whether the language constructs work. And Clang therefore must be 
> careful about how it diagnoses invalid constructs. Clang shouldn't
> willy-nilly change the way it reports invalid constructs, as that can 
> break Autoconf.

This is only true for the status quo.  We could finally band together
and define an interface between autoconf and the toolchain that avoids
feature probing through source code fragments for common cases.  It
might make configure scripts to run quite a bit faster, too.

That being said, system compilers need to be careful when turning
warnings into errors by default, but that doesn't mean we should never
do such changes, particularly when we know based on interactions with
programmers that the warnings are not sufficient for avoiding wasted
time.

Thanks,
Florian

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Aaron Ballman via cfe-commits
On Mon, Nov 14, 2022 at 1:14 PM Paul Eggert  wrote:
>
> On 2022-11-14 04:41, Aaron Ballman wrote:
> > it's generally a problem when autoconf relies on invalid
> > language constructs
>
> Autoconf *must* rely on invalid language constructs, if only to test
> whether the language constructs work. And Clang therefore must be
> careful about how it diagnoses invalid constructs. Clang shouldn't
> willy-nilly change the way it reports invalid constructs, as that can
> break Autoconf.
>
> > issues of security
> > like statically known instances of UB
>
> It's fine to report those; I'm not saying don't report them. All I'm
> saying is that Clang should be careful about *how* it reports them.
>
> At the very least if there are going to be changes in this area, the
> Clang developers should notify Autoconf (and presumably other)
> downstream users of the changes, and provide a supported way to get the
> old behavior for reporting, and give downstream time to adapt.

Definitely agreed about the communication aspects! I mentioned this upthread:

FWIW, we're working on improving communication
about potentially disruptive changes to Clang, so you might want to
consider either subscribing to the clang-vendors code review group at
https://reviews.llvm.org/project/members/113/ (if you want to be
involved in code review before things land) or the Announcements
discourse channel at https://discourse.llvm.org/c/announce/ (if you
want to be notified after something lands but before Clang ships).

One other thing we've done recently is starting to call out
potentially disruptive changes in the release notes as well:
https://clang.llvm.org/docs/ReleaseNotes.html#potentially-breaking-changes
-- but this is more for notifying folks after a release goes out, so
one of the other approaches is more proactive if the goal is to alert
Clang developers to serious deployment problems before we ship.

~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-11-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

I'll hold off on submitting this until that bug is figured out


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133036/new/

https://reviews.llvm.org/D133036

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137968: [clang-tidy] Ignore overriden methods in `readability-const-return-type`.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: njames93, thomasetter.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang-tools-extra.

Overrides are constrained by the signature of the overridden method, so a
warning on an override is frequently unactionable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137968

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,11 +279,11 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
 // Don't warn about const auto types, because it may be impossible to make 
them non-const
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return types in overridden functions since the derived
+  class cannot always choose to change the function signature.
+
 - Fixed crashes in :doc:`readability-braces-around-statements
   ` and
   :doc:`readability-simplify-boolean-expr 
`
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -114,7 +114,9 @@
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),
-  anyOf(isDefinition(), cxxMethodDecl(isPure(
+  anyOf(isDefinition(), cxxMethodDecl(isPure())),
+  // Overridden functions are not actionable.
+  unless(cxxMethodDecl(isOverride(
   .bind("func"),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,11 +279,11 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
 // Don't warn about const auto types, because it may be impossible to make them non-const
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return types in overridden functions since the derived
+  class cannot always choose to change the function signature.
+
 - Fixed crashes in :doc:`readability-braces-around-statements
   ` and
   :doc:`readability-simplify-boolean-expr `
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -114,7 +114,9 @@
   Finder->addMatcher(
   funct

[clang] 840a793 - clang/AMDGPU: Use Support's wrapper around getenv

2022-11-14 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2022-11-14T11:07:31-08:00
New Revision: 840a793375fec763c2b2781b82b764325635cc7a

URL: 
https://github.com/llvm/llvm-project/commit/840a793375fec763c2b2781b82b764325635cc7a
DIFF: 
https://github.com/llvm/llvm-project/commit/840a793375fec763c2b2781b82b764325635cc7a.diff

LOG: clang/AMDGPU: Use Support's wrapper around getenv

This does some extra stuff for Windows, so might as well
use it just in case.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 261594171564e..153537c45d2d6 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -199,9 +200,10 @@ RocmInstallationDetector::getInstallationPathCandidates() {
 ROCmSearchDirs.emplace_back(RocmPathArg.str());
 DoPrintROCmSearchDirs();
 return ROCmSearchDirs;
-  } else if (const char *RocmPathEnv = ::getenv("ROCM_PATH")) {
-if (!StringRef(RocmPathEnv).empty()) {
-  ROCmSearchDirs.emplace_back(RocmPathEnv);
+  } else if (Optional RocmPathEnv =
+ llvm::sys::Process::GetEnv("ROCM_PATH")) {
+if (!RocmPathEnv->empty()) {
+  ROCmSearchDirs.emplace_back(std::move(*RocmPathEnv));
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;
 }
@@ -374,8 +376,9 @@ void RocmInstallationDetector::detectDeviceLibrary() {
 
   if (!RocmDeviceLibPathArg.empty())
 LibDevicePath = RocmDeviceLibPathArg[RocmDeviceLibPathArg.size() - 1];
-  else if (const char *LibPathEnv = ::getenv("HIP_DEVICE_LIB_PATH"))
-LibDevicePath = LibPathEnv;
+  else if (Optional LibPathEnv =
+   llvm::sys::Process::GetEnv("HIP_DEVICE_LIB_PATH"))
+LibDevicePath = std::move(*LibPathEnv);
 
   auto &FS = D.getVFS();
   if (!LibDevicePath.empty()) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137874: clang/AMDGPU: Use Support's wrapper around getenv

2022-11-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

840a793375fec763c2b2781b82b764325635cc7a 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137874/new/

https://reviews.llvm.org/D137874

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137738: [clang-tidy] Suppress google-objc-avoid-throwing-exception in system macros 🫢

2022-11-14 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 475222.
stephanemoore added a subscriber: Eugene.Zelenko.
stephanemoore added a comment.

Included namespace comment linter fixes from D137740 
 as advised by @Eugene.Zelenko,


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137738/new/

https://reviews.llvm.org/D137738

Files:
  clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/google/Inputs/system-header-throw.h
  
clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m

Index: clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m
===
--- clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m
+++ clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t -- -- -I %S/Inputs/
+
 @class NSString;
 
 @interface NSException
@@ -21,12 +22,29 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 }
 
+#include "system-header-throw.h"
+
+#define THROW(e) @throw e
+
+#define RAISE [NSException raise:@"example" format:@"fmt"]
+
 - (void)f2 {
 [NSException raise:@"TestException" format:@"Test"];
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 [NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 [NotException raise:@"NotException" format:@"Test"];
+
+NSException *e;
+SYS_THROW(e);
+
+SYS_RAISE;
+
+THROW(e);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+
+RAISE;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 }
 @end
 
Index: clang-tools-extra/test/clang-tidy/checkers/google/Inputs/system-header-throw.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/google/Inputs/system-header-throw.h
@@ -0,0 +1,6 @@
+#pragma clang system_header
+
+#define SYS_THROW(e) @throw e
+
+#define SYS_RAISE [NSException raise:@"example" format:@"fmt"]
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -141,6 +141,10 @@
   would be emitted for uninitialized members of an anonymous union despite
   there being an initializer for one of the other members.
 
+- Fixed false positives in :doc:`google-objc-avoid-throwing-exception
+  ` check for exceptions
+  thrown by code emitted from macros in system headers.
+
 - Improved :doc:`modernize-use-emplace `
   check.
 
Index: clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
+++ clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
@@ -36,12 +36,28 @@
   Result.Nodes.getNodeAs("raiseException");
   auto SourceLoc = MatchedStmt == nullptr ? MatchedExpr->getSelectorStartLoc()
   : MatchedStmt->getThrowLoc();
+
+  // Early return on invalid locations.
+  if (SourceLoc.isInvalid())
+return;
+
+  // If the match location was in a macro, check if the macro was in a system
+  // header.
+  if (SourceLoc.isMacroID()) {
+SourceManager &SM = *Result.SourceManager;
+auto MacroLoc = SM.getImmediateMacroCallerLoc(SourceLoc);
+
+// Matches in system header macros should be ignored.
+if (SM.isInSystemHeader(MacroLoc))
+  return;
+  }
+
   diag(SourceLoc,
"pass in NSError ** instead of throwing exception to indicate "
"Objective-C errors");
 }
 
-}  // namespace objc
-}  // namespace google
-}  // namespace tidy
-}  // namespace clang
+} // namespace objc
+} // namespace google
+} // namespace tidy
+} // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137968: [clang-tidy] Ignore overriden methods in `readability-const-return-type`.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 475224.
ymandel added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137968/new/

https://reviews.llvm.org/D137968

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,13 +279,22 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
+class NVDeriveOutOfLine : public PVBase {
+public:
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as one may not be able to change the base class
+  const int getC();
+};
+
+const int NVDeriveOutOfLine::getC() { return 1; }
+
 // Don't warn about const auto types, because it may be impossible to make 
them non-const
 // without a significant semantics change. Since `auto` drops cv-qualifiers,
 // tests check `decltype(auto)`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return types in overridden functions since the derived
+  class cannot always choose to change the function signature.
+
 - Fixed crashes in :doc:`readability-braces-around-statements
   ` and
   :doc:`readability-simplify-boolean-expr 
`
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -114,7 +114,9 @@
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),
-  anyOf(isDefinition(), cxxMethodDecl(isPure(
+  anyOf(isDefinition(), cxxMethodDecl(isPure())),
+  // Overridden functions are not actionable.
+  unless(cxxMethodDecl(isOverride(
   .bind("func"),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,13 +279,22 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
+class NVDeriveOutOfLine : public PVBase {
+public:
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as one may not be able to change the base class
+  const int getC();
+};
+
+const int NVDeriveOutOfLine::getC() { return 1; }
+
 // Don't warn about const auto types, because it may be impossible to make them non-const
 // without a significant semantics change. Since `auto` drops cv-qualifiers,
 // tests check `decltype(auto)`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return 

[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 475225.
jyu2 added a comment.

Thanks Alexey!  Address Alexey comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/error_ast_print.cpp
  clang/test/OpenMP/error_message.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -301,6 +301,9 @@
   let clangClass = "OMPAtomicDefaultMemOrderClause";
   let flangClass = "OmpAtomicDefaultMemOrderClause";
 }
+def OMPC_At : Clause<"at"> {
+  let clangClass = "OMPAtClause";
+}
 def OMPC_Allocate : Clause<"allocate"> {
   let clangClass = "OMPAllocateClause";
   let flangClass = "OmpAllocateClause";
@@ -527,7 +530,11 @@
 }
 def OMP_TaskYield : Directive<"taskyield"> {}
 def OMP_Barrier : Directive<"barrier"> {}
-def OMP_Error : Directive<"error"> {}
+def OMP_Error : Directive<"error"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+}
 def OMP_TaskWait : Directive<"taskwait"> {
   let allowedClauses = [
 VersionedClause
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1868,6 +1868,7 @@
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
+CHECK_SIMPLE_CLAUSE(At, OMPC_at)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
 CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2443,6 +2443,8 @@
 void OMPClauseEnqueue::VisitOMPAtomicDefaultMemOrderClause(
 const OMPAtomicDefaultMemOrderClause *) {}
 
+void OMPClauseEnqueue::VisitOMPAtClause(const OMPAtClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }
Index: clang/test/OpenMP/error_message.cpp
===
--- clang/test/OpenMP/error_message.cpp
+++ clang/test/OpenMP/error_message.cpp
@@ -7,19 +7,19 @@
   if (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 if (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   while (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   do
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc)
   ;
   do {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } while (argc);
   switch (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
@@ -28,47 +28,75 @@
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   }
   switch (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   case 1:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 break;
   default: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } break;
   }
   for (;;)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 for (;;) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 label:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 label1 : {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 if (1)
   label2:
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 
+// expected-error@+1 {{ERROR}}
+#pragma omp error at() // expected-error {{expected 'compilation' or 'execution' in Open

[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11293
+   SourceLocation EndLoc,
+   bool InExContext = true);
   /// Called on well-formed '\#pragma omp barrier'.

ABataev wrote:
> Why do you need this flag?
The error pragma is not allowed in declared context when "at" clause with 
execution modifier. 
It is allowed with compilation modifier.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11035-11037
+  for (auto *AC :
+   OMPExecutableDirective::getClausesOfKind(Clauses))
+AtC = AC;

ABataev wrote:
> Why do you need a loop here?
Only one "at" clause is allowed.  So I think Loop does not matters.  Changed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137972: [clang-tidy] Optionally ignore findings in macros in `readability-const-return-type`.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: njames93, thomasetter.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang-tools-extra.

Adds support for options-controlled configuration of the check to ignore 
results in macros.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137972

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -196,13 +196,22 @@
 // Test cases where the `const` token lexically is hidden behind some form of
 // indirection.
 
+// Regression tests involving macros, which are ignored by default because
+// IgnoreMacros defaults to true.
+#define CONCAT(a, b) a##b
+CONCAT(cons, t) int n22(){}
+
 #define CONSTINT const int
-CONSTINT p18() {}
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+CONSTINT n23() {}
 
 #define CONST const
-CONST int p19() {}
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+CONST int n24() {}
+
+#define CREATE_FUNCTION()\
+const int n_inside_macro() { \
+  return 1; \
+}
+CREATE_FUNCTION();
 
 using ty = const int;
 ty p21() {}
Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t -- \
+// RUN:   -config="{CheckOptions: [{key: readability-const-return-type.IgnoreMacros, value: false}]}"
+
+//  p# = positive test
+//  n# = negative test
+
+// Regression tests involving macros
+#define CONCAT(a, b) a##b
+CONCAT(cons, t) int p22(){}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+// We warn, but we can't give a fix
+
+#define CONSTINT const int
+CONSTINT p23() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+
+#define CONST const
+CONST int p24() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+
+#define CREATE_FUNCTION()\
+const int p_inside_macro() { \
+  return 1; \
+}
+CREATE_FUNCTION();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+// We warn, but we can't give a fix
Index: clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
@@ -24,3 +24,12 @@
const int* foo();
const int& foo();
const Clazz* foo();
+
+
+Options
+---
+
+.. option:: IgnoreMacros
+
+   If set to `true`, the check will not give warnings inside macros. Default
+   is `true`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,10 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the default behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` value parameters of declarations inside macros.
+
 - Change the behavior of :doc:`readability-const-return-type
   ` to not
   warn about `const` return types in overridden functions since the derived
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
@@ -22,9 +22,15 @@
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html
 class ConstReturnTypeCheck : public ClangTidyCheck {
  public:
-  using ClangTidyCheck::ClangTidyCheck;
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+   ConstReturnTypeCheck(StringRef Name, ClangTidyContext *Context)
+   : ClangTidyCheck(Name

[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137217/new/

https://reviews.llvm.org/D137217

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Drive by: Please add commit messages to non trivial changes to explaining 
what's going on.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137872: Try to implement lambdas with inalloca parameters by forwarding without use of inallocas.

2022-11-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not quite sure I understand what's happening here.  Does this actually 
avoid generating two copies of the function body if both the call operator and 
the conversion are used?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137872/new/

https://reviews.llvm.org/D137872

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137968: [clang-tidy] Ignore overriden methods in `readability-const-return-type`.

2022-11-14 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

Lg, but can you address that one nit before landing




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:169
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not

Can this be moved to below the braces around statements check as we like to 
keep things in alphabetical order.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137968/new/

https://reviews.llvm.org/D137968

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D137851#3925661 , @jdoerfert wrote:

> Drive by: Please add commit messages to non trivial changes to explaining 
> what's going on.

Thanks.  Added.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137851/new/

https://reviews.llvm.org/D137851

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475242.
francii added a comment.

Add sysroot check to aix-ld.c test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "countin

[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8da41fe69622: [cmake] Fix _GNU_SOURCE being added 
unconditionally (authored by Trass3r, committed by tstellar).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137917/new/

https://reviews.llvm.org/D137917

Files:
  clang/CMakeLists.txt
  llvm/cmake/config-ix.cmake


Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -414,8 +414,6 @@
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 


Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -414,8 +414,6 @@
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8da41fe - [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Tom Stellard via cfe-commits

Author: Andreas Hollandt
Date: 2022-11-14T12:28:21-08:00
New Revision: 8da41fe69622f35e0a15b5a1754cd670e6057938

URL: 
https://github.com/llvm/llvm-project/commit/8da41fe69622f35e0a15b5a1754cd670e6057938
DIFF: 
https://github.com/llvm/llvm-project/commit/8da41fe69622f35e0a15b5a1754cd670e6057938.diff

LOG: [cmake] Fix _GNU_SOURCE being added unconditionally

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D137917

Added: 


Modified: 
clang/CMakeLists.txt
llvm/cmake/config-ix.cmake

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c9f86d4c9889c..e6cc6e4705428 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -414,8 +414,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 

diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 15a7d78b3ac43..28ca8223ce934 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@ endif()
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137562: [clang][Interp] Start supporting virtual base classes

2022-11-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Descriptor.cpp:126
+  auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase,
+ bool Recurse = true) {
 auto *Desc = reinterpret_cast(Ptr + SubOff) - 1;

To recurse or not seems to be a property of whether the base is virtual or not.

Maybe a enum w/ `Base` and `Virtual` base would be better and then the logic of 
whether to recurse can be kept local to the lambda,



Comment at: clang/lib/AST/Interp/Descriptor.cpp:147
   for (const auto &V : D->ElemRecord->virtual_bases())
-CtorSub(V.Offset, V.Desc, /*isBase=*/true);
+CtorSub(V.Offset, V.Desc, /*isBase=*/true, false);
 }




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137562/new/

https://reviews.llvm.org/D137562

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

The naming convention used here for COFF is actually very similar to what is 
done for other ThinLTO save-temps output files, which are placed at the input 
module locations. We may want to just do this across the board. @MaskRay wdyt? 
A few other questions/comments below.




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1104
 
-  auto AddStream = [&](size_t Task) {
+  auto AddStream = [&](size_t Task, Twine File) {
 return std::make_unique(std::move(OS),

I think you might need to mark the new parameter as unused here and in other 
cases where it isn't used via LLVM_ATTRIBUTE_UNUSED, to avoid build warnings - 
I can't recall how strictly that is enforced.



Comment at: lld/COFF/LTO.cpp:229
+StringRef ltoObjName;
+if (bitcodeFilePath == "ld-temp.o") {
+  ltoObjName =

This case should always be i==0 I think?



Comment at: lld/COFF/LTO.cpp:245
+  saveBuffer(buf[i].second, ltoObjName);
 ret.push_back(make(ctx, MemoryBufferRef(objBuf, ltoObjName)));
   }

The above changes affect both the MemoryBufferRef name as well as the saveTemps 
output file name. I assume the change to the former is what is required for 
PDB, is that correct?



Comment at: lld/MachO/LTO.cpp:132
+"ThinLTO", "Thin", config->thinLTOCacheDir,
+[&](size_t task, Twine originFile, std::unique_ptr mb) {
+  files[task] = std::move(mb);

In some files this parameter is called "filed" and in others "originFile". 
Better to be consistent, and perhaps to use a more descriptive name, something 
like moduleName ?



Comment at: llvm/include/llvm/Support/Caching.h:53
 ///
 /// if (AddStreamFn AddStream = Cache(Task, Key))
 ///   ProduceContent(AddStream);

This and possibly other header file descriptions need updates.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137217/new/

https://reviews.llvm.org/D137217

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137823: [clang-format][NFC] Moved configuration parsing tests in own file

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 3 inline comments as done.
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/ConfigParseTest.cpp:1006
+
+TEST(FormatStyle, GetStyleWithEmptyFileName) {
+  llvm::vfs::InMemoryFileSystem FS;

owenpan wrote:
> Otherwise, the test will be skipped.
That is not true.
It will be executed, and that was the name in the beginning.

I only changed the old `FormatTest` to `ParseTest` and didn't change these 3, 
because I thought someone made this on purpose.

```
[ RUN  ] ParseTest.ConfigurationRoundTripTest
[   OK ] ParseTest.ConfigurationRoundTripTest (4 ms)
[--] 7 tests from ParseTest (201 ms total)

[--] 3 tests from FormatStyle
[ RUN  ] FormatStyle.GetStyleWithEmptyFileName
[   OK ] FormatStyle.GetStyleWithEmptyFileName (3 ms)
```



Comment at: clang/unittests/Format/ConfigParseTest.cpp:1013
+
+TEST(FormatStyle, GetStyleOfFile) {
+  llvm::vfs::InMemoryFileSystem FS;

owenpan wrote:
> Change `FormatStyle` to `ParseTest` here and on line 1220 below.
Discussion above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137823/new/

https://reviews.llvm.org/D137823

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7215
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  "paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   "paramC);\n"

Sorry for the confusion, you can (and should?) keep the `Input` variable. There 
is a verifyFormat with 4 arguments. So that the input in the formatting doesn't 
have to be the expected.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137762/new/

https://reviews.llvm.org/D137762

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137768: [opt][clang] Enable using -module-summary /-flto=thin with -S / -emit-llvm

2022-11-14 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:988
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);

tejohnson wrote:
> I'd go ahead and move this extra file emission under the EmitBC case, since 
> it is also a BC file.
sure, will do


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137768/new/

https://reviews.llvm.org/D137768

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137563: [clang][Interp] Check declarations for constexpr-ness in Load() instructions

2022-11-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:101
 
+static bool CheckConstexpr(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  if (!S.inConstantContext())

Is `CheckConstexpr` descriptive enough? Would something like `CheckLoadIsValid` 
be better?



Comment at: clang/lib/AST/Interp/Interp.cpp:110
+  if (auto *VarD = dyn_cast(VD)) {
+if (VarD->hasLocalStorage() || VarD->isConstexpr())
+  return true;

Is this sufficient? How about something like this:

```
int *p;

int constexpr f(int &x) {
*p=1;
return 10;
}
```

Maybe I am not understanding. I think more test case would be useful.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137563/new/

https://reviews.llvm.org/D137563

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137865: [clang-format][NFC] Improve documentation on ReflowComments

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 475253.
HazardyKnusperkeks marked 3 inline comments as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137865/new/

https://reviews.llvm.org/D137865

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3070,7 +3070,9 @@
   ReferenceAlignmentStyle ReferenceAlignment;
 
   // clang-format off
-  /// If ``true``, clang-format will attempt to re-flow comments.
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``.
   /// \code
   ///false:
   ///// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information
@@ -3821,7 +3823,7 @@
   /// \version 3.7
   bool SpacesInCStyleCastParentheses;
 
-  /// Control of spaces within a single line comment
+  /// Control of spaces within a single line comment.
   struct SpacesInLineComment {
 /// The minimum number of spaces at the start of the comment.
 unsigned Minimum;
@@ -3858,6 +3860,8 @@
   ///   ///  - Foo/// - Foo
   ///   ///- Bar  ///   - Bar
   /// \endcode
+  ///
+  /// This option has only effect if ``ReflowComments`` is set to ``true``.
   /// \version 13
   SpacesInLineComment SpacesInLineCommentPrefix;
 
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3795,7 +3795,9 @@
 
 
 **ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8`
-  If ``true``, clang-format will attempt to re-flow comments.
+  If ``true``, clang-format will attempt to re-flow comments. That is it
+  will touch a comment and *reflow* long comments into new lines, trying to
+  obey the ``ColumnLimit``.
 
   .. code-block:: c++
 
@@ -4610,9 +4612,11 @@
 ///  - Foo/// - Foo
 ///- Bar  ///   - Bar
 
+  This option has only effect if ``ReflowComments`` is set to ``true``.
+
   Nested configuration flags:
 
-  Control of spaces within a single line comment
+  Control of spaces within a single line comment.
 
   * ``unsigned Minimum`` The minimum number of spaces at the start of the 
comment.
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3070,7 +3070,9 @@
   ReferenceAlignmentStyle ReferenceAlignment;
 
   // clang-format off
-  /// If ``true``, clang-format will attempt to re-flow comments.
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``.
   /// \code
   ///false:
   ///// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
@@ -3821,7 +3823,7 @@
   /// \version 3.7
   bool SpacesInCStyleCastParentheses;
 
-  /// Control of spaces within a single line comment
+  /// Control of spaces within a single line comment.
   struct SpacesInLineComment {
 /// The minimum number of spaces at the start of the comment.
 unsigned Minimum;
@@ -3858,6 +3860,8 @@
   ///   ///  - Foo/// - Foo
   ///   ///- Bar  ///   - Bar
   /// \endcode
+  ///
+  /// This option has only effect if ``ReflowComments`` is set to ``true``.
   /// \version 13
   SpacesInLineComment SpacesInLineCommentPrefix;
 
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3795,7 +3795,9 @@
 
 
 **ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8`
-  If ``true``, clang-format will attempt to re-flow comments.
+  If ``true``, clang-format will attempt to re-flow comments. That is it
+  will touch a comment and *reflow* long comments into new lines, trying to
+  obey the ``ColumnLimit``.
 
   .. code-block:: c++
 
@@ -4610,9 +4612,11 @@
 ///  - Foo/// - Foo
 ///- Bar  ///   - Bar
 
+  This option has only effect if ``ReflowComments`` is set to ``true``.
+
   Nested configuration flags:
 
-  Control of spaces within a single line comment
+  Control of spaces within a single line comment.
 
   * ``unsigned Minimum`` The minimum number of spaces at the start of the comment.
 
___
cfe-commits mailing list
cfe-commits@lists.

[PATCH] D137865: [clang-format][NFC] Improve documentation on ReflowComments

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:3073-3076
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``. ``/*`` comments will get a leading ``*`` on the
+  /// new lines.

owenpan wrote:
> Let's leave it as is because the new lines don't always get a leading `*`:
> ```
> $ cat foo.cpp
> /* The LLVM Project is a collection of modular and reusable compiler and 
> toolchain
>technologies. */
> $ clang-format -style='{ReflowComments: true}' foo.cpp
> /* The LLVM Project is a collection of modular and reusable compiler and
>toolchain technologies. */
> ```
That was from a short glimpse on the code.
Adapted the text.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137865/new/

https://reviews.llvm.org/D137865

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >