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

2022-11-09 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

This patch will probably need unit tests




Comment at: clang/lib/Format/TokenAnnotator.cpp:5004-5005
 const FormatToken *Previous = Right.MatchingParen->Previous;
-return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+// avoid breaking when there is an opening parens immediately following
+// a closing parens, such as in cast operators and indirect function calls
+return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||

Please follow the convention on comments as seen on surrounding lines (i.e. use 
proper sentences with capitalization and a full stop at the end)


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] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137517: [TargetSupport] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-11-09 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCV.td:509-517
+class RISCVProcessorModelPROC {
+  string Enum = enum;
+  string EnumFeatures = enum_features;
+  string DefaultMarch = default_march;
+}
+
+class RISCVProcessorModelTUNE_PROC {

Given RISCVProcessorModelTUNE_PROC is a subset of RISCVProcessorModelPROC the 
latter should inherit from the former. Also since every use is also inheriting 
from ProcessorModel why not make RISCVProcessorModelTUNE_PROC itself inherit 
from ProcessorModel?



Comment at: llvm/lib/Target/RISCV/RISCV.td:519
+
+def : ProcessorModel<"generic-rv32", NoSchedModel, [Feature32Bit]>, 
RISCVProcessorModelPROC<"GENERIC_RV32", "FK_NONE", "">;
+def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>, 
RISCVProcessorModelPROC<"GENERIC_RV64", "FK_64BIT", "">;

This would be more natural in TableGen as `def GENERIC_RV32 : ...` and dropping 
the Enum field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D136354: [Driver] Enable nested configuration files

2022-11-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 474455.
sepavloff added a comment.

Rebase patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136354

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/Inputs/config-6.cfg
  clang/test/Driver/config-file-errs.c
  clang/test/Driver/config-file.c
  clang/unittests/Driver/ToolChainTest.cpp
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1200,18 +1200,44 @@
 if (InConfigFile)
   ExpandBasePaths(BasePath, Saver, Arg);
 
-// Get expanded file name.
-StringRef FileName(Arg);
-if (!FileName.consume_front("@"))
-  continue;
-if (!llvm::sys::path::is_relative(FileName))
+// Discover the case, when argument should be transformed into '@file' and
+// evaluate 'file' for it.
+StringRef ArgStr(Arg);
+StringRef FileName;
+bool ConfigInclusion = false;
+if (ArgStr.consume_front("@")) {
+  FileName = ArgStr;
+  if (!llvm::sys::path::is_relative(FileName))
+continue;
+} else if (ArgStr.consume_front("--config=")) {
+  FileName = ArgStr;
+  ConfigInclusion = true;
+} else if (ArgStr == "--config") {
+  if (I + 1 == E)
+return createStringError(std::errc::invalid_argument,
+ "Option '--config' requires an argument");
+  I = NewArgv.erase(I);
+  E = NewArgv.end();
+  FileName = *I;
+  ConfigInclusion = true;
+} else {
   continue;
+}
 
 // Update expansion construct.
 SmallString<128> ResponseFile;
 ResponseFile.push_back('@');
-ResponseFile.append(BasePath);
-llvm::sys::path::append(ResponseFile, FileName);
+if (ConfigInclusion && !llvm::sys::path::has_parent_path(FileName)) {
+  SmallString<128> FilePath;
+  if (!findConfigFile(FileName, FilePath))
+return createStringError(
+std::make_error_code(std::errc::no_such_file_or_directory),
+"cannot not find configuration file: " + FileName);
+  ResponseFile.append(FilePath);
+} else {
+  ResponseFile.append(BasePath);
+  llvm::sys::path::append(ResponseFile, FileName);
+}
 Arg = Saver.save(ResponseFile.str()).data();
   }
   return Error::success();
Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -652,4 +652,58 @@
 #undef INCLUDED1
 }
 
+TEST(ToolChainTest, NestedConfigFile) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr FS(
+  new llvm::vfs::InMemoryFileSystem);
+
+#ifdef _WIN32
+  const char *TestRoot = "C:\\";
+#else
+  const char *TestRoot = "/";
+#endif
+  FS->setCurrentWorkingDirectory(TestRoot);
+
+  FS->addFile("/opt/sdk/root.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--config platform.cfg\n"));
+  FS->addFile("/opt/sdk/root2.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--config=platform.cfg\n"));
+  FS->addFile("/opt/sdk/platform.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-sys\n"));
+  FS->addFile("/home/test/bin/platform.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-bin\n"));
+
+  SmallString<128> ClangExecutable("/home/test/bin/clang");
+  FS->makeAbsolute(ClangExecutable);
+
+  // User file is absent - use system definitions.
+  {
+Driver TheDriver(ClangExecutable, "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+std::unique_ptr C(TheDriver.BuildCompilation(
+{"/home/test/bin/clang", "--config", "root.cfg",
+ "--config-system-dir=/opt/sdk", "--config-user-dir=/home/test/sdk"}));
+ASSERT_TRUE(C);
+ASSERT_FALSE(C->containsError());
+EXPECT_EQ("/platform-sys", TheDriver.SysRoot);
+  }
+
+  // User file overrides system definitions.
+  FS->addFile("/home/test/sdk/platform.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-user\n"));
+  {
+Driver TheDriver(ClangExecutable, "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+std::unique_ptr C(TheDriver.BuildCompilation(
+{"/home/test/bin/clang", "--config", "root2.cfg",
+ "--config-system-dir=/opt/sdk", "--config-user-dir=/home/test/sdk"}));
+ASSERT_TRUE(C);
+ASSERT_FALSE(C->containsError());
+EXPECT_EQ("/platform-user", TheDriver.SysRoot);
+  }
+}
+
 } // end anonymous 

[PATCH] D112049: [ObjC] avoid crashing when emitting synthesized getter/setter and ptrdiff_t is smaller than long

2022-11-09 Thread Matt Jacobson via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd9f7963e434: [ObjC] avoid crashing when emitting 
synthesized getter/setter and ptrdiff_t is… (authored by mhjacobson).

Changed prior to commit:
  https://reviews.llvm.org/D112049?vs=451085=474449#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112049

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/avr/objc-property.m


Index: clang/test/CodeGen/avr/objc-property.m
===
--- /dev/null
+++ clang/test/CodeGen/avr/objc-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm -fobjc-runtime=macosx %s -o /dev/null
+
+__attribute__((objc_root_class))
+@interface Foo
+
+@property(strong) Foo *f;
+
+@end
+
+@implementation Foo
+
+@synthesize f = _f;
+
+@end
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3974,6 +3974,8 @@
 
   llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
   const ObjCIvarDecl *Ivar);
+  llvm::Value *EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface,
+   const ObjCIvarDecl *Ivar);
   LValue EmitLValueForField(LValue Base, const FieldDecl* Field);
   LValue EmitLValueForLambdaField(const FieldDecl *Field);
 
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -1228,7 +1228,7 @@
 llvm::Value *cmd = emitCmdValueForGetterSetterBody(*this, getterMethod);
 llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
-  EmitIvarOffset(classImpl->getClassInterface(), ivar);
+EmitIvarOffsetAsPointerDiff(classImpl->getClassInterface(), ivar);
 
 CallArgList args;
 args.add(RValue::get(self), getContext().getObjCIdType());
@@ -1532,7 +1532,7 @@
 llvm::Value *self =
   Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
-  EmitIvarOffset(classImpl->getClassInterface(), ivar);
+EmitIvarOffsetAsPointerDiff(classImpl->getClassInterface(), ivar);
 Address argAddr = GetAddrOfLocalVar(*setterMethod->param_begin());
 llvm::Value *arg = Builder.CreateLoad(argAddr, "arg");
 arg = Builder.CreateBitCast(arg, VoidPtrTy);
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5242,6 +5242,15 @@
   return CGM.getObjCRuntime().EmitIvarOffset(*this, Interface, Ivar);
 }
 
+llvm::Value *
+CodeGenFunction::EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl 
*Interface,
+ const ObjCIvarDecl *Ivar) {
+  llvm::Value *OffsetValue = EmitIvarOffset(Interface, Ivar);
+  QualType PointerDiffType = getContext().getPointerDiffType();
+  return Builder.CreateZExtOrTrunc(OffsetValue,
+   getTypes().ConvertType(PointerDiffType));
+}
+
 LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
   llvm::Value *BaseValue,
   const ObjCIvarDecl *Ivar,


Index: clang/test/CodeGen/avr/objc-property.m
===
--- /dev/null
+++ clang/test/CodeGen/avr/objc-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm -fobjc-runtime=macosx %s -o /dev/null
+
+__attribute__((objc_root_class))
+@interface Foo
+
+@property(strong) Foo *f;
+
+@end
+
+@implementation Foo
+
+@synthesize f = _f;
+
+@end
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3974,6 +3974,8 @@
 
   llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
   const ObjCIvarDecl *Ivar);
+  llvm::Value *EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface,
+   const ObjCIvarDecl *Ivar);
   LValue EmitLValueForField(LValue Base, const FieldDecl* Field);
   LValue EmitLValueForLambdaField(const FieldDecl *Field);
 
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -1228,7 +1228,7 @@
 llvm::Value *cmd = emitCmdValueForGetterSetterBody(*this, getterMethod);
 llvm::Value *self = 

[clang] dd9f796 - [ObjC] avoid crashing when emitting synthesized getter/setter and ptrdiff_t is smaller than long

2022-11-09 Thread Matt Jacobson via cfe-commits

Author: Matt Jacobson
Date: 2022-11-10T02:10:30-05:00
New Revision: dd9f7963e434a53e8d70f607392ee9abf76f1d99

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

LOG: [ObjC] avoid crashing when emitting synthesized getter/setter and 
ptrdiff_t is smaller than long

On targets where ptrdiff_t is smaller than long, clang crashes when emitting
synthesized getters/setters that call objc_[gs]etProperty.  Explicitly emit a
zext/trunc of the ivar offset value (which is defined to long) to ptrdiff_t,
which objc_[gs]etProperty takes.

Add a test using the AVR target, where ptrdiff_t is smaller than long. Test
failed previously and passes now.

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

Added: 
clang/test/CodeGen/avr/objc-property.m

Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 40d9b8f37b4a6..ee09a8566c371 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5242,6 +5242,15 @@ llvm::Value *CodeGenFunction::EmitIvarOffset(const 
ObjCInterfaceDecl *Interface,
   return CGM.getObjCRuntime().EmitIvarOffset(*this, Interface, Ivar);
 }
 
+llvm::Value *
+CodeGenFunction::EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl 
*Interface,
+ const ObjCIvarDecl *Ivar) {
+  llvm::Value *OffsetValue = EmitIvarOffset(Interface, Ivar);
+  QualType PointerDiffType = getContext().getPointerDiffType();
+  return Builder.CreateZExtOrTrunc(OffsetValue,
+   getTypes().ConvertType(PointerDiffType));
+}
+
 LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
   llvm::Value *BaseValue,
   const ObjCIvarDecl *Ivar,

diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 5ec2fdb5c1708..3eb530d3e9417 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1228,7 +1228,7 @@ CodeGenFunction::generateObjCGetterBody(const 
ObjCImplementationDecl *classImpl,
 llvm::Value *cmd = emitCmdValueForGetterSetterBody(*this, getterMethod);
 llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
-  EmitIvarOffset(classImpl->getClassInterface(), ivar);
+EmitIvarOffsetAsPointerDiff(classImpl->getClassInterface(), ivar);
 
 CallArgList args;
 args.add(RValue::get(self), getContext().getObjCIdType());
@@ -1532,7 +1532,7 @@ CodeGenFunction::generateObjCSetterBody(const 
ObjCImplementationDecl *classImpl,
 llvm::Value *self =
   Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
-  EmitIvarOffset(classImpl->getClassInterface(), ivar);
+EmitIvarOffsetAsPointerDiff(classImpl->getClassInterface(), ivar);
 Address argAddr = GetAddrOfLocalVar(*setterMethod->param_begin());
 llvm::Value *arg = Builder.CreateLoad(argAddr, "arg");
 arg = Builder.CreateBitCast(arg, VoidPtrTy);

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 05e5bad21d46f..7ef22eb064efd 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3974,6 +3974,8 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
   const ObjCIvarDecl *Ivar);
+  llvm::Value *EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface,
+   const ObjCIvarDecl *Ivar);
   LValue EmitLValueForField(LValue Base, const FieldDecl* Field);
   LValue EmitLValueForLambdaField(const FieldDecl *Field);
 

diff  --git a/clang/test/CodeGen/avr/objc-property.m 
b/clang/test/CodeGen/avr/objc-property.m
new file mode 100644
index 0..a3eaea2e0375a
--- /dev/null
+++ b/clang/test/CodeGen/avr/objc-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm -fobjc-runtime=macosx %s -o /dev/null
+
+__attribute__((objc_root_class))
+@interface Foo
+
+@property(strong) Foo *f;
+
+@end
+
+@implementation Foo
+
+@synthesize f = _f;
+
+@end



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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-09 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added a comment.

In D137181#3918673 , @owenpan wrote:

> In D137181#3918117 , @goldstein.w.n 
> wrote:
>
 maybe you did something different?
>>>
>>> Here is what I did:
>>>
>>>   $ git diff UnwrappedLineParser.cpp
>>>   diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
>>> b/clang/lib/Format/UnwrappedLineParser.cpp
>>>   index 25d9018fa109..ab3b9c53ee54 100644
>>>   --- a/clang/lib/Format/UnwrappedLineParser.cpp
>>>   +++ b/clang/lib/Format/UnwrappedLineParser.cpp
>>>   @@ -197,6 +197,7 @@ public:
>>>PreBlockLine = std::move(Parser.Line);
>>>Parser.Line = std::make_unique();
>>>Parser.Line->Level = PreBlockLine->Level;
>>>   +Parser.Line->PPLevel = PreBlockLine->PPLevel;
>>>Parser.Line->InPPDirective = PreBlockLine->InPPDirective;
>>>Parser.Line->InMacroBody = PreBlockLine->InMacroBody;
>>>  }
>>>   @@ -1274,6 +1275,10 @@ void UnwrappedLineParser::parsePPDefine() {
>>>  addUnwrappedLine();
>>>  ++Line->Level;
>>>  Line->InMacroBody = true;
>>>   +  if (Style.IndentPPDirectives != FormatStyle::PPDIS_None) {
>>>   +Line->PPLevel =
>>>   +IncludeGuard == IG_Defined ? PPBranchLevel : PPBranchLevel + 1;
>>>   +  }
>>>
>>>  // Errors during a preprocessor directive can only affect the layout 
>>> of the
>>>  // preprocessor directive, and thus we ignore them. An alternative 
>>> approach
>>
>> You're right this works (but off by one). Updated patch.
>
> It was not off by 1, or else it wouldn't have worked. Below is how I defined 
> `PPLevel`:
>
>   $ git diff UnwrappedLineParser.h
>   diff --git a/clang/lib/Format/UnwrappedLineParser.h 
> b/clang/lib/Format/UnwrappedLineParser.h
>   index b9b106bcc89a..a234f6852e0c 100644
>   --- a/clang/lib/Format/UnwrappedLineParser.h
>   +++ b/clang/lib/Format/UnwrappedLineParser.h
>   @@ -43,6 +43,9 @@ struct UnwrappedLine {
>
>  /// The indent level of the \c UnwrappedLine.
>  unsigned Level;
>   +  /// The \c PPBranchLevel (adjusted for header guards) of the macro 
> definition
>   +  /// this line belongs to.
>   +  unsigned PPLevel;
>
>  /// Whether this \c UnwrappedLine is part of a preprocessor directive.
>  bool InPPDirective;
>   @@ -358,7 +361,7 @@ struct UnwrappedLineNode {
>};
>
>inline UnwrappedLine::UnwrappedLine()
>   -: Level(0), InPPDirective(false), InPragmaDirective(false),
>   +: Level(0), PPLevel(0), InPPDirective(false), InPragmaDirective(false),
>  InMacroBody(false), MustBeDeclaration(false),
>  MatchingOpeningBlockLineIndex(kInvalidIndex) {}
>
>
> Conceptually, I think it's more accurate to make `PPLevel` to mean the PP 
> branching level of the `#define` line, not the first line of the macro body. 
> IMO it may simplify the changes you made to the formatter.

Hmm? Not sure what you mean.

> BTW you still need to change `PPLevel` to `unsigned` and initialize it as 
> requested in D137181#inline-1328385 
> .

Fixed.




Comment at: clang/lib/Format/UnwrappedLineParser.h:66
+  /// #endifPPLevel still at : 0
+  int PPLevel;
+

owenpan wrote:
> goldstein.w.n wrote:
> > owenpan wrote:
> > > You need to initialize `PPLevel` in the constructor. FWIW I'd use 
> > > `unsigned` to be consistent with `Level` above.
> > Will initialize. It's `int` because we do a less than zero check in the 
> > Formatter.
> > It's `int` because we do a less than zero check in the Formatter.
> 
> If you set `PPLevel` to `PPBranchLevel` when there is no header guard, and to 
> `PPBranchLevel + 1`otherwise, `PPLevel` can never be negative.
Sorry didnt see your reply. Fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-09 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n updated this revision to Diff 474447.
goldstein.w.n added a comment.



1. Updating D137181 : [clang-format] Don't 
use 'PPIndentWidth' inside multi-line macros #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Make PPLevel unsigned + Initialize in constructor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

Files:
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5040,6 +5040,254 @@
"  int y = 0;\n"
"}",
style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef X\n"
+   "#define Y  \\\n"
+   "switch (Y) {   \\\n"
+   "case 0:\\\n"
+   "break; \\\n"
+   "case 1:\\\n"
+   "break; \\\n"
+   "}  \\\n"
+   "Z();\n"
+   "#endif",
+   style);
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "if (B) { \\\n"
+   "C(); \\\n"
+   "}\\\n"
+   "}\\\n"
+   "D();\n"
+   "#endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}\n"
+   "#endif",
+   style);
+
+  style.PPIndentWidth = 2;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  style.IndentWidth = 8;
+  verifyFormat("#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "B(); \\\n"
+   "}\\\n"
+   "C();\n"
+   "#endif",
+   style);
+
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef X\n"
+   "# define Y  \\\n"
+   " switch (Y) {   \\\n"
+   " case 0:\\\n"
+   " break; \\\n"
+   " case 1:\\\n"
+   " break; \\\n"
+   " }  \\\n"
+   " Z();\n"
+   "#endif",
+   style);
+  verifyFormat("#ifdef foo\n"
+   "# define bar() \\\n"
+   " if (A) {  \\\n"
+   " B();  \\\n"
+   " } \\\n"
+   " C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "# define lit   \\\n"
+   " if (af) { \\\n"
+   " return duh(); \\\n"
+   " }\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "# ifdef foo\n"
+   "#  define bar()\\\n"
+   "  if (A) { \\\n"
+   "  if (B) { \\\n"
+   "  C(); \\\n"
+   "  }\\\n"
+   "  }\\\n"
+   "  D();\n"
+   "# endif\n"
+

[clang] a86b506 - [NFC] Fixing a comment and some indentations

2022-11-09 Thread Chi Chun Chen via cfe-commits

Author: sandeepkosuri
Date: 2022-11-10T01:02:12-06:00
New Revision: a86b506294bc7b9a921e3e613f49730c5780eb22

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

LOG: [NFC] Fixing a comment and some indentations

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Sema/Scope.h

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 1a4ec43705bc3..a8d2221316a5c 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7640,7 +7640,7 @@ class OMPOrderClause final : public OMPClause {
   /// Location of '('.
   SourceLocation LParenLoc;
 
-  /// A kind of the 'default' clause.
+  /// A kind of the 'order' clause.
   OpenMPOrderClauseKind Kind = OMPC_ORDER_unknown;
 
   /// Start location of the kind in source code.

diff  --git a/clang/include/clang/Sema/Scope.h 
b/clang/include/clang/Sema/Scope.h
index d2acf253552dc..deb011892b850 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -44,11 +44,11 @@ class Scope {
   enum ScopeFlags {
 /// This indicates that the scope corresponds to a function, which
 /// means that labels are set here.
-FnScope   = 0x01,
+FnScope = 0x01,
 
 /// This is a while, do, switch, for, etc that can have break
 /// statements embedded into it.
-BreakScope= 0x02,
+BreakScope = 0x02,
 
 /// This is a while, do, for, which can have continue statements
 /// embedded into it.



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


[PATCH] D137693: [NFC] [C++20] [Modules] [clangd] Add test for code completion for C++20 Named Modules

2022-11-09 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 474445.
ChuanqiXu added a comment.

Add dependency to clangd tests to make sure they can find the corresponding 
rules.


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

https://reviews.llvm.org/D137693

Files:
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/completion-modules.test
  clang-tools-extra/clangd/test/completion-modules2.test
  clang-tools-extra/clangd/test/completion-modules3.test
  clang-tools-extra/clangd/test/completion-modules4.test

Index: clang-tools-extra/clangd/test/completion-modules4.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/completion-modules4.test
@@ -0,0 +1,76 @@
+# Tests that the importee can't find the entities in the global module fragment.
+# RUN: rm -fr %t
+# RUN: mkdir -p %t
+# RUN: split-file %s %t
+#
+# RUN: sed -e "s|DIR|%/t|g" %t/compile_commands.json.tmpl > %t/compile_commands.json
+# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc
+# RUN: %clang++ -std=c++20 %t/A.cppm --precompile -o %t/A.pcm
+# RUN: clangd -lit-test < %t/definition.jsonrpc  | FileCheck %t/definition.jsonrpc
+
+#--- foo.h
+void printA() {}
+
+#--- A.cppm
+module;
+#include "foo.h"
+export module A;
+
+
+#--- Use.cpp
+import A;
+void foo() {
+print
+}
+
+#--- compile_commands.json.tmpl
+[
+{
+  "directory": "DIR",
+  "command": "clang++  -fprebuilt-module-path=DIR -std=c++20 -o DIR/main.cpp.o -c DIR/Use.cpp",
+  "file": "DIR/Use.cpp"
+}
+]
+
+#--- definition.jsonrpc.tmpl
+{
+  "jsonrpc": "2.0",
+  "id": 0,
+  "method": "initialize",
+  "params": {
+"processId": 123,
+"rootPath": "clangd",
+"capabilities": {
+  "textDocument": {
+"completion": {
+  "completionItem": {
+"snippetSupport": true
+  }
+}
+  }
+},
+"trace": "off"
+  }
+}
+---
+{
+  "jsonrpc": "2.0",
+  "method": "textDocument/didOpen",
+  "params": {
+"textDocument": {
+  "uri": "file://DIR/Use.cpp",
+  "languageId": "cpp",
+  "version": 1,
+  "text": "import A;\nvoid foo() {\nprint\n}\n"
+}
+  }
+}
+
+# CHECK-NOT: "filterText": "printA"
+
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}}
+---
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/test/completion-modules3.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/completion-modules3.test
@@ -0,0 +1,97 @@
+# Tests that the importee can find the exported entities.
+# RUN: rm -fr %t
+# RUN: mkdir -p %t
+# RUN: split-file %s %t
+#
+# RUN: sed -e "s|DIR|%/t|g" %t/compile_commands.json.tmpl > %t/compile_commands.json
+# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc
+# RUN: %clang++ -std=c++20 %t/A.cppm --precompile -o %t/A.pcm
+# RUN: clangd -lit-test < %t/definition.jsonrpc  | FileCheck -strict-whitespace %t/definition.jsonrpc
+
+#--- A.cppm
+export module A;
+void printA() {}
+
+#--- Use.cpp
+export module A:part;
+import A;
+void foo() {
+print
+}
+
+#--- compile_commands.json.tmpl
+[
+{
+  "directory": "DIR",
+  "command": "clang++  -fprebuilt-module-path=DIR -std=c++20 -o DIR/main.cpp.o -c DIR/Use.cpp",
+  "file": "DIR/Use.cpp"
+}
+]
+
+#--- definition.jsonrpc.tmpl
+{
+  "jsonrpc": "2.0",
+  "id": 0,
+  "method": "initialize",
+  "params": {
+"processId": 123,
+"rootPath": "clangd",
+"capabilities": {
+  "textDocument": {
+"completion": {
+  "completionItem": {
+"snippetSupport": true
+  }
+}
+  }
+},
+"trace": "off"
+  }
+}
+---
+{
+  "jsonrpc": "2.0",
+  "method": "textDocument/didOpen",
+  "params": {
+"textDocument": {
+  "uri": "file://DIR/Use.cpp",
+  "languageId": "cpp",
+  "version": 1,
+  "text": "export module A:part;\nimport A;\nvoid foo() {\nprint\n}\n"
+}
+  }
+}
+
+# CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"detail": "void",
+# CHECK-NEXT:"filterText": "printA",
+# CHECK-NEXT:"insertText": "printA()",
+# CHECK-NEXT:"insertTextFormat": 2,
+# CHECK-NEXT:"kind": 3,
+# CHECK-NEXT:"label": " printA()",
+# CHECK-NEXT:"score":
+# CHECK-NEXT:"sortText": "409fc4f5printA",
+# CHECK-NEXT:"textEdit": {
+# CHECK-NEXT:  "newText": "printA()",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 6,
+# CHECK-NEXT:  "line": 3
+# CHECK-NEXT:},
+# CHECK-NEXT: 

[PATCH] D137765: [NFC] Fixing a comment and some indentations

2022-11-09 Thread Sandeep via Phabricator via cfe-commits
sandeepkosuri created this revision.
sandeepkosuri added reviewers: cchen, ABataev, RitanyaB, soumitra.
Herald added a project: All.
sandeepkosuri requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137765

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Sema/Scope.h


Index: clang/include/clang/Sema/Scope.h
===
--- clang/include/clang/Sema/Scope.h
+++ clang/include/clang/Sema/Scope.h
@@ -44,11 +44,11 @@
   enum ScopeFlags {
 /// This indicates that the scope corresponds to a function, which
 /// means that labels are set here.
-FnScope   = 0x01,
+FnScope = 0x01,
 
 /// This is a while, do, switch, for, etc that can have break
 /// statements embedded into it.
-BreakScope= 0x02,
+BreakScope = 0x02,
 
 /// This is a while, do, for, which can have continue statements
 /// embedded into it.
Index: clang/include/clang/AST/OpenMPClause.h
===
--- clang/include/clang/AST/OpenMPClause.h
+++ clang/include/clang/AST/OpenMPClause.h
@@ -7640,7 +7640,7 @@
   /// Location of '('.
   SourceLocation LParenLoc;
 
-  /// A kind of the 'default' clause.
+  /// A kind of the 'order' clause.
   OpenMPOrderClauseKind Kind = OMPC_ORDER_unknown;
 
   /// Start location of the kind in source code.


Index: clang/include/clang/Sema/Scope.h
===
--- clang/include/clang/Sema/Scope.h
+++ clang/include/clang/Sema/Scope.h
@@ -44,11 +44,11 @@
   enum ScopeFlags {
 /// This indicates that the scope corresponds to a function, which
 /// means that labels are set here.
-FnScope   = 0x01,
+FnScope = 0x01,
 
 /// This is a while, do, switch, for, etc that can have break
 /// statements embedded into it.
-BreakScope= 0x02,
+BreakScope = 0x02,
 
 /// This is a while, do, for, which can have continue statements
 /// embedded into it.
Index: clang/include/clang/AST/OpenMPClause.h
===
--- clang/include/clang/AST/OpenMPClause.h
+++ clang/include/clang/AST/OpenMPClause.h
@@ -7640,7 +7640,7 @@
   /// Location of '('.
   SourceLocation LParenLoc;
 
-  /// A kind of the 'default' clause.
+  /// A kind of the 'order' clause.
   OpenMPOrderClauseKind Kind = OMPC_ORDER_unknown;
 
   /// Start location of the kind in source code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D137181#3918117 , @goldstein.w.n 
wrote:

>>> maybe you did something different?
>>
>> Here is what I did:
>>
>>   $ git diff UnwrappedLineParser.cpp
>>   diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
>> b/clang/lib/Format/UnwrappedLineParser.cpp
>>   index 25d9018fa109..ab3b9c53ee54 100644
>>   --- a/clang/lib/Format/UnwrappedLineParser.cpp
>>   +++ b/clang/lib/Format/UnwrappedLineParser.cpp
>>   @@ -197,6 +197,7 @@ public:
>>PreBlockLine = std::move(Parser.Line);
>>Parser.Line = std::make_unique();
>>Parser.Line->Level = PreBlockLine->Level;
>>   +Parser.Line->PPLevel = PreBlockLine->PPLevel;
>>Parser.Line->InPPDirective = PreBlockLine->InPPDirective;
>>Parser.Line->InMacroBody = PreBlockLine->InMacroBody;
>>  }
>>   @@ -1274,6 +1275,10 @@ void UnwrappedLineParser::parsePPDefine() {
>>  addUnwrappedLine();
>>  ++Line->Level;
>>  Line->InMacroBody = true;
>>   +  if (Style.IndentPPDirectives != FormatStyle::PPDIS_None) {
>>   +Line->PPLevel =
>>   +IncludeGuard == IG_Defined ? PPBranchLevel : PPBranchLevel + 1;
>>   +  }
>>
>>  // Errors during a preprocessor directive can only affect the layout of 
>> the
>>  // preprocessor directive, and thus we ignore them. An alternative 
>> approach
>
> You're right this works (but off by one). Updated patch.

It was not off by 1, or else it wouldn't have worked. Below is how I defined 
`PPLevel`:

  $ git diff UnwrappedLineParser.h
  diff --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
  index b9b106bcc89a..a234f6852e0c 100644
  --- a/clang/lib/Format/UnwrappedLineParser.h
  +++ b/clang/lib/Format/UnwrappedLineParser.h
  @@ -43,6 +43,9 @@ struct UnwrappedLine {
   
 /// The indent level of the \c UnwrappedLine.
 unsigned Level;
  +  /// The \c PPBranchLevel (adjusted for header guards) of the macro 
definition
  +  /// this line belongs to.
  +  unsigned PPLevel;
   
 /// Whether this \c UnwrappedLine is part of a preprocessor directive.
 bool InPPDirective;
  @@ -358,7 +361,7 @@ struct UnwrappedLineNode {
   };
   
   inline UnwrappedLine::UnwrappedLine()
  -: Level(0), InPPDirective(false), InPragmaDirective(false),
  +: Level(0), PPLevel(0), InPPDirective(false), InPragmaDirective(false),
 InMacroBody(false), MustBeDeclaration(false),
 MatchingOpeningBlockLineIndex(kInvalidIndex) {}
   

Conceptually, I think it's more accurate to make `PPLevel` to mean the PP 
branching level of the `#define` line, not the first line of the macro body. 
IMO it may simplify the changes you made to the formatter.

BTW you still need to change `PPLevel` to `unsigned` and initialize it as 
requested in D137181#inline-1328385 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

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

Use existing error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: unsupported option '-p' for target 's390x-none-zos'
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: rror: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck -check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: unsupported option '-p' for target 's390x-none-zos'
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: rror: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 
___
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-09 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

Another test case for function pointers is here: F25259090: tmp.c 


Before applying these changes, it is:

  clang-format -style="{BasedOnStyle: LLVM, AlignAfterOpenBracket: 
BlockIndent}" tmp.c
  int foo(long l) { return l; }
  
  int main() {
int 
(*abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
)(long) = foo;
  
(*abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
)(1000L);
  }

After applying these changes, it is:

  clang-format -style="{BasedOnStyle: LLVM, AlignAfterOpenBracket: 
BlockIndent}" tmp.c
  int foo(long l) { return l; }
  
  int main() {
int 
(*abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679)(
long
) = foo;
  
(*abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679)(
1000L
);
  }

The function pointer declaration is still a little strange-looking, but I 
believe it is more in line with the intent behind the BlockIndent style.


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] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-09 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

A test case from the GitHub Issue 
https://github.com/llvm/llvm-project/issues/57250 is attached here: F25258989: 
test.c 

When run without these changes, it yields:
clang-format -style="{BasedOnStyle: LLVM, AlignAfterOpenBracket: BlockIndent}" 
test.c

  int foo(void) {
int x = (int
)(10 + 20 + 10 + 20 + 10 + 20 + 10 + 20 +
  10 + 20 + 10 + 20 + 10 + 20 + 10 + 20 +
  10 + 20);
int y = 10 + 20 + 10 + 20 + 10 + 20 + 10 +
20 + 10 + 20 + 10 + 20 + 10 + 20 +
10 + 20 + 10 + 20;
  }

When run with these changes, it yields:
clang-format -style="{BasedOnStyle: LLVM, AlignAfterOpenBracket: BlockIndent}" 
test.c

  int foo(void) {
int x = (int)(10 + 20 + 10 + 20 + 10 + 20 + 10 +
  20 + 10 + 20 + 10 + 20 + 10 + 20 +
  10 + 20 + 10 + 20);
int y = 10 + 20 + 10 + 20 + 10 + 20 + 10 +
20 + 10 + 20 + 10 + 20 + 10 + 20 +
10 + 20 + 10 + 20;
  }


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] D137762: [clang-format] avoid breaking )( with BlockIndent

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

Add a fix to enable breaking for continuation after a )(


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


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5001,7 +5001,10 @@
   return false;
 }
 const FormatToken *Previous = Right.MatchingParen->Previous;
-return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+// avoid breaking when there is an opening parens immediately following
+// a closing parens, such as in cast operators and indirect function calls
+return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||
+ (Right.Next && Right.Next->is(tok::l_paren)));
   }
 
   // Allow breaking after a trailing annotation, e.g. after a method
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -717,7 +717,7 @@
 Style.Cpp11BracedListStyle)) &&
   State.Column > getNewLineColumn(State) &&
   (!Previous.Previous || !Previous.Previous->isOneOf(
- tok::kw_for, tok::kw_while, tok::kw_switch)) 
&&
+  tok::r_paren,  tok::kw_for, tok::kw_while, tok::kw_switch)) 
&&
   // Don't do this for simple (no expressions) one-argument function calls
   // as that feels like needlessly wasting whitespace, e.g.:
   //


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5001,7 +5001,10 @@
   return false;
 }
 const FormatToken *Previous = Right.MatchingParen->Previous;
-return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+// avoid breaking when there is an opening parens immediately following
+// a closing parens, such as in cast operators and indirect function calls
+return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||
+ (Right.Next && Right.Next->is(tok::l_paren)));
   }
 
   // Allow breaking after a trailing annotation, e.g. after a method
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -717,7 +717,7 @@
 Style.Cpp11BracedListStyle)) &&
   State.Column > getNewLineColumn(State) &&
   (!Previous.Previous || !Previous.Previous->isOneOf(
- tok::kw_for, tok::kw_while, tok::kw_switch)) &&
+  tok::r_paren,  tok::kw_for, tok::kw_while, tok::kw_switch)) &&
   // Don't do this for simple (no expressions) one-argument function calls
   // as that feels like needlessly wasting whitespace, e.g.:
   //
___
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-09 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 474429.
gedare added a comment.

Allow line breaks in a continuation with BlockIndent after )(


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


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -717,7 +717,7 @@
 Style.Cpp11BracedListStyle)) &&
   State.Column > getNewLineColumn(State) &&
   (!Previous.Previous || !Previous.Previous->isOneOf(
- tok::kw_for, tok::kw_while, tok::kw_switch)) 
&&
+  tok::r_paren,  tok::kw_for, tok::kw_while, tok::kw_switch)) 
&&
   // Don't do this for simple (no expressions) one-argument function calls
   // as that feels like needlessly wasting whitespace, e.g.:
   //


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -717,7 +717,7 @@
 Style.Cpp11BracedListStyle)) &&
   State.Column > getNewLineColumn(State) &&
   (!Previous.Previous || !Previous.Previous->isOneOf(
- tok::kw_for, tok::kw_while, tok::kw_switch)) &&
+  tok::r_paren,  tok::kw_for, tok::kw_while, tok::kw_switch)) &&
   // Don't do this for simple (no expressions) one-argument function calls
   // as that feels like needlessly wasting whitespace, e.g.:
   //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-11-09 Thread Sean via Phabricator via cfe-commits
SeanP added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:241
+def err_option_unsupported_zos: Error<
+  "the clang compiler does not support the '%0' option on z/OS.">;
+

Rather than saying "on z/OS" you should say "by the target '%1'" and pass in 
the triple.  There must be the equivalent message already.  If not rename the 
message too (eg. err_option_unsupported_target).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137756

___
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-09 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

Something about this is still a bit off though. This change seems to prevent 
any more breaking on the line. For example, the test example given in GitHub 
Issue https://github.com/llvm/llvm-project/issues/57250 when formatted with 
this change becomes:

`clang-format -style="{BasedOnStyle: LLVM, AlignAfterOpenBracket: BlockIndent}" 
test.c

int foo(void) {

  int x =
  (int)(10 + 20 + 10 + 20 + 10 + 20 + 10 + 
20 + 10 + 20 + 10 + 20 + 10 + 20 + 10 + 20 
+ 10 + 20);
  int y = 10 + 20 + 10 + 20 + 10 + 20 + 10 +
  20 + 10 + 20 + 10 + 20 + 10 + 20 +
  10 + 20 + 10 + 20;

}
`


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] D127855: [OpenMP] Basic parse and sema support for modifiers in order clause

2022-11-09 Thread Sandeep via Phabricator via cfe-commits
sandeepkosuri added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10634
   "OpenMP constructs may not be nested inside an atomic region">;
+def err_omp_prohibited_region_order
+: Error<"construct %0 not allowed in a region associated with a directive "

ABataev wrote:
> Do you have the test for this error message?
I forgot to add a test for this, I will do it. Thanks for noticing.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:875
+  /// false - otherwise.
+  bool HasOrderConcurrent() const {
+if (const SharingMapTy *Top = getTopOfStackOrNull())

ABataev wrote:
> `isOrderConcurrent`
This function is never used, So I will remove this altogether. Thanks for 
pointing this out.


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

https://reviews.llvm.org/D127855

___
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-09 Thread Gedare Bloom via Phabricator via cfe-commits
gedare created this revision.
Herald added a project: All.
gedare requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The BracketAlignmentStyle BAS_BlockIndent was forcing breaks before a
closing right parenthesis yielding strange-looking results in case of
code structures that have a left parens immediately following a right
parens ")(" such as is seen with indirect function calls via function
pointers and with type casting.

See GitHub issues #57250 and #58496.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137762

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5001,7 +5001,10 @@
   return false;
 }
 const FormatToken *Previous = Right.MatchingParen->Previous;
-return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+// avoid breaking when there is an opening parens immediately following
+// a closing parens, such as in cast operators and indirect function calls
+return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||
+ (Right.Next && Right.Next->is(tok::l_paren)));
   }
 
   // Allow breaking after a trailing annotation, e.g. after a method


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5001,7 +5001,10 @@
   return false;
 }
 const FormatToken *Previous = Right.MatchingParen->Previous;
-return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+// avoid breaking when there is an opening parens immediately following
+// a closing parens, such as in cast operators and indirect function calls
+return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||
+ (Right.Next && Right.Next->is(tok::l_paren)));
   }
 
   // Allow breaking after a trailing annotation, e.g. after a method
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137760: Add FP8 E4M3 support to APFloat.

2022-11-09 Thread Reed Wanderman-Milne via Phabricator via cfe-commits
reedwm created this revision.
reedwm added reviewers: stellaraccident, bkramer, rengolin, jpienaar.
Herald added subscribers: bzcheeseman, rriddle, hiraditya, kristof.beyls.
Herald added a project: All.
reedwm requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer.
Herald added projects: clang, LLVM.

NVIDIA, ARM, and Intel recently introduced two new FP8 formats, as described in 
the paper: https://arxiv.org/abs/2209.05433. The first of the two FP8 dtypes, 
E5M2, was added in https://reviews.llvm.org/D133823. This change adds the 
second of the two: E4M3.

There is an RFC for adding the FP8 dtypes here: 
https://discourse.llvm.org/t/rfc-add-apfloat-and-mlir-type-support-for-fp8-e5m2/65279.
 I spoke with the RFC's author, Stella, and she gave me the go ahead to 
implement the E4M3 type. The name of the E4M3 type in APFloat is Float8E4M3FN, 
as discussed in the RFC. The "FN" means only Finite and NaN values are 
supported.

Unlike E5M2, E4M3 has different behavior from IEEE types in regards to Inf and 
NaN values. There are no Inf values, and NaN is represented when the exponent 
and mantissa bits are all 1s. To represent these differences in APFloat, I 
added an enum field, fltNonfiniteBehavior, to the fltSemantics struct. The 
possible enum values are IEEE754 and NanOnly. Only Float8E4M3FN has the NanOnly 
behavior.

After this change is submitted, I plan on adding the Float8E4M3FN type to MLIR, 
in the same way as E5M2 was added in https://reviews.llvm.org/D133823.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137760

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/MicrosoftMangle.cpp
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp
  llvm/unittests/ADT/APFloatTest.cpp

Index: llvm/unittests/ADT/APFloatTest.cpp
===
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -1683,6 +1683,7 @@
 TEST(APFloatTest, getLargest) {
   EXPECT_EQ(3.402823466e+38f, APFloat::getLargest(APFloat::IEEEsingle()).convertToFloat());
   EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble()).convertToDouble());
+  EXPECT_EQ(448, APFloat::getLargest(APFloat::Float8E4M3FN()).convertToDouble());
 }
 
 TEST(APFloatTest, getSmallest) {
@@ -1766,6 +1767,8 @@
   {::x87DoubleExtended(), true, {0, 0x8000ULL}, 2},
   {::Float8E5M2(), false, {0, 0}, 1},
   {::Float8E5M2(), true, {0x80ULL, 0}, 1},
+  {::Float8E4M3FN(), false, {0, 0}, 1},
+  {::Float8E4M3FN(), true, {0x80ULL, 0}, 1},
   };
   const unsigned NumGetZeroTests = 12;
   for (unsigned i = 0; i < NumGetZeroTests; ++i) {
@@ -3665,6 +3668,16 @@
 EXPECT_EQ(f1.mod(f2), APFloat::opOK);
 EXPECT_TRUE(f1.bitwiseIsEqual(expected));
   }
+  {
+// Test E4M3FN mod where the LHS exponent is maxExponent (8) and the RHS is
+// the max value whose exponent is minExponent (-6). This requires special
+// logic in the mod implementation to prevent overflow to NaN.
+APFloat f1(APFloat::Float8E4M3FN(), "0x1p8");// 256
+APFloat f2(APFloat::Float8E4M3FN(), "0x1.ep-6"); // 0.029296875
+APFloat expected(APFloat::Float8E4M3FN(), "0x1p-8"); // 0.00390625
+EXPECT_EQ(f1.mod(f2), APFloat::opOK);
+EXPECT_TRUE(f1.bitwiseIsEqual(expected));
+  }
 }
 
 TEST(APFloatTest, remainder) {
@@ -4756,6 +4769,389 @@
   EXPECT_TRUE(ilogb(F) == -1);
 }
 
+TEST(APFloatTest, ConvertE4M3FNToE5M2) {
+  bool losesInfo;
+  APFloat test(APFloat::Float8E4M3FN(), "1.0");
+  APFloat::opStatus status = test.convert(
+  APFloat::Float8E5M2(), APFloat::rmNearestTiesToEven, );
+  EXPECT_EQ(1.0f, test.convertToFloat());
+  EXPECT_FALSE(losesInfo);
+  EXPECT_EQ(status, APFloat::opOK);
+
+  test = APFloat(APFloat::Float8E4M3FN(), "0.0");
+  status = test.convert(APFloat::Float8E5M2(), APFloat::rmNearestTiesToEven,
+);
+  EXPECT_EQ(0.0f, test.convertToFloat());
+  EXPECT_FALSE(losesInfo);
+  EXPECT_EQ(status, APFloat::opOK);
+
+  test = APFloat(APFloat::Float8E4M3FN(), "0x1.2p0"); // 1.125
+  status = test.convert(APFloat::Float8E5M2(), APFloat::rmNearestTiesToEven,
+);
+  EXPECT_EQ(0x1.0p0 /* 1.0 */, test.convertToFloat());
+  EXPECT_TRUE(losesInfo);
+  EXPECT_EQ(status, APFloat::opInexact);
+
+  test = APFloat(APFloat::Float8E4M3FN(), "0x1.6p0"); // 1.375
+  status = test.convert(APFloat::Float8E5M2(), APFloat::rmNearestTiesToEven,
+);
+  EXPECT_EQ(0x1.8p0 /* 1.5 */, test.convertToFloat());
+  EXPECT_TRUE(losesInfo);
+  EXPECT_EQ(status, APFloat::opInexact);
+
+  // Convert E4M3 denormal to E5M2 normal. Should not be truncated, despite the
+  // destination format having one fewer significand bit
+  test = APFloat(APFloat::Float8E4M3FN(), "0x1.Cp-7");
+  status = test.convert(APFloat::Float8E5M2(), APFloat::rmNearestTiesToEven,
+);
+  EXPECT_EQ(0x1.Cp-7, 

[PATCH] D136146: [Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu options

2022-11-09 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 474414.
SixWeining added a comment.

Revise the `err_drv_loongarch_invalid_mfpu_EQ` diagnostic info. Add necessary 
braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136146

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/loongarch-default-features.c
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-mfpu-error.c
  clang/test/Driver/loongarch-mfpu.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c
  llvm/include/llvm/Support/LoongArchTargetParser.def
  llvm/include/llvm/Support/LoongArchTargetParser.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/LoongArchTargetParser.cpp

Index: llvm/lib/Support/LoongArchTargetParser.cpp
===
--- /dev/null
+++ llvm/lib/Support/LoongArchTargetParser.cpp
@@ -0,0 +1,50 @@
+//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- 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
+//
+//===--===//
+//
+// This file implements a target parser to recognise LoongArch hardware features
+// such as CPU/ARCH and extension names.
+//
+//===--===//
+
+#include "llvm/Support/LoongArchTargetParser.h"
+#include "llvm/ADT/StringSwitch.h"
+
+using namespace llvm;
+using namespace llvm::LoongArch;
+
+const FeatureInfo AllFeatures[] = {
+#define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
+#include "llvm/Support/LoongArchTargetParser.def"
+};
+
+const ArchInfo AllArchs[] = {
+#define LOONGARCH_ARCH(NAME, KIND, FEATURES)   \
+  {NAME, LoongArch::ArchKind::KIND, FEATURES},
+#include "llvm/Support/LoongArchTargetParser.def"
+};
+
+LoongArch::ArchKind LoongArch::parseArch(StringRef Arch) {
+  for (const auto A : AllArchs)
+if (A.Name == Arch)
+  return A.Kind;
+
+  return LoongArch::ArchKind::AK_INVALID;
+}
+
+bool LoongArch::getArchFeatures(StringRef Arch,
+std::vector ) {
+  for (const auto A : AllArchs) {
+if (A.Name == Arch) {
+  for (const auto F : AllFeatures)
+if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID)
+  Features.push_back(F.Name);
+  return true;
+}
+  }
+  return false;
+}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -187,6 +187,7 @@
   LineIterator.cpp
   Locale.cpp
   LockFileManager.cpp
+  LoongArchTargetParser.cpp
   LowLevelType.cpp
   ManagedStatic.cpp
   MathExtras.cpp
Index: llvm/include/llvm/Support/LoongArchTargetParser.h
===
--- /dev/null
+++ llvm/include/llvm/Support/LoongArchTargetParser.h
@@ -0,0 +1,74 @@
+//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- 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
+//
+//===--===//
+//
+// This file implements a target parser to recognise LoongArch hardware features
+// such as CPU/ARCH and extension names.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#define LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+
+#include "llvm/ADT/Triple.h"
+#include 
+
+namespace llvm {
+class StringRef;
+
+namespace LoongArch {
+
+enum FeatureKind : uint32_t {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+
+  // 64-bit ISA is available.
+  FK_64BIT = 1 << 1,
+
+  // Single-precision floating-point instructions are available.
+  FK_FP32 = 1 << 2,
+
+  // Double-precision floating-point instructions are available.
+  FK_FP64 = 1 << 3,
+
+  // Loongson SIMD Extension is available.
+  FK_LSX = 1 << 4,
+
+  // Loongson Advanced SIMD Extension is available.
+  FK_LASX = 1 << 5,
+
+  // Loongson Binary Translation Extension is available.
+  FK_LBT = 1 << 6,
+
+  // Loongson Virtualization Extension is available.
+  FK_LVZ = 1 << 7,
+};
+
+struct FeatureInfo {
+  StringRef Name;
+  FeatureKind Kind;
+};
+
+enum class 

[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-11-09 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Throw an error when trying to compile with `-p` or `-pg` on z/OS,
as the platform does not support `prof` and `gprof`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137756

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: the clang compiler does not support the '-p' option on 
z/OS.
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: the clang compiler does not support the '-pg' option 
on z/OS.
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,12 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_option_unsupported_zos) << ArgString;
+  }
+}
 
 ZOS::~ZOS() {}
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -237,6 +237,9 @@
 def err_arch_unsupported_isa
   : Error<"architecture '%0' does not support '%1' execution mode">;
 
+def err_option_unsupported_zos: Error<
+  "the clang compiler does not support the '%0' option on z/OS.">;
+
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck -check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: the clang compiler does not support the '-p' option on z/OS.
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: the clang compiler does not support the '-pg' option on z/OS.
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,12 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_option_unsupported_zos) << ArgString;
+  }
+}
 
 ZOS::~ZOS() {}
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -237,6 +237,9 @@
 def err_arch_unsupported_isa
   : Error<"architecture '%0' does not support '%1' execution mode">;
 
+def err_option_unsupported_zos: Error<
+  "the clang compiler does not support the '%0' option on z/OS.">;
+
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137650: [clangd] Implement hover for string literals

2022-11-09 Thread v1nh1shungry via Phabricator via cfe-commits
v1nh1shungry added a comment.

@kadircet Thanks for your suggestions!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137650

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


[PATCH] D137650: [clangd] Implement hover for string literals

2022-11-09 Thread v1nh1shungry via Phabricator via cfe-commits
v1nh1shungry updated this revision to Diff 474399.
v1nh1shungry added a comment.

Apply the reviewing suggestions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137650

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1300,7 +1300,6 @@
   "auto x = ^42.0i;",
   "auto x = ^42;",
   "auto x = ^nullptr;",
-  "auto x = ^\"asdf\";",
   };
 
   for (const auto  : Tests) {
@@ -1326,6 +1325,12 @@
  HI.Type = "char";
  HI.Value = "65 (0x41)";
}},
+  {"auto s = ^[[\"Hello, world!\"]]; // string literal",
+   [](HoverInfo ) {
+ HI.Name = "String Literal";
+ HI.Size = 14;
+ HI.Type = "const char[14]";
+   }},
   {
   R"cpp(// Local variable
 int main() {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -777,6 +777,17 @@
   return HI;
 }
 
+HoverInfo getStringLiteralContents(const StringLiteral *SL,
+   const PrintingPolicy ) {
+  HoverInfo HI;
+
+  HI.Name = "String Literal";
+  HI.Size = (SL->getLength() + 1) * SL->getCharByteWidth();
+  HI.Type = SL->getType().getAsString(PP).c_str();
+
+  return HI;
+}
+
 bool isLiteral(const Expr *E) {
   // Unfortunately there's no common base Literal classes inherits from
   // (apart from Expr), therefore these exclusions.
@@ -785,7 +796,7 @@
  llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
- llvm::isa(E) || llvm::isa(E);
+ llvm::isa(E);
 }
 
 llvm::StringLiteral getNameForExpr(const Expr *E) {
@@ -810,6 +821,9 @@
 return llvm::None;
 
   HoverInfo HI;
+  // Print the type and the size for string literals
+  if (const StringLiteral *SL = dyn_cast(E))
+return getStringLiteralContents(SL, PP);
   // For `this` expr we currently generate hover with pointee type.
   if (const CXXThisExpr *CTE = dyn_cast(E))
 return getThisExprHoverContents(CTE, AST.getASTContext(), PP);


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1300,7 +1300,6 @@
   "auto x = ^42.0i;",
   "auto x = ^42;",
   "auto x = ^nullptr;",
-  "auto x = ^\"asdf\";",
   };
 
   for (const auto  : Tests) {
@@ -1326,6 +1325,12 @@
  HI.Type = "char";
  HI.Value = "65 (0x41)";
}},
+  {"auto s = ^[[\"Hello, world!\"]]; // string literal",
+   [](HoverInfo ) {
+ HI.Name = "String Literal";
+ HI.Size = 14;
+ HI.Type = "const char[14]";
+   }},
   {
   R"cpp(// Local variable
 int main() {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -777,6 +777,17 @@
   return HI;
 }
 
+HoverInfo getStringLiteralContents(const StringLiteral *SL,
+   const PrintingPolicy ) {
+  HoverInfo HI;
+
+  HI.Name = "String Literal";
+  HI.Size = (SL->getLength() + 1) * SL->getCharByteWidth();
+  HI.Type = SL->getType().getAsString(PP).c_str();
+
+  return HI;
+}
+
 bool isLiteral(const Expr *E) {
   // Unfortunately there's no common base Literal classes inherits from
   // (apart from Expr), therefore these exclusions.
@@ -785,7 +796,7 @@
  llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
- llvm::isa(E) || llvm::isa(E);
+ llvm::isa(E);
 }
 
 llvm::StringLiteral getNameForExpr(const Expr *E) {
@@ -810,6 +821,9 @@
 return llvm::None;
 
   HoverInfo HI;
+  // Print the type and the size for string literals
+  if (const StringLiteral *SL = dyn_cast(E))
+return getStringLiteralContents(SL, PP);
   // For `this` expr we currently generate hover with pointee type.
   if (const CXXThisExpr *CTE = dyn_cast(E))
 return getThisExprHoverContents(CTE, AST.getASTContext(), PP);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137755: [clang-format] Treats &/&& as reference when followed by ',' or ')'.

2022-11-09 Thread Micah Weston via Phabricator via cfe-commits
red1bluelost created this revision.
red1bluelost added a reviewer: curdeius.
Herald added a project: All.
red1bluelost requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Ran into an issue where function declarations inside function scopes or uses
of sizeof inside a function would treat the && in 'sizeof(Type &&)' as a binary
operator.

Attempt to fix this by assuming reference when followed by ',' or ')'. Also adds
tests for these.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137755

Files:
  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
@@ -2132,6 +2132,10 @@
   verifyFormat("int *a = f1();", Style);
   verifyFormat("int  = f2();", Style);
   verifyFormat("int & = f3();", Style);
+  verifyFormat("int f3() { return sizeof(Foo &); }", Style);
+  verifyFormat("int f4() { return sizeof(Foo &&); }", Style);
+  verifyFormat("void f5() { int f6(Foo &, Bar &); }", Style);
+  verifyFormat("void f5() { int f6(Foo &&, Bar &&); }", Style);
   verifyFormat("for (auto a = 0, b = 0; const auto  : {1, 2, 3})", Style);
   verifyFormat("for (auto a = 0, b = 0; const int  : {1, 2, 3})", Style);
   verifyFormat("for (auto a = 0, b = 0; const Foo  : {1, 2, 3})", Style);
@@ -2171,6 +2175,10 @@
   verifyFormat("int* a = f1();", Style);
   verifyFormat("int& b = f2();", Style);
   verifyFormat("int&& c = f3();", Style);
+  verifyFormat("int f3() { return sizeof(Foo&); }", Style);
+  verifyFormat("int f4() { return sizeof(Foo&&); }", Style);
+  verifyFormat("void f5() { int f6(Foo&, Bar&); }", Style);
+  verifyFormat("void f5() { int f6(Foo&&, Bar&&); }", Style);
   verifyFormat("for (auto a = 0, b = 0; const auto& c : {1, 2, 3})", Style);
   verifyFormat("for (auto a = 0, b = 0; const int& c : {1, 2, 3})", Style);
   verifyFormat("for (auto a = 0, b = 0; const Foo& c : {1, 2, 3})", Style);
@@ -2211,6 +2219,10 @@
   verifyFormat("int *a = f1();", Style);
   verifyFormat("int& b = f2();", Style);
   verifyFormat("int&& c = f3();", Style);
+  verifyFormat("int f3() { return sizeof(Foo&); }", Style);
+  verifyFormat("int f4() { return sizeof(Foo&&); }", Style);
+  verifyFormat("void f5() { int f6(Foo&, Bar&); }", Style);
+  verifyFormat("void f5() { int f6(Foo&&, Bar&&); }", Style);
   verifyFormat("for (auto a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo *c : {1, 2, 3})", Style);
@@ -2232,6 +2244,10 @@
   verifyFormat("int* a = f1();", Style);
   verifyFormat("int & b = f2();", Style);
   verifyFormat("int && c = f3();", Style);
+  verifyFormat("int f3() { return sizeof(Foo &); };", Style);
+  verifyFormat("int f4() { return sizeof(Foo &&); };", Style);
+  verifyFormat("void f5() { int f6(Foo &, Bar &); };", Style);
+  verifyFormat("void f5() { int f6(Foo &&, Bar &&); };", Style);
   verifyFormat("for (auto a = 0, b = 0; const auto & c : {1, 2, 3})", Style);
   verifyFormat("for (auto a = 0, b = 0; const int & c : {1, 2, 3})", Style);
   verifyFormat("for (auto a = 0, b = 0; const Foo & c : {1, 2, 3})", Style);
@@ -2268,6 +2284,10 @@
   verifyFormat("int * a = f1();", Style);
   verifyFormat("int  = f2();", Style);
   verifyFormat("int & = f3();", Style);
+  verifyFormat("int f3() { return sizeof(Foo &); };", Style);
+  verifyFormat("int f4() { return sizeof(Foo &&); };", Style);
+  verifyFormat("void f5() { int f6(Foo &, Bar &); };", Style);
+  verifyFormat("void f5() { int f6(Foo &&, Bar &&); };", Style);
   verifyFormat("for (auto a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
@@ -8981,7 +9001,7 @@
   "\"long 
literal\");");
   verifyFormat("someFunction(\"Always break between multi-line\"\n"
" \" string literals\",\n"
-   " and, other, parameters);");
+   " also, other, parameters);");
   EXPECT_EQ("fun + \"1243\" /* comment */\n"
 "  \"5678\";",
 format("fun + \"1243\" /* comment */\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2351,7 +2351,8 @@
   return TT_BinaryOperator;
 
 if (!NextToken ||
-NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept) ||
+NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept, 
tok::comma,
+   tok::r_paren) ||
 

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

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

Update the recently-added 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
@@ -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 \
@@ -189,6 +193,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 +222,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,11 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back("-L/lib/profiled");
+  CmdArgs.push_back("-L/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
@@ -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 \
@@ -189,6 +193,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 +222,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,11 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back("-L/lib/profiled");
+  CmdArgs.push_back("-L/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][p]Enable -p Functionality

2022-11-09 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

A test case will be added shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137753

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


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

2022-11-09 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a subscriber: ormris.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This patch enables general, non-platform-specific `-p` functionality
into Clang to create parity with GCC. Specifically, this patch
creates a new CodeGen option for `-p` and allows it to be used
as an instrument for profiling.

A side effect of this change is that the CodeGen option for `-pg`
was renamed from `InstrumentForProfiling` to `InstrumentForProfilingGraph`,
as profiling with `-pg` provides call-graph information while `-p` does not.

The purpose of the `-p` flag is similar to that of `-pg`, but the
results are analyzed with the `prof` tool as opposed to the `gprof` tool.
More details can be found in this RFC post:
https://discourse.llvm.org/t/rfc-add-p-driver-support-to-clang/66013?u=francii

It is up to each vendor to implement their specific behaviour of `-p`.


Repository:
  rG LLVM Github Monorepo

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/Clang.cpp


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 ,
   const llvm::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/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.InstrumentForProfiling) {
+CodeGenOpts.InstrumentForProfiling ||
+CodeGenOpts.InstrumentForProfilingGraph) {
   PB.registerPipelineStartEPCallback(
   [](ModulePassManager , OptimizationLevel Level) {
 MPM.addPass(createModuleToFunctionPassAdaptor(
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4094,8 +4094,10 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
-def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
+def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
+  MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
   HelpText<"Use pipes between commands, when possible">;
 def prebind__all__twolevel__modules : Flag<["-"], 
"prebind_all_twolevel_modules">;
@@ -4140,7 +4142,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def 

[PATCH] D137473: [vfs] Allow root paths relative to the directory of the vfsoverlay YAML file

2022-11-09 Thread Haowei Wu via Phabricator via cfe-commits
haowei added inline comments.



Comment at: clang/test/VFS/Inputs/root-relative-overlay.yaml:4
+  'case-sensitive': false,
+  'overlay-relative': true,
+  'root-relative': 'yaml-dir',

haowei wrote:
> haowei wrote:
> > bnbarham wrote:
> > > bnbarham wrote:
> > > > I'd prefer a test without `overlay-relative` set to make it clear they 
> > > > don't depend on each other.
> > > There's also unit tests in 
> > > `llvm/unittests/Support/VirtualFileSystemTest.cpp` that you could add to.
> > I need some time to patch this unit test for testing the new option.
> > Existing functions in this unit test file does not support defining the 
> > YAMLFilePath.
> > 
> > I will update this patch when I finish.
> I updated the yaml file and add unit tests with overlay-relative set to true 
> and false.
I updated `llvm/unittests/Support/VirtualFileSystemTest.cpp` to include tests 
on `root-relative` option.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1903
+assert(!FullPath.empty() && "YAML file directory must exist");
+sys::fs::make_absolute(FS->getYAMLFileDir(), Name);
+Name = canonicalize(Name);

bnbarham wrote:
> haowei wrote:
> > bnbarham wrote:
> > > IMO both this and CWD should be using the base FS instead. VFS didn't 
> > > have a CWD previously, but now that it does it doesn't really make sense 
> > > to use the process wide CWD. Especially since `-working-directory` 
> > > doesn't change it.
> > Could you clarify a bit more about the "base FS" please? I am still quite 
> > new to the LLVM VFS system.  Which API should I use to get the appropriate 
> > working directory instead of the the process wide CWD?
> > 
> > I avoided changing the default behavior (relative to the process's current 
> > working directory) as I am a bit concerned breaking other people's use 
> > cases. 
> > 
> > I looked up a bit, the value "--working-directory" will be writen into 
> > "VFS->setCurrentWorkingDirectory()" Do you think it is a better idea to use 
> > this value instead of the process current working directory? Though it 
> > would still be a behavior change for users rely on process current working 
> > directories. 
> > Could you clarify a bit more about the "base FS" please?
> 
> By "base FS" I just meant the filesystem that's passed down when creating the 
> RedirectingFileSystem, ie. `ExternalFS` in `getVFSFromYAML`.
> 
> > Which API should I use to get the appropriate working directory instead of 
> > the the process wide CWD?
> 
> `ExternalFS->getCurrentWorkingDirectory()` and `ExternalFS->makeAbsolute` is 
> what I'd expect to be used here.
> 
> > Do you think it is a better idea to use this value instead of the process 
> > current working directory? Though it would still be a behavior change for 
> > users rely on process current working directories.
> 
> Yes, I think it's surprising that it currently *isn't* using it. It's just a 
> hold over from when the VFS didn't have the concept of CWD. I'd be happy with 
> accepting this patch as is, with a separate patch after that changes to using 
> the VFS CWD.
> Yes, I think it's surprising that it currently *isn't* using it. It's just a 
> hold over from when the VFS didn't have the concept of CWD. I'd be happy with 
> accepting this patch as is, with a separate patch after that changes to using 
> the VFS CWD.

I see, I can upload a follow up change after this one is landed. to use VFS CWD 
instead of process CWD here. It is also easier to revert if anything goes wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137473

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


[PATCH] D137473: [vfs] Allow root paths relative to the directory of the vfsoverlay YAML file

2022-11-09 Thread Haowei Wu via Phabricator via cfe-commits
haowei updated this revision to Diff 474391.
haowei added a comment.

Add additional unit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137473

Files:
  clang/test/VFS/Inputs/root-relative-overlay.yaml
  clang/test/VFS/relative-path.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1452,18 +1452,20 @@
 
   std::unique_ptr
   getFromYAMLRawString(StringRef Content,
-   IntrusiveRefCntPtr ExternalFS) {
+   IntrusiveRefCntPtr ExternalFS,
+   StringRef YAMLFilePath = "") {
 std::unique_ptr Buffer = MemoryBuffer::getMemBuffer(Content);
-return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, "", this,
-  ExternalFS);
+return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, YAMLFilePath,
+  this, ExternalFS);
   }
 
   std::unique_ptr getFromYAMLString(
   StringRef Content,
-  IntrusiveRefCntPtr ExternalFS = new DummyFileSystem()) {
+  IntrusiveRefCntPtr ExternalFS = new DummyFileSystem(),
+  StringRef YAMLFilePath = "") {
 std::string VersionPlusContent("{\n  'version':0,\n");
 VersionPlusContent += Content.slice(Content.find('{') + 1, StringRef::npos);
-return getFromYAMLRawString(VersionPlusContent, ExternalFS);
+return getFromYAMLRawString(VersionPlusContent, ExternalFS, YAMLFilePath);
   }
 
   // This is intended as a "XFAIL" for windows hosts.
@@ -1849,6 +1851,45 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, RootRelativeTest) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
+  Lower->addRegularFile("//root/foo/bar/a");
+  IntrusiveRefCntPtr FS =
+  getFromYAMLString("{\n"
+"  'case-sensitive': false,\n"
+"  'root-relative': 'overlay-dir',\n"
+"  'roots': [\n"
+"{ 'name': 'b', 'type': 'file',\n"
+"  'external-contents': '//root/foo/bar/a'\n"
+"}\n"
+"  ]\n"
+"}",
+Lower, "//root/foo/bar/overlay");
+
+  ASSERT_NE(FS.get(), nullptr);
+  ErrorOr S = FS->status("//root/foo/bar/b");
+  ASSERT_FALSE(S.getError());
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
+
+  IntrusiveRefCntPtr FSOverlayRelative =
+  getFromYAMLString("{\n"
+"  'case-sensitive': false,\n"
+"  'overlay-relative': true,\n"
+"  'root-relative': 'overlay-dir',\n"
+"  'roots': [\n"
+"{ 'name': 'b', 'type': 'file',\n"
+"  'external-contents': 'a'\n"
+"}\n"
+"  ]\n"
+"}",
+Lower, "//root/foo/bar/overlay");
+  ASSERT_NE(FSOverlayRelative.get(), nullptr);
+  ErrorOr SOverlayRelative = FS->status("//root/foo/bar/b");
+  ASSERT_FALSE(SOverlayRelative.getError());
+  EXPECT_EQ("//root/foo/bar/a", SOverlayRelative->getName());
+}
+
 TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
   IntrusiveRefCntPtr BaseFS(
   new vfs::InMemoryFileSystem);
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1482,12 +1482,12 @@
   return Combined;
 }
 
-void RedirectingFileSystem::setExternalContentsPrefixDir(StringRef PrefixDir) {
-  ExternalContentsPrefixDir = PrefixDir.str();
+void RedirectingFileSystem::setOverlayFileDir(StringRef Dir) {
+  OverlayFileDir = Dir.str();
 }
 
-StringRef RedirectingFileSystem::getExternalContentsPrefixDir() const {
-  return ExternalContentsPrefixDir;
+StringRef RedirectingFileSystem::getOverlayFileDir() const {
+  return OverlayFileDir;
 }
 
 void RedirectingFileSystem::setFallthrough(bool Fallthrough) {
@@ -1621,6 +1621,20 @@
 return None;
   }
 
+  Optional
+  parseRootRelativeKind(yaml::Node *N) {
+SmallString<12> Storage;
+StringRef Value;
+if (!parseScalarString(N, Value, Storage))
+  return None;
+if (Value.equals_insensitive("cwd")) {
+  return RedirectingFileSystem::RootRelativeKind::CWD;
+} else if (Value.equals_insensitive("overlay-dir")) {
+  return RedirectingFileSystem::RootRelativeKind::OverlayDir;
+}
+return None;
+  }
+
   struct KeyStatus {
 bool Required;
 bool Seen = false;
@@ -1828,7 

[PATCH] D137740: [clang-tidy][NFC] Fix namespace comments in AvoidThrowingObjCExceptionCheck.cpp 粒

2022-11-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D137740#3918335 , @stephanemoore 
wrote:

> In D137740#3918271 , 
> @Eugene.Zelenko wrote:
>
>> Will be good idea to combine this patch with D137738 
>> .
>
> My intent was to land the simpler linter fixes first while iterating on the 
> fixes in D137738  as necessary but I can 
> combine the two patches if that is preferred.

I don't think that such patches deserve dedicated commit unless you fix them on 
entire Clang-tidy code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137740

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


[PATCH] D137751: Produce a more informative diagnostics when Clang runs out of source locations

2022-11-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 474385.

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

https://reviews.llvm.org/D137751

Files:
  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
@@ -163,6 +163,33 @@
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
 
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:-pg \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-GPROF %s
+// CHECK-LD32-GPROF-NOT: warning:
+// CHECK-LD32-GPROF: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-GPROF: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-LD32-GPROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-GPROF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-GPROF-NOT: "-bnso"
+// CHECK-LD32-GPROF: "-b32"
+// CHECK-LD32-GPROF: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK-LD32-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-GPROF-NOT: "-lc++"
+// CHECK-LD32-GPROF-NOT: "-lc++abi"
+// CHECK-LD32-GPROF: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-GPROF-NOT: "--as-needed"
+// CHECK-LD32-GPROF: "-lunwind"
+// CHECK-LD32-GPROF-NOT: "--no-as-needed"
+// CHECK-LD32-GPROF-NOT: "-lm"
+// CHECK-LD32-GPROF: "-lc"
+
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -163,6 +163,33 @@
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
 
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:-pg \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-GPROF %s
+// CHECK-LD32-GPROF-NOT: warning:
+// CHECK-LD32-GPROF: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-GPROF: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-LD32-GPROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-GPROF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-GPROF-NOT: "-bnso"
+// CHECK-LD32-GPROF: "-b32"
+// CHECK-LD32-GPROF: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK-LD32-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-GPROF-NOT: "-lc++"
+// CHECK-LD32-GPROF-NOT: "-lc++abi"
+// CHECK-LD32-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-GPROF-NOT: "--as-needed"
+// CHECK-LD32-GPROF: "-lunwind"
+// CHECK-LD32-GPROF-NOT: "--no-as-needed"
+// CHECK-LD32-GPROF-NOT: "-lm"
+// CHECK-LD32-GPROF: "-lc"
+
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137740: [clang-tidy][NFC] Fix namespace comments in AvoidThrowingObjCExceptionCheck.cpp 粒

2022-11-09 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In D137740#3918271 , @Eugene.Zelenko 
wrote:

> Will be good idea to combine this patch with D137738 
> .

My intent was to land the simpler linter fixes first while iterating on the 
fixes in D137738  as necessary but I can 
combine the two patches if that is preferred.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137740

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


[PATCH] D137751: Produce a more informative diagnostics when Clang runs out of source locations

2022-11-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: aaron.ballman.
Herald added a subscriber: mgrang.
Herald added a project: All.
rsmith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If Clang runs out of source location address space, produce a more helpful 
diagnostic than "ran out of source locations" or "translation unit is too 
large". In addition to that diagnostic, also describe the current source 
location address space usage, listing the header files that are contributing 
most to that as well as how many times they were textually entered. The intent 
is to make it easier to determine if the problem is some kind of 
misconfiguration (for example, a header isn't properly include-guarded and gets 
textually entered a lot, or is entered in many AST files), problematic input 
(for example, a preprocessor metaprogram uses a huge amount of source location 
space), or a death by a thousand cuts due to the source program just plain 
being too large.

Also included is a debug pragma to produce the usage report, both to make this 
more readily testable and to provide visibility into source location address 
space usage when debugging clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137751

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Misc/Inputs/include.h
  clang/test/Misc/sloc-usage.cpp

Index: clang/test/Misc/sloc-usage.cpp
===
--- /dev/null
+++ clang/test/Misc/sloc-usage.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/include.h"
+#include "Inputs/include.h"
+
+#define FOO(x) x + x
+int k = FOO(FOO(123));
+bool b = EQUALS(k, k);
+
+#pragma clang __debug sloc_usage // expected-remark {{address space usage}}
+// expected-note@* {{(0% of available space)}}
+// (this file) expected-note-re@1 {{file entered 1 time using {{.*}}B of space plus 51B for macro expansions}}
+// (included file) expected-note-re@Inputs/include.h:1 {{file entered 2 times using {{.*}}B of space{{$
+// (builtins file) expected-note@* {{file entered}}
Index: clang/test/Misc/Inputs/include.h
===
--- clang/test/Misc/Inputs/include.h
+++ clang/test/Misc/Inputs/include.h
@@ -1,3 +1,8 @@
 #define EQUALS(a,b) a == b
 
+// It's important for sloc_usage.cpp that this file does not have proper
+// include guards.
+#ifndef FOO_DEFINED
+#define FOO_DEFINED
 int foo(int x) { return x; }
+#endif
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3401,9 +3401,14 @@
   std::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
   SourceMgr.AllocateLoadedSLocEntries(F.LocalNumSLocEntries,
   SLocSpaceSize);
-  if (!F.SLocEntryBaseID)
+  if (!F.SLocEntryBaseID) {
+if (!Diags.isDiagnosticInFlight()) {
+  Diags.Report(SourceLocation(), diag::remark_sloc_usage);
+  SourceMgr.noteSLocAddressSpaceUsage(Diags);
+}
 return llvm::createStringError(std::errc::invalid_argument,
"ran out of source locations");
+  }
   // Make our entry in the range map. BaseID is negative and growing, so
   // we invert it. Because we invert it, though, we need the other end of
   // the range.
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1043,7 +1043,7 @@
 Token Tok;
 PP.LexUnexpandedToken(Tok);
 if (Tok.isNot(tok::identifier)) {
-  PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
+  PP.Diag(Tok, diag::warn_pragma_debug_missing_command);
   return;
 }
 IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -1181,6 +1181,22 @@
 PP.Diag(Tok, diag::warn_pragma_debug_unexpected_command)
   << DumpII->getName();
   }
+} else if (II->isStr("sloc_usage")) {
+  // An optional integer literal argument specifies the number of files to
+  // specifically report information about.
+  uint64_t MaxNotes = (uint64_t)-1;
+  Token ArgToken;
+  PP.Lex(ArgToken);
+  if (ArgToken.isNot(tok::eod)) {
+if (ArgToken.isNot(tok::numeric_constant) ||
+!PP.parseSimpleIntegerLiteral(ArgToken, MaxNotes)) {
+  PP.Diag(ArgToken, diag::warn_pragma_debug_unexpected_argument);
+}
+  }
+
+  PP.Diag(Tok, diag::remark_sloc_usage);
+  PP.getSourceManager().noteSLocAddressSpaceUsage(PP.getDiagnostics(),
+  

[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-09 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu updated this revision to Diff 474382.
tarunprabhu added a comment.

Previous revision was missing the tests.

Only add a dependence to the Bye plugin when plugins are enabled.


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

https://reviews.llvm.org/D129156

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/docs/FlangDriver.md
  flang/docs/ReleaseNotes.md
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/pass-plugin-not-found.f90
  flang/test/Driver/pass-plugin.f90

Index: flang/test/Driver/pass-plugin.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin.f90
@@ -0,0 +1,13 @@
+! Verify that the plugin passed to -fpass-plugin is loaded and run
+
+! UNSUPPORTED: system-windows
+
+! REQUIRES: plugins, shell
+
+! RUN: %flang -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+
+! CHECK: Running pass: {{.*}}Bye on empty_
+
+subroutine empty
+end subroutine empty
Index: flang/test/Driver/pass-plugin-not-found.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin-not-found.f90
@@ -0,0 +1,8 @@
+! Check the correct error diagnostic is reported when a pass plugin shared object isn't found
+
+! REQUIRES: plugins, shell
+
+! RUN: not %flang -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang_fc1 -emit-llvm -o /dev/null -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! ERROR: error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: cannot open shared object file: No such file or directory'
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,7 @@
 ! RUN: -fno-signed-zeros \
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -33,4 +34,5 @@
 ! CHECK: "-mreassociate"
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -46,6 +46,7 @@
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -129,6 +130,7 @@
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -48,6 +48,7 @@
 ! CHECK-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic 

[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-09 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu updated this revision to Diff 474381.
tarunprabhu added a comment.

Only add a dependence to the Bye plugin when plugins are enabled.


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

https://reviews.llvm.org/D129156

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/docs/FlangDriver.md
  flang/docs/ReleaseNotes.md
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90

Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,7 @@
 ! RUN: -fno-signed-zeros \
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -33,4 +34,5 @@
 ! CHECK: "-mreassociate"
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -46,6 +46,7 @@
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -129,6 +130,7 @@
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -48,6 +48,7 @@
 ! CHECK-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -76,4 +77,3 @@
 
 ! Frontend driver -help-hidden is not supported
 ! ERROR-FLANG-FC1: error: unknown argument: '{{.*}}'
-
Index: flang/test/CMakeLists.txt
===
--- flang/test/CMakeLists.txt
+++ flang/test/CMakeLists.txt
@@ -63,6 +63,9 @@
   Fortran_main
   FortranDecimal
 )
+if (LLVM_ENABLE_PLUGINS)
+  list(APPEND FLANG_TEST_DEPENDS Bye)
+endif()
 
 if (FLANG_INCLUDE_TESTS)
   if (FLANG_GTEST_AVAIL)
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -48,6 +48,7 @@
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
 #include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SourceMgr.h"
@@ -675,6 +676,7 @@
 
 void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream ) {
   auto opts = getInstance().getInvocation().getCodeGenOpts();
+  auto  = getInstance().getDiagnostics();
   llvm::OptimizationLevel level = mapToLevel(opts);
 
   // Create the analysis managers.
@@ -691,6 +693,17 @@
   si.registerCallbacks(pic, );
   llvm::PassBuilder 

[clang] a11cd0d - Move googletest to the third-party directory

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

Author: Tom Stellard
Date: 2022-11-09T15:28:08-08:00
New Revision: a11cd0d94ed3cabf0998a0289aead05da94c86eb

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

LOG: Move googletest to the third-party directory

Rre-commit of 59052468c3e38cab15582cefbb5133fd4c2ffce5 with a typo
fix in compiler-rt/CMakeLists.txt

Added: 
third-party/unittest/CMakeLists.txt
third-party/unittest/UnitTestMain/CMakeLists.txt
third-party/unittest/UnitTestMain/TestMain.cpp
third-party/unittest/googlemock/LICENSE.txt
third-party/unittest/googlemock/README.LLVM
third-party/unittest/googlemock/include/gmock/gmock-actions.h
third-party/unittest/googlemock/include/gmock/gmock-cardinalities.h
third-party/unittest/googlemock/include/gmock/gmock-function-mocker.h
third-party/unittest/googlemock/include/gmock/gmock-generated-actions.h

third-party/unittest/googlemock/include/gmock/gmock-generated-function-mockers.h
third-party/unittest/googlemock/include/gmock/gmock-generated-matchers.h
third-party/unittest/googlemock/include/gmock/gmock-matchers.h
third-party/unittest/googlemock/include/gmock/gmock-more-actions.h
third-party/unittest/googlemock/include/gmock/gmock-more-matchers.h
third-party/unittest/googlemock/include/gmock/gmock-nice-strict.h
third-party/unittest/googlemock/include/gmock/gmock-spec-builders.h
third-party/unittest/googlemock/include/gmock/gmock.h

third-party/unittest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h

third-party/unittest/googlemock/include/gmock/internal/custom/gmock-matchers.h
third-party/unittest/googlemock/include/gmock/internal/custom/gmock-port.h

third-party/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h
third-party/unittest/googlemock/include/gmock/internal/gmock-port.h
third-party/unittest/googlemock/include/gmock/internal/gmock-pp.h
third-party/unittest/googlemock/src/gmock-all.cc
third-party/unittest/googlemock/src/gmock-cardinalities.cc
third-party/unittest/googlemock/src/gmock-internal-utils.cc
third-party/unittest/googlemock/src/gmock-matchers.cc
third-party/unittest/googlemock/src/gmock-spec-builders.cc
third-party/unittest/googlemock/src/gmock.cc
third-party/unittest/googletest/LICENSE.TXT
third-party/unittest/googletest/README.LLVM
third-party/unittest/googletest/include/gtest/gtest-death-test.h
third-party/unittest/googletest/include/gtest/gtest-matchers.h
third-party/unittest/googletest/include/gtest/gtest-message.h
third-party/unittest/googletest/include/gtest/gtest-param-test.h
third-party/unittest/googletest/include/gtest/gtest-printers.h
third-party/unittest/googletest/include/gtest/gtest-spi.h
third-party/unittest/googletest/include/gtest/gtest-test-part.h
third-party/unittest/googletest/include/gtest/gtest-typed-test.h
third-party/unittest/googletest/include/gtest/gtest.h
third-party/unittest/googletest/include/gtest/gtest_pred_impl.h
third-party/unittest/googletest/include/gtest/gtest_prod.h
third-party/unittest/googletest/include/gtest/internal/custom/gtest-port.h

third-party/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
third-party/unittest/googletest/include/gtest/internal/custom/gtest.h
third-party/unittest/googletest/include/gtest/internal/custom/raw-ostream.h

third-party/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
third-party/unittest/googletest/include/gtest/internal/gtest-filepath.h
third-party/unittest/googletest/include/gtest/internal/gtest-internal.h
third-party/unittest/googletest/include/gtest/internal/gtest-param-util.h
third-party/unittest/googletest/include/gtest/internal/gtest-port-arch.h
third-party/unittest/googletest/include/gtest/internal/gtest-port.h
third-party/unittest/googletest/include/gtest/internal/gtest-string.h
third-party/unittest/googletest/include/gtest/internal/gtest-type-util.h
third-party/unittest/googletest/src/gtest-all.cc
third-party/unittest/googletest/src/gtest-death-test.cc
third-party/unittest/googletest/src/gtest-filepath.cc
third-party/unittest/googletest/src/gtest-internal-inl.h
third-party/unittest/googletest/src/gtest-matchers.cc
third-party/unittest/googletest/src/gtest-port.cc
third-party/unittest/googletest/src/gtest-printers.cc
third-party/unittest/googletest/src/gtest-test-part.cc
third-party/unittest/googletest/src/gtest-typed-test.cc
third-party/unittest/googletest/src/gtest.cc

Modified: 
clang/CMakeLists.txt
compiler-rt/CMakeLists.txt
lld/CMakeLists.txt
lldb/cmake/modules/LLDBStandalone.cmake
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
mlir/CMakeLists.txt
polly/CMakeLists.txt

Removed: 

[PATCH] D137740: [clang-tidy][NFC] Fix namespace comments in AvoidThrowingObjCExceptionCheck.cpp 粒

2022-11-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Will be good idea to combine this patch with D137738 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137740

___
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-09 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

I believe this patch might be the cause of some assertion failures we are 
seeing in a two stage lto build, as it's only happening for arm64-darwin. See 
https://ci.chromium.org/ui/p/fuchsia/builders/prod/clang-mac-xarm64/b8798097341668696785/overview
 and it's corresponding build logs 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8798097341668696785/+/u/clang/build/stdout

  [4060/4274](20) Linking CXX executable bin/clang-refactor
  FAILED: bin/clang-refactor 
  : && /opt/s/w/ir/x/w/staging/llvm_build/./bin/clang++ 
--target=arm64-apple-darwin 
--sysroot=/opt/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
 -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -flto 
-ffile-prefix-map=/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins=../staging/llvm_build/tools/clang/stage2-bins
 -ffile-prefix-map=/opt/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes 
-fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -isysroot 
/opt/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
 -mmacosx-version-min=10.13 -Wl,-headerpad_max_install_names -nostdlib++ 
/opt/s/w/ir/x/w/staging/llvm_build/lib/libc++.a -stdlib=libc++ 
-static-libstdc++ -fno-pie -fuse-ld=lld -Wl,--color-diagnostics -flto 
-Wl,-lto_library -Wl,/opt/s/w/ir/x/w/staging/llvm_build/./lib/libLTO.dylib
-Wl,-dead_strip 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
 -o bin/clang-refactor  -Wl,-rpath,@loader_path/../lib  lib/libLLVMOption.a  
lib/libLLVMSupport.a  lib/libclangAST.a  lib/libclangBasic.a  
lib/libclangFormat.a  lib/libclangFrontend.a  lib/libclangLex.a  
lib/libclangRewrite.a  lib/libclangSerialization.a  lib/libclangTooling.a  
lib/libclangToolingCore.a  lib/libclangToolingRefactoring.a  
lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  
lib/libclangFrontend.a  lib/libclangDriver.a  lib/libLLVMWindowsDriver.a  
lib/libLLVMOption.a  lib/libclangParse.a  lib/libclangSerialization.a  
lib/libclangSema.a  lib/libclangEdit.a  lib/libclangAnalysis.a  
lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libLLVMFrontendOpenMP.a  
lib/libLLVMScalarOpts.a  lib/libLLVMAggressiveInstCombine.a  
lib/libLLVMInstCombine.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  
lib/libLLVMProfileData.a  lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoPDB.a  
lib/libLLVMDebugInfoMSF.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMObject.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  
lib/libLLVMIRReader.a  lib/libLLVMAsmParser.a  lib/libLLVMTextAPI.a  
lib/libclangSupport.a  lib/libLLVMFrontendHLSL.a  lib/libLLVMBitReader.a  
lib/libclangToolingCore.a  lib/libclangRewrite.a  lib/libclangLex.a  
lib/libclangBasic.a  lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMSupport.a  -lm  
/opt/s/w/ir/x/w/staging/zlib_install/lib/libz.a  
/opt/s/w/ir/x/w/staging/zstd_install_prefix/lib/libzstd.a  
lib/libLLVMDemangle.a && :
  clang++: warning: argument unused during compilation: '-static-libstdc++' 
[-Wunused-command-line-argument]
  Assertion failed: (BitWidth == RHS.BitWidth && "Bit widths must be the 
same"), function operator+=, file 
/opt/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Support/APInt.cpp, line 189.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.Program arguments: /opt/s/w/ir/x/w/staging/llvm_build/./bin/ld64.lld 
-demangle -dynamic -arch arm64 -platform_version macos 11.0.0 11.0 -no_pie 
-mllvm -global-isel -mllvm -global-isel-abort=0 -syslibroot 
/opt/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
 -o bin/clang-refactor -headerpad_max_install_names 
/opt/s/w/ir/x/w/staging/llvm_build/lib/libc++.a --color-diagnostics 
-lto_library /opt/s/w/ir/x/w/staging/llvm_build/./lib/libLTO.dylib -dead_strip 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
 -rpath @loader_path/../lib lib/libLLVMOption.a lib/libLLVMSupport.a 
lib/libclangAST.a lib/libclangBasic.a lib/libclangFormat.a 
lib/libclangFrontend.a lib/libclangLex.a lib/libclangRewrite.a 
lib/libclangSerialization.a 

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

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

Hmm I added the test for the flag to Sema, but now we kinda have the same test 
case duplicated in sema and clangd tests - I guess for clangd we now actually 
only have to test that the SnippetSuffix is cleared when FunctionCanBeCall is 
true, but I don't see an easy way to somehow inject fake Sema results into 
CodeComplete.cpp


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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-09 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added a comment.

In D137181#3916605 , @owenpan wrote:

> In D137181#3916558 , @goldstein.w.n 
> wrote:
>
>> In D137181#3916547 , @owenpan 
>> wrote:
>>
>>> Yes, if there is a header guard. Otherwise, set `PPLevel` to `PPBranchLevel 
>>> + 1`.
>>
>> That fails alot of the tests for me.
>>
>> maybe you did something different?
>
> Here is what I did:
>
>   $ git diff UnwrappedLineParser.cpp
>   diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
> b/clang/lib/Format/UnwrappedLineParser.cpp
>   index 25d9018fa109..ab3b9c53ee54 100644
>   --- a/clang/lib/Format/UnwrappedLineParser.cpp
>   +++ b/clang/lib/Format/UnwrappedLineParser.cpp
>   @@ -197,6 +197,7 @@ public:
>PreBlockLine = std::move(Parser.Line);
>Parser.Line = std::make_unique();
>Parser.Line->Level = PreBlockLine->Level;
>   +Parser.Line->PPLevel = PreBlockLine->PPLevel;
>Parser.Line->InPPDirective = PreBlockLine->InPPDirective;
>Parser.Line->InMacroBody = PreBlockLine->InMacroBody;
>  }
>   @@ -1274,6 +1275,10 @@ void UnwrappedLineParser::parsePPDefine() {
>  addUnwrappedLine();
>  ++Line->Level;
>  Line->InMacroBody = true;
>   +  if (Style.IndentPPDirectives != FormatStyle::PPDIS_None) {
>   +Line->PPLevel =
>   +IncludeGuard == IG_Defined ? PPBranchLevel : PPBranchLevel + 1;
>   +  }
>
>  // Errors during a preprocessor directive can only affect the layout of 
> the
>  // preprocessor directive, and thus we ignore them. An alternative 
> approach

You're right this works (but off by one). Updated patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-09 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n updated this revision to Diff 474359.
goldstein.w.n added a comment.



1. Updating D137181 : [clang-format] Don't 
use 'PPIndentWidth' inside multi-line macros #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Remove many unnecessary `PPLevel` changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

Files:
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5040,6 +5040,254 @@
"  int y = 0;\n"
"}",
style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef X\n"
+   "#define Y  \\\n"
+   "switch (Y) {   \\\n"
+   "case 0:\\\n"
+   "break; \\\n"
+   "case 1:\\\n"
+   "break; \\\n"
+   "}  \\\n"
+   "Z();\n"
+   "#endif",
+   style);
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "if (B) { \\\n"
+   "C(); \\\n"
+   "}\\\n"
+   "}\\\n"
+   "D();\n"
+   "#endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}\n"
+   "#endif",
+   style);
+
+  style.PPIndentWidth = 2;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  style.IndentWidth = 8;
+  verifyFormat("#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "B(); \\\n"
+   "}\\\n"
+   "C();\n"
+   "#endif",
+   style);
+
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef X\n"
+   "# define Y  \\\n"
+   " switch (Y) {   \\\n"
+   " case 0:\\\n"
+   " break; \\\n"
+   " case 1:\\\n"
+   " break; \\\n"
+   " }  \\\n"
+   " Z();\n"
+   "#endif",
+   style);
+  verifyFormat("#ifdef foo\n"
+   "# define bar() \\\n"
+   " if (A) {  \\\n"
+   " B();  \\\n"
+   " } \\\n"
+   " C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "# define lit   \\\n"
+   " if (af) { \\\n"
+   " return duh(); \\\n"
+   " }\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "# ifdef foo\n"
+   "#  define bar()\\\n"
+   "  if (A) { \\\n"
+   "  if (B) { \\\n"
+   "  C(); \\\n"
+   "  }\\\n"
+   "  }\\\n"
+   "  D();\n"
+   "# endif\n"
+

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

2022-11-09 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders updated this revision to Diff 474358.
tom-anders added a comment.

Add test to sema


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137040

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -23,7 +23,10 @@
 
 using namespace clang;
 using namespace clang::tooling;
+using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::Each;
+using ::testing::Field;
 using ::testing::UnorderedElementsAre;
 
 const char TestCCName[] = "test.cc";
@@ -36,6 +39,48 @@
   std::string PtrDiffType;
 };
 
+struct CompletedFunctionDecl {
+  std::string Name;
+  bool IsStatic;
+  bool CanBeCall;
+};
+
+class SaveCompletedFunctions : public CodeCompleteConsumer {
+public:
+  SaveCompletedFunctions(std::vector )
+  : CodeCompleteConsumer(/*CodeCompleteOpts=*/{}),
+CompletedFuncDecls(CompletedFuncDecls),
+CCTUInfo(std::make_shared()) {}
+
+  void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+  CodeCompletionResult *Results,
+  unsigned NumResults) override {
+for (unsigned I = 0; I < NumResults; ++I) {
+  auto R = Results[I];
+  if (R.Kind == CodeCompletionResult::RK_Declaration) {
+if (const auto *FD = llvm::dyn_cast(R.getDeclaration())) {
+  CompletedFunctionDecl D;
+  D.Name = FD->getNameAsString();
+  D.CanBeCall = R.FunctionCanBeCall;
+  D.IsStatic = FD->isStatic();
+  CompletedFuncDecls.emplace_back(std::move(D));
+}
+  }
+}
+  }
+
+private:
+  CodeCompletionAllocator () override {
+return CCTUInfo.getAllocator();
+  }
+
+  CodeCompletionTUInfo () override { return CCTUInfo; }
+
+  std::vector 
+
+  CodeCompletionTUInfo CCTUInfo;
+};
+
 class VisitedContextFinder : public CodeCompleteConsumer {
 public:
   VisitedContextFinder(CompletionContext )
@@ -74,12 +119,15 @@
 
 class CodeCompleteAction : public SyntaxOnlyAction {
 public:
-  CodeCompleteAction(ParsedSourceLocation P, CompletionContext )
-  : CompletePosition(std::move(P)), ResultCtx(ResultCtx) {}
+  CodeCompleteAction(ParsedSourceLocation P, CompletionContext ,
+ CodeCompleteConsumer *Consumer = nullptr)
+  : CompletePosition(std::move(P)), ResultCtx(ResultCtx),
+Consumer(Consumer) {}
 
   bool BeginInvocation(CompilerInstance ) override {
 CI.getFrontendOpts().CodeCompletionAt = CompletePosition;
-CI.setCodeCompletionConsumer(new VisitedContextFinder(ResultCtx));
+CI.setCodeCompletionConsumer(
+Consumer ? Consumer : new VisitedContextFinder(ResultCtx));
 return true;
   }
 
@@ -87,6 +135,7 @@
   // 1-based code complete position ;
   ParsedSourceLocation CompletePosition;
   CompletionContext 
+  CodeCompleteConsumer *Consumer;
 };
 
 ParsedSourceLocation offsetToPosition(llvm::StringRef Code, size_t Offset) {
@@ -129,6 +178,83 @@
   return Types;
 }
 
+std::vector
+CollectCompletedFunctions(StringRef Code, std::size_t Point) {
+  CompletionContext DummyContext;
+  std::vector Result;
+  clang::tooling::runToolOnCodeWithArgs(
+  std::make_unique(offsetToPosition(Code, Point),
+   DummyContext,
+   new SaveCompletedFunctions(Result)),
+  Code, {"-std=c++11"}, TestCCName);
+  return Result;
+}
+
+TEST(SemaCodeCompleteTest, FunctionCanBeCall) {
+  llvm::Annotations Code(R"cpp(
+struct Foo {
+  static int staticMethod();
+  int method() const;
+  Foo() {
+this->$canBeCall^
+$canBeCall^
+Foo::$canBeCall^
+  }
+};
+
+struct Derived : Foo {
+  Derived() {
+Foo::$canBeCall^
+  }
+};
+
+struct OtherClass {
+  OtherClass() {
+Foo f;
+f.$canBeCall^
+::$cannotBeCall^
+  }
+};
+
+int main() {
+  Foo f;
+  f.$canBeCall^
+  ::$cannotBeCall^
+}
+)cpp");
+
+  for (const auto  : Code.points("canBeCall")) {
+auto Results = CollectCompletedFunctions(Code.code(), P);
+EXPECT_THAT(
+Results,
+Contains(AllOf(
+Field("Name", ::Name, "method"),
+Field("IsStatic", ::IsStatic, false),
+Field("CanBeCall", ::CanBeCall, true;
+  }
+
+  for (const auto  : Code.points("keepSnippet")) {
+auto Results = CollectCompletedFunctions(Code.code(), P);
+EXPECT_THAT(
+Results,
+Contains(AllOf(
+Field("Name", ::Name, "method"),
+

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

2022-11-09 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
stephanemoore updated this revision to Diff 474350.
stephanemoore added a comment.
stephanemoore updated this revision to Diff 474356.
stephanemoore published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

[clang-tidy] Fix namespace comments in AvoidThrowingObjCExceptionCheck.cpp 粒

This commit fixes namespace comments as suggested by the linter.


stephanemoore added a comment.

Restore original diff that was replaced by accident.


The google-objc-avoid-throwing-exception check enforces the Google
Objective-C Style Guide's prohibition on throwing exceptions in user
code but the check incorrectly triggers findings for code emitted from
system headers. This commit suppresses any findings that do not have
valid locations or are emitted from macros in system headers.

Avoid Throwing Exceptions, Google Objective-C Style Guide:
https://github.com/google/styleguide/blob/gh-pages/objcguide.md#avoid-throwing-exceptions

Test Notes:
Ran clang-tidy lit tests.


Repository:
  rG LLVM Github Monorepo

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,6 +36,22 @@
   Result.Nodes.getNodeAs("raiseException");
   auto SourceLoc = MatchedStmt == nullptr ? MatchedExpr->getSelectorStartLoc()
   : MatchedStmt->getThrowLoc();
+
+  // Early return on invalid locations.
+  if (SourceLoc.isInvalid())
+return;
+
+ 

[PATCH] D137740: [clang-tidy] Fix namespace comments in AvoidThrowingObjCExceptionCheck.cpp 粒

2022-11-09 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
stephanemoore published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This commit fixes namespace comments as suggested by the linter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137740

Files:
  clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp


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
@@ -41,7 +41,7 @@
"Objective-C errors");
 }
 
-}  // namespace objc
-}  // namespace google
-}  // namespace tidy
-}  // namespace clang
+} // namespace objc
+} // namespace google
+} // namespace tidy
+} // namespace clang


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
@@ -41,7 +41,7 @@
"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] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: clang/CMakeLists.txt:14
   set(CLANG_BUILT_STANDALONE TRUE)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING

I wonder if we could move this to `CMakePolicy.cmake`, though admittedly you'd 
have to somehow avoid warning multiple times in in-tree builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137154: Adding nvvm_reflect clang builtin

2022-11-09 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D137154#3917752 , @tra wrote:

> As for the code specialization, why not build for individual GPUs? To me it 
> looks like this use case is a good match for the "new-driver" offloading 
> that's been recently implemented in clang. It allows compiling/linking GPU 
> side code and that should obviate the need for shipping bitcode and relying 
> on `__nvvm_reflect` for specialization.

Dealing with the relative compatibility of GPU targets is a never-ending 
endeavor so I'm a proponent of just compiling the source for every single 
architecture, this is what we do with the `libomptarget` device libraries and 
is how the future `libm` and `libc` libraries will work.

> The downside is that it's a recent feature, so it would not be available in 
> older clang versions. @jhuber6 : I'm also not sure if OpenCL is supported by 
> the new driver.

It's not currently, I could put some cycles into that if needed. Also I'm 
wondering if it might be time to start an RFC for moving CUDA to the new driver 
by default. The one downside would be losing compatibility with CUDA's method 
of RDC compilation but I don't think that was ever a goal.

> With the new driver, you in theory should be able to compile the source with 
> `--offload-arch=A --offload-arch=B` and it would produce an object file with 
> GPU-specific bitcode or object file which can then be transparently linked 
> into the final executable, where clang would also perform final linking of 
> GPU binaries, as well.

Part of me wonders if  we should supply `--offload-arch=all` if people start 
doing this a lot.

> I realize that it may be hard or not feasible for your project right now. I'm 
> OK with allowing limited nvvm_reflect use for the time being, but please do 
> consider making things work w/o it or libdevice, if possible.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137154

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


[PATCH] D137609: [C++20] [Modules] Remove unmaintained header modules

2022-11-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I'm not aware of anyone using this mode, but please wait for responses from 
> Google and Meta people to verify that.

Best understanding on the Google side is we aren't using this.


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

https://reviews.llvm.org/D137609

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


[PATCH] D136701: [LinkerWrapper] Perform device linking steps in parallel

2022-11-09 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136701

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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

LGTM (sorry, it looks like I approved on behalf of all libc++ vendors but that 
wasn't my intention).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[clang] e07a704 - [Test][AIX][pg] Add 32-bit linker invocation tests

2022-11-09 Thread Chris Bowler via cfe-commits

Author: Michael Francis
Date: 2022-11-09T15:02:45-05:00
New Revision: e07a7040d9c6dbdd71e55d1153bfe1357079e511

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

LOG: [Test][AIX][pg] Add 32-bit linker invocation tests

Differential Review: https://reviews.llvm.org/D137372

Added: 


Modified: 
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 46da1ef20720..8aae6b086cbf 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -163,6 +163,33 @@
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
 
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:-pg \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-GPROF %s
+// CHECK-LD32-GPROF-NOT: warning:
+// CHECK-LD32-GPROF: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-GPROF: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-LD32-GPROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-GPROF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-GPROF-NOT: "-bnso"
+// CHECK-LD32-GPROF: "-b32"
+// CHECK-LD32-GPROF: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK-LD32-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-GPROF-NOT: "-lc++"
+// CHECK-LD32-GPROF-NOT: "-lc++abi"
+// CHECK-LD32-GPROF: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-GPROF-NOT: "--as-needed"
+// CHECK-LD32-GPROF: "-lunwind"
+// CHECK-LD32-GPROF-NOT: "--no-as-needed"
+// CHECK-LD32-GPROF-NOT: "-lm"
+// CHECK-LD32-GPROF: "-lc"
+
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \



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


[PATCH] D137071: [clang][Interp] Implement missing compound assign operators

2022-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D137071

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


[clang] dc9846c - [Test][AIX][p] Add 64-bit linker invocation tests

2022-11-09 Thread Chris Bowler via cfe-commits

Author: Michael Francis
Date: 2022-11-09T14:51:40-05:00
New Revision: dc9846ce988b9ddfcbc42cd462d5d94b634b3161

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

LOG: [Test][AIX][p] Add 64-bit linker invocation tests

Differential Review: https://reviews.llvm.org/D137373

Added: 


Modified: 
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 5684a1e6ac957..46da1ef207207 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -136,6 +136,33 @@
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
 
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:-p \
+// RUN:--target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64-PROF %s
+// CHECK-LD64-PROF-NOT: warning:
+// CHECK-LD64-PROF: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PROF: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-LD64-PROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64-PROF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD64-PROF-NOT: "-bnso"
+// CHECK-LD64-PROF: "-b64"
+// CHECK-LD64-PROF: "-bpT:0x1" "-bpD:0x11000"
+// CHECK-LD64-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0_64.o"
+// CHECK-LD64-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-PROF-NOT: "-lc++"
+// CHECK-LD64-PROF-NOT: "-lc++abi"
+// CHECK-LD64-PROF: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-PROF-NOT: "--as-needed"
+// CHECK-LD64-PROF: "-lunwind"
+// CHECK-LD64-PROF-NOT: "--no-as-needed"
+// CHECK-LD64-PROF-NOT: "-lm"
+// CHECK-LD64-PROF: "-lc"
+
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \



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


[PATCH] D137373: [Test][[AIX][p] Add 64-bit linker invocation tests

2022-11-09 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm accepted this revision.
cebowleratibm added a comment.
This revision is now accepted and ready to land.

LGTM.

Test only patch is safe to commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137373

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


[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos

2022-11-09 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

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


[clang] 8a084f6 - Revert "Move googletest to the third-party directory"

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

Author: Tom Stellard
Date: 2022-11-09T11:34:59-08:00
New Revision: 8a084f68c8a1cac99d9fa0fbcf490b53ab3b6e0c

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

LOG: Revert "Move googletest to the third-party directory"

This reverts commit 59052468c3e38cab15582cefbb5133fd4c2ffce5.

It looks like this patch breaks the build when compiler-rt is passed to
LLVM_ENABLE_PROJECTS instead of LLVM_ENABLE_RUNTIMES.

Added: 
llvm/utils/unittest/CMakeLists.txt
llvm/utils/unittest/UnitTestMain/CMakeLists.txt
llvm/utils/unittest/UnitTestMain/TestMain.cpp
llvm/utils/unittest/googlemock/LICENSE.txt
llvm/utils/unittest/googlemock/README.LLVM
llvm/utils/unittest/googlemock/include/gmock/gmock-actions.h
llvm/utils/unittest/googlemock/include/gmock/gmock-cardinalities.h
llvm/utils/unittest/googlemock/include/gmock/gmock-function-mocker.h
llvm/utils/unittest/googlemock/include/gmock/gmock-generated-actions.h

llvm/utils/unittest/googlemock/include/gmock/gmock-generated-function-mockers.h
llvm/utils/unittest/googlemock/include/gmock/gmock-generated-matchers.h
llvm/utils/unittest/googlemock/include/gmock/gmock-matchers.h
llvm/utils/unittest/googlemock/include/gmock/gmock-more-actions.h
llvm/utils/unittest/googlemock/include/gmock/gmock-more-matchers.h
llvm/utils/unittest/googlemock/include/gmock/gmock-nice-strict.h
llvm/utils/unittest/googlemock/include/gmock/gmock-spec-builders.h
llvm/utils/unittest/googlemock/include/gmock/gmock.h

llvm/utils/unittest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h

llvm/utils/unittest/googlemock/include/gmock/internal/custom/gmock-matchers.h
llvm/utils/unittest/googlemock/include/gmock/internal/custom/gmock-port.h
llvm/utils/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h
llvm/utils/unittest/googlemock/include/gmock/internal/gmock-port.h
llvm/utils/unittest/googlemock/include/gmock/internal/gmock-pp.h
llvm/utils/unittest/googlemock/src/gmock-all.cc
llvm/utils/unittest/googlemock/src/gmock-cardinalities.cc
llvm/utils/unittest/googlemock/src/gmock-internal-utils.cc
llvm/utils/unittest/googlemock/src/gmock-matchers.cc
llvm/utils/unittest/googlemock/src/gmock-spec-builders.cc
llvm/utils/unittest/googlemock/src/gmock.cc
llvm/utils/unittest/googletest/LICENSE.TXT
llvm/utils/unittest/googletest/README.LLVM
llvm/utils/unittest/googletest/include/gtest/gtest-death-test.h
llvm/utils/unittest/googletest/include/gtest/gtest-matchers.h
llvm/utils/unittest/googletest/include/gtest/gtest-message.h
llvm/utils/unittest/googletest/include/gtest/gtest-param-test.h
llvm/utils/unittest/googletest/include/gtest/gtest-printers.h
llvm/utils/unittest/googletest/include/gtest/gtest-spi.h
llvm/utils/unittest/googletest/include/gtest/gtest-test-part.h
llvm/utils/unittest/googletest/include/gtest/gtest-typed-test.h
llvm/utils/unittest/googletest/include/gtest/gtest.h
llvm/utils/unittest/googletest/include/gtest/gtest_pred_impl.h
llvm/utils/unittest/googletest/include/gtest/gtest_prod.h
llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest-port.h

llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest.h
llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h

llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-filepath.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-param-util.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-port-arch.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-string.h
llvm/utils/unittest/googletest/include/gtest/internal/gtest-type-util.h
llvm/utils/unittest/googletest/src/gtest-all.cc
llvm/utils/unittest/googletest/src/gtest-death-test.cc
llvm/utils/unittest/googletest/src/gtest-filepath.cc
llvm/utils/unittest/googletest/src/gtest-internal-inl.h
llvm/utils/unittest/googletest/src/gtest-matchers.cc
llvm/utils/unittest/googletest/src/gtest-port.cc
llvm/utils/unittest/googletest/src/gtest-printers.cc
llvm/utils/unittest/googletest/src/gtest-test-part.cc
llvm/utils/unittest/googletest/src/gtest-typed-test.cc
llvm/utils/unittest/googletest/src/gtest.cc

Modified: 
clang/CMakeLists.txt
compiler-rt/CMakeLists.txt
lld/CMakeLists.txt
lldb/cmake/modules/LLDBStandalone.cmake
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
mlir/CMakeLists.txt

[PATCH] D134089: [clang] Mention vector in the description for -mno-implict-float.

2022-11-09 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0453857d7402: [clang] Mention vector in the description for 
-mno-implict-float. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134089

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3851,7 +3851,7 @@
 def mno_outline_atomics : Flag<["-"], "mno-outline-atomics">, 
Group, Flags<[CC1Option]>,
   HelpText<"Don't generate local calls to out-of-line atomic operations">;
 def mno_implicit_float : Flag<["-"], "mno-implicit-float">, Group,
-  HelpText<"Don't generate implicit floating point instructions">;
+  HelpText<"Don't generate implicit floating point or vector instructions">;
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, 
Flags<[CC1Option]>,
@@ -5408,7 +5408,7 @@
   HelpText<"Emit an error if a C++ static local initializer would need a guard 
variable">,
   MarshallingInfoFlag>;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,
-  HelpText<"Don't generate implicit floating point instructions">,
+  HelpText<"Don't generate implicit floating point or vector instructions">,
   MarshallingInfoFlag>;
 def fdump_vtable_layouts : Flag<["-"], "fdump-vtable-layouts">,
   HelpText<"Dump the layouts of all vtables that will be emitted in a 
translation unit">,


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3851,7 +3851,7 @@
 def mno_outline_atomics : Flag<["-"], "mno-outline-atomics">, Group, Flags<[CC1Option]>,
   HelpText<"Don't generate local calls to out-of-line atomic operations">;
 def mno_implicit_float : Flag<["-"], "mno-implicit-float">, Group,
-  HelpText<"Don't generate implicit floating point instructions">;
+  HelpText<"Don't generate implicit floating point or vector instructions">;
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>,
@@ -5408,7 +5408,7 @@
   HelpText<"Emit an error if a C++ static local initializer would need a guard variable">,
   MarshallingInfoFlag>;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,
-  HelpText<"Don't generate implicit floating point instructions">,
+  HelpText<"Don't generate implicit floating point or vector instructions">,
   MarshallingInfoFlag>;
 def fdump_vtable_layouts : Flag<["-"], "fdump-vtable-layouts">,
   HelpText<"Dump the layouts of all vtables that will be emitted in a translation unit">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0453857 - [clang] Mention vector in the description for -mno-implict-float.

2022-11-09 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2022-11-09T11:32:19-08:00
New Revision: 0453857d740248a8991ac28981784445dffa8dee

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

LOG: [clang] Mention vector in the description for -mno-implict-float.

As far as I understand, this disables all integer vectors too.

Reviewed By: efriedma

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 70bad936346b6..c096c58440045 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3851,7 +3851,7 @@ def moutline_atomics : Flag<["-"], "moutline-atomics">, 
Group, Fl
 def mno_outline_atomics : Flag<["-"], "mno-outline-atomics">, 
Group, Flags<[CC1Option]>,
   HelpText<"Don't generate local calls to out-of-line atomic operations">;
 def mno_implicit_float : Flag<["-"], "mno-implicit-float">, Group,
-  HelpText<"Don't generate implicit floating point instructions">;
+  HelpText<"Don't generate implicit floating point or vector instructions">;
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, 
Flags<[CC1Option]>,
@@ -5408,7 +5408,7 @@ def fforbid_guard_variables : Flag<["-"], 
"fforbid-guard-variables">,
   HelpText<"Emit an error if a C++ static local initializer would need a guard 
variable">,
   MarshallingInfoFlag>;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,
-  HelpText<"Don't generate implicit floating point instructions">,
+  HelpText<"Don't generate implicit floating point or vector instructions">,
   MarshallingInfoFlag>;
 def fdump_vtable_layouts : Flag<["-"], "fdump-vtable-layouts">,
   HelpText<"Dump the layouts of all vtables that will be emitted in a 
translation unit">,



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


[PATCH] D137154: Adding nvvm_reflect clang builtin

2022-11-09 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: jhuber6.
tra added a comment.

In D137154#3917692 , @hdelan wrote:

> Thanks for feedback. Instead of adding `__nvvm_reflect` as a clang builtin, 
> would it be acceptable if I modified the NVVMReflect pass

That would be less problematic, but I'm still concerned that it would tacitly 
endorse the use of `__nvvm_reflect` by LLVM users.

> so that it works with addrspace casting as well? This would allow us to use 
> `__nvvm_reflect` in openCL

Relaxing argument type checks on `__nvvm_reflect` function would be fine with 
me.

That said,...

TBH, I still don't quite convinced that compiler changes is the right solution 
for making it possible for *one* library to rely on something that was never 
intended to be exposed to compiler users.

Perhaps we should take a step back, figure out the fundamental problem you need 
to solve (as opposed to figuring out how to make a tactical hack work) and then 
figure out a more principled solution.

> In DPC++ for CUDA we use libclc as a wrapper around CUDA SDK's libdevice. 
> Like libdevice we want to precompile libclc to bc for the CUDA backend 
> without specializing for a particular arch, so that we can call different 
> __nv funcs based on the arch. For this reason we use the __nvvm_reflect llvm 
> intrinsic.

For starters, libdevice by itself is something that's not quite intended for 
the end user. It was a rather poor stop-gap solution to address the fact that 
there used to be no linking phase for GPU binaries and no 'standard' math 
library the code could rely on. The library itself does not have anything 
particularly interesting in it. Its major advantage is that it exists, while we 
don't have our own GPU-side libm yet. We do want to get rid of libdevice and 
replace it with an open-source math library of our own. With the recent 
improvements in offloading support in clang driver we're getting closer to 
making it possible.

As for the code specialization, why not build for individual GPUs? To me it 
looks like this use case is a good match for the "new-driver" offloading that's 
been recently implemented in clang. It allows compiling/linking GPU side code 
and that should obviate the need for shipping bitcode and relying on 
`__nvvm_reflect` for specialization.
The downside is that it's a recent feature, so it would not be available in 
older clang versions. @jhuber6 : I'm also not sure if OpenCL is supported by 
the new driver.

With the new driver, you in theory should be able to compile the source with 
`--offload-arch=A --offload-arch=B` and it would produce an object file with 
GPU-specific bitcode or object file which can then be transparently linked into 
the final executable, where clang would also perform final linking of GPU 
binaries, as well.

I realize that it may be hard or not feasible for your project right now. I'm 
OK with allowing limited nvvm_reflect use for the time being, but please do 
consider making things work w/o it or libdevice, if possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137154

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


[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2022-11-09 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D91950#3917635 , @MyDeveloperDay 
wrote:

> I think this is them..
>
> https://twitter.com/xen_org/status/1397581514318225412
> https://xenproject.org/
> https://xenproject.org/2021/09/22/clang-format-for-xen-coding-style-checking-scheduled/
> https://www.youtube.com/watch?v=3EVE0TTEztc
>
> https://github.com/NastyaVicodin

Yep, from that github account I got the mail.


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

https://reviews.llvm.org/D91950

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


[PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D137583#3917706 , @aaron.ballman 
wrote:

>> ...we expect template params to be fully qualified when comparing them for 
>> simple template names
>
> So lldb is not inspecting the AST, they're doing reflection (of a sort) on 
> the pretty printed names? Or am I misunderstanding something?

Not reflection as such - but building names for the user, but partly from the 
AST - basically LLDB wants to be able to produce the same name that CGDebugInfo 
produces - so, maybe it should produce it the same way as CGDebugInfo, which 
isn't to use the pretty printer from scratch.

@aeubanks would this work for lldb's use case? 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGDebugInfo.cpp#L5229
 it'd be identical to the original debug info generation, and looks like it 
doesn't require a printing policy change/feature. Sorry I didn't think of that 
earlier. I guess since `Qualified` would be `false` for lldb's use case, you 
could go down into the implementation and just call the unqualified side 
directly: `NamedDecl::printName(OS, Policy);` should print it unqualified for 
this name, but respect the qualified printing policy flag for any nested names, 
parameters, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

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


[PATCH] D137372: [Test][[AIX][pg] Add 32-bit linker invocation tests

2022-11-09 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm accepted this revision.
cebowleratibm added a comment.
This revision is now accepted and ready to land.

LGTM.

Test only patch is safe to commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137372

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


[PATCH] D137386: [clang][Interp] Reject invalid declarations and expressions

2022-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1235-1236
 bool ByteCodeExprGen::visitDecl(const VarDecl *VD) {
-  Optional VarT = classify(VD->getType());
+  if (VD->isInvalidDecl())
+return false;
 

Because we can't find a case where we hit this, I think we should try asserting 
instead.


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

https://reviews.llvm.org/D137386

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


[PATCH] D131919: Move googletest to the third-party directory

2022-11-09 Thread Tom Stellard 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 rG59052468c3e3: Move googletest to the third-party directory 
(authored by tstellar).

Changed prior to commit:
  https://reviews.llvm.org/D131919?vs=468784=474310#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131919

Files:
  clang/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/utils/unittest/CMakeLists.txt
  llvm/utils/unittest/UnitTestMain/CMakeLists.txt
  llvm/utils/unittest/UnitTestMain/TestMain.cpp
  llvm/utils/unittest/googlemock/LICENSE.txt
  llvm/utils/unittest/googlemock/README.LLVM
  llvm/utils/unittest/googlemock/include/gmock/gmock-actions.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-cardinalities.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-function-mocker.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-generated-actions.h
  
llvm/utils/unittest/googlemock/include/gmock/gmock-generated-function-mockers.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-generated-matchers.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-matchers.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-more-actions.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-more-matchers.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-nice-strict.h
  llvm/utils/unittest/googlemock/include/gmock/gmock-spec-builders.h
  llvm/utils/unittest/googlemock/include/gmock/gmock.h
  
llvm/utils/unittest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h
  llvm/utils/unittest/googlemock/include/gmock/internal/custom/gmock-matchers.h
  llvm/utils/unittest/googlemock/include/gmock/internal/custom/gmock-port.h
  llvm/utils/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h
  llvm/utils/unittest/googlemock/include/gmock/internal/gmock-port.h
  llvm/utils/unittest/googlemock/include/gmock/internal/gmock-pp.h
  llvm/utils/unittest/googlemock/src/gmock-all.cc
  llvm/utils/unittest/googlemock/src/gmock-cardinalities.cc
  llvm/utils/unittest/googlemock/src/gmock-internal-utils.cc
  llvm/utils/unittest/googlemock/src/gmock-matchers.cc
  llvm/utils/unittest/googlemock/src/gmock-spec-builders.cc
  llvm/utils/unittest/googlemock/src/gmock.cc
  llvm/utils/unittest/googletest/LICENSE.TXT
  llvm/utils/unittest/googletest/README.LLVM
  llvm/utils/unittest/googletest/include/gtest/gtest-death-test.h
  llvm/utils/unittest/googletest/include/gtest/gtest-matchers.h
  llvm/utils/unittest/googletest/include/gtest/gtest-message.h
  llvm/utils/unittest/googletest/include/gtest/gtest-param-test.h
  llvm/utils/unittest/googletest/include/gtest/gtest-printers.h
  llvm/utils/unittest/googletest/include/gtest/gtest-spi.h
  llvm/utils/unittest/googletest/include/gtest/gtest-test-part.h
  llvm/utils/unittest/googletest/include/gtest/gtest-typed-test.h
  llvm/utils/unittest/googletest/include/gtest/gtest.h
  llvm/utils/unittest/googletest/include/gtest/gtest_pred_impl.h
  llvm/utils/unittest/googletest/include/gtest/gtest_prod.h
  llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest-port.h
  llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
  llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest.h
  llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h
  
llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-filepath.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-param-util.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-port-arch.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-string.h
  llvm/utils/unittest/googletest/include/gtest/internal/gtest-type-util.h
  llvm/utils/unittest/googletest/src/gtest-all.cc
  llvm/utils/unittest/googletest/src/gtest-death-test.cc
  llvm/utils/unittest/googletest/src/gtest-filepath.cc
  llvm/utils/unittest/googletest/src/gtest-internal-inl.h
  llvm/utils/unittest/googletest/src/gtest-matchers.cc
  llvm/utils/unittest/googletest/src/gtest-port.cc
  llvm/utils/unittest/googletest/src/gtest-printers.cc
  llvm/utils/unittest/googletest/src/gtest-test-part.cc
  llvm/utils/unittest/googletest/src/gtest-typed-test.cc
  llvm/utils/unittest/googletest/src/gtest.cc
  mlir/CMakeLists.txt
  polly/CMakeLists.txt
  third-party/unittest/CMakeLists.txt
  third-party/unittest/UnitTestMain/CMakeLists.txt
  third-party/unittest/UnitTestMain/TestMain.cpp
  third-party/unittest/googlemock/LICENSE.txt
  third-party/unittest/googlemock/README.LLVM
  

[PATCH] D137232: [clang][Interp] Support inc/dec operators on pointers

2022-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/AST/Interp/arrays.cpp:216
 
-  static_assert(getNextElem(E, 1) == 3);
-#endif
+  static_assert(getNextElem(E, 1) == 3, "");
+

aaron.ballman wrote:
> I'd like test cases where the pointer arithmetic has run off the 
> beginning/end of the object (forming the invalid pointer is UB per 
> http://eel.is/c++draft/expr.add#4.3 even if you never dereference the 
> pointer).
```
constexpr int bad1() {
  const int *e =  E + 3;
  e++; // This is fine because it's a one-past-the-end pointer
  return *e; // This is UB
}

constexpr int bad2() {
  const int *e = E + 4;
  e++; // This is UB
  return *e; // This is UB as well
}

constexpr int bad3() {
  const int *e = E;
  --e; // This is UB
  return *e; // This is UB as well
}
```


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

https://reviews.llvm.org/D137232

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


[PATCH] D137550: [clangd] Fix the code action `RemoveUsingNamespace`

2022-11-09 Thread Tom Praschan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82ca918b5755: [clangd] Fix the code action 
`RemoveUsingNamespace` (authored by v1nh1shungry, committed by tom-anders).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137550

Files:
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -249,6 +249,21 @@
 ns::Foo foo;
 foo + 10;
   }
+)cpp"},
+  {// Does not qualify user-defined literals
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  using namespace n^s;
+  int main() { 1.5_w; }
+)cpp",
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  
+  int main() { 1.5_w; }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -155,12 +155,23 @@
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
+auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.
 //   using namespace std;
 //   cout << "foo"; // Must not changed to std::cout std:: << "foo"
-// FIXME: User-defined literals are not handled
-if (T->isInIdentifierNamespace(
-Decl::IdentifierNamespace::IDNS_NonMemberOperator))
+if (Kind == DeclarationName::CXXOperatorName)
+  return;
+// Avoid adding qualifiers before user-defined literals, e.g.
+//   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
+// FIXME: Add a using-directive for user-defined literals
+// declared in an inline namespace, e.g.
+//   using namespace s^td;
+//   int main() { cout << "foo"s; }
+// change to
+//   using namespace std::literals;
+//   int main() { std::cout << "foo"s; }
+if (Kind == DeclarationName::NameKind::CXXLiteralOperatorName)
   return;
   }
   SourceLocation Loc = Ref.NameLoc;


Index: clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -249,6 +249,21 @@
 ns::Foo foo;
 foo + 10;
   }
+)cpp"},
+  {// Does not qualify user-defined literals
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  using namespace n^s;
+  int main() { 1.5_w; }
+)cpp",
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  
+  int main() { 1.5_w; }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -155,12 +155,23 @@
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
+auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.
 //   using namespace std;
 //   cout << "foo"; // Must not changed to std::cout std:: << "foo"
-// FIXME: User-defined literals are not handled
-if (T->isInIdentifierNamespace(
-Decl::IdentifierNamespace::IDNS_NonMemberOperator))
+if (Kind == DeclarationName::CXXOperatorName)
+  return;
+// Avoid adding qualifiers before user-defined literals, e.g.
+//   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
+// FIXME: Add a using-directive for 

[clang-tools-extra] 82ca918 - [clangd] Fix the code action `RemoveUsingNamespace`

2022-11-09 Thread Tom Praschan via cfe-commits

Author: v1nh1shungry
Date: 2022-11-09T21:04:21+01:00
New Revision: 82ca918b5755f3c442e247563dc011f7b310e446

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

LOG: [clangd] Fix the code action `RemoveUsingNamespace`

Avoid adding qualifiers before user-defined literals

Reviewed By: tom-anders

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
index 93fdbb9486cc7..f4228ae0be1f8 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -155,12 +155,23 @@ Expected RemoveUsingNamespace::apply(const 
Selection ) {
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
+auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.
 //   using namespace std;
 //   cout << "foo"; // Must not changed to std::cout std:: << "foo"
-// FIXME: User-defined literals are not handled
-if (T->isInIdentifierNamespace(
-Decl::IdentifierNamespace::IDNS_NonMemberOperator))
+if (Kind == DeclarationName::CXXOperatorName)
+  return;
+// Avoid adding qualifiers before user-defined literals, e.g.
+//   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
+// FIXME: Add a using-directive for user-defined literals
+// declared in an inline namespace, e.g.
+//   using namespace s^td;
+//   int main() { cout << "foo"s; }
+// change to
+//   using namespace std::literals;
+//   int main() { std::cout << "foo"s; }
+if (Kind == DeclarationName::NameKind::CXXLiteralOperatorName)
   return;
   }
   SourceLocation Loc = Ref.NameLoc;

diff  --git 
a/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
index 3449c6475e3fc..03a46d954fcd4 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -249,6 +249,21 @@ TEST_F(RemoveUsingNamespaceTest, All) {
 ns::Foo foo;
 foo + 10;
   }
+)cpp"},
+  {// Does not qualify user-defined literals
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  using namespace n^s;
+  int main() { 1.5_w; }
+)cpp",
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  
+  int main() { 1.5_w; }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;



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


[PATCH] D137583: [lldb] Fix simple template names and template params with scope qualifiers

2022-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> ...we expect template params to be fully qualified when comparing them for 
> simple template names

So lldb is not inspecting the AST, they're doing reflection (of a sort) on the 
pretty printed names? Or am I misunderstanding something?




Comment at: clang/include/clang/AST/PrettyPrinter.h:134
+  /// When SuppressScope is true, do not apply it to template parameters.
+  unsigned NoSuppressTemplateParamsScope : 1;
+

I think this should be expressed in the positive rather than in the negative 
(`SuppressTemplateParamScope`) so it's consistent with the rest of the options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137583

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


[PATCH] D137154: Adding nvvm_reflect clang builtin

2022-11-09 Thread Hugh Delaney via Phabricator via cfe-commits
hdelan added a comment.

Thanks for feedback. Instead of adding `__nvvm_reflect` as a clang builtin, 
would it be acceptable if I modified the NVVMReflect pass so that it works with 
addrspace casting as well? This would allow us to use `__nvvm_reflect` in openCL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137154

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


[PATCH] D137719: [clang] Missed rounding mode use in constant evaluation

2022-11-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 474304.
sepavloff added a comment.

Remove accidentally added file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137719

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/const-fpfeatures.c


Index: clang/test/AST/const-fpfeatures.c
===
--- clang/test/AST/const-fpfeatures.c
+++ clang/test/AST/const-fpfeatures.c
@@ -13,6 +13,9 @@
 // CHECK: @F2u = {{.*}} float 0x3FF02000
 // CHECK: @F3u = {{.*}} float 0x3FF02000
 
+float FI1u = 0xU;
+// CHECK: @FI1u = {{.*}} float 0x41F0
+
 float _Complex C1u = C0;
 // CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 
0x3FF02000 }
 
@@ -27,5 +30,8 @@
 // CHECK: @F2d = {{.*}} float 1.00e+00
 // CHECK: @F3d = {{.*}} float 1.00e+00
 
+float FI1d = 0xU;
+// CHECK: @FI1d = {{.*}} float 0x41EFE000
+
 float _Complex C1d = C0;
 // CHECK: @C1d = {{.*}} { float, float } { float 1.00e+00, float 
1.00e+00 }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2644,18 +2644,12 @@
 }
 
 static bool HandleIntToFloatCast(EvalInfo , const Expr *E,
- const FPOptions FPO,
- QualType SrcType, const APSInt ,
- QualType DestType, APFloat ) {
+ const APSInt , QualType DestType,
+ APFloat ) {
   Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
-  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(),
-   APFloat::rmNearestTiesToEven);
-  if (!Info.InConstantContext && St != llvm::APFloatBase::opOK &&
-  FPO.isFPConstrained()) {
-Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
-return false;
-  }
-  return true;
+  llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
+  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
+  return checkFloatingPointResult(Info, E, St);
 }
 
 static bool truncateBitfieldValue(EvalInfo , const Expr *E,
@@ -4413,11 +4407,8 @@
   Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS);
   return true;
 } else if (RHS.isFloat()) {
-  const FPOptions FPO = E->getFPFeaturesInEffect(
-Info.Ctx.getLangOpts());
   APFloat FValue(0.0);
-  return HandleIntToFloatCast(Info, E, FPO, SubobjType, Value,
-  PromotedLHSType, FValue) &&
+  return HandleIntToFloatCast(Info, E, Value, PromotedLHSType, FValue) &&
  handleFloatFloatBinOp(Info, E, FValue, Opcode, RHS.getFloat()) &&
  HandleFloatToIntCast(Info, E, PromotedLHSType, FValue, SubobjType,
   Value);
@@ -14169,11 +14160,8 @@
 
   case CK_IntegralToFloating: {
 APSInt IntResult;
-const FPOptions FPO = E->getFPFeaturesInEffect(
-  Info.Ctx.getLangOpts());
 return EvaluateInteger(SubExpr, IntResult, Info) &&
-   HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(),
-IntResult, E->getType(), Result);
+   HandleIntToFloatCast(Info, E, IntResult, E->getType(), Result);
   }
 
   case CK_FixedPointToFloating: {
@@ -14414,16 +14402,11 @@
 if (!Visit(E->getSubExpr()))
   return false;
 
-const FPOptions FPO = E->getFPFeaturesInEffect(
-  Info.Ctx.getLangOpts());
 QualType To = E->getType()->castAs()->getElementType();
-QualType From
-  = E->getSubExpr()->getType()->castAs()->getElementType();
 Result.makeComplexFloat();
-return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal,
-To, Result.FloatReal) &&
-   HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag,
-To, Result.FloatImag);
+return HandleIntToFloatCast(Info, E, Result.IntReal, To,
+Result.FloatReal) &&
+   HandleIntToFloatCast(Info, E, Result.IntImag, To, Result.FloatImag);
   }
   }
 


Index: clang/test/AST/const-fpfeatures.c
===
--- clang/test/AST/const-fpfeatures.c
+++ clang/test/AST/const-fpfeatures.c
@@ -13,6 +13,9 @@
 // CHECK: @F2u = {{.*}} float 0x3FF02000
 // CHECK: @F3u = {{.*}} float 0x3FF02000
 
+float FI1u = 0xU;
+// CHECK: @FI1u = {{.*}} float 0x41F0
+
 float _Complex C1u = C0;
 // CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 0x3FF02000 }
 
@@ -27,5 +30,8 @@
 // CHECK: @F2d = {{.*}} float 1.00e+00
 // CHECK: @F3d = {{.*}} 

[PATCH] D137719: [clang] Missed rounding mode use in constant evaluation

2022-11-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 474303.
sepavloff added a comment.

Removed unused parateters from HandleIntToFloatCast


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137719

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/const-fpfeatures.c
  clang/test/Sema/constant-conversion.c

Index: clang/test/Sema/constant-conversion.c
===
--- clang/test/Sema/constant-conversion.c
+++ clang/test/Sema/constant-conversion.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -verify=expected,one-bit -triple x86_64-apple-darwin %s
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wno-single-bit-bitfield-constant-conversion -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wno-unknown-pragmas -verify=expected,one-bit -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -Wno-unknown-pragmas -Wno-single-bit-bitfield-constant-conversion -verify -triple x86_64-apple-darwin %s
 
 #include 
 
Index: clang/test/AST/const-fpfeatures.c
===
--- clang/test/AST/const-fpfeatures.c
+++ clang/test/AST/const-fpfeatures.c
@@ -13,6 +13,9 @@
 // CHECK: @F2u = {{.*}} float 0x3FF02000
 // CHECK: @F3u = {{.*}} float 0x3FF02000
 
+float FI1u = 0xU;
+// CHECK: @FI1u = {{.*}} float 0x41F0
+
 float _Complex C1u = C0;
 // CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 0x3FF02000 }
 
@@ -27,5 +30,8 @@
 // CHECK: @F2d = {{.*}} float 1.00e+00
 // CHECK: @F3d = {{.*}} float 1.00e+00
 
+float FI1d = 0xU;
+// CHECK: @FI1d = {{.*}} float 0x41EFE000
+
 float _Complex C1d = C0;
 // CHECK: @C1d = {{.*}} { float, float } { float 1.00e+00, float 1.00e+00 }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2644,18 +2644,12 @@
 }
 
 static bool HandleIntToFloatCast(EvalInfo , const Expr *E,
- const FPOptions FPO,
- QualType SrcType, const APSInt ,
- QualType DestType, APFloat ) {
+ const APSInt , QualType DestType,
+ APFloat ) {
   Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
-  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(),
-   APFloat::rmNearestTiesToEven);
-  if (!Info.InConstantContext && St != llvm::APFloatBase::opOK &&
-  FPO.isFPConstrained()) {
-Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
-return false;
-  }
-  return true;
+  llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
+  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
+  return checkFloatingPointResult(Info, E, St);
 }
 
 static bool truncateBitfieldValue(EvalInfo , const Expr *E,
@@ -4413,11 +4407,8 @@
   Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS);
   return true;
 } else if (RHS.isFloat()) {
-  const FPOptions FPO = E->getFPFeaturesInEffect(
-Info.Ctx.getLangOpts());
   APFloat FValue(0.0);
-  return HandleIntToFloatCast(Info, E, FPO, SubobjType, Value,
-  PromotedLHSType, FValue) &&
+  return HandleIntToFloatCast(Info, E, Value, PromotedLHSType, FValue) &&
  handleFloatFloatBinOp(Info, E, FValue, Opcode, RHS.getFloat()) &&
  HandleFloatToIntCast(Info, E, PromotedLHSType, FValue, SubobjType,
   Value);
@@ -14169,11 +14160,8 @@
 
   case CK_IntegralToFloating: {
 APSInt IntResult;
-const FPOptions FPO = E->getFPFeaturesInEffect(
-  Info.Ctx.getLangOpts());
 return EvaluateInteger(SubExpr, IntResult, Info) &&
-   HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(),
-IntResult, E->getType(), Result);
+   HandleIntToFloatCast(Info, E, IntResult, E->getType(), Result);
   }
 
   case CK_FixedPointToFloating: {
@@ -14414,16 +14402,11 @@
 if (!Visit(E->getSubExpr()))
   return false;
 
-const FPOptions FPO = E->getFPFeaturesInEffect(
-  Info.Ctx.getLangOpts());
 QualType To = E->getType()->castAs()->getElementType();
-QualType From
-  = E->getSubExpr()->getType()->castAs()->getElementType();
 Result.makeComplexFloat();
-return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal,
-To, Result.FloatReal) &&
-   HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag,
-To, Result.FloatImag);
+

[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D137724#3917644 , @MaskRay wrote:

> I think `if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)` checks for 
> standalone builds is not necessary. The check in `llvm/CMakeLists.txt` 
> suffices.
> It's unlikely the users will use different cmake versions to configure llvm 
> and a subproject like clang.

I can remove the others, but we need to keep the one in 
`runtimes/CMakeLists.txt` too. The runtimes (libc++, libc++abi, and libunwind) 
can be build without building or configuring LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision as: MaskRay.
MaskRay added a comment.

I think `if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)` checks for 
standalone builds is not necessary. The check in `llvm/CMakeLists.txt` suffices.
It's unlikely the users will use different cmake versions to configure llvm and 
a subproject like clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D136146: [Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu options

2022-11-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

In D136146#3911137 , @SixWeining 
wrote:

> Sorry for the late reply.
>
> Should we choose not to implement the `-mfpu=` option which is not mandatory?

OK, I accept the `-mfpu=` different from `-m*-float`. If the patch does not 
implement the required semantics, deferring `-mfpu=` implementation may be good.
We can also check how many pieces of software actually use `-mfpu=` and some 
unneeded uses may be removed?




Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:696
+def err_drv_loongarch_invalid_mfpu_EQ : Error<
+  "invalid argument '%0' to -mfpu=; must be one of: 64, 32, 0, none">;
 }

`0, none (alias for 0)` or `none, 0 (alias for none)`

Ideally only one spelling is retained... No need to implement an alias if 
-mfpu= itself is niche.



Comment at: llvm/lib/Support/LoongArchTargetParser.cpp:46
+if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID) {
+  Features.push_back(F.Name);
+}

SixWeining wrote:
> MaskRay wrote:
> > delete braces
> OK.
`for (const auto A : AllArchs)` needs braces since the nested `if (A.Name == 
Arch) {` has braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136146

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


[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2022-11-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think this is them..

https://twitter.com/xen_org/status/1397581514318225412

https://xenproject.org/


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

https://reviews.llvm.org/D91950

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


[PATCH] D135859: [Includecleaner] Introduce RefType to ast walking

2022-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sent out rG453c2879cb2ad6c46267ef8f39f0274aed69d9ee 
 to fix 
this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135859

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


[clang-tools-extra] 453c287 - [include-cleaner] Add dependency to fix build with shared libraries

2022-11-09 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2022-11-09T18:31:14+01:00
New Revision: 453c2879cb2ad6c46267ef8f39f0274aed69d9ee

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

LOG: [include-cleaner] Add dependency to fix build with shared libraries

Added: 


Modified: 
clang-tools-extra/include-cleaner/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/unittests/CMakeLists.txt 
b/clang-tools-extra/include-cleaner/unittests/CMakeLists.txt
index ba9fc6419f388..8fdd855c7a1a6 100644
--- a/clang-tools-extra/include-cleaner/unittests/CMakeLists.txt
+++ b/clang-tools-extra/include-cleaner/unittests/CMakeLists.txt
@@ -19,6 +19,7 @@ clang_target_link_libraries(ClangIncludeCleanerTests
   clangAST
   clangBasic
   clangFrontend
+  clangLex
   clangToolingInclusionsStdlib
   )
 



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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D137724#3917616 , @thieta wrote:

> I think this is fine as we have discussed before. But I really dislike the 
> code duplication for the check. We could put it in a include() I guess - but 
> maybe it's not worth it.

I wanted to make sure it shows up in different build scenarios. The code is 
temporary, once we switch to CMake 3.20.0 we can just change the 
`cmake_minimum_required` and remove these verbose blocks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta accepted this revision as: thieta.
thieta added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, JDevlieghere.

I think this is fine as we have discussed before. But I really dislike the code 
duplication for the check. We could put it in a include() I guess - but maybe 
it's not worth it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137712: Correctly handle Substitution failure in concept specialization.

2022-11-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I dont have a good hold as to why this is the solution, can you better explain 
the issue and the solution that you made?  I will take a look when I get a 
chance next week, as the ISO meeting is taking up my week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137712

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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Herald added a reviewer: bollu.
Herald added subscribers: Moerafaat, zero9178, Enna1, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini.
Herald added projects: Flang, All.
Mordante edited the summary of this revision.
Mordante added reviewers: libc++ vendors, clang-vendors, tstellar, mehdi_amini, 
MaskRay, ChuanqiXu, to268, kparzysz, thieta, tschuett, mgorny, stellaraccident, 
mizvekov, ldionne.
Herald added subscribers: StephenFan, jdoerfert.
Mordante published this revision for review.
Herald added subscribers: llvm-commits, libcxx-commits, openmp-commits, 
lldb-commits, Sanitizers, cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc++abi, 
MLIR, LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.

This is a preparation to require CMake 3.20.0 after LLVM 16 has been
released.

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137724

Files:
  clang/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/lib/crt/CMakeLists.txt
  flang/CMakeLists.txt
  flang/runtime/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/tools/debugserver/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/docs/ReleaseNotes.rst
  mlir/CMakeLists.txt
  openmp/CMakeLists.txt
  polly/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -1,5 +1,12 @@
 # This file handles building LLVM runtime sub-projects.
 cmake_minimum_required(VERSION 3.13.4)
+if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+  message(WARNING
+"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+"minimum version of CMake required to build LLVM will become 3.20.0, and "
+"using an older CMake will become an error. Please upgrade your CMake to "
+"at least 3.20.0 now to avoid issues in the future!")
+endif()
 project(Runtimes C CXX ASM)
 
 # Add path for custom and the LLVM build's modules to the CMake module path.
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -2,6 +2,13 @@
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
   cmake_minimum_required(VERSION 3.13.4)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING
+  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+  "minimum version of CMake required to build LLVM will become 3.20.0, and "
+  "using an older CMake will become an error. Please upgrade your CMake to "
+  "at least 3.20.0 now to avoid issues in the future!")
+  endif()
   set(POLLY_STANDALONE_BUILD TRUE)
 endif()
 
Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -12,6 +12,13 @@
 if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
   set(OPENMP_STANDALONE_BUILD TRUE)
   project(openmp C CXX)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING
+  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+  "minimum version of CMake required to build LLVM will become 3.20.0, and "
+  "using an older CMake will become an error. Please upgrade your CMake to "
+  "at least 3.20.0 now to avoid issues in the future!")
+  endif()
 endif()
 
 # Must go below project(..)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -11,6 +11,13 @@
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(mlir)
   set(MLIR_STANDALONE_BUILD TRUE)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING
+  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+  "minimum version of CMake required to build LLVM will become 3.20.0, and "
+  "using an older CMake will become an error. Please upgrade your CMake to "
+  "at least 3.20.0 now to avoid issues in the future!")
+  endif()
 endif()
 
 # Must go below project(..)
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -64,6 +64,17 @@
 * Apple Clang >= 10.0
 * Visual Studio 2019 >= 16.7
 
+With LLVM 16.x we will raise the version requirement of CMake used to build
+LLVM. The new requirements are as follows:
+
+* CMake >= 3.20.0
+
+In LLVM 16.x 

[PATCH] D137722: [clang][analyzer] No new nodes when bug is detected in StdLibraryFunctionsChecker.

2022-11-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, gamesh411, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a reviewer: NoQ.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If a constraint violation was found the already applied other constraints were 
already added
and analysis was continuing on this path even if bug is reported. After the fix 
the error node
is added as the last node on the current path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137722

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -20,6 +20,7 @@
 // RUN:   -verify=bugpath
 
 void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
 
 int glob;
 
@@ -215,6 +216,20 @@
 // bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 }
+void test_no_node_after_bug(FILE *fp, size_t size, size_t n, void *buf) {
+  if (fp) // \
+  // bugpath-note{{Assuming 'fp' is null}} \
+  // bugpath-note{{Taking false branch}}
+return;
+  size_t ret = fread(buf, size, n, fp); // \
+  // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+  clang_analyzer_warnIfReached(); // not reachable
+}
+
 typedef __WCHAR_TYPE__ wchar_t;
 // This is one test case for the ARR38-C SEI-CERT rule.
 void ARR38_C_F(FILE *file) {
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -950,7 +950,7 @@
 Constraint->negate()->apply(NewState, Call, Summary, C);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
-  if (ExplodedNode *N = C.generateErrorNode(NewState))
+  if (ExplodedNode *N = C.generateErrorNode(NewState, NewNode))
 reportBug(Call, N, Constraint.get(), Summary, C);
   break;
 }
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -211,6 +211,22 @@
(Tag ? Tag : Location.getTag()));
   }
 
+  /// Generate a transition to a node that will be used to report
+  /// an error. This node will be a sink. That is, it will stop exploration of
+  /// the given path.
+  ///
+  /// @param State The state of the generated node.
+  /// @param Pred The transition will be generated from the specified Pred node
+  /// to the newly generated node.
+  /// @param Tag The tag to uniquely identify the creation site. If null,
+  ///the default tag for the checker will be used.
+  ExplodedNode *generateErrorNode(ProgramStateRef State,
+  ExplodedNode *Pred,
+  const ProgramPointTag *Tag = nullptr) {
+return generateSink(State, Pred,
+   (Tag ? Tag : Location.getTag()));
+  }
+
   /// Generate a transition to a node that will be used to report
   /// an error. This node will not be a sink. That is, exploration will
   /// continue along this path.


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -20,6 +20,7 @@
 // RUN:   -verify=bugpath
 
 void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
 
 int glob;
 
@@ -215,6 +216,20 @@
 // bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 }
+void test_no_node_after_bug(FILE *fp, size_t size, size_t n, void *buf) {
+  if (fp) // \
+  // bugpath-note{{Assuming 'fp' is null}} \
+  // bugpath-note{{Taking false branch}}
+return;
+  size_t ret = fread(buf, size, n, fp); // \
+  // report-warning{{Function argument constraint is not satisfied}} \
+  // 

[PATCH] D135859: [Includecleaner] Introduce RefType to ast walking

2022-11-09 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo added a comment.

@kadircet, this commit causes failure on 
https://lab.llvm.org/buildbot/#/builders/121 which is possible to reproduce 
locally, can you please take a look?

[

  35/111] Linking CXX executable 
tools/clang/tools/extra/include-cleaner/unittests/ClangIncludeCleanerTests
  FAILED: 
tools/clang/tools/extra/include-cleaner/unittests/ClangIncludeCleanerTests 
  : && /usr/lib64/ccache/c++  -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,--gc-sections 
tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/AnalysisTest.cpp.o
 
tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/RecordTest.cpp.o
 
tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/WalkASTTest.cpp.o
  -o tools/clang/tools/extra/include-cleaner/unittests/ClangIncludeCleanerTests 
 
-Wl,-rpath,/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib
  -lpthread  lib/libllvm_gtest_main.so.16git  -lpthread  
lib/libclangIncludeCleaner.so.16git  lib/libclangTesting.so.16git  
lib/libLLVMTestingSupport.so.16git  
lib/libclangToolingInclusionsStdlib.so.16git  lib/libllvm_gtest.so.16git  
lib/libclangFrontend.so.16git  lib/libclangAST.so.16git  
lib/libclangBasic.so.16git  lib/libLLVMSupport.so.16git  
-Wl,-rpath-link,/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib
 && :
  /usr/bin/ld: 
tools/clang/tools/extra/include-cleaner/unittests/CMakeFiles/ClangIncludeCleanerTests.dir/RecordTest.cpp.o:
 undefined reference to symbol '_ZTVN5clang18PPChainedCallbacksE'
  
/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib/libclangLex.so.16git:
 error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status
  [79/111] cd 
/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/clang/bindings/python
 && /usr/local/bin/cmake -E env 
CLANG_LIBRARY_PATH=/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib
 /usr/bin/python3.6 -m unittest discover
  ..
  
  
  cmake -G Ninja ../llvm-project/llvm -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=True '-DLLVM_LIT_ARGS='"'"'-v'"'"'' 
-DCMAKE_INSTALL_PREFIX=../stage1.install -DLLVM_ENABLE_ASSERTIONS=ON 
-DLLVM_ENABLE_RUNTIMES=compiler-rt -DBUILD_SHARED_LIBS=ON 
-DLLVM_CCACHE_BUILD=ON '-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra;llvm'
  
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135859

___
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-09 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 474284.
TIFitis added a comment.

Fix commit message indentation.


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 , 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  = *InternalVars.try_emplace(RuntimeName, nullptr).first;
+GlobalVariable *
+OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef ,
+ unsigned AddressSpace) {
+  auto  = *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 ,
-   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,16 @@
   void
   loadOffloadInfoMetadata(Module ,
   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(llvm::Type *Ty,
+  const llvm::StringRef ,
+ 

[PATCH] D137719: [clang] Missed rounding mode use in constant evaluation

2022-11-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2653
+  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
+  return checkFloatingPointResult(Info, E, St);
 }

tbaeder wrote:
> `SrcType` was already unused before, but not so is `FPO`.
//now// so is `FPO`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137719

___
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-09 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis created this revision.
TIFitis added reviewers: jdoerfert, jsjodin.
Herald added a subscriber: hiraditya.
Herald added a project: All.
TIFitis requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

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


Repository:
  rG LLVM Github Monorepo

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 , 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  = *InternalVars.try_emplace(RuntimeName, nullptr).first;
+GlobalVariable *
+OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef ,
+ unsigned AddressSpace) {
+  auto  = *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 ,
-   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,16 @@
   void
   loadOffloadInfoMetadata(Module ,
   OffloadEntriesInfoManager );
+
+  /// Gets (if variable with the given name already exist) or creates
+  /// internal global variable with the specified Name. The created 

[PATCH] D137719: [clang] Missed rounding mode use in constant evaluation

2022-11-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2653
+  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
+  return checkFloatingPointResult(Info, E, St);
 }

`SrcType` was already unused before, but not so is `FPO`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137719

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


[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

2022-11-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Patch https://reviews.llvm.org/D137719 fixed int->float conversion.


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

https://reviews.llvm.org/D134859

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


[PATCH] D137719: [clang] Missed rounding mode use in constant evaluation

2022-11-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, efriedma, aaron.ballman.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a project: clang.

Integer-to-float conversion was handled in constant evaluator with
default rounding mode. This change fixes the behavior and the conversion
is made using rounding mode stored in ImplicitCastExpr node.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137719

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/const-fpfeatures.c


Index: clang/test/AST/const-fpfeatures.c
===
--- clang/test/AST/const-fpfeatures.c
+++ clang/test/AST/const-fpfeatures.c
@@ -13,6 +13,9 @@
 // CHECK: @F2u = {{.*}} float 0x3FF02000
 // CHECK: @F3u = {{.*}} float 0x3FF02000
 
+float FI1u = 0xU;
+// CHECK: @FI1u = {{.*}} float 0x41F0
+
 float _Complex C1u = C0;
 // CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 
0x3FF02000 }
 
@@ -27,5 +30,8 @@
 // CHECK: @F2d = {{.*}} float 1.00e+00
 // CHECK: @F3d = {{.*}} float 1.00e+00
 
+float FI1d = 0xU;
+// CHECK: @FI1d = {{.*}} float 0x41EFE000
+
 float _Complex C1d = C0;
 // CHECK: @C1d = {{.*}} { float, float } { float 1.00e+00, float 
1.00e+00 }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2648,14 +2648,9 @@
  QualType SrcType, const APSInt ,
  QualType DestType, APFloat ) {
   Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
-  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(),
-   APFloat::rmNearestTiesToEven);
-  if (!Info.InConstantContext && St != llvm::APFloatBase::opOK &&
-  FPO.isFPConstrained()) {
-Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
-return false;
-  }
-  return true;
+  llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
+  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
+  return checkFloatingPointResult(Info, E, St);
 }
 
 static bool truncateBitfieldValue(EvalInfo , const Expr *E,


Index: clang/test/AST/const-fpfeatures.c
===
--- clang/test/AST/const-fpfeatures.c
+++ clang/test/AST/const-fpfeatures.c
@@ -13,6 +13,9 @@
 // CHECK: @F2u = {{.*}} float 0x3FF02000
 // CHECK: @F3u = {{.*}} float 0x3FF02000
 
+float FI1u = 0xU;
+// CHECK: @FI1u = {{.*}} float 0x41F0
+
 float _Complex C1u = C0;
 // CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 0x3FF02000 }
 
@@ -27,5 +30,8 @@
 // CHECK: @F2d = {{.*}} float 1.00e+00
 // CHECK: @F3d = {{.*}} float 1.00e+00
 
+float FI1d = 0xU;
+// CHECK: @FI1d = {{.*}} float 0x41EFE000
+
 float _Complex C1d = C0;
 // CHECK: @C1d = {{.*}} { float, float } { float 1.00e+00, float 1.00e+00 }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2648,14 +2648,9 @@
  QualType SrcType, const APSInt ,
  QualType DestType, APFloat ) {
   Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
-  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(),
-   APFloat::rmNearestTiesToEven);
-  if (!Info.InConstantContext && St != llvm::APFloatBase::opOK &&
-  FPO.isFPConstrained()) {
-Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
-return false;
-  }
-  return true;
+  llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
+  APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
+  return checkFloatingPointResult(Info, E, St);
 }
 
 static bool truncateBitfieldValue(EvalInfo , const Expr *E,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137650: [clangd] Implement hover for string literals

2022-11-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:816
+  if (llvm::isa(E)) {
+HoverInfo::PrintedType PT;
+PT.Type = E->getType().getAsString(PP);

can you extract this into a function, similar to the cases below?



Comment at: clang-tools-extra/clangd/Hover.cpp:819
+HI.Type = PT;
+HI.Name = "String Literal";
+return HI;

i think it's a good idea to also include the size here (e.g. L"XYZ", would be 8 
bytes).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137650

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


[PATCH] D137232: [clang][Interp] Support inc/dec operators on pointers

2022-11-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Opcodes.td:421-425
+// [Pointer] -> []
+def IncPtr : Opcode {
+  let HasGroup = 0;
+}
+// [Pointer] -> []

aaron.ballman wrote:
> Don't both of these result in a `Pointer`? And should they have a `Types` 
> field?
Ah yes, they do. They don't need a type field, we know we're operating on a 
pointer.


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

https://reviews.llvm.org/D137232

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


[PATCH] D137071: [clang][Interp] Implement missing compound assign operators

2022-11-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/test/AST/Interp/literals.cpp:591
+
+  static_assert(IntDiv(INT_MIN, -1) == 0, "");
+

aaron.ballman wrote:
> This one should fail for the same reason as `%`
Works when replacing all the `unsigned`s with `int`s.


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

https://reviews.llvm.org/D137071

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


[PATCH] D137071: [clang][Interp] Implement missing compound assign operators

2022-11-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 474273.

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

https://reviews.llvm.org/D137071

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -469,5 +469,156 @@
 return (a -= a);
   }
   static_assert(subAll(213) == 0, "");
+
+  constexpr bool BoolOr(bool b1, bool b2) {
+bool a;
+a = b1;
+a |= b2;
+return a;
+  }
+  static_assert(BoolOr(true, true), "");
+  static_assert(BoolOr(true, false), "");
+  static_assert(BoolOr(false, true), "");
+  static_assert(!BoolOr(false, false), "");
+
+  constexpr int IntOr(unsigned a, unsigned b) {
+unsigned r;
+r = a;
+r |= b;
+return r;
+  }
+  static_assert(IntOr(10, 1) == 11, "");
+  static_assert(IntOr(1337, -1) == -1, "");
+  static_assert(IntOr(0, 12) == 12, "");
+
+  constexpr bool BoolAnd(bool b1, bool b2) {
+bool a;
+a = b1;
+a &= b2;
+return a;
+  }
+  static_assert(BoolAnd(true, true), "");
+  static_assert(!BoolAnd(true, false), "");
+  static_assert(!BoolAnd(false, true), "");
+  static_assert(!BoolAnd(false, false), "");
+
+  constexpr int IntAnd(unsigned a, unsigned b) {
+unsigned r;
+r = a;
+r &= b;
+return r;
+  }
+  static_assert(IntAnd(10, 1) == 0, "");
+  static_assert(IntAnd(1337, -1) == 1337, "");
+  static_assert(IntAnd(0, 12) == 0, "");
+
+  constexpr bool BoolXor(bool b1, bool b2) {
+bool a;
+a = b1;
+a ^= b2;
+return a;
+  }
+  static_assert(!BoolXor(true, true), "");
+  static_assert(BoolXor(true, false), "");
+  static_assert(BoolXor(false, true), "");
+  static_assert(!BoolXor(false, false), "");
+
+  constexpr int IntXor(unsigned a, unsigned b) {
+unsigned r;
+r = a;
+r ^= b;
+return r;
+  }
+  static_assert(IntXor(10, 1) == 11, "");
+  static_assert(IntXor(10, 10) == 0, "");
+  static_assert(IntXor(12, true) == 13, "");
+
+  constexpr bool BoolRem(bool b1, bool b2) {
+bool a;
+a = b1;
+a %= b2;
+return a;
+  }
+  static_assert(!BoolRem(true, true), "");
+  static_assert(!BoolRem(false, true), "");
+
+  constexpr int IntRem(int a, int b) {
+int r;
+r = a;
+r %= b; // expected-note {{division by zero}} \
+// ref-note {{division by zero}} \
+// expected-note {{outside the range of representable values}}
+return r;
+  }
+  static_assert(IntRem(2, 2) == 0, "");
+  static_assert(IntRem(2, 1) == 0, "");
+  static_assert(IntRem(9, 7) == 2, "");
+  static_assert(IntRem(5, 0) == 0, ""); // expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'IntRem(5, 0)'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'IntRem(5, 0)'}}
+
+  static_assert(IntRem(INT_MIN, -1) == 0, ""); // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'IntRem}}
+
+
+  constexpr bool BoolDiv(bool b1, bool b2) {
+bool a;
+a = b1;
+a /= b2;
+return a;
+  }
+  static_assert(BoolDiv(true, true), "");
+  static_assert(!BoolDiv(false, true), "");
+
+  constexpr int IntDiv(int a, int b) {
+int r;
+r = a;
+r /= b; // expected-note {{division by zero}} \
+// ref-note {{division by zero}} \
+// expected-note {{outside the range of representable values}} \
+// ref-note {{outside the range of representable values}}
+return r;
+  }
+  static_assert(IntDiv(2, 2) == 1, "");
+  static_assert(IntDiv(12, 20) == 0, "");
+  static_assert(IntDiv(2, 1) == 2, "");
+  static_assert(IntDiv(9, 7) == 1, "");
+  static_assert(IntDiv(5, 0) == 0, ""); // expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'IntDiv(5, 0)'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'IntDiv(5, 0)'}}
+
+  static_assert(IntDiv(INT_MIN, -1) == 0, ""); // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'IntDiv}} \
+   // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'IntDiv}}
+
+  constexpr bool BoolMul(bool b1, bool b2) {
+bool a;
+a = b1;
+a *= b2;
+return a;
+  }
+  static_assert(BoolMul(true, true), "");
+  static_assert(!BoolMul(true, false), "");
+  static_assert(!BoolMul(false, true), "");
+  static_assert(!BoolMul(false, false), "");
+
+  

[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-09 Thread Aaron Gokaslan via Phabricator via cfe-commits
Skylion007 added a comment.

Hmm, I still had a crash on this latest code (although it is crashing much more 
rarely now.

It crashes on scanning this file 
https://github.com/facebookresearch/habitat-sim/blob/5fb04078b0b8432dc4a88ec186a2b7af74163be1/src/esp/core/managedContainers/ManagedContainerBase.cpp

  Found compiler error(s).
  /home/aaron/git/llvm-project/build/bin/clang-tidy -checks=-*,*perf*last* 
-export-fixes /tmp/tmp38bqy_w9/tmpa_p4xe5f.yaml -p=build 
/home/aaron/git/habitat-sim/src/esp/core/managedContainers/ManagedContainerBase.cpp
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.Program arguments: /home/aaron/git/llvm-project/build/bin/clang-tidy 
-checks=-*,*perf*last* -export-fixes /tmp/tmp38bqy_w9/tmpa_p4xe5f.yaml -p=build 
/home/aaron/git/habitat-sim/src/esp/core/managedContainers/ManagedContainerBase.cpp
  1. parser at end of file
  2.ASTMatcher: Processing 'performance-unnecessary-copy-on-last-use' 
against:
CXXConstructExpr : 

  --- Bound Nodes Begin ---
  constructExpr - { CXXConstructExpr : 

 }
  param - { DeclRefExpr : 

 }
  --- Bound Nodes End ---
   #0 0x55a33b1c14f4 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
   #1 0x55a33b1bed74 SignalHandler(int) Signals.cpp:0:0
   #2 0x7f80af664420 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
   #3 0x55a338761176 
clang::tidy::performance::UnnecessaryCopyOnLastUseCheck::check(clang::ast_matchers::MatchFinder::MatchResult
 const&) (/home/aaron/git/llvm-project/build/bin/clang-tidy+0x10c7176)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D122385: [clang][deps] Fix clang-cl output argument parsing

2022-11-09 Thread Sylvain Audi via Phabricator via cfe-commits
saudi added inline comments.
Herald added a subscriber: ributzka.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:487
+if (!llvm::sys::path::has_extension(CurrentO))
+  LastO = (CurrentO + ".obj").str();
+else

Before the patch `LastO` string allocation was done only once (because of the 
`!LastO.empty()` test).
It probably would be better to have it of type `StringRef` and allocate once at 
the end


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122385

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


[PATCH] D137618: [Clang] Fix behavior of -ffp-model option when overriden

2022-11-09 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3034
   RoundingFPMath = false;
+  FPExceptionBehavior = "";
   // If fast-math is set then set the fp-contract mode to fast.

 FPExceptionBehavior should be set here and in case options::OPT_ffp_model_EQ:



Comment at: clang/test/Driver/fp-model.c:69
 
+// RUN: %clang -### -ffp-model=fast -ffp-model=strict -c %s 2>&1 | FileCheck \
+// RUN:   --check-prefix=WARN11 %s

Add a RUN command for '-ffast-math -ffp-model=strict'. I would expect the same 
warning.
Currently (without your patch) it is generating this non-sense warning:
https://godbolt.org/z/eW679Y7G3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137618

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


[PATCH] D137550: [clangd] Fix the code action `RemoveUsingNamespace`

2022-11-09 Thread v1nh1shungry via Phabricator via cfe-commits
v1nh1shungry updated this revision to Diff 474262.
v1nh1shungry added a comment.

Format codes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137550

Files:
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -249,6 +249,21 @@
 ns::Foo foo;
 foo + 10;
   }
+)cpp"},
+  {// Does not qualify user-defined literals
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  using namespace n^s;
+  int main() { 1.5_w; }
+)cpp",
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  
+  int main() { 1.5_w; }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -155,12 +155,23 @@
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
+auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.
 //   using namespace std;
 //   cout << "foo"; // Must not changed to std::cout std:: << "foo"
-// FIXME: User-defined literals are not handled
-if (T->isInIdentifierNamespace(
-Decl::IdentifierNamespace::IDNS_NonMemberOperator))
+if (Kind == DeclarationName::CXXOperatorName)
+  return;
+// Avoid adding qualifiers before user-defined literals, e.g.
+//   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
+// FIXME: Add a using-directive for user-defined literals
+// declared in an inline namespace, e.g.
+//   using namespace s^td;
+//   int main() { cout << "foo"s; }
+// change to
+//   using namespace std::literals;
+//   int main() { std::cout << "foo"s; }
+if (Kind == DeclarationName::NameKind::CXXLiteralOperatorName)
   return;
   }
   SourceLocation Loc = Ref.NameLoc;


Index: clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -249,6 +249,21 @@
 ns::Foo foo;
 foo + 10;
   }
+)cpp"},
+  {// Does not qualify user-defined literals
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  using namespace n^s;
+  int main() { 1.5_w; }
+)cpp",
+   R"cpp(
+  namespace ns {
+  long double operator "" _w(long double);
+  }
+  
+  int main() { 1.5_w; }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -155,12 +155,23 @@
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
+auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.
 //   using namespace std;
 //   cout << "foo"; // Must not changed to std::cout std:: << "foo"
-// FIXME: User-defined literals are not handled
-if (T->isInIdentifierNamespace(
-Decl::IdentifierNamespace::IDNS_NonMemberOperator))
+if (Kind == DeclarationName::CXXOperatorName)
+  return;
+// Avoid adding qualifiers before user-defined literals, e.g.
+//   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
+// FIXME: Add a using-directive for user-defined literals
+// declared in an inline namespace, e.g.
+//   using namespace s^td;
+   

  1   2   >