[PATCH] D127614: [clang-format] Handle more cases for RemoveBracesLLVM

2022-06-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: curdeius, MyDeveloperDay, HazardyKnusperkeks.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Call mightFitOneOneline() on the line before the closing brace only if it is at 
the level of the block.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127614

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25784,6 +25784,25 @@
"}",
Style);
 
+  verifyFormat("if (a)\n"
+   "  b;\n"
+   "else if (c) {\n"
+   "  d;\n"
+   "  e;\n"
+   "} else\n"
+   "  f = g(foo, bar,\n"
+   "baz);",
+   "if (a)\n"
+   "  b;\n"
+   "else {\n"
+   "  if (c) {\n"
+   "d;\n"
+   "e;\n"
+   "  } else\n"
+   "f = g(foo, bar, baz);\n"
+   "}",
+   Style);
+
   Style.ColumnLimit = 0;
   verifyFormat("if (a)\n"
"  b234567890223456789032345678904234567890 = "
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -844,7 +844,7 @@
 
   size_t PPStartHash = computePPHash();
 
-  unsigned InitialLevel = Line->Level;
+  const unsigned InitialLevel = Line->Level;
   nextToken(/*LevelDifference=*/AddLevels);
 
   // Bail out if there are too many levels. Otherwise, the stack might 
overflow.
@@ -905,7 +905,8 @@
 return false;
 }
 assert(!CurrentLines->empty());
-if (!mightFitOnOneLine(CurrentLines->back()))
+auto &LastLine = CurrentLines->back();
+if (LastLine.Level == InitialLevel + 1 && !mightFitOnOneLine(LastLine))
   return false;
 if (Tok->is(TT_ElseLBrace))
   return true;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25784,6 +25784,25 @@
"}",
Style);
 
+  verifyFormat("if (a)\n"
+   "  b;\n"
+   "else if (c) {\n"
+   "  d;\n"
+   "  e;\n"
+   "} else\n"
+   "  f = g(foo, bar,\n"
+   "baz);",
+   "if (a)\n"
+   "  b;\n"
+   "else {\n"
+   "  if (c) {\n"
+   "d;\n"
+   "e;\n"
+   "  } else\n"
+   "f = g(foo, bar, baz);\n"
+   "}",
+   Style);
+
   Style.ColumnLimit = 0;
   verifyFormat("if (a)\n"
"  b234567890223456789032345678904234567890 = "
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -844,7 +844,7 @@
 
   size_t PPStartHash = computePPHash();
 
-  unsigned InitialLevel = Line->Level;
+  const unsigned InitialLevel = Line->Level;
   nextToken(/*LevelDifference=*/AddLevels);
 
   // Bail out if there are too many levels. Otherwise, the stack might overflow.
@@ -905,7 +905,8 @@
 return false;
 }
 assert(!CurrentLines->empty());
-if (!mightFitOnOneLine(CurrentLines->back()))
+auto &LastLine = CurrentLines->back();
+if (LastLine.Level == InitialLevel + 1 && !mightFitOnOneLine(LastLine))
   return false;
 if (Tok->is(TT_ElseLBrace))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays for stricter handling of flexible arrays

2022-06-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked 4 inline comments as done.
serge-sans-paille added inline comments.



Comment at: clang/test/CodeGen/object-size-flex-array.c:34
+  // CHECK: ret i32 %
+  // CHECK-STRICT: ret i32 %
+  return OBJECT_SIZE_BUILTIN(f->c, 1);

kees wrote:
> Shouldn't this explicitly return -1?
There's still the possibility that llvm folds that to an actual constant if it 
can track the allocation site (not the case for that particular function, but I 
think that's not for clang to decide that)


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

https://reviews.llvm.org/D126864

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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays for stricter handling of flexible arrays

2022-06-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.

Looks good on my side, waiting for feedback ;-)


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

https://reviews.llvm.org/D126864

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


[PATCH] D118996: [clang-tidy] Support C++14 in bugprone-signal-handler.

2022-06-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added a comment.

Ping
I have a question with Objective-C support.
@njames93 Could you look at this again?




Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:126
 const LangOptions &LangOpts) const {
-  // FIXME: Make the checker useful on C++ code.
-  if (LangOpts.CPlusPlus)
+  if (LangOpts.CPlusPlus17)
 return false;

balazske wrote:
> LegalizeAdulthood wrote:
> > njames93 wrote:
> > > Is this check valid on Objective-C code?
> > `return LangOpts.CPlusPlus17 == 0;`
> I do not know if the check is applicable to Objective-C, it may depend on if 
> the C standard (or POSIX) is applicable to Objective-C.
I could not find out if it is valid for Objective-C, probably not? But there 
are other checkers (for example in the `concurrency` module) that look POSIX or 
runtime-library specific and these do not contain check for ObjC language.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118996

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-13 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

I noticed that on one of our downstream (not public) buildbots the

  clang/test/Driver/femit-dwarf-unwind.s

test seems to fail rather randomly.
So if I run

  clang -target x86_64-apple-macos11.0 -c 
../clang/test/Driver/femit-dwarf-unwind.s -o foo.o
  llvm-objdump --macho --dwarf=frames foo.o

a couple of times I sometimes get

  .debug_frame contents:
  
  
  .eh_frame contents:

and sometimes I get

  .debug_frame contents:
  
  
  .eh_frame contents:
  
   0014  CIE
Format:DWARF32
Version:   1
Augmentation:  "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 10
  
DW_CFA_def_cfa: reg7 +8
DW_CFA_offset: reg16 -8
DW_CFA_nop:
DW_CFA_nop:
  
CFA=reg7+8: reg16=[CFA-8]
  
  0018 001c 001c FDE cie= pc=...0001
Format:   DWARF32
DW_CFA_def_cfa_offset: +8
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
  
0x0: CFA=reg7+8: reg16=[CFA-8]

On another machine I don't seem to get that problem though, even if I compile 
in the same way so I really don't know what the difference is or why it is 
happening at all.
Any ideas? Anything anyone else is seeing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-06-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Will continue looking at the implementation tomorrow, for now a few minor 
comments and a suggested variation on a testcase.




Comment at: clang-tools-extra/clangd/AST.h:19
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/NestedNameSpecifier.h"

nit: this include seems unnecessary given the code being added



Comment at: clang-tools-extra/clangd/AST.h:210
+
+/// Checks whether D is the expanded form of a parameter pack
+bool isExpandedParameterPack(const ParmVarDecl *D);

This function does something a bit more specific than what this description 
suggests: given a type parameter pack `typename... T`, it will return true for 
function parameters instantiated from a parameter pack of type `T...` or 
`T&...` or `T&&...`, but not `T*...` or `vector...` or anything else.

Suggested description:

```
/// Checks whether D is instantiated from a function parameter pack
/// whose type is a bare type parameter pack (e.g. `Args...`), or a 
/// reference to one (e.g. `Args&...` or `Args&&...`).
```



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:200
+  )cpp",
+   ExpectedHint{"&: ", "fwd"});
+}

As an aside, `&` does not seem like a useful hint to show for `std::forward` -- 
should we try to omit it? (We don't need to do it in this patch as it's not 
really related.)



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:467
+
+TEST(ParameterHints, VariadicVarargs) {
+  assertParameterHints(R"cpp(

I think a variation of this test case where `foo` is also variadic, would be 
valuable to add:

```
template 
void foo(int fixed, Args&&... args);

template 
void bar(Args&&... args) {
  foo(args...);
}

void baz() { 
  bar($fixed[[41]], 42, 43);
}
```

This case does seem to already work with the current patch, and I think it's 
the more common case; I'm happy to defer the varargs one as a less important 
edge case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

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


[PATCH] D111548: [Clang] Add the `annotate_type` attribute

2022-06-13 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

Is there anything else that needs to happen on this change before it's ready to 
land?

There is some breakage in the pre-merge checks, but it looks as if it's 
pre-existing breakage. See the comment-only change here that looks as if it 
exhibits similar breakage:

https://reviews.llvm.org/D127494




Comment at: clang/test/SemaCXX/annotate-type.cpp:2
+// RUN: %clang_cc1 %s -std=c++17 -fsyntax-only -verify
+
+struct S1 {

mboehme wrote:
> mboehme wrote:
> > mboehme wrote:
> > > rsmith wrote:
> > > > mboehme wrote:
> > > > > rsmith wrote:
> > > > > > mboehme wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > mboehme wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > mboehme wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > mboehme wrote:
> > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > mboehme wrote:
> > > > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > > > mboehme wrote:
> > > > > > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > > > > > Can you also add some test coverage for 
> > > > > > > > > > > > > > > > > > applying the attribute to a declaration 
> > > > > > > > > > > > > > > > > > instead of a type or not giving it any 
> > > > > > > > > > > > > > > > > > arguments? Also, should test arguments 
> > > > > > > > > > > > > > > > > > which are not a constant expression.
> > > > > > > > > > > > > > > > > I've added tests as you suggested, though I 
> > > > > > > > > > > > > > > > > put most of them in Sema/annotate-type.c, as 
> > > > > > > > > > > > > > > > > they're not specific to C++.
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > Thanks for prompting me to do this -- the 
> > > > > > > > > > > > > > > > > tests caused me to notice and fix a number of 
> > > > > > > > > > > > > > > > > bugs.
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > I haven't managed to diagnose the case when 
> > > > > > > > > > > > > > > > > the attribute appears at the beginning of the 
> > > > > > > > > > > > > > > > > declaration. It seems to me that, at the 
> > > > > > > > > > > > > > > > > point where I've added the check, this case 
> > > > > > > > > > > > > > > > > is indistinguishable from an attribute that 
> > > > > > > > > > > > > > > > > appears on the type. In both cases, the `TAL` 
> > > > > > > > > > > > > > > > > is `TAL_DeclSpec`, and the attribute is 
> > > > > > > > > > > > > > > > > contained in `DeclSpec::getAttributes()`. 
> > > > > > > > > > > > > > > > > This is because 
> > > > > > > > > > > > > > > > > `Parser::ParseSimpleDeclaration` forwards the 
> > > > > > > > > > > > > > > > > declaration attributes to the `DeclSpec`:
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDecl.cpp#L1851
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > I believe if I wanted to prohibit this case, 
> > > > > > > > > > > > > > > > > I would need to add a check to 
> > > > > > > > > > > > > > > > > `Parser::ParseStatementOrDeclaration` and 
> > > > > > > > > > > > > > > > > prohibit any occurrences of `annotate_type` 
> > > > > > > > > > > > > > > > > there. However, this seems the wrong place to 
> > > > > > > > > > > > > > > > > do this because it doesn't contain any 
> > > > > > > > > > > > > > > > > specific processing for other attributes.
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > I've noticed that Clang also doesn't prohibit 
> > > > > > > > > > > > > > > > > other type attributes (even ones with C++ 11 
> > > > > > > > > > > > > > > > > syntax) from being applied to declarations. 
> > > > > > > > > > > > > > > > > For example: https://godbolt.org/z/Yj1zWY7nn
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > How do you think I should proceed here? I 
> > > > > > > > > > > > > > > > > think the underlying issue is that Clang 
> > > > > > > > > > > > > > > > > doesn't always distinguish cleanly between 
> > > > > > > > > > > > > > > > > declaration attributes and type attributes, 
> > > > > > > > > > > > > > > > > and fixing this might be nontrivial.
> > > > > > > > > > > > > > > > > How do you think I should proceed here? I 
> > > > > > > > > > > > > > > > > think the underlying issue is that Clang 
> > > > > > > > > > > > > > > > > doesn't always distinguish cleanly between 
> > > > > > > > > > > > > > > > > declaration attributes and type attributes, 
> > > > > > > > > > > > > > > > > and fixing this might be nontrivial.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > This is a general issue with attribute 
> > > > > > > > > > > > > > > > processing. I would imagine that 
> > > > > > > > > > > > > > > > SemaDeclAttr.cpp should be able to diagnose 
> > > > > > > > > > > > > > > > that case when the attribute only applies to 
> > 

[PATCH] D126061: [clang] Reject non-declaration C++11 attributes on declarations

2022-06-13 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

@aaron.ballman Any further comments from you on this change?

There is some breakage in the pre-merge checks, but it looks as if it's 
pre-existing breakage. See the comment-only change here that looks as if it 
exhibits similar breakage:

https://reviews.llvm.org/D127494


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126061

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Markus Mützel via Phabricator via cfe-commits
mmuetzel added inline comments.



Comment at: flang/test/Driver/linker-flags-windows.f90:6
+! NOTE: The additional linker flags tested here are currently specified in
+! clang/lib/Driver/Toolchains/MSVC.cpp.
+! REQUIRES: windows-msvc

mmuetzel wrote:
> Since this test only applies to MSVC toolchains (not to MinGW), should the 
> file be renamed to, e.g., `linker-flags-msvc.f90`?
> 
> Should there be a similar test for MinGW? Which `REQUIRES` would that need?
> 
> Could maybe look like this (pending the correct `REQUIRES` line):
> ```
> ! Verify that the Fortran runtime libraries are present in the linker
> ! invocation. These libraries are added on top of other standard runtime
> ! libraries that the Clang driver will include.
> 
> ! NOTE: The additional linker flags tested here are currently specified in
> ! clang/lib/Driver/Toolchains/MinGW.cpp.
> ! REQUIRES: windows-mingw
> 
> !
> ! RUN COMMAND
> !
> ! RUN: %flang -### -flang-experimental-exec %S/Inputs/hello.f90 2>&1 | 
> FileCheck %s
> 
> !
> ! EXPECTED OUTPUT
> !
> ! Compiler invocation to generate the object file
> ! CHECK-LABEL: {{.*}} "-emit-obj"
> ! CHECK-SAME:  "-o" "[[object_file:.*]]" {{.*}}Inputs/hello.f90
> 
> ! Linker invocation to generate the executable
> ! CHECK-SAME: "[[object_file]]"
> ! CHECK-SAME: -lFortran_main
> ! CHECK-SAME: -lFortranRuntime
> ! CHECK-SAME: -lFortranDecimal
> ! CHECK-SAME: -lm
> ```
> 
I don't know how to edit or retract inline comments.
My previous comments to this file are no longer valid should we follow 
@mstorsjo's suggestion on running these tests on all platforms.


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

https://reviews.llvm.org/D126291

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

I had the same idea about switching the tests to using target triples instead 
of having separate files for it, but initially I had some issues getting that 
to work properly. When specifying a triple, we need to provide an architecture. 
Leaving the triple as `unkown-linux-gnu` or just `linux-gnu` gives us an error 
along the lines of `flang-new: error: unknown target triple 
'unknown-unknown-linux-gnu', please use -triple or -arch`. OTOH, hardcoding an 
architecture like x86 or aarch64 fails if we're not building that specific 
backend. We could do that and make the test REQUIRE the architecture that we're 
hardcoding, but this isn't really an architecture-specific test. So what I've 
finally done instead is to check for flang supported architectures and add a 
lit substitution for the first one that we find (be it aarch64, powerpc or x86) 
and use that in the test. We'll still get an error if someone tries to build 
the test without enabling any of these targets, but I think that's a good 
thing, since then people can decide either to add their architecture to lit or 
just, you know, not build flang on platforms where it isn't supported :) Patch 
incoming.


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

https://reviews.llvm.org/D126291

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka updated this revision to Diff 436300.
rovka added a comment.
Herald added a subscriber: ormris.

- Switch to the new style of testing (using triples rather than separate files)
- Fix oversight in Darwin toolchain file

I hope I've addressed all the comments and nothing slipped past during rebase. 
Thanks again for all the contributions :)


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

https://reviews.llvm.org/D126291

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  flang/test/Driver/linker-flags.f90
  flang/test/lit.cfg.py

Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -45,6 +45,17 @@
 for arch in config.targets_to_build.split():
 config.available_features.add(arch.lower() + '-registered-target')
 
+# Some driver tests need to use a supported and registered architecture as part
+# of the target triple, so we define a substitution for it. Note that it doesn't
+# matter which of the supported targets is used as long as it is enabled in
+# LLVM_TARGETS_TO_BUILD.
+if 'AArch64' in config.targets:
+config.substitutions.append(('%flangarch%', 'aarch64'))
+elif 'PowerPC' in config.targets:
+config.substitutions.append(('%flangarch%', 'ppc64le'))
+elif 'X86' in config.targets:
+config.substitutions.append(('%flangarch%', 'x86_64'))
+
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
 # directories.
Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -2,18 +2,15 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! NOTE: The additional linker flags tested here are currently only specified for
-! GNU and Darwin. The following line will make sure that this test is skipped on
-! Windows. If you are running this test on a yet another platform and it is
-! failing for you, please either update the following or (preferably) update the
-! linker invocation accordingly.
-! UNSUPPORTED: system-windows
-
-!
-! RUN COMMAND
-!
+!-
+! RUN COMMANDS
+!-
 ! Use `--ld-path` so that the linker location (used in the LABEL below) is deterministic.
-! RUN: %flang -### -flang-experimental-exec --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s
+! Note that `--ld-path` is ignored on some systems.
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-linux-gnu --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU,WITHLM
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-apple-darwin --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-windows-gnu --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-windows-msvc %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC
 
 !
 ! EXPECTED OUTPUT
@@ -22,10 +19,21 @@
 ! CHECK-LABEL: {{.*}} "-emit-obj"
 ! CHECK-SAME:  "-o" "[[object_file:.*\.o]]" {{.*}}Inputs/hello.f90
 
-! Linker invocation to generate the executable
-! CHECK-LABEL:  "/usr/bin/ld"
-! CHECK-SAME: "[[object_file]]"
-! CHECK-SAME: -lFortran_main
-! CHECK-SAME: -lFortranRuntime
-! CHECK-SAME: -lFortranDecimal
-! CHECK-SAME: -lm
+! Linker invocation to generate the executable - GNU version
+! GNU-LABEL:  "/usr/bin/ld"
+! GNU-SAME: "[[object_file]]"
+! GNU-SAME: -lFortran_main
+! GNU-SAME: -lFortranRuntime
+! GNU-SAME: -lFortranDecimal
+! WITHLM-SAME: -lm
+
+! Linker invocation to generate the executable - MSVC version
+! NOTE: This check should also match if the default linker is lld-link.exe
+! MSVC-LABEL: link.exe
+! MSVC-NOT: libcmt
+! MSVC-NOT: oldnames
+! MSVC-SAME: Fortran_main.lib
+! MSVC-SAME: FortranRuntime.lib
+! MSVC-SAME: FortranDecimal.lib
+! MSVC-SAME: /subsystem:console
+! MSVC-SAME: "[[object_file]]"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -218,6 +218,11 @@
 
   AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
 
+  if (C.getDriver().IsFlangMode()) {
+tools::addFortranRuntimeLibraryPath(TC, Args, CmdArgs);
+tools::addFortranRuntimeLibs(TC, CmdArgs);
+  }
+
   // TODO: Add profile stuff here
 
   if (TC.ShouldLinkCXXStdlib(Args)) {
Index: clang/lib/D

[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka updated this revision to Diff 436301.
rovka added a comment.

Missed a spot (removing the namespace in MinGW.cpp)


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

https://reviews.llvm.org/D126291

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  flang/test/Driver/linker-flags.f90
  flang/test/lit.cfg.py

Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -45,6 +45,17 @@
 for arch in config.targets_to_build.split():
 config.available_features.add(arch.lower() + '-registered-target')
 
+# Some driver tests need to use a supported and registered architecture as part
+# of the target triple, so we define a substitution for it. Note that it doesn't
+# matter which of the supported targets is used as long as it is enabled in
+# LLVM_TARGETS_TO_BUILD.
+if 'AArch64' in config.targets:
+config.substitutions.append(('%flangarch%', 'aarch64'))
+elif 'PowerPC' in config.targets:
+config.substitutions.append(('%flangarch%', 'ppc64le'))
+elif 'X86' in config.targets:
+config.substitutions.append(('%flangarch%', 'x86_64'))
+
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
 # directories.
Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -2,18 +2,15 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! NOTE: The additional linker flags tested here are currently only specified for
-! GNU and Darwin. The following line will make sure that this test is skipped on
-! Windows. If you are running this test on a yet another platform and it is
-! failing for you, please either update the following or (preferably) update the
-! linker invocation accordingly.
-! UNSUPPORTED: system-windows
-
-!
-! RUN COMMAND
-!
+!-
+! RUN COMMANDS
+!-
 ! Use `--ld-path` so that the linker location (used in the LABEL below) is deterministic.
-! RUN: %flang -### -flang-experimental-exec --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s
+! Note that `--ld-path` is ignored on some systems.
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-linux-gnu --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU,WITHLM
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-apple-darwin --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-windows-gnu --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -flang-experimental-exec -target %flangarch%-windows-msvc %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC
 
 !
 ! EXPECTED OUTPUT
@@ -22,10 +19,21 @@
 ! CHECK-LABEL: {{.*}} "-emit-obj"
 ! CHECK-SAME:  "-o" "[[object_file:.*\.o]]" {{.*}}Inputs/hello.f90
 
-! Linker invocation to generate the executable
-! CHECK-LABEL:  "/usr/bin/ld"
-! CHECK-SAME: "[[object_file]]"
-! CHECK-SAME: -lFortran_main
-! CHECK-SAME: -lFortranRuntime
-! CHECK-SAME: -lFortranDecimal
-! CHECK-SAME: -lm
+! Linker invocation to generate the executable - GNU version
+! GNU-LABEL:  "/usr/bin/ld"
+! GNU-SAME: "[[object_file]]"
+! GNU-SAME: -lFortran_main
+! GNU-SAME: -lFortranRuntime
+! GNU-SAME: -lFortranDecimal
+! WITHLM-SAME: -lm
+
+! Linker invocation to generate the executable - MSVC version
+! NOTE: This check should also match if the default linker is lld-link.exe
+! MSVC-LABEL: link.exe
+! MSVC-NOT: libcmt
+! MSVC-NOT: oldnames
+! MSVC-SAME: Fortran_main.lib
+! MSVC-SAME: FortranRuntime.lib
+! MSVC-SAME: FortranDecimal.lib
+! MSVC-SAME: /subsystem:console
+! MSVC-SAME: "[[object_file]]"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -218,6 +218,11 @@
 
   AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
 
+  if (C.getDriver().IsFlangMode()) {
+addFortranRuntimeLibraryPath(TC, Args, CmdArgs);
+addFortranRuntimeLibs(TC, CmdArgs);
+  }
+
   // TODO: Add profile stuff here
 
   if (TC.ShouldLinkCXXStdlib(Args)) {
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -81,7 +81,7 @@
 Args.MakeArgString(std::string("-out:"

[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D126291#3577133 , @rovka wrote:

> I had the same idea about switching the tests to using target triples instead 
> of having separate files for it, but initially I had some issues getting that 
> to work properly. When specifying a triple, we need to provide an 
> architecture. Leaving the triple as `unkown-linux-gnu` or just `linux-gnu` 
> gives us an error along the lines of `flang-new: error: unknown target triple 
> 'unknown-unknown-linux-gnu', please use -triple or -arch`. OTOH, hardcoding 
> an architecture like x86 or aarch64 fails if we're not building that specific 
> backend.

If you actually execute code generation, then yes, it fails if that specific 
arch isn't enabled. But for general compiler driver level tests, which just 
print out the command the would have executed (when running with `-###`), it 
should work without the actual code generation target being available. This is 
at least how it's done for clang's corresponding tests, most files in 
`clang/test/Driver` have hardcoded arch triples, without any REQUIRES lines or 
other exclusions.


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

https://reviews.llvm.org/D126291

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

In D126291#3572796 , @mmuetzel wrote:

> In D126291#3572777 , @rovka wrote:
>
>> Moved the check for `-flang-experimental-exec` into 
>> addFortranRuntimeLibraryPath, so it affects all the toolchains. @awarzynski 
>> does this look like a good idea?
>
> If moving that check to inside that function is ok, should the same check be 
> added to `addFortranRuntimeLibs`, too?
> Edit: And also retain that condition for any flags that are added in the 
> respective part of the toolchain files that don't use any of these two 
> functions?

I don't think we need to add it to the other function since we'll get an error 
anyway if the linker can't find the libraries. In any case, the right way to 
handle this is probably to error out in the driver before trying to compose a 
link job when `-flang-experimental-exec` is not specified, rather than rely on 
a specific linker error. But that should probably be a different patch. 
@awarzynski wdyt?


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

https://reviews.llvm.org/D126291

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


[PATCH] D127184: [clangd] Add to header map

2022-06-13 Thread Florian Albrechtskirchinger via Phabricator via cfe-commits
falbrechtskirchinger added a comment.

Here's the preliminary list of mappings I've identified:

  "bits/align.h", ""
  "bits/atomic_wait.h", ""
  "bits/atomic_timed_wait.h", ""
  "bits/boost_concept_check.h", ""
  "bits/charconv.h", ""
  "bits/chrono.h", ""
  "bits/cow_string.h", ""
  "bits/fs_dir.h", ""
  "bits/fs_fwd.h", ""
  "bits/fs_ops.h", ""
  "bits/fs_path.h", ""
  "bits/iterator_concepts.h", ""
  "bits/max_size_type.h", ""
  "bits/memory_resource.h", ""
  "bits/move_only_function.h", 
  "bits/ranges_algo.h", ""
  "bits/ranges_algobase.h", ""
  "bits/ranges_base.h", ""
  "bits/ranges_cmp.h", ""
  "bits/ranges_uninitialized.h", ""
  "bits/ranges_util.h", ""
  "bits/semaphore_base.h", ""
  "bits/std_thread.h", ""
  "bits/this_thread_sleep.h", ""
  "bits/uses_allocator_args.h", ""
  "bits/unique_lock.h", ""
  "bits/utility.h", ""

Furthermore, the following headers have no mapping:

  // Not clearly associated
  bits/c++0x_warning.h
  bits/enable_special_members.h
  bits/erase_if.h
  bits/node_handle.h
  
  // Not included anywhere
  bits/mofunc_impl.h
  bits/new_allocator.h
  bits/specfun.h

The search was limited to `bits/*.h` in GCC trunk.
I'll push a new revision after I have a chance to review the list a second time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127184

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


[PATCH] D125094: [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

2022-06-13 Thread Lucas Prates 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 rG6119053dab67: [ARM][Thumb] Command-line option to ensure 
AAPCS compliant Frame Records (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125094

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMFrameLowering.cpp
  llvm/lib/Target/ARM/ARMFrameLowering.h
  llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
  llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
  llvm/test/CodeGen/ARM/frame-chain-reserved-fp.ll
  llvm/test/CodeGen/ARM/frame-chain.ll
  llvm/test/CodeGen/Thumb/frame-access.ll
  llvm/test/CodeGen/Thumb/frame-chain-reserved-fp.ll
  llvm/test/CodeGen/Thumb/frame-chain.ll

Index: llvm/test/CodeGen/Thumb/frame-chain.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb/frame-chain.ll
@@ -0,0 +1,288 @@
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all | FileCheck %s --check-prefixes=FP,LEAF-FP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP-AAPCS
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf | FileCheck %s --check-prefixes=FP,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP-AAPCS
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none | FileCheck %s --check-prefixes=NOFP,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP-AAPCS
+
+define dso_local noundef i32 @leaf(i32 noundef %0) {
+; LEAF-FP-LABEL: leaf:
+; LEAF-FP:   @ %bb.0:
+; LEAF-FP-NEXT:.pad #4
+; LEAF-FP-NEXT:sub sp, #4
+; LEAF-FP-NEXT:str r0, [sp]
+; LEAF-FP-NEXT:adds r0, r0, #4
+; LEAF-FP-NEXT:add sp, #4
+; LEAF-FP-NEXT:bx lr
+;
+; LEAF-FP-AAPCS-LABEL: leaf:
+; LEAF-FP-AAPCS:   @ %bb.0:
+; LEAF-FP-AAPCS-NEXT:.save {lr}
+; LEAF-FP-AAPCS-NEXT:push {lr}
+; LEAF-FP-AAPCS-NEXT:mov lr, r11
+; LEAF-FP-AAPCS-NEXT:.save {r11}
+; LEAF-FP-AAPCS-NEXT:push {lr}
+; LEAF-FP-AAPCS-NEXT:.setfp r11, sp
+; LEAF-FP-AAPCS-NEXT:mov r11, sp
+; LEAF-FP-AAPCS-NEXT:.pad #4
+; LEAF-FP-AAPCS-NEXT:sub sp, #4
+; LEAF-FP-AAPCS-NEXT:str r0, [sp]
+; LEAF-FP-AAPCS-NEXT:adds r0, r0, #4
+; LEAF-FP-AAPCS-NEXT:add sp, #4
+; LEAF-FP-AAPCS-NEXT:pop {r1}
+; LEAF-FP-AAPCS-NEXT:mov r11, r1
+; LEAF-FP-AAPCS-NEXT:pop {r1}
+; LEAF-FP-AAPCS-NEXT:bx r1
+;
+; LEAF-NOFP-LABEL: leaf:
+; LEAF-NOFP:   @ %bb.0:
+; LEAF-NOFP-NEXT:.pad #4
+; LEAF-NOFP-NEXT:sub sp, #4
+; LEAF-NOFP-NEXT:str r0, [sp]
+; LEAF-NOFP-NEXT:adds r0, r0, #4
+; LEAF-NOFP-NEXT:add sp, #4
+; LEAF-NOFP-NEXT:bx lr
+;
+; LEAF-NOFP-AAPCS-LABEL: leaf:
+; LEAF-NOFP-AAPCS:   @ %bb.0:
+; LEAF-NOFP-AAPCS-NEXT:.pad #4
+; LEAF-NOFP-AAPCS-NEXT:sub sp, #4
+; LEAF-NOFP-AAPCS-NEXT:str r0, [sp]
+; LEAF-NOFP-AAPCS-NEXT:adds r0, r0, #4
+; LEAF-NOFP-AAPCS-NEXT:add sp, #4
+; LEAF-NOFP-AAPCS-NEXT:bx lr
+  %2 = alloca i32, align 4
+  store i32 %0, i32* %2, align 4
+  %3 = load i32, i32* %2, align 4
+  %4 = add nsw i32 %3, 4
+  ret i32 %4
+}
+
+define dso_local noundef i32 @non_leaf(i32 noundef %0) {
+; FP-LABEL: non_leaf:
+; FP:   @ %bb.0:
+; FP-NEXT:.save {r7, lr}
+; FP-NEXT:push {r7, lr}
+; FP-NEXT:.setfp r7, sp
+; FP-NEXT:add r7, sp, #0
+; FP-NEXT:.pad #8
+; FP-NEXT:sub sp, #8
+; FP-NEXT:str r0, [sp, #4]
+; FP-NEXT:bl leaf
+; FP-NEXT:adds r0, r0, #1
+; FP-NEXT:add sp, #8
+; FP-NEXT:pop {r7}
+; FP-NEXT:pop {r1}
+; FP-NEXT:bx r1
+;
+; FP-AAPCS-LABEL: non_leaf:
+; FP-AAPCS:   @ %bb.0:
+; FP-AAPCS-NEXT:.save {lr}
+; FP-AAPCS-NEXT:push {lr}
+; FP-AAPCS-NEXT:mov lr, r11
+; FP-AAPCS-NEXT:.save {r11}
+; FP-AAPCS-NEXT:push {lr}
+; FP-AAP

[clang] 6119053 - [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

2022-06-13 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2022-06-13T10:21:06+01:00
New Revision: 6119053dab67129eb1700dbf36db3524dd3e421f

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

LOG: [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

Currently the a AAPCS compliant frame record is not always created for
functions when it should. Although a consistent frame record might not
be required in some cases, there are still scenarios where applications
may want to make use of the call hierarchy made available trough it.

In order to enable the use of AAPCS compliant frame records whilst keep
backwards compatibility, this patch introduces a new command-line option
(`-mframe-chain=[none|aapcs|aapcs+leaf]`) for Aarch32 and Thumb backends.
The option allows users to explicitly select when to use it, and is also
useful to ensure the extra overhead introduced by the frame records is
only introduced when necessary, in particular for Thumb targets.

Reviewed By: efriedma

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

Added: 
llvm/test/CodeGen/ARM/frame-chain-reserved-fp.ll
llvm/test/CodeGen/ARM/frame-chain.ll
llvm/test/CodeGen/Thumb/frame-chain-reserved-fp.ll
llvm/test/CodeGen/Thumb/frame-chain.ll

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/ARM.cpp
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
llvm/lib/Target/ARM/ARMCallingConv.td
llvm/lib/Target/ARM/ARMFrameLowering.cpp
llvm/lib/Target/ARM/ARMFrameLowering.h
llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
llvm/test/CodeGen/Thumb/frame-access.ll

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 002cd6cc8cb17..a311781181561 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3467,7 +3467,9 @@ defm aapcs_bitfield_width : BoolOption<"f", 
"aapcs-bitfield-width",
   BothFlags<[NoXarchOption, CC1Option], " the AAPCS standard requirement 
stating that"
 " volatile bit-field width is dictated by the field container 
type. (ARM only).">>,
   Group;
-
+def mframe_chain : Joined<["-"], "mframe-chain=">,
+  Group, Values<"none,aapcs,aapcs+leaf">,
+  HelpText<"Select the frame chain model used to emit frame records (Arm 
only).">;
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group,
   HelpText<"Generate code which only uses the general purpose registers 
(AArch64/x86 only)">;
 def mfix_cmse_cve_2021_35465 : Flag<["-"], "mfix-cmse-cve-2021-35465">,

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index dc6b35e39cfdd..b79d1f00ea48b 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -718,6 +718,15 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 }
   }
 
+  // Propagate frame-chain model selection
+  if (Arg *A = Args.getLastArg(options::OPT_mframe_chain)) {
+StringRef FrameChainOption = A->getValue();
+if (FrameChainOption.startswith("aapcs"))
+  Features.push_back("+aapcs-frame-chain");
+if (FrameChainOption == "aapcs+leaf")
+  Features.push_back("+aapcs-frame-chain-leaf");
+  }
+
   // CMSE: Check for target 8M (for -mcmse to be applicable) is performed 
later.
   if (Args.getLastArg(options::OPT_mcmse))
 Features.push_back("+8msecext");

diff  --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td
index e8970b916a5f0..48559a89a30a0 100644
--- a/llvm/lib/Target/ARM/ARM.td
+++ b/llvm/lib/Target/ARM/ARM.td
@@ -546,6 +546,16 @@ def FeatureFixCortexA57AES1742098 : 
SubtargetFeature<"fix-cortex-a57-aes-1742098
   "FixCortexA57AES1742098", "true",
   "Work around Cortex-A57 Erratum 1742098 / Cortex-A72 Erratum 1655431 (AES)">;
 
+def FeatureAAPCSFrameChain : SubtargetFeature<"aapcs-frame-chain",
+  "CreateAAPCSFrameChain", "true",
+  "Create an AAPCS compliant frame 
chain">;
+
+def FeatureAAPCSFrameChainLeaf : SubtargetFeature<"aapcs-frame-chain-leaf",
+  "CreateAAPCSFrameChainLeaf", 
"true",
+  "Create an AAPCS compliant 
frame chain "
+  "for leaf functions",
+  [FeatureAAPCSFrameChain]>;
+
 
//===--===//
 // ARM architecture class
 //

diff  --git a/llvm/lib/Targe

[PATCH] D127624: [C++20][Modules] Allow for redeclarations in partitions.

2022-06-13 Thread Iain Sandoe via Phabricator via cfe-commits
iains created this revision.
Herald added a project: All.
iains added reviewers: urnathan, ChuanqiXu.
iains published this revision for review.
iains added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

this is really a bug fix, rather than a new feature - the current impl was not 
general enough.


The existing provision is not sufficient, it did not allow for the cases
where an implementation partition includes the primary module interface,
or for the case that an exported interface partition is contains a decl
that is then implemented in a regular implementation unit.

It is somewhat unfortunate that we have to compare top level module names
to achieve this, since built modules are not necessarily available.

TODO: It might be useful to cache a hash of the primary module name if
this test proves to be a  significant load.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127624

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Modules/cxx20-partition-redeclarations.cpp


Index: clang/test/Modules/cxx20-partition-redeclarations.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-partition-redeclarations.cpp
@@ -0,0 +1,55 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 A-intf-part.cpp -emit-module-interface \
+// RUN:  -o A-PubPart.pcm
+// RUN: %clang_cc1 -std=c++20 A-interface.cpp -emit-module-interface \
+// RUN:   -fmodule-file=A-PubPart.pcm -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fmodule-file=A.pcm
+
+//--- A-interface.cpp
+export module A;
+
+export import :PubPart;
+
+export void do_something();
+
+void helper1();
+void helper3();
+
+//--- A-intf-part.cpp
+export module A:PubPart;
+
+void helper2();
+
+//--- A-impl-top.cpp
+
+module A;
+
+void do_something() {
+  helper1();
+  helper2();
+  helper3();
+}
+
+//--- A-impl-part.cpp
+module A:Secret;
+
+import A;
+
+void helper3() {}
+
+//--- A-impl-1.cpp
+module A;
+
+void helper1() {}
+
+//--- A-impl-2.cpp
+module A;
+
+void helper2() {}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1625,22 +1625,20 @@
   Module *NewM = New->getOwningModule();
   Module *OldM = Old->getOwningModule();
 
-  if (NewM && NewM->Kind == Module::PrivateModuleFragment)
+  if (NewM && NewM->isPrivateModule())
 NewM = NewM->Parent;
-  if (OldM && OldM->Kind == Module::PrivateModuleFragment)
+  if (OldM && OldM->isPrivateModule())
 OldM = OldM->Parent;
 
-  // If we have a decl in a module partition, it is part of the containing
-  // module (which is the only thing that can be importing it).
-  if (NewM && OldM &&
-  (OldM->Kind == Module::ModulePartitionInterface ||
-   OldM->Kind == Module::ModulePartitionImplementation)) {
-return false;
-  }
-
   if (NewM == OldM)
 return false;
 
+  // Partitions are part of the module, but a partition could import another
+  // module, so verify that the PMIs agree.
+  if (NewM && OldM && (NewM->isModulePartition() || OldM->isModulePartition()))
+return NewM->getPrimaryModuleInterfaceName() ==
+   OldM->getPrimaryModuleInterfaceName();
+
   bool NewIsModuleInterface = NewM && NewM->isModulePurview();
   bool OldIsModuleInterface = OldM && OldM->isModulePurview();
   if (NewIsModuleInterface || OldIsModuleInterface) {


Index: clang/test/Modules/cxx20-partition-redeclarations.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-partition-redeclarations.cpp
@@ -0,0 +1,55 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 A-intf-part.cpp -emit-module-interface \
+// RUN:  -o A-PubPart.pcm
+// RUN: %clang_cc1 -std=c++20 A-interface.cpp -emit-module-interface \
+// RUN:   -fmodule-file=A-PubPart.pcm -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fmodule-file=A.pcm
+
+//--- A-interface.cpp
+export module A;
+
+export import :PubPart;
+
+export void do_something();
+
+void helper1();
+void helper3();
+
+//--- A-intf-part.cpp
+export module A:PubPart;
+
+void helper2();
+
+//--- A-impl-top.cpp
+
+module A;
+
+void do_something() {
+  helper1();
+  helper2();
+  helper3();
+}
+
+//--- A-impl-part.cpp
+module A:Secret;
+
+import A;
+
+void helper3() {}
+
+//--- A-impl-1.cpp
+module A;
+
+void helper1()

[clang] 33b9ad6 - Revert "[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records"

2022-06-13 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2022-06-13T11:00:49+01:00
New Revision: 33b9ad647e9142c8e48f51c3067bf2340b8416c3

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

LOG: Revert "[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame 
Records"

Reverting change due to test failure.

This reverts commit 6119053dab67129eb1700dbf36db3524dd3e421f.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/ARM.cpp
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
llvm/lib/Target/ARM/ARMCallingConv.td
llvm/lib/Target/ARM/ARMFrameLowering.cpp
llvm/lib/Target/ARM/ARMFrameLowering.h
llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
llvm/test/CodeGen/Thumb/frame-access.ll

Removed: 
llvm/test/CodeGen/ARM/frame-chain-reserved-fp.ll
llvm/test/CodeGen/ARM/frame-chain.ll
llvm/test/CodeGen/Thumb/frame-chain-reserved-fp.ll
llvm/test/CodeGen/Thumb/frame-chain.ll



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a311781181561..002cd6cc8cb17 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3467,9 +3467,7 @@ defm aapcs_bitfield_width : BoolOption<"f", 
"aapcs-bitfield-width",
   BothFlags<[NoXarchOption, CC1Option], " the AAPCS standard requirement 
stating that"
 " volatile bit-field width is dictated by the field container 
type. (ARM only).">>,
   Group;
-def mframe_chain : Joined<["-"], "mframe-chain=">,
-  Group, Values<"none,aapcs,aapcs+leaf">,
-  HelpText<"Select the frame chain model used to emit frame records (Arm 
only).">;
+
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group,
   HelpText<"Generate code which only uses the general purpose registers 
(AArch64/x86 only)">;
 def mfix_cmse_cve_2021_35465 : Flag<["-"], "mfix-cmse-cve-2021-35465">,

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index b79d1f00ea48b..dc6b35e39cfdd 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -718,15 +718,6 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 }
   }
 
-  // Propagate frame-chain model selection
-  if (Arg *A = Args.getLastArg(options::OPT_mframe_chain)) {
-StringRef FrameChainOption = A->getValue();
-if (FrameChainOption.startswith("aapcs"))
-  Features.push_back("+aapcs-frame-chain");
-if (FrameChainOption == "aapcs+leaf")
-  Features.push_back("+aapcs-frame-chain-leaf");
-  }
-
   // CMSE: Check for target 8M (for -mcmse to be applicable) is performed 
later.
   if (Args.getLastArg(options::OPT_mcmse))
 Features.push_back("+8msecext");

diff  --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td
index 48559a89a30a0..e8970b916a5f0 100644
--- a/llvm/lib/Target/ARM/ARM.td
+++ b/llvm/lib/Target/ARM/ARM.td
@@ -546,16 +546,6 @@ def FeatureFixCortexA57AES1742098 : 
SubtargetFeature<"fix-cortex-a57-aes-1742098
   "FixCortexA57AES1742098", "true",
   "Work around Cortex-A57 Erratum 1742098 / Cortex-A72 Erratum 1655431 (AES)">;
 
-def FeatureAAPCSFrameChain : SubtargetFeature<"aapcs-frame-chain",
-  "CreateAAPCSFrameChain", "true",
-  "Create an AAPCS compliant frame 
chain">;
-
-def FeatureAAPCSFrameChainLeaf : SubtargetFeature<"aapcs-frame-chain-leaf",
-  "CreateAAPCSFrameChainLeaf", 
"true",
-  "Create an AAPCS compliant 
frame chain "
-  "for leaf functions",
-  [FeatureAAPCSFrameChain]>;
-
 
//===--===//
 // ARM architecture class
 //

diff  --git a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp 
b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
index 1d0e743b94dbf..cae72e465c7bf 100644
--- a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
@@ -63,8 +63,12 @@ const MCPhysReg*
 ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
   const ARMSubtarget &STI = MF->getSubtarget();
   bool UseSplitPush = STI.splitFramePushPop(*MF);
-  const Function &F = MF->getFunction();
+  const MCPhysReg *RegList =
+  STI.isTargetDarwin()
+  ? CSR_iOS_SaveList
+  : (UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList);
 
+  const Function &F = MF->getFunctio

[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

In D126291#3577159 , @mstorsjo wrote:

> In D126291#3577133 , @rovka wrote:
>
>> I had the same idea about switching the tests to using target triples 
>> instead of having separate files for it, but initially I had some issues 
>> getting that to work properly. When specifying a triple, we need to provide 
>> an architecture. Leaving the triple as `unkown-linux-gnu` or just 
>> `linux-gnu` gives us an error along the lines of `flang-new: error: unknown 
>> target triple 'unknown-unknown-linux-gnu', please use -triple or -arch`. 
>> OTOH, hardcoding an architecture like x86 or aarch64 fails if we're not 
>> building that specific backend.
>
> If you actually execute code generation, then yes, it fails if that specific 
> arch isn't enabled. But for general compiler driver level tests, which just 
> print out the command the would have executed (when running with `-###`), it 
> should work without the actual code generation target being available. This 
> is at least how it's done for clang's corresponding tests, most files in 
> `clang/test/Driver` have hardcoded arch triples, without any REQUIRES lines 
> or other exclusions.

Oops, you're right, I was testing with a wrong x86 triple >.< I'll simplify the 
patch then.


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

https://reviews.llvm.org/D126291

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D126291#3577133 , @rovka wrote:

> I had the same idea about switching the tests to using target triples instead 
> of having separate files for it, but initially I had some issues getting that 
> to work properly.

Could you give it another go? I agree with @mstorsjo that ... it should just 
work when using `-###` :)

In D126291#3577160 , @rovka wrote:

> In D126291#3572796 , @mmuetzel 
> wrote:
>
>> In D126291#3572777 , @rovka wrote:
>>
>>> Moved the check for `-flang-experimental-exec` into 
>>> addFortranRuntimeLibraryPath, so it affects all the toolchains. @awarzynski 
>>> does this look like a good idea?
>>
>> If moving that check to inside that function is ok, should the same check be 
>> added to `addFortranRuntimeLibs`, too?
>> Edit: And also retain that condition for any flags that are added in the 
>> respective part of the toolchain files that don't use any of these two 
>> functions?
>
> I don't think we need to add it to the other function since we'll get an 
> error anyway if the linker can't find the libraries. In any case, the right 
> way to handle this is probably to error out in the driver before trying to 
> compose a link job when `-flang-experimental-exec` is not specified, rather 
> than rely on a specific linker error. But that should probably be a different 
> patch. @awarzynski wdyt?

IMHO, `addFortranRuntimeLibraryPath` should be adding Fortran runtime library 
path unconditionally (as the name suggests). Similarly, `addFortranRuntimeLibs` 
should be adding Fortran library libs unconditionally. But unfortunately, we 
need to deal with `-flang-experimental-exec` (I really wish we didn't). What 
you are suggesting here makes a lot of sense to me, but it is also worth 
keeping in mind that this flag is here only temporarily ;-) So, I'd mostly 
focus on making sure that removing it is easy (and that everything else is rock 
solid). We do need `Args.hasArg(options::OPT_flang_experimental_exec)` there 
somewhere - I'll be happy with whatever you decide!


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

https://reviews.llvm.org/D126291

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

🤔 linker-flags.f90 is failing on Windows in the pre-commit CI. Not sure why - 
seems fine on Debian.




Comment at: flang/test/Driver/linker-flags.f90:28
+! GNU-SAME: -lFortranDecimal
+! WITHLM-SAME: -lm
+

Does `-SAME` makese sense here? As in, this makes sense to me:
```
! GNU: -lFortranDecimal
! GNU-SAME: -lm
```
and this:
```
! WITHLM: -lFortranDecimal
! WITHLM-SAME: -lm
```
but for `! WITHLM-SAME: -lm` there's no [[ 
https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-same-directive | 
previous match ]], is there?



Comment at: flang/test/Driver/linker-flags.f90:33-34
+! MSVC-LABEL: link.exe
+! MSVC-NOT: libcmt
+! MSVC-NOT: oldnames
+! MSVC-SAME: Fortran_main.lib

Is it worth adding a comment to explain why to single these out?


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

https://reviews.llvm.org/D126291

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


[clang] b4f2f7b - [clang][AArch64][SVE] Implicit conversions for vector-scalar operations

2022-06-13 Thread David Truby via cfe-commits

Author: David Truby
Date: 2022-06-13T10:22:10Z
New Revision: b4f2f7bebd29f7cedd3ce93c1925e8029b8e2b05

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

LOG: [clang][AArch64][SVE] Implicit conversions for vector-scalar operations

This patch allows the same implicit conversions for vector-scalar
operations in SVE that are allowed for NEON.

Depends on D126377

Reviewed By: c-rhodes

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/aarch64-sve-vector-arith-ops.c
clang/test/Sema/aarch64-sve-vector-arith-ops.c
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 57a034d3c61e9..9cb031b87f3a8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -13574,6 +13574,29 @@ static void CheckImplicitConversion(Sema &S, Expr *E, 
QualType T,
   const BuiltinType *SourceBT = dyn_cast(Source);
   const BuiltinType *TargetBT = dyn_cast(Target);
 
+  // Strip SVE vector types
+  if (SourceBT && SourceBT->isVLSTBuiltinType()) {
+// Need the original target type for vector type checks
+const Type *OriginalTarget = S.Context.getCanonicalType(T).getTypePtr();
+// Handle conversion from scalable to fixed when msve-vector-bits is
+// specified
+if (S.Context.areCompatibleSveTypes(QualType(OriginalTarget, 0),
+QualType(Source, 0)) ||
+S.Context.areLaxCompatibleSveTypes(QualType(OriginalTarget, 0),
+   QualType(Source, 0)))
+  return;
+
+// If the vector cast is cast between two vectors of the same size, it is
+// a bitcast, not a conversion.
+if (S.Context.getTypeSize(Source) == S.Context.getTypeSize(Target))
+  return;
+
+Source = SourceBT->getSveEltType(S.Context).getTypePtr();
+  }
+
+  if (TargetBT && TargetBT->isVLSTBuiltinType())
+Target = TargetBT->getSveEltType(S.Context).getTypePtr();
+
   // If the source is floating point...
   if (SourceBT && SourceBT->isFloatingPoint()) {
 // ...and the target is floating point...

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e44172c399639..7e6618bd2d11d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10261,12 +10261,18 @@ static bool tryGCCVectorConvertAndSplat(Sema &S, 
ExprResult *Scalar,
 ExprResult *Vector) {
   QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
   QualType VectorTy = Vector->get()->getType().getUnqualifiedType();
-  const auto *VT = VectorTy->castAs();
-
-  assert(!isa(VT) &&
- "ExtVectorTypes should not be handled here!");
-
-  QualType VectorEltTy = VT->getElementType();
+  QualType VectorEltTy;
+
+  if (const auto *VT = VectorTy->getAs()) {
+assert(!isa(VT) &&
+   "ExtVectorTypes should not be handled here!");
+VectorEltTy = VT->getElementType();
+  } else if (VectorTy->isVLSTBuiltinType()) {
+VectorEltTy =
+VectorTy->castAs()->getSveEltType(S.getASTContext());
+  } else {
+llvm_unreachable("Only Fixed-Length and SVE Vector types are handled 
here");
+  }
 
   // Reject cases where the vector element type or the scalar element type are
   // not integral or floating point types.
@@ -10593,24 +10599,14 @@ QualType Sema::CheckSizelessVectorOperands(ExprResult 
&LHS, ExprResult &RHS,
   if (Context.hasSameType(LHSType, RHSType))
 return LHSType;
 
-  auto tryScalableVectorConvert = [this](ExprResult *Src, QualType SrcType,
- QualType DestType) {
-const QualType DestBaseType = DestType->getSveEltType(Context);
-if (DestBaseType->getUnqualifiedDesugaredType() ==
-SrcType->getUnqualifiedDesugaredType()) {
-  unsigned DiagID = diag::err_typecheck_invalid_operands;
-  if (!tryVectorConvertAndSplat(*this, Src, SrcType, DestBaseType, 
DestType,
-DiagID))
-return DestType;
-}
-return QualType();
-  };
-
   if (LHSType->isVLSTBuiltinType() && !RHSType->isVLSTBuiltinType()) {
-auto DestType = tryScalableVectorConvert(&RHS, RHSType, LHSType);
-if (DestType == QualType())
-  return InvalidOperands(Loc, LHS, RHS);
-return DestType;
+if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS))
+  return LHSType;
+  }
+  if (RHSType->isVLSTBuiltinType() && !LHSType->isVLSTBuiltinType()) {
+if (LHS.get()->isLValue() ||
+!tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
+  return RHSType;
   }
 
   if ((!LHSType->isVLSTBuiltinType() && !LHSTyp

[PATCH] D126380: [clang][AArch64][SVE] Implicit conversions for vector-scalar operations

2022-06-13 Thread David Truby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4f2f7bebd29: [clang][AArch64][SVE] Implicit conversions for 
vector-scalar operations (authored by DavidTruby).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126380

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/aarch64-sve-vector-arith-ops.c
  clang/test/Sema/aarch64-sve-vector-arith-ops.c
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -213,23 +213,6 @@
   local_int8 &&init_int8;  // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
   local_int8 || init_int8; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
 
-  local_int8 + 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 - 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 * 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 / 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 % 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 & 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 | 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 ^ 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 < 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 <= 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 == 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 != 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 >= 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 > 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 && 0; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
-  local_int8 || 0; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
-
   if (local_int8) { // expected-error {{not contextually convertible to 'bool'}}
   }
   while (local_int8) { // expected-error {{not contextually convertible to 'bool'}}
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -201,23 +201,6 @@
   local_int8 &&init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 || init_int8; // expected-error {{invalid operands to binary expression}}
 
-  local_int8 + 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 - 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 * 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 / 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 % 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 & 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 | 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 ^ 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 < 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 <= 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 == 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 != 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 >= 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 > 0;  // expected-error {{invalid operands to binary expression}}
-  local_int8 && 0; // expected-error {{invalid operands to binary expression}}
-  local_int8 || 0; // expected-error {{invalid operands to binary expression}}
-
   if (local_int8) { // expected-error {{statement requires expression of scalar type}}
   }
   while (local_int8) { // expected-error {{statement requires expression of scalar type}}
Index: clang/test/Sema/aarch64-sve-vector-arith-ops.c
===
--- clang/test/Sema/aarch64-sve-vector-arith-ops.c
+++ clang/test/Sema/aarch64-sve-vector-arith-ops.c
@@ -701,3 +701,11 @@
   (void)(s % f16); // expected-error{{invalid operands to binary expression}}
   (void)(s % f32); // expected-error{{invalid operands to binary expression}}
 }
+
+svint8_t svi8(svint8_t a) {
+  return a + 256; // expected-error{{cannot convert between scalar type 'int' and vector type 'svint8_t' (aka

[PATCH] D127629: [clang] Use correct visibility parameters when following a Using declaration

2022-06-13 Thread Furkan via Phabricator via cfe-commits
furkanusta created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
furkanusta requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

Fixes clangd issue #1137


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127629

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1268,7 +1268,9 @@
   if (const auto *Using = dyn_cast(R.Declaration)) {
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),
-R.Qualifier);
+R.Qualifier, false,
+(R.Availability == CXAvailability_Available ||
+ R.Availability == CXAvailability_Deprecated));
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -413,6 +413,23 @@
   )cpp");
   EXPECT_THAT(External.Completions,
   AllOf(has("pub"), Not(has("prot")), Not(has("priv";
+
+  auto Results = completions(R"cpp(
+  struct Foo {
+public: void pub();
+protected: void prot();
+private: void priv();
+  };
+  struct Bar : public Foo {
+private: using Foo::pub;
+  };
+  void test() {
+Bar B;
+B.^
+  }
+  )cpp");
+  EXPECT_THAT(Results.Completions,
+  AllOf(Not(has("priv")), Not(has("prot")), Not(has("pub";
 }
 
 TEST(CompletionTest, Qualifiers) {


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1268,7 +1268,9 @@
   if (const auto *Using = dyn_cast(R.Declaration)) {
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),
-R.Qualifier);
+R.Qualifier, false,
+(R.Availability == CXAvailability_Available ||
+ R.Availability == CXAvailability_Deprecated));
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -413,6 +413,23 @@
   )cpp");
   EXPECT_THAT(External.Completions,
   AllOf(has("pub"), Not(has("prot")), Not(has("priv";
+
+  auto Results = completions(R"cpp(
+  struct Foo {
+public: void pub();
+protected: void prot();
+private: void priv();
+  };
+  struct Bar : public Foo {
+private: using Foo::pub;
+  };
+  void test() {
+Bar B;
+B.^
+  }
+  )cpp");
+  EXPECT_THAT(Results.Completions,
+  AllOf(Not(has("priv")), Not(has("prot")), Not(has("pub";
 }
 
 TEST(CompletionTest, Qualifiers) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127629: [clang] Use correct visibility parameters when following a Using declaration

2022-06-13 Thread Furkan via Phabricator via cfe-commits
furkanusta added a comment.

I wasn't sure if I should add a URL to the commit message for easy access but 
here is the corresponding clangd issue: 
https://github.com/clangd/clangd/issues/1137


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127629

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-13 Thread Jez Ng via Phabricator via cfe-commits
int3 added a comment.

Oh dear. Hmm does running the test with ASAN enabled hit any memory issues?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-13 Thread Jez Ng via Phabricator via cfe-commits
int3 added a comment.

Actually let me try it now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D124749: [clang-format] Handle Verilog preprocessor directives

2022-06-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.
This revision is now accepted and ready to land.
Herald added a subscriber: nlopes.



Comment at: clang/lib/Format/FormatToken.h:982
 
 kw_always = &IdentTable.get("always");
 kw_always_comb = &IdentTable.get("always_comb");

It seems a comment before is missing. Should be fixed in a separate patch.



Comment at: clang/lib/Format/FormatToken.h:1142
+VerilogExtraKeywords =
+std::unordered_set({kw_always,
+  kw_always_comb,

sstwcw wrote:
> Now that I added `kw_` to `verilogHashHash`, four columns can't fit.
Happens. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124749

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-13 Thread Jez Ng via Phabricator via cfe-commits
int3 added inline comments.



Comment at: clang/tools/driver/cc1as_main.cpp:323-329
+  if (auto *A = Args.getLastArg(OPT_femit_dwarf_unwind_EQ)) {
+Opts.EmitDwarfUnwind =
+llvm::StringSwitch(A->getValue())
+.Case("always", EmitDwarfUnwindType::Always)
+.Case("no-compact-unwind", EmitDwarfUnwindType::NoCompactUnwind)
+.Case("default", EmitDwarfUnwindType::Default);
+  }

still building ASAN but this looks sus -- if no flag gets passed, we never 
initialize `EmitDwarfUnwind` before using it on line 381

also it occurred to me that if the buildbots haven't flagged anything, ASAN 
probably can't detect this. Let me just put up a patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-13 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang/tools/driver/cc1as_main.cpp:323-329
+  if (auto *A = Args.getLastArg(OPT_femit_dwarf_unwind_EQ)) {
+Opts.EmitDwarfUnwind =
+llvm::StringSwitch(A->getValue())
+.Case("always", EmitDwarfUnwindType::Always)
+.Case("no-compact-unwind", EmitDwarfUnwindType::NoCompactUnwind)
+.Case("default", EmitDwarfUnwindType::Default);
+  }

int3 wrote:
> still building ASAN but this looks sus -- if no flag gets passed, we never 
> initialize `EmitDwarfUnwind` before using it on line 381
> 
> also it occurred to me that if the buildbots haven't flagged anything, ASAN 
> probably can't detect this. Let me just put up a patch
We have bots running ASAN on this without complaining.

A patch sounds good! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D127630: [MC] Fix likely uninitialized memory bug

2022-06-13 Thread Jez Ng via Phabricator via cfe-commits
int3 created this revision.
int3 added reviewers: lld-macho, uabelho.
Herald added a project: All.
int3 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

See https://reviews.llvm.org/D122258#inline-1223493. I can't repro the
issue locally but this seems like the likely culprit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127630

Files:
  clang/tools/driver/cc1as_main.cpp


Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -170,6 +170,7 @@
 Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
+EmitDwarfUnwind = EmitDwarfUnwindType::Default;
   }
 
   static bool CreateFromArgs(AssemblerInvocation &Res,


Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -170,6 +170,7 @@
 Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
+EmitDwarfUnwind = EmitDwarfUnwindType::Default;
   }
 
   static bool CreateFromArgs(AssemblerInvocation &Res,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127630: [MC] Fix likely uninitialized memory bug

2022-06-13 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho accepted this revision.
uabelho added a comment.
This revision is now accepted and ready to land.

As I haven't been able to reproduce the problem manually myself I can't confirm 
that this fixes the problem, but it does seem likely.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127630

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


[PATCH] D127393: [Driver] Don't add -lresolv on FreeBSD

2022-06-13 Thread Andrew Turner via Phabricator via cfe-commits
andrew updated this revision to Diff 436338.
andrew added a comment.

Update the comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127393

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -107,7 +107,6 @@
 // CHECK-ASAN-FREEBSD: "--export-dynamic"
 // CHECK-ASAN-FREEBSD: "-lpthread"
 // CHECK-ASAN-FREEBSD: "-lrt"
-// CHECK-ASAN-FREEBSD: "-lresolv"
 
 // RUN: %clang -### %s 2>&1 \
 // RUN: --target=i386-unknown-freebsd -fuse-ld=ld -fsanitize=address \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -838,8 +838,8 @@
   TC.getTriple().isOSNetBSD() ||
   TC.getTriple().isOSOpenBSD())
 CmdArgs.push_back("-lexecinfo");
-  // There is no libresolv on Android.
-  if (!TC.getTriple().isAndroid())
+  // There is no libresolv on Android or FreeBSD.
+  if (!TC.getTriple().isAndroid() && !TC.getTriple().isOSFreeBSD())
 CmdArgs.push_back("-lresolv");
 }
 


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -107,7 +107,6 @@
 // CHECK-ASAN-FREEBSD: "--export-dynamic"
 // CHECK-ASAN-FREEBSD: "-lpthread"
 // CHECK-ASAN-FREEBSD: "-lrt"
-// CHECK-ASAN-FREEBSD: "-lresolv"
 
 // RUN: %clang -### %s 2>&1 \
 // RUN: --target=i386-unknown-freebsd -fuse-ld=ld -fsanitize=address \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -838,8 +838,8 @@
   TC.getTriple().isOSNetBSD() ||
   TC.getTriple().isOSOpenBSD())
 CmdArgs.push_back("-lexecinfo");
-  // There is no libresolv on Android.
-  if (!TC.getTriple().isAndroid())
+  // There is no libresolv on Android or FreeBSD.
+  if (!TC.getTriple().isAndroid() && !TC.getTriple().isOSFreeBSD())
 CmdArgs.push_back("-lresolv");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127393: [Driver] Don't add -lresolv on FreeBSD

2022-06-13 Thread Andrew Turner via Phabricator via cfe-commits
andrew added a comment.

I'll leave it to someone else to get non-FreeBSD working as it's unlikely I'll 
have time to fix them in the hear future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127393

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


[clang] aebe24a - [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-13 Thread via cfe-commits

Author: wangpc
Date: 2022-06-13T19:12:15+08:00
New Revision: aebe24a856d2f40284d940970d4e159319dbb90f

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

LOG: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

These two functions are described in RVV intrinsics doc
to read/write RVV CSRs. This matches what GCC does.

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c

Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 8a1e0eb742582..933a6c11f3359 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -1497,6 +1497,56 @@ multiclass RVVPseudoVNCVTBuiltin
+
+// CHECK-LABEL: @vread_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vstart", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vstart(void) {
+  return vread_csr(RVV_VSTART);
+}
+
+// CHECK-LABEL: @vread_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vxsat", "=r,~{memory}"() #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxsat(void) {
+  return vread_csr(RVV_VXSAT);
+}
+
+// CHECK-LABEL: @vread_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vxrm", "=r,~{memory}"() #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxrm(void) {
+  return vread_csr(RVV_VXRM);
+}
+
+// CHECK-LABEL: @vread_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vcsr", "=r,~{memory}"() #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vcsr(void) {
+  return vread_csr(RVV_VCSR);
+}

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
new file mode 100644
index 0..119fc018595e2
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
@@ -0,0 +1,41 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone 
-emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vwrite_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vstart, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vstart(unsigned long value) {
+  vwrite_csr(RVV_VSTART, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxsat, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxsat(unsigned long value) {
+  vwrite_csr(RVV_VXSAT, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxrm, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxrm(unsigned long value) {
+  vwrite_csr(RVV_VXRM, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vcsr, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vcsr(unsigned long value) {
+  vwrite_csr(RVV_VCSR, value);
+}



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


[PATCH] D125875: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-13 Thread Wang Pengcheng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaebe24a856d2: [RISCV] Add vread_csr and vwrite_csr to 
riscv_vector.h (authored by pcwang-thead).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125875

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
@@ -0,0 +1,41 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vwrite_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vstart, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vstart(unsigned long value) {
+  vwrite_csr(RVV_VSTART, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxsat, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxsat(unsigned long value) {
+  vwrite_csr(RVV_VXSAT, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxrm, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxrm(unsigned long value) {
+  vwrite_csr(RVV_VXRM, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vcsr, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vcsr(unsigned long value) {
+  vwrite_csr(RVV_VCSR, value);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
@@ -0,0 +1,41 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vread_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vstart", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vstart(void) {
+  return vread_csr(RVV_VSTART);
+}
+
+// CHECK-LABEL: @vread_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vxsat", "=r,~{memory}"() #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxsat(void) {
+  return vread_csr(RVV_VXSAT);
+}
+
+// CHECK-LABEL: @vread_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vxrm", "=r,~{memory}"() #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxrm(void) {
+  return vread_csr(RVV_VXRM);
+}
+
+// CHECK-LABEL: @vread_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vcsr", "=r,~{memory}"() #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vcsr(void) {
+  return vread_csr(RVV_VCSR);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1497,6 +1497,56 @@
   }
 }
 
+// Define vread_csr&vwrite_csr described in RVV intrinsics doc.
+let HeaderCode =
+[{
+enum RVV_CSR {
+  RVV_VSTART = 0,
+  RVV_VXSAT,
+  RVV_VXRM,
+  RVV_VCSR,
+};
+
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+unsigned long vread_csr(enum RVV_CSR __csr) {
+  unsigned long __rv = 0;
+  switch (__csr) {
+case RVV_VSTART:
+  __asm__ __volatile__ ("csrr\t%0, vstart" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VXSAT:
+  __asm__ __volatile__ ("csrr\t%0, vxsat" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VXRM:
+  __asm__ __volatile__ ("csrr\t%0, vxrm" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VCSR:
+  __asm__ __volatile__ ("csrr\t%0, vcsr" : "=r"(__rv) : : "memory");
+  break;
+  }
+  return __rv;
+}
+
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+void vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
+  switch (__csr) {
+case 

[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

I'm guessing the Windows precommit is failing because --ld-path is ignored on 
Windows, even if we use a Linux target? I have a fix that works on my Windows 
machine, coming right up.




Comment at: flang/test/Driver/linker-flags.f90:28
+! GNU-SAME: -lFortranDecimal
+! WITHLM-SAME: -lm
+

awarzynski wrote:
> Does `-SAME` makese sense here? As in, this makes sense to me:
> ```
> ! GNU: -lFortranDecimal
> ! GNU-SAME: -lm
> ```
> and this:
> ```
> ! WITHLM: -lFortranDecimal
> ! WITHLM-SAME: -lm
> ```
> but for `! WITHLM-SAME: -lm` there's no [[ 
> https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-same-directive | 
> previous match ]], is there?
It doesn't say that the previous match has to be with the same prefix, and it 
seems to work :)
But since it looks funny to at least one person, I'll update it to use the same 
prefix.



Comment at: flang/test/Driver/linker-flags.f90:33-34
+! MSVC-LABEL: link.exe
+! MSVC-NOT: libcmt
+! MSVC-NOT: oldnames
+! MSVC-SAME: Fortran_main.lib

awarzynski wrote:
> Is it worth adding a comment to explain why to single these out?
I guess it won't hurt 


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

https://reviews.llvm.org/D126291

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Diana Picus via Phabricator via cfe-commits
rovka updated this revision to Diff 436340.
rovka added a comment.

- Stop using --ld-path, since it seems to be ignored on Windows. Instead, just 
match any path that ends in ld (should work with ld, lld, gold). This isn't 
very robust, but I don't have any better ideas (other than actually support 
--ld-path everywhere, not sure how much work that would be).


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

https://reviews.llvm.org/D126291

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  flang/test/Driver/linker-flags.f90

Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -2,18 +2,13 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! NOTE: The additional linker flags tested here are currently only specified for
-! GNU and Darwin. The following line will make sure that this test is skipped on
-! Windows. If you are running this test on a yet another platform and it is
-! failing for you, please either update the following or (preferably) update the
-! linker invocation accordingly.
-! UNSUPPORTED: system-windows
-
-!
-! RUN COMMAND
-!
-! Use `--ld-path` so that the linker location (used in the LABEL below) is deterministic.
-! RUN: %flang -### -flang-experimental-exec --ld-path=/usr/bin/ld %S/Inputs/hello.f90 2>&1 | FileCheck %s
+!-
+! RUN COMMANDS
+!-
+! RUN: %flang -### -flang-experimental-exec -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-WITHLM
+! RUN: %flang -### -flang-experimental-exec -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-WITHOUTLM
+! RUN: %flang -### -flang-experimental-exec -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-WITHOUTLM
+! RUN: %flang -### -flang-experimental-exec -target aarch64-windows-msvc %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC
 
 !
 ! EXPECTED OUTPUT
@@ -22,10 +17,31 @@
 ! CHECK-LABEL: {{.*}} "-emit-obj"
 ! CHECK-SAME:  "-o" "[[object_file:.*\.o]]" {{.*}}Inputs/hello.f90
 
-! Linker invocation to generate the executable
-! CHECK-LABEL:  "/usr/bin/ld"
-! CHECK-SAME: "[[object_file]]"
-! CHECK-SAME: -lFortran_main
-! CHECK-SAME: -lFortranRuntime
-! CHECK-SAME: -lFortranDecimal
-! CHECK-SAME: -lm
+! Linker invocation to generate the executable - GNU version
+! GNU-WITHLM-LABEL:  "{{.*}}ld" 
+! GNU-WITHLM-SAME: "[[object_file]]"
+! GNU-WITHLM-SAME: -lFortran_main
+! GNU-WITHLM-SAME: -lFortranRuntime
+! GNU-WITHLM-SAME: -lFortranDecimal
+! GNU-WITHLM-SAME: -lm
+
+! GNU-WITHOUTLM-LABEL:  "{{.*}}ld" 
+! GNU-WITHOUTLM-SAME: "[[object_file]]"
+! GNU-WITHOUTLM-SAME: -lFortran_main
+! GNU-WITHOUTLM-SAME: -lFortranRuntime
+! GNU-WITHOUTLM-SAME: -lFortranDecimal
+
+! Linker invocation to generate the executable - MSVC version
+! NOTE: This check should also match if the default linker is lld-link.exe
+! MSVC-LABEL: link.exe
+! These libraries are added by clang, but are not needed when compiling
+! Fortran code, and they might bring in other dependencies.
+! MSVC-NOT: libcmt
+! MSVC-NOT: oldnames
+! MSVC-SAME: Fortran_main.lib
+! MSVC-SAME: FortranRuntime.lib
+! MSVC-SAME: FortranDecimal.lib
+! MSVC-SAME: /subsystem:console
+! MSVC-NOT: libcmt
+! MSVC-NOT: oldnames
+! MSVC-SAME: "[[object_file]]"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -218,6 +218,11 @@
 
   AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
 
+  if (C.getDriver().IsFlangMode()) {
+addFortranRuntimeLibraryPath(TC, Args, CmdArgs);
+addFortranRuntimeLibs(TC, CmdArgs);
+  }
+
   // TODO: Add profile stuff here
 
   if (TC.ShouldLinkCXXStdlib(Args)) {
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -81,7 +81,7 @@
 Args.MakeArgString(std::string("-out:") + Output.getFilename()));
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
-  !C.getDriver().IsCLMode()) {
+  !C.getDriver().IsCLMode() && !C.getDriver().IsFlangMode()) {
 CmdArgs.push_back("-defaultlib:libcmt");
 CmdArgs.push_back("-defaultlib:oldnames");
   }
@@ -130,6 +130,16 @@
   Args.MakeArgString(std::string("-libpath:") + WindowsSdkLibPath));
   }
 
+  if (C.getDriver().IsFlangMode()) {
+addFortranRuntimeLibraryPath(TC, Args, C

[clang] c12577c - [clang][driver] Introduce new -fdriver-only flag

2022-06-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2022-06-13T13:30:56+02:00
New Revision: c12577c61dbf37b1b6ae25ed422a900ac71f18fe

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

LOG: [clang][driver] Introduce new -fdriver-only flag

This patch introduces the new -fdriver-only flag which instructs Clang to only 
execute the driver logic without running individual jobs. In a way, this is 
very similar to -###, with the following differences:
 * it doesn't automatically print all jobs,
 * it doesn't avoid side effects (e.g. it will generate compilation database 
when -MJ is specified).

This flag will be useful in testing D121997.

Reviewed By: dexonsmith, egorzhdan

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

Added: 
clang/test/Driver/driver-only.c

Modified: 
clang/include/clang/Driver/Compilation.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
clang/test/Driver/cc-print-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Compilation.h 
b/clang/include/clang/Driver/Compilation.h
index 260e2a34ed5a7..c5714d3208884 100644
--- a/clang/include/clang/Driver/Compilation.h
+++ b/clang/include/clang/Driver/Compilation.h
@@ -295,16 +295,22 @@ class Compilation {
   ///
   /// \param FailingCommand - For non-zero results, this will be set to the
   /// Command which failed, if any.
+  /// \param LogOnly - When true, only tries to log the command, not actually
+  /// execute it.
   /// \return The result code of the subprocess.
-  int ExecuteCommand(const Command &C, const Command *&FailingCommand) const;
+  int ExecuteCommand(const Command &C, const Command *&FailingCommand,
+ bool LogOnly = false) const;
 
   /// ExecuteJob - Execute a single job.
   ///
   /// \param FailingCommands - For non-zero results, this will be a vector of
   /// failing commands and their associated result code.
-  void ExecuteJobs(
-  const JobList &Jobs,
-  SmallVectorImpl> &FailingCommands) const;
+  /// \param LogOnly - When true, only tries to log the command, not actually
+  /// execute it.
+  void
+  ExecuteJobs(const JobList &Jobs,
+  SmallVectorImpl> 
&FailingCommands,
+  bool LogOnly = false) const;
 
   /// initCompilationForDiagnostics - Remove stale state and suppress output
   /// so compilation can be reexecuted to generate additional diagnostic

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 002cd6cc8cb17..5d650534ce07f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2751,6 +2751,8 @@ defm strict_vtable_pointers : 
BoolFOption<"strict-vtable-pointers",
 " overwriting polymorphic C++ objects">,
   NegFlag>;
 def fstrict_overflow : Flag<["-"], "fstrict-overflow">, Group;
+def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption, 
CoreOption]>,
+  Group, HelpText<"Only run the driver.">;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
   Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;

diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index 67d941c6c2ab9..b4367a0af81ee 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -162,7 +162,8 @@ bool Compilation::CleanupFileMap(const ArgStringMap &Files,
 }
 
 int Compilation::ExecuteCommand(const Command &C,
-const Command *&FailingCommand) const {
+const Command *&FailingCommand,
+bool LogOnly) const {
   if ((getDriver().CCPrintOptions ||
getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) {
 raw_ostream *OS = &llvm::errs();
@@ -191,6 +192,9 @@ int Compilation::ExecuteCommand(const Command &C,
 C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions);
   }
 
+  if (LogOnly)
+return 0;
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
@@ -237,7 +241,8 @@ static bool InputsOk(const Command &C,
 }
 
 void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+  FailingCommandList &FailingCommands,
+  bool LogOnly) const {
   // According to UNIX standard, driver need to continue compiling all the
   // inputs on the command line even one of them failed.
   // In all but CLMode, execute all the jobs unless the necessary inputs for 
the
@@ -246,7 +251,7 @@ void Compilation::ExecuteJobs(const JobList &Jobs,

[clang] a856700 - [clang][driver] Fix compilation database dump with multiple architectures

2022-06-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2022-06-13T13:30:57+02:00
New Revision: a85670001ba2487988839656299771915ebc7633

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

LOG: [clang][driver] Fix compilation database dump with multiple architectures

Command lines with multiple `-arch` arguments expand into multiple entries in 
the compilation database. However, the file writes are not appending, meaning 
subsequent writes end up overwriting the previous ones, resulting in garbled 
output.

This patch fixes that by always appending to the file.

rdar://90165004

Reviewed By: dexonsmith

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

Added: 
clang/test/Driver/compilation_database_multiarch.c

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/compilation_database.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 62e891ce38c49..5aa172edc362d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2406,7 +2406,8 @@ void Clang::DumpCompilationDatabase(Compilation &C, 
StringRef Filename,
   if (!CompilationDatabase) {
 std::error_code EC;
 auto File = std::make_unique(
-Filename, EC, llvm::sys::fs::OF_TextWithCRLF);
+Filename, EC,
+llvm::sys::fs::OF_TextWithCRLF | llvm::sys::fs::OF_Append);
 if (EC) {
   D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
<< EC.message();
@@ -2432,6 +2433,7 @@ void Clang::DumpCompilationDatabase(Compilation &C, 
StringRef Filename,
 CDB << ", \"" << escape(Buf) << "\"";
   }
   CDB << ", \"" << escape(Input.getFilename()) << "\"";
+  CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\"";
   for (auto &A: Args) {
 auto &O = A->getOption();
 // Skip language selection, which is positional.
@@ -2445,6 +2447,9 @@ void Clang::DumpCompilationDatabase(Compilation &C, 
StringRef Filename,
 // Skip inputs.
 if (O.getKind() == Option::InputClass)
   continue;
+// Skip output.
+if (O.getID() == options::OPT_o)
+  continue;
 // All other arguments are quoted and appended.
 ArgStringList ASL;
 A->render(Args, ASL);

diff  --git a/clang/test/Driver/compilation_database.c 
b/clang/test/Driver/compilation_database.c
index 19224d22de044..879c67c59c883 100644
--- a/clang/test/Driver/compilation_database.c
+++ b/clang/test/Driver/compilation_database.c
@@ -2,8 +2,8 @@
 // RUN: %clang -no-canonical-prefixes -fintegrated-as -MD -MP 
--sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
 // RUN: not %clang -no-canonical-prefixes -c -x c %s -MJ %s/non-existant 2>&1 
| FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-no-canonical-prefixes", "-fintegrated-as", "--sysroot=somewhere", 
"-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-no-canonical-prefixes", "-fintegrated-as", "--sysroot=somewhere", 
"-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-o", "compilation_database.o", "-no-canonical-prefixes", 
"-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-o", "compilation_database.o", "-no-canonical-prefixes", 
"-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {

diff  --git a/clang/test/Driver/compilation_database_multiarch.c 
b/clang/test/Driver/compilation_database_multiarch.c
new file mode 100644
index 0..b64e0265a3ff8
--- /dev/null
+++ b/clang/test/Driver/compilation_database_multiarch.c
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -fdriver-only -o %t/out %s -mtargetos=macos12 -arch arm64 -arch 
x86_64 -MJ %t/compilation_database.json
+// RUN: FileCheck --input-file=%t/compilation_database.json %s
+
+// CHECK:  { "directory": "{{.*}}", "file": "{{.*}}", "output": 
"[[OUTPUT_X86_64:.*]]", "arguments": [{{.*}}, "-o", "

[PATCH] D127408: [clang][driver] Introduce new -fdriver-only flag

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc12577c61dbf: [clang][driver] Introduce new -fdriver-only 
flag (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D127408?vs=435569&id=436342#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127408

Files:
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/test/Driver/cc-print-options.c
  clang/test/Driver/driver-only.c

Index: clang/test/Driver/driver-only.c
===
--- /dev/null
+++ clang/test/Driver/driver-only.c
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// Check that -fdriver-only doesn't actually run the generated -cc1 job.
+//
+// RUN: %clang -c %s -o %t/a.o -fdriver-only
+// RUN: not cat %t/a.o
+
+// Check that -fdriver-only respects errors.
+//
+// RUN: not %clang -c %s -fdriver-only -target i386-apple-darwin9 -m32 -Xarch_i386 -o
+
+// Check that -fdriver-only respects -v.
+//
+// RUN: %clang -c %s -fdriver-only -v 2>&1 | FileCheck %s --check-prefix=CHECK-V
+// CHECK-V: {{.*}} "-cc1"
+//
+// RUN: %clang -c %s -fdriver-only2>&1 | FileCheck %s --check-prefix=CHECK-NO-V --allow-empty
+// CHECK-NO-V-NOT: {{.*}} "-cc1"
Index: clang/test/Driver/cc-print-options.c
===
--- clang/test/Driver/cc-print-options.c
+++ clang/test/Driver/cc-print-options.c
@@ -1,8 +1,14 @@
+// RUN: rm -f %t.log
 // RUN: env CC_PRINT_OPTIONS=1 \
 // RUN: CC_PRINT_OPTIONS_FILE=%t.log \
 // RUN: %clang -S -o %t.s %s
 // RUN: FileCheck %s < %t.log
 
-// CHECK: [Logging clang options]
-// CHECK: {{.*}} "-S"
+// RUN: rm -f %t.log
+// RUN: env CC_PRINT_OPTIONS=1 \
+// RUN: CC_PRINT_OPTIONS_FILE=%t.log \
+// RUN: %clang -fdriver-only -o %t.s %s
+// RUN: FileCheck %s < %t.log
 
+// CHECK: [Logging clang options]
+// CHECK: {{.*}} "-cc1"
Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -54,6 +54,9 @@
   if (!C)
 return nullptr;
 
+  if (C->getArgs().hasArg(driver::options::OPT_fdriver_only))
+return nullptr;
+
   // Just print the cc1 options if -### was present.
   if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) {
 C->getJobs().Print(llvm::errs(), "\n", true);
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1689,6 +1689,19 @@
 int Driver::ExecuteCompilation(
 Compilation &C,
 SmallVectorImpl> &FailingCommands) {
+  if (C.getArgs().hasArg(options::OPT_fdriver_only)) {
+if (C.getArgs().hasArg(options::OPT_v))
+  C.getJobs().Print(llvm::errs(), "\n", true);
+
+C.ExecuteJobs(C.getJobs(), FailingCommands, /*LogOnly=*/true);
+
+// If there were errors building the compilation, quit now.
+if (!FailingCommands.empty() || Diags.hasErrorOccurred())
+  return 1;
+
+return 0;
+  }
+
   // Just print if -### was present.
   if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
 C.getJobs().Print(llvm::errs(), "\n", true);
@@ -4761,6 +4774,8 @@
   C.getArgs().hasArg(options::OPT_Qunused_arguments))
 return;
 
+  // Claim -fdriver-only here.
+  (void)C.getArgs().hasArg(options::OPT_fdriver_only);
   // Claim -### here.
   (void)C.getArgs().hasArg(options::OPT__HASH_HASH_HASH);
 
Index: clang/lib/Driver/Compilation.cpp
===
--- clang/lib/Driver/Compilation.cpp
+++ clang/lib/Driver/Compilation.cpp
@@ -162,7 +162,8 @@
 }
 
 int Compilation::ExecuteCommand(const Command &C,
-const Command *&FailingCommand) const {
+const Command *&FailingCommand,
+bool LogOnly) const {
   if ((getDriver().CCPrintOptions ||
getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) {
 raw_ostream *OS = &llvm::errs();
@@ -191,6 +192,9 @@
 C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions);
   }
 
+  if (LogOnly)
+return 0;
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
@@ -237,7 +241,8 @@
 }
 
 void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+  FailingCommandList &FailingCommands,
+  bool LogOnly) const {
   // According to UNIX standard, driver need to continue compiling all the
  

[PATCH] D121997: [clang][driver] Fix compilation database dump with multiple architectures

2022-06-13 Thread Jan Svoboda 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 rGa85670001ba2: [clang][driver] Fix compilation database dump 
with multiple architectures (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121997

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/compilation_database.c
  clang/test/Driver/compilation_database_multiarch.c


Index: clang/test/Driver/compilation_database_multiarch.c
===
--- /dev/null
+++ clang/test/Driver/compilation_database_multiarch.c
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -fdriver-only -o %t/out %s -mtargetos=macos12 -arch arm64 -arch 
x86_64 -MJ %t/compilation_database.json
+// RUN: FileCheck --input-file=%t/compilation_database.json %s
+
+// CHECK:  { "directory": "{{.*}}", "file": "{{.*}}", "output": 
"[[OUTPUT_X86_64:.*]]", "arguments": [{{.*}}, "-o", "[[OUTPUT_X86_64]]", {{.*}} 
"--target=x86_64-apple-macosx12.0.0"]},
+// CHECK-NEXT: { "directory": "{{.*}}", "file": "{{.*}}", "output": 
"[[OUTPUT_ARM64:.*]]", "arguments": [{{.*}}, "-o", "[[OUTPUT_ARM64]]", {{.*}} 
"--target=arm64-apple-macosx12.0.0"]},
Index: clang/test/Driver/compilation_database.c
===
--- clang/test/Driver/compilation_database.c
+++ clang/test/Driver/compilation_database.c
@@ -2,8 +2,8 @@
 // RUN: %clang -no-canonical-prefixes -fintegrated-as -MD -MP 
--sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
 // RUN: not %clang -no-canonical-prefixes -c -x c %s -MJ %s/non-existant 2>&1 
| FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-no-canonical-prefixes", "-fintegrated-as", "--sysroot=somewhere", 
"-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-no-canonical-prefixes", "-fintegrated-as", "--sysroot=somewhere", 
"-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{[^"]*}}workdir",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-o", "compilation_database.o", "-no-canonical-prefixes", 
"-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-o", "compilation_database.o", "-no-canonical-prefixes", 
"-fintegrated-as", "--sysroot=somewhere", "-c", "-Wall",{{.*}} 
"--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2406,7 +2406,8 @@
   if (!CompilationDatabase) {
 std::error_code EC;
 auto File = std::make_unique(
-Filename, EC, llvm::sys::fs::OF_TextWithCRLF);
+Filename, EC,
+llvm::sys::fs::OF_TextWithCRLF | llvm::sys::fs::OF_Append);
 if (EC) {
   D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
<< EC.message();
@@ -2432,6 +2433,7 @@
 CDB << ", \"" << escape(Buf) << "\"";
   }
   CDB << ", \"" << escape(Input.getFilename()) << "\"";
+  CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\"";
   for (auto &A: Args) {
 auto &O = A->getOption();
 // Skip language selection, which is positional.
@@ -2445,6 +2447,9 @@
 // Skip inputs.
 if (O.getKind() == Option::InputClass)
   continue;
+// Skip output.
+if (O.getID() == options::OPT_o)
+  continue;
 // All other arguments are quoted and appended.
 ArgStringList ASL;
 A->render(Args, ASL);


Index: clang/test/Driver/compilation_database_multiarch.c
===
--- /dev/null
+++ clang/test/Driver/compilation_database_multiarch.c
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -fdriver-only -o %t/out %s -mtargetos=macos12 -arch arm64 -arch x86_64 -MJ %t/compilation_database.json
+// RUN: FileCheck --input-file=%t/compilation_database.json %s
+
+// CHECK:  { "directory": "{{.*}}", "file": "{{.*}}", "output": "[[OUTPUT_X86_64:.*]]", "arguments": [{{.*}}, "-o", "[[O

[clang] 0f6f429 - Revert "[RISCV] Add vread_csr and vwrite_csr to riscv_vector.h"

2022-06-13 Thread via cfe-commits

Author: wangpc
Date: 2022-06-13T19:31:25+08:00
New Revision: 0f6f4295d10fe8cc9c3933b85dc9a66b840e3eca

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

LOG: Revert "[RISCV] Add vread_csr and vwrite_csr to riscv_vector.h"

This reverts commit aebe24a856d2f40284d940970d4e159319dbb90f.

`REQUIRES` for RISCV target is needed in tests.

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 
clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c



diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 933a6c11f3359..8a1e0eb742582 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -1497,56 +1497,6 @@ multiclass RVVPseudoVNCVTBuiltin
-
-// CHECK-LABEL: @vread_csr_vstart(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vstart", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
-// CHECK-NEXT:ret i64 [[TMP0]]
-//
-unsigned long vread_csr_vstart(void) {
-  return vread_csr(RVV_VSTART);
-}
-
-// CHECK-LABEL: @vread_csr_vxsat(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vxsat", "=r,~{memory}"() #[[ATTR1]], !srcloc !5
-// CHECK-NEXT:ret i64 [[TMP0]]
-//
-unsigned long vread_csr_vxsat(void) {
-  return vread_csr(RVV_VXSAT);
-}
-
-// CHECK-LABEL: @vread_csr_vxrm(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vxrm", "=r,~{memory}"() #[[ATTR1]], !srcloc !6
-// CHECK-NEXT:ret i64 [[TMP0]]
-//
-unsigned long vread_csr_vxrm(void) {
-  return vread_csr(RVV_VXRM);
-}
-
-// CHECK-LABEL: @vread_csr_vcsr(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vcsr", "=r,~{memory}"() #[[ATTR1]], !srcloc !7
-// CHECK-NEXT:ret i64 [[TMP0]]
-//
-unsigned long vread_csr_vcsr(void) {
-  return vread_csr(RVV_VCSR);
-}

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
deleted file mode 100644
index 119fc018595e2..0
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
+++ /dev/null
@@ -1,41 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone 
-emit-llvm %s -o - \
-// RUN: | opt -S -O2 | FileCheck  %s
-
-#include 
-
-// CHECK-LABEL: @vwrite_csr_vstart(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:tail call void asm sideeffect "csrw\09vstart, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !4
-// CHECK-NEXT:ret void
-//
-void vwrite_csr_vstart(unsigned long value) {
-  vwrite_csr(RVV_VSTART, value);
-}
-
-// CHECK-LABEL: @vwrite_csr_vxsat(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxsat, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !5
-// CHECK-NEXT:ret void
-//
-void vwrite_csr_vxsat(unsigned long value) {
-  vwrite_csr(RVV_VXSAT, value);
-}
-
-// CHECK-LABEL: @vwrite_csr_vxrm(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxrm, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !6
-// CHECK-NEXT:ret void
-//
-void vwrite_csr_vxrm(unsigned long value) {
-  vwrite_csr(RVV_VXRM, value);
-}
-
-// CHECK-LABEL: @vwrite_csr_vcsr(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:tail call void asm sideeffect "csrw\09vcsr, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !7
-// CHECK-NEXT:ret void
-//
-void vwrite_csr_vcsr(unsigned long value) {
-  vwrite_csr(RVV_VCSR, value);
-}



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


[PATCH] D125875: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-13 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead updated this revision to Diff 436344.
pcwang-thead added a comment.

Add `REQUIRES` to tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125875

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vwrite_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vstart, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vstart(unsigned long value) {
+  vwrite_csr(RVV_VSTART, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxsat, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxsat(unsigned long value) {
+  vwrite_csr(RVV_VXSAT, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxrm, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxrm(unsigned long value) {
+  vwrite_csr(RVV_VXRM, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vcsr, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vcsr(unsigned long value) {
+  vwrite_csr(RVV_VCSR, value);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vread_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vstart", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vstart(void) {
+  return vread_csr(RVV_VSTART);
+}
+
+// CHECK-LABEL: @vread_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vxsat", "=r,~{memory}"() #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxsat(void) {
+  return vread_csr(RVV_VXSAT);
+}
+
+// CHECK-LABEL: @vread_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vxrm", "=r,~{memory}"() #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxrm(void) {
+  return vread_csr(RVV_VXRM);
+}
+
+// CHECK-LABEL: @vread_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vcsr", "=r,~{memory}"() #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vcsr(void) {
+  return vread_csr(RVV_VCSR);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1497,6 +1497,56 @@
   }
 }
 
+// Define vread_csr&vwrite_csr described in RVV intrinsics doc.
+let HeaderCode =
+[{
+enum RVV_CSR {
+  RVV_VSTART = 0,
+  RVV_VXSAT,
+  RVV_VXRM,
+  RVV_VCSR,
+};
+
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+unsigned long vread_csr(enum RVV_CSR __csr) {
+  unsigned long __rv = 0;
+  switch (__csr) {
+case RVV_VSTART:
+  __asm__ __volatile__ ("csrr\t%0, vstart" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VXSAT:
+  __asm__ __volatile__ ("csrr\t%0, vxsat" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VXRM:
+  __asm__ __volatile__ ("csrr\t%0, vxrm" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VCSR:
+  __asm__ __volatile__ ("csrr\t%0, vcsr" : "=r"(__rv) : : "memory");
+  break;
+  }
+  return __rv;
+}
+
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+void vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
+  switch (__csr) {
+case RVV_VST

[clang] e4a21e1 - [MC] Fix likely uninitialized memory bug

2022-06-13 Thread Jez Ng via cfe-commits

Author: Jez Ng
Date: 2022-06-13T07:41:17-04:00
New Revision: e4a21e1644f2015dd4f9c3a7c67378879aa912cc

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

LOG: [MC] Fix likely uninitialized memory bug

See https://reviews.llvm.org/D122258#inline-1223493. I can't repro the
issue locally but this seems like the likely culprit.

Reviewed By: uabelho

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

Added: 


Modified: 
clang/tools/driver/cc1as_main.cpp

Removed: 




diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 264f747d6d740..5498810d835cd 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -170,6 +170,7 @@ struct AssemblerInvocation {
 Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
+EmitDwarfUnwind = EmitDwarfUnwindType::Default;
   }
 
   static bool CreateFromArgs(AssemblerInvocation &Res,



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


[PATCH] D127630: [MC] Fix likely uninitialized memory bug

2022-06-13 Thread Jez Ng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4a21e1644f2: [MC] Fix likely uninitialized memory bug 
(authored by int3).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127630

Files:
  clang/tools/driver/cc1as_main.cpp


Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -170,6 +170,7 @@
 Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
+EmitDwarfUnwind = EmitDwarfUnwindType::Default;
   }
 
   static bool CreateFromArgs(AssemblerInvocation &Res,


Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -170,6 +170,7 @@
 Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
+EmitDwarfUnwind = EmitDwarfUnwindType::Default;
   }
 
   static bool CreateFromArgs(AssemblerInvocation &Res,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2de36d0 - [clang][driver] Only run multi-arch tests on Darwin

2022-06-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2022-06-13T14:03:23+02:00
New Revision: 2de36d0369a5107a3f02aceebb55326adf4ad2cb

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

LOG: [clang][driver] Only run multi-arch tests on Darwin

This fixes the test introduced in a85670001ba2487988839656299771915ebc7633 that 
causes failures on non-Darwin systems.

Added: 


Modified: 
clang/test/Driver/compilation_database_multiarch.c

Removed: 




diff  --git a/clang/test/Driver/compilation_database_multiarch.c 
b/clang/test/Driver/compilation_database_multiarch.c
index b64e0265a3ff..86401503aa17 100644
--- a/clang/test/Driver/compilation_database_multiarch.c
+++ b/clang/test/Driver/compilation_database_multiarch.c
@@ -1,3 +1,5 @@
+// REQUIRES: system-darwin
+
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: %clang -fdriver-only -o %t/out %s -mtargetos=macos12 -arch arm64 -arch 
x86_64 -MJ %t/compilation_database.json
 // RUN: FileCheck --input-file=%t/compilation_database.json %s



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


[PATCH] D127509: Prefer `getCurrentFileOrBufferName` in `FrontendAction::EndSourceFile`

2022-06-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

LGTM but can you try re-running the pre-commit CI?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127509

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


[clang] 93b4a41 - [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-13 Thread via cfe-commits

Author: wangpc
Date: 2022-06-13T20:38:52+08:00
New Revision: 93b4a41b55102fb400ef6507068148761bb10be1

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

LOG: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

These two functions are described in RVV intrinsics doc
to read/write RVV CSRs. This matches what GCC does.

This reapply aebe24a which was reverted in 0f6f429 due
to missing REQUIRES in tests.

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c

Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 8a1e0eb742582..933a6c11f3359 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -1497,6 +1497,56 @@ multiclass RVVPseudoVNCVTBuiltin
+
+// CHECK-LABEL: @vread_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vstart", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vstart(void) {
+  return vread_csr(RVV_VSTART);
+}
+
+// CHECK-LABEL: @vread_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vxsat", "=r,~{memory}"() #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxsat(void) {
+  return vread_csr(RVV_VXSAT);
+}
+
+// CHECK-LABEL: @vread_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vxrm", "=r,~{memory}"() #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxrm(void) {
+  return vread_csr(RVV_VXRM);
+}
+
+// CHECK-LABEL: @vread_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vcsr", "=r,~{memory}"() #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vcsr(void) {
+  return vread_csr(RVV_VCSR);
+}

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
new file mode 100644
index 0..a94f599d7c7c3
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone 
-emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vwrite_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vstart, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vstart(unsigned long value) {
+  vwrite_csr(RVV_VSTART, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxsat, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxsat(unsigned long value) {
+  vwrite_csr(RVV_VXSAT, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxrm, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxrm(unsigned long value) {
+  vwrite_csr(RVV_VXRM, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vcsr, ${0:z}", 
"rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vcsr(unsigned long value) {
+  vwrite_csr(RVV_VCSR, value);
+}



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


[PATCH] D125875: [RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

2022-06-13 Thread Wang Pengcheng 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 rG93b4a41b5510: [RISCV] Add vread_csr and vwrite_csr to 
riscv_vector.h (authored by pcwang-thead).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125875

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vwrite-csr.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vwrite_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vstart, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vstart(unsigned long value) {
+  vwrite_csr(RVV_VSTART, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxsat, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxsat(unsigned long value) {
+  vwrite_csr(RVV_VXSAT, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vxrm, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vxrm(unsigned long value) {
+  vwrite_csr(RVV_VXRM, value);
+}
+
+// CHECK-LABEL: @vwrite_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void asm sideeffect "csrw\09vcsr, ${0:z}", "rJ,~{memory}"(i64 [[VALUE:%.*]]) #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret void
+//
+void vwrite_csr_vcsr(unsigned long value) {
+  vwrite_csr(RVV_VCSR, value);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @vread_csr_vstart(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vstart", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vstart(void) {
+  return vread_csr(RVV_VSTART);
+}
+
+// CHECK-LABEL: @vread_csr_vxsat(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vxsat", "=r,~{memory}"() #[[ATTR1]], !srcloc !5
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxsat(void) {
+  return vread_csr(RVV_VXSAT);
+}
+
+// CHECK-LABEL: @vread_csr_vxrm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vxrm", "=r,~{memory}"() #[[ATTR1]], !srcloc !6
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vxrm(void) {
+  return vread_csr(RVV_VXRM);
+}
+
+// CHECK-LABEL: @vread_csr_vcsr(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vcsr", "=r,~{memory}"() #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long vread_csr_vcsr(void) {
+  return vread_csr(RVV_VCSR);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1497,6 +1497,56 @@
   }
 }
 
+// Define vread_csr&vwrite_csr described in RVV intrinsics doc.
+let HeaderCode =
+[{
+enum RVV_CSR {
+  RVV_VSTART = 0,
+  RVV_VXSAT,
+  RVV_VXRM,
+  RVV_VCSR,
+};
+
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+unsigned long vread_csr(enum RVV_CSR __csr) {
+  unsigned long __rv = 0;
+  switch (__csr) {
+case RVV_VSTART:
+  __asm__ __volatile__ ("csrr\t%0, vstart" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VXSAT:
+  __asm__ __volatile__ ("csrr\t%0, vxsat" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VXRM:
+  __asm__ __volatile__ ("csrr\t%0, vxrm" : "=r"(__rv) : : "memory");
+  break;
+case RVV_VCSR:
+  __asm__ __volatile__ ("csrr\t%0, vcsr" : "=r"(__rv) : : "memory");
+  break;
+  }
+  return __rv;
+}
+
+static __inline__ __attrib

[PATCH] D127629: [clang] Use correct visibility parameters when following a Using declaration

2022-06-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a reviewer: kadircet.
kadircet added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:1269
   if (const auto *Using = dyn_cast(R.Declaration)) {
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),

can you also update `MaybeAddResult` around line 1096.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127629

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


[PATCH] D127629: [clang] Use correct visibility parameters when following a Using declaration

2022-06-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Also if you put `Fixes https://github.com/clangd/clangd/issues/1137` in the 
commit message, it'll automatically close the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127629

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


[PATCH] D127184: [clangd] Add to header map

2022-06-13 Thread Florian Albrechtskirchinger via Phabricator via cfe-commits
falbrechtskirchinger added a comment.

Since `*.tcc` files are mapped as well and there are only a few of them 
missing, should I add them as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127184

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


[PATCH] D123032: [clang][dataflow] Exclude protobuf types from modeling in the environment.

2022-06-13 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added a comment.

Ping... Gabor, Stanislav: what are your thoughts on this patch? I think we're 
in a place where I could do performance comparisons before/after if you think 
that's justified.

Alternatively, I have a relatively simple proposal for lazy initialization that 
I expect I will implement in the next couple of months. If you're sufficiently 
concerned with this patch, waiting for that patch is an option as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123032

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


[PATCH] D127629: [clang] Use correct visibility parameters when following a Using declaration

2022-06-13 Thread Furkan via Phabricator via cfe-commits
furkanusta updated this revision to Diff 436369.
furkanusta added a comment.

[clang] Use correct visibility parameters when following a Using declaration

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127629

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1095,7 +1095,9 @@
   if (const UsingShadowDecl *Using = dyn_cast(R.Declaration)) 
{
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),
-R.Qualifier);
+R.Qualifier, false,
+(R.Availability == CXAvailability_Available ||
+ R.Availability == CXAvailability_Deprecated));
 Result.ShadowDecl = Using;
 MaybeAddResult(Result, CurContext);
 return;
@@ -1268,7 +1270,9 @@
   if (const auto *Using = dyn_cast(R.Declaration)) {
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),
-R.Qualifier);
+R.Qualifier, false,
+(R.Availability == CXAvailability_Available ||
+ R.Availability == CXAvailability_Deprecated));
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -413,6 +413,23 @@
   )cpp");
   EXPECT_THAT(External.Completions,
   AllOf(has("pub"), Not(has("prot")), Not(has("priv";
+
+  auto Results = completions(R"cpp(
+  struct Foo {
+public: void pub();
+protected: void prot();
+private: void priv();
+  };
+  struct Bar : public Foo {
+private: using Foo::pub;
+  };
+  void test() {
+Bar B;
+B.^
+  }
+  )cpp");
+  EXPECT_THAT(Results.Completions,
+  AllOf(Not(has("priv")), Not(has("prot")), Not(has("pub";
 }
 
 TEST(CompletionTest, Qualifiers) {


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1095,7 +1095,9 @@
   if (const UsingShadowDecl *Using = dyn_cast(R.Declaration)) {
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),
-R.Qualifier);
+R.Qualifier, false,
+(R.Availability == CXAvailability_Available ||
+ R.Availability == CXAvailability_Deprecated));
 Result.ShadowDecl = Using;
 MaybeAddResult(Result, CurContext);
 return;
@@ -1268,7 +1270,9 @@
   if (const auto *Using = dyn_cast(R.Declaration)) {
 CodeCompletionResult Result(Using->getTargetDecl(),
 getBasePriority(Using->getTargetDecl()),
-R.Qualifier);
+R.Qualifier, false,
+(R.Availability == CXAvailability_Available ||
+ R.Availability == CXAvailability_Deprecated));
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -413,6 +413,23 @@
   )cpp");
   EXPECT_THAT(External.Completions,
   AllOf(has("pub"), Not(has("prot")), Not(has("priv";
+
+  auto Results = completions(R"cpp(
+  struct Foo {
+public: void pub();
+protected: void prot();
+private: void priv();
+  };
+  struct Bar : public Foo {
+private: using Foo::pub;
+  };
+  void test() {
+Bar B;
+B.^
+  }
+  )cpp");
+  EXPECT_THAT(Results.Completions,
+  AllOf(Not(has("priv")), Not(has("prot")), Not(has("pub";
 }
 
 TEST(CompletionTest, Qualifiers) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127201: [clang] Add tests for statement expression in initializers

2022-06-13 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders added a comment.

One week gentle ping.
+ added reviewers from the https://reviews.llvm.org/D111400 patch that fixed 
the bug these tests covers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127201

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


[PATCH] D121997: [clang][driver] Fix compilation database dump with multiple architectures

2022-06-13 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan added a comment.

Hi, it seems on AIX the target and arch options are ignored, so we don't get 
the expected output for this test. Any ideas about the course of action we 
should take?
https://lab.llvm.org/buildbot/#/builders/214/builds/1785/steps/6/logs/FAIL__Clang__compilation_database_multiarch_c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121997

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


[PATCH] D127452: [clang-cl][MSVC] Map /external:Wn n=1-4 to -Wsystem-headers

2022-06-13 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

Hmm do you know how I can restart the pre-merge checks? It looks like the x64 
debian openmp tests failed. I don't think this patch is related, but I want to 
make sure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127452

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


[PATCH] D127184: [clangd] Add to header map

2022-06-13 Thread Florian Albrechtskirchinger via Phabricator via cfe-commits
falbrechtskirchinger updated this revision to Diff 436377.
falbrechtskirchinger added a comment.

Add more missing headers to the system header map


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127184

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp

Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -181,19 +181,26 @@
   {"backward/auto_ptr.h", ""},
   {"backward/binders.h", ""},
   {"bits/algorithmfwd.h", ""},
+  {"bits/align.h", ""},
   {"bits/alloc_traits.h", ""},
   {"bits/allocated_ptr.h", ""},
   {"bits/allocator.h", ""},
   {"bits/atomic_base.h", ""},
   {"bits/atomic_lockfree_defines.h", ""},
   {"bits/atomic_futex.h", ""},
+  {"bits/atomic_timed_wait.h", ""},
+  {"bits/atomic_wait.h", ""},
   {"bits/basic_ios.h", ""},
   {"bits/basic_ios.tcc", ""},
   {"bits/basic_string.h", ""},
   {"bits/basic_string.tcc", ""},
+  {"bits/boost_concept_check.h", ""},
   {"bits/char_traits.h", ""},
+  {"bits/charconv.h", ""},
+  {"bits/chrono.h", ""},
   {"bits/codecvt.h", ""},
   {"bits/concept_check.h", ""},
+  {"bits/cow_string.h", ""},
   {"bits/cpp_type_traits.h", ""},
   {"bits/cxxabi_forced.h", ""},
   {"bits/deque.tcc", ""},
@@ -202,6 +209,10 @@
   {"bits/exception_ptr.h", ""},
   {"bits/forward_list.h", ""},
   {"bits/forward_list.tcc", ""},
+  {"bits/fs_dir.h", ""},
+  {"bits/fs_fwd.h", ""},
+  {"bits/fs_ops.h", ""},
+  {"bits/fs_path.h", ""},
   {"bits/fstream.tcc", ""},
   {"bits/functexcept.h", ""},
   {"bits/functional_hash.h", ""},
@@ -214,6 +225,7 @@
   {"bits/invoke.h", ""},
   {"bits/ios_base.h", ""},
   {"bits/istream.tcc", ""},
+  {"bits/iterator_concepts.h", ""},
   {"bits/list.tcc", ""},
   {"bits/locale_classes.h", ""},
   {"bits/locale_classes.tcc", ""},
@@ -224,8 +236,11 @@
   {"bits/locale_facets_nonio.tcc", ""},
   {"bits/localefwd.h", ""},
   {"bits/mask_array.h", ""},
+  {"bits/max_size_type.h", ""},
+  {"bits/memory_resource.h", ""},
   {"bits/memoryfwd.h", ""},
   {"bits/move.h", ""},
+  {"bits/move_only_function.h", ""},
   {"bits/nested_exception.h", ""},
   {"bits/ostream.tcc", ""},
   {"bits/ostream_insert.h", ""},
@@ -237,6 +252,12 @@
   {"bits/random.h", ""},
   {"bits/random.tcc", ""},
   {"bits/range_access.h", ""},
+  {"bits/ranges_algo.h", ""},
+  {"bits/ranges_algobase.h", ""},
+  {"bits/ranges_base.h", ""},
+  {"bits/ranges_cmp.h", ""},
+  {"bits/ranges_uninitialized.h", ""},
+  {"bits/ranges_util.h", ""},
   {"bits/refwrap.h", ""},
   {"bits/regex.h", ""},
   {"bits/regex_automaton.h", ""},
@@ -249,6 +270,7 @@
   {"bits/regex_grep_matcher.tcc", ""},
   {"bits/regex_nfa.h", ""},
   {"bits/regex_scanner.h", ""},
+  {"bits/semaphore_base.h", ""},
   {"bits/shared_ptr.h", ""},
   {"bits/shared_ptr_base.h", ""},
   {"bits/shared_ptr_atomic.h", ""},
@@ -257,6 +279,7 @@
   {"bits/std_abs.h", ""},
   {"bits/std_function.h", ""},
   {"bits/std_mutex.h", ""},
+  {"bits/std_thread.h", ""},
   {"bits/stl_algo.h", ""},
   {"bits/stl_algobase.h", ""},
   {"bits/stl_bvector.h", ""},
@@ -286,11 +309,15 @@
   {"bits/streambuf.tcc", ""},
   {"bits/streambuf_iterator.h", ""},
   {"bits/stringfwd.h", ""},
+  {"bits/this_thread_sleep.h", ""},
   {"bits/uniform_int_dist.h", ""},
+  {"bits/unique_lock.h", ""},
   {"bits/unique_ptr.h", ""},
   {"bits/unordered_map.h", ""},
   {"bits/unordered_set.h", ""},
   {"bits/uses_allocator.h", ""},
+  {"bits/uses_allocator_args.h", ""},
+  {"bits/utility.h", ""},
   {"bits/valarray_after.h", ""},
   {"bits/valarray_array.h", ""},
   {"bits/valarray_array.tcc", ""},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121997: [clang][driver] Fix compilation database dump with multiple architectures

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D121997#3577690 , @Jake-Egan wrote:

> Hi, it seems on AIX the target and arch options are ignored, so we don't get 
> the expected output for this test. Any ideas about the course of action we 
> should take?
> https://lab.llvm.org/buildbot/#/builders/214/builds/1785/steps/6/logs/FAIL__Clang__compilation_database_multiarch_c

Hey, I disabled the test on non-Darwin hosts in 
2de36d0369a5107a3f02aceebb55326adf4ad2cb 
. Your 
build bot is back to green.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121997

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


[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-06-13 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 436378.
iains marked 2 inline comments as done.
iains added a comment.

rebased, fixed the fail for explicitly-specialized-template.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/ast-dump-decl.c
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/Modules/cxx-templates.cpp
  clang/test/Modules/cxx20-10-4-ex2.cpp
  clang/test/Modules/explicitly-specialized-template.cpp
  clang/test/Modules/template-function-specialization.cpp

Index: clang/test/Modules/template-function-specialization.cpp
===
--- clang/test/Modules/template-function-specialization.cpp
+++ clang/test/Modules/template-function-specialization.cpp
@@ -51,7 +51,9 @@
   foo2(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
  // expected-note@* {{declaration here is not visible}}
   foo2();   // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
+ // expected-error@-1 {{missing '#include'; explicit specialization of 'foo2' must be declared before it is used}}
  // expected-note@* {{declaration here is not visible}}
+ // expected-note@* {{explicit specialization declared here is not reachable}}
   foo3();
   foo3();
 
Index: clang/test/Modules/explicitly-specialized-template.cpp
===
--- clang/test/Modules/explicitly-specialized-template.cpp
+++ clang/test/Modules/explicitly-specialized-template.cpp
@@ -42,6 +42,6 @@
 foo f; // expected-error {{'foo' must be declared before it is used}}
 // expected-note@* {{declaration here is not visible}}
 int bar() {
-  X x;
-  return x.print();
+  X y;
+  return y.print();
 }
Index: clang/test/Modules/cxx20-10-4-ex2.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-4-ex2.cpp
@@ -0,0 +1,60 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 std-10-4-ex2-interface.cpp \
+// RUN:  -emit-module-interface -o M.pcm -Wno-unused-value
+// RUN: %clang_cc1 -std=c++20 std-10-4-ex2-implementation.cpp \
+// RUN:  -fmodule-file=M.pcm -fsyntax-only -verify
+//--- std-10-4-ex2.h
+
+namespace N {
+struct X {};
+int d();
+int e();
+inline int f(X, int = d()) { return e(); }
+int g(X);
+int h(X);
+} // namespace N
+
+//--- std-10-4-ex2-interface.cpp
+
+module;
+
+#include "std-10-4-ex2.h"
+
+export module M;
+
+template  int use_f() {
+  N::X x;   // N::X, N, and  ::  are decl-reachable from use_f
+  return f(x, 123); // N::f is decl-reachable from use_f,
+// N::e is indirectly decl-reachable from use_f
+//   because it is decl-reachable from N::f, and
+// N::d is decl-reachable from use_f
+//   because it is decl-reachable from N::f
+//   even though it is not used in this call
+}
+
+template  int use_g() {
+  N::X x; // N::X, N, and :: are decl-reachable from use_g
+  return g((T(), x)); // N::g is not decl-reachable from use_g
+}
+
+template  int use_h() {
+  N::X x; // N::X, N, and :: are decl-reachable from use_h
+  return h((T(), x)); // N::h is not decl-reachable from use_h, but
+  // N::h is decl-reachable from use_h
+}
+
+int k = use_h();
+// use_h is decl-reachable from k, so
+// N::h is decl-reachable from k
+
+//--- std-10-4-ex2-implementation.cpp
+
+module M;
+
+int a = use_f();
+int b = use_g(); // expected-er...@std-10-4-ex2-interface.cpp:20 {{use of undeclared identifier 'g'}}
+  // expected-note@-1 {{in instantiation of function template specialization 'use_g' requested here}}
+int c = use_h();
Index: clang/test/Modules/cxx-templates.cpp
===
--- clang/test/Modules/cxx-templates.cpp
+++ clang/test/Modules/cxx-templates.cpp
@@ -252,7 +252,7 @@
 // CHECK-DUMP:  ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}>  col:{{.*}} in cxx_templates_common SomeTemplate
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
 /

[PATCH] D127452: [clang-cl][MSVC] Map /external:Wn n=1-4 to -Wsystem-headers

2022-06-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D127452#3577729 , @steplong wrote:

> Hmm do you know how I can restart the pre-merge checks? It looks like the x64 
> debian openmp tests failed. I don't think this patch is related, but I want 
> to make sure

You can rebase and upload the patch again. But those bots are pretty flaky, I 
don't think it's related to this patch either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127452

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


[PATCH] D123771: [clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 436380.
jansvoboda11 added a comment.

Replace the `Dir = File->getLastRef().getDir();` escape hatch with 
`FileMgr.getOptionalDirectoryRef(File->getDir()->getName())`. The former was 
causing failures in 
`clang/test/VFS/real-path-found-first.m` on Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123771

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -319,7 +319,8 @@
   SmallString<128> FrameworkDirName;
   FrameworkDirName += Dir.getFrameworkDir()->getName();
   llvm::sys::path::append(FrameworkDirName, SearchName + ".framework");
-  if (auto FrameworkDir = FileMgr.getDirectory(FrameworkDirName)) {
+  if (auto FrameworkDir =
+  FileMgr.getOptionalDirectoryRef(FrameworkDirName)) {
 bool IsSystem = Dir.getDirCharacteristic() != SrcMgr::C_User;
 Module = loadFrameworkModule(ModuleName, *FrameworkDir, IsSystem);
 if (Module)
@@ -334,8 +335,10 @@
   continue;
 
 bool IsSystem = Dir.isSystemHeaderDirectory();
+// Only returns None if not a normal directory, which we just checked
+DirectoryEntryRef NormalDir = *Dir.getDirRef();
 // Search for a module map file in this directory.
-if (loadModuleMapFile(Dir.getDir(), IsSystem,
+if (loadModuleMapFile(NormalDir, IsSystem,
   /*IsFramework*/false) == LMM_NewlyLoaded) {
   // We just loaded a module map file; check whether the module is
   // available now.
@@ -507,7 +510,7 @@
 /// \param DirName The name of the framework directory.
 /// \param SubmodulePath Will be populated with the submodule path from the
 /// returned top-level module to the originally named framework.
-static const DirectoryEntry *
+static Optional
 getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
SmallVectorImpl &SubmodulePath) {
   assert(llvm::sys::path::extension(DirName) == ".framework" &&
@@ -527,12 +530,10 @@
   //
   // Similar issues occur when a top-level framework has moved into an
   // embedded framework.
-  const DirectoryEntry *TopFrameworkDir = nullptr;
-  if (auto TopFrameworkDirOrErr = FileMgr.getDirectory(DirName))
-TopFrameworkDir = *TopFrameworkDirOrErr;
+  auto TopFrameworkDir = FileMgr.getOptionalDirectoryRef(DirName);
 
   if (TopFrameworkDir)
-DirName = FileMgr.getCanonicalName(TopFrameworkDir);
+DirName = FileMgr.getCanonicalName(*TopFrameworkDir);
   do {
 // Get the parent directory name.
 DirName = llvm::sys::path::parent_path(DirName);
@@ -540,7 +541,7 @@
   break;
 
 // Determine whether this directory exists.
-auto Dir = FileMgr.getDirectory(DirName);
+auto Dir = FileMgr.getOptionalDirectoryRef(DirName);
 if (!Dir)
   break;
 
@@ -1486,13 +1487,13 @@
   return false;
 
 // Determine whether this directory exists.
-auto Dir = FileMgr.getDirectory(DirName);
+auto Dir = FileMgr.getOptionalDirectoryRef(DirName);
 if (!Dir)
   return false;
 
 // Try to load the module map file in this directory.
 switch (loadModuleMapFile(*Dir, IsSystem,
-  llvm::sys::path::extension((*Dir)->getName()) ==
+  llvm::sys::path::extension(Dir->getName()) ==
   ".framework")) {
 case LMM_NewlyLoaded:
 case LMM_AlreadyLoaded:
@@ -1589,15 +1590,16 @@
   if (needModuleLookup(RequestingModule, SuggestedModule)) {
 // Find the top-level framework based on this framework.
 SmallVector SubmodulePath;
-const DirectoryEntry *TopFrameworkDir
-  = ::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath);
+Optional TopFrameworkDir =
+::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath);
+assert(TopFrameworkDir && "Could not find the top-most framework dir");
 
 // Determine the name of the top-level framework.
 StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName());
 
 // Load this framework module. If that succeeds, find the suggested module
 // for this header, if any.
-loadFrameworkModule(ModuleName, TopFrameworkDir, IsSystemFramework);
+loadFrameworkModule(ModuleName, *TopFrameworkDir, IsSystemFramework);
 
 // FIXME: This can find a module not part of ModuleName, which is
 // important so that we're consistent about whether this header
@@ -1628,39 +1630,40 @@
  StringRef OriginalModuleMapFile) {
   // Find the directory for the module. For frameworks, that may require going
   // up from the 'Modules' directory.
-  const DirectoryEntry *Dir = nullptr;
+  Optional Dir;
   if (getHeaderSearchOpts().ModuleMapFileHome

[clang] 35aaf54 - [clang][driver] fix to correctly set devtoolset on RHEL

2022-06-13 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2022-06-13T09:12:49-05:00
New Revision: 35aaf548237a4f213ba9d95de53b33c5ce1eadce

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

LOG: [clang][driver] fix to correctly set devtoolset on RHEL

This patch correctly sets the devtoolset on RHEL.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index c6ea1d026647..f4caa5e10609 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2154,7 +2154,7 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 }
 
 if (ChosenToolsetVersion > 0)
-  Prefixes.push_back(ChosenToolsetDir);
+  Prefixes.push_back(ChosenToolsetDir + "/root/usr");
   }
 
   // Fall back to /usr which is used by most non-Solaris systems.

diff  --git a/clang/unittests/Driver/ToolChainTest.cpp 
b/clang/unittests/Driver/ToolChainTest.cpp
index 33389a52c6bb..3637b10cdd66 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -587,9 +587,9 @@ TEST(ToolChainTest, Toolsets) {
 llvm::MemoryBuffer::getMemBuffer("\n"));
 
 // File needed for GCC installation detection.
-InMemoryFileSystem->addFile(
-"/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
+InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-12/root/usr/lib/gcc/"
+"x86_64-redhat-linux/11/crtbegin.o",
+0, llvm::MemoryBuffer::getMemBuffer("\n"));
 
 DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
 Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
@@ -603,9 +603,9 @@ TEST(ToolChainTest, Toolsets) {
   C->getDefaultToolChain().printVerboseInfo(OS);
 }
 EXPECT_EQ("Found candidate GCC installation: "
-  "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  
"/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Selected GCC installation: "
-  "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  
"/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Candidate multilib: .;@m64\n"
   "Selected multilib: .;@m64\n",
   S);
@@ -627,9 +627,9 @@ TEST(ToolChainTest, Toolsets) {
 llvm::MemoryBuffer::getMemBuffer("\n"));
 
 // File needed for GCC installation detection.
-InMemoryFileSystem->addFile(
-"/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
+InMemoryFileSystem->addFile("/opt/rh/devtoolset-12/root/usr/lib/gcc/"
+"x86_64-redhat-linux/11/crtbegin.o",
+0, llvm::MemoryBuffer::getMemBuffer("\n"));
 
 DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
 Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
@@ -643,9 +643,9 @@ TEST(ToolChainTest, Toolsets) {
   C->getDefaultToolChain().printVerboseInfo(OS);
 }
 EXPECT_EQ("Found candidate GCC installation: "
-  "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  "/opt/rh/devtoolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Selected GCC installation: "
-  "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  "/opt/rh/devtoolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Candidate multilib: .;@m64\n"
   "Selected multilib: .;@m64\n",
   S);



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


[PATCH] D127310: [clang][driver] fix to correctly set devtoolset on RHEL

2022-06-13 Thread Quinn Pham 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 rG35aaf548237a: [clang][driver] fix to correctly set 
devtoolset on RHEL (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127310

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -587,9 +587,9 @@
 llvm::MemoryBuffer::getMemBuffer("\n"));
 
 // File needed for GCC installation detection.
-InMemoryFileSystem->addFile(
-"/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
+InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-12/root/usr/lib/gcc/"
+"x86_64-redhat-linux/11/crtbegin.o",
+0, llvm::MemoryBuffer::getMemBuffer("\n"));
 
 DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
 Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
@@ -603,9 +603,9 @@
   C->getDefaultToolChain().printVerboseInfo(OS);
 }
 EXPECT_EQ("Found candidate GCC installation: "
-  "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  
"/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Selected GCC installation: "
-  "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  
"/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Candidate multilib: .;@m64\n"
   "Selected multilib: .;@m64\n",
   S);
@@ -627,9 +627,9 @@
 llvm::MemoryBuffer::getMemBuffer("\n"));
 
 // File needed for GCC installation detection.
-InMemoryFileSystem->addFile(
-"/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
+InMemoryFileSystem->addFile("/opt/rh/devtoolset-12/root/usr/lib/gcc/"
+"x86_64-redhat-linux/11/crtbegin.o",
+0, llvm::MemoryBuffer::getMemBuffer("\n"));
 
 DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
 Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
@@ -643,9 +643,9 @@
   C->getDefaultToolChain().printVerboseInfo(OS);
 }
 EXPECT_EQ("Found candidate GCC installation: "
-  "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  "/opt/rh/devtoolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Selected GCC installation: "
-  "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  "/opt/rh/devtoolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Candidate multilib: .;@m64\n"
   "Selected multilib: .;@m64\n",
   S);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2154,7 +2154,7 @@
 }
 
 if (ChosenToolsetVersion > 0)
-  Prefixes.push_back(ChosenToolsetDir);
+  Prefixes.push_back(ChosenToolsetDir + "/root/usr");
   }
 
   // Fall back to /usr which is used by most non-Solaris systems.


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -587,9 +587,9 @@
 llvm::MemoryBuffer::getMemBuffer("\n"));
 
 // File needed for GCC installation detection.
-InMemoryFileSystem->addFile(
-"/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
+InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-12/root/usr/lib/gcc/"
+"x86_64-redhat-linux/11/crtbegin.o",
+0, llvm::MemoryBuffer::getMemBuffer("\n"));
 
 DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
 Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
@@ -603,9 +603,9 @@
   C->getDefaultToolChain().printVerboseInfo(OS);
 }
 EXPECT_EQ("Found candidate GCC installation: "
-  "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
   "Selected GCC installation: "
-  "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
+  "/opt/rh/gcc-

[PATCH] D127270: [clang-format] Add space in placement new expression

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



Comment at: clang/lib/Format/Format.cpp:1314
   LLVMStyle.SpaceBeforeParensOptions.AfterIfMacros = true;
+  LLVMStyle.SpaceBeforeParensOptions.AfterPlacementNew = true;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;

omarahmed wrote:
> HazardyKnusperkeks wrote:
> > This isn't needed, because the default CTor initializes it with true.
> > Or you change that, I don't know right now why all other attributes are 
> > initialized with false.
> I think they are initialized with false so that when we come to [this 
> case](https://github.com/llvm/llvm-project/blob/54ae4ca7550a81fd1fa9e484904d553af8fbb2fd/clang/lib/Format/Format.cpp#L1155),
>  it breaks while all of them are false. (I am not sure so) I will try to add 
> a test to cover 'SBPO_Never' but after converting it to enum.
Then you need to set it to `false` in the CTor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

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


[PATCH] D127638: [clang][sema] Provide better diagnostic for missing template parameters

2022-06-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: dblaikie, aaron.ballman.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes https://github.com/llvm/llvm-project/issues/55962

i.e. instead of the output being

  ./test.cpp:5:9: error: 'x' is not a class, namespace, or enumeration
  int y = x::a;
  ^
  ./test.cpp:2:8: note: 'x' declared here
  struct x;
 ^
  1 error generated.

it is now:

  ./test.cpp:5:9: error: use of class template 'x' requires template arguments
  int y = x::a;
  ^
  ./test.cpp:2:8: note: template is declared here
  struct x;
 ^
  1 error generated.

Note that the call to `isTemplateName()` is basically copied from 
`DiagnoseUnknownTypeName()` in `SemaDecl.cpp`. However, just calling that from 
`SemaCXXScopeSpec.cpp` as well makes the `SemaObjCXX/property-dot-error.mm` 
test fail, because it now outputs

  clang/test/SemaObjCXX/propert-dot-error.mm Line 67: unknown type name 'D'; 
did you mean 'D'?
  clang/test/SemaObjCXX/propert-dot-error.mm Line 68: unknown type name 'D'; 
did you mean 'D'?

and I don't know enough about objc to fix this, but if anyone has some pointers 
I'd be happy to avoid the code duplication.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127638

Files:
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/test/SemaCXX/nested-name-spec.cpp


Index: clang/test/SemaCXX/nested-name-spec.cpp
===
--- clang/test/SemaCXX/nested-name-spec.cpp
+++ clang/test/SemaCXX/nested-name-spec.cpp
@@ -473,3 +473,10 @@
 x: goto x;
   }
 }
+
+template 
+struct x; // expected-note {{template is declared here}}
+
+template 
+int issue55962 = x::a; // expected-error {{use of class template 'x' requires 
template arguments}} \
+   // expected-warning {{variable templates are a C++14 
extension}}
Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -828,15 +828,30 @@
   }
 
   if (!Found.empty()) {
-if (TypeDecl *TD = Found.getAsSingle())
+if (TypeDecl *TD = Found.getAsSingle()) {
   Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
   << Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus;
-else {
-  Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
-  << IdInfo.Identifier << getLangOpts().CPlusPlus;
-  if (NamedDecl *ND = Found.getAsSingle())
-Diag(ND->getLocation(), diag::note_entity_declared_at)
-<< IdInfo.Identifier;
+} else {
+  // Try to diagnose x::y where x is a class template and the
+  // template arguments are missing.
+  UnqualifiedId Name;
+  Name.setIdentifier(IdInfo.Identifier, IdInfo.IdentifierLoc);
+  CXXScopeSpec EmptySS;
+  TemplateTy TemplateResult;
+  bool MemberOfUnknownSpecialization;
+  if (isTemplateName(S, SS, /*hasTemplateKeyword=*/false, Name, nullptr,
+ true, TemplateResult,
+ MemberOfUnknownSpecialization) == TNK_Type_template) {
+diagnoseMissingTemplateArguments(TemplateResult.get(),
+ IdInfo.IdentifierLoc);
+  } else {
+Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
+<< IdInfo.Identifier << getLangOpts().CPlusPlus;
+if (NamedDecl *ND = Found.getAsSingle()) {
+  Diag(ND->getLocation(), diag::note_entity_declared_at)
+  << IdInfo.Identifier;
+}
+  }
 }
   } else if (SS.isSet())
 Diag(IdInfo.IdentifierLoc, diag::err_no_member) << IdInfo.Identifier


Index: clang/test/SemaCXX/nested-name-spec.cpp
===
--- clang/test/SemaCXX/nested-name-spec.cpp
+++ clang/test/SemaCXX/nested-name-spec.cpp
@@ -473,3 +473,10 @@
 x: goto x;
   }
 }
+
+template 
+struct x; // expected-note {{template is declared here}}
+
+template 
+int issue55962 = x::a; // expected-error {{use of class template 'x' requires template arguments}} \
+   // expected-warning {{variable templates are a C++14 extension}}
Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -828,15 +828,30 @@
   }
 
   if (!Found.empty()) {
-if (TypeDecl *TD = Found.getAsSingle())
+if (TypeDecl *TD = Found.getAsSingle()) {
   Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
   << Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus;
-else {
-  Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
-  << IdInfo.Identifier << getLangOpts().CPlusP

[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-06-13 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked 3 inline comments as done.
iains added a comment.

In D126694#3576853 , @ChuanqiXu wrote:

> In D126694#3576602 , @iains wrote:
>
>> @ChuanqiXu - I changed the module ownership name to "ModuleDiscardable" - 
>> because, while we are permitted to discard these, we might choose not to (to 
>> give your better diagnostics) - but we still need to treat them as 
>> non-reachable and non-visible.  Please could you examine what is happening 
>> with `Modules/explicitly-specialized-template.cpp` where there a multiple 
>> error messages for each (intentionally) failing line .. add the test from 
>> the std.
>
> I've looked into this. The multiple duplicated diagnostic message is a legacy 
> problem. I tried to fix it but it is hard (change it would break many other 
> tests). To filter out the redundant duplicated diagnostic message, you could 
> use '+1' suffix after `expected-error`. For example: 
> https://github.com/llvm/llvm-project/blob/16ca490f450ea3ceaeda92addd8546967af4b2e1/clang/test/Modules/cxx-templates.cpp#L215-L232
>  BTW, after I filtered out the duplicated diagnostic message,

This was not the problem in this particular case - but (for reference) is there 
an issue for the duplicated diagnostics? - that seems not very user-friendly, 
especially since C++ emits a lot of long diagnostics already.

> I find the complains the use of `foo` in the module purview, which is 
> not right and should be a bug of this revision.

Yes, fixed with the latest upload; the provisions of [module.global.frag] p3 
are quite complex, it's easy to miss one (and now the 
`explicitly-specialized-template.cpp` tase passes too)

>> @rsmith
>>  this seems like an awful lot of work that has to be done for every decl we 
>> mark used in the module purview - we cannot even short-cut ones that are not 
>> in the GMF, since the provisions of [module.global.frag] p3.5 seem to allow 
>> this to happen for indirect reaching.  I wonder if I misread the std.
>
> Yeah, and I am not sure what is better idea here. I tried to implement GMF 
> decl elision before. My first idea is similar to your first revision. But I 
> tried to implement indirect discarding that time. So I chose to traverse the 
> decls in GMF until a fixed point when we handle the end of the TU. It looks 
> bad clearly (the time complexity is not satisfying). So I didn't post it up.
>
>> I am also wondering what is supposed to happen when an interface makes a 
>> type reachable, but that type is not visible to the implementation .. it 
>> seems to mean that interfaces would have to add using declarations for each 
>> such type.
>
> @rsmith should be the best to answer here. But I am trying to answer it. If  
> 'the implementation' means the implementation unit, I think the type is 
> naturally visible to the implementation unit. We could find the example in: 
> module.interface-example5 
>  .

That is not the problem I am describing - which more like:

type.h:
typedef int MyInt;

mod-interface.cpp:
module;
#include "type.h"
export module A;

MyInt foo (); // makes MyInt reachable, but not visible.

mod-imp.cpp:
module A;

MyInt foo () { return 42; } // will not compile because the type declaration is 
not visible.

  I am told that this is the intention .. it just seems a wee bit odd.




Comment at: clang/include/clang/AST/DeclBase.h:240
+/// GMF is part.
+ModuleUnreachable
   };

ChuanqiXu wrote:
> iains wrote:
> > ChuanqiXu wrote:
> > > Would you like to use the term 'ModuleDiscarded'? My point is that not 
> > > all unreachable declaration in modules are in GMF. And the term `discard` 
> > > is used in standard to describe it. So it looks better.
> > `ModuleDiscardable` Is better, it says we have permission to discard it (so 
> > that it cannot be used or reached) but allows for the case we elect to keep 
> > them around for better diagnostics.  You might want to consider renaming 
> > the wrapper function similarly?
> > 
> > 
> From my reading, it looks like the std says "we should discard things in 
> following cases... although there are some cases we could make decision by 
> ourself". So it looks like `ModuleDiscarded` is better than 
> `ModuleDiscardable` to me.
I think we should observe the "as if" rule here, and say that the 
implementation would behave "as if" the decls were removed (but we choose to 
leave them, at least for now, because that improves the diagnostic you 
mentioned before).

The name should be helpful to programmers - if we make it "Discarded" then it 
will surely be confusing to a programmer to find that the decls are still 
present - "Discardable" says the right thing (that you should not use them 
because at some time they could be removed).




Comment at: clang/include/clang/AST/DeclBase.h:647
+  bool isDiscardedInGlobalModuleFragment(

[PATCH] D127518: [Diagnostics] Fix inconsistent shift-overflow warnings in C++20

2022-06-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: clang-language-wg.
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:11422
   llvm::APSInt Left = LHSResult.Val.getInt();
 
   // If LHS does not have a signed type and non-negative value

... to early here instead, and it should also check `isSignedOverflowDefined()` 
(note: we should probably fix `SignedOverflowBehavior` in LangOptions.def to be 
set based on the C++ language mode instead of needing to check for C++20 
specifically)



Comment at: clang/lib/Sema/SemaExpr.cpp:11425-11426
   // then, the behavior is undefined before C++2a. Warn about it.
   if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined() &&
   !S.getLangOpts().CPlusPlus20) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),

and then we can remove the check for signed overflow defined or C++20 here 
because we've already bailed out.



Comment at: clang/lib/Sema/SemaExpr.cpp:11456-11457
 
+  if (S.getLangOpts().CPlusPlus20)
+return;
+

I think this should move up...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127518

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


[PATCH] D126479: [Clang] Allow 'Complex float __attribute__((mode(HC)))'

2022-06-13 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

The code changes and test updates all look good to me.  Please add a release 
note to `clang/docs/ReleaseNotes.rst`; I'll be happy to approve after that is 
done. It would be great to get an additional approval on this; I'm not an 
expert here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126479

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


[PATCH] D127518: [Diagnostics] Fix inconsistent shift-overflow warnings in C++20

2022-06-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:11425-11426
   // then, the behavior is undefined before C++2a. Warn about it.
   if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined() &&
   !S.getLangOpts().CPlusPlus20) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),

aaron.ballman wrote:
> and then we can remove the check for signed overflow defined or C++20 here 
> because we've already bailed out.
I think we'd want to remove the CPlusPlus20 check here, right? Signed-overflow 
should cover this case as well, and the check for C++20 below is no longer 
necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127518

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


[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D127593#3576538 , @royjacobson 
wrote:

> Hi Javier, thank you for submitting this patch!
>
> As far as I could tell, this patch implements the CWG2171 defect report from 
> 2016: https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2171. 
> That means that you'll have to add a test inside 
> clang/test/CXX/drs/dr21xx.cpp to make sure it shows on the DRs status page.
>
> This change is also a large ABI break, which means it has to be considered 
> carefully. I think the best approach here would be to revert to the previous 
> behavior when the -fclang-abi-compat flag is used for clang <= 14, but I'm 
> not sure about this. I would like the approval of someone with more ABI 
> experience here.
>
> The code itself and the tests look good! If you'll need help with the changes 
> I mentioned please let me know.

Yep, this needs to add a new ABI value to the -fclang-abi-compat stuff, so 
starting with LangOptions.h's ClangABI enum, probably a Ver15 value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D127519: [clang-cl] Accept /FA[c][s][u], but ignore the arguments

2022-06-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> Previously, /FAsc would emit a warning. Now, it will just do what /FA does.

I suppose we could still warn that the 's' and 'c' parts are ignored.. though I 
suppose that becomes evident from the output file..

If we're going to treat them the same, how about just making the _SLASH_FA 
option a CLJoined and dropping _SLASH_FA_joined?

> I'm not sure which test file to modify and how to test this. I do see it 
> generating the .asm file now when I pass /FAsc, not the .codd file though 
> since we are ignoring the c argument.

There are some /FA tests in clang/test/Driver/cl-options.c and 
clang/test/Driver/cl-outputs.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127519

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


[PATCH] D127641: [clang-cl][MSVC] Add default /Zc conformance arguments

2022-06-13 Thread Stephen Long via Phabricator via cfe-commits
steplong created this revision.
Herald added a project: All.
steplong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch doesn't turn on all the "on by default" /Zc arguments, but
this should be a good enough starting point.

https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127641

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-zc.cpp
  clang/tools/driver/driver.cpp


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -234,6 +234,25 @@
   }
 }
 
+static void insertDefaultClangCLZcConformanceArgs(
+SmallVectorImpl &ArgVector) {
+  // Put the /Zc arguments at the start of argument list so that arguments
+  // specified on
+  // the command line could override them. Avoid putting them at index 0, as an
+  // option
+  // like '-cc1' must remain the first.
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
+++InsertionPoint;
+
+  const char *arr[] = {
+  "/Zc:auto", "/Zc:forScope",   "/Zc:implicitNoexcept",
+  "/Zc:sizedDealloc", "/Zc:threadSafeInit", "/Zc:wchar_t"};
+
+  ArgVector.insert(ArgVector.begin() + InsertionPoint, std::begin(arr),
+   std::end(arr));
+}
+
 static void getCLEnvVarOptions(std::string &EnvValue, llvm::StringSaver &Saver,
SmallVectorImpl &Opts) {
   llvm::cl::TokenizeWindowsCommandLine(EnvValue, Saver, Opts);
@@ -473,6 +492,9 @@
 
   insertTargetAndModeArgs(TargetAndMode, Args, SavedStrings);
 
+  if (ClangCLMode)
+insertDefaultClangCLZcConformanceArgs(Args);
+
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   if (!UseNewCC1Process) {
Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,9 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
+// DEFAULT: "-fsized-deallocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
 // isn't explicitly passed.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6701,6 +6701,7 @@
 def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
+def _SLASH_Zc_implicitNoexcept : CLIgnoredFlag<"Zc:implicitNoexcept">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
 def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">;
 def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">;


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -234,6 +234,25 @@
   }
 }
 
+static void insertDefaultClangCLZcConformanceArgs(
+SmallVectorImpl &ArgVector) {
+  // Put the /Zc arguments at the start of argument list so that arguments
+  // specified on
+  // the command line could override them. Avoid putting them at index 0, as an
+  // option
+  // like '-cc1' must remain the first.
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
+++InsertionPoint;
+
+  const char *arr[] = {
+  "/Zc:auto", "/Zc:forScope",   "/Zc:implicitNoexcept",
+  "/Zc:sizedDealloc", "/Zc:threadSafeInit", "/Zc:wchar_t"};
+
+  ArgVector.insert(ArgVector.begin() + InsertionPoint, std::begin(arr),
+   std::end(arr));
+}
+
 static void getCLEnvVarOptions(std::string &EnvValue, llvm::StringSaver &Saver,
SmallVectorImpl &Opts) {
   llvm::cl::TokenizeWindowsCommandLine(EnvValue, Saver, Opts);
@@ -473,6 +492,9 @@
 
   insertTargetAndModeArgs(TargetAndMode, Args, SavedStrings);
 
+  if (ClangCLMode)
+insertDefaultClangCLZcConformanceArgs(Args);
+
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   if (!UseNewCC1Process) {
Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,9 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
+// DEFAULT: "-fsized-deallocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will di

[PATCH] D127460: Rename GCCBuiltin into ClangBuiltin

2022-06-13 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision as: libc++abi.
ldionne added a comment.

LGTM for libc++abi once my comment is addressed, which should make the libc++ 
CI pass. Please don't submit this until you have a green check-mark from the 
libc++ CI.




Comment at: llvm/include/llvm/ADT/Triple.h:1031
   /// @}
   /// @name Static helpers for IDs.
   /// @{

Comment applies to `test_demangle.pass.cpp` (it's a binary file so I can't 
comment on it). The test is currently failing because you need to change 
`_ZN4llvm9Intrinsic25getIntrinsicForClangBuiltinEPKcS2_` to 
`_ZN4llvm9Intrinsic27getIntrinsicForClangBuiltinEPKcS2_`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127460

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


[PATCH] D127641: [clang-cl][MSVC] Add default /Zc conformance arguments

2022-06-13 Thread Stephen Long via Phabricator via cfe-commits
steplong added reviewers: rnk, hans, thakis.
steplong added a comment.

I'm not sure how to check for `/std:` at this stage to turn on arguments like 
`/Zc:alignedNew`




Comment at: clang/test/Driver/cl-zc.cpp:98
 // thread safe statics are off for versions < 19.
 // RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck 
-check-prefix=NoThreadSafeStatics %s
 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | 
FileCheck -check-prefix=NoThreadSafeStatics %s

This line will fail, but I can't find any documentation on thread safe statics 
being off for versions < 19. 
https://docs.microsoft.com/en-us/cpp/build/reference/zc-threadsafeinit-thread-safe-local-static-initialization?view=msvc-170
 says Visual Studio 2015 implements this by default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

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


[PATCH] D127452: [clang-cl][MSVC] Map /external:Wn n=1-4 to -Wsystem-headers

2022-06-13 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 436394.
steplong added a comment.

- Rebase patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127452

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -752,4 +752,12 @@
 // RUN: %clang_cl /JMC /Z7 /c -### -- %s 2>&1 | FileCheck %s --check-prefix JMC
 // JMC: -fjmc
 
+// RUN: %clang_cl /external:W0 /c -### -- %s 2>&1 | FileCheck 
-check-prefix=EXTERNAL_W0 %s
+// RUN: %clang_cl /external:W1 /c -### -- %s 2>&1 | FileCheck 
-check-prefix=EXTERNAL_Wn %s
+// RUN: %clang_cl /external:W2 /c -### -- %s 2>&1 | FileCheck 
-check-prefix=EXTERNAL_Wn %s
+// RUN: %clang_cl /external:W3 /c -### -- %s 2>&1 | FileCheck 
-check-prefix=EXTERNAL_Wn %s
+// RUN: %clang_cl /external:W4 /c -### -- %s 2>&1 | FileCheck 
-check-prefix=EXTERNAL_Wn %s
+// EXTERNAL_W0: "-Wno-system-headers"
+// EXTERNAL_Wn: "-Wsystem-headers"
+
 void f(void) { }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -775,6 +775,8 @@
   MetaVarName<"">;
 def Wall : Flag<["-"], "Wall">, Group, Flags<[CC1Option, HelpHidden]>;
 def WCL4 : Flag<["-"], "WCL4">, Group, Flags<[CC1Option, HelpHidden]>;
+def Wsystem_headers : Flag<["-"], "Wsystem-headers">, Group, 
Flags<[CC1Option, HelpHidden]>;
+def Wno_system_headers : Flag<["-"], "Wno-system-headers">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, 
Flags<[CC1Option]>,
   HelpText<"Enable warnings for deprecated constructs and define 
__DEPRECATED">;
 def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, 
Flags<[CC1Option]>;
@@ -6468,6 +6470,11 @@
   Alias, AliasArgs<["invalid-source-encoding"]>;
 def _SLASH_validate_charset_ : CLFlag<"validate-charset-">,
   Alias, AliasArgs<["no-invalid-source-encoding"]>;
+def _SLASH_external_W0 : CLFlag<"external:W0">, HelpText<"Ignore warnings from 
system headers (default)">, Alias;
+def _SLASH_external_W1 : CLFlag<"external:W1">, HelpText<"Enable 
-Wsystem-headers">, Alias;
+def _SLASH_external_W2 : CLFlag<"external:W2">, HelpText<"Enable 
-Wsystem-headers">, Alias;
+def _SLASH_external_W3 : CLFlag<"external:W3">, HelpText<"Enable 
-Wsystem-headers">, Alias;
+def _SLASH_external_W4 : CLFlag<"external:W4">, HelpText<"Enable 
-Wsystem-headers">, Alias;
 def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias;
 def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias;
 def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -752,4 +752,12 @@
 // RUN: %clang_cl /JMC /Z7 /c -### -- %s 2>&1 | FileCheck %s --check-prefix JMC
 // JMC: -fjmc
 
+// RUN: %clang_cl /external:W0 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_W0 %s
+// RUN: %clang_cl /external:W1 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s
+// RUN: %clang_cl /external:W2 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s
+// RUN: %clang_cl /external:W3 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s
+// RUN: %clang_cl /external:W4 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s
+// EXTERNAL_W0: "-Wno-system-headers"
+// EXTERNAL_Wn: "-Wsystem-headers"
+
 void f(void) { }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -775,6 +775,8 @@
   MetaVarName<"">;
 def Wall : Flag<["-"], "Wall">, Group, Flags<[CC1Option, HelpHidden]>;
 def WCL4 : Flag<["-"], "WCL4">, Group, Flags<[CC1Option, HelpHidden]>;
+def Wsystem_headers : Flag<["-"], "Wsystem-headers">, Group, Flags<[CC1Option, HelpHidden]>;
+def Wno_system_headers : Flag<["-"], "Wno-system-headers">, Group, Flags<[CC1Option, HelpHidden]>;
 def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, Flags<[CC1Option]>,
   HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">;
 def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Flags<[CC1Option]>;
@@ -6468,6 +6470,11 @@
   Alias, AliasArgs<["invalid-source-encoding"]>;
 def _SLASH_validate_charset_ : CLFlag<"validate-charset-">,
   Alias, AliasArgs<["no-invalid-source-encoding"]>;
+def _SLASH_external_W0 : CLFlag<"external:W0">, HelpText<"Ignore warnings from system headers (default)">, Alias;
+def _SLASH_external_W1 : CLFlag<"external:W1">, HelpText<"Enable -Wsystem-headers">, Alias;
+def _SLASH_external_W2 : CLFlag<"external:W2">, HelpText<"Enable -Wsystem-hea

[PATCH] D127201: [clang] Add tests for statement expression in initializers

2022-06-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

The command line on one of the tests is a little strange to me, and I don't see 
the need for the -std=gnu11 on either, but the test content itself looks fine 
enough to me.




Comment at: clang/test/CodeGen/stmtexpr-init.c:1
+// RUN: %clang_cc1 -O -std=gnu11 %s -emit-llvm -o - | FileCheck %s
+

why the -std=gnu11 here?  I would assume our default would be enough?  Also, 
why the opt-flag?  That likely is unnecessary/will cause 'bad things' to 
happen.  Clang tests typically don't use the opt flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127201

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


[PATCH] D126291: [flang][Driver] Update link job on windows

2022-06-13 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/test/Driver/linker-flags.f90:28
+
+! GNU-WITHOUTLM-LABEL:  "{{.*}}ld" 
+! GNU-WITHOUTLM-SAME: "[[object_file]]"

I think that GNU in this case might be a bit misleading. These linker 
invocations are defined in almost completely independent toolchains: [[ 
https://github.com/llvm/llvm-project/blob/b9a7dea9171416a998e4fafb9f76baa167b8/clang/lib/Driver/ToolChains/Darwin.h#L33-L47
 | MachOTool ]], [[ 
https://github.com/llvm/llvm-project/blob/b9a7dea9171416a998e4fafb9f76baa167b8/clang/lib/Driver/ToolChains/Gnu.h#L40-L51
 | gnutools ]].

I't be inclined to try this instead:
```
! RUN: %flang -### -flang-experimental-exec -target ppc64le-linux-gnu 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
! RUN: %flang -### -flang-experimental-exec -target aarch64-apple-darwin 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN
! RUN: %flang -### -flang-experimental-exec -target x86_64-windows-gnu 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW
! RUN: %flang -### -flang-experimental-exec -target aarch64-windows-msvc 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC
```

This will lead to more duplication, but would clarify things a bit.


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

https://reviews.llvm.org/D126291

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


[clang] d9390b6 - Reapply "[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()"

2022-06-13 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2022-06-13T17:03:32+02:00
New Revision: d9390b6ac387345e7d3348bfc648929bc349d6b1

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

LOG: Reapply "[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()"

This reverts commit 340654e0f246cddb3fb6ebddb843ade9bfcff0a5, essentially 
reapplying 1d3ba05e4a288b49287fe997763e90234b8c62db.

The test VFS/real-path-found-first.m that was failing on Windows is now passing 
with a workaround.

Added: 


Modified: 
clang/include/clang/Lex/HeaderSearch.h
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index b523ad5ef9ff2..1b7eda333b6bd 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -727,8 +727,7 @@ class HeaderSearch {
   /// frameworks.
   ///
   /// \returns The module, if found; otherwise, null.
-  Module *loadFrameworkModule(StringRef Name,
-  const DirectoryEntry *Dir,
+  Module *loadFrameworkModule(StringRef Name, DirectoryEntryRef Dir,
   bool IsSystem);
 
   /// Load all of the module maps within the immediate subdirectories
@@ -884,7 +883,7 @@ class HeaderSearch {
 
   LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
 bool IsSystem,
-const DirectoryEntry *Dir,
+DirectoryEntryRef Dir,
 FileID ID = FileID(),
 unsigned *Offset = nullptr);
 
@@ -908,8 +907,8 @@ class HeaderSearch {
   ///
   /// \returns The result of attempting to load the module map file from the
   /// named directory.
-  LoadModuleMapResult loadModuleMapFile(const DirectoryEntry *Dir,
-bool IsSystem, bool IsFramework);
+  LoadModuleMapResult loadModuleMapFile(DirectoryEntryRef Dir, bool IsSystem,
+bool IsFramework);
 };
 
 /// Apply the header search options to get given HeaderSearch object.

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 0b9727cc7cd30..85804bc83eb74 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -319,7 +319,8 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, 
StringRef SearchName,
   SmallString<128> FrameworkDirName;
   FrameworkDirName += Dir.getFrameworkDir()->getName();
   llvm::sys::path::append(FrameworkDirName, SearchName + ".framework");
-  if (auto FrameworkDir = FileMgr.getDirectory(FrameworkDirName)) {
+  if (auto FrameworkDir =
+  FileMgr.getOptionalDirectoryRef(FrameworkDirName)) {
 bool IsSystem = Dir.getDirCharacteristic() != SrcMgr::C_User;
 Module = loadFrameworkModule(ModuleName, *FrameworkDir, IsSystem);
 if (Module)
@@ -334,8 +335,10 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, 
StringRef SearchName,
   continue;
 
 bool IsSystem = Dir.isSystemHeaderDirectory();
+// Only returns None if not a normal directory, which we just checked
+DirectoryEntryRef NormalDir = *Dir.getDirRef();
 // Search for a module map file in this directory.
-if (loadModuleMapFile(Dir.getDir(), IsSystem,
+if (loadModuleMapFile(NormalDir, IsSystem,
   /*IsFramework*/false) == LMM_NewlyLoaded) {
   // We just loaded a module map file; check whether the module is
   // available now.
@@ -507,7 +510,7 @@ Optional DirectoryLookup::LookupFile(
 /// \param DirName The name of the framework directory.
 /// \param SubmodulePath Will be populated with the submodule path from the
 /// returned top-level module to the originally named framework.
-static const DirectoryEntry *
+static Optional
 getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
SmallVectorImpl &SubmodulePath) {
   assert(llvm::sys::path::extension(DirName) == ".framework" &&
@@ -527,12 +530,10 @@ getTopFrameworkDir(FileManager &FileMgr, StringRef 
DirName,
   //
   // Similar issues occur when a top-level framework has moved into an
   // embedded framework.
-  const DirectoryEntry *TopFrameworkDir = nullptr;
-  if (auto TopFrameworkDirOrErr = FileMgr.getDirectory(DirName))
-TopFrameworkDir = *TopFrameworkDirOrErr;
+  auto TopFrameworkDir = FileMgr.getOptionalDirectoryRef(DirName);
 
   if (TopFrameworkDir)
-DirName = FileMgr.getCanonicalName(TopFrameworkDir);
+DirName = FileMgr.getCanonicalName(*TopFrameworkDir);
   do {
 // Get the parent directory name.
 DirName = llvm::sys::path::parent_path(Dir

[PATCH] D125094: [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

2022-06-13 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 436396.
pratlucas added a comment.

Fixing assertion failure caused by incorrect use of tSTRr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125094

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMFrameLowering.cpp
  llvm/lib/Target/ARM/ARMFrameLowering.h
  llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
  llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
  llvm/test/CodeGen/ARM/frame-chain-reserved-fp.ll
  llvm/test/CodeGen/ARM/frame-chain.ll
  llvm/test/CodeGen/Thumb/frame-access.ll
  llvm/test/CodeGen/Thumb/frame-chain-reserved-fp.ll
  llvm/test/CodeGen/Thumb/frame-chain.ll

Index: llvm/test/CodeGen/Thumb/frame-chain.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb/frame-chain.ll
@@ -0,0 +1,288 @@
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all | FileCheck %s --check-prefixes=FP,LEAF-FP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP-AAPCS
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf | FileCheck %s --check-prefixes=FP,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP-AAPCS
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none | FileCheck %s --check-prefixes=NOFP,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP-AAPCS
+
+define dso_local noundef i32 @leaf(i32 noundef %0) {
+; LEAF-FP-LABEL: leaf:
+; LEAF-FP:   @ %bb.0:
+; LEAF-FP-NEXT:.pad #4
+; LEAF-FP-NEXT:sub sp, #4
+; LEAF-FP-NEXT:str r0, [sp]
+; LEAF-FP-NEXT:adds r0, r0, #4
+; LEAF-FP-NEXT:add sp, #4
+; LEAF-FP-NEXT:bx lr
+;
+; LEAF-FP-AAPCS-LABEL: leaf:
+; LEAF-FP-AAPCS:   @ %bb.0:
+; LEAF-FP-AAPCS-NEXT:.save {lr}
+; LEAF-FP-AAPCS-NEXT:push {lr}
+; LEAF-FP-AAPCS-NEXT:mov lr, r11
+; LEAF-FP-AAPCS-NEXT:.save {r11}
+; LEAF-FP-AAPCS-NEXT:push {lr}
+; LEAF-FP-AAPCS-NEXT:.setfp r11, sp
+; LEAF-FP-AAPCS-NEXT:mov r11, sp
+; LEAF-FP-AAPCS-NEXT:.pad #4
+; LEAF-FP-AAPCS-NEXT:sub sp, #4
+; LEAF-FP-AAPCS-NEXT:str r0, [sp]
+; LEAF-FP-AAPCS-NEXT:adds r0, r0, #4
+; LEAF-FP-AAPCS-NEXT:add sp, #4
+; LEAF-FP-AAPCS-NEXT:pop {r1}
+; LEAF-FP-AAPCS-NEXT:mov r11, r1
+; LEAF-FP-AAPCS-NEXT:pop {r1}
+; LEAF-FP-AAPCS-NEXT:bx r1
+;
+; LEAF-NOFP-LABEL: leaf:
+; LEAF-NOFP:   @ %bb.0:
+; LEAF-NOFP-NEXT:.pad #4
+; LEAF-NOFP-NEXT:sub sp, #4
+; LEAF-NOFP-NEXT:str r0, [sp]
+; LEAF-NOFP-NEXT:adds r0, r0, #4
+; LEAF-NOFP-NEXT:add sp, #4
+; LEAF-NOFP-NEXT:bx lr
+;
+; LEAF-NOFP-AAPCS-LABEL: leaf:
+; LEAF-NOFP-AAPCS:   @ %bb.0:
+; LEAF-NOFP-AAPCS-NEXT:.pad #4
+; LEAF-NOFP-AAPCS-NEXT:sub sp, #4
+; LEAF-NOFP-AAPCS-NEXT:str r0, [sp]
+; LEAF-NOFP-AAPCS-NEXT:adds r0, r0, #4
+; LEAF-NOFP-AAPCS-NEXT:add sp, #4
+; LEAF-NOFP-AAPCS-NEXT:bx lr
+  %2 = alloca i32, align 4
+  store i32 %0, i32* %2, align 4
+  %3 = load i32, i32* %2, align 4
+  %4 = add nsw i32 %3, 4
+  ret i32 %4
+}
+
+define dso_local noundef i32 @non_leaf(i32 noundef %0) {
+; FP-LABEL: non_leaf:
+; FP:   @ %bb.0:
+; FP-NEXT:.save {r7, lr}
+; FP-NEXT:push {r7, lr}
+; FP-NEXT:.setfp r7, sp
+; FP-NEXT:add r7, sp, #0
+; FP-NEXT:.pad #8
+; FP-NEXT:sub sp, #8
+; FP-NEXT:str r0, [sp, #4]
+; FP-NEXT:bl leaf
+; FP-NEXT:adds r0, r0, #1
+; FP-NEXT:add sp, #8
+; FP-NEXT:pop {r7}
+; FP-NEXT:pop {r1}
+; FP-NEXT:bx r1
+;
+; FP-AAPCS-LABEL: non_leaf:
+; FP-AAPCS:   @ %bb.0:
+; FP-AAPCS-NEXT:.save {lr}
+; FP-AAPCS-NEXT:push {lr}
+; FP-AAPCS-NEXT:mov lr, r11
+; FP-AAPCS-NEXT:.save {r11}
+; FP-AAPCS-NEXT:push {lr}
+; FP-AAPCS-NEXT:.setfp r11, sp
+; FP-AAPCS-NEXT:mov r11, sp
+; FP-AAPCS-NEXT:.pad #8
+; FP-AAPCS-NEXT:sub sp, #8
+; FP

[PATCH] D126061: [clang] Reject non-declaration C++11 attributes on declarations

2022-06-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D126061#3577054 , @mboehme wrote:

> @aaron.ballman Any further comments from you on this change?

Mostly just nits from me at this point, plus some answers to questions I had 
missed previously.

> There is some breakage in the pre-merge checks, but it looks as if it's 
> pre-existing breakage. See the comment-only change here that looks as if it 
> exhibits similar breakage:
>
> https://reviews.llvm.org/D127494

I agree that the precommit CI failures look unrelated to this patch.




Comment at: clang/include/clang/Basic/AttributeCommonInfo.h:153
 // FIXME: Use a better mechanism to determine this.
+// We use this in `isCXX11Attribute` below, so it _should_ only return
+// true for the `alignas` spelling, but it currently also returns true

Now that C23 has attributes, it's also not clear whether `_Alignas` will be 
handled slightly differently in the future as an attribute rather than a 
declaration specifier as happened with `_Noreturn` for C23. So agreed this is a 
tricky area.



Comment at: clang/include/clang/Sema/DeclSpec.h:1916
+  /// declaration, i.e. `x` and `y` in this case.
+  Declarator(const DeclSpec &ds, const ParsedAttributesView &DeclarationAttrs,
+ DeclaratorContext C)

I know it's pre-existing code, but since you're updating the parameters and 
adding some great comments, can you rename `ds` to `DS` per coding style guides?



Comment at: clang/include/clang/Sema/DeclSpec.h:1928-1930
+assert(llvm::all_of(DeclarationAttrs, [](const ParsedAttr &AL) {
+  return AL.isStandardAttributeSyntax();
+}));

Can you add an `&& "and this is what the assert is testing for"` message here 
so when the assertion fails there's more details as to what went sideways?



Comment at: clang/include/clang/Sema/ParsedAttr.h:1126
+/// `Result`. Sets `Result.Range` to the combined range of `First` and 
`Second`.
+void ConcatenateAttributes(ParsedAttributes &First, ParsedAttributes &Second,
+   ParsedAttributes &Result);

I think `Concatenate` implies that `First` and `Second` are untouched, but 
that's not really the case here. Perhaps `takeAndConcatenateAll()` or something 
along those lines instead? Also, the function should start with a lowercase 
letter per the usual coding style rules.



Comment at: clang/include/clang/Sema/ParsedAttr.h:664
+  /// This may only be called if isStandardAttributeSyntax() returns true.
+  bool slidesFromDeclToDeclSpec() const;
+

mboehme wrote:
> aaron.ballman wrote:
> > Because this is now specific to standard attributes, and those don't 
> > "slide" under normal circumstances, it might be nice to rename this method 
> > to make it more clear that this should not be called normally. I don't have 
> > a strong opinion on what a *good* name is, but even something like 
> > `improperlySlidesFromDeclToDeclSpec()` would make me happy.
> I've decided to add `LegacyBehavior` at the end -- WDYT?
Works for me



Comment at: clang/lib/Parse/ParseStmt.cpp:229
   default: {
+auto isStmtAttr = [](ParsedAttr &Attr) { return Attr.isStmtAttr(); };
 if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt ||

Coding style nit.



Comment at: clang/lib/Parse/ParseStmt.cpp:230-237
 if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt ||
  (StmtCtx & ParsedStmtContext::AllowDeclarationsInC) !=
  ParsedStmtContext()) &&
 ((GNUAttributeLoc.isValid() &&
-  !(!Attrs.empty() &&
-llvm::all_of(
-Attrs, [](ParsedAttr &Attr) { return Attr.isStmtAttr(); }))) ||
+  !(!(CXX11Attrs.empty() && GNUAttrs.empty()) &&
+llvm::all_of(CXX11Attrs, isStmtAttr) &&
+llvm::all_of(GNUAttrs, isStmtAttr))) ||

The logic is correct here, but this predicate has gotten really difficult to 
understand. If you wanted to split some of those conditions out into named 
variables for clarity, I would not be sad (but I also don't insist either).



Comment at: clang/lib/Parse/ParseStmt.cpp:248-251
+  if (CXX11Attrs.Range.getBegin().isValid())
+DeclStart = CXX11Attrs.Range.getBegin();
+  else if (GNUAttrs.Range.getBegin().isValid())
+DeclStart = GNUAttrs.Range.getBegin();

Do CXX attributes always precede GNU ones, or do we need to do a source 
location comparison here to see which location is lexically earlier?



Comment at: clang/lib/Parse/ParseStmt.cpp:317-318
   case tok::kw_asm: {
-ProhibitAttributes(Attrs);
+ProhibitAttributes(CXX11Attrs);
+ProhibitAttributes(GNUAttrs);
 bool msAsm = false;

mboehme wrote:
> aaron.ballman wrote:
> > mboehme wrote:
> > > aaro

[PATCH] D127646: [analyzer][NFC][test] Add new RUN lint with support-symbolic-integer-casts=true to svalbuilder-rearrange-comparisons.c

2022-06-13 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vabridgers, steakhal.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: All.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Added a new run line to bolster gradual transition of handling cast operations,
see 
https://discourse.llvm.org/t/roadmap-of-modeling-symbolic-cast-operations/63107


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127646

Files:
  clang/test/Analysis/svalbuilder-rearrange-comparisons.c
  clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp


Index: clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
===
--- clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
+++ clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
@@ -1,8 +1,24 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin 
-analyzer-config aggressive-binary-operation-simplification=true -verify 
-analyzer-config eagerly-assume=false %s
-
-void clang_analyzer_eval(int x);
-void clang_analyzer_denote(int x, const char *literal);
-void clang_analyzer_express(int x);
+// RUN: %clang_analyze_cc1 \
+// RUN:-analyzer-checker=debug.ExprInspection,core.builtin \
+// RUN:-analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:-analyzer-config support-symbolic-integer-casts=false \
+// RUN:-analyzer-config eagerly-assume=false \
+// RUN:-verify %s
+
+// RUN: %clang_analyze_cc1 \
+// RUN:-analyzer-checker=debug.ExprInspection,core.builtin \
+// RUN:-analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:-analyzer-config support-symbolic-integer-casts=true \
+// RUN:-DSUPPORT_SYMBOLIC_INTEGER_CASTS \
+// RUN:-analyzer-config eagerly-assume=false \
+// RUN:-verify %s
+
+template 
+void clang_analyzer_eval(T x);
+template 
+void clang_analyzer_denote(T x, const char *literal);
+template 
+void clang_analyzer_express(T x);
 
 void exit(int);
 
@@ -510,6 +526,17 @@
   clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
 }
 
+// Rearrange should happen on signed types only (tryRearrange):
+//
+//  // Rearrange signed symbolic expressions only
+//  if (!SingleTy->isSignedIntegerOrEnumerationType())
+//return None;
+//
+// Without the symbolic casts, the SVal for `x` in `unsigned x = f()` will be
+// the signed `int`. However, with the symbolic casts it will be `unsigned`.
+// Thus, these tests are meaningful only if the cast is not emitted.
+#ifndef SUPPORT_SYMBOLIC_INTEGER_CASTS
+
 void compare_different_symbol_equal_unsigned(void) {
   unsigned x = f(), y = f();
   clang_analyzer_denote(x, "$x");
@@ -894,6 +921,10 @@
   clang_analyzer_express(x < y); // expected-warning {{$x - $y < 1}}
 }
 
+#endif
+
+// These pass even with aggressive-binary-operation-simplification=false
+
 void compare_same_symbol_less_unsigned(void) {
   unsigned x = f(), y = x;
   clang_analyzer_denote(x, "$x");


Index: clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
===
--- clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
+++ clang/test/Analysis/svalbuilder-rearrange-comparisons.cpp
@@ -1,8 +1,24 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-binary-operation-simplification=true -verify -analyzer-config eagerly-assume=false %s
-
-void clang_analyzer_eval(int x);
-void clang_analyzer_denote(int x, const char *literal);
-void clang_analyzer_express(int x);
+// RUN: %clang_analyze_cc1 \
+// RUN:-analyzer-checker=debug.ExprInspection,core.builtin \
+// RUN:-analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:-analyzer-config support-symbolic-integer-casts=false \
+// RUN:-analyzer-config eagerly-assume=false \
+// RUN:-verify %s
+
+// RUN: %clang_analyze_cc1 \
+// RUN:-analyzer-checker=debug.ExprInspection,core.builtin \
+// RUN:-analyzer-config aggressive-binary-operation-simplification=true \
+// RUN:-analyzer-config support-symbolic-integer-casts=true \
+// RUN:-DSUPPORT_SYMBOLIC_INTEGER_CASTS \
+// RUN:-analyzer-config eagerly-assume=false \
+// RUN:-verify %s
+
+template 
+void clang_analyzer_eval(T x);
+template 
+void clang_analyzer_denote(T x, const char *literal);
+template 
+void clang_analyzer_express(T x);
 
 void exit(int);
 
@@ -510,6 +526,17 @@
   clang_analyzer_eval(x < y); // expected-warning {{FALSE}}
 }
 
+// Rearrange should happen on signed types only (tryRearrange):
+//
+//  // Rearrange signed symbolic expressions only
+//  if (!SingleTy->isSignedIntegerOrEnumerationType())
+//return None;
+//
+// Without the symbolic c

[PATCH] D127647: [clang][lex] NFCI: Use FileEntryRef in ModuleMap::{load,lookup}ModuleMap()

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the return/argument types of 
`ModuleMap::{load,lookup}ModuleMap()` from `const FileEntry *` to 
`FileEntryRef` in order to remove uses of the deprecated 
`DirectoryEntry::getName()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127647

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -989,9 +989,9 @@
   // We haven't looked here before. Load a module map, if there is
   // one.
   bool IsFrameworkDir = Parent.endswith(".framework");
-  if (const FileEntry *ModMapFile =
-HeaderInfo.lookupModuleMapFile(*ParentDir, IsFrameworkDir)) {
-parseModuleMapFile(ModMapFile, Attrs.IsSystem, *ParentDir);
+  if (Optional ModMapFile =
+  HeaderInfo.lookupModuleMapFile(*ParentDir, IsFrameworkDir)) {
+parseModuleMapFile(*ModMapFile, Attrs.IsSystem, *ParentDir);
 inferred = InferredDirectories.find(*ParentDir);
   }
 
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1610,10 +1610,10 @@
   return true;
 }
 
-static const FileEntry *getPrivateModuleMap(const FileEntry *File,
+static const FileEntry *getPrivateModuleMap(FileEntryRef File,
 FileManager &FileMgr) {
-  StringRef Filename = llvm::sys::path::filename(File->getName());
-  SmallString<128>  PrivateFilename(File->getDir()->getName());
+  StringRef Filename = llvm::sys::path::filename(File.getName());
+  SmallString<128>  PrivateFilename(File.getDir().getName());
   if (Filename == "module.map")
 llvm::sys::path::append(PrivateFilename, "module_private.map");
   else if (Filename == "module.modulemap")
@@ -1625,7 +1625,7 @@
   return nullptr;
 }
 
-bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem,
+bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
  FileID ID, unsigned *Offset,
  StringRef OriginalModuleMapFile) {
   // Find the directory for the module. For frameworks, that may require going
@@ -1644,9 +1644,7 @@
 Dir = FakeFile.getDir();
   }
 } else {
-  // TODO: Replace with `Dir = File.getDir()` when `File` is switched to
-  // `FileEntryRef`.
-  Dir = FileMgr.getOptionalDirectoryRef(File->getDir()->getName());
+  Dir = File.getDir();
 }
 
 assert(Dir && "parent must exist");
@@ -1675,11 +1673,9 @@
 }
 
 HeaderSearch::LoadModuleMapResult
-HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem,
+HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
 DirectoryEntryRef Dir, FileID ID,
 unsigned *Offset) {
-  assert(File && "expected FileEntry");
-
   // Check whether we've already loaded this module map, and mark it as being
   // loaded in case we recursively try to load it from itself.
   auto AddResult = LoadedModuleMaps.insert(std::make_pair(File, true));
@@ -1703,23 +1699,23 @@
   return LMM_NewlyLoaded;
 }
 
-const FileEntry *
+Optional
 HeaderSearch::lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework) {
   if (!HSOpts->ImplicitModuleMaps)
-return nullptr;
+return None;
   // For frameworks, the preferred spelling is Modules/module.modulemap, but
   // module.map at the framework root is also accepted.
   SmallString<128> ModuleMapFileName(Dir->getName());
   if (IsFramework)
 llvm::sys::path::append(ModuleMapFileName, "Modules");
   llvm::sys::path::append(ModuleMapFileName, "module.modulemap");
-  if (auto F = FileMgr.getFile(ModuleMapFileName))
+  if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
 return *F;
 
   // Continue to allow module.map
   ModuleMapFileName = Dir->getName();
   llvm::sys::path::append(ModuleMapFileName, "module.map");
-  if (auto F = FileMgr.getFile(ModuleMapFileName))
+  if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
 return *F;
 
   // For frameworks, allow to have a private module map with a preferred
@@ -1728,10 +1724,10 @@
 ModuleMapFileName = Dir->getName();
 llvm::sys::path::append(ModuleMapFileName, "Modules",
 "module.private.modulemap");
-if (auto F = FileMgr.getFile(ModuleMapFileName))
+if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
 

[PATCH] D112916: Confusable identifiers detection

2022-06-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 436399.
serge-sans-paille added a comment.

- quiet output of the table conversion program when everything goes well
- cross-compilation support (untested)
- fix identifier retrieving


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

https://reviews.llvm.org/D112916

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConfusableTable/build_confusable_table.cpp
  clang-tools-extra/clang-tidy/misc/ConfusableTable/confusables.txt
  clang-tools-extra/clang-tidy/misc/Homoglyph.cpp
  clang-tools-extra/clang-tidy/misc/Homoglyph.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-homoglyph.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-homoglyph.cpp

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


[PATCH] D112916: Confusable identifiers detection

2022-06-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille reopened this revision.
serge-sans-paille added a comment.
This revision is now accepted and ready to land.

cc @thakis


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

https://reviews.llvm.org/D112916

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


[PATCH] D127201: [clang] Add tests for statement expression in initializers

2022-06-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for adding some more test coverage! Would it be worth mentioning the 
miscompile fix in the release notes more explicitly?




Comment at: clang/test/Sema/stmtexpr-init.c:1
+// RUN: %clang_cc1 -verify -fsyntax-only -std=gnu11 %s
+

I'd remove the gnu11 from here as well (we default to being in GNU mode anyway).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127201

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


[PATCH] D127648: [clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::inferFrameworkModule()

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the argument type of `ModuleMap::inferFrameworkModule()` 
from `const DirectoryEntry *` to `DirectoryEntryRef` in order to remove the 
deprecated uses of `DirectoryEntry::getName()`.

Depends on D127647 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127648

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/ModuleMap.cpp


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -942,14 +942,14 @@
   }
 }
 
-Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
+Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
 bool IsSystem, Module *Parent) {
   Attributes Attrs;
   Attrs.IsSystem = IsSystem;
   return inferFrameworkModule(FrameworkDir, Attrs, Parent);
 }
 
-Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
+Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
 Attributes Attrs, Module *Parent) {
   // Note: as an egregious but useful hack we use the real path here, because
   // we might be looking at an embedded framework that symlinks out to a
@@ -980,7 +980,7 @@
 if (llvm::sys::path::has_parent_path(FrameworkDirName)) {
   // Figure out the parent path.
   StringRef Parent = llvm::sys::path::parent_path(FrameworkDirName);
-  if (auto ParentDir = FileMgr.getDirectory(Parent)) {
+  if (auto ParentDir = FileMgr.getOptionalDirectoryRef(Parent)) {
 // Check whether we have already looked into the parent directory
 // for a module map.
 llvm::DenseMap::const_iterator
@@ -1025,7 +1025,7 @@
 
 
   // Look for an umbrella header.
-  SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName());
+  SmallString<128> UmbrellaName = StringRef(FrameworkDir.getName());
   llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h");
   auto UmbrellaHeader = FileMgr.getFile(UmbrellaName);
 
@@ -1070,8 +1070,7 @@
 
   // Look for subframeworks.
   std::error_code EC;
-  SmallString<128> SubframeworksDirName
-= StringRef(FrameworkDir->getName());
+  SmallString<128> SubframeworksDirName = StringRef(FrameworkDir.getName());
   llvm::sys::path::append(SubframeworksDirName, "Frameworks");
   llvm::sys::path::native(SubframeworksDirName);
   llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
@@ -1082,8 +1081,7 @@
 if (!StringRef(Dir->path()).endswith(".framework"))
   continue;
 
-if (auto SubframeworkDir =
-FileMgr.getDirectory(Dir->path())) {
+if (auto SubframeworkDir = FileMgr.getOptionalDirectoryRef(Dir->path())) {
   // Note: as an egregious but useful hack, we use the real path here and
   // check whether it is actually a subdirectory of the parent directory.
   // This will not be the case if the 'subframework' is actually a symlink
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -466,7 +466,8 @@
 SmallString<128> InferredFrameworkPath = ModuleMap->getDir().getName();
 llvm::sys::path::append(InferredFrameworkPath,
 CI.getLangOpts().ModuleName + ".framework");
-if (auto Dir = CI.getFileManager().getDirectory(InferredFrameworkPath))
+if (auto Dir =
+CI.getFileManager().getOptionalDirectoryRef(InferredFrameworkPath))
   (void)HS.getModuleMap().inferFrameworkModule(*Dir, IsSystem, nullptr);
   }
 
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -374,8 +374,8 @@
 return static_cast(findHeaderInUmbrellaDirs(File, IntermediateDirs));
   }
 
-  Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir,
-   Attributes Attrs, Module *Parent);
+  Module *inferFrameworkModule(DirectoryEntryRef FrameworkDir, Attributes 
Attrs,
+   Module *Parent);
 
 public:
   /// Construct a new module map.
@@ -570,8 +570,8 @@
 
   /// Infer the contents of a framework module map from the given
   /// framework directory.
-  Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir,
-   bool IsSystem, Module *Parent);
+  Module *inferFrameworkModule(DirectoryEntryRef FrameworkDir, bool IsSystem,
+   Module *Parent);
 
   /// Create a ne

[PATCH] D127649: [analyzer][NFC][test] Add new RUN line with support-symbolic-integer-casts=true to expr-inspection.cpp

2022-06-13 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vabridgers, steakhal, NoQ, ASDenysPetrov.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: All.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Added a new run line to bolster gradual transition of handling cast operations,
see 
https://discourse.llvm.org/t/roadmap-of-modeling-symbolic-cast-operations/63107


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127649

Files:
  clang/test/Analysis/expr-inspection.cpp


Index: clang/test/Analysis/expr-inspection.cpp
===
--- clang/test/Analysis/expr-inspection.cpp
+++ clang/test/Analysis/expr-inspection.cpp
@@ -1,8 +1,15 @@
-// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection 
-verify %s
+// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \
+// RUN:-analyzer-config support-symbolic-integer-casts=false \
+// RUN:-verify %s
+
+// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \
+// RUN:-analyzer-config support-symbolic-integer-casts=true \
+// RUN:-verify %s
 
 // Self-tests for the debug.ExprInspection checker.
 
 void clang_analyzer_denote(int x, const char *str);
+void clang_analyzer_denote(unsigned x, const char *str);
 void clang_analyzer_express(int x);
 
 // Invalid declarations to test basic correctness checks.


Index: clang/test/Analysis/expr-inspection.cpp
===
--- clang/test/Analysis/expr-inspection.cpp
+++ clang/test/Analysis/expr-inspection.cpp
@@ -1,8 +1,15 @@
-// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \
+// RUN:-analyzer-config support-symbolic-integer-casts=false \
+// RUN:-verify %s
+
+// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \
+// RUN:-analyzer-config support-symbolic-integer-casts=true \
+// RUN:-verify %s
 
 // Self-tests for the debug.ExprInspection checker.
 
 void clang_analyzer_denote(int x, const char *str);
+void clang_analyzer_denote(unsigned x, const char *str);
 void clang_analyzer_express(int x);
 
 // Invalid declarations to test basic correctness checks.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-06-13 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:847-849
+} else if (const auto Iface =
+   dyn_cast(Decl)) {
+  if (Iface->isThisDeclarationADefinition())

ckandeler wrote:
> dgoldman wrote:
> > Do we need similar code for ObjCProtocolDecl? Also should ObjCImplDecl be 
> > considered definitions here?
> Possibly. I know next to nothing about Objective C, so I'll just do as I'm 
> told here. On a related note, the code above regarding ObjCMethodDecl does 
> not seem to do anything, i.e. none of the constructs that to my eye appear to 
> be Objective-C methods get the "def" modifier. 
Gotcha, yeah I think it makes sense to do the same for ObjCImplDecl, 
ObjCProtocolDecl, and ObjCCategoryDecl.

re: methods, ah yeah, that's because canHighlightName will return false since 
we need to special case handling for ObjC methods since their names can be 
split across non contiguous tokens (selectors). Instead, would need to update 
`VisitObjCMethodDecl` and `highlightObjCSelector`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D127651: [clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::parseModuleMapFile()

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

This patch changes the argument type of `ModuleMap::parseModuleMapFile()` from 
`const DirectoryEntry *` to `DirectoryEntryRef` in order to remove the 
deprecated uses of `DirectoryEntry::getName()`.

Depends on D127648 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127651

Files:
  clang-tools-extra/modularize/ModularizeUtilities.cpp
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1451,7 +1451,7 @@
 
 /// The directory that file names in this module map file should
 /// be resolved relative to.
-const DirectoryEntry *Directory;
+DirectoryEntryRef Directory;
 
 /// Whether this module map is in a system header directory.
 bool IsSystem;
@@ -1517,7 +1517,7 @@
 explicit ModuleMapParser(Lexer &L, SourceManager &SourceMgr,
  const TargetInfo *Target, DiagnosticsEngine &Diags,
  ModuleMap &Map, const FileEntry *ModuleMapFile,
- const DirectoryEntry *Directory, bool IsSystem)
+ DirectoryEntryRef Directory, bool IsSystem)
 : L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),
   ModuleMapFile(ModuleMapFile), Directory(Directory),
   IsSystem(IsSystem) {
@@ -2189,16 +2189,16 @@
   StringRef FileNameRef = FileName;
   SmallString<128> ModuleMapFileName;
   if (llvm::sys::path::is_relative(FileNameRef)) {
-ModuleMapFileName += Directory->getName();
+ModuleMapFileName += Directory.getName();
 llvm::sys::path::append(ModuleMapFileName, FileName);
 FileNameRef = ModuleMapFileName;
   }
-  if (auto File = SourceMgr.getFileManager().getFile(FileNameRef))
+  if (auto File = SourceMgr.getFileManager().getOptionalFileRef(FileNameRef))
 Map.parseModuleMapFile(
 *File, IsSystem,
 Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd
 ? Directory
-: (*File)->getDir(),
+: File->getDir(),
 FileID(), nullptr, ExternLoc);
 }
 
@@ -2453,7 +2453,7 @@
   Dir = *D;
   } else {
 SmallString<128> PathName;
-PathName = Directory->getName();
+PathName = Directory.getName();
 llvm::sys::path::append(PathName, DirName);
 if (auto D = SourceMgr.getFileManager().getDirectory(PathName))
   Dir = *D;
@@ -3016,7 +3016,7 @@
 }
 
 bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem,
-   const DirectoryEntry *Dir, FileID ID,
+   DirectoryEntryRef Dir, FileID ID,
unsigned *Offset,
SourceLocation ExternModuleLoc) {
   assert(Target && "Missing target information");
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -703,8 +703,8 @@
   ///
   /// \returns true if an error occurred, false otherwise.
   bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
-  const DirectoryEntry *HomeDir,
-  FileID ID = FileID(), unsigned *Offset = nullptr,
+  DirectoryEntryRef HomeDir, FileID ID = FileID(),
+  unsigned *Offset = nullptr,
   SourceLocation ExternModuleLoc = SourceLocation());
 
   /// Dump the contents of the module map, for debugging purposes.
Index: clang-tools-extra/modularize/ModularizeUtilities.cpp
===
--- clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -258,31 +258,26 @@
 std::error_code ModularizeUtilities::loadModuleMap(
 llvm::StringRef InputPath) {
   // Get file entry for module.modulemap file.
-  auto ModuleMapEntryOrErr =
-SourceMgr->getFileManager().getFile(InputPath);
+  auto ModuleMapEntryOrErr = SourceMgr->getFileManager().getFileRef(InputPath);
 
   // return error if not found.
   if (!ModuleMapEntryOrErr) {
 llvm::errs() << "error: File \"" << InputPath << "\" not found.\n";
-return ModuleMapEntryOrErr.getError();
+return errorToErrorCode(ModuleMapEntryOrErr.takeError());
   }
-  const FileEntry *ModuleMapEntry = *ModuleMapEntryOrErr;
+  FileEntryRef ModuleMapEntry = *ModuleMapEntryOrErr;
 
   // Because the module map parser uses a ForwardingDiagnosticConsumer,
   // which doesn't forward the Beg

[PATCH] D127654: [clang] NFCI: Use DirectoryEntryRef in Module::Directory

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the type of `Module::Directory` from `const DirectoryEntry 
*` to (essentially) `Optional` in order to remove uses of 
the deprecated `DirectoryEntry::getName()`.

Depends on D127651 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127654

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Lex/ModuleMap.cpp


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -175,7 +175,7 @@
 Module *M, const Module::UnresolvedHeaderDirective &Header,
 SmallVectorImpl &RelativePathName, bool &NeedsFramework) {
   // Search for the header file within the module's home directory.
-  auto *Directory = M->Directory;
+  auto Directory = M->Directory;
   SmallString<128> FullPathName(Directory->getName());
 
   auto GetFile = [&](StringRef Filename) -> Optional {
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -135,7 +135,7 @@
   /// The build directory of this module. This is the directory in
   /// which the module is notionally built, and relative to which its headers
   /// are found.
-  const DirectoryEntry *Directory = nullptr;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr Directory;
 
   /// The presumed file name for the module map defining this module.
   /// Only non-empty when building from preprocessed source.


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -175,7 +175,7 @@
 Module *M, const Module::UnresolvedHeaderDirective &Header,
 SmallVectorImpl &RelativePathName, bool &NeedsFramework) {
   // Search for the header file within the module's home directory.
-  auto *Directory = M->Directory;
+  auto Directory = M->Directory;
   SmallString<128> FullPathName(Directory->getName());
 
   auto GetFile = [&](StringRef Filename) -> Optional {
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -135,7 +135,7 @@
   /// The build directory of this module. This is the directory in
   /// which the module is notionally built, and relative to which its headers
   /// are found.
-  const DirectoryEntry *Directory = nullptr;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr Directory;
 
   /// The presumed file name for the module map defining this module.
   /// Only non-empty when building from preprocessed source.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127655: [AArch64] Define __FP_FAST_FMA[F]

2022-06-13 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
jolanta.jensen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Libraries use this flag to decide whether to use the fma builtin.
Author: Paul Walker


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127655

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/init-aarch64.c


Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -104,18 +104,20 @@
 // AARCH64-NEXT: #define __FLT_MIN_EXP__ (-125)
 // AARCH64-NEXT: #define __FLT_MIN__ 1.17549435e-38F
 // AARCH64-NEXT: #define __FLT_RADIX__ 2
+// AARCH64-NEXT: #define __FP_FAST_FMA 1
+// AARCH64-NEXT: #define __FP_FAST_FMAF 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
 // AARCH64_CXX-NEXT: #define __GLIBCXX_BITSIZE_INT_N_0 128
 // AARCH64_CXX-NEXT: #define __GLIBCXX_TYPE_INT_N_0 __int128
-// AARCH64-NEXT: #define __INT16_C_SUFFIX__ 
+// AARCH64-NEXT: #define __INT16_C_SUFFIX__
 // AARCH64-NEXT: #define __INT16_FMTd__ "hd"
 // AARCH64-NEXT: #define __INT16_FMTi__ "hi"
 // AARCH64-NEXT: #define __INT16_MAX__ 32767
 // AARCH64-NEXT: #define __INT16_TYPE__ short
-// AARCH64-NEXT: #define __INT32_C_SUFFIX__ 
+// AARCH64-NEXT: #define __INT32_C_SUFFIX__
 // AARCH64-NEXT: #define __INT32_FMTd__ "d"
 // AARCH64-NEXT: #define __INT32_FMTi__ "i"
 // AARCH64-NEXT: #define __INT32_MAX__ 2147483647
@@ -125,7 +127,7 @@
 // AARCH64-NEXT: #define __INT64_FMTi__ "li"
 // AARCH64-NEXT: #define __INT64_MAX__ 9223372036854775807L
 // AARCH64-NEXT: #define __INT64_TYPE__ long int
-// AARCH64-NEXT: #define __INT8_C_SUFFIX__ 
+// AARCH64-NEXT: #define __INT8_C_SUFFIX__
 // AARCH64-NEXT: #define __INT8_FMTd__ "hhd"
 // AARCH64-NEXT: #define __INT8_FMTi__ "hhi"
 // AARCH64-NEXT: #define __INT8_MAX__ 127
@@ -253,7 +255,7 @@
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
 // AARCH64_C: #define __STDC_VERSION__ 201710L
 // AARCH64-NEXT: #define __STDC__ 1
-// AARCH64-NEXT: #define __UINT16_C_SUFFIX__ 
+// AARCH64-NEXT: #define __UINT16_C_SUFFIX__
 // AARCH64-NEXT: #define __UINT16_FMTX__ "hX"
 // AARCH64-NEXT: #define __UINT16_FMTo__ "ho"
 // AARCH64-NEXT: #define __UINT16_FMTu__ "hu"
@@ -274,7 +276,7 @@
 // AARCH64-NEXT: #define __UINT64_FMTx__ "lx"
 // AARCH64-NEXT: #define __UINT64_MAX__ 18446744073709551615UL
 // AARCH64-NEXT: #define __UINT64_TYPE__ long unsigned int
-// AARCH64-NEXT: #define __UINT8_C_SUFFIX__ 
+// AARCH64-NEXT: #define __UINT8_C_SUFFIX__
 // AARCH64-NEXT: #define __UINT8_FMTX__ "hhX"
 // AARCH64-NEXT: #define __UINT8_FMTo__ "hho"
 // AARCH64-NEXT: #define __UINT8_FMTu__ "hhu"
@@ -344,7 +346,7 @@
 // AARCH64-NEXT: #define __UINT_LEAST8_FMTx__ "hhx"
 // AARCH64-NEXT: #define __UINT_LEAST8_MAX__ 255
 // AARCH64-NEXT: #define __UINT_LEAST8_TYPE__ unsigned char
-// AARCH64-NEXT: #define __USER_LABEL_PREFIX__ 
+// AARCH64-NEXT: #define __USER_LABEL_PREFIX__
 // AARCH64-NEXT: #define __VERSION__ "{{.*}}"
 // AARCH64-NEXT: #define __WCHAR_MAX__ 4294967295U
 // AARCH64-NEXT: #define __WCHAR_TYPE__ unsigned int
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -56,6 +56,8 @@
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
+// CHECK: __FP_FAST_FMA 1
+// CHECK: __FP_FAST_FMAF 1
 
 // RUN: %clang -target aarch64-arm-eabi -march=armv8-r -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-R-PROFILE
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-R-PROFILE
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -485,6 +485,10 @@
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 
+  // Allow detection of fast FMA support.
+  Builder.defineMacro("__FP_FAST_FMA", "1");
+  Builder.defineMacro("__FP_FAST_FMAF", "1");
+
   if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) {
 Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128));
 Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS");


Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/

[clang] 1054a73 - [Clang] Change host/device only compilation to a driver mode

2022-06-13 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-06-13T11:33:54-04:00
New Revision: 1054a7318788beb99536d84b34f84fccf2289769

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

LOG: [Clang] Change host/device only compilation to a driver mode

We use the flags `--offload-host-only` and `--offload-device-only` to
change the driver's code generation for offloading programs. These are
currently parsed out independently in many places. This patch simply
refactors this to work as a mode for the Driver. This stopped us from
emitting warnings if unused because it's always used now, but I don't
think this is a great loss.

Reviewed By: tra

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

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/lib/Driver/Driver.cpp

Removed: 
clang/test/Driver/cuda-unused-arg-warning.cu



diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 67ff4dc2e01e8..774eac613a100 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -95,6 +95,12 @@ class Driver {
 EmbedBitcode
   } BitcodeEmbed;
 
+  enum OffloadMode {
+OffloadHostDevice,
+OffloadHost,
+OffloadDevice,
+  } Offload;
+
   /// Header unit mode set by -fmodule-header={user,system}.
   ModuleHeaderMode CXX20HeaderType;
 
@@ -391,6 +397,9 @@ class Driver {
   bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); }
   bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); }
 
+  bool offloadHostOnly() const { return Offload == OffloadHost; }
+  bool offloadDeviceOnly() const { return Offload == OffloadDevice; }
+
   /// Compute the desired OpenMP runtime from the flags provided.
   OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const;
 

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index bb879805ae79e..70816def4b3fc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -192,13 +192,14 @@ Driver::Driver(StringRef ClangExecutable, StringRef 
TargetTriple,
IntrusiveRefCntPtr VFS)
 : Diags(Diags), VFS(std::move(VFS)), Mode(GCCMode),
   SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone),
-  CXX20HeaderType(HeaderMode_None), ModulesModeCXX20(false),
-  LTOMode(LTOK_None), ClangExecutable(ClangExecutable),
-  SysRoot(DEFAULT_SYSROOT), DriverTitle(Title), CCCPrintBindings(false),
-  CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
-  CCGenDiagnostics(false), CCPrintProcessStats(false),
-  TargetTriple(TargetTriple), Saver(Alloc), CheckInputsExist(true),
-  ProbePrecompiled(true), SuppressMissingInputWarning(false) {
+  Offload(OffloadHostDevice), CXX20HeaderType(HeaderMode_None),
+  ModulesModeCXX20(false), LTOMode(LTOK_None),
+  ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
+  DriverTitle(Title), CCCPrintBindings(false), CCPrintOptions(false),
+  CCPrintHeaders(false), CCLogDiagnostics(false), CCGenDiagnostics(false),
+  CCPrintProcessStats(false), TargetTriple(TargetTriple), Saver(Alloc),
+  CheckInputsExist(true), ProbePrecompiled(true),
+  SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
@@ -1284,6 +1285,17 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 .Default(SaveTempsCwd);
   }
 
+  if (const Arg *A = Args.getLastArg(options::OPT_offload_host_only,
+ options::OPT_offload_device_only,
+ options::OPT_offload_host_device)) {
+if (A->getOption().matches(options::OPT_offload_host_only))
+  Offload = OffloadHost;
+else if (A->getOption().matches(options::OPT_offload_device_only))
+  Offload = OffloadDevice;
+else
+  Offload = OffloadHostDevice;
+  }
+
   setLTOMode(Args);
 
   // Process -fembed-bitcode= flags.
@@ -2933,15 +2945,8 @@ class OffloadingActionBuilder final {
   ? C.getSingleOffloadToolChain()
   : C.getSingleOffloadToolChain());
 
-  Arg *PartialCompilationArg = Args.getLastArg(
-  options::OPT_offload_host_only, options::OPT_offload_device_only,
-  options::OPT_offload_host_device);
-  CompileHostOnly =
-  PartialCompilationArg && PartialCompilationArg->getOption().matches(
-   options::OPT_offload_host_only);
-  CompileDeviceOnly =
-  PartialCompilationArg && PartialCompilationArg->getOption().matches(
-   options::OPT_offload_device_only);
+  CompileHostOnly = C.getDriver().offloadHostOnly()

[PATCH] D127515: [Clang] Change host/device only compilation to a driver mode

2022-06-13 Thread Joseph Huber 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 rG1054a7318788: [Clang] Change host/device only compilation to 
a driver mode (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127515

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/cuda-unused-arg-warning.cu

Index: clang/test/Driver/cuda-unused-arg-warning.cu
===
--- clang/test/Driver/cuda-unused-arg-warning.cu
+++ /dev/null
@@ -1,28 +0,0 @@
-// Tests that we trigger unused-arg warnings on CUDA flags appropriately.
-
-// REQUIRES: x86-registered-target
-// REQUIRES: nvptx-registered-target
-
-// --cuda-host-only and --cuda-compile-host-device should never trigger an
-// unused arg warning.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
-// RUN:FileCheck %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
-// RUN:FileCheck %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -c %s 2>&1 | \
-// RUN:FileCheck %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -x c -c %s 2>&1 | \
-// RUN:FileCheck %s
-
-// --cuda-device-only should warn during non-CUDA compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix UNUSED-WARNING %s
-
-// --cuda-device-only should not produce warning compiling CUDA files
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix NO-UNUSED-WARNING %s
-
-// CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
-// CHECK-NOT: warning: argument unused during compilation: '--cuda-compile-host-device'
-// UNUSED-WARNING: warning: argument unused during compilation: '--cuda-device-only'
-// NO-UNUSED-WARNING-NOT: warning: argument unused during compilation: '--cuda-device-only'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -192,13 +192,14 @@
IntrusiveRefCntPtr VFS)
 : Diags(Diags), VFS(std::move(VFS)), Mode(GCCMode),
   SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone),
-  CXX20HeaderType(HeaderMode_None), ModulesModeCXX20(false),
-  LTOMode(LTOK_None), ClangExecutable(ClangExecutable),
-  SysRoot(DEFAULT_SYSROOT), DriverTitle(Title), CCCPrintBindings(false),
-  CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
-  CCGenDiagnostics(false), CCPrintProcessStats(false),
-  TargetTriple(TargetTriple), Saver(Alloc), CheckInputsExist(true),
-  ProbePrecompiled(true), SuppressMissingInputWarning(false) {
+  Offload(OffloadHostDevice), CXX20HeaderType(HeaderMode_None),
+  ModulesModeCXX20(false), LTOMode(LTOK_None),
+  ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
+  DriverTitle(Title), CCCPrintBindings(false), CCPrintOptions(false),
+  CCPrintHeaders(false), CCLogDiagnostics(false), CCGenDiagnostics(false),
+  CCPrintProcessStats(false), TargetTriple(TargetTriple), Saver(Alloc),
+  CheckInputsExist(true), ProbePrecompiled(true),
+  SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
@@ -1284,6 +1285,17 @@
 .Default(SaveTempsCwd);
   }
 
+  if (const Arg *A = Args.getLastArg(options::OPT_offload_host_only,
+ options::OPT_offload_device_only,
+ options::OPT_offload_host_device)) {
+if (A->getOption().matches(options::OPT_offload_host_only))
+  Offload = OffloadHost;
+else if (A->getOption().matches(options::OPT_offload_device_only))
+  Offload = OffloadDevice;
+else
+  Offload = OffloadHostDevice;
+  }
+
   setLTOMode(Args);
 
   // Process -fembed-bitcode= flags.
@@ -2933,15 +2945,8 @@
   ? C.getSingleOffloadToolChain()
   : C.getSingleOffloadToolChain());
 
-  Arg *PartialCompilationArg = Args.getLastArg(
-  options::OPT_offload_host_only, options::OPT_offload_device_only,
-  options::OPT_offload_host_device);
-  CompileHostOnly =
-  PartialCompilationArg && PartialCompilationArg->getOption().matches(
-   options::OPT_offload_host_only);
-  CompileDeviceOnly =
-  PartialCompilationArg && PartialCompilationArg->getOption().matches(
-   options::OPT_offload_device_only);
+  CompileHostOnly = C.getDriver().offloadHostOnly();
+  CompileDeviceOnly = C.getDriver(

[PATCH] D123032: [clang][dataflow] Exclude protobuf types from modeling in the environment.

2022-06-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Since there are many moving pieces and the whole framework is experimental 
without many users, I'm fine with landing this as is as long we are tracking 
the improvement opportunities (tickets or fixemes).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123032

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


[PATCH] D127658: [clang][lex] NFCI: Use FileEntryRef in Sema::CodeCompleteIncludedFile

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch replaces some calls to the deprecated `DirectoryEntry::getName()` 
with calls to `DirectoryEntryRef::getName()` in SemaCodeComplete.cpp.

Depends on D127654 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127658

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9957,12 +9957,12 @@
   // header maps are not (currently) enumerable.
   break;
 case DirectoryLookup::LT_NormalDir:
-  AddFilesFromIncludeDir(IncludeDir.getDir()->getName(), IsSystem,
+  AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
  DirectoryLookup::LT_NormalDir);
   break;
 case DirectoryLookup::LT_Framework:
-  AddFilesFromIncludeDir(IncludeDir.getFrameworkDir()->getName(), IsSystem,
- DirectoryLookup::LT_Framework);
+  AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
+ IsSystem, DirectoryLookup::LT_Framework);
   break;
 }
   };
@@ -9974,9 +9974,8 @@
   using llvm::make_range;
   if (!Angled) {
 // The current directory is on the include path for "quoted" includes.
-const FileEntry *CurFile = PP.getCurrentFileLexer()->getFileEntry();
-if (CurFile && CurFile->getDir())
-  AddFilesFromIncludeDir(CurFile->getDir()->getName(), false,
+if (auto CurFile = PP.getCurrentFileLexer()->getFileEntry())
+  AddFilesFromIncludeDir(CurFile->getDir().getName(), false,
  DirectoryLookup::LT_NormalDir);
 for (const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
   AddFilesFromDirLookup(D, false);


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9957,12 +9957,12 @@
   // header maps are not (currently) enumerable.
   break;
 case DirectoryLookup::LT_NormalDir:
-  AddFilesFromIncludeDir(IncludeDir.getDir()->getName(), IsSystem,
+  AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
  DirectoryLookup::LT_NormalDir);
   break;
 case DirectoryLookup::LT_Framework:
-  AddFilesFromIncludeDir(IncludeDir.getFrameworkDir()->getName(), IsSystem,
- DirectoryLookup::LT_Framework);
+  AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
+ IsSystem, DirectoryLookup::LT_Framework);
   break;
 }
   };
@@ -9974,9 +9974,8 @@
   using llvm::make_range;
   if (!Angled) {
 // The current directory is on the include path for "quoted" includes.
-const FileEntry *CurFile = PP.getCurrentFileLexer()->getFileEntry();
-if (CurFile && CurFile->getDir())
-  AddFilesFromIncludeDir(CurFile->getDir()->getName(), false,
+if (auto CurFile = PP.getCurrentFileLexer()->getFileEntry())
+  AddFilesFromIncludeDir(CurFile->getDir().getName(), false,
  DirectoryLookup::LT_NormalDir);
 for (const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
   AddFilesFromDirLookup(D, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127660: [clang][lex] NFCI: Use DirectoryEntryRef in MainFileDir::MainFileDir

2022-06-13 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the type of `Preprocessor::MainFileDir` from `const 
DirectoryEntry *` to `Optional` in order to remove some 
calls to the deprecated `DirectoryEntry::getName()`.

Depends on D127658 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127660

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -909,7 +909,7 @@
 // map file.
 if (!FileEnt) {
   if (FID == SourceMgr.getMainFileID() && MainFileDir) {
-Includers.push_back(std::make_pair(nullptr, MainFileDir));
+Includers.push_back(std::make_pair(nullptr, *MainFileDir));
 BuildSystemModule = getCurrentModule()->IsSystem;
   } else if ((FileEnt =
 SourceMgr.getFileEntryForID(SourceMgr.getMainFileID(
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -504,7 +504,7 @@
 
   // Inform the preprocessor that includes from within the input buffer should
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 
   // If the module was inferred from a different module map (via an expanded
   // umbrella module definition), track that fact.
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -430,7 +430,7 @@
   /// The directory that the main file should be considered to occupy,
   /// if it does not correspond to a real file (as happens when building a
   /// module).
-  const DirectoryEntry *MainFileDir = nullptr;
+  Optional MainFileDir;
 
   /// The number of bytes that we will initially skip when entering the
   /// main file, along with a flag that indicates whether skipping this number
@@ -1785,9 +1785,7 @@
 
   /// Set the directory in which the main file should be considered
   /// to have been found, if it is not a real file.
-  void setMainFileDir(const DirectoryEntry *Dir) {
-MainFileDir = Dir;
-  }
+  void setMainFileDir(DirectoryEntryRef Dir) { MainFileDir = Dir; }
 
   /// Instruct the preprocessor to skip part of the main source file.
   ///


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -909,7 +909,7 @@
 // map file.
 if (!FileEnt) {
   if (FID == SourceMgr.getMainFileID() && MainFileDir) {
-Includers.push_back(std::make_pair(nullptr, MainFileDir));
+Includers.push_back(std::make_pair(nullptr, *MainFileDir));
 BuildSystemModule = getCurrentModule()->IsSystem;
   } else if ((FileEnt =
 SourceMgr.getFileEntryForID(SourceMgr.getMainFileID(
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -504,7 +504,7 @@
 
   // Inform the preprocessor that includes from within the input buffer should
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 
   // If the module was inferred from a different module map (via an expanded
   // umbrella module definition), track that fact.
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -430,7 +430,7 @@
   /// The directory that the main file should be considered to occupy,
   /// if it does not correspond to a real file (as happens when building a
   /// module).
-  const DirectoryEntry *MainFileDir = nullptr;
+  Optional MainFileDir;
 
   /// The number of bytes that we will initially skip when entering the
   /// main file, along with a flag that indicates whether skipping this number
@@ -1785,9 +1785,7 @@
 
   /// Set the directory in which the main file should be considered
   /// to have been found, if it is not a real file.
-  void setMainFileDir(const DirectoryEntry *Dir) {
-MainFileDir = Dir;
-  }
+  void setMainFileDir(DirectoryEntryRef Dir) { MainFileDir = Dir; }
 
   /// In

[PATCH] D127486: [analyzer][NFC] Inline AnalyzerOptions::getUserMode()

2022-06-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:362-364
-  /// Retrieves and sets the UserMode. This is a high-level option,
-  /// which is used to set other low-level options. It is not accessible
-  /// outside of AnalyzerOptions.

I would miss this comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127486

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


  1   2   3   >