[clang] f4707af - [clang][Interp][NFCI] Cleanup emitConst()

2022-11-07 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-11-07T09:05:29+01:00
New Revision: f4707af2944015732b1f35e1bc66cc62f489cef2

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

LOG: [clang][Interp][NFCI] Cleanup emitConst()

Before, when emitting a regular integer constant, we went:

Int -> APInt -> int -> emit

Fix this by using regular integer constants in emitConst() and instead
converting APInt to those once.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index f3f4ae774886..91b9809861d8 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -160,9 +160,7 @@ bool ByteCodeExprGen::VisitIntegerLiteral(const 
IntegerLiteral *LE) {
   if (DiscardResult)
 return true;
 
-  if (Optional T = classify(LE->getType()))
-return emitConst(*T, LE->getValue(), LE);
-  return this->bail(LE);
+  return this->emitConst(LE->getValue(), LE);
 }
 
 template 
@@ -380,7 +378,7 @@ bool 
ByteCodeExprGen::VisitUnaryExprOrTypeTraitExpr(
   Size = Ctx.getASTContext().getTypeSizeInChars(ArgType);
 }
 
-return this->emitConst(E, Size.getQuantity());
+return this->emitConst(Size.getQuantity(), E);
   }
 
   return false;
@@ -420,9 +418,7 @@ bool ByteCodeExprGen::VisitArrayInitIndexExpr(
   // stand-alone, e.g. via EvaluateAsInt().
   if (!ArrayIndex)
 return false;
-  QualType IndexType = E->getType();
-  APInt Value(getIntWidth(IndexType), *ArrayIndex);
-  return this->emitConst(classifyPrim(IndexType), Value, E);
+  return this->emitConst(*ArrayIndex, E);
 }
 
 template 
@@ -470,7 +466,7 @@ bool ByteCodeExprGen::VisitStringLiteral(const 
StringLiteral *E) {
 template 
 bool ByteCodeExprGen::VisitCharacterLiteral(
 const CharacterLiteral *E) {
-  return this->emitConst(E, E->getValue());
+  return this->emitConst(E->getValue(), E);
 }
 
 template 
@@ -715,27 +711,27 @@ bool ByteCodeExprGen::dereferenceVar(
 }
 
 template 
-bool ByteCodeExprGen::emitConst(PrimType T, const APInt &Value,
- const Expr *E) {
-  switch (T) {
+template 
+bool ByteCodeExprGen::emitConst(T Value, const Expr *E) {
+  switch (classifyPrim(E->getType())) {
   case PT_Sint8:
-return this->emitConstSint8(Value.getSExtValue(), E);
+return this->emitConstSint8(Value, E);
   case PT_Uint8:
-return this->emitConstUint8(Value.getZExtValue(), E);
+return this->emitConstUint8(Value, E);
   case PT_Sint16:
-return this->emitConstSint16(Value.getSExtValue(), E);
+return this->emitConstSint16(Value, E);
   case PT_Uint16:
-return this->emitConstUint16(Value.getZExtValue(), E);
+return this->emitConstUint16(Value, E);
   case PT_Sint32:
-return this->emitConstSint32(Value.getSExtValue(), E);
+return this->emitConstSint32(Value, E);
   case PT_Uint32:
-return this->emitConstUint32(Value.getZExtValue(), E);
+return this->emitConstUint32(Value, E);
   case PT_Sint64:
-return this->emitConstSint64(Value.getSExtValue(), E);
+return this->emitConstSint64(Value, E);
   case PT_Uint64:
-return this->emitConstUint64(Value.getZExtValue(), E);
+return this->emitConstUint64(Value, E);
   case PT_Bool:
-return this->emitConstBool(Value.getBoolValue(), E);
+return this->emitConstBool(Value, E);
   case PT_Ptr:
 llvm_unreachable("Invalid integral type");
 break;
@@ -743,6 +739,13 @@ bool ByteCodeExprGen::emitConst(PrimType T, const 
APInt &Value,
   llvm_unreachable("unknown primitive type");
 }
 
+template 
+bool ByteCodeExprGen::emitConst(const APSInt &Value, const Expr *E) {
+  if (Value.isSigned())
+return this->emitConst(Value.getSExtValue(), E);
+  return this->emitConst(Value.getZExtValue(), E);
+}
+
 template 
 unsigned ByteCodeExprGen::allocateLocalPrimitive(DeclTy &&Src,
   PrimType Ty,
@@ -1198,7 +1201,7 @@ bool ByteCodeExprGen::VisitUnaryOperator(const 
UnaryOperator *E) {
   return this->emitIncPop(*T, E);
 
 this->emitLoad(*T, E);
-this->emitConst(E, 1);
+this->emitConst(1, E);
 this->emitAdd(*T, E);
 return this->emitStore(*T, E);
   }
@@ -1211,7 +1214,7 @@ bool ByteCodeExprGen::VisitUnaryOperator(const 
UnaryOperator *E) {
   return this->emitDecPop(*T, E);
 
 this->emitLoad(*T, E);
-this->emitConst(E, 1);
+this->emitConst(1, E);
 this->emitSub(*T, E);
 return this->emitStore(*T, E);
   }
@@ -1284,9 +1287,7 @@ bool ByteCodeExprGen::VisitDeclRefExpr(const 
DeclRefExpr *E) {
   return this->emitGetPtrParam(It->second, E);
 }
   } else if (const auto *ECD = dyn_cast(Decl)) {
-Prim

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

2022-11-07 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D137040#3909906 , @tom-anders 
wrote:

> We now probably also need a unit test for Sema that tests the new flag, right?

Good point. My understanding is that most test coverage of libSema's code 
completion takes the form of lit tests 
 
which are suitable for checking the completion proposals themselves but not 
flags like this. However, we do have one unittest file 
 
which could be adapted for testing the flag. It may require some light 
refactoring to make this work (e.g. I don't think we can just stuff the 
`CodeCompletionResult`s themselves into the returned `CompletionContext` 
because they point to `Decl`s and such whose lifetime is tied to the AST which 
is destroyed by the time `runCompletion()` returns).




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:414
&Completion.RequiredQualifier, IsPattern);
+  if (!C.SemaResult->FunctionCanBeCall)
+S.SnippetSuffix.clear();

tom-anders wrote:
> Here, the SnippetSuffix is still created and then immediately cleared again. 
> But the logic inside getSignature is quite complex and it's used in multiple 
> places, so I didn't really want to touch that function for now.
Fair enough, we can optimize this later if it turns out to be necessary


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] D137056: [clangd] Fix a small inconsistency in system-include-extractor.test

2022-11-07 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 473588.
nridge added a comment.

address nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137056

Files:
  clang-tools-extra/clangd/test/system-include-extractor.test


Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -11,9 +11,11 @@
 # RUN: echo '#!/bin/sh' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/bin/my_driver.sh" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'args="$*"' >> %t.dir/bin/my_driver.sh
+# Check that clangd preserves certain flags like `-nostdinc` from
+# original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
-# RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> 
%t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> 
%t.dir/bin/my_driver.sh


Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -11,9 +11,11 @@
 # RUN: echo '#!/bin/sh' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/bin/my_driver.sh" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'args="$*"' >> %t.dir/bin/my_driver.sh
+# Check that clangd preserves certain flags like `-nostdinc` from
+# original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
-# RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/bin/my_driver.sh
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137056: [clangd] Fix a small inconsistency in system-include-extractor.test

2022-11-07 Thread Nathan Ridge 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 rG41fa7d2093e0: [clangd] Fix a small inconsistency in 
system-include-extractor.test (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137056

Files:
  clang-tools-extra/clangd/test/system-include-extractor.test


Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -11,9 +11,11 @@
 # RUN: echo '#!/bin/sh' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/bin/my_driver.sh" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'args="$*"' >> %t.dir/bin/my_driver.sh
+# Check that clangd preserves certain flags like `-nostdinc` from
+# original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
-# RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> 
%t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> 
%t.dir/bin/my_driver.sh


Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -11,9 +11,11 @@
 # RUN: echo '#!/bin/sh' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/bin/my_driver.sh" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'args="$*"' >> %t.dir/bin/my_driver.sh
+# Check that clangd preserves certain flags like `-nostdinc` from
+# original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
-# RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/bin/my_driver.sh
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 41fa7d2 - [clangd] Fix a small inconsistency in system-include-extractor.test

2022-11-07 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-11-07T03:29:42-05:00
New Revision: 41fa7d2093e0b7ff5f729b318643e8e18feb

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

LOG: [clangd] Fix a small inconsistency in system-include-extractor.test

Also add an explanatory comment

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

Added: 


Modified: 
clang-tools-extra/clangd/test/system-include-extractor.test

Removed: 




diff  --git a/clang-tools-extra/clangd/test/system-include-extractor.test 
b/clang-tools-extra/clangd/test/system-include-extractor.test
index c861a2346470e..b109aa67aad1c 100644
--- a/clang-tools-extra/clangd/test/system-include-extractor.test
+++ b/clang-tools-extra/clangd/test/system-include-extractor.test
@@ -11,9 +11,11 @@
 # RUN: echo '#!/bin/sh' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/bin/my_driver.sh" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'args="$*"' >> %t.dir/bin/my_driver.sh
+# Check that clangd preserves certain flags like `-nostdinc` from
+# original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
-# RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> 
%t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> 
%t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> 
%t.dir/bin/my_driver.sh



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


[PATCH] D137409: [clang-format][NFCish] Alphabetical sort Format.(h|pp)

2022-11-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Format/FormatTest.cpp:23323
  "WhitespaceSensitiveMacros: ['FOO', 'BAR']")));
-  std::vector NonDefaultWhiteSpaceMacros{"FOO", "BAR"};
+  std::vector NonDefaultWhiteSpaceMacros =
+  Style9->WhitespaceSensitiveMacros;

related?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137409

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


[clang] c8341a6 - [clang][Interp][NFC] Avoid a getSource() call in the common case

2022-11-07 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-11-07T09:42:41+01:00
New Revision: c8341a66159703de242ab8de362b59548cdda71e

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

LOG: [clang][Interp][NFC] Avoid a getSource() call in the common case

In the common (successful) case, we don't need the getSource() call, so
move it to the two if statement bodies instead.

Added: 


Modified: 
clang/lib/AST/Interp/Interp.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index a5984a21efb1..b22756a80345 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -201,8 +201,8 @@ bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr) {
 
 bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
AccessKinds AK) {
-  const auto &Src = S.Current->getSource(OpPC);
   if (Ptr.isZero()) {
+const auto &Src = S.Current->getSource(OpPC);
 
 if (Ptr.isField())
   S.FFDiag(Src, diag::note_constexpr_null_subobject) << CSK_Field;
@@ -213,6 +213,7 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr,
   }
 
   if (!Ptr.isLive()) {
+const auto &Src = S.Current->getSource(OpPC);
 bool IsTemp = Ptr.isTemporary();
 
 S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;



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


[clang] 6b3e5c5 - [clang][Interp][NFC] Remove unused function

2022-11-07 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-11-07T09:42:41+01:00
New Revision: 6b3e5c595b6930ae87aef6d75377663d238c0921

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

LOG: [clang][Interp][NFC] Remove unused function

Added: 


Modified: 
clang/lib/AST/Interp/Interp.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index b7666745efd4..a90e1246311d 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -112,8 +112,6 @@ bool CheckDivRem(InterpState &S, CodePtr OpPC, const T 
&LHS, const T &RHS) {
   return true;
 }
 
-template  inline bool IsTrue(const T &V) { return !V.isZero(); }
-
 /// Interpreter entry point.
 bool Interpret(InterpState &S, APValue &Result);
 



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


[clang] 5dfacb1 - [clang][Interp][NFC] Replace dyn_cast_or_null with _if_present

2022-11-07 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-11-07T09:42:41+01:00
New Revision: 5dfacb12452026eb9492d046e816fafa0ff5915c

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

LOG: [clang][Interp][NFC] Replace dyn_cast_or_null with _if_present

... in Descriptor.h

Added: 


Modified: 
clang/lib/AST/Interp/Descriptor.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.h 
b/clang/lib/AST/Interp/Descriptor.h
index dacec6be89c7..b2f50815fe84 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -113,15 +113,15 @@ struct Descriptor final {
   const Expr *asExpr() const { return Source.dyn_cast(); }
 
   const ValueDecl *asValueDecl() const {
-return dyn_cast_or_null(asDecl());
+return dyn_cast_if_present(asDecl());
   }
 
   const FieldDecl *asFieldDecl() const {
-return dyn_cast_or_null(asDecl());
+return dyn_cast_if_present(asDecl());
   }
 
   const RecordDecl *asRecordDecl() const {
-return dyn_cast_or_null(asDecl());
+return dyn_cast_if_present(asDecl());
   }
 
   /// Returns the size of the object without metadata.



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


[clang] 5bd6bd1 - [clang][Interp][NFC] Simplify visitReturnStmt()

2022-11-07 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-11-07T09:42:41+01:00
New Revision: 5bd6bd12276ff5e5c38002cf607976e8ac9ed8a6

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

LOG: [clang][Interp][NFC] Simplify visitReturnStmt()

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 81243d846bc1..a6aa8d88622a 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -237,12 +237,11 @@ bool ByteCodeStmtGen::visitReturnStmt(const 
ReturnStmt *RS) {
   this->emitCleanup();
   return this->emitRetVoid(RS);
 }
-  } else {
-this->emitCleanup();
-if (!this->emitRetVoid(RS))
-  return false;
-return true;
   }
+
+  // Void return.
+  this->emitCleanup();
+  return this->emitRetVoid(RS);
 }
 
 template 



___
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-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Opcodes.td:502
+  let Types = [AluTypeClass];
+  let Args = [ArgFltSemantics];
+  let HasGroup = 1;

sepavloff wrote:
> tbaeder wrote:
> > jcranmer-intel wrote:
> > > Integer-to-floating point conversion is dependent on rounding 
> > > mode--consider `(float)UINT_MAX`.
> > This test succeeds here, whether I use `-frounding-math` or not:
> > 
> > ```
> > constexpr float f = (float)4294967295;
> > static_assert(f == (float)4.2949673E+9);
> > ```
> > How can I test this behavior?
> You can use `#pragma STDC FENV_ROUND`. See 
> `clang/test/AST/const-fpfeatures.c` as an example.
Why does it work here to compare both `f` and `f2` to the same value? 
https://godbolt.org/z/zdsf1sK7r


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] D137252: [include-cleaner] Testing helpers for ast walking

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

In D137252#3907743 , @kadircet wrote:

> In D137252#3907665 , @hokein wrote:
>
>> Just share my experience when reading the code, overall I have a feeling 
>> that we're regressing the code readability of the tests (left some comments 
>> on regressing samples):
>>
>> 1. with the sugared macros, the syntax of `TargetCode` and `ReferenceCode` 
>> are identical -- both using the `^` without any names, it is hard to 
>> distinguish them (we could use a different syntax `[[]]` in the 
>> ReferenceCode to identify the point);
>
> I see your point but this is not really a regression, right? that's the way 
> the tests were written in the previous version as well. i am not sure how we 
> can make this more explicit without introducing a bunch of boilerplate into 
> each test case.

In the previous version, we can easily distinguish the `TargetCode` and 
`ReferenceCode` by looking at annotation `$name` in the code, while in the 
current version, we have to memorize the function argument order.

One alternative will be to merge `TargetCode` and `ReferenceCode` together:

  int ^x; // using ^ as a reference point to the target symbol
  
  int y = [[]]x; // using [[]]] as a ref point to the reference.



>> 2. the code of using `EXPECT_REFERENCES_WITH_TYPES` is not easy to read 
>> (especially with multiple `RefType` arguments), we're losing the 
>> relationship between RefType and `^` point, this is my biggest concern;
>
> That is one of the points I disliked the most as well, maybe we should keep 
> the old test syntax for these cases (with abbreviations), i.e. rather than 
> putting the types at the end, we'll put them into the annotations. WDYT?

It can work, probably it is ok, it looks like -- we keep the original 
annotation approach (with shorter names), and provide some syntax sugar for 
common cases. (though I personally prefer to use the shortened-annotation 
approach everywhere). We might want a third opinion @sammccall.

>> 3. the `EXPECT_{EXPLICIT, IMPLICIT, EXPLICIT}_REFERENCES` is designed for a 
>> single reference point. When we have > 1 reference points, we have to use 
>> the fallback `EXPECT_REFERENCES_WITH_TYPES` even if all ref points are the 
>> same type  (not sure it is generic enough, maybe it is fine as 
>> single-ref-point is the most common case);
>
> These macros are not for single references, but rather for single reference 
> types. e.g. if all the references are of same kind.

I see, I got confusing when reading the  `EXPECT_REFERENCES_WITH_TYPES("", "", 
Ambiguous, Ambiguous)` code.




Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:156
 namespace ns {
-  void $ambiguous^x(); void $ambiguous^x(int); void $ambiguous^x(char);
 })cpp",

kadircet wrote:
> hokein wrote:
> > a bug in existing code? by looking at this example, we should use 
> > `EXPECT_AMBIGUOUS_REFERENCES(Code, Code, RefType::Ambiguous, 
> > RefType::Ambiguous, RefType::Ambiguous)`
> no, that's actually a change in behaviour (in the base patch) but wasn't 
> reflected here.
I don't get it. My understanding is 

1. this patch is basically a NFC change on top of the 
https://reviews.llvm.org/D135859 and in https://reviews.llvm.org/D135859, we 
use three ambiguous ref types
2. and here, we are changing one of ambiguous ref types to an explicit type.

1 and 2 is conflicted, do you mean in the base version, it should be 
`ambiguous, explicit, ambiguous`?



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:279
+  EXPECT_IMPLICIT_REFERENCES("struct S { ^S(); };", "S ^t;");
+  EXPECT_EXPLICIT_REFERENCES("struct S { ^S(int); };", "S ^t(42);");
+  EXPECT_IMPLICIT_REFERENCES("struct S { ^S(int); };", "S t = ^42;");

kadircet wrote:
> hokein wrote:
> > When reading this code, the implicit vs explicit in these 4 consecutive 
> > statements is less obvious than before (each of them has the same length, 
> > same indentation and is a single-line)
> i am not sure if there's much difference between having them in the code vs 
> in the macro names here actually.
> 
> the case on the left hand side of the diff is exactly the same, you've got 
> implicit vs explicit right next to points, each with same length. IMO the 
> author/reviewer needs to pay ~the same level of attention in either case.
I think there is a difference -- in the previous version, you don't need to 
read the function name, you can see the reference type from the `^` point in 
the reference code snippet, while in the current version, you first identify 
the `^` point, and *move* our eyeball to the macro name (extra step).

Maybe we can use shorter names for these macros (e.g. EXPECT_IMPLICIT, 
EXPECT_EXPLICIT?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D

[PATCH] D136906: [Clang][LoongArch] Implement __builtin_loongarch_dbar builtin

2022-11-07 Thread Lu Weining via Phabricator via cfe-commits
SixWeining accepted this revision.
SixWeining added a comment.
This revision is now accepted and ready to land.

LGTM but let's wait others.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136906

___
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-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

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

> In D137181#3910799 , @owenpan wrote:
>
>> IMO we should find a simpler way to indent bodies of macro definitions that 
>> are nested more than one level deep. I prefer we handle that in another 
>> patch and only support the examples in the summary for now.
>
> I'm not sure what changes to the patch that would imply?

I meant only making changes to UnwrappedLineFormatter.cpp.

> Also want to note, for the unit tests to all pass only 4-places actually need 
> the
> `PPLevel` tracking. 
> L373
> L1286
> L1290
> L1312

I think you were referring to UnwrappedLineParser.cpp here. Anyway, I think 
most of the added tests are incorrect: the first line in a macro body should be 
indented 3 columns relative to `define` as explained in D137181#3910566 
.

One idea I've experimented with is to pass `PPBranchLevel` from `UnwrappedLine` 
to `AnnotatedLine` and use that in the unwrapped line formatter. It seems very 
promising.


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] D124730: [RISCV][NFC] Refactor RISC-V vector intrinsic utils.

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



Comment at: clang/lib/Support/RISCVVIntrinsicUtils.cpp:35
+// Concat BasicType, LMUL and Proto as key
+static std::unordered_map LegalTypes;
+static std::set IllegalTypes;

these were previously owned by `RVVEmitter`, hence we would have one instance 
per invocation. After this move, and the follow up patch that introduced lazy 
lookup, now we actually have a race condition in tools that can perform 
concurrent AST builds (e.g. any tool, like clang-tidy, that might have multiple 
`Sema`s alive because they're being executed with `all-TU`s executor, or clangd 
when the user opens multiple files).

Rather than having these caches as global singletons (or static local variables 
as things have evolved since this patch), can we:
- make them owned by `RISCVIntrinsicManagerImpl` (while getting rid of the 
cache for TableGen purposes completely, isn't it already generating the full 
header, why does it need a cache?)? that way we would get one instance per 
`Sema` and prevent above mentioned race conditions
- add some locks to synchronise access to these caches.

This has been triggering crashes in clangd for a long while now (tracking it 
back to this issue wasn't easy, sorry for the delay)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124730

___
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-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 473595.
tbaeder added a comment.

Return `opStatus` from `convertToInteger` as well, and add a test case to 
`floats.cpp` that tests float-to-integer conversion.


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

https://reviews.llvm.org/D134859

Files:
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Floating.cpp
  clang/lib/AST/Interp/Floating.h
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/lib/AST/Interp/Primitives.h
  clang/test/AST/Interp/const-fpfeatures.cpp
  clang/test/AST/Interp/floats.cpp
  clang/test/SemaCXX/rounding-math.cpp

Index: clang/test/SemaCXX/rounding-math.cpp
===
--- clang/test/SemaCXX/rounding-math.cpp
+++ clang/test/SemaCXX/rounding-math.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify=norounding -Wno-unknown-pragmas %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -Wno-unknown-pragmas
+// RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -fexperimental-new-constant-interpreter -Wno-unknown-pragmas
 // rounding-no-diagnostics
 
 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
Index: clang/test/AST/Interp/floats.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/floats.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+constexpr int i = 2;
+constexpr float f = 1.0f;
+static_assert(f == 1.0f, "");
+
+constexpr float f2 = 1u * f;
+static_assert(f2 == 1.0f, "");
+
+constexpr float f3 = 1.5;
+constexpr int i3 = f3;
+static_assert(i3 == 1);
+
+
+static_assert(1.0f + 3u == 4, "");
+static_assert(4.0f / 1.0f == 4, "");
+static_assert(10.0f * false == 0, "");
+
+constexpr float floats[] = {1.0f, 2.0f, 3.0f, 4.0f};
+
+constexpr float m = 5.0f / 0.0f; // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{division by zero}} \
+ // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{division by zero}}
+
+static_assert(~2.0f == 3, ""); // ref-error {{invalid argument type 'float' to unary expression}} \
+   // expected-error {{invalid argument type 'float' to unary expression}}
+
+/// Initialized by a double.
+constexpr float df = 0.0;
+/// The other way around.
+constexpr double fd = 0.0f;
+
+static_assert(0.0f == -0.0f, "");
+
+const int k = 3 * (1.0f / 3.0f);
+static_assert(k == 1, "");
+
+constexpr bool b = 1.0;
+static_assert(b, "");
+
+constexpr double db = true;
+static_assert(db == 1.0, "");
+
+constexpr float fa[] = {1.0f, 2.0, 1, false};
+constexpr float da[] = {1.0f, 2.0, 1, false};
Index: clang/test/AST/Interp/const-fpfeatures.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/const-fpfeatures.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -fexperimental-new-constant-interpreter -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
+
+
+#pragma STDC FENV_ROUND FE_UPWARD
+
+float F1u = 1.0F + 0x0.02p0F;
+float F2u = 1.0F + 0x0.01p0F;
+float F3u = 0x1.01p0;
+// CHECK: @F1u = {{.*}} float 0x3FF02000
+// CHECK: @F2u = {{.*}} float 0x3FF02000
+// CHECK: @F3u = {{.*}} float 0x3FF02000
+
+#pragma STDC FENV_ROUND FE_DOWNWARD
+
+float F1d = 1.0F + 0x0.02p0F;
+float F2d = 1.0F + 0x0.01p0F;
+float F3d = 0x1.01p0;
+
+// CHECK: @F1d = {{.*}} float 0x3FF02000
+// CHECK: @F2d = {{.*}} float 1.00e+00
+// CHECK: @F3d = {{.*}} float 1.00e+00
+
+// nextUp(1.F) == 0x1.02p0F
+
+constexpr float add_round_down(float x, float y) {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+constexpr float add_round_up(float x, float y) {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+float V1 = add_round_down(1.0F, 0x0.01p0F);
+float V2 = add_round_up(1.0F, 0x0.01p0F);
+// CHECK: @V1 = {{.*}} float 1.00e+00
+// CHECK: @V2 = {{.*}} float 0x3FF02000
+
+constexpr float add_cast_round_down(float x, double y) {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+constexpr float add_cast_round_up(float x, double y) {
+  #pragma STDC FENV_ROUND FE_UPWARD
+

[PATCH] D130015: [clangd] Add "usedAsMutablePointer" highlighting modifier

2022-11-07 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:592
+  Arg = IC->getSubExprAsWritten();
+if (auto *UO = dyn_cast(Arg)) {
+  if (UO->getOpcode() == UO_AddrOf)

nridge wrote:
> Could you add a test case that exercises the `UnaryOperator` case?
Doesn't the very first hunk in SemanticHighlightingTests.cpp do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130015

___
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-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D137181#3911005 , @sstwcw wrote:

> Here is one problem:
>
>   clang-format -style='{IndentPPDirectives: BeforeHash, PPIndentWidth: 1, 
> IndentWidth: 4, IndentCaseLabels: true}'
>   
>   actual:
>   #define X   
>\
>switch (x) {   
>\
>case 0:
>\
> break;
>\
>default:   
>\
> break;
>\
>}
>   
>   expected:
>   #define X   
>\
>switch (x) {   
>\
>case 0:
>\
>break; 
>\
>default:   
>\
>break; 
>\
>}

Actually, the expected should be:

  #define X 
\
  switch (x) {  
\
  case 0:   
\
  break;
\
  default:  
\
  break;
\
  }


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] D137524: clang/AMDGPU: Emit atomicrmw for atomic_inc/dec builtins

2022-11-07 Thread Jay Foad via Phabricator via cfe-commits
foad added a comment.

In D137524#3911439 , @JonChesterfield 
wrote:

> Do you know where the uinc_wrap etc were introduced?

D137361  in the stack for this patch.


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

https://reviews.llvm.org/D137524

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


[PATCH] D130015: [clangd] Add "usedAsMutablePointer" highlighting modifier

2022-11-07 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:592
+  Arg = IC->getSubExprAsWritten();
+if (auto *UO = dyn_cast(Arg)) {
+  if (UO->getOpcode() == UO_AddrOf)

ckandeler wrote:
> nridge wrote:
> > Could you add a test case that exercises the `UnaryOperator` case?
> Doesn't the very first hunk in SemanticHighlightingTests.cpp do that?
Yep, my bad, overlooked that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130015

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


[PATCH] D137516: [TargetSupport] Move TargetParser API in a separate LLVM component.

2022-11-07 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

In D137516#3911245 , @arsenm wrote:

> I think this is fine, but think the name needs to be bikeshedded. "Target" 
> and "Support" are already overloaded enough as it is. Is there anything else 
> that would really ever go into this library?

I was wondering this new library could house MVTs in some form. I've wanted to 
auto-generate both the C++ and tablegen MVTs from a single source of truth for 
a while.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137516

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


[PATCH] D137409: [clang-format][NFCish] Alphabetical sort Format.(h|pp)

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

Don't forget to run dump_format_style.py before landing. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137409

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


[PATCH] D137486: [clang-format] Correctly annotate function names before attributes

2022-11-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:76
+static bool isCppAttribute(bool IsCpp, const FormatToken &Tok) {
+  if (!IsCpp || !Tok.startsSequence(tok::l_square, tok::l_square))
+return false;

HazardyKnusperkeks wrote:
> What about  `__declspec`, or `__attribute__(())`?
I was only refactoring here. I suppose `isCpp11AttributeSpecifier` was added to 
specifically handle attributes starting with `[[` as the name suggests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137486

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


[PATCH] D130015: [clangd] Add "usedAsMutablePointer" highlighting modifier

2022-11-07 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 473603.
ckandeler marked an inline comment as done.
ckandeler added a comment.

Rebased and updated comment as indicated in review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130015

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -382,7 +382,7 @@
   void $Function_def[[foo]]() {
 $Class[[F]] $LocalVariable_def[[FF]];
 $Class[[G]]<$Class[[F]], &$Class[[F]]::$Method[[f]]> $LocalVariable_def[[GG]];
-$LocalVariable[[GG]].$Method[[foo]](&$LocalVariable[[FF]]);
+$LocalVariable[[GG]].$Method[[foo]](&$LocalVariable_usedAsMutablePointer[[FF]]);
 $Class[[A]]<$Function[[foo]]> $LocalVariable_def[[AA]];
   }
 )cpp",
@@ -781,14 +781,14 @@
   const int* $LocalVariable_def_readonly[[constPtr]];
   int** $LocalVariable_def[[array]];
   $Function[[fun]]($LocalVariable[[val]], $LocalVariable[[val]],
-   $LocalVariable[[ptr]], $LocalVariable_readonly[[constPtr]],
+   $LocalVariable_usedAsMutablePointer[[ptr]], $LocalVariable_readonly[[constPtr]],
$LocalVariable_usedAsMutableReference[[val]], $LocalVariable[[val]],
 
$LocalVariable_usedAsMutableReference[[ptr]],
$LocalVariable_readonly_usedAsMutableReference[[constPtr]],
$LocalVariable_readonly[[constPtr]],
 
-   $LocalVariable[[array]], $LocalVariable_usedAsMutableReference[[array]],
+   $LocalVariable_usedAsMutablePointer[[array]], $LocalVariable_usedAsMutableReference[[array]],
$LocalVariable[[array]]
);
   [](int){}($LocalVariable[[val]]);
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+# CHECK-NEXT:  65539
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+# CHECK-NEXT:  65539
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771,
+# CHECK-NEXT:  65539,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+# CHECK-NEXT:  65539
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -68,6 +68,7 @@
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"usedAsMutableReference",
+# CHECK-NEXT:"usedAsMutablePointer",
 # CHECK-NEXT:"constructorOrDestructor",
 # CHECK-NEXT:"functionScope",
 # CHECK-NEXT:"classScope",
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -71,6 +71,7 @@
   DependentName,
   DefaultLibrary,
   UsedAsMutableReference,
+  UsedAsMutablePointer,
   ConstructorOrDestructor,
 
   FunctionScope,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -597,19 +597,27 @@
 if (!Arg)
   return;
 
-// Is this parameter passed by non-const reference?
+// Is this parameter passed by non-const pointer or reference?
 // FIXME The condition T->idDependentType() could be relaxed a bit,
 // e.g. std::vector& is dependent but we would want to highlight it
- 

[PATCH] D137536: [NFC] Replace use of PPC64 macro into powerpc64 in intrinsic headers

2022-11-07 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: nemanjai, lkail, shchenz, PowerPC.
Herald added a subscriber: kbarton.
Herald added a project: All.
qiucf 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/D137536

Files:
  clang/lib/Headers/ppc_wrappers/bmi2intrin.h
  clang/lib/Headers/ppc_wrappers/bmiintrin.h
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/mm_malloc.h
  clang/lib/Headers/ppc_wrappers/mmintrin.h
  clang/lib/Headers/ppc_wrappers/pmmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/lib/Headers/ppc_wrappers/tmmintrin.h
  clang/lib/Headers/ppc_wrappers/xmmintrin.h

Index: clang/lib/Headers/ppc_wrappers/xmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -35,7 +35,7 @@
 #ifndef XMMINTRIN_H_
 #define XMMINTRIN_H_
 
-#if defined(__ppc64__) &&  \
+#if defined(__powerpc64__) &&  \
 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
 
 /* Define four value permute mask */
@@ -1821,7 +1821,7 @@
 
 #else
 #include_next 
-#endif /* defined(__ppc64__) &&
+#endif /* defined(__powerpc64__) &&
 *   (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */
 
 #endif /* XMMINTRIN_H_ */
Index: clang/lib/Headers/ppc_wrappers/tmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/tmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/tmmintrin.h
@@ -25,7 +25,7 @@
 #ifndef TMMINTRIN_H_
 #define TMMINTRIN_H_
 
-#if defined(__ppc64__) &&  \
+#if defined(__powerpc64__) &&  \
 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
 
 #include 
@@ -447,7 +447,7 @@
 
 #else
 #include_next 
-#endif /* defined(__ppc64__) &&
+#endif /* defined(__powerpc64__) &&
 *   (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */
 
 #endif /* TMMINTRIN_H_ */
Index: clang/lib/Headers/ppc_wrappers/smmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/smmintrin.h
+++ clang/lib/Headers/ppc_wrappers/smmintrin.h
@@ -29,7 +29,7 @@
 #ifndef SMMINTRIN_H_
 #define SMMINTRIN_H_
 
-#if defined(__ppc64__) &&  \
+#if defined(__powerpc64__) &&  \
 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
 
 #include 
@@ -657,7 +657,7 @@
 
 #else
 #include_next 
-#endif /* defined(__ppc64__) &&
+#endif /* defined(__powerpc64__) &&
 *   (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */
 
 #endif /* SMMINTRIN_H_ */
Index: clang/lib/Headers/ppc_wrappers/pmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/pmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/pmmintrin.h
@@ -39,7 +39,7 @@
 #ifndef PMMINTRIN_H_
 #define PMMINTRIN_H_
 
-#if defined(__ppc64__) &&  \
+#if defined(__powerpc64__) &&  \
 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
 
 /* We need definitions from the SSE2 and SSE header files*/
@@ -139,7 +139,7 @@
 
 #else
 #include_next 
-#endif /* defined(__ppc64__) &&
+#endif /* defined(__powerpc64__) &&
 *   (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */
 
 #endif /* PMMINTRIN_H_ */
Index: clang/lib/Headers/ppc_wrappers/mmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/mmintrin.h
+++ clang/lib/Headers/ppc_wrappers/mmintrin.h
@@ -35,7 +35,7 @@
 #ifndef _MMINTRIN_H_INCLUDED
 #define _MMINTRIN_H_INCLUDED
 
-#if defined(__ppc64__) &&  \
+#if defined(__powerpc64__) &&  \
 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
 
 #include 
@@ -1447,7 +1447,7 @@
 
 #else
 #include_next 
-#endif /* defined(__ppc64__) &&
+#endif /* defined(__powerpc64__) &&
 *   (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */
 
 #endif /* _MMINTRIN_H_INCLUDED */
Index: clang/lib/Headers/ppc_wrappers/mm_malloc.h
===
--- clang/lib/Headers/ppc_wrappers/mm_malloc.h
+++ clang/lib/Headers/ppc_wrappers/mm_malloc.h
@@ -10,7 +10,7 @@
 #ifndef _MM_MALLOC_H_INCLUDED
 #define _MM_MALLOC_H_INCLUDED
 
-#if defined(__ppc64__) &&  \
+#if defined(__powerpc64__) &&  

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

2022-11-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 473608.
tbaeder added a comment.

Report overflows when converting floats to integers.


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

https://reviews.llvm.org/D134859

Files:
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Floating.cpp
  clang/lib/AST/Interp/Floating.h
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/lib/AST/Interp/Primitives.h
  clang/test/AST/Interp/const-fpfeatures.cpp
  clang/test/AST/Interp/floats.cpp
  clang/test/SemaCXX/rounding-math.cpp

Index: clang/test/SemaCXX/rounding-math.cpp
===
--- clang/test/SemaCXX/rounding-math.cpp
+++ clang/test/SemaCXX/rounding-math.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify=norounding -Wno-unknown-pragmas %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -Wno-unknown-pragmas
+// RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -fexperimental-new-constant-interpreter -Wno-unknown-pragmas
 // rounding-no-diagnostics
 
 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
Index: clang/test/AST/Interp/floats.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/floats.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+constexpr int i = 2;
+constexpr float f = 1.0f;
+static_assert(f == 1.0f, "");
+
+constexpr float f2 = 1u * f;
+static_assert(f2 == 1.0f, "");
+
+constexpr float f3 = 1.5;
+constexpr int i3 = f3;
+static_assert(i3 == 1);
+
+constexpr bool b3 = f3;
+static_assert(b3);
+
+
+static_assert(1.0f + 3u == 4, "");
+static_assert(4.0f / 1.0f == 4, "");
+static_assert(10.0f * false == 0, "");
+
+constexpr float floats[] = {1.0f, 2.0f, 3.0f, 4.0f};
+
+constexpr float m = 5.0f / 0.0f; // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{division by zero}} \
+ // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{division by zero}}
+
+static_assert(~2.0f == 3, ""); // ref-error {{invalid argument type 'float' to unary expression}} \
+   // expected-error {{invalid argument type 'float' to unary expression}}
+
+/// Initialized by a double.
+constexpr float df = 0.0;
+/// The other way around.
+constexpr double fd = 0.0f;
+
+static_assert(0.0f == -0.0f, "");
+
+const int k = 3 * (1.0f / 3.0f);
+static_assert(k == 1, "");
+
+constexpr bool b = 1.0;
+static_assert(b, "");
+
+constexpr double db = true;
+static_assert(db == 1.0, "");
+
+constexpr float fa[] = {1.0f, 2.0, 1, false};
+constexpr float da[] = {1.0f, 2.0, 1, false};
Index: clang/test/AST/Interp/const-fpfeatures.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/const-fpfeatures.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -fexperimental-new-constant-interpreter -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
+
+
+#pragma STDC FENV_ROUND FE_UPWARD
+
+float F1u = 1.0F + 0x0.02p0F;
+float F2u = 1.0F + 0x0.01p0F;
+float F3u = 0x1.01p0;
+// CHECK: @F1u = {{.*}} float 0x3FF02000
+// CHECK: @F2u = {{.*}} float 0x3FF02000
+// CHECK: @F3u = {{.*}} float 0x3FF02000
+
+#pragma STDC FENV_ROUND FE_DOWNWARD
+
+float F1d = 1.0F + 0x0.02p0F;
+float F2d = 1.0F + 0x0.01p0F;
+float F3d = 0x1.01p0;
+
+// CHECK: @F1d = {{.*}} float 0x3FF02000
+// CHECK: @F2d = {{.*}} float 1.00e+00
+// CHECK: @F3d = {{.*}} float 1.00e+00
+
+// nextUp(1.F) == 0x1.02p0F
+
+constexpr float add_round_down(float x, float y) {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+constexpr float add_round_up(float x, float y) {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+float V1 = add_round_down(1.0F, 0x0.01p0F);
+float V2 = add_round_up(1.0F, 0x0.01p0F);
+// CHECK: @V1 = {{.*}} float 1.00e+00
+// CHECK: @V2 = {{.*}} float 0x3FF02000
+
+constexpr float add_cast_round_down(float x, double y) {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+constexpr float add_cast_round_up(float x, double y) {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  float res = x;
+  res += y

[PATCH] D136671: [analyzer] Fix crash for array-delete of UnknownVal values.

2022-11-07 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs accepted this revision.
isuckatcs added a comment.
This revision is now accepted and ready to land.

I have nothing else to add, this patch looks good to me. If the others don't 
have anything to add either, feel free to commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136671

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


[clang-tools-extra] 2bf960a - [clangd] Add "usedAsMutablePointer" highlighting modifier

2022-11-07 Thread Christian Kandeler via cfe-commits

Author: Christian Kandeler
Date: 2022-11-07T11:58:33+01:00
New Revision: 2bf960aef08e93d687f21e6d636186561b56cbf3

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

LOG: [clangd] Add "usedAsMutablePointer" highlighting modifier

Counterpart to "usedAsMutableReference". Just as for references, there
are const and non-const pointer parameters, and it's valuable to be able
to have different highlighting for the two cases at the call site.
We could have re-used the existing modifier, but having a dedicated one
maximizes client flexibility.

Reviewed By: nridge

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index af3a3e6f8e941..dd9392b029df8 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -597,19 +597,27 @@ class CollectExtraHighlightings
 if (!Arg)
   return;
 
-// Is this parameter passed by non-const reference?
+// Is this parameter passed by non-const pointer or reference?
 // FIXME The condition T->idDependentType() could be relaxed a bit,
 // e.g. std::vector& is dependent but we would want to highlight it
-if (!T->isLValueReferenceType() ||
-T.getNonReferenceType().isConstQualified() || T->isDependentType()) {
+bool IsRef = T->isLValueReferenceType();
+bool IsPtr = T->isPointerType();
+if ((!IsRef && !IsPtr) || T->getPointeeType().isConstQualified() ||
+T->isDependentType()) {
   return;
 }
 
 llvm::Optional Location;
 
-// FIXME Add "unwrapping" for ArraySubscriptExpr and UnaryOperator,
+// FIXME Add "unwrapping" for ArraySubscriptExpr,
 //  e.g. highlight `a` in `a[i]`
 // FIXME Handle dependent expression types
+if (auto *IC = dyn_cast(Arg))
+  Arg = IC->getSubExprAsWritten();
+if (auto *UO = dyn_cast(Arg)) {
+  if (UO->getOpcode() == UO_AddrOf)
+Arg = UO->getSubExpr();
+}
 if (auto *DR = dyn_cast(Arg))
   Location = DR->getLocation();
 else if (auto *M = dyn_cast(Arg))
@@ -617,7 +625,8 @@ class CollectExtraHighlightings
 
 if (Location)
   H.addExtraModifier(*Location,
- HighlightingModifier::UsedAsMutableReference);
+ IsRef ? HighlightingModifier::UsedAsMutableReference
+   : HighlightingModifier::UsedAsMutablePointer);
   }
 
   void
@@ -1140,6 +1149,8 @@ llvm::StringRef 
toSemanticTokenModifier(HighlightingModifier Modifier) {
 return "defaultLibrary";
   case HighlightingModifier::UsedAsMutableReference:
 return "usedAsMutableReference"; // nonstandard
+  case HighlightingModifier::UsedAsMutablePointer:
+return "usedAsMutablePointer"; // nonstandard
   case HighlightingModifier::ConstructorOrDestructor:
 return "constructorOrDestructor"; // nonstandard
   case HighlightingModifier::FunctionScope:

diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.h 
b/clang-tools-extra/clangd/SemanticHighlighting.h
index 79ecb344275d1..64ad431909faa 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.h
+++ b/clang-tools-extra/clangd/SemanticHighlighting.h
@@ -71,6 +71,7 @@ enum class HighlightingModifier {
   DependentName,
   DefaultLibrary,
   UsedAsMutableReference,
+  UsedAsMutablePointer,
   ConstructorOrDestructor,
 
   FunctionScope,

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index eb958cac20279..a2df61ca75235 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -68,6 +68,7 @@
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"usedAsMutableReference",
+# CHECK-NEXT:"usedAsMutablePointer",
 # CHECK-NEXT:"constructorOrDestructor",
 # CHECK-NEXT:"functionScope",
 # CHECK-NEXT:"classScope",

diff  --git a/clang-tools-extra/clangd/test/semantic-tokens.test 
b/clang-tools-extra/clangd/test/semantic-tokens.test
index 5abe78e9a51e1..b3a92b7cc737b 100644
--- a/clang-tools-extra/clangd/test/semantic-tokens.test
+++ b/clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+

[PATCH] D130015: [clangd] Add "usedAsMutablePointer" highlighting modifier

2022-11-07 Thread Christian Kandeler via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bf960aef08e: [clangd] Add "usedAsMutablePointer" 
highlighting modifier (authored by ckandeler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130015

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -382,7 +382,7 @@
   void $Function_def[[foo]]() {
 $Class[[F]] $LocalVariable_def[[FF]];
 $Class[[G]]<$Class[[F]], &$Class[[F]]::$Method[[f]]> $LocalVariable_def[[GG]];
-$LocalVariable[[GG]].$Method[[foo]](&$LocalVariable[[FF]]);
+$LocalVariable[[GG]].$Method[[foo]](&$LocalVariable_usedAsMutablePointer[[FF]]);
 $Class[[A]]<$Function[[foo]]> $LocalVariable_def[[AA]];
   }
 )cpp",
@@ -781,14 +781,14 @@
   const int* $LocalVariable_def_readonly[[constPtr]];
   int** $LocalVariable_def[[array]];
   $Function[[fun]]($LocalVariable[[val]], $LocalVariable[[val]],
-   $LocalVariable[[ptr]], $LocalVariable_readonly[[constPtr]],
+   $LocalVariable_usedAsMutablePointer[[ptr]], $LocalVariable_readonly[[constPtr]],
$LocalVariable_usedAsMutableReference[[val]], $LocalVariable[[val]],
 
$LocalVariable_usedAsMutableReference[[ptr]],
$LocalVariable_readonly_usedAsMutableReference[[constPtr]],
$LocalVariable_readonly[[constPtr]],
 
-   $LocalVariable[[array]], $LocalVariable_usedAsMutableReference[[array]],
+   $LocalVariable_usedAsMutablePointer[[array]], $LocalVariable_usedAsMutableReference[[array]],
$LocalVariable[[array]]
);
   [](int){}($LocalVariable[[val]]);
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+# CHECK-NEXT:  65539
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+# CHECK-NEXT:  65539
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771,
+# CHECK-NEXT:  65539,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  32771
+# CHECK-NEXT:  65539
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -68,6 +68,7 @@
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"usedAsMutableReference",
+# CHECK-NEXT:"usedAsMutablePointer",
 # CHECK-NEXT:"constructorOrDestructor",
 # CHECK-NEXT:"functionScope",
 # CHECK-NEXT:"classScope",
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -71,6 +71,7 @@
   DependentName,
   DefaultLibrary,
   UsedAsMutableReference,
+  UsedAsMutablePointer,
   ConstructorOrDestructor,
 
   FunctionScope,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -597,19 +597,27 @@
 if (!Arg)
   return;
 
-// Is this parameter passed by non-const reference?
+// Is this parameter passed by non-const pointer or reference?
 // FIXME The condition T->idDependentType() could be relaxed a bit,
 // e.g. std::vector& is dependent but we would want 

[PATCH] D137316: [Clang][LoongArch] Implement __builtin_loongarch_crc_w_d_w builtin and add diagnostics

2022-11-07 Thread Lu Weining via Phabricator via cfe-commits
SixWeining accepted this revision.
SixWeining added a comment.
This revision is now accepted and ready to land.

LGTM except 2 nits. And let's wait others.




Comment at: clang/lib/Basic/Targets/LoongArch.cpp:174
+const std::vector &FeaturesVec) const {
+
+  if (getTriple().getArch() == llvm::Triple::loongarch64)

Delete blank line.



Comment at: clang/lib/Sema/SemaChecking.cpp:3677
+ CallExpr *TheCall) {
+
+  switch (BuiltinID) {

Delete blank line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137316

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


[PATCH] D137020: [clang][AST] Handle variable declaration with unknown typedef in C

2022-11-07 Thread Dilshod Urazov via Phabricator via cfe-commits
urazoff added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:5392-5394
+  case tok::amp:
+  case tok::ampamp:
+return getLangOpts().CPlusPlus;

aaron.ballman wrote:
> Looking for `*`, `&`, and `&&` will help catch some cases... but it's not 
> really going to help for situations like `unknown const *` or other 
> qualifiers...
Actually, this `Parser::isDeclarationSpecifier` is never called in case of C++. 
So I am not sure if we need to cover C++ specific constructs or not. But 
`unknown const *` is a good catch, I missed it for some reason. I will update 
the patch soon.



Comment at: clang/lib/Parse/ParseDecl.cpp:5425
+// node in AST for such cases which is good for AST readers.
+if (IsUnknownTypedefName() && !getLangOpts().ObjC)
+  return true;

aaron.ballman wrote:
> Why is ObjC exempted from this?
> 
> I need to think about this a whole lot more. On the one hand, I like the 
> changes happening in the test cases; those look like good changes to me. But 
> on the other hand, this function is called in a fair number of places to make 
> parsing decisions and I'm not convinced that speculative answers are the best 
> way to go from this interface. I need to see if I can find any situations 
> where this is called and we'd get worse parsing behavior (or incorrect 
> parsing behavior!).
There is weird behavior in case of ObjC range-based for loop. For example, in 
`for (NSString* key in xyz)`  token for `in` keyword is of type `Identifier` by 
the call of `Parser::isDeclarationSpecifier`. So I decided to exempt it in 
first version and discuss it in review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137020

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


[PATCH] D136603: [analyzer] Model cast after LValueToRValueBitCasts

2022-11-07 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136603

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


[PATCH] D137316: [Clang][LoongArch] Implement __builtin_loongarch_crc_w_d_w builtin and add diagnostics

2022-11-07 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin added inline comments.



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:174
+const std::vector &FeaturesVec) const {
+
+  if (getTriple().getArch() == llvm::Triple::loongarch64)

SixWeining wrote:
> Delete blank line.
Thanks, I will delete it.



Comment at: clang/lib/Sema/SemaChecking.cpp:3677
+ CallExpr *TheCall) {
+
+  switch (BuiltinID) {

SixWeining wrote:
> Delete blank line.
Thanks, I will delete it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137316

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


[PATCH] D137316: [Clang][LoongArch] Implement __builtin_loongarch_crc_w_d_w builtin and add diagnostics

2022-11-07 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin updated this revision to Diff 473620.
gonglingqin added a comment.

Delete blank line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137316

Files:
  clang/include/clang/Basic/BuiltinsLoongArch.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/larchintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/LoongArch/intrinsic-error.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  llvm/include/llvm/IR/IntrinsicsLoongArch.td
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
  llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la64.ll

Index: llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
@@ -0,0 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
+
+declare i32 @llvm.loongarch.crc.w.d.w(i64, i32)
+
+define i32 @crc_w_d_w(i64 %a, i32 %b) nounwind {
+; CHECK-LABEL: crc_w_d_w:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:crc.w.d.w $a0, $a0, $a1
+; CHECK-NEXT:ret
+  %res = call i32 @llvm.loongarch.crc.w.d.w(i64 %a, i32 %b)
+  ret i32 %res
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
@@ -0,0 +1,10 @@
+; RUN: not llc --mtriple=loongarch32 --disable-verify < %s 2>&1 | FileCheck %s
+
+declare i32 @llvm.loongarch.crc.w.d.w(i64, i32)
+
+define i32 @crc_w_d_w(i64 %a, i32 %b) nounwind {
+; CHECK: llvm.loongarch.crc.w.d.w requires target: loongarch64
+entry:
+  %res = call i32 @llvm.loongarch.crc.w.d.w(i64 %a, i32 %b)
+  ret i32 %res
+}
Index: llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
===
--- llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
+++ llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
@@ -55,6 +55,8 @@
 def loongarch_srl_w : SDNode<"LoongArchISD::SRL_W", SDT_LoongArchIntBinOpW>;
 def loongarch_rotr_w : SDNode<"LoongArchISD::ROTR_W", SDT_LoongArchIntBinOpW>;
 def loongarch_rotl_w : SDNode<"LoongArchISD::ROTL_W", SDT_LoongArchIntBinOpW>;
+def loongarch_crc_w_d_w
+: SDNode<"LoongArchISD::CRC_W_D_W", SDT_LoongArchIntBinOpW>;
 def loongarch_bstrins
 : SDNode<"LoongArchISD::BSTRINS", SDT_LoongArchBStrIns>;
 def loongarch_bstrpick
@@ -1307,6 +1309,9 @@
 
 let Predicates = [IsLA64] in {
 def : Pat<(loongarch_dbar uimm15:$imm15), (DBAR uimm15:$imm15)>;
+
+// CRC Check Instructions
+def : PatGprGpr;
 } // Predicates = [IsLA64]
 
 /// Other pseudo-instructions
Index: llvm/lib/Target/LoongArch/LoongArchISelLowering.h
===
--- llvm/lib/Target/LoongArch/LoongArchISelLowering.h
+++ llvm/lib/Target/LoongArch/LoongArchISelLowering.h
@@ -59,6 +59,9 @@
 
   // Intrinsic operations
   DBAR,
+
+  // CRC check operations
+  CRC_W_D_W
 };
 } // end namespace LoongArchISD
 
@@ -177,6 +180,7 @@
   SDValue lowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
+  SDValue lowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
Index: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
===
--- llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -89,6 +89,7 @@
 setOperationAction(ISD::CTTZ, MVT::i32, Custom);
 setOperationAction(ISD::CTLZ, MVT::i32, Custom);
 setOperationAction(ISD::INTRINSIC_VOID, MVT::i32, Custom);
+setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i32, Custom);
 if (Subtarget.hasBasicF() && !Subtarget.hasBasicD())
   setOperationAction(ISD::FP_TO_UINT, MVT::i32, Custom);
 if (Subtarget.hasBasicF())
@@ -113,6 +114,7 @@
 setOperationAction(ISD::BITREVERSE, MVT::i64, Legal);
   } else {
 setOperationAction(ISD::BITREVERSE, MVT::i32, Legal);
+setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i64, Custom);
   }
 
   static const ISD::CondCode FPCCToExpand[] = {
@@ -209,6 +211,8 @@
 return lowerGlobalTLSAddress(Op, DAG);
   case ISD::INTRINSIC_WO_CHAIN:
 return lowerINTRINSIC_WO_CHAIN(Op, DAG);
+  case ISD::I

[PATCH] D137252: [include-cleaner] Testing helpers for ast walking

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

Agree there are readability concerns here (long macro names, out-of-line kinds, 
complicated macros).

My suggestion would be to treat RefKind as an optional feature. Most tests 
would just assert the set of marked locations and test the cases where kind is 
interesting separately.

  string markReferences(string TargetCode, string ReferencingCode, bool 
WithKind);
  // markReferences("int x;", "int y = ^x;", false) => "int ^x;"
  // markReferences("int x;", "int y = ^x;", true) => "int $explicit^x;"
  
  #define EXPECT_REFS(T, R) EXPECT_EQ(T, markReferences(Annotations(T).code(), 
R, false)) << R;
  #define EXPECT_TYPED_REFS(T, R) EXPECT_EQ(T, 
markReferences(Annotations(T).code(), R, true)) << R;




Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:248
   // decls.
-  testWalk(R"cpp(
+  EXPECT_EXPLICIT_REFERENCES(R"cpp(
   template  struct S {};

It's probably OK to use raw-strings inside macros these days...
Some versions of GCC had a problem with it, but the c++17 bump may have taken 
care of those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137252

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


[PATCH] D136283: [clang-tools-extra] [clangd] Split huge generated CompletionModel.cpp into smaller files

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

I don't think we should add significant build-system complexity here in order 
to support the completion model on ppc32.
Do people actually use clangd on ppc32 machines? (The linked bug calls this a 
clang build failure, but this code is not part of clang).

If we need to support building on this toolchain, then we should probably just 
disable the decision forest model entirely and use the heuristic completion 
scorer instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136283

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


[clang] f63db91 - Only add targetFallback if target is not in defined in current product

2022-11-07 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-11-07T13:12:34Z
New Revision: f63db91590db98e13cb4440fdaa5c40e219b

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

LOG: Only add targetFallback if target is not in defined in current product

Added: 


Modified: 
clang/include/clang/ExtractAPI/API.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/anonymous_record_no_typedef.c
clang/test/ExtractAPI/enum.c
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/objc_property.m
clang/test/ExtractAPI/objc_protocol.m
clang/test/ExtractAPI/struct.c
clang/test/ExtractAPI/underscored.c

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index b77d76d500df6..ffb700eb923f8 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -675,6 +675,12 @@ class APISet {
   const RecordMap &getMacros() const { return Macros; }
   const RecordMap &getTypedefs() const { return Typedefs; }
 
+  /// Get the APIRecord associated with the USR if it's defined in the
+  /// current product.
+  ///
+  /// \returns a APIRecord pointer to the stored symbol record if it exists.
+  APIRecord *getSymbolForUSR(StringRef USR) const;
+
   /// Generate and store the USR of declaration \p D.
   ///
   /// Note: The USR string is stored in and owned by Allocator.

diff  --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 8ab03a833e3c2..48322023d5041 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -197,6 +197,39 @@ TypedefRecord *APISet::addTypedef(StringRef Name, 
StringRef USR,
Comment, Declaration, SubHeading, UnderlyingType);
 }
 
+template 
+static APIRecord *getSymbolInRecordMapForUSR(StringRef USR,
+ const RecordMap &Records) {
+  auto It = Records.find(USR);
+  return (It != Records.end() ? It->second.get() : nullptr);
+}
+
+APIRecord *APISet::getSymbolForUSR(StringRef USR) const {
+  if (USR.empty())
+return nullptr;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCProtocols))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCInterfaces))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, Structs))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, Enums))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, Typedefs))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalFunctions))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalVariables))
+return Record;
+  if (auto *Record = getSymbolInRecordMapForUSR(USR, Macros))
+return Record;
+  return nullptr;
+}
+
 StringRef APISet::recordUSR(const Decl *D) {
   SmallString<128> USR;
   index::generateUSRForDecl(D, USR);

diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 641f1ae812a58..807c618e3198f 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -559,7 +559,10 @@ void 
SymbolGraphSerializer::serializeRelationship(RelationshipKind Kind,
   Object Relationship;
   Relationship["source"] = Source.USR;
   Relationship["target"] = Target.USR;
-  Relationship["targetFallback"] = Target.Name;
+  // Emit a fallback if the target is not a symbol that will be part of this
+  // symbol graph.
+  if (API.getSymbolForUSR(Target.USR) == nullptr)
+Relationship["targetFallback"] = Target.Name;
   Relationship["kind"] = getRelationshipString(Kind);
 
   Relationships.emplace_back(std::move(Relationship));

diff  --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c 
b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
index abb96db058dbf..e20abfdd86ab4 100644
--- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c
+++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
@@ -56,26 +56,22 @@ struct Vehicle {
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@E@input.h@64@Bicycle",
-  "target": "c:@S@Vehicle@E@input.h@64",
-  "targetFallback": "Vehicle::enum (unnamed)"
+  "target": "c:@S@Vehicle@E@input.h@64"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@E@input.h@64@Car",
-  "target": "c:@S@Vehicle@E@input.h@64",
-  "targe

[clang] 671709f - [clang][ExtractAPI] Add targetFallback to relationships in symbol graph

2022-11-07 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-11-07T13:12:34Z
New Revision: 671709f0e7d49826fd0908be2c9aed07debf5bc9

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

LOG: [clang][ExtractAPI] Add targetFallback to relationships in symbol graph

Adds a 'targetFallback' field to relationships in symbol graph that
contains the plain name of the relationship target. This is useful for
clients when the relationship target symbol is not available.

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

Added: 


Modified: 
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/anonymous_record_no_typedef.c
clang/test/ExtractAPI/enum.c
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/objc_property.m
clang/test/ExtractAPI/objc_protocol.m
clang/test/ExtractAPI/struct.c
clang/test/ExtractAPI/underscored.c

Removed: 




diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 988ecd2defa9c..641f1ae812a58 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -559,6 +559,7 @@ void 
SymbolGraphSerializer::serializeRelationship(RelationshipKind Kind,
   Object Relationship;
   Relationship["source"] = Source.USR;
   Relationship["target"] = Target.USR;
+  Relationship["targetFallback"] = Target.Name;
   Relationship["kind"] = getRelationshipString(Kind);
 
   Relationships.emplace_back(std::move(Relationship));

diff  --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c 
b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
index e20abfdd86ab4..abb96db058dbf 100644
--- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c
+++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
@@ -56,22 +56,26 @@ struct Vehicle {
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@E@input.h@64@Bicycle",
-  "target": "c:@S@Vehicle@E@input.h@64"
+  "target": "c:@S@Vehicle@E@input.h@64",
+  "targetFallback": "Vehicle::enum (unnamed)"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@E@input.h@64@Car",
-  "target": "c:@S@Vehicle@E@input.h@64"
+  "target": "c:@S@Vehicle@E@input.h@64",
+  "targetFallback": "Vehicle::enum (unnamed)"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@FI@type",
-  "target": "c:@S@Vehicle"
+  "target": "c:@S@Vehicle",
+  "targetFallback": "Vehicle"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@FI@information",
-  "target": "c:@S@Vehicle"
+  "target": "c:@S@Vehicle",
+  "targetFallback": "Vehicle"
 }
   ],
   "symbols": [

diff  --git a/clang/test/ExtractAPI/enum.c b/clang/test/ExtractAPI/enum.c
index 07d848082981f..7b345464cb982 100644
--- a/clang/test/ExtractAPI/enum.c
+++ b/clang/test/ExtractAPI/enum.c
@@ -65,57 +65,68 @@ enum {
 {
   "kind": "memberOf",
   "source": "c:@E@Vehicle@Bicycle",
-  "target": "c:@E@Vehicle"
+  "target": "c:@E@Vehicle",
+  "targetFallback": "Vehicle"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Vehicle@Car",
-  "target": "c:@E@Vehicle"
+  "target": "c:@E@Vehicle",
+  "targetFallback": "Vehicle"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Vehicle@Train",
-  "target": "c:@E@Vehicle"
+  "target": "c:@E@Vehicle",
+  "targetFallback": "Vehicle"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Vehicle@Ship",
-  "target": "c:@E@Vehicle"
+  "target": "c:@E@Vehicle",
+  "targetFallback": "Vehicle"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Vehicle@Airplane",
-  "target": "c:@E@Vehicle"
+  "target": "c:@E@Vehicle",
+  "targetFallback": "Vehicle"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Direction@North",
-  "target": "c:@E@Direction"
+  "target": "c:@E@Direction",
+  "targetFallback": "Direction"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Direction@East",
-  "target": "c:@E@Direction"
+  "target": "c:@E@Direction",
+  "targetFallback": "Direction"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Direction@South",
-  "target": "c:@E@Direction"
+  "target": "c:@E@Direction",
+  "targetFallback": "Direction"
 },
 {
   "kind": "memberOf",
   "source": "c:@E@Direction@West",
-  "target": "c:@E@Direction"
+  "target": "c:@E@Direction",
+  "targetFallback": "Direction"
 },
 {
   "kind": "memberOf",
   "source": "c:@Ea@Constant@Constant",
-  "target": "c:@Ea@Constant

[PATCH] D136455: [clang][ExtractAPI] Add targetFallback to relationships in symbol graph

2022-11-07 Thread Daniel Grumberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG671709f0e7d4: [clang][ExtractAPI] Add targetFallback to 
relationships in symbol graph (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136455

Files:
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/anonymous_record_no_typedef.c
  clang/test/ExtractAPI/enum.c
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_interface.m
  clang/test/ExtractAPI/objc_property.m
  clang/test/ExtractAPI/objc_protocol.m
  clang/test/ExtractAPI/struct.c
  clang/test/ExtractAPI/underscored.c

Index: clang/test/ExtractAPI/underscored.c
===
--- clang/test/ExtractAPI/underscored.c
+++ clang/test/ExtractAPI/underscored.c
@@ -65,7 +65,8 @@
 {
   "kind": "memberOf",
   "source": "c:@S@ExposedRecord@FI@a",
-  "target": "c:@S@ExposedRecord"
+  "target": "c:@S@ExposedRecord",
+  "targetFallback": "ExposedRecord"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/struct.c
===
--- clang/test/ExtractAPI/struct.c
+++ clang/test/ExtractAPI/struct.c
@@ -52,22 +52,26 @@
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Red",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Green",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Blue",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Alpha",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/objc_protocol.m
===
--- clang/test/ExtractAPI/objc_protocol.m
+++ clang/test/ExtractAPI/objc_protocol.m
@@ -49,7 +49,8 @@
 {
   "kind": "conformsTo",
   "source": "c:objc(pl)AnotherProtocol",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/objc_property.m
===
--- clang/test/ExtractAPI/objc_property.m
+++ clang/test/ExtractAPI/objc_property.m
@@ -55,37 +55,44 @@
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(py)myInterfaceInstanceProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(cpy)myCategoryTypeProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(py)myCategoryInstanceProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "conformsTo",
   "source": "c:objc(cs)Interface",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(pl)Protocol(py)myProtocolInstanceProp",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -57,37 +57,44 @@
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Super(cm)getWithProperty:",
-  "target": "c:objc(cs)Super"
+  "target": "c:objc(cs)Super",
+  "targetFallback": "Super"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Super(im)setProperty:andOtherThing:",
-  "target": "c:objc(cs)Super"
+  "target": "c:objc(cs)Super",
+  "targetFallback": "Super"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Super(py)Property",

[PATCH] D137246: Add clang_CXXMethod_isMoveAssignmentOperator to libclang

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

I finally had some time to look into the pre-merge failure. I couldn't 
replicate it on my machine by following 
https://buildkite.com/llvm-project/premerge-checks/builds/119952#01843856-e8c7-4709-89c6-d52d0286862a
 .

Looking at the log it does not seem related to the patch, I think it might be a 
flaky failing.
Is there a way to rerun the pre-merge checks?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137246

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


[PATCH] D136565: [clang] Instantiate alias templates with sugar

2022-11-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Hi Matheus, 279fe6281d2ca5b2318c7437316c28750feaac8d 
 causes 
compilation timeout on some of our internal files. We're trying to get a test 
case we can share, but so far the only information I can provide is compiler 
perf profile difference:

OK:

  3.08%  compiler.OK  compiler.OK [.] 
llvm::FoldingSetBase::GrowBucketCount(unsigned int, 
llvm::FoldingSetBase::FoldingSet
  2.82%  compiler.OK  compiler.OK [.] 
llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, 
void*&, llv
  2.32%  compiler.OK  compiler.OK [.] 
llvm::FoldingSet::NodeEquals(llvm::FoldingSetBase 
const*, llv
  1.86%  compiler.OK  compiler.OK [.] 
clang::Decl::castFromDeclContext(clang::DeclContext const*)
  1.61%  compiler.OK  compiler.OK [.] 
clang::TypeLoc::getFullDataSizeForType(clang::QualType)
  1.56%  compiler.OK  compiler.OK [.] 
clang::TypeLoc::getNextTypeLocImpl(clang::TypeLoc)
  1.47%  compiler.OK  compiler.OK [.] 
clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, 
clang::SourceLocation,

Bad:

  61.07%  compiler.bad  compiler.bad[.] 
llvm::FoldingSet::NodeEquals(llvm::FoldingSetBase const*, 
llvm::F
   8.14%  compiler.bad  compiler.bad[.] 
clang::UsingType::Profile(llvm::FoldingSetNodeID&, clang::UsingShadowDecl 
const*, c
   3.63%  compiler.bad  compiler.bad[.] 
llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, 
void*&, ll
   1.95%  compiler.bad  compiler.bad[.] 
llvm::FoldingSetNodeID::operator==(llvm::FoldingSetNodeID const&) const
   0.69%  compiler.bad  compiler.bad[.] 
llvm::FoldingSetBase::GrowBucketCount(unsigned int, 
llvm::FoldingSetBase::FoldingSe
   0.56%  compiler.bad  compiler.bad[.] 
llvm::FoldingSet::NodeEquals(llvm::FoldingSetBase 
const*, ll
   0.49%  compiler.bad  compiler.bad[.] 
clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, 
clang::SourceLocation,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136565

___
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-07 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 473627.
SixWeining added a comment.

Add test for warning: argument unused during compilation. And address other 
comments from @MaskRay.


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,49 @@
+//==-- 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 &Features) {
+  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;
+};
+

[PATCH] D137545: [clang][Interp] DerivedToBase casts

2022-11-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder 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/D137545

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


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -269,6 +269,8 @@
   static_assert(c.a == 10, "");
   static_assert(c.b == 20, "");
 
+  constexpr const A *aPointer = &c;
+  constexpr const B *bPointer = &c;
 
   class D : private A, private B {
 public:
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -109,7 +109,8 @@
 });
   }
 
-  case CK_UncheckedDerivedToBase: {
+  case CK_UncheckedDerivedToBase:
+  case CK_DerivedToBase: {
 if (!this->visit(SubExpr))
   return false;
 


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -269,6 +269,8 @@
   static_assert(c.a == 10, "");
   static_assert(c.b == 20, "");
 
+  constexpr const A *aPointer = &c;
+  constexpr const B *bPointer = &c;
 
   class D : private A, private B {
 public:
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -109,7 +109,8 @@
 });
   }
 
-  case CK_UncheckedDerivedToBase: {
+  case CK_UncheckedDerivedToBase:
+  case CK_DerivedToBase: {
 if (!this->visit(SubExpr))
   return false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 39dbfa7 - Revert "Only add targetFallback if target is not in defined in current product"

2022-11-07 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-11-07T13:33:59Z
New Revision: 39dbfa72aaebe64e913d65f1eeab48c5f33b8010

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

LOG: Revert "Only add targetFallback if target is not in defined in current 
product"

This was an accidental addition of a non-reviewed change.

This reverts commit f63db91590db98e13cb4440fdaa5c40e219b.

Added: 


Modified: 
clang/include/clang/ExtractAPI/API.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/anonymous_record_no_typedef.c
clang/test/ExtractAPI/enum.c
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/objc_property.m
clang/test/ExtractAPI/objc_protocol.m
clang/test/ExtractAPI/struct.c
clang/test/ExtractAPI/underscored.c

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index ffb700eb923f..b77d76d500df 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -675,12 +675,6 @@ class APISet {
   const RecordMap &getMacros() const { return Macros; }
   const RecordMap &getTypedefs() const { return Typedefs; }
 
-  /// Get the APIRecord associated with the USR if it's defined in the
-  /// current product.
-  ///
-  /// \returns a APIRecord pointer to the stored symbol record if it exists.
-  APIRecord *getSymbolForUSR(StringRef USR) const;
-
   /// Generate and store the USR of declaration \p D.
   ///
   /// Note: The USR string is stored in and owned by Allocator.

diff  --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 48322023d504..8ab03a833e3c 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -197,39 +197,6 @@ TypedefRecord *APISet::addTypedef(StringRef Name, 
StringRef USR,
Comment, Declaration, SubHeading, UnderlyingType);
 }
 
-template 
-static APIRecord *getSymbolInRecordMapForUSR(StringRef USR,
- const RecordMap &Records) {
-  auto It = Records.find(USR);
-  return (It != Records.end() ? It->second.get() : nullptr);
-}
-
-APIRecord *APISet::getSymbolForUSR(StringRef USR) const {
-  if (USR.empty())
-return nullptr;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCProtocols))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCInterfaces))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, Structs))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, Enums))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, Typedefs))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalFunctions))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalVariables))
-return Record;
-  if (auto *Record = getSymbolInRecordMapForUSR(USR, Macros))
-return Record;
-  return nullptr;
-}
-
 StringRef APISet::recordUSR(const Decl *D) {
   SmallString<128> USR;
   index::generateUSRForDecl(D, USR);

diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 807c618e3198..641f1ae812a5 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -559,10 +559,7 @@ void 
SymbolGraphSerializer::serializeRelationship(RelationshipKind Kind,
   Object Relationship;
   Relationship["source"] = Source.USR;
   Relationship["target"] = Target.USR;
-  // Emit a fallback if the target is not a symbol that will be part of this
-  // symbol graph.
-  if (API.getSymbolForUSR(Target.USR) == nullptr)
-Relationship["targetFallback"] = Target.Name;
+  Relationship["targetFallback"] = Target.Name;
   Relationship["kind"] = getRelationshipString(Kind);
 
   Relationships.emplace_back(std::move(Relationship));

diff  --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c 
b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
index e20abfdd86ab..abb96db058db 100644
--- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c
+++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
@@ -56,22 +56,26 @@ struct Vehicle {
 {
   "kind": "memberOf",
   "source": "c:@S@Vehicle@E@input.h@64@Bicycle",
-  "target": "c:@S@Vehicle@E@input.h@64"
+  "target": "c:@S@Vehicle@E@input.h@64",
+  "targetFallback": "Vehicle::enum (unnamed)"
 },
 {
   "kind

[PATCH] D136809: [CMake] Make sure all headers are installed into `CLANG_RESOURCE_DIR`

2022-11-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

This change introduces a lot of conditional code, that is not necessary. This 
change also uses `CLANG_` outside `clang/` which is messy. and confusing. 
Please clean up.


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

https://reviews.llvm.org/D136809

___
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-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev 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 "

Do you have the test for this error message?



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

`isOrderConcurrent`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:882
+  /// 'order' clause), false - otherwise.
+  bool ParentHasOrderConcurrent() const {
+if (const SharingMapTy *Parent = getSecondOnStackOrNull())

`isParentOrderConcurrent`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:7215
 
+  if (this->LangOpts.OpenMP >= 51 && CalleeFnDecl->getIdentifier() &&
+  CalleeFnDecl->getName().startswith_insensitive(StringRef("omp_"))) {

Remove `this`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:7216
+  if (this->LangOpts.OpenMP >= 51 && CalleeFnDecl->getIdentifier() &&
+  CalleeFnDecl->getName().startswith_insensitive(StringRef("omp_"))) {
+// checking for any calls inside an Order region

I think you can drop call of `StringRef` constructor here, just `omp_`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16694
+  if (Kind != OMPC_ORDER_concurrent ||
+  (this->LangOpts.OpenMP < 51 && MLoc.isValid())) {
+// Kind should be concurrent,

Remove `this`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16707
   }
-  return new (Context)
-  OMPOrderClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
+  if (this->LangOpts.OpenMP >= 51) {
+if (Modifier == OMPC_ORDER_MODIFIER_unknown && MLoc.isValid()) {

Remove `this`


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] D137020: [clang][AST] Handle variable declaration with unknown typedef in C

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

I admire the goals of this patch, but I think it needs some explanation "why we 
expect this to be roughly correct/safe", rather than just trying to think of 
cases that might go wrong and patch them.

The test coverage for incorrect code is not good, I'd expect to need to add 
some new cases here. (And if there are benefits to the AST, we'd want to test 
those).




Comment at: clang/lib/Parse/ParseDecl.cpp:5425
+// node in AST for such cases which is good for AST readers.
+if (IsUnknownTypedefName() && !getLangOpts().ObjC)
+  return true;

urazoff wrote:
> aaron.ballman wrote:
> > Why is ObjC exempted from this?
> > 
> > I need to think about this a whole lot more. On the one hand, I like the 
> > changes happening in the test cases; those look like good changes to me. 
> > But on the other hand, this function is called in a fair number of places 
> > to make parsing decisions and I'm not convinced that speculative answers 
> > are the best way to go from this interface. I need to see if I can find any 
> > situations where this is called and we'd get worse parsing behavior (or 
> > incorrect parsing behavior!).
> There is weird behavior in case of ObjC range-based for loop. For example, in 
> `for (NSString* key in xyz)`  token for `in` keyword is of type `Identifier` 
> by the call of `Parser::isDeclarationSpecifier`. So I decided to exempt it in 
> first version and discuss it in review.
This looks very suspicious to me, for example in `a * b;`. 
isDeclarationSpecifier() is going to return true when pointing at `a`. In fact 
`a` may be either a type or an expression here.

Even if this right now this function never gets called for that case, it's not 
obvious why it wouldn't be in the future, or wouldn't be called for similar 
cases.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137020

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


[PATCH] D135721: [HLSL] Added HLSL this as a reference

2022-11-07 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, thank you!




Comment at: clang/test/AST/HLSL/RWBuffer-AST.hlsl:49-50
 // CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <> 
'element_type' lvalue
-// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'element_type *' 
lvalue ->h 0x{{[0-9A-Fa-f]+}}
-// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 'const 
RWBuffer *' implicit this
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'element_type *' 
lvalue .h 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 'const 
RWBuffer' lvalue implicit this
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <> 'unsigned int' 
ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'

beanz wrote:
> aaron.ballman wrote:
> > `// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 
> > 'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}`
> > 
> > I'm confused by this -- it says the type of the expression is `element_type 
> > *` but that it uses `.` as an operator instead of `->`. One of these seems 
> > like it is wrong, but perhaps I'm missing something.
> Isn't that the type of the member not the type of the `this`? This example 
> seems to result in a pointer `MemberExpr` with a `.` access: 
> https://godbolt.org/z/j9f5nP4s6
> 
> This is a little awkward because we have a pointer member inside this struct 
> even though pointers are illegal in HLSL source :(
> Isn't that the type of the member not the type of the this? This example 
> seems to result in a pointer MemberExpr with a . access: 
> https://godbolt.org/z/j9f5nP4s6

Oh yeah, that is correct, it's the member type not the base object type. I was 
reading the AST dumping code incorrectly when I peeked at it, this is fine (for 
the moment; it'd be good to fix the illegal pointer bits but that's orthogonal).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135721

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


[PATCH] D134231: [clang][C++20] p0960 Allow initializing aggregates from a parenthesized list of values

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

In D134231#3910882 , @ecatmur wrote:

> In D134231#3803380 , @shafik wrote:
>
>> Hello Ed, thank you for picking up this work.
>>
>> I liked the approach in the first PR, did you consider reaching out to the 
>> author is asking if it was ok to commandeer the work to allow it to move 
>> forward?
>
> Hi Shafik,
>
> No, I didn't consider that - sorry! I felt that having done this work 
> independently it was worth presenting separately. Sorry if I wasted anyone's 
> time and happy to see that Alan has picked up the other PR.

No worries at all, I think it's great that we had a few independent approaches 
to this, so definitely not a waste of time IMO.

> I'll close this as superseded if I can work out how.

If you go to the "Add Action" dropdown, there should be an "Abandon Revision" 
option (or something along those lines).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134231

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


[PATCH] D133757: [clangd] Perform system include extraction inside CommandMangler

2022-11-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Woohoo, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133757

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


[PATCH] D137338: Fix dupe word typos

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

In D137338#3907281 , @Rageking8 wrote:

> I am ok with you guys taking the parts of this revision that you reviewed and 
> directly commiting them to the repo, just like how the person above did it. 
> This is to break the revision up to smaller parts.

What name and email address would you like us to use for patch attribution when 
landing these bits?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137338

___
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-07 Thread v1nh1shungry via Phabricator via cfe-commits
v1nh1shungry created this revision.
v1nh1shungry added reviewers: tom-anders, sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
v1nh1shungry requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Avoid adding qualifiers before user-defined literals


Repository:
  rG LLVM Github Monorepo

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 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,14 @@
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
-// Avoid adding qualifiers before operators, e.g.
+// Avoid adding qualifiers before operators
+// and user-defined literals, e.g.
 //   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
 //   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 (auto kind = T->getDeclName().getNameKind();
+kind == DeclarationName::NameKind::CXXOperatorName ||
+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 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,14 @@
 if (!visibleContext(T->getDeclContext())
  ->Equals(TargetDirective->getNominatedNamespace()))
   return;
-// Avoid adding qualifiers before operators, e.g.
+// Avoid adding qualifiers before operators
+// and user-defined literals, e.g.
 //   using namespace std;
+//   auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
 //   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 (auto kind = T->getDeclName().getNameKind();
+kind == DeclarationName::NameKind::CXXOperatorName ||
+kind == DeclarationName::NameKind::CXXLiteralOperatorName)
   return;
   }
   SourceLocation Loc = Ref.NameLoc;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136790: [Clang][Sema] Add -Wincompatible-function-pointer-types-strict

2022-11-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136790

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


[PATCH] D135360: [clang][analyzer] Add some more functions to StreamChecker and StdLibraryFunctionsChecker.

2022-11-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 473659.
balazske added a comment.

Added more functions to StdLibraryFunctionsChecker.
This is redundant with the StreamChecker for now but
makes possible to remove the NULL stream check from
StreamChecker and reduce overlap of the checkers.
This way no dependency should be needed between these checkers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135360

Files:
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-errno-note.c
  clang/test/Analysis/stream-errno.c
  clang/test/Analysis/stream-noopen.c

Index: clang/test/Analysis/stream-noopen.c
===
--- clang/test/Analysis/stream-noopen.c
+++ clang/test/Analysis/stream-noopen.c
@@ -77,6 +77,49 @@
   clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
 }
 
+void check_fgetpos(FILE *F) {
+  errno = 0;
+  fpos_t Pos;
+  int Ret = fgetpos(F, &Pos);
+  if (Ret)
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+ // expected-warning@-1{{FALSE}}
+  if (errno) {} // no-warning
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void check_fsetpos(FILE *F) {
+  errno = 0;
+  fpos_t Pos;
+  int Ret = fsetpos(F, &Pos);
+  if (Ret)
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+ // expected-warning@-1{{FALSE}}
+  if (errno) {} // no-warning
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void check_ftell(FILE *F) {
+  errno = 0;
+  long Ret = ftell(F);
+  if (Ret == -1) {
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+ // expected-warning@-1{{FALSE}}
+clang_analyzer_eval(Ret >= 0); // expected-warning{{TRUE}}
+  }
+  if (errno) {} // no-warning
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
 void freadwrite_zerosize(FILE *F) {
   fwrite(WBuf, 1, 0, F);
   clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
Index: clang/test/Analysis/stream-errno.c
===
--- clang/test/Analysis/stream-errno.c
+++ clang/test/Analysis/stream-errno.c
@@ -123,6 +123,64 @@
   fclose(F);
 }
 
+void check_fgetpos(void) {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  errno = 0;
+  fpos_t Pos;
+  int Ret = fgetpos(F, &Pos);
+  if (Ret)
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+  if (errno) {} // no-warning
+  fclose(F);
+}
+
+void check_fsetpos(void) {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  errno = 0;
+  fpos_t Pos;
+  int Ret = fsetpos(F, &Pos);
+  if (Ret)
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+  if (errno) {} // no-warning
+  fclose(F);
+}
+
+void check_ftell(void) {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  errno = 0;
+  long Ret = ftell(F);
+  if (Ret == -1) {
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(Ret >= 0); // expected-warning{{TRUE}}
+  }
+  if (errno) {} // no-warning
+  fclose(F);
+}
+
+void check_rewind(void) {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  errno = 0;
+  rewind(F);
+  clang_analyzer_eval(errno == 0);
+  // expected-warning@-1{{FALSE}}
+  // expected-warning@-2{{TRUE}}
+  fclose(F);
+}
+
 void check_fileno(void) {
   FILE *F = tmpfile();
   if (!F)
Index: clang/test/Analysis/stream-errno-note.c
===
--- clang/test/Analysis/stream-errno-note.c
+++ clang/test/Analysis/stream-errno-note.c
@@ -98,6 +98,18 @@
   (void)fclose(F);
 }
 
+void check_rewind_errnocheck(void) {
+  FILE *F = tmpfile();
+  // expected-note@+2{{'F' is non-null}}
+  // expected-note@+1{{Taking false branch}}
+  if (!F)
+return;
+  errno = 0;
+  rewind(F); // expected-note{{Function 'rewind' indicates failure only by setting of 'errno'}}
+  fclose(F); // expected-warning{{Value of 'errno' was not checked and may be overwritten by function 'fclose' [alpha.unix.Errno]

[PATCH] D131295: [clangd] Implement textDocument/codeLens

2022-11-07 Thread Trass3r via Phabricator via cfe-commits
Trass3r updated this revision to Diff 473662.
Trass3r edited the summary of this revision.
Trass3r added a comment.

remove bases codelens for classes
fix lit test
exclude self from ref count


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131295

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeLens.cpp
  clang-tools-extra/clangd/CodeLens.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -343,6 +343,11 @@
 CommaSeparated,
 };
 
+opt EnableCodeLens{
+"code-lens", cat(Features), desc("Enable preview of CodeLens feature"),
+init(true),  Hidden,
+};
+
 opt WorkerThreadsCount{
 "j",
 cat(Misc),
@@ -911,6 +916,7 @@
   }
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.MemoryCleanup = getMemoryCleanupFunction();
+  Opts.CodeLens = EnableCodeLens;
 
   Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;
   Opts.CodeComplete.Limit = LimitResults;
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -9,6 +9,9 @@
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "clangdInlayHintsProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "codeLensProvider": {
+# CHECK-NEXT:"resolveProvider": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "compilationDatabase": {
 # CHECK-NEXT:"automaticReload": true
 # CHECK-NEXT:  },
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -225,6 +225,7 @@
 return std::tie(LHS.uri, LHS.range) < std::tie(RHS.uri, RHS.range);
   }
 };
+bool fromJSON(const llvm::json::Value &, Location &, llvm::json::Path);
 llvm::json::Value toJSON(const Location &);
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Location &);
 
@@ -1008,6 +1009,9 @@
   const static llvm::StringLiteral QUICKFIX_KIND;
   const static llvm::StringLiteral REFACTOR_KIND;
   const static llvm::StringLiteral INFO_KIND;
+  /// This action should be implemented by client,
+  /// because we can not call 'editor.action.showReferences' directly.
+  const static llvm::StringLiteral SHOW_REFERENCES;
 
   /// The diagnostics that this code action resolves.
   llvm::Optional> diagnostics;
@@ -1862,6 +1866,33 @@
 llvm::json::Value toJSON(const ASTNode &);
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const ASTNode &);
 
+/// https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens
+struct CodeLensResolveData {
+  std::string uri;
+};
+bool fromJSON(const llvm::json::Value &, CodeLensResolveData &,
+  llvm::json::Path);
+llvm::json::Value toJSON(const CodeLensResolveData &A);
+
+struct CodeLensArgument {
+  std::string uri;
+  Position position;
+  std::vector locations;
+};
+llvm::json::Value toJSON(const CodeLensArgument &A);
+
+struct CodeLensParams : DocumentSymbolParams {};
+
+struct CodeLens {
+  // CodeLens range.
+  Range range;
+  // CodeLens command.
+  llvm::Optional command;
+  // CodeLens resolve data.
+  llvm::Optional data;
+};
+bool fromJSON(const llvm::json::Value &, CodeLens &, llvm::json::Path);
+llvm::json::Value toJSON(const CodeLens &);
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -150,6 +150,12 @@
   return OS << R.start << '-' << R.end;
 }
 
+bool fromJSON(const llvm::json::Value &Params, Location &L,
+  llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+  return O && O.map("uri", L.uri) && O.map("range", L.range);
+}
+
 llvm::json::Value toJSON(const Location &P) {
   return llvm::json::Object{
   {"uri", P.uri},
@@ -800,6 +806,8 @@
 const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
 const llvm::StringLiteral CodeAction::REFACTOR_KIND = "refactor";
 const llvm::StringLiteral CodeAction::INFO_KIND = "info";
+const llvm::StringLiteral CodeAction::SHOW_REFERENCES =
+"clangd.action.showReferences";
 
 llvm::json::Value toJSON(const C

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

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

One other bug I found with this diff, is it seems to suggest calling 
std::move() on function args that are references, despite the fact that 
invalidating the reference to the input arg could be undesirable. For instance 
take a function that takes in a reference to a String, assigns a new value to 
the arg reference, and then returns the value of the reference. It suggests 
calling std::move() on the arg ref when it is returned, which invalidate the 
reference to the argument.


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] D137516: [TargetSupport] Move TargetParser API in a separate LLVM component.

2022-11-07 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I'm not convinced we should be leaving any of the other Target Parser 
information in Support, if we are doing this, though this creates layering 
issues which I've been trying to unpick.

If you try to take `llvm/Support/*TargetParser*`, you find a few places where 
there are dependencies from these files to other bits of Support:

- `llvm/Support/Host` has lots of logic for turning cpu information into a 
target, to handle `-mcpu=native`. My opinion is that should also move into 
target parser. There are some parts of this file that can move into other parts 
of `llvm/Support`, like the introspection about number of cores.
- `llvm/{Support/ADT}Triple` depends on the Arm/AArch64 target parsers (because 
arm triples canonically look like `armv7a-…` or similar, and we use the 
targetparser to help canonicalise the triple). My opinion is that all this code 
can move into the target parser.

There are quite a few small cleanup patches to enable this. One of the biggest 
is that `llvm/Support/CommmandLine` wants to know the current triple and CPU 
for `--version`, even in e.g. tablegen. This was the change I most struggled 
with, but I think I have a solution that does the job fine.

I'm going to try to polish and post my patch set this week which does this 
split, as a comparison to this one.

Re the name: "TargetParser" seems reasonable to me, given that's what we've 
called the files so far anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137516

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


[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-11-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 473679.
Ericson2314 added a comment.
Herald added a subscriber: Moerafaat.

Dedup code, rename variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

Files:
  bolt/CMakeLists.txt
  clang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  cmake/Modules/LLVMGNUDirs.cmake
  cmake/Modules/LLVMSetIntDirs.cmake
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/base-config-ix.cmake
  flang/CMakeLists.txt
  libc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/CMakeLists.txt
  mlir/CMakeLists.txt
  openmp/CMakeLists.txt
  polly/CMakeLists.txt

Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -1,12 +1,25 @@
 # Check if this is a in tree build.
+
+set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
   cmake_minimum_required(VERSION 3.13.4)
   set(POLLY_STANDALONE_BUILD TRUE)
 endif()
 
-# Must go below project(..)
-include(GNUInstallDirs)
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${POLLY_SOURCE_DIR}/../cmake)
+endif()
+
+list(INSERT CMAKE_MODULE_PATH 0
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
+# Must go before the first `include(GNUInstallDirs)`.
+# Must go after project(..)
+include(LLVMGNUDirs)
 
 if(POLLY_STANDALONE_BUILD)
   # Where is LLVM installed?
@@ -48,18 +61,10 @@
   set(POLLY_GTEST_AVAIL 1)
 endif ()
 
-set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-
-if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
-  set(LLVM_COMMON_CMAKE_UTILS ${POLLY_SOURCE_DIR}/../cmake)
-endif()
-
 # Make sure that our source directory is on the current cmake module path so that
 # we can include cmake files from this directory.
 list(INSERT CMAKE_MODULE_PATH 0
   "${POLLY_SOURCE_DIR}/cmake"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
   )
 
 include("polly_macros")
Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -1,12 +1,5 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
-
-# Add path for custom modules
-list(INSERT CMAKE_MODULE_PATH 0
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
 
 # llvm/runtimes/ will set OPENMP_STANDALONE_BUILD.
 if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -14,8 +7,18 @@
   project(openmp C CXX)
 endif()
 
-# Must go below project(..)
-include(GNUInstallDirs)
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+# Add path for custom modules
+list(INSERT CMAKE_MODULE_PATH 0
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
+# Must go before the first `include(GNUInstallDirs)`.
+# Must go after project(..)
+include(LLVMGNUDirs)
 
 if (OPENMP_STANDALONE_BUILD)
   # CMAKE_BUILD_TYPE was not set, default to Release.
@@ -51,6 +54,11 @@
   endif()
 endif()
 
+# Add path for custom modules
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+  )
+
 # Check and set up common compiler flags.
 include(config-ix)
 include(HandleOpenMPOptions)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -7,14 +7,26 @@
 include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
   NO_POLICY_SCOPE)
 
+set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
 # Check if MLIR is built as a standalone project.
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(mlir)
   set(MLIR_STANDALONE_BUILD TRUE)
 endif()
 
-# Must go below project(..)
-include(GNUInstallDirs)
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+list(INSERT CMAKE_MODULE_PATH 0
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
+# Must go before the first `include(GNUInstallDirs)`.
+# Must go after project(..)
+include(LLVMGNUDirs)
 
 if(MLIR_STANDALONE_BUILD)
   find_package(LLVM CONFIG REQUIRED)
@@ -43,19 +55,16 @@
 "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
 mark_as_advanced(MLIR_TOOLS_INSTALL_DIR)
 
-set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
+set(MLIR_MAIN_SRC_DIR ${MLIR_SOURCE_DIR}   )
 set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include )
 
-set(MLIR_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
-set(MLIR_BINARY_DIR  ${CMAKE_CU

[PATCH] D137556: [POC] Clang implementation for AArch64 SME and some SME2 builtins

2022-11-07 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
Herald added subscribers: ecnelises, jdoerfert, mgrang, hiraditya, 
kristof.beyls.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
sdesmalen requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

THIS IS A PROOF OF CONCEPT, PLEASE DO NOT REVIEW

We're sharing this patch for people who want to try out the full C/C++ ->
asm flow for the SME (and some of the SME2) intrinsics. The patch can be
applied to b50392342be27efdc01d877ba0c357485dc7e918 
.

Some parts are being upstreamed independently from this proof of concept.

- C-level attributes in Clang (D127762 )
- Support for `svcount_t` (D136861  and 
D136862 )
- SME2 assembler

Some changes in this patch may have already diverged from the patches that
are in flight on Phabricator (this is mostly true for the SME2 assembler).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137556

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/AArch64SVEACLETypes.def
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsSME.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sme.td
  clang/include/clang/Basic/arm_sve.td
  clang/include/clang/Basic/arm_sve_common.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-dump-aarch64-sve-types.c
  clang/test/CodeGen/aarch64-debug-sve-vector-types.c
  clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c
  clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.c
  clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_cnt.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_loads.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mem_ops.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mop.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_reads.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_funs.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_stores.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_writes.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_add.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_loads.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_mop.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_reads.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_stores.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_writes.c
  clang/test/CodeGen/aarch64-sme-intrinsics/negative/acle_sme_zero.c
  clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
  clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mlal.c
  clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
  clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mlsl.c
  clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_read.c
  clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write.c
  clang/test/CodeGen/aarch64-sve-inline-asm-crash.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_psel.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_revd.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_sclamp.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_uclamp.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_ld1.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_ldnt1.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_pext.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_ptrue.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_st1.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_stnt1.c
  clang/test/CodeGen/svboolx2_t.cpp
  clang/test/CodeGen/svboolx4_t.cpp
  clang/test/CodeGenCXX/aarch64-mangle-sve-vect

[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-11-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

I have done the deduping @phosek requested, and changed the variable names from 
`CMAKE_*` to `LLVMPROJ_*` which hopefully satisfies everyone's criteria. Happy 
with other non `LLVM_` options too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

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


[PATCH] D133890: [CMake] Do these replacements to make use of D132608

2022-11-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 473684.
Ericson2314 added a comment.
Herald added a subscriber: Moerafaat.

Rebase, rename variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133890

Files:
  bolt/tools/driver/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/modules/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  flang/tools/f18/CMakeLists.txt
  libc/test/utils/tools/WrapperGen/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lldb/bindings/python/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBStandalone.cmake
  mlir/cmake/modules/CMakeLists.txt
  mlir/examples/standalone/CMakeLists.txt
  mlir/test/CMakeLists.txt
  mlir/utils/mbr/CMakeLists.txt
  openmp/libomptarget/plugins/remote/CMakeLists.txt

Index: openmp/libomptarget/plugins/remote/CMakeLists.txt
===
--- openmp/libomptarget/plugins/remote/CMakeLists.txt
+++ openmp/libomptarget/plugins/remote/CMakeLists.txt
@@ -26,7 +26,7 @@
 
 if (Protobuf_FOUND AND gRPC_FOUND AND PROTOC AND GRPC_CPP_PLUGIN)
   libomptarget_say("Building remote offloading plugin.")
-  set(directory "${CMAKE_BINARY_DIR}/include/openmp/libomptarget/plugins/remote/")
+  set(directory "${LLVMPROJ_BINARY_INCLUDEDIR}/openmp/libomptarget/plugins/remote/")
   file(MAKE_DIRECTORY ${directory})
   execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})
   execute_process(
Index: mlir/utils/mbr/CMakeLists.txt
===
--- mlir/utils/mbr/CMakeLists.txt
+++ mlir/utils/mbr/CMakeLists.txt
@@ -1 +1 @@
-configure_file(mlir-mbr.in ${CMAKE_BINARY_DIR}/bin/mlir-mbr @ONLY)
+configure_file(mlir-mbr.in ${LLVMPROJ_BINARY_BINDIR}/mlir-mbr @ONLY)
Index: mlir/test/CMakeLists.txt
===
--- mlir/test/CMakeLists.txt
+++ mlir/test/CMakeLists.txt
@@ -8,7 +8,7 @@
 # Provide the MLIR CMake module dir so that the out of tree Standalone
 # dialect and can add it to the module path.
 set(MLIR_CMAKE_DIR
-  "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
+  "${LLVMPROJ_BINARY_LIBDIR}/cmake/mlir")
 
 # Passed to lit.site.cfg.py.in to set up the path where to find libraries.
 set(MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -10,8 +10,8 @@
 message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
 message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
 
-set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
-set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
+set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVMPROJ_BINARY_BINDIR})
+set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVMPROJ_BINARY_LIBDIR})
 set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
 
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -9,7 +9,7 @@
 set(MLIR_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/mlir" CACHE STRING
   "Path for CMake subdirectory for Polly (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/polly')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
+set(mlir_cmake_builddir "${LLVMPROJ_BINARY_LIBDIR}/cmake/mlir")
 
 # Keep this in sync with llvm/cmake/CMakeLists.txt!
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -79,7 +79,7 @@
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 include_directories(
-  "${CMAKE_BINARY_DIR}/include"
+  "${LLVMPROJ_BINARY_INCLUDEDIR}"
   "${LLVM_INCLUDE_DIRS}"
   "${CLANG_INCLUDE_DIRS}")
 
@@ -109,6 +109,6 @@
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
 endif()
 
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVMPROJ_BINARY_BINDIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVMPROJ_BINARY_LIBDIR})
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVMPROJ_BINARY_LIBDIR})
Index: lldb/cmake/modules/LLDBConfig.cmake
===

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

2022-11-07 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: llvm/lib/TargetSupport/CMakeLists.txt:2
+
+set(LLVM_TARGET_DEFINITIONS ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
+

Here `RISCVTargetSupportTableGen` depends on files in `lib/Target/RISCV`, 
meaning the folder structure doesn't reflect the dependency graph and it looks 
like a circular dependency. It would be cleaner to keep the `TargetParser` data 
out of `lib/Target` in e.g. `llvm/lib/TargetSupport/RISCVTargetInfo.td`. If it 
is needed in `RISCV.td` it could be included from there.


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] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

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

In D137375#3906777 , @MaskRay wrote:

> This needs a clang/test/Driver test. And, does this work with --sysroot= ?

Thanks for your comment.
It seems there will need to be a separate patch for `--sysroot`. From my 
initial findings, the compiler recognizes but does not respect sysroot on AIX.

On `xlc`, passing `--sysroot=` does not change the path used for these 
libraries. The driver will emit the same link flags: 
`-L/lib/profiled,-L/usr/lib/profiled`. As of now, this patch follows the same 
standard for consistency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

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


[PATCH] D136811: -Wunsafe-buffer-usage: WIP: RFC: NFC: User documentation.

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



Comment at: clang/docs/SafeBuffers.rst:31
+convert large amounts of old code to conform to the warning;
+  - Attribute ``[[unsafe_buffer_usage]]`` lets you annotate custom functions as
+unsafe, while providing a safe alternative that can often be suggested by

xazax.hun wrote:
> NoQ wrote:
> > aaron.ballman wrote:
> > > xazax.hun wrote:
> > > > aaron.ballman wrote:
> > > > > H that attribute name looks problematic (more below in that 
> > > > > section).
> > > > With C++ modules gaining some momentum, I wonder if it would be 
> > > > possible/beneficial to be able to annotate module import/export 
> > > > declarations with this attribute to signal that the APIs and the 
> > > > content in a module was not yet hardened. 
> > > I think it makes sense on module export (the module author knows whether 
> > > they are buffer-safe or not), but what do you have in mind for import 
> > > where the user may not be in a position to make that assertion validly?
> > > I wonder if it would be possible/beneficial to be able to annotate module 
> > > import/export declarations with this attribute to signal that the APIs 
> > > and the content in a module was not yet hardened.
> > 
> > It's usually not that valuable for us to know that outside the module. If 
> > the module wasn't hardened, there's nothing the "caller module" can do 
> > about it, the recommended approach is to harden the module first, and then 
> > use the attribute to indicate which functions were found to be unsafe in 
> > that process (especially if safe alternatives were implemented).
> > 
> > So it's only valuable when the module *will never be hardened*, and the 
> > only thing the caller module can do in such case is isolate calls to that 
> > module, maybe cover it with a safe abstraction. In this case, yeah, I think 
> > it makes sense. Maybe we should consider this eventually.
> Wouldn't `only_safe_buffers` make sense on the import side to ensure that no 
> unhardened code is being imported from a specific module?
> Wouldn't only_safe_buffers make sense on the import side to ensure that no 
> unhardened code is being imported from a specific module?

But the import side has no way to know that the module being imported has no 
unhardened code, only the module implementer knows that.

That said, I could imagine wanting to mark a module import as "will never be 
hardened" as a blanket way to say "don't complain about interfaces in this 
module I have no control over".

But now I'm questioning something from the docs:

> Pragmas ``unsafe_buffer_usage`` and ``only_safe_buffers`` and allow you to
> annotate sections of code as either already-hardened or not-to-be-hardened,

It now occurs to me there's two ways to read this.

`unsafe_buffer_usage` = will diagnose any unsafe buffer usage, it's already 
hardened.
`only_safe_buffers` == should only be used with known-safe buffers, it's not 
going to be hardened

or

`unsafe_buffer_usage` == this uses unsafe buffers, it's not to be hardened
`only_safe_buffers` == this uses only safe buffers, it's already been hardened

I originally read it the first way from the docs in the patch but the comment 
from @xazax.hun reads to me like he read it the second way.



Comment at: clang/docs/SafeBuffers.rst:40-41
+  - Finally, in order to avoid bugs in newly converted code, the
+Clang static analyzer provides a checker to find misconstructed
+``std::span`` objects.
+

xazax.hun wrote:
> jkorous wrote:
> > NoQ wrote:
> > > xazax.hun wrote:
> > > > Isn't this overly specific? What about `string_view`s? 
> > > Yeah I think we can cover string views as well!
> > This is based on our current plans for near future.
> > While we are positive we will use `std::span` in the FixIts it is very 
> > unlikely we'd use `string_view`. That's why having a checker for 
> > `std::span` is more important for us now.
> Does this mean you'd recommend using a `span` over `string_view` in all 
> cases? I think that might surprise some users, so I wonder if it is worth 
> documenting. 
Oh, I was sort of assuming we'd be suggesting `string_view` over `span` 
when appropriate. So agreed that we should clearly document this as it may 
surprise folks.

Out of curiosity, why the strong preference for `span`?



Comment at: clang/docs/SafeBuffers.rst:132
+attribute ``[[unsafe_buffer_usage]]``,
+  - unless the pointer is a compile time constant ``0`` or ``nullptr``;
+  - a number of C/C++ standard library buffer manipulation functions

NoQ wrote:
> aaron.ballman wrote:
> > `NULL` as well, I presume? (This matters for C where `NULL` often expands 
> > to `(void *)0`.)
> Hmm, I was thinking that `((void *)0)` is a compile-time constant `0`. Like, 
> I didn't say it's a *literal*. Is there a better term?
Are you okay with constant expressions? e.g.,
```
consteval int foo() { return 0

[PATCH] D137240: [clang][Interp] Support alignof()

2022-11-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

In D137240#3909034 , @tbaeder wrote:

> It's not really all that interesting since the current interpreter already 
> does all the work, but it works like this.

Ahhh okay, that makes sense, thanks!




Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:461
+return this->emitConst(Size.getQuantity(), E);
+  } else if (Kind == UETT_AlignOf || Kind == UETT_PreferredAlignOf) {
+CharUnits Size;

No need for the `else` because of the unconditional return in the `if` branch.


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

https://reviews.llvm.org/D137240

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


[PATCH] D137558: [clang][Interp] Reject reinterpret_casts

2022-11-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

An appropriate diagnostic has already been emitted when we get to the 
expression, so just return `false` here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137558

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h


Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -61,6 +61,7 @@
 
   // Expression visitors - result returned on interp stack.
   bool VisitCastExpr(const CastExpr *E);
+  bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
   bool VisitIntegerLiteral(const IntegerLiteral *E);
   bool VisitFloatingLiteral(const FloatingLiteral *E);
   bool VisitParenExpr(const ParenExpr *E);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -192,6 +192,12 @@
   llvm_unreachable("Unhandled clang::CastKind enum");
 }
 
+
+template 
+bool ByteCodeExprGen::VisitCXXReinterpretCastExpr(const 
CXXReinterpretCastExpr *E) {
+  return false;
+}
+
 template 
 bool ByteCodeExprGen::VisitIntegerLiteral(const IntegerLiteral *LE) {
   if (DiscardResult)


Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -61,6 +61,7 @@
 
   // Expression visitors - result returned on interp stack.
   bool VisitCastExpr(const CastExpr *E);
+  bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
   bool VisitIntegerLiteral(const IntegerLiteral *E);
   bool VisitFloatingLiteral(const FloatingLiteral *E);
   bool VisitParenExpr(const ParenExpr *E);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -192,6 +192,12 @@
   llvm_unreachable("Unhandled clang::CastKind enum");
 }
 
+
+template 
+bool ByteCodeExprGen::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
+  return false;
+}
+
 template 
 bool ByteCodeExprGen::VisitIntegerLiteral(const IntegerLiteral *LE) {
   if (DiscardResult)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137531: [clang] Fix the GitHub issue #58674

2022-11-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: clang-language-wg.
aaron.ballman added a comment.

FWIW, it'd help reviewers out if you would use a more descriptive title for the 
patch than just the GitHub issue number (it's easier for us to keep reviews 
straight when they have more concrete titles). I made a quick pass over this 
review and spotted some tiny nits, but I need to give it a more thorough review 
when I have some spare cycles.




Comment at: clang/lib/Sema/SemaExpr.cpp:2708-2710
+  if (R.isSingleResult() && (isa(R.getFoundDecl()) ||
+ isa(R.getFoundDecl()) ||
+ isa(R.getFoundDecl( {

We can simplify this since we're in the area anyway.



Comment at: clang/lib/Sema/SemaExpr.cpp:2711-2715
+if (auto Class = dyn_cast_or_null(
+(*R.begin())->getDeclContext())) {
+  for (auto Curr = S->getLookupEntity(); Curr && 
!Curr->isFileContext();
+   Curr = Curr->getParent()) {
+if (auto ThisClass = dyn_cast_or_null(Curr)) {




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137531

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


[clang] 6ebca03 - [Clang] Update test after wasm intrinsics attribute change (NFC)

2022-11-07 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-11-07T17:42:35+01:00
New Revision: 6ebca0302126c43ec8614d26aa444060e7a6da76

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

LOG: [Clang] Update test after wasm intrinsics attribute change (NFC)

I missed this test in d35fcf0e97e7bb02381506a71e61ec282b292c50.

Added: 


Modified: 
clang/test/CodeGenCXX/wasm-eh.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/wasm-eh.cpp 
b/clang/test/CodeGenCXX/wasm-eh.cpp
index e965768bf834f..27752f5f58036 100644
--- a/clang/test/CodeGenCXX/wasm-eh.cpp
+++ b/clang/test/CodeGenCXX/wasm-eh.cpp
@@ -34,7 +34,7 @@ void test0() {
 // CHECK-NEXT:   %[[EXN:.*]] = call ptr @llvm.wasm.get.exception(token 
%[[CATCHPAD]])
 // CHECK-NEXT:   store ptr %[[EXN]], ptr %exn.slot
 // CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector(token 
%[[CATCHPAD]])
-// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #2
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #8
 // CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
 // CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label 
%[[CATCH_FALLTHROUGH_BB:.*]]
 
@@ -51,7 +51,7 @@ void test0() {
 // CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
 
 // CHECK: [[CATCH_FALLTHROUGH_BB]]
-// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(ptr @_ZTId) #2
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(ptr @_ZTId) #8
 // CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
 // CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label 
%[[RETHROW_BB:.*]]
 



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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-11-07 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 473693.

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

https://reviews.llvm.org/D137107

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/PR19955.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/dllimport-constexpr.cpp


Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- clang/test/SemaCXX/dllimport-constexpr.cpp
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -60,3 +60,12 @@
   // expected-note@+1 {{requested here}}
   StaticConstexpr::g_fp();
 }
+
+extern int __declspec(dllimport) val;
+// expected-error@+1{{constexpr variable 'val_ref' must be initialized by a 
constant expression}}
+constexpr int& val_ref = val;
+
+void AssignDllImportToConst () {
+  extern int _declspec(dllimport) val;
+  constexpr int& val_ref = val;
+}
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1594,8 +1594,8 @@
 
   void f(int k) { // expected-note {{here}}
 int arr[k]; // expected-warning {{C99}} expected-note {{function parameter 
'k'}}
-constexpr int n = 1 +
-sizeof(arr) // expected-error {{constant expression}}
+constexpr int n = 1 + // expected-error{{constexpr variable 'n' must be 
initialized by a constant expression}}
+sizeof(arr)
 * 3;
   }
 }
Index: clang/test/CodeGenCXX/dllimport.cpp
===
--- clang/test/CodeGenCXX/dllimport.cpp
+++ clang/test/CodeGenCXX/dllimport.cpp
@@ -769,6 +769,7 @@
   USEVAR(D<42>::y);
   // MSC-DAG: @"?x@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
   // MSC-DAG: @"?y@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
+  // MSC-DAG: @"?val@@3HA" = external dllimport global i32
 }
 
 namespace PR21355 {
@@ -1026,3 +1027,11 @@
 void baz() { U u; u.foo(); } // No diagnostic.
 
 }
+
+void assigndllimport () {
+  // MSC-DAG: define dso_local void @"?assigndllimport@@YAXXZ"()
+  // MSC-DAG: %[[VAL_REF:.*]] = alloca ptr
+  // MSC-DAG-NEXT: store ptr @"?val@@3HA", ptr %[[VAL_REF]]
+  extern int _declspec(dllimport) val;
+  constexpr int& val_ref = val;
+}
Index: clang/test/CodeGenCXX/PR19955.cpp
===
--- clang/test/CodeGenCXX/PR19955.cpp
+++ clang/test/CodeGenCXX/PR19955.cpp
@@ -14,9 +14,6 @@
 // CHECK-DAG: @"?funp@@3P6AXXZA" = dso_local global ptr null
 // X64-DAG: @"?funp@@3P6AXXZEA" = dso_local global ptr null
 
-// CHECK-LABEL: @"??__Evarp@@YAXXZ"
-// CHECK-DAG: store ptr @"?var@@3HA", ptr @"?varp@@3PAHA"
-
 // X64-LABEL: @"??__Evarp@@YAXXZ"
 // X64-DAG: store ptr @"?var@@3HA", ptr @"?varp@@3PEAHEA"
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13890,6 +13890,9 @@
   // FIXME: Consider replacing the initializer with a ConstantExpr.
 } else if (var->isConstexpr()) {
   SourceLocation DiagLoc = var->getLocation();
+  if (IsGlobal || (!IsGlobal && Notes.size() != 0))
+Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
+<< var << Init->getSourceRange();
   // If the note doesn't add any useful information other than a source
   // location, fold it into the primary diagnostic.
   if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
@@ -13897,8 +13900,6 @@
 DiagLoc = Notes[0].first;
 Notes.clear();
   }
-  Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
-  << var << Init->getSourceRange();
   for (unsigned I = 0, N = Notes.size(); I != N; ++I)
 Diag(Notes[I].first, Notes[I].second);
 } else if (GlobalStorage && var->hasAttr()) {


Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- clang/test/SemaCXX/dllimport-constexpr.cpp
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -60,3 +60,12 @@
   // expected-note@+1 {{requested here}}
   StaticConstexpr::g_fp();
 }
+
+extern int __declspec(dllimport) val;
+// expected-error@+1{{constexpr variable 'val_ref' must be initialized by a constant expression}}
+constexpr int& val_ref = val;
+
+void AssignDllImportToConst () {
+  extern int _declspec(dllimport) val;
+  constexpr int& val_ref = val;
+}
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1594,8 +1594,8 @@
 
   void f(int k) { // expected-note {{here}}
 int arr[k]; // expected-warning {{C99}} expected-note {{function parameter 'k'}}
-constexpr 

[PATCH] D131295: [clangd] Implement textDocument/codeLens

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



Comment at: clang-tools-extra/clangd/CodeLens.cpp:93
+  if (auto Loc = declToLocation(P->getCanonicalDecl()))
+Super.locations.emplace_back(*Loc);
+}

As noted in the previous PR it may be of low value, I guess only if override is 
missing or if it actually hides several functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131295

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


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

2022-11-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As discussed on IRC. This is just the bare minimum to support virtual base 
classes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137562

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -335,3 +335,24 @@
// expected-error {{must be initialized 
by a constant expression}}
// FIXME: Missing reason for rejection.
 };
+
+namespace VirtBases {
+  struct VB {
+int a;
+  };
+
+  struct S : virtual VB {}; // ref-note {{struct with virtual base class is 
not a literal type}} \
+// expected-note {{struct with virtual base class 
is not a literal type}} \
+// ref-note {{virtual base class declared here}} \
+// expected-note {{virtual base class declared 
here}}
+
+
+  constexpr S s; // ref-error {{cannot have non-literal type 'const S'}} \
+ // expected-error {{cannot have non-literal type 'const S'}}
+
+  S s2;
+  constexpr VB *v = &s2;
+//  static_assert(v->a); FIXME: Loading from s should error out, since
+//  it's not a constant expression.
+
+};
Index: clang/lib/AST/Interp/Descriptor.cpp
===
--- clang/lib/AST/Interp/Descriptor.cpp
+++ clang/lib/AST/Interp/Descriptor.cpp
@@ -122,7 +122,8 @@
 static void ctorRecord(Block *B, char *Ptr, bool IsConst, bool IsMutable,
bool IsActive, Descriptor *D) {
   const bool IsUnion = D->ElemRecord->isUnion();
-  auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase) {
+  auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase,
+ bool Recurse = true) {
 auto *Desc = reinterpret_cast(Ptr + SubOff) - 1;
 Desc->Offset = SubOff;
 Desc->Desc = F;
@@ -131,6 +132,10 @@
 Desc->IsActive = IsActive && !IsUnion;
 Desc->IsConst = IsConst || F->IsConst;
 Desc->IsMutable = IsMutable || F->IsMutable;
+
+if (!Recurse)
+  return;
+
 if (auto Fn = F->CtorFn)
   Fn(B, Ptr + SubOff, Desc->IsConst, Desc->IsMutable, Desc->IsActive, F);
   };
@@ -139,7 +144,7 @@
   for (const auto &F : D->ElemRecord->fields())
 CtorSub(F.Offset, F.Desc, /*isBase=*/false);
   for (const auto &V : D->ElemRecord->virtual_bases())
-CtorSub(V.Offset, V.Desc, /*isBase=*/true);
+CtorSub(V.Offset, V.Desc, /*isBase=*/true, false);
 }
 
 static void dtorRecord(Block *B, char *Ptr, Descriptor *D) {
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -119,9 +119,13 @@
 const CXXRecordDecl *ToDecl = getRecordDecl(CE);
 assert(ToDecl);
 const Record *R = getRecord(FromDecl);
-const Record::Base *ToBase = R->getBase(ToDecl);
-assert(ToBase);
+const Record::Base *ToBase;
+if (FromDecl->isVirtuallyDerivedFrom(ToDecl))
+  ToBase = R->getVirtualBase(ToDecl);
+else
+  ToBase = R->getBase(ToDecl);
 
+assert(ToBase);
 return this->emitGetPtrBase(ToBase->Offset, CE);
   }
 
@@ -515,7 +519,9 @@
   if (const auto *FD = dyn_cast(Member)) {
 const RecordDecl *RD = FD->getParent();
 const Record *R = getRecord(RD);
+assert(R);
 const Record::Field *F = R->getField(FD);
+assert(F);
 // Leave a pointer to the field on the stack.
 if (F->Decl->getType()->isReferenceType())
   return this->emitGetFieldPop(PT_Ptr, F->Offset, E);


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -335,3 +335,24 @@
// expected-error {{must be initialized by a constant expression}}
// FIXME: Missing reason for rejection.
 };
+
+namespace VirtBases {
+  struct VB {
+int a;
+  };
+
+  struct S : virtual VB {}; // ref-note {{struct with virtual base class is not a literal type}} \
+// expected-note {{struct with virtual base class is not a literal type}} \
+// ref-note {{virtual base class declared here}} \
+// expected-note {{virtual base class declared here}}
+
+
+  constexpr S s; // ref-error {{cannot have non-literal type 'const 

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

2022-11-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Refering to non-constexpr variables in a constant expression is (apparently) 
just fine, and only problematic once we load a value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137563

Files:
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -29,6 +29,15 @@
 
 static_assert(Ints::getFive() == 5, "");
 
+// Read of a non-constexpr variable in a constant expression.
+BoolPair nonConstBP; // ref-note {{declared here}} \
+ // expected-note {{declared here}}
+constexpr BoolPair *constBP = &nonConstBP;
+static_assert(constBP->first, ""); // ref-error {{not an integral constant 
expression}} \
+   // ref-note {{read of non-constexpr 
variable}} \
+   // expected-error {{not an integral 
constant expression}} \
+   // expected-note {{read of non-constexpr 
variable}}
+
 constexpr Ints ints;
 static_assert(ints.a == 20, "");
 static_assert(ints.b == 30, "");
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -98,6 +98,26 @@
   return true;
 }
 
+static bool CheckConstexpr(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  if (!S.inConstantContext())
+return true;
+
+  auto *VD = Ptr.getDeclDesc()->asValueDecl();
+  if (!VD)
+return true;
+
+  if (auto *VarD = dyn_cast(VD)) {
+if (VarD->hasLocalStorage() || VarD->isConstexpr())
+  return true;
+  }
+
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  S.FFDiag(Loc, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
+  S.Note(VD->getLocation(), diag::note_declared_at);
+
+  return false;
+}
+
 static bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
  AccessKinds AK) {
   if (Ptr.isInitialized())
@@ -294,6 +314,8 @@
 return false;
   if (!CheckExtern(S, OpPC, Ptr))
 return false;
+  if (!CheckConstexpr(S, OpPC, Ptr))
+return false;
   if (!CheckRange(S, OpPC, Ptr, AK_Read))
 return false;
   if (!CheckInitialized(S, OpPC, Ptr, AK_Read))


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -29,6 +29,15 @@
 
 static_assert(Ints::getFive() == 5, "");
 
+// Read of a non-constexpr variable in a constant expression.
+BoolPair nonConstBP; // ref-note {{declared here}} \
+ // expected-note {{declared here}}
+constexpr BoolPair *constBP = &nonConstBP;
+static_assert(constBP->first, ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{read of non-constexpr variable}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{read of non-constexpr variable}}
+
 constexpr Ints ints;
 static_assert(ints.a == 20, "");
 static_assert(ints.b == 30, "");
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -98,6 +98,26 @@
   return true;
 }
 
+static bool CheckConstexpr(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  if (!S.inConstantContext())
+return true;
+
+  auto *VD = Ptr.getDeclDesc()->asValueDecl();
+  if (!VD)
+return true;
+
+  if (auto *VarD = dyn_cast(VD)) {
+if (VarD->hasLocalStorage() || VarD->isConstexpr())
+  return true;
+  }
+
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  S.FFDiag(Loc, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
+  S.Note(VD->getLocation(), diag::note_declared_at);
+
+  return false;
+}
+
 static bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
  AccessKinds AK) {
   if (Ptr.isInitialized())
@@ -294,6 +314,8 @@
 return false;
   if (!CheckExtern(S, OpPC, Ptr))
 return false;
+  if (!CheckConstexpr(S, OpPC, Ptr))
+return false;
   if (!CheckRange(S, OpPC, Ptr, AK_Read))
 return false;
   if (!CheckInitialized(S, OpPC, Ptr, AK_Read))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-11-07 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 473706.
abidmalikwaterloo marked 2 inline comments as done.
abidmalikwaterloo added a comment.

corrected the syntex of the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -121,6 +121,19 @@
   return
 }
 
+// CHECK-LABEL: omp_DistributeOp
+func.func @omp_DistributeOp(%lb : index, %ub : index, %step : index, %data_var : memref, %chunk_var : i32) -> () {
+  // CHECK: omp.distribute collapse(2)
+  // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
+  "omp.distribute" (%lb, %ub, %step) ({
+^bb0(%iv: index):
+ omp.yield 
+  }) {operand_segment_sizes = dense<[1,1,1,0,0,0]> : vector<6xi32>, collapse_val = 2} :
+(index, index, index) -> ()
+ 
+ return
+ }
+
 // CHECK-LABEL: omp_wsloop
 func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref, %linear_var : i32, %chunk_var : i32) -> () {
 
Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -207,6 +207,20 @@
   return success();
 }
 
+//===-===//
+// Verifier for Dristribute Op
+//===-===//
+
+LogicalResult DistributeOp::verify(){
+  if (this->lowerBound().empty()) 
+return emitOpError() << "empty lowerbound for distribute loop operation";
+  
+  if (this->upperBound().empty()) 
+return emitOpError() << "empty upperbound for distribute loop operation";
+  
+  return success();	
+}
+
 /// schedule ::= `schedule` `(` sched-list `)`
 /// sched-list ::= sched-val | sched-val sched-list |
 ///sched-val `,` sched-modifier
@@ -510,14 +524,14 @@
 }
 
 //===--===//
-// WsLoopOp
+// LoopControl
 //===--===//
 
 /// loop-control ::= `(` ssa-id-list `)` `:` type `=`  loop-bounds
 /// loop-bounds := `(` ssa-id-list `)` to `(` ssa-id-list `)` inclusive? steps
 /// steps := `step` `(`ssa-id-list`)`
 ParseResult
-parseWsLoopControl(OpAsmParser &parser, Region ®ion,
+parseLoopControl(OpAsmParser &parser, Region ®ion,
SmallVectorImpl &lowerBound,
SmallVectorImpl &upperBound,
SmallVectorImpl &steps,
@@ -560,7 +574,7 @@
   return success();
 }
 
-void printWsLoopControl(OpAsmPrinter &p, Operation *op, Region ®ion,
+void printLoopControl(OpAsmPrinter &p, Operation *op, Region ®ion,
 ValueRange lowerBound, ValueRange upperBound,
 ValueRange steps, TypeRange loopVarTypes,
 UnitAttr inclusive) {
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -394,7 +394,7 @@
   custom(
 $reduction_vars, type($reduction_vars), $reductions
   ) `)`
-) `for` custom($region, $lowerBound, $upperBound, $step,
+) `for` custom($region, $lowerBound, $upperBound, $step,
   type($step), $inclusive) attr-dict
   }];
   let hasVerifier = 1;
@@ -446,7 +446,7 @@
 def YieldOp : OpenMP_Op<"yield",
 [NoSideEffect, ReturnLike, Terminator,
  ParentOneOf<["WsLoopOp", "ReductionDeclareOp", 
- "AtomicUpdateOp", "SimdLoopOp"]>]> {
+ "AtomicUpdateOp", "SimdLoopOp", "DistributeOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
 "omp.yield" yields SSA values from the OpenMP dialect op region and
@@ -463,6 +463,68 @@
   let assemblyFormat = [{ ( `(` $results^ `:` type($results) `)` )? attr-dict}];
 }
 
+//===--===//
+// 2.9.4.1 distribute Construct
+//===--===//
+
+def DistributeOp : OpenMP_Op<"distribute", [AttrSizedOperandSegments,
+AllTypesMatch<["lowerBound", "upperBound", "step"]>]> {
+  let summary = "distribute loop construct";
+  let description = [{ 
+The distribute construct specifies that the iterations of one or more loop
+will be executed by the initial teams in the context of their implicit 
+tasks. The iterations are distribut

[PATCH] D137240: [clang][Interp] Support alignof()

2022-11-07 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 473707.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D137240

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/class-layout.cpp
  clang/test/AST/Interp/cxx20.cpp

Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
 // RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
+void test_alignas_operand() {
+  alignas(8) char dummy;
+  static_assert(__alignof(dummy) == 8);
+}
 
 constexpr int getMinus5() {
   int a = 10;
Index: clang/test/AST/Interp/class-layout.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/class-layout.cpp
@@ -0,0 +1,698 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// expected-no-diagnostics
+
+// FIXME: This is a copy of clang/test/SemaCXX/class-layout.cpp, but with the
+//   __builtin_offsetof calls commented out. Once that is supported in the
+//   new interpreter, we might as well remove this duplicated file and
+//   just use the one in SemaCXX/.
+
+#define SA(n, p) int a##n[(p) ? 1 : -1]
+
+struct A {
+  int a;
+  char b;
+};
+
+SA(0, sizeof(A) == 8);
+
+struct B : A {
+  char c;
+};
+
+SA(1, sizeof(B) == 12);
+
+struct C {
+// Make fields private so C won't be a POD type.
+private:
+  int a;
+  char b;
+};
+
+SA(2, sizeof(C) == 8);
+
+struct D : C {
+  char c;
+};
+
+SA(3, sizeof(D) == 8);
+
+struct __attribute__((packed)) E {
+  char b;
+  int a;
+};
+
+SA(4, sizeof(E) == 5);
+
+struct __attribute__((packed)) F : E {
+  char d;
+};
+
+SA(5, sizeof(F) == 6);
+
+struct G { G(); };
+struct H : G { };
+
+SA(6, sizeof(H) == 1);
+
+struct I {
+  char b;
+  int a;
+} __attribute__((packed));
+
+SA(6_1, sizeof(I) == 5);
+
+// PR5580
+namespace PR5580 {
+
+class A { bool iv0 : 1; };
+SA(7, sizeof(A) == 1);  
+
+class B : A { bool iv0 : 1; };
+SA(8, sizeof(B) == 2);
+
+struct C { bool iv0 : 1; };
+SA(9, sizeof(C) == 1);  
+
+struct D : C { bool iv0 : 1; };
+SA(10, sizeof(D) == 2);
+
+}
+
+namespace Test1 {
+
+// Test that we don't assert on this hierarchy.
+struct A { };
+struct B : A { virtual void b(); };
+class C : virtual A { int c; };
+struct D : virtual B { };
+struct E : C, virtual D { };
+class F : virtual E { };
+struct G : virtual E, F { };
+
+SA(0, sizeof(G) == 24);
+
+}
+
+namespace Test2 {
+
+// Test that this somewhat complex class structure is laid out correctly.
+struct A { };
+struct B : A { virtual void b(); };
+struct C : virtual B { };
+struct D : virtual A { };
+struct E : virtual B, D { };
+struct F : E, virtual C { };
+struct G : virtual F, A { };
+struct H { G g; };
+
+SA(0, sizeof(H) == 24);
+
+}
+
+namespace PR16537 {
+namespace test1 {
+  struct pod_in_11_only {
+  private:
+long long x;
+  };
+   
+  struct tail_padded_pod_in_11_only {
+pod_in_11_only pod11;
+char tail_padding;
+  };
+
+  struct might_use_tail_padding : public tail_padded_pod_in_11_only {
+char may_go_into_tail_padding;
+  };
+
+  SA(0, sizeof(might_use_tail_padding) == 16);
+}
+
+namespace test2 {
+  struct pod_in_11_only {
+  private:
+long long x;
+  };
+   
+  struct tail_padded_pod_in_11_only {
+pod_in_1

[PATCH] D137240: [clang][Interp] Support alignof()

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

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

https://reviews.llvm.org/D137240

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/class-layout.cpp
  clang/test/AST/Interp/cxx20.cpp

Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
 // RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
+void test_alignas_operand() {
+  alignas(8) char dummy;
+  static_assert(__alignof(dummy) == 8);
+}
 
 constexpr int getMinus5() {
   int a = 10;
Index: clang/test/AST/Interp/class-layout.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/class-layout.cpp
@@ -0,0 +1,698 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -fexperimental-new-constant-interpreter -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// expected-no-diagnostics
+
+// FIXME: This is a copy of clang/test/SemaCXX/class-layout.cpp, but with the
+//   __builtin_offsetof calls commented out. Once that is supported in the
+//   new interpreter, we might as well remove this duplicated file and
+//   just use the one in SemaCXX/.
+
+#define SA(n, p) int a##n[(p) ? 1 : -1]
+
+struct A {
+  int a;
+  char b;
+};
+
+SA(0, sizeof(A) == 8);
+
+struct B : A {
+  char c;
+};
+
+SA(1, sizeof(B) == 12);
+
+struct C {
+// Make fields private so C won't be a POD type.
+private:
+  int a;
+  char b;
+};
+
+SA(2, sizeof(C) == 8);
+
+struct D : C {
+  char c;
+};
+
+SA(3, sizeof(D) == 8);
+
+struct __attribute__((packed)) E {
+  char b;
+  int a;
+};
+
+SA(4, sizeof(E) == 5);
+
+struct __attribute__((packed)) F : E {
+  char d;
+};
+
+SA(5, sizeof(F) == 6);
+
+struct G { G(); };
+struct H : G { };
+
+SA(6, sizeof(H) == 1);
+
+struct I {
+  char b;
+  int a;
+} __attribute__((packed));
+
+SA(6_1, sizeof(I) == 5);
+
+// PR5580
+namespace PR5580 {
+
+class A { bool iv0 : 1; };
+SA(7, sizeof(A) == 1);  
+
+class B : A { bool iv0 : 1; };
+SA(8, sizeof(B) == 2);
+
+struct C { bool iv0 : 1; };
+SA(9, sizeof(C) == 1);  
+
+struct D : C { bool iv0 : 1; };
+SA(10, sizeof(D) == 2);
+
+}
+
+namespace Test1 {
+
+// Test that we don't assert on this hierarchy.
+struct A { };
+struct B : A { virtual void b(); };
+class C : virtual A { int c; };
+struct D : virtual B { };
+struct E : C, virtual D { };
+class F : virtual E { };
+struct G : virtual E, F { };
+
+SA(0, sizeof(G) == 24);
+
+}
+
+namespace Test2 {
+
+// Test that this somewhat complex class structure is laid out correctly.
+struct A { };
+struct B : A { virtual void b(); };
+struct C : virtual B { };
+struct D : virtual A { };
+struct E : virtual B, D { };
+struct F : E, virtual C { };
+struct G : virtual F, A { };
+struct H { G g; };
+
+SA(0, sizeof(H) == 24);
+
+}
+
+namespace PR16537 {
+namespace test1 {
+  struct pod_in_11_only {
+  private:
+long long x;
+  };
+   
+  struct tail_padded_pod_in_11_only {
+pod_in_11_only pod11;
+char tail_padding;
+  };
+
+  struct might_use_tail_padding : public tail_padded_pod_in_11_only {
+char may_go_into_tail_padding;
+  };
+
+  SA(0, sizeof(might_use_tail_padding) == 16);
+}
+
+namespace test2 {
+  struct pod_in_11_only {
+  private:
+long long x;
+  };
+   
+  struct tail_padded_pod_in_11_only {
+pod_in_11_only pod11 __attribute__((aligned(16)));

[PATCH] D136811: -Wunsafe-buffer-usage: WIP: RFC: NFC: User documentation.

2022-11-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/docs/SafeBuffers.rst:124
+  - Array subscript expression on raw arrays or raw pointers,
+  - unless the index is a compile-time constant ``0``,
+  - Increment and decrement of a raw pointer with operators ``++`` and ``--``;

xazax.hun wrote:
> Isn't this too restrictive? How about arrays where both the index and the 
> size of the array is known at compile time?
> 
> Also, what about subscripts in `consteval` code where the compiler should 
> diagnose OOB accesses at compile time?
> 
> I believe this model can be made more ergonomic without losing any of the 
> guarantees.
Small ping on this point. I think there are many code patterns that are 
completely safe (i.e., the compiler can diagnose OOB accesses), but the current 
model would ban. One example is converting an enum value to string using an 
array of string_views. In those cases, both enum consts' value and the array's 
size are known at compile time. I think those easy to diagnose special cases 
should be permitted to make programming more ergonomic. The more ergonomic the 
experience, the faster the adoption will be. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D136811

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


[PATCH] D137564: [ARM] Move Triple::getARMCPUForArch into ARMTargetParser

2022-11-07 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
tmatheson added reviewers: lenary, pratlucas, DavidSpickett.
Herald added subscribers: hiraditya, kristof.beyls, dschuff.
Herald added a project: All.
tmatheson requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLDB, LLVM.

This is very backend specific so either belongs in Toolchains/ARM or in
ARMTargetParser. Since it is used in lldb, ARMTargetParser made more sense.

This is part of an effort to move information about ARM/AArch64 architecture
versions, extensions and CPUs into their respective TargetParsers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137564

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  lldb/source/Utility/ArchSpec.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -6,12 +6,13 @@
 //
 //===--===//
 
+#include "llvm/Support/TargetParser.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/AArch64TargetParser.h"
 #include "llvm/Support/ARMBuildAttributes.h"
 #include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/TargetParser.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -871,6 +872,70 @@
   EXPECT_EQ(5u, ARM::parseArchVersion(ARMArch[i]));
 }
 
+TEST(TargetParserTest, getARMCPUForArch) {
+  // Platform specific defaults.
+  {
+llvm::Triple Triple("arm--nacl");
+EXPECT_EQ("cortex-a8", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("arm--openbsd");
+EXPECT_EQ("cortex-a8", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armv6-unknown-freebsd");
+EXPECT_EQ("arm1176jzf-s", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("thumbv6-unknown-freebsd");
+EXPECT_EQ("arm1176jzf-s", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armebv6-unknown-freebsd");
+EXPECT_EQ("arm1176jzf-s", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("arm--win32");
+EXPECT_EQ("cortex-a9", ARM::getARMCPUForArch(Triple));
+EXPECT_EQ("generic", ARM::getARMCPUForArch(Triple, "armv8-a"));
+  }
+  // Some alternative architectures
+  {
+llvm::Triple Triple("armv7k-apple-ios9");
+EXPECT_EQ("cortex-a7", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armv7k-apple-watchos3");
+EXPECT_EQ("cortex-a7", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armv7k-apple-tvos9");
+EXPECT_EQ("cortex-a7", ARM::getARMCPUForArch(Triple));
+  }
+  // armeb is permitted, but armebeb is not
+  {
+llvm::Triple Triple("armeb-none-eabi");
+EXPECT_EQ("arm7tdmi", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armebeb-none-eabi");
+EXPECT_EQ("", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armebv6eb-none-eabi");
+EXPECT_EQ("", ARM::getARMCPUForArch(Triple));
+  }
+  // xscaleeb is permitted, but armebxscale is not
+  {
+llvm::Triple Triple("xscaleeb-none-eabi");
+EXPECT_EQ("xscale", ARM::getARMCPUForArch(Triple));
+  }
+  {
+llvm::Triple Triple("armebxscale-none-eabi");
+EXPECT_EQ("", ARM::getARMCPUForArch(Triple));
+  }
+}
+
 class AArch64CPUTestFixture
 : public ::testing::TestWithParam {};
 
Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1855,70 +1855,6 @@
 Triple::normalize("aarch64-linux-android21"));
 }
 
-TEST(TripleTest, getARMCPUForArch) {
-  // Platform specific defaults.
-  {
-llvm::Triple Triple("arm--nacl");
-EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
-  }
-  {
-llvm::Triple Triple("arm--openbsd");
-EXPECT_EQ("cortex-a8", Triple.getARMCPUForArch());
-  }
-  {
-llvm::Triple Triple("armv6-unknown-freebsd");
-EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
-  }
-  {
-llvm::Triple Triple("thumbv6-unknown-freebsd");
-EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
-  }
-  {
-llvm::Triple Triple("armebv6-unknown-freebsd");
-EXPECT_EQ("arm1176jzf-s", Triple.getARMCPUForArch());
-  }
-  {
-llvm::Triple Triple("arm--win32");
-EXPECT_EQ("cortex-a9", Triple.getARMCPUForArch());
-EXPECT_EQ("generic", Triple.getARMCPUForArch("armv8-a"));
-  }
-  // Some alternative architectures
-  {
-llvm::Triple Triple("armv7k-apple-ios9");
-EXPECT_EQ("cortex-a

[PATCH] D137372: [AIX][pg] Add 32-bit Test Case to Linker Tests

2022-11-07 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added a comment.

Use the [Test] tag in the abstract.

Suggest: "[Test][AIX][pg] Add 32-bit expected driver output"

No need for a summary.


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] D137514: [clang-tidy] add check for capturing lambda coroutines

2022-11-07 Thread Noah Watkins via Phabricator via cfe-commits
dotnwat added a comment.

In D137514#3911046 , @ChuanqiXu wrote:

> This is helpful. I feel it is OK to add the warning in the clang too. Are you 
> interested in that?

Yes, but unfortunately I'm very time constrained until the end of the year. Is 
that something that would need to be added to this diff, or could be separate? 
(fyi, brand new to clang development)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137514

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


[PATCH] D137373: [AIX][p] Add 64-bit Test Case to Linker Tests

2022-11-07 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added a comment.

Suggest: [Test][AIX][p] Add 64-bit driver expected output

No summary required.


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] D137511: [PPC] Undefine __ppc64__ to match GCC

2022-11-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D137511#3911149 , @nemanjai wrote:

> I am going to block this since the uses of the macros in 
> `clang/lib/Headers/ppc_wrappers` will likely cause build bot failures.

clang/lib/Headers/ppc_wrappers was fixed yesterday. The only dependency is 
D137513  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137511

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


[PATCH] D137516: [TargetSupport] Move TargetParser API in a separate LLVM component.

2022-11-07 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

@arsenm @frasercrmck @lenary - thank you for the feedback

1. The library could host anything that needs to be auto-generated with 
tablegen. If we add `MVT`s, the name `TargetSupport` becomes obsolete.
2. Therefore we could use a name like `AutoGenSupport` (or similar, I am open 
to suggestions).
3. @lenary is saying that components like `Support/Host` needs to be moved 
together with the AArch64/ARM bits of the target parser. Do people see an issue 
if we add files that do not need auto-generated content in a library called 
`AutoGenSupport`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137516

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


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a reviewer: hans.
thieta added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137322

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


[PATCH] D137570: [Clang][Sema] Refactor category declaration under CheckForIncompatibleAttributes. NFC

2022-11-07 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added a reviewer: SjoerdMeijer.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added a project: clang.

This change allows extension of new categories be aware of adding more
code here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137570

Files:
  clang/lib/Sema/SemaStmtAttr.cpp


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -306,21 +306,30 @@
   if (!DiagnoseMutualExclusions(S, Attrs))
 return;
 
-  // There are 6 categories of loop hints attributes: vectorize, interleave,
-  // unroll, unroll_and_jam, pipeline and distribute. Except for distribute 
they
-  // come in two variants: a state form and a numeric form.  The state form
-  // selectively defaults/enables/disables the transformation for the loop
-  // (for unroll, default indicates full unrolling rather than enabling the
-  // transformation). The numeric form form provides an integer hint (for
-  // example, unroll count) to the transformer. The following array accumulates
-  // the hints encountered while iterating through the attributes to check for
-  // compatibility.
+  enum CategoryType {
+Vectorize,
+Interleave,
+Unroll,
+UnrollAndJam,
+Distribute,
+Pipeline,
+VectorizePredicate,
+NumberOfCategories
+  };
+  // There are 7 categories of loop hints attributes: vectorize, interleave,
+  // unroll, unroll_and_jam, pipeline, distribute, and vectorize predicate.
+  // Except for distribute and vectorize predicate, they come in two variants: 
a
+  // state form and a numeric form.  The state form selectively
+  // defaults/enables/disables the transformation for the loop (for unroll,
+  // default indicates full unrolling rather than enabling the transformation).
+  // The numeric form form provides an integer hint (for example, unroll count)
+  // to the transformer. The following array accumulates the hints encountered
+  // while iterating through the attributes to check for compatibility.
   struct {
 const LoopHintAttr *StateAttr;
 const LoopHintAttr *NumericAttr;
-  } HintAttrs[] = {{nullptr, nullptr}, {nullptr, nullptr}, {nullptr, nullptr},
-   {nullptr, nullptr}, {nullptr, nullptr}, {nullptr, nullptr},
-   {nullptr, nullptr}};
+  } HintAttrs[CategoryType::NumberOfCategories];
+  memset(HintAttrs, 0, sizeof(HintAttrs));
 
   for (const auto *I : Attrs) {
 const LoopHintAttr *LH = dyn_cast(I);
@@ -329,16 +338,8 @@
 if (!LH)
   continue;
 
+CategoryType Category = CategoryType::NumberOfCategories;
 LoopHintAttr::OptionType Option = LH->getOption();
-enum {
-  Vectorize,
-  Interleave,
-  Unroll,
-  UnrollAndJam,
-  Distribute,
-  Pipeline,
-  VectorizePredicate
-} Category;
 switch (Option) {
 case LoopHintAttr::Vectorize:
 case LoopHintAttr::VectorizeWidth:
@@ -369,7 +370,7 @@
   break;
 };
 
-assert(Category < sizeof(HintAttrs) / sizeof(HintAttrs[0]));
+assert(Category != NumberOfCategories && "Unhandled loop hint option");
 auto &CategoryState = HintAttrs[Category];
 const LoopHintAttr *PrevAttr;
 if (Option == LoopHintAttr::Vectorize ||


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -306,21 +306,30 @@
   if (!DiagnoseMutualExclusions(S, Attrs))
 return;
 
-  // There are 6 categories of loop hints attributes: vectorize, interleave,
-  // unroll, unroll_and_jam, pipeline and distribute. Except for distribute they
-  // come in two variants: a state form and a numeric form.  The state form
-  // selectively defaults/enables/disables the transformation for the loop
-  // (for unroll, default indicates full unrolling rather than enabling the
-  // transformation). The numeric form form provides an integer hint (for
-  // example, unroll count) to the transformer. The following array accumulates
-  // the hints encountered while iterating through the attributes to check for
-  // compatibility.
+  enum CategoryType {
+Vectorize,
+Interleave,
+Unroll,
+UnrollAndJam,
+Distribute,
+Pipeline,
+VectorizePredicate,
+NumberOfCategories
+  };
+  // There are 7 categories of loop hints attributes: vectorize, interleave,
+  // unroll, unroll_and_jam, pipeline, distribute, and vectorize predicate.
+  // Except for distribute and vectorize predicate, they come in two variants: a
+  // state form and a numeric form.  The state form selectively
+  // defaults/enables/disables the transformation for the loop (for unroll,
+  // default indicates full unrolling rather than enabling the transformation).
+  // The numeric form form provides an integ

[PATCH] D137570: [Clang][Sema] Refactor category declaration under CheckForIncompatibleAttributes. NFC

2022-11-07 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Upon additional modification to this code base I am tempt to prefer having a 
`NumberOfCategories` under the enum and make the sanity check explicit. I 
understand this is totally a problem of personal taste so definitely feel free 
to argue with me :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137570

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


[PATCH] D137572: [AVR][Clang] Implement __AVR_HAVE_*__ macros

2022-11-07 Thread Ayke via Phabricator via cfe-commits
aykevl created this revision.
aykevl added reviewers: benshi001, dylanmckay.
Herald added a subscriber: Jim.
Herald added a project: All.
aykevl requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These macros are defined in avr-gcc and are useful when working with assembly.
For example, startup code needs to copy the contents of .data from flash to 
RAM, but should use elpm (instead of lpm) on devices with more than 64kB flash. 
Without `__AVR_HAVE_ELPM__`, there is no way to know whether the elpm 
instruction is supported.

Depends on D137521 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137572

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/test/Preprocessor/avr-atmega328p.c
  clang/test/Preprocessor/avr-attiny104.c

Index: clang/test/Preprocessor/avr-attiny104.c
===
--- clang/test/Preprocessor/avr-attiny104.c
+++ clang/test/Preprocessor/avr-attiny104.c
@@ -4,5 +4,6 @@
 // CHECK: #define __AVR 1
 // CHECK: #define __AVR_ARCH__ 100
 // CHECK: #define __AVR_ATtiny104__ 1
+// CHECK-NOT: #define __AVR_HAVE_MUL__ 1
 // CHECK: #define __AVR__ 1
 // CHECK: #define __ELF__ 1
Index: clang/test/Preprocessor/avr-atmega328p.c
===
--- clang/test/Preprocessor/avr-atmega328p.c
+++ clang/test/Preprocessor/avr-atmega328p.c
@@ -4,5 +4,9 @@
 // CHECK: #define __AVR 1
 // CHECK: #define __AVR_ARCH__ 5
 // CHECK: #define __AVR_ATmega328P__ 1
+// CHECK-NOT: #define __AVR_HAVE_EIJMP_EICALL__
+// CHECK: #define __AVR_HAVE_LPMX__ 1
+// CHECK: #define __AVR_HAVE_MOVW__ 1
+// CHECK: #define __AVR_HAVE_MUL__ 1
 // CHECK: #define __AVR__ 1
 // CHECK: #define __ELF__ 1
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -12,6 +12,7 @@
 
 #include "AVR.h"
 #include "clang/Basic/MacroBuilder.h"
+#include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -348,6 +349,53 @@
 } // namespace targets
 } // namespace clang
 
+static bool ArchHasELPM(StringRef Arch) {
+  return llvm::StringSwitch(Arch)
+.Cases("31", "51", "6", true)
+.Cases("104", "105", "106", "107", true)
+.Default(false);
+}
+
+static bool ArchHasELPMX(StringRef Arch) {
+  return llvm::StringSwitch(Arch)
+.Cases("51", "6", true)
+.Cases("104", "105", "106", "107", true)
+.Default(false);
+}
+
+static bool ArchHasMOVW(StringRef Arch) {
+  return llvm::StringSwitch(Arch)
+.Cases("25", "35", "4", "5", "51", "6", true)
+.Cases("102", "103", "104", "105", "106", "107", true)
+.Default(false);
+}
+
+static bool ArchHasLPMX(StringRef Arch) {
+  return ArchHasMOVW(Arch); // same architectures
+}
+
+static bool ArchHasMUL(StringRef Arch) {
+  return llvm::StringSwitch(Arch)
+.Cases("4", "5", "51", "6", true)
+.Cases("102", "103", "104", "105", "106", "107", true)
+.Default(false);
+}
+
+static bool ArchHasJMPCALL(StringRef Arch) {
+  return llvm::StringSwitch(Arch)
+.Cases("3", "31", "35", "5", "51", "6", true)
+.Cases("102", "103", "104", "105", "106", "107", true)
+.Default(false);
+}
+
+static bool ArchHas3BytePC(StringRef Arch) {
+  // These devices have more than 128kB of program memory.
+  return llvm::StringSwitch(Arch)
+.Case("6", true)
+.Cases("106", "107", true)
+.Default(false);
+}
+
 bool AVRTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::any_of(
   AVRMcus, [&](const MCUInfo &Info) { return Info.Name == Name; });
@@ -390,6 +438,25 @@
 
   Builder.defineMacro("__AVR_ARCH__", Arch);
 
+  if (ArchHasELPM(Arch))
+Builder.defineMacro("__AVR_HAVE_ELPM__");
+  if (ArchHasELPMX(Arch))
+Builder.defineMacro("__AVR_HAVE_ELPMX__");
+  if (ArchHasMOVW(Arch))
+Builder.defineMacro("__AVR_HAVE_MOVW__");
+  if (ArchHasLPMX(Arch))
+Builder.defineMacro("__AVR_HAVE_LPMX__");
+  if (ArchHasMUL(Arch))
+Builder.defineMacro("__AVR_HAVE_MUL__");
+  if (ArchHasJMPCALL(Arch))
+Builder.defineMacro("__AVR_HAVE_JMP_CALL__");
+  if (ArchHas3BytePC(Arch)) {
+Builder.defineMacro("__AVR_HAVE_EIJMP_EICALL__");
+Builder.defineMacro("__AVR_3_BYTE_PC__");
+  } else {
+Builder.defineMacro("__AVR_2_BYTE_PC__");
+  }
+
   if (NumFlashBanks >= 1)
 Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
   if (NumFlashBanks >= 2)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137516: [TargetSupport] Move TargetParser API in a separate LLVM component.

2022-11-07 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D137516#3912751 , @fpetrogalli 
wrote:

> @arsenm @frasercrmck @lenary - thank you for the feedback
>
> 1. The library could host anything that needs to be auto-generated with 
> tablegen. If we add `MVT`s, the name `TargetSupport` becomes obsolete.

I am in favour of splitting parts of Support that could be table-gen'd out of 
Support, and into supplemental libraries.

> 2. Therefore we could use a name like `AutoGenSupport` (or similar, I am open 
> to suggestions).

I actually think this is an awful name, even worse than "Support". One of the 
big issues with "Support" is that it's a junk-drawer that anyone throws stuff 
in when they need it anywhere in LLVM, when their layering questions become 
more difficult. This then becomes very hard to undo, because everything at this 
layer depends on everything else. "AutoGenSupport" to me says "we now have two 
bits, the junk drawer, and the junk drawer that's auto generated" and so I feel 
this is is worse, as you cannot differentiate which you need based on what 
you're doing.

I think we need to name things after what they're for, not how they're made.

> 3. @lenary is saying that components like `Support/Host` needs to be moved 
> together with the AArch64/ARM bits of the target parser. Do people see an 
> issue if we add files that do not need auto-generated content in a library 
> called `AutoGenSupport`?

The reason I'm in favour of "TargetParser" is because we already call the 
classes and related files "target parsers", and most of them contain 
target-related parsers. I don't know why this is a bad name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137516

___
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-07 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCV.td:509
 
-def : ProcessorModel<"generic-rv32", NoSchedModel, [Feature32Bit]>;
-def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
+class RISCVProcessorModelPROC {
+  string Enum = enum;

pcwang-thead wrote:
> Can `EnumFeatures/DefaultMarch` string be inferred from ProcessorModel's 
> SubtargetFeature if not specified and `Enum` just be the uppercase of the 
> name of ProcessorModel? The implementation could be more complicated but I 
> think it's worthy.
> Can `EnumFeatures/DefaultMarch` string be inferred from ProcessorModel's 
> SubtargetFeature if not specified 

Sorry, I don't see how. `SubtargetFeature` is used in the fields `Features` and 
`TuneFeatures`. I don't see the logic to extract this information from them.

> and `Enum` just be the uppercase of the name of ProcessorModel? The 
> implementation could be more complicated but I think it's worthy.

My preference would be to keep the Enum explicit as it would help using those 
enums in the code. Also, sometimes the enum cannot be derived from the Name 
(see for example `"sifive-7-series"` vs `"SIFIVE_7"`).




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] D137516: [TargetSupport] Move TargetParser API in a separate LLVM component.

2022-11-07 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D137516#3912842 , @lenary wrote:

> In D137516#3912751 , @fpetrogalli 
> wrote:
>
>> @arsenm @frasercrmck @lenary - thank you for the feedback
>>
>> 1. The library could host anything that needs to be auto-generated with 
>> tablegen. If we add `MVT`s, the name `TargetSupport` becomes obsolete.
>
> I am in favour of splitting parts of Support that could be table-gen'd out of 
> Support, and into supplemental libraries.

+1

>> 2. Therefore we could use a name like `AutoGenSupport` (or similar, I am 
>> open to suggestions).
>
> I actually think this is an awful name, even worse than "Support". One of the 
> big issues with "Support" is that it's a junk-drawer that anyone throws stuff 
> in when they need it anywhere in LLVM, when their layering questions become 
> more difficult. This then becomes very hard to undo, because everything at 
> this layer depends on everything else. "AutoGenSupport" to me says "we now 
> have two bits, the junk drawer, and the junk drawer that's auto generated" 
> and so I feel this is is worse, as you cannot differentiate which you need 
> based on what you're doing.
>
> I think we need to name things after what they're for, not how they're made.

Agree.

>> 3. @lenary is saying that components like `Support/Host` needs to be moved 
>> together with the AArch64/ARM bits of the target parser. Do people see an 
>> issue if we add files that do not need auto-generated content in a library 
>> called `AutoGenSupport`?
>
> The reason I'm in favour of "TargetParser" is because we already call the 
> classes and related files "target parsers", and most of them contain 
> target-related parsers. I don't know why this is a bad name.

I'd be very happy to use the name `TargetParser`. I initially used that because 
I knew that moving the RSCV bits of it meant  we needed to move the other 
parsers too, together with `Support/Host`. Therefore I was trying to create a 
name that would have covered for both the target parser any other pieces that 
would have been moved in it. However...

> Edited to add: Once I've split out Support/Host, I'm likely to give it a less 
> generic name, something like "HostDetection", which is more clearly what it 
> is doing.

... you seem to imply that you want to create a second component that is 
independent of `[TargetParser|TargetSUpport]`. If that's the case, I am even 
more convinced that `TargetParser` is the best name for the component 
introduced in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137516

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


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm with nits




Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:47
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT:  0x{{.+}}: `"{{.+}}-fmessage-length=

could this be just
MESSAGELEN-NOT: -fmessage-length
?



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:911
   continue;
+// Skip fmessage-length for reproduciability
+if (Arg.startswith("-fmessage-length"))

nit: Period at the end (though I know we're not super consistent about this).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137322

___
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-07 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 473738.
fpetrogalli added a comment.

When looping through the records in tablegen, I have added an extra (necessary) 
condition to make sure that the records we are processing are also derived from 
the class 
`ProcessorModel`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/CMakeLists.txt
  llvm/include/llvm/TargetSupport/RISCVTargetParser.def
  llvm/include/llvm/TargetSupport/TargetParser.h
  llvm/include/llvm/module.modulemap
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
  llvm/lib/Target/AMDGPU/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
  llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/TargetSupport/CMakeLists.txt
  llvm/lib/TargetSupport/TargetParser.cpp
  llvm/unittests/Support/CMakeLists.txt
  llvm/unittests/TargetSupport/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  llvm/utils/TableGen/TableGen.cpp
  llvm/utils/TableGen/TableGenBackends.h

Index: llvm/utils/TableGen/TableGenBackends.h
===
--- llvm/utils/TableGen/TableGenBackends.h
+++ llvm/utils/TableGen/TableGenBackends.h
@@ -94,7 +94,7 @@
 void EmitDirectivesDecl(RecordKeeper &RK, raw_ostream &OS);
 void EmitDirectivesImpl(RecordKeeper &RK, raw_ostream &OS);
 void EmitDXILOperation(RecordKeeper &RK, raw_ostream &OS);
-
+void EmitRISCVTargetDef(RecordKeeper &RK, raw_ostream &OS);
 } // End llvm namespace
 
 #endif
Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -58,6 +58,7 @@
   GenDirectivesEnumDecl,
   GenDirectivesEnumImpl,
   GenDXILOperation,
+  GenRISCVTargetDef,
 };
 
 namespace llvm {
@@ -141,8 +142,9 @@
 clEnumValN(GenDirectivesEnumImpl, "gen-directive-impl",
"Generate directive related implementation code"),
 clEnumValN(GenDXILOperation, "gen-dxil-operation",
-   "Generate DXIL operation information")));
-
+   "Generate DXIL operation information"),
+clEnumValN(GenRISCVTargetDef, "gen-riscv-target-def",
+   "Generate the list of CPU for RISCV")));
 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
 cl::opt Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"),
@@ -278,6 +280,9 @@
   case GenDXILOperation:
 EmitDXILOperation(Records, OS);
 break;
+  case GenRISCVTargetDef:
+EmitRISCVTargetDef(Records, OS);
+break;
   }
 
   return false;
Index: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
===
--- /dev/null
+++ llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -0,0 +1,51 @@
+//===- RISCVTargetDefEmitter.cpp - Generate lists of RISCV CPUs ---===//
+//
+// 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 tablegen backend emits the include file needed by the target
+// parser to parse the RISCV CPUs.
+//
+//===--===//
+
+#include "llvm/TableGen/Record.h"
+
+namespace llvm {
+void EmitRISCVTargetDef(RecordKeeper &RK, raw_ostream &OS) {
+  const auto &Map = RK.getDefs();
+
+  OS << "#ifndef PROC\n"
+ << "#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)\n"
+ << "#endif\n\n";
+
+  OS << "PROC(INVALID, {\"invalid\"}, FK_INVALID, {\"\"})\n";
+  // Iterate on all definition records.
+  for (auto &Def : Map) {
+const auto &Record = Def.second;
+if (Record->isSubClassOf("RISCVProcessorModelPROC") &&
+Record->isSubClassOf("ProcessorModel"))
+  OS << "PROC(" << Record->getValueAsString("Enum") << ", "
+ << "{\"" << Record->getValueAsString("Name") << "\"}, "
+ << Record->getValueAsString("EnumFeatures") << ", "
+ << "{\"" << Record->getValueAsString("DefaultMarch") << "\"})\n";
+  }
+  OS << "\n#undef PROC\n";
+  OS << "\n";
+  OS << "#ifndef TUNE_PROC\n"
+ << "#define TUNE_PROC(ENUM, NAME)\n"
+ << "#endif\n\n";
+  OS << "TUNE_PROC(GENERIC, \"generic\")\n";
+  for (auto &Def : Map) {
+const auto &Record = Def.seco

[clang] 108e41d - [clang][NFC] Use c++17 style variable type traits

2022-11-07 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2022-11-07T18:25:48Z
New Revision: 108e41d962463ea1cb956d1a929692a5b49c0a80

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

LOG: [clang][NFC] Use c++17 style variable type traits

This was done as a test for D137302 and it makes sense to push these changes

Reviewed By: shafik

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Comment.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/Interp/Disasm.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/Basic/SourceLocation.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/MacroArgs.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/Tooling/ASTDiff/ASTDiff.cpp
clang/unittests/Lex/HeaderMapTest.cpp
clang/unittests/Tooling/ASTSelectionTest.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index f07c40cb6c5d..52b361328ebc 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12280,16 +12280,14 @@ static Decl *getCommonDecl(Decl *X, Decl *Y) {
   llvm_unreachable("Corrupt redecls chain");
 }
 
-template ::value, bool> = true>
+template , bool> = true>
 T *getCommonDecl(T *X, T *Y) {
   return cast_or_null(
   getCommonDecl(const_cast(cast_or_null(X)),
 const_cast(cast_or_null(Y;
 }
 
-template ::value, bool> = true>
+template , bool> = true>
 T *getCommonDeclChecked(T *X, T *Y) {
   return cast(getCommonDecl(const_cast(cast(X)),
const_cast(cast(Y;

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 631dfaebabbd..88262268fc97 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -200,8 +200,8 @@ namespace clang {
 // cast the return value to `T`.
 template 
 auto import(T *From)
--> std::conditional_t::value,
-  Expected, Expected> {
+-> std::conditional_t, Expected,
+  Expected> {
   auto ToOrErr = Importer.Import(From);
   if (!ToOrErr)
 return ToOrErr.takeError();

diff  --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index eaa235bbe610..4cf3bb39c4e8 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -29,7 +29,7 @@ namespace comments {
 #undef ABSTRACT_COMMENT
 
 // DeclInfo is also allocated with a BumpPtrAllocator.
-static_assert(std::is_trivially_destructible::value,
+static_assert(std::is_trivially_destructible_v,
   "DeclInfo should be trivially destructible!");
 
 const char *Comment::getCommentKindName() const {

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 04808643ab84..1efe9c6d40dc 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -188,8 +188,7 @@ static bool usesTypeVisibility(const NamedDecl *D) {
 /// Does the given declaration have member specialization information,
 /// and if so, is it an explicit specialization?
 template 
-static std::enable_if_t::value,
-bool>
+static std::enable_if_t, bool>
 isExplicitMemberSpecialization(const T *D) {
   if (const MemberSpecializationInfo *member =
 D->getMemberSpecializationInfo()) {

diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index 82debe4fcae1..d31e879d516f 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -22,7 +22,7 @@ using namespace clang;
 using namespace clang::interp;
 
 template  inline T ReadArg(Program &P, CodePtr &OpPC) {
-  if constexpr (std::is_pointer::value) {
+  if constexpr (std::is_pointer_v) {
 uint32_t ID = OpPC.read();
 return reinterpret_cast(P.getNativePointer(ID));
   } else {

diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 20c6c68e44a0..458de974e46b 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -727,9 +727,9 @@ class CFGBuilder {
   // hence strict duck-typing.
   template ::value ||
-std::is_base_of::value ||
-std::is_base_of::value>>
+std::is_base_of_v ||
+std::is_base_of_v ||
+std::is_base_of_v>>
   void findConstructionContextsForArguments(CallLikeExpr *E) {
 for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
   Expr *Arg = E->getArg(i);

diff  --git a/clang/lib/Analysis/RetainSummaryManager.cpp 
b/clang/lib/Analysis/RetainSummaryManager.cpp
index 5e9c73534aeb..143c03

[PATCH] D137491: [clang][NFC] Use c++17 style variable type traits

2022-11-07 Thread Nathan James 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 rG108e41d96246: [clang][NFC] Use c++17 style variable type 
traits (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D137491?vs=473429&id=473739#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137491

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Comment.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Interp/Disasm.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/MacroArgs.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/Tooling/ASTDiff/ASTDiff.cpp
  clang/unittests/Lex/HeaderMapTest.cpp
  clang/unittests/Tooling/ASTSelectionTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -151,9 +151,8 @@
   // FIXME: mutate and observe no invalidation. Mutations are private for now...
   auto It = Range.begin();
   auto CIt = ConstRange.begin();
-  static_assert(std::is_same::value,
-"mutable range");
-  static_assert(std::is_same::value,
+  static_assert(std::is_same_v, "mutable range");
+  static_assert(std::is_same_v,
 "const range");
 
   for (unsigned I = 0; I < 3; ++I) {
Index: clang/unittests/Tooling/ASTSelectionTest.cpp
===
--- clang/unittests/Tooling/ASTSelectionTest.cpp
+++ clang/unittests/Tooling/ASTSelectionTest.cpp
@@ -101,22 +101,22 @@
 }
 
 template 
-const SelectedASTNode &checkNode(
-const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
-unsigned NumChildren = 0,
-std::enable_if_t::value, T> *StmtOverloadChecker =
-nullptr) {
+const SelectedASTNode &
+checkNode(const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
+  unsigned NumChildren = 0,
+  std::enable_if_t, T> *StmtOverloadChecker =
+  nullptr) {
   checkNodeImpl(isa(StmtNode.Node.get()), StmtNode, SelectionKind,
 NumChildren);
   return StmtNode;
 }
 
 template 
-const SelectedASTNode &checkNode(
-const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
-unsigned NumChildren = 0, StringRef Name = "",
-std::enable_if_t::value, T> *DeclOverloadChecker =
-nullptr) {
+const SelectedASTNode &
+checkNode(const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
+  unsigned NumChildren = 0, StringRef Name = "",
+  std::enable_if_t, T> *DeclOverloadChecker =
+  nullptr) {
   checkNodeImpl(isa(DeclNode.Node.get()), DeclNode, SelectionKind,
 NumChildren);
   if (!Name.empty())
Index: clang/unittests/Lex/HeaderMapTest.cpp
===
--- clang/unittests/Lex/HeaderMapTest.cpp
+++ clang/unittests/Lex/HeaderMapTest.cpp
@@ -115,8 +115,7 @@
 TEST(HeaderMapTest, lookupFilenameTruncatedSuffix) {
   typedef HMapFileMock<2, 64 - sizeof(HMapHeader) - 2 * sizeof(HMapBucket)>
   FileTy;
-  static_assert(std::is_standard_layout::value,
-"Expected standard layout");
+  static_assert(std::is_standard_layout_v, "Expected standard layout");
   static_assert(sizeof(FileTy) == 64, "check the math");
   PaddedFile P;
   auto &File = P.File;
@@ -151,8 +150,7 @@
 TEST(HeaderMapTest, lookupFilenameTruncatedPrefix) {
   typedef HMapFileMock<2, 64 - sizeof(HMapHeader) - 2 * sizeof(HMapBucket)>
   FileTy;
-  static_assert(std::is_standard_layout::value,
-"Expected standard layout");
+  static_assert(std::is_standard_layout_v, "Expected standard layout");
   static_assert(sizeof(FileTy) == 64, "check the math");
   PaddedFile P;
   auto &File = P.File;
Index: clang/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -117,13 +117,11 @@
   Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST);
   template 
   Impl(SyntaxTree *Parent,
-   std::enable_if_t::value, T> *Node,
-   ASTContext &AST)
+   std::enable_if_t, T> *Node, ASTContext &AST)
   : Impl(Parent, dyn_cast(Node), AST) {}
   template 
   Impl(SyntaxTree *Parent,
-   std::enable_if_t::value, T> *Node,
-   ASTContext &AST)
+   std::enable_if_t, T> *Node, ASTContext &AST)
   : Impl(Parent, dyn_cast(Node), AST) {}
 
   SyntaxTree *Parent;
Index: clang/lib/StaticAnalyzer/Core/Expr

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

2022-11-07 Thread Haowei Wu via Phabricator via cfe-commits
haowei added reviewers: bnbarham, keith.
haowei added a comment.

Please take a look.


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] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-11-07 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 473746.
ayzhao added a comment.

rebase + update commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CodeGen/P0960R3.cpp
  clang/test/SemaCXX/P0960R3.cpp

Index: clang/test/SemaCXX/P0960R3.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/P0960R3.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 3{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B { // expected-note 3{{candidate constructor}}
+  A a;
+  int b[20];
+  int &&c; // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 6{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public C, public A { // expected-note 6{{candidate constructor}}
+  int a;
+};
+
+void foo() {
+  A a(1954, 9, 21);
+  // expected-error@-1 {{no matching constructor for initialization of 'A'}}
+  A b(2.1);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A e(-1.2, 9.8);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A s = static_cast(1.1);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A h = (A)3.1;
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A i = A(8.7);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+
+  B n(2022, {7, 8});
+  // expected-error@-1 {{no matching constructor for initialization}}
+  B z(A(1), {}, 1);
+  // expected-error@-1 {{reference member 'c' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
+
+  C o(A(1), 1, 2, 3, 4);
+  // expected-error@-1 {{no matching constructor for initialization of 'C'}}
+  D R(1);
+  // expected-error@-1 {{no matching constructor for initialization}}
+  D I(C(1));
+  // expected-error@-1 {{no matching conversion for functional-style cast from 'int' to 'C'}}
+  D P(C(A(1)), 1);
+  // expected-error@-1 {{no matching constructor for initialization}}
+
+  int arr1[](0, 1, 2, A(1));
+  // expected-error@-1 {{no viable conversion from 'A' to 'int'}}
+  int arr2[2](0, 1, 2);
+  // expected-error@-1 {{excess elements in array initializer}}
+}
Index: clang/test/CodeGen/P0960R3.cpp
===
--- /dev/null
+++ clang/test/CodeGen/P0960R3.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o - | FileCheck %s
+
+struct A {
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b;
+};
+
+struct C : public B, public A {};
+
+// CHECK-LABEL:   entry:
+// CHECK-NEXT:[[A1:%.*]] = alloca [[STRUCT_A:%.*]], align 8
+// CHECK-NEXT:[[B1:%.*]] = alloca [[STRUCT_B:%.*]], align 8
+// CHECK-NEXT:[[C1:%.*]] = alloca [[STRUCT_C:%.*]], align 8
+// CHECK-NEXT:[[REF_TMP:%.*]] = alloca [[STRUCT_B]], align 8
+// CHECK-NEXT:[[REF_TMP5:%.*]] = alloca [[STRUCT_A]], align 8
+// CHECK-NEXT:[[I:%.*]] = getelementptr inbounds [[STRUCT_A]], ptr [[A1]], i32 0, i32 0
+// CHECK-NEXT:store i8 3, ptr [[I]], align 8
+// CHECK-NEXT:[[J:%.*]] = getelementptr inbounds [[STRUCT_A]], ptr [[A1]], i32 0, i32 1
+// CHECK-NEXT:store double 2.00e+00, ptr [[J]], align 8
+// CHECK-NEXT:[[A:%.*]] = getelementptr inbounds [[STRUCT_B]], ptr [[B1]], i32 0, i32 0
+// CHECK-NEXT:[[I1:%.*]] = getelementptr inbounds [[STRUCT_A]], ptr [[A]], i32 0, i32 0
+// CHECK-NEXT:store i8 99, ptr [[I1]], align 8
+// CHECK-NEXT:[[A2:%.*]] = getelementptr inbounds [[STRUCT_B]], ptr [[REF_TMP]], i32 0, i32 0
+// CHECK-NEXT:[[I3:%.*]] = getelementptr inbounds [[STRUCT_A]], ptr [[A2]], i32 0, i32 0
+// CHECK-NEXT:store i8 1, ptr [[I3]], align 8
+// CHECK-NEXT:[[J4:%.*]] = getelementptr inbounds [[STRUCT_A]], ptr [[A2]], i32 0, i32 1
+// CHECK-NEXT:store double 1.00e+00, ptr [[J4]], align 8
+// CHECK-NEXT:[[B:%.*]] = getelementptr inbounds [[STRUCT_B]], ptr [[REF_TMP]], i32 0, i32 1
+// CHECK-NEXT:store i32 1, ptr [[B]], align 8
+// CHECK-NEXT:c

[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-11-07 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

Friendly ping, does anyone else have any more comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D137475: Explicitly initialize opaque pointer mode in CodeGenAction

2022-11-07 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB updated this revision to Diff 473747.
MatzeB retitled this revision from "Explicitly initialize opaque pointer mode 
when -fthinlto-index is used" to "Explicitly initialize opaque pointer mode in 
CodeGenAction".
MatzeB edited the summary of this revision.
MatzeB added a comment.

address review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137475

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/Inputs/thinlto-opaque.ll
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  clang/test/CodeGen/thinlto-opaque-typed-mix.ll


Index: clang/test/CodeGen/thinlto-opaque-typed-mix.ll
===
--- /dev/null
+++ clang/test/CodeGen/thinlto-opaque-typed-mix.ll
@@ -0,0 +1,23 @@
+; REQUIRES: x86-registered-target
+; Test that mixing bitcode file with opaque and typed pointers works.
+
+; RUN: mkdir -p %t
+; RUN: opt -module-summary -o %t/typed.bc %s
+; RUN: opt -module-summary -o %t/opaque.bc %S/Inputs/thinlto-opaque.ll
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t/typed.bc %t/opaque.bc \
+; RUN:   -o %t/native.o -r %t/typed.bc,main,plx -r %t/typed.bc,f2, \
+; RUN:   -r %t/opaque.bc,f2,p
+
+; RUN: %clang_cc1 -triple x86_64-- -emit-obj -o %t/native.o %t/typed.bc \
+; RUN:   -Wno-override-module \
+; RUN:   -fthinlto-index=%t/typed.bc.thinlto.bc
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--"
+
+declare i8* @f2()
+
+define i32 @main() {
+  call i8* @f2()
+  ret i32 0
+}
Index: clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
===
--- clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -100,7 +100,7 @@
   ; CHECK-IR: br i1 {{.*}}, label %trap
 
   ; We still have to call it as virtual.
-  ; CHECK-IR: %call3 = tail call i32 %7
+  ; CHECK-IR: %call3 = tail call i32 {{%[0-9]+}}
   %call3 = tail call i32 %8(%struct.A* nonnull %obj, i32 %call)
   ret i32 %call3
 }
Index: clang/test/CodeGen/Inputs/thinlto-opaque.ll
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/thinlto-opaque.ll
@@ -0,0 +1,6 @@
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--"
+
+define ptr @f2() {
+  ret ptr null
+}
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1102,6 +1102,8 @@
   CompilerInstance &CI = getCompilerInstance();
   SourceManager &SM = CI.getSourceManager();
 
+  VMContext->setOpaquePointers(CI.getCodeGenOpts().OpaquePointers);
+
   // For ThinLTO backend invocations, ensure that the context
   // merges types based on ODR identifiers. We also need to read
   // the correct module out of a multi-module bitcode file.


Index: clang/test/CodeGen/thinlto-opaque-typed-mix.ll
===
--- /dev/null
+++ clang/test/CodeGen/thinlto-opaque-typed-mix.ll
@@ -0,0 +1,23 @@
+; REQUIRES: x86-registered-target
+; Test that mixing bitcode file with opaque and typed pointers works.
+
+; RUN: mkdir -p %t
+; RUN: opt -module-summary -o %t/typed.bc %s
+; RUN: opt -module-summary -o %t/opaque.bc %S/Inputs/thinlto-opaque.ll
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t/typed.bc %t/opaque.bc \
+; RUN:   -o %t/native.o -r %t/typed.bc,main,plx -r %t/typed.bc,f2, \
+; RUN:   -r %t/opaque.bc,f2,p
+
+; RUN: %clang_cc1 -triple x86_64-- -emit-obj -o %t/native.o %t/typed.bc \
+; RUN:   -Wno-override-module \
+; RUN:   -fthinlto-index=%t/typed.bc.thinlto.bc
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--"
+
+declare i8* @f2()
+
+define i32 @main() {
+  call i8* @f2()
+  ret i32 0
+}
Index: clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
===
--- clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -100,7 +100,7 @@
   ; CHECK-IR: br i1 {{.*}}, label %trap
 
   ; We still have to call it as virtual.
-  ; CHECK-IR: %call3 = tail call i32 %7
+  ; CHECK-IR: %call3 = tail call i32 {{%[0-9]+}}
   %call3 = tail call i32 %8(%struct.A* nonnull %obj, i32 %call)
   ret i32 %call3
 }
Index: clang/test/CodeGen/Inputs/thinlto-opaque.ll
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/thinlto-opaque.ll
@@ -0,0 +1,6 @@
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--"
+
+define ptr @f2() {
+  ret ptr null
+}
Index: clang/lib/Code

[PATCH] D137475: Explicitly initialize opaque pointer mode in CodeGenAction

2022-11-07 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137475

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


[PATCH] D136565: [clang] Instantiate alias templates with sugar

2022-11-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D136565#3911884 , @alexfh wrote:

> Hi Matheus, 279fe6281d2ca5b2318c7437316c28750feaac8d 
>  causes 
> compilation timeout on some of our internal files.

Hi @alexfh. It looks like somehow we may be creating a crazy amount of extra 
UsingTypes in your test scenario.

There is a clang flag that prints some performance statistics, including the 
amount of AST nodes created. I can't lookup the spelling as I am on vacations / 
on a cellphone for the next two weeks, but I believe this is documented.

One idea to get a reduction here is to perhaps tie your creduce interestingness 
test to that UsingType count.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136565

___
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-07 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: llvm/lib/TargetSupport/CMakeLists.txt:2
+
+set(LLVM_TARGET_DEFINITIONS ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
+

tmatheson wrote:
> Here `RISCVTargetSupportTableGen` depends on files in `lib/Target/RISCV`, 
> meaning the folder structure doesn't reflect the dependency graph and it 
> looks like a circular dependency. It would be cleaner to keep the 
> `TargetParser` data out of `lib/Target` in e.g. 
> `llvm/lib/TargetSupport/RISCVTargetInfo.td`. If it is needed in `RISCV.td` it 
> could be included from there.
The generator needs the field `Name` which is stored in the class 
`ProcessorModel`. Moving instances of `ProcessorModel` out of 
`lib/Target/RISCV/RISCV.td` seems quite a major change, not just a matter of 
including a file. I'll give it a go anyway and report back.


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


  1   2   >