[clang] [Clang][OpenMP] Fix stdio.h wrapper when glibc includes again (PR #77017)

2024-01-05 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl closed 
https://github.com/llvm/llvm-project/pull/77017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Fix stdio.h wrapper when glibc includes again (PR #77017)

2024-01-04 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> TYVM for fixing this. There's a lot of hacky stuff we need to do here to make 
> it work, but it is what it is.
> 
> Guessing the other wrapped files are fine? I remember having problems with 
> `cytype` and `string` but I hopefully resolved a lot of those already.

I do have remaining test failures I haven't yet sorted out on some of our 
systems, but I don't yet have reason to suspect they're related to these libc 
wrappers.

Thanks for the quick review.  Will push tomorrow when I have time to watch bots.

https://github.com/llvm/llvm-project/pull/77017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Fix stdio.h wrapper when glibc includes again (PR #77017)

2024-01-04 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl created 
https://github.com/llvm/llvm-project/pull/77017

Since D154036 landed (2a65d0388ca0 on July 7, 2023), I've been seeing many 
(40-50) libomptarget test failures with errors like the following on some of 
our test systems:

```
/auto/software/gcc/x86_64/gcc-11.1.0/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/cstdio:99:11:
 error: no member named 'fpos_t' in the global namespace
   99 |   using ::fpos_t;
  | ~~^
```

This patch fixes that and doesn't break our other test sytems.  I've looked 
through the glibc history and at LLVM's libc stdio.h to give me confidence that 
this solution should work on other systems.  Of course, there might be use 
cases I've overlooked, so feedback is appreciated.

>From 4bd9961fd69be29644942cd05417b622721bad92 Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 4 Jan 2024 17:27:29 -0500
Subject: [PATCH] [Clang][OpenMP] Fix stdio.h wrapper when glibc includes again

Since D154036 landed (2a65d0388ca0 on July 7, 2023), I've been seeing
many (40-50) libomptarget test failures with errors like the following
on some of our test systems:

```
/auto/software/gcc/x86_64/gcc-11.1.0/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/cstdio:99:11:
 error: no member named 'fpos_t' in the global namespace
   99 |   using ::fpos_t;
  | ~~^
```

This patch fixes that and doesn't break our other test sytems.  I've
looked through the glibc history and at LLVM's libc stdio.h to give me
confidence that this solution should work on other systems.  Of
course, there might be use cases I've overlooked, so feedback is
appreciated.
---
 clang/lib/Headers/llvm_libc_wrappers/stdio.h | 34 ++--
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h 
b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index 0870f3e741ec13..950f91b3763e85 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -6,15 +6,41 @@
 //
 
//===--===//
 
-#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
-#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
-
 #if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
 #error "This file is for GPU offloading compilation only"
 #endif
 
 #include_next 
 
+// In some old versions of glibc, other standard headers sometimes define
+// special macros (e.g., __need_FILE) before including stdio.h to cause stdio.h
+// to produce special definitions.  Future includes of stdio.h when those
+// special macros are undefined are expected to produce the normal definitions
+// from stdio.h.
+//
+// We do not apply our include guard (__CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__)
+// unconditionally to the above include_next.  Otherwise, after an occurrence 
of
+// the first glibc stdio.h use case described above, the include_next would be
+// skipped for remaining includes of stdio.h, leaving required symbols
+// undefined.
+//
+// We make the following assumptions to handle all use cases:
+//
+// 1. If the above include_next produces special glibc definitions, then (a) it
+//does not produce the normal definitions that we must intercept below, (b)
+//the current file was included from a glibc header that already defined
+//__GLIBC__ (usually by including glibc's ), and (c) the above
+//include_next does not define _STDIO_H.  In that case, we skip the rest of
+//the current file and don't guard against future includes.
+// 2. If the above include_next produces the normal stdio.h definitions, then
+//either (a) __GLIBC__ is not defined because C headers are from some other
+//libc implementation or (b) the above include_next defines _STDIO_H to
+//prevent the above include_next from having any effect in the future.
+#if !defined(__GLIBC__) || defined(_STDIO_H)
+
+#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
+#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
+
 #if __has_include()
 
 #if defined(__HIP__) || defined(__CUDA__)
@@ -50,3 +76,5 @@
 #endif
 
 #endif // __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
+
+#endif

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


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I have no stake in Apple/Swift, but for myself, `cmd` is the natural shell to 
> use on Windows. (When I install Visual Studio, it creates a widget that 
> brings up a `cmd` shell with the right environment. I'm not aware of a 
> similar widget for PowerShell.) While I rarely try to copy-paste from a `lit` 
> dump into `cmd` (the commands are generally too full of long paths to temp 
> locations to work well) I think it would be good (but not mandatory) for that 
> copy-paste to actually work.
> 
> Like others have said, I had not really grokked that Windows defaults to the 
> internal shell, although just this week I tripped over a behavioral 
> difference in how `diff` works in the two environments (not related to your 
> patches). So, if there seems to be benefit to making the external shell Just 
> Not Work on Windows, I wouldn't lose a lot of sleep over it.

In case it isn't clear, there are two somewhat orthogonal issues here:

- This PR is about whether lit can execute RUN lines in `cmd`.  That does not 
appear to have worked since April, 2022. 
- The copy-paste issue is about whether lit can print RUN lines in a form that 
the user can easily copy to `cmd`.  For RUN lines that were written for lit's 
internal shell, that might require lit to *translate* the RUN lines to a form 
compatible with `cmd`.  I say might because I don't have much experience there. 
 The `diff` example above sounds like an example.



https://github.com/llvm/llvm-project/pull/65242
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I think that might be a bit too accelerated. I work mostly with a fork of 
> LLVM (https://github.com/apple/llvm-project) and do care about the usability 
> of `cmd` as a shell (however, it is significantly behind but is working on 
> updating to a more recent version). I think that Swift is a large enough 
> consumer of LLVM to consider testing that before declaring this feature 
> removed.

Thanks for mentioning this.

Given that `cmd` as a lit external shell appears to be have been unusable since 
April, 2022, how is that fork relying on it?  Is it farther behind than that?

Fixing the remaining problem with `cmd` appears to be straight-forward, so I'm 
fine to do that.  However, how hard would it be to use lit's internal shell for 
your use case?

https://github.com/llvm/llvm-project/pull/65242
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I think that might be a bit too accelerated. I work mostly with a fork of 
> LLVM (https://github.com/apple/llvm-project) and do care about the usability 
> of `cmd` as a shell (however, it is significantly behind but is working on 
> updating to a more recent version). I think that Swift is a large enough 
> consumer of LLVM to consider testing that before declaring this feature 
> removed.

Thanks for mentioning this.

Given that `cmd` as a lit external shell appears to be have been unusable since 
April, 2022, how is that fork relying on it?  Is it farther behind than that?

Fixing the remaining problem with `cmd` appears to be straight-forward, so I'm 
fine to do that.  However, how hard would it be to use lit's internal shell for 
your use case?

https://github.com/llvm/llvm-project/pull/65242
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-05 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

Thanks for everyone's comments so far.

This PR is not ready to land.  As discussed, it doesn't fully fix support for 
windows `cmd` as a lit external shell.  Given how long that use case has been 
broken (apparently since April, 2022), it seems that's a use case no one cares 
about anymore.

Possible next steps include:

1. Fix windows `cmd` support.  That looks straight-forward.  If we're going to 
do that, then we probably should also apply changes that PR #65267 applied for 
sh-like external shells, and there [might still be further changes along those 
lines as 
well](https://discourse.llvm.org/t/rfc-improving-lits-debug-output/72839/44?u=jdenny-ornl).
  But I don't see a reason to go down this path if no one actually cares.
2. Land a patch to raise a python exception when lit encounters its code path 
to use windows `cmd` as an external shell.  If no one complains for a few 
weeks, then we drop support.
3. Rewrite this PR's title and commit log to explain what it does do: clean up 
the `%dbg` expansion implementation, and make `--per-test-coverage` work for 
lit's internal shell.

Please let me know if you have opinions on this.  When I have some more time, 
I'm thinking of pursuing 1 and 3.




https://github.com/llvm/llvm-project/pull/65242
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-05 Thread Joel E. Denny via cfe-commits

https://github.com/jdenny-ornl updated 
https://github.com/llvm/llvm-project/pull/65242:

>From 26d5891879583b9addd2a6d4d7caf4241ba55b85 Mon Sep 17 00:00:00 2001
From: "Joel E. Denny" 
Date: Thu, 31 Aug 2023 20:24:51 -0400
Subject: [PATCH 1/2] [lit] Are all RUN lines skipped in windows cmd?

Key issue
-

When lit is configured to use windows `cmd` as an external shell, it
appears that all RUN lines are effectively commented out.  The
problematic change landed in July 26, 2023, so it's surprising it
hasn't come up yet.  I'm afraid I don't have a windows setup, so I
could use some help to verify what's happening.

Details
---

In the case that lit is configured to use an external shell, D154280
(landed in 64d19542e78a on July 26, 2023) causes
`%dbg(RUN: at line N)` to be expanded in RUN lines early and in a
manner that is specific to sh-like shells.  As a result, later code in
lit that expands it in a shell-specific manner is useless.

That sh-like expansion uses the `:` command as follows:

```
: 'RUN: at line N'; original-commands
```

In sh-like shells, the `:` command simply discards its arguments.
However, in windows `cmd`, `:` indicates a goto label.  That appears
to effectively comment out the rest of the line, including the
original commands from the RUN line.

I am not aware of any complaints about this change.  Did I miss them?
Are all tests still passing and so no one noticed?  Lit's own test
suite has some tests that normally fail if RUN lines don't execute.
Is no one running lit's test suite with windows `cmd` as a lit
external shell?  Or is no one using windows `cmd` as a lit external
shell at all anymore?

Another issue
-

D154280 doesn't implement `--per-test-coverage` for lit's internal
shell.

Fix
---

This patch fixes the above problems by implementing
`--per-test-coverage` before selecting the shell (internal or
external) and by leaving `%dbg(RUN: at line N)` unexpanded.  Thus, it
is expanded later in a shell-specific manner, as before D154280.

I would like to understand whether windows `cmd` as a lit external
shell is worthwhile to support anymore.
---
 llvm/utils/lit/lit/TestRunner.py  | 44 ---
 .../per-test-coverage-by-lit-cfg/lit.cfg  |  4 +-
 .../per-test-coverage-by-lit-cfg.py   |  5 ++-
 .../tests/Inputs/per-test-coverage/lit.cfg|  5 ++-
 .../per-test-coverage/per-test-coverage.py|  5 ++-
 .../lit/tests/per-test-coverage-by-lit-cfg.py |  9 +++-
 llvm/utils/lit/tests/per-test-coverage.py |  9 +++-
 7 files changed, 53 insertions(+), 28 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 461cf63d6b9685..d564d6150a04a8 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1144,25 +1144,10 @@ def executeScriptInternal(test, litConfig, tmpBase, 
commands, cwd,
 def executeScript(test, litConfig, tmpBase, commands, cwd):
 bashPath = litConfig.getBashPath()
 isWin32CMDEXE = litConfig.isWindows and not bashPath
-coverage_index = 0  # Counter for coverage file index
 script = tmpBase + ".script"
 if isWin32CMDEXE:
 script += ".bat"
 
-# Set unique LLVM_PROFILE_FILE for each run command
-for j, ln in enumerate(commands):
-match = re.match(kPdbgRegex, ln)
-if match:
-command = match.group(2)
-commands[j] = match.expand(": '\\1'; \\2" if command else ": 
'\\1'")
-if litConfig.per_test_coverage:
-# Extract the test case name from the test object
-test_case_name = test.path_in_suite[-1]
-test_case_name = test_case_name.rsplit(".", 1)[0]  # Remove 
the file extension
-llvm_profile_file = f"{test_case_name}{coverage_index}.profraw"
-commands[j] = f"export LLVM_PROFILE_FILE={llvm_profile_file} 
&& {commands[j]}"
-coverage_index += 1
-
 # Write script file
 mode = "w"
 open_kwargs = {}
@@ -2115,10 +2100,35 @@ def parseIntegratedTestScript(test, 
additional_parsers=[], require_script=True):
 
 def _runShTest(test, litConfig, useExternalSh, script, tmpBase):
 def runOnce(execdir):
+# Set unique LLVM_PROFILE_FILE for each run command
+if litConfig.per_test_coverage:
+# Extract the test case name from the test object, and remove the
+# file extension.
+test_case_name = test.path_in_suite[-1]
+test_case_name = test_case_name.rsplit(".", 1)[0]
+coverage_index = 0  # Counter for coverage file index
+scriptProf = []
+for ln in script:
+match = re.match(kPdbgRegex, ln)
+if match:
+dbg = match.group(1)
+command = match.group(2)
+else:
+command = ln
+profile = f"{test_case_name}{coverage_index}.profraw"
+coverage_index 

[clang] 19841e4 - [OpenMP] Fix transformed loop's var privacy

2023-06-02 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2023-06-02T12:18:13-04:00
New Revision: 19841e4dcaabe573d35eb88a130fc34d32ecd708

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

LOG: [OpenMP] Fix transformed loop's var privacy

Without this patch, the following example crashes Clang:

```
 #pragma omp target map(i)
 #pragma omp tile sizes(2)
 for (i = 0; i < N; ++i)
   ;
```

This patch fixes the crash by changing `Sema::isOpenMPPrivateDecl` not
to identify `i` as private just because it's the loop variable of a
`tile` construct.

While OpenMP TR11 and earlier do specify privacy for loop variables of
loops *generated* from a `tile` construct, I haven't found text
stating that the original loop variable must be private in the above
example, so this patch leaves it shared.  Even so, it is a bit
unexpected that value of `i` after the loop is `N - 1` instead of `N`.

Reviewed By: ABataev

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

Added: 
openmp/libomptarget/test/offloading/target-tile.c

Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 6e83e20d96d59..0b6f5be9f0447 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2551,7 +2551,8 @@ OpenMPClauseKind Sema::isOpenMPPrivateDecl(ValueDecl *D, 
unsigned Level,
   }
 }
   }
-  if (isOpenMPLoopDirective(DSAStack->getCurrentDirective())) {
+  if (isOpenMPLoopDirective(DSAStack->getCurrentDirective()) &&
+  !isOpenMPLoopTransformationDirective(DSAStack->getCurrentDirective())) {
 if (DSAStack->getAssociatedLoops() > 0 && !DSAStack->isLoopStarted()) {
   DSAStack->resetPossibleLoopCounter(D);
   DSAStack->loopStart();

diff  --git a/clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp 
b/clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
index 44127525b2527..a710d889a0b6d 100644
--- a/clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
+++ b/clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
@@ -21,7 +21,7 @@ extern "C" void body(...) {}
 // IR-NEXT:store i32 %[[START:.+]], ptr %[[START_ADDR]], align 4
 // IR-NEXT:store i32 %[[END:.+]], ptr %[[END_ADDR]], align 4
 // IR-NEXT:store i32 %[[STEP:.+]], ptr %[[STEP_ADDR]], align 4
-// IR-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @2, i32 3, 
ptr @func.omp_outlined, ptr %[[END_ADDR]], ptr %[[STEP_ADDR]], ptr 
%[[START_ADDR]])
+// IR-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @2, i32 3, 
ptr @func.omp_outlined, ptr %[[START_ADDR]], ptr %[[END_ADDR]], ptr 
%[[STEP_ADDR]])
 // IR-NEXT:ret void
 // IR-NEXT:  }
 extern "C" void func(int start, int end, int step) {
@@ -36,9 +36,9 @@ extern "C" void func(int start, int end, int step) {
 // IR-NEXT:  [[ENTRY:.*]]:
 // IR-NEXT:%[[DOTGLOBAL_TID__ADDR:.+]] = alloca ptr, align 8
 // IR-NEXT:%[[DOTBOUND_TID__ADDR:.+]] = alloca ptr, align 8
+// IR-NEXT:%[[START_ADDR:.+]] = alloca ptr, align 8
 // IR-NEXT:%[[END_ADDR:.+]] = alloca ptr, align 8
 // IR-NEXT:%[[STEP_ADDR:.+]] = alloca ptr, align 8
-// IR-NEXT:%[[START_ADDR:.+]] = alloca ptr, align 8
 // IR-NEXT:%[[DOTOMP_IV:.+]] = alloca i32, align 4
 // IR-NEXT:%[[TMP:.+]] = alloca i32, align 4
 // IR-NEXT:%[[I:.+]] = alloca i32, align 4
@@ -57,12 +57,12 @@ extern "C" void func(int start, int end, int step) {
 // IR-NEXT:%[[DOTUNROLL_INNER_IV_I:.+]] = alloca i32, align 4
 // IR-NEXT:store ptr %[[DOTGLOBAL_TID_:.+]], ptr %[[DOTGLOBAL_TID__ADDR]], 
align 8
 // IR-NEXT:store ptr %[[DOTBOUND_TID_:.+]], ptr %[[DOTBOUND_TID__ADDR]], 
align 8
+// IR-NEXT:store ptr %[[START:.+]], ptr %[[START_ADDR]], align 8
 // IR-NEXT:store ptr %[[END:.+]], ptr %[[END_ADDR]], align 8
 // IR-NEXT:store ptr %[[STEP:.+]], ptr %[[STEP_ADDR]], align 8
-// IR-NEXT:store ptr %[[START:.+]], ptr %[[START_ADDR]], align 8
+// IR-NEXT:%[[TMP2:.+]] = load ptr, ptr %[[START_ADDR]], align 8
 // IR-NEXT:%[[TMP0:.+]] = load ptr, ptr %[[END_ADDR]], align 8
 // IR-NEXT:%[[TMP1:.+]] = load ptr, ptr %[[STEP_ADDR]], align 8
-// IR-NEXT:%[[TMP2:.+]] = load ptr, ptr %[[START_ADDR]], align 8
 // IR-NEXT:%[[TMP3:.+]] = load i32, ptr %[[TMP2]], align 4
 // IR-NEXT:store i32 %[[TMP3]], ptr %[[I]], align 4
 // IR-NEXT:%[[TMP4:.+]] = load i32, ptr %[[TMP2]], align 4

diff  --git a/openmp/libomptarget/test/offloading/target-tile.c 
b/openmp/libomptarget/test/offloading/target-tile.c
new file mode 100644
index 0..8460b43b6f9c7
--- /dev/null
+++ b/openmp/libomptarget/test/offloading/target-tile.c
@@ -0,0 +1,62 @@
+// Check that omp tile (introduced in OpenMP 5.1) is permitted and behaves when

[clang] 28412d1 - [lit] Implement DEFINE and REDEFINE directives

2022-09-21 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-09-21T11:32:05-04:00
New Revision: 28412d1800e391c5ba8e7607bb15c74b106d581b

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

LOG: [lit] Implement DEFINE and REDEFINE directives

These directives define per-test lit substitutions.  The concept was
discussed at
.

For example, the following directives can be inserted into a test file
to define `%{cflags}` and `%{fcflags}` substitutions with empty
initial values, which serve as the parameters of another newly defined
`%{check}` substitution:

```
// DEFINE: %{cflags} =
// DEFINE: %{fcflags} =

// DEFINE: %{check} = %clang_cc1 %{cflags} -emit-llvm -o - %s | \
// DEFINE:FileCheck %{fcflags} %s
```

The following directives then redefine the parameters before each use
of `%{check}`:

```
// REDEFINE: %{cflags} = -foo
// REDEFINE: %{fcflags} = -check-prefix=FOO
// RUN: %{check}

// REDEFINE: %{cflags} = -bar
// REDEFINE: %{fcflags} = -check-prefix=BAR
// RUN: %{check}
```

Of course, `%{check}` would typically be more elaborate, increasing
the benefit of the reuse.

One issue is that the strings `DEFINE:` and `REDEFINE:` already appear
in 5 tests.  This patch adjusts those tests not to use those strings.
Our prediction is that, in the vast majority of cases, if a test
author mistakenly uses one of those strings for another purpose, the
text appearing after the string will not happen to have the syntax
required for these directives.  Thus, the test author will discover
the mistake immediately when lit reports the syntax error.

This patch also expands the documentation on existing lit substitution
behavior.

Reviewed By: jhenderson, MaskRay, awarzynski

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

Added: 
llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/before-name.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/between-name-equals.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/braces-empty.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/braces-with-dot.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/braces-with-equals.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/braces-with-newline.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/braces-with-number.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/braces-with-ws.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/empty.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/no-equals.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/no-name.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/assignment/ws-only.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/empty.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/end-in-double-backslash.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-define-bad-redefine.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-define-continuation.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-define-redefine.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-define-run.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-define.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-redefine-bad-define.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-redefine-continuation.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-redefine-define.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-redefine-run.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-redefine.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-run-define.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/unterminated-run-redefine.txt
llvm/utils/lit/tests/Inputs/shtest-define/errors/continuation/ws-only.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/defined-check/define-already-by-config.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/defined-check/define-already-by-test.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/defined-check/define-inside-pattern.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/defined-check/define-multiple-exact.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/defined-check/define-multiple-once-exact.txt

llvm/utils/lit/tests/Inputs/shtest-define/errors/defined-check/define-prefixes-pattern.txt


[clang] 0103d4d - [Clang][OpenMP] Don't overload "extension" in status doc

2022-06-27 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-06-27T18:41:17-04:00
New Revision: 0103d4da740c9d2688389e2aa5e3c2f3792e6940

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

LOG: [Clang][OpenMP] Don't overload "extension" in status doc

In Clang's OpenMPSupport.rst, "extension" is currently overloaded to
describe both:

1. Standard OpenMP features that appear only in recent versions of the
   OpenMP spec.
2. Non-standard features supported by Clang.  This usage appears in
   the final table on the page.

Last fall, we discussed this issue in the OpenMP in LLVM call and
agreed it should be corrected.  This patch takes the simple approach
of dropping the word "extension" for all occurrences of the first
usage.  The result seems to read well.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 0f306be72ba0..336d8e597522 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -117,19 +117,19 @@ implementation.
 
+--+--+--+---+
 |Category  | Feature   
   | Status   | Reviews 
  |
 
+==+==+==+===+
-| loop extension   | support != in the canonical loop form 
   | :good:`done` | D54441  
  |
+| loop | support != in the canonical loop form 
   | :good:`done` | D54441  
  |
 
+--+--+--+---+
-| loop extension   | #pragma omp loop (directive)  
   | :part:`worked on`| 
  |
+| loop | #pragma omp loop (directive)  
   | :part:`worked on`| 
  |
 
+--+--+--+---+
-| loop extension   | collapse imperfectly nested loop  
   | :good:`done` | 
  |
+| loop | collapse imperfectly nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | collapse non-rectangular nested loop  
   | :good:`done` | 
  |
+| loop | collapse non-rectangular nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | C++ range-base for loop   
   | :good:`done` | 
  |
+| loop | C++ range-base for loop   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | clause: if for SIMD directives
   | 

[clang] d2e3cb7 - [OpenMP][Clang] Fix atomic compare for signed vs. unsigned

2022-05-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-05-30T11:02:20-04:00
New Revision: d2e3cb737417a2e5ffad34f666fa8510e88e8bc2

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

LOG: [OpenMP][Clang] Fix atomic compare for signed vs. unsigned

Without this patch, arguments to the
`llvm::OpenMPIRBuilder::AtomicOpValue` initializer are reversed.

Reviewed By: ABataev, tianshilei1992

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

Added: 
openmp/libomptarget/test/offloading/atomic-compare-signedness.c
openmp/runtime/test/atomic/omp-atomic-compare-signedness.c

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/atomic_compare_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 61e3661e59be..f78443fd20bc 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6188,8 +6188,8 @@ static void emitOMPAtomicCompareExpr(CodeGenFunction ,
 
   llvm::OpenMPIRBuilder::AtomicOpValue XOpVal{
   XAddr.getPointer(), XAddr.getElementType(),
-  X->getType().isVolatileQualified(),
-  X->getType()->hasSignedIntegerRepresentation()};
+  X->getType()->hasSignedIntegerRepresentation(),
+  X->getType().isVolatileQualified()};
 
   CGF.Builder.restoreIP(OMPBuilder.createAtomicCompare(
   CGF.Builder, XOpVal, EVal, DVal, AO, Op, IsXBinopExpr));

diff  --git a/clang/test/OpenMP/atomic_compare_codegen.cpp 
b/clang/test/OpenMP/atomic_compare_codegen.cpp
index cc36eae2cd50..825832399e3c 100644
--- a/clang/test/OpenMP/atomic_compare_codegen.cpp
+++ b/clang/test/OpenMP/atomic_compare_codegen.cpp
@@ -1979,21 +1979,21 @@ void foo(void) {
 // CHECK-NEXT:[[ULLE:%.*]] = alloca i64, align 8
 // CHECK-NEXT:[[ULLD:%.*]] = alloca i64, align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP0]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP0]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP2:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP3:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP2]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP3:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP2]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP4:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP5:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP4]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP5:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP4]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP6:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP7:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP6]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP7:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP6]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP8:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP9:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP8]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP9:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP8]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP10:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP11:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP10]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP11:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP10]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP12:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP13:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP12]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP13:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP12]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP14:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP15:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP14]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP15:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP14]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP16:%.*]] = load i8, i8* [[CE]], align 1
 // CHECK-NEXT:[[TMP17:%.*]] = load i8, i8* [[CD]], align 1
 // CHECK-NEXT:[[TMP18:%.*]] = cmpxchg i8* [[CX]], i8 [[TMP16]], i8 
[[TMP17]] monotonic monotonic, align 1
@@ -2035,28 +2035,28 @@ void foo(void) {
 // CHECK-NEXT:[[TMP54:%.*]] = load i8, i8* [[UCD]], align 1
 // CHECK-NEXT:[[TMP55:%.*]] = cmpxchg i8* [[UCX]], i8 [[TMP53]], i8 
[[TMP54]] monotonic monotonic, align 1
 // CHECK-NEXT:[[TMP56:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP57:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP56]] 
acq_rel, align 1
+// CHECK-NEXT:[[TMP57:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP56]] 
acq_rel, align 1
 // CHECK-NEXT:call void @__kmpc_flush(%struct.ident_t* @[[GLOB1:[0-9]+]])
 // CHECK-NEXT:[[TMP58:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP59:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP58]] 
acq_rel, align 1
+// CHECK-NEXT:[[TMP59:%.*]] = atomicrmw 

[clang] 4a36813 - [OpenACC][OpenMP] Document atomic-in-teams extension

2022-05-27 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-05-27T18:53:19-04:00
New Revision: 4a368136693ba9c4e827702e9d390280c3d5e7ac

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

LOG: [OpenACC][OpenMP] Document atomic-in-teams extension

That is, put D126323 in the status doc and explain its relationship to
OpenACC support.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst
openmp/docs/openacc/OpenMPExtensions.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 1292af07a8e41..88e3050d3622c 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -369,9 +369,12 @@ documentation are provided.  As these extensions mature, 
they will be
 considered for standardization.  Please contact *openmp-dev* at
 *lists.llvm.org* to provide feedback.
 
-+--+---+--++
-|Category  | Feature   
| Status   | Reviews
|
-+==+===+==++
-| device extension | `'ompx_hold' map type modifier
| :good:`prototyped`   | D106509, D106510   
|
-|  | 
`_  | 
 ||
-+--+---+--++
++--+---+--++
+|Category  | Feature   
| Status   | Reviews
|
++==+===+==++
+| atomic extension | `'atomic' strictly nested within 'teams'  
| :good:`prototyped`   | D126323
|
+|  | 
`_
  |  |  
  |
++--+---+--++
+| device extension | `'ompx_hold' map type modifier
| :good:`prototyped`   | D106509, 
D106510   |
+|  | 
`_
  |  |  
  |
++--+---+--++

diff  --git a/openmp/docs/openacc/OpenMPExtensions.rst 
b/openmp/docs/openacc/OpenMPExtensions.rst
index bc662c32e81ca..82cf77548b9a0 100644
--- a/openmp/docs/openacc/OpenMPExtensions.rst
+++ b/openmp/docs/openacc/OpenMPExtensions.rst
@@ -137,3 +137,36 @@ selecting OpenMP reference counts, the implementation is 
the same at
 the runtime level.  That is, OpenACC's dynamic reference count is
 OpenMP's dynamic reference count, and OpenACC's structured reference
 count is our OpenMP hold reference count extension.
+
+.. _atomicWithinTeams:
+
+``atomic`` Strictly Nested Within ``teams``
+---
+
+Example
+^^^
+
+OpenMP 5.2, sec. 10.2 "teams Construct", p. 232, L9-12 restricts what
+regions can be strictly nested within a ``teams`` region.  As an
+extension, Clang relaxes that restriction in the case of the
+``atomic`` construct so 

[clang] 48ca3a5 - [OpenMP] Extend omp teams to permit nested omp atomic

2022-05-26 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-05-26T14:59:16-04:00
New Revision: 48ca3a5ebb156ccb776eea399138b7cda4d13395

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

LOG: [OpenMP] Extend omp teams to permit nested omp atomic

OpenMP 5.2, sec. 10.2 "teams Construct", p. 232, L9-12 restricts what
regions can be strictly nested within a `teams` construct.  This patch
relaxes Clang's enforcement of this restriction in the case of nested
`atomic` constructs unless `-fno-openmp-extensions` is specified.
Cases like the following then seem to work fine with no additional
implementation changes:

```
 #pragma omp target teams map(tofrom:x)
 #pragma omp atomic update
 x++;
```

Reviewed By: ABataev

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

Added: 
openmp/libomptarget/test/offloading/target-teams-atomic.c
openmp/runtime/test/teams/teams-atomic.c

Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/nesting_of_regions.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 09c187f24a802..753decfb167cd 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4975,9 +4975,13 @@ static bool checkNestingOfRegions(Sema , const 
DSAStackTy *Stack,
   // omp_get_num_teams() regions, and omp_get_team_num() regions are the
   // only OpenMP regions that may be strictly nested inside the teams
   // region.
+  //
+  // As an extension, we permit atomic within teams as well.
   NestingProhibited = !isOpenMPParallelDirective(CurrentRegion) &&
   !isOpenMPDistributeDirective(CurrentRegion) &&
-  CurrentRegion != OMPD_loop;
+  CurrentRegion != OMPD_loop &&
+  !(SemaRef.getLangOpts().OpenMPExtensions &&
+CurrentRegion == OMPD_atomic);
   Recommend = ShouldBeInParallelRegion;
 }
 if (!NestingProhibited && CurrentRegion == OMPD_loop) {

diff  --git a/clang/test/OpenMP/nesting_of_regions.cpp 
b/clang/test/OpenMP/nesting_of_regions.cpp
index 7e23e00548197..3581b05e3a043 100644
--- a/clang/test/OpenMP/nesting_of_regions.cpp
+++ b/clang/test/OpenMP/nesting_of_regions.cpp
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45,omp45warn %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp50 %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45 -Wno-openmp %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45 -Wno-source-uses-openmp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fno-openmp-extensions 
-verify=expected,omp50,omp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-extensions 
-verify=expected,omp50 %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45,omp -fno-openmp-extensions -Wno-openmp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45,omp -fno-openmp-extensions -Wno-source-uses-openmp %s
 
-// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 
-verify=expected,omp45,omp45warn %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50 %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 
-fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50,omp 
-fno-openmp-extensions %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 void bar();
@@ -5264,7 +5265,7 @@ void foo() {
 #pragma omp target
 #pragma omp teams
   {
-#pragma omp atomic // expected-error {{region cannot be closely nested inside 
'teams' region; perhaps you forget to enclose 'omp atomic' directive into a 
parallel region?}}
+#pragma omp atomic // omp-error {{region cannot be closely nested inside 
'teams' region; perhaps you forget to enclose 'omp atomic' directive into a 
parallel region?}}
 ++a;
   }
 #pragma omp target
@@ -8422,7 +8423,7 @@ void foo() {
   }
 #pragma omp target teams
   {
-#pragma omp atomic // expected-error {{region cannot be closely nested inside 
'target teams' region; perhaps you forget to enclose 'omp atomic' directive 
into a parallel region?}}
+#pragma omp atomic // omp-error {{region cannot be closely nested inside 
'target teams' region; perhaps you forget to enclose 'omp atomic' directive 
into a parallel region?}}
 ++a;
   }
 #pragma omp target teams
@@ -14096,7 +14097,7 @@ void foo() {
 #pragma omp target
 #pragma omp teams
   {
-#pragma omp atomic // expected-error {{region cannot be closely 

[clang] 5b0a948 - [UpdateCCTestChecks] Implement --global-hex-value-regex

2021-07-20 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-07-20T11:23:20-04:00
New Revision: 5b0a948a81e695f044e88659be18a28256b1e309

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

LOG: [UpdateCCTestChecks] Implement --global-hex-value-regex

For example, in OpenMP offload codegen tests, global variables like
`.offload_maptypes*` are much easier to read in hex.

Reviewed By: jdoerfert

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c

clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
clang/test/utils/update_cc_test_checks/global-hex-value-regex.test

Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c 
b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c
new file mode 100644
index 0..ad4c109c45ec5
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+void foo() {
+  static int hex = 0x10;
+  static int dec = 10;
+}
+void bar() {
+  static int hex = 0x20;
+  static int dec = 20;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
new file mode 100644
index 0..3018d0261adf9
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
@@ -0,0 +1,25 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "foo\..*" "bar\..*" 
--global-hex-value-regex ".*\.hex"
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+//.
+// CHECK: @foo.hex = internal global i32 [[#0x10]], align 4
+// CHECK: @foo.dec = internal global i32 10, align 4
+// CHECK: @bar.hex = internal global i32 [[#0x20]], align 4
+// CHECK: @bar.dec = internal global i32 20, align 4
+//.
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void foo() {
+  static int hex = 0x10;
+  static int dec = 10;
+}
+// CHECK-LABEL: @bar(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void bar() {
+  static int hex = 0x20;
+  static int dec = 20;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/global-hex-value-regex.test 
b/clang/test/utils/update_cc_test_checks/global-hex-value-regex.test
new file mode 100644
index 0..6ff06b4028d82
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/global-hex-value-regex.test
@@ -0,0 +1,19 @@
+RUN: rm -rf %t && mkdir %t
+
+# Check --global-hex-value-regex.
+RUN: cp %S/Inputs/global-hex-value-regex.c %t/test.c
+RUN: %update_cc_test_checks %t/test.c --check-globals \
+RUN: --global-value-regex "foo\..*" "bar\..*" \
+RUN: --global-hex-value-regex ".*\.hex"
+RUN: 
diff  -u %S/Inputs/global-hex-value-regex.c.expected %t/test.c
+
+# Check that the generated directives actually work correctly.
+RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg
+# Show lit failures while avoiding confusing FileCheck input dump nesting.
+RUN: %lit %t
+# Lit was successful.  Sanity-check the results with deterministic test order.
+RUN: rm %t/.lit_test_times.txt
+RUN: %lit %t 2>&1 | FileCheck %s
+
+CHECK: Testing: 1 tests
+CHECK: PASS: {{.*}} test.c

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index 29d22401cf73d..aa9b845f05fdc 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -38,10 +38,13 @@ def parse_commandline_args(parser):
   help='Add a prefix to FileCheck IR value names to avoid 
conflicts with scripted names')
   parser.add_argument('--global-value-regex', nargs='+', default=[],
   help='List of regular expressions that a global value 
declaration must match to generate a check (has no effect if checking globals 
is not enabled)')
+  parser.add_argument('--global-hex-value-regex', nargs='+', default=[],
+  help='List of regular expressions such that, for 
matching global value declarations, literal integer values should be encoded in 
hex in the associated FileCheck directives')
   args = parser.parse_args()
-  global _verbose, _global_value_regex
+  global _verbose, _global_value_regex, _global_hex_value_regex
   _verbose = args.verbose
   _global_value_regex = args.global_value_regex
+  _global_hex_value_regex = args.global_hex_value_regex
   return args
 
 
@@ -607,6 +610,12 @@ def transform_line_vars(match):
   for i, line in 

[clang] 2f5b2ea - [UpdateCCTestChecks] Implement --global-value-regex

2021-07-20 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-07-20T11:23:20-04:00
New Revision: 2f5b2ea6cd854edfa2722ae0b5acf604a333e785

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

LOG: [UpdateCCTestChecks] Implement --global-value-regex

`--check-globals` activates checks for all global values, and
`--global-value-regex` filters them.  For example, I'd like to use it
in OpenMP offload codegen tests to check only global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c
clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
clang/test/utils/update_cc_test_checks/global-value-regex.test

Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c 
b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c
new file mode 100644
index 0..cacaac63b0368
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+void foo() {
+  static int i, j;
+}
+void bar() {
+  static int i, j;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
new file mode 100644
index 0..b0f74c5381984
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
@@ -0,0 +1,21 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "foo\.."
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+//.
+// CHECK: @foo.i = internal global i32 0, align 4
+// CHECK: @foo.j = internal global i32 0, align 4
+//.
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void foo() {
+  static int i, j;
+}
+// CHECK-LABEL: @bar(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void bar() {
+  static int i, j;
+}

diff  --git a/clang/test/utils/update_cc_test_checks/global-value-regex.test 
b/clang/test/utils/update_cc_test_checks/global-value-regex.test
new file mode 100644
index 0..33103e101794d
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/global-value-regex.test
@@ -0,0 +1,18 @@
+RUN: rm -rf %t && mkdir %t
+
+# Check --global-value-regex.
+RUN: cp %S/Inputs/global-value-regex.c %t/test.c
+RUN: %update_cc_test_checks %t/test.c --check-globals \
+RUN:   --global-value-regex "foo\.."
+RUN: 
diff  -u %S/Inputs/global-value-regex.c.expected %t/test.c
+
+# Check that the generated directives actually work correctly.
+RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg
+# Show lit failures while avoiding confusing FileCheck input dump nesting.
+RUN: %lit %t
+# Lit was successful.  Sanity-check the results with deterministic test order.
+RUN: rm %t/.lit_test_times.txt
+RUN: %lit %t 2>&1 | FileCheck %s
+
+CHECK: Testing: 1 tests
+CHECK: PASS: {{.*}} test.c

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index ff48e3b9f678e..29d22401cf73d 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -36,9 +36,12 @@ def parse_commandline_args(parser):
   help='List of regular expressions to replace matching 
value names')
   parser.add_argument('--prefix-filecheck-ir-name', default='',
   help='Add a prefix to FileCheck IR value names to avoid 
conflicts with scripted names')
+  parser.add_argument('--global-value-regex', nargs='+', default=[],
+  help='List of regular expressions that a global value 
declaration must match to generate a check (has no effect if checking globals 
is not enabled)')
   args = parser.parse_args()
-  global _verbose
+  global _verbose, _global_value_regex
   _verbose = args.verbose
+  _global_value_regex = args.global_value_regex
   return args
 
 
@@ -796,13 +799,27 @@ def add_global_checks(glob_val_dict, comment_marker, 
prefix_list, output_lines,
 if not glob_val_dict[checkprefix][nameless_value.check_prefix]:
   continue
 
-output_lines.append(comment_marker + SEPARATOR)
-
+check_lines = []
 global_vars_seen_before = [key for key in global_vars_seen.keys()]
 for line in glob_val_dict[checkprefix][nameless_value.check_prefix]:
+  if _global_value_regex:
+matched = False
+for regex in _global_value_regex:
+  if re.match('^@' + regex + ' = ', line):
+matched 

[clang] cc60fa2 - [UpdateCCTestChecks] Fix new test from 9eaf0d120d32

2021-06-25 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-06-25T14:29:58-04:00
New Revision: cc60fa2685bdbff889df826a1bfd5e52ffd163c8

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

LOG: [UpdateCCTestChecks] Fix new test from 9eaf0d120d32

`clang/test/utils/update_cc_test_checks/check-globals.test` from
9eaf0d120d32 broke at:

* 
* 

The problem is non-deterministic test order because the
`.lit_test_times.txt` from one run of a sample test suite affects the
other.

Added: 


Modified: 
clang/test/utils/update_cc_test_checks/check-globals.test

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/check-globals.test 
b/clang/test/utils/update_cc_test_checks/check-globals.test
index 2af041b5ec7c..def1a8e93672 100644
--- a/clang/test/utils/update_cc_test_checks/check-globals.test
+++ b/clang/test/utils/update_cc_test_checks/check-globals.test
@@ -31,7 +31,8 @@ RUN: rm %t/igf-again.c
 RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg
 # Show lit failures while avoiding confusing FileCheck input dump nesting.
 RUN: %lit %t
-# Lit was successful.  Sanity-check the results.
+# Lit was successful.  Sanity-check the results with deterministic test order.
+RUN: rm %t/.lit_test_times.txt
 RUN: %lit %t 2>&1 | FileCheck -check-prefix=LIT-RUN %s
 
 END.



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


[clang] 9eaf0d1 - [UpdateCCTestChecks] Support --check-globals

2021-06-25 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-06-25T13:17:56-04:00
New Revision: 9eaf0d120d3255c43789213c499513ba1be9dde7

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

LOG: [UpdateCCTestChecks] Support --check-globals

This option is already supported by update_test_checks.py, but it can
also be useful in update_cc_test_checks.py.  For example, I'd like to
use it in OpenMP offload codegen tests to check global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert, arichardson, ggeorgakoudis

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/check-globals.c
clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example
clang/test/utils/update_cc_test_checks/check-globals.test

Modified: 
clang/test/utils/update_cc_test_checks/lit.local.cfg
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_cc_test_checks.py

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/check-globals.c 
b/clang/test/utils/update_cc_test_checks/Inputs/check-globals.c
new file mode 100644
index 0..a63cec246e468
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/check-globals.c
@@ -0,0 +1,10 @@
+// First, make sure --check-globals doesn't crash on a non-FileChecked command.
+// RUN: true
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
%s
+
+void foo() {
+  static int i, j;
+}
+void bar() {
+  static int i, j;
+}

diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example 
b/clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example
new file mode 100644
index 0..c1afdc47956a3
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example
@@ -0,0 +1,9 @@
+import lit
+lit_config.load_config(
+config, os.path.join(lit_config.params.get('clang_obj_root'),
+ "test/lit.site.cfg.py"))
+config.name = 'update_cc_test_checks.py example'
+config.suffixes = ['.c', '.cpp']
+config.test_format = lit.formats.ShTest(execute_external=False)
+config.test_source_root = os.path.dirname(__file__)
+config.test_exec_root = os.path.dirname(__file__)

diff  --git a/clang/test/utils/update_cc_test_checks/check-globals.test 
b/clang/test/utils/update_cc_test_checks/check-globals.test
new file mode 100644
index 0..2af041b5ec7c4
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/check-globals.test
@@ -0,0 +1,83 @@
+RUN: rm -rf %t && mkdir %t
+
+# Check --check-globals in normal mode and in --include-generated-funcs mode.
+
+RUN: cp %S/Inputs/check-globals.c %t/norm.c
+RUN: %update_cc_test_checks %t/norm.c --check-globals
+RUN: FileCheck %s --input-file=%t/norm.c --match-full-lines -strict-whitespace 
\
+RUN:   -check-prefixes=BOTH,NRM
+
+RUN: cp %S/Inputs/check-globals.c %t/igf.c
+RUN: %update_cc_test_checks %t/igf.c --check-globals --include-generated-funcs
+RUN: FileCheck %s --input-file=%t/igf.c --match-full-lines -strict-whitespace \
+RUN:   -check-prefixes=BOTH,IGF
+
+# Check that repeating doesn't change it, such as duplicating '//.' 
occurrences.
+
+RUN: cp %t/norm.c %t/norm-again.c
+RUN: %update_cc_test_checks %t/norm-again.c --check-globals
+RUN: 
diff  -u %t/norm.c %t/norm-again.c
+RUN: rm %t/norm-again.c
+
+RUN: cp %t/igf.c %t/igf-again.c
+RUN: %update_cc_test_checks %t/igf-again.c --check-globals \
+RUN: --include-generated-funcs
+RUN: 
diff  -u %t/igf.c %t/igf-again.c
+RUN: rm %t/igf-again.c
+
+# Check that the generated directives actually work correctly.  For example,
+# they're not in the wrong order.
+
+RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg
+# Show lit failures while avoiding confusing FileCheck input dump nesting.
+RUN: %lit %t
+# Lit was successful.  Sanity-check the results.
+RUN: %lit %t 2>&1 | FileCheck -check-prefix=LIT-RUN %s
+
+END.
+
+  BOTH-NOT:{{.}}
+   NRM:// NOTE: Assertions have been autogenerated by 
utils/update_cc_test_checks.py UTC_ARGS: --check-globals
+   IGF:// NOTE: Assertions have been autogenerated by 
utils/update_cc_test_checks.py UTC_ARGS: --check-globals 
--include-generated-funcs
+ BOTH-NEXT:// {{.*}}
+ BOTH-NEXT:// RUN: true
+ BOTH-NEXT:// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+BOTH-EMPTY:
+  IGF-NEXT:void foo() {
+  IGF-NEXT:  static int i, j;
+  IGF-NEXT:}
+  IGF-NEXT:void bar() {
+  IGF-NEXT:  static int i, j;
+  IGF-NEXT:}
+ BOTH-NEXT://.
+ BOTH-NEXT:// CHECK: @foo.i = internal global i32 0, align 4
+ BOTH-NEXT:// CHECK: @foo.j = internal global i32 0, align 4
+ BOTH-NEXT:// CHECK: @bar.i = internal global i32 0, align 4
+ BOTH-NEXT:// CHECK: @bar.j = internal global i32 0, align 4
+ BOTH-NEXT://.
+ BOTH-NEXT:// CHECK-LABEL: @foo(
+ BOTH-NEXT:// CHECK-NEXT:  entry:
+ 

[clang] 2bfe053 - [UpdateCCTestChecks] Fix --replace-value-regex across RUN lines

2021-06-21 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-06-21T17:01:17-04:00
New Revision: 2bfe0536e5143caad80f7a9691fa775cf451317b

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

LOG: [UpdateCCTestChecks] Fix --replace-value-regex across RUN lines

Without this patch, llvm/utils/update_cc_test_checks.py fails to
perform `--replace-value-regex` replacements when two RUN lines
produce the same output and use the same single FileCheck prefix.  The
problem is that replacements in a RUN line's output are not performed
until after comparing against previous RUN lines' output, where
replacements have already been performed.  This patch fixes that.

Reviewed By: MaskRay

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

Added: 

clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c

clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test

Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c
 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c
new file mode 100644
index ..8914a2195371
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+
+void foo(void) {
+  #pragma omp target
+  ;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
new file mode 100644
index ..ea3cc9480f6d
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/replace-value-regex-across-runs.c.expected
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+"
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_foo_l7() 
#[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret void
+//
+void foo(void) {
+  #pragma omp target
+  ;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test 
b/clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test
new file mode 100644
index ..c2fdf6113fc2
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/replace-value-regex-across-runs.test
@@ -0,0 +1,7 @@
+# Test that --replace-value-regex is applied correctly when multiple RUN lines
+# use the same FileCheck prefix and have the same output.
+
+RUN: cp %S/Inputs/replace-value-regex-across-runs.c %t.c
+RUN: %update_cc_test_checks %t.c \
+RUN: --replace-value-regex '__omp_offloading_[0-9a-z]+_[0-9a-z]+'
+RUN: 
diff  -u %S/Inputs/replace-value-regex-across-runs.c.expected %t.c

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index 80b0c847080c..3f3682c5b9de 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -351,27 +351,6 @@ def process_run_line(self, function_re, scrubber, 
raw_tool_output, prefixes):
 for l in scrubbed_body.splitlines():
   print('  ' + l, file=sys.stderr)
   for prefix in prefixes:
-if func in self._func_dict[prefix]:
-  if (self._func_dict[prefix][func] is None or
-  str(self._func_dict[prefix][func]) != scrubbed_body or
-  self._func_dict[prefix][func].args_and_sig != args_and_sig or
-  self._func_dict[prefix][func].attrs != attrs):
-if (self._func_dict[prefix][func] is not None and
-self._func_dict[prefix][func].is_same_except_arg_names(
-scrubbed_extra,
-args_and_sig,
-attrs)):
-  self._func_dict[prefix][func].scrub = scrubbed_extra
-  self._func_dict[prefix][func].args_and_sig = args_and_sig
-  continue
-else:
-  # This means a previous RUN line produced a body for this 
function
-  # that is 
diff erent from the one produced by this current RUN line,
-  # so the body can't be common accross RUN lines. We use None to
-  

[clang] 82e99f5 - [OpenMP] Fix second debug name from map clause

2021-04-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2021-04-30T16:26:59-04:00
New Revision: 82e99f50351dd83d854f45bab3d91d4e6ad6450e

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

LOG: [OpenMP] Fix second debug name from map clause

This patch fixes a bug from D89802.  For example, without it, Clang
generates x as the debug map name for both x and y in the following
example:

```
 #pragma omp target map(to: x, y)
 x = y = 1;
```

Reviewed By: jhuber6

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_map_names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a3c7365fafd87..fce6efe9fee01 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7763,6 +7763,8 @@ class MappableExprsHandler {
   const ValueDecl *MapDecl = (I->getAssociatedDeclaration())
  ? I->getAssociatedDeclaration()
  : BaseDecl;
+  MapExpr = (I->getAssociatedExpression()) ? I->getAssociatedExpression()
+   : MapExpr;
 
   // Get information on whether the element is a pointer. Have to do a
   // special treatment for array sections given that they are built-in

diff  --git a/clang/test/OpenMP/target_map_names.cpp 
b/clang/test/OpenMP/target_map_names.cpp
index c9ca447f18bd9..a96a1e9d87719 100644
--- a/clang/test/OpenMP/target_map_names.cpp
+++ b/clang/test/OpenMP/target_map_names.cpp
@@ -16,7 +16,6 @@
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
-// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->i;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->s.f;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
@@ -25,7 +24,6 @@
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps->ps;{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
-// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->ps->ps->s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.f[:22];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.p[:33];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";ps->p[:33];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
@@ -181,6 +179,18 @@ void qux() {
 
 // DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";s.Z[0:64];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
 
+// Clang used to mistakenly generate the map name "x" for both x and y on this
+// directive.  Conditions to reproduce the bug: a single map clause has two
+// variables, and at least the second is used in the associated statement.
+//
+// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";x;{{.*}}.cpp;[[@LINE+3]];7;;\00"
+// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] 
c";y;{{.*}}.cpp;[[@LINE+2]];10;;\00"
+void secondMapNameInClause() {
+  int x, y;
+  #pragma omp target map(to: x, y)
+  x = y = 1;
+}
+
 // DEBUG: %{{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i8* @{{.+}}, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, i64* 
{{.+}}, i8** getelementptr inbounds ([{{[0-9]+}} x i8*], [{{[0-9]+}} x i8*]* 
@.offload_mapnames{{.*}}, i32 0, i32 0), i8** {{.+}})
 // DEBUG: %{{.+}} = call i32 @__tgt_target_teams_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i8* @{{.+}}, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* {{.+}}, 
i64* {{.+}}, i8** getelementptr inbounds ([{{[0-9]+}} x i8*], [{{[0-9]+}} x 
i8*]* @.offload_mapnames{{.*}}, i32 0, i32 0), i8** {{.+}}, i32 {{.+}}, i32 
{{.+}})
 // DEBUG: call 

[clang] 26cf9c1 - [OpenMP][Docs] Add map clause reordering status as unclaimed

2020-08-05 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-08-05T10:03:31-04:00
New Revision: 26cf9c17044515cdde3e7baeea843001ba33be59

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

LOG: [OpenMP][Docs] Add map clause reordering status as unclaimed

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index af5e538b1435..9bad27ea8817 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -221,6 +221,8 @@ implementation.
 
+--+--+--+---+
 | device extension | pointer attachment
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
+| device extension | map clause reordering based on map types  
   | :none:`unclaimed`| 
  |
++--+--+--+---+
 | atomic extension | hints for the atomic construct
   | :good:`done` | D51233  
  |
 
+--+--+--+---+
 | base language| C11 support   
   | :good:`done` | 
  |
@@ -272,3 +274,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+
+| device extension | map clause reordering reordering based on 
'present' modifier | :none:`unclaimed`| 
  |
++--+--+--+---+



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


[clang] 002d61d - [OpenMP] Fix `present` for exit from `omp target data`

2020-08-05 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-08-05T10:03:31-04:00
New Revision: 002d61db2b7790dc884953bf9271878bf0af3a8e

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

LOG: [OpenMP] Fix `present` for exit from `omp target data`

Without this patch, the following example fails but shouldn't
according to OpenMP TR8:

```
 #pragma omp target enter data map(alloc:i)
 #pragma omp target data map(present, alloc: i)
 {
   #pragma omp target exit data map(delete:i)
 } // fails presence check here
```

OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 321, L23-26 states:

> If the map clause appears on a target, target data, target enter
> data or target exit data construct with a present map-type-modifier
> then on entry to the region if the corresponding list item does not
> appear in the device data environment an error occurs and the
> program terminates.

There is no corresponding statement about the exit from a region.
Thus, the `present` modifier should:

1. Check for presence upon entry into any region, including a `target
   exit data` region.  This behavior is already implemented correctly.

2. Should not check for presence upon exit from any region, including
   a `target` or `target data` region.  Without this patch, this
   behavior is not implemented correctly, breaking the above example.

In the case of `target data`, this patch fixes the latter behavior by
removing the `present` modifier from the map types Clang generates for
the runtime call at the end of the region.

In the case of `target`, we have not found a valid OpenMP program for
which such a fix would matter.  It appears that, if a program can
guarantee that data is present at the beginning of a `target` region
so that there's no error there, that data is also guaranteed to be
present at the end.  This patch adds a comment to the runtime to
document this case.

Reviewed By: grokos, RaviNarayanaswamy, ABataev

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

Added: 
openmp/libomptarget/test/mapping/present/target_data_at_exit.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/target_data_codegen.cpp
openmp/libomptarget/src/omptarget.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 60c7081b135b..547a9307dce2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8826,6 +8826,30 @@ emitOffloadingArrays(CodeGenFunction ,
 MapTypesArrayGbl->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 Info.MapTypesArray = MapTypesArrayGbl;
 
+// If there's a present map type modifier, it must not be applied to the 
end
+// of a region, so generate a separate map type array in that case.
+if (Info.separateBeginEndCalls()) {
+  bool EndMapTypesDiffer = false;
+  for (uint64_t  : Mapping) {
+if (Type & MappableExprsHandler::OMP_MAP_PRESENT) {
+  Type &= ~MappableExprsHandler::OMP_MAP_PRESENT;
+  EndMapTypesDiffer = true;
+}
+  }
+  if (EndMapTypesDiffer) {
+MapTypesArrayInit =
+llvm::ConstantDataArray::get(CGF.Builder.getContext(), Mapping);
+MaptypesName = CGM.getOpenMPRuntime().getName({"offload_maptypes"});
+MapTypesArrayGbl = new llvm::GlobalVariable(
+CGM.getModule(), MapTypesArrayInit->getType(),
+/*isConstant=*/true, llvm::GlobalValue::PrivateLinkage,
+MapTypesArrayInit, MaptypesName);
+MapTypesArrayGbl->setUnnamedAddr(
+llvm::GlobalValue::UnnamedAddr::Global);
+Info.MapTypesArrayEnd = MapTypesArrayGbl;
+  }
+}
+
 for (unsigned I = 0; I < Info.NumberOfPtrs; ++I) {
   llvm::Value *BPVal = *CombinedInfo.BasePointers[I];
   llvm::Value *BP = CGF.Builder.CreateConstInBoundsGEP2_32(
@@ -8878,12 +8902,16 @@ emitOffloadingArrays(CodeGenFunction ,
 }
 
 /// Emit the arguments to be passed to the runtime library based on the
-/// arrays of base pointers, pointers, sizes, map types, and mappers.
+/// arrays of base pointers, pointers, sizes, map types, and mappers.  If
+/// ForEndCall, emit map types to be passed for the end of the region instead 
of
+/// the beginning.
 static void emitOffloadingArraysArgument(
 CodeGenFunction , llvm::Value *,
 llvm::Value *, llvm::Value *,
 llvm::Value *, llvm::Value *,
-CGOpenMPRuntime::TargetDataInfo ) {
+CGOpenMPRuntime::TargetDataInfo , bool ForEndCall = false) {
+  assert((!ForEndCall || Info.separateBeginEndCalls()) &&
+ "expected region end call to runtime only when end call is separate");
   CodeGenModule  = CGF.CGM;
   if (Info.NumberOfPtrs) {
 

[clang] 03bb545 - [OpenMP][Docs] Mark `present` map type modifier as done

2020-08-05 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-08-05T10:03:31-04:00
New Revision: 03bb545b68c2edb9dc5bd092104bdb83a8e5e347

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

LOG: [OpenMP][Docs] Mark `present` map type modifier as done

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 9bad27ea8817..e63d91586b95 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -270,7 +270,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`worked on`| D76342  
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
+| device extension | 'present' map type modifier   
   | :good:`done` | D83061, D83062, D84422  
  |
 
+--+--+--+---+
 | device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] 3d06fc0 - [OpenMP][Docs] Mark `present` motion modifier as done

2020-07-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-30T12:21:37-04:00
New Revision: 3d06fc0049c6bb94e6efd77388453206037f43ad

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

LOG: [OpenMP][Docs] Mark `present` motion modifier as done

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index bda52e934c26..28fbd7baebb2 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -270,5 +270,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
 
+--+--+--+---+
-| device extension | 'present' motion modifier 
   | :part:`worked on`| D84711, D84712  
  |
+| device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] 9f2f3b9 - [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-29 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-29T12:18:45-04:00
New Revision: 9f2f3b9de6314a009322b6081c792ebf9a469460

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

LOG: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

This patch implements Clang front end support for the OpenMP TR8
`present` motion modifier for `omp target update` directives.  The
next patch in this series implements OpenMP runtime support.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 4f94aa7074ee..5b588f4b5740 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,8 +6329,20 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
+  /// Motion-modifiers for the 'to' clause.
+  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
+  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
+
+  /// Location of motion-modifiers for the 'to' clause.
+  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param TheMotionModifiers Motion-modifiers.
+  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6342,13 +6354,24 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(ArrayRef TheMotionModifiers,
+   ArrayRef TheMotionModifiersLoc,
+   NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy ,
const OMPMappableExprListSizeTy )
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, ,
-  ) {}
+  ) {
+assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
+   "Unexpected number of motion modifiers.");
+llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
+
+assert(llvm::array_lengthof(MotionModifiersLoc) ==
+   TheMotionModifiersLoc.size() &&
+   "Unexpected number of motion modifier locations.");
+llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
+  }
 
   /// Build an empty clause.
   ///
@@ -6361,6 +6384,29 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
+  /// Set motion-modifier for the clause.
+  ///
+  /// \param I index for motion-modifier.
+  /// \param T motion-modifier for the clause.
+  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Unexpected index to store motion modifier, exceeds array size.");
+MotionModifiers[I] = T;
+  }
+
+  /// Set location for the motion-modifier.
+  ///
+  /// \param I index for motion-modifier location.
+  /// \param TLoc motion-modifier location.
+  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Index to store motion 

[clang] 69fc33f - Revert "[OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)"

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T20:30:05-04:00
New Revision: 69fc33f0cd130b02a38d2fc582afc7b0fcd6458a

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

LOG: Revert "[OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)"

This reverts commit 3c3faae497046be706df29e16c9fbccb7e1fce09.

It breaks a number of bots.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 46c26c6c77de..c649502f765b 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,20 +6329,8 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
-  /// Motion-modifiers for the 'to' clause.
-  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
-  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
-
-  /// Location of motion-modifiers for the 'to' clause.
-  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
-
-  /// Colon location.
-  SourceLocation ColonLoc;
-
   /// Build clause with number of variables \a NumVars.
   ///
-  /// \param TheMotionModifiers Motion-modifiers.
-  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6354,24 +6342,13 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(ArrayRef TheMotionModifiers,
-   ArrayRef TheMotionModifiersLoc,
-   NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy ,
const OMPMappableExprListSizeTy )
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, ,
-  ) {
-assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
-   "Unexpected number of motion modifiers.");
-llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
-
-assert(llvm::array_lengthof(MotionModifiersLoc) ==
-   TheMotionModifiersLoc.size() &&
-   "Unexpected number of motion modifier locations.");
-llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
-  }
+  ) {}
 
   /// Build an empty clause.
   ///
@@ -6384,29 +6361,6 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
-  /// Set motion-modifier for the clause.
-  ///
-  /// \param I index for motion-modifier.
-  /// \param T motion-modifier for the clause.
-  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
-assert(I < NumberOfOMPMotionModifiers &&
-   "Unexpected index to store motion modifier, exceeds array size.");
-MotionModifiers[I] = T;
-  }
-
-  /// Set location for the motion-modifier.
-  ///
-  /// \param I index for motion-modifier location.
-  /// \param TLoc motion-modifier location.
-  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
-assert(I < NumberOfOMPMotionModifiers &&
-   "Index to store motion modifier location exceeds array size.");
-MotionModifiersLoc[I] = TLoc;
-  }
-
-  /// Set colon location.
-  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
-
   

[clang] 3c3faae - [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T19:15:18-04:00
New Revision: 3c3faae497046be706df29e16c9fbccb7e1fce09

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

LOG: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

This patch implements Clang front end support for the OpenMP TR8
`present` motion modifier for `omp target update` directives.  The
next patch in this series implements OpenMP runtime support.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index c649502f765b..46c26c6c77de 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,8 +6329,20 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
+  /// Motion-modifiers for the 'to' clause.
+  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
+  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
+
+  /// Location of motion-modifiers for the 'to' clause.
+  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param TheMotionModifiers Motion-modifiers.
+  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6342,13 +6354,24 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(ArrayRef TheMotionModifiers,
+   ArrayRef TheMotionModifiersLoc,
+   NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy ,
const OMPMappableExprListSizeTy )
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, ,
-  ) {}
+  ) {
+assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
+   "Unexpected number of motion modifiers.");
+llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
+
+assert(llvm::array_lengthof(MotionModifiersLoc) ==
+   TheMotionModifiersLoc.size() &&
+   "Unexpected number of motion modifier locations.");
+llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
+  }
 
   /// Build an empty clause.
   ///
@@ -6361,6 +6384,29 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
+  /// Set motion-modifier for the clause.
+  ///
+  /// \param I index for motion-modifier.
+  /// \param T motion-modifier for the clause.
+  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Unexpected index to store motion modifier, exceeds array size.");
+MotionModifiers[I] = T;
+  }
+
+  /// Set location for the motion-modifier.
+  ///
+  /// \param I index for motion-modifier location.
+  /// \param TLoc motion-modifier location.
+  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Index to store motion 

[clang] a3d1f88 - [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T19:15:18-04:00
New Revision: a3d1f88fa7da3dfc0b4319f2e4eb7374fa60b819

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

LOG: [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

`to` and `from` clauses take the same modifiers, which are called
"motion modifiers" in TR8, so implement handling of their modifiers
once not twice.  This will make it easier to implement additional
motion modifiers in the future.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 275c4fcdabb2..04ecbeaaa03e 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -29,11 +29,8 @@
 #ifndef OPENMP_MAP_MODIFIER_KIND
 #define OPENMP_MAP_MODIFIER_KIND(Name)
 #endif
-#ifndef OPENMP_TO_MODIFIER_KIND
-#define OPENMP_TO_MODIFIER_KIND(Name)
-#endif
-#ifndef OPENMP_FROM_MODIFIER_KIND
-#define OPENMP_FROM_MODIFIER_KIND(Name)
+#ifndef OPENMP_MOTION_MODIFIER_KIND
+#define OPENMP_MOTION_MODIFIER_KIND(Name)
 #endif
 #ifndef OPENMP_DIST_SCHEDULE_KIND
 #define OPENMP_DIST_SCHEDULE_KIND(Name)
@@ -126,11 +123,8 @@ OPENMP_MAP_MODIFIER_KIND(close)
 OPENMP_MAP_MODIFIER_KIND(mapper)
 OPENMP_MAP_MODIFIER_KIND(present)
 
-// Modifiers for 'to' clause.
-OPENMP_TO_MODIFIER_KIND(mapper)
-
-// Modifiers for 'from' clause.
-OPENMP_FROM_MODIFIER_KIND(mapper)
+// Modifiers for 'to' or 'from' clause.
+OPENMP_MOTION_MODIFIER_KIND(mapper)
 
 // Static attributes for 'dist_schedule' clause.
 OPENMP_DIST_SCHEDULE_KIND(static)
@@ -163,8 +157,7 @@ OPENMP_REDUCTION_MODIFIER(task)
 #undef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
 #undef OPENMP_MAP_KIND
 #undef OPENMP_MAP_MODIFIER_KIND
-#undef OPENMP_TO_MODIFIER_KIND
-#undef OPENMP_FROM_MODIFIER_KIND
+#undef OPENMP_MOTION_MODIFIER_KIND
 #undef OPENMP_DIST_SCHEDULE_KIND
 #undef OPENMP_DEFAULTMAP_KIND
 #undef OPENMP_DEFAULTMAP_MODIFIER

diff  --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index dc6198f93f9d..3e9b5c4a8b14 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -86,20 +86,12 @@ enum OpenMPMapModifierKind {
 static constexpr unsigned NumberOfOMPMapClauseModifiers =
 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
 
-/// OpenMP modifier kind for 'to' clause.
-enum OpenMPToModifierKind {
-#define OPENMP_TO_MODIFIER_KIND(Name) \
-  OMPC_TO_MODIFIER_##Name,
+/// OpenMP modifier kind for 'to' or 'from' clause.
+enum OpenMPMotionModifierKind {
+#define OPENMP_MOTION_MODIFIER_KIND(Name) \
+  OMPC_MOTION_MODIFIER_##Name,
 #include "clang/Basic/OpenMPKinds.def"
-  OMPC_TO_MODIFIER_unknown
-};
-
-/// OpenMP modifier kind for 'from' clause.
-enum OpenMPFromModifierKind {
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  OMPC_FROM_MODIFIER_##Name,
-#include "clang/Basic/OpenMPKinds.def"
-  OMPC_FROM_MODIFIER_unknown
+  OMPC_MOTION_MODIFIER_unknown
 };
 
 /// OpenMP attributes for 'dist_schedule' clause.

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 4807702e896e..da362f99ed29 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -64,17 +64,12 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind 
Kind, StringRef Str,
 return Type;
   }
   case OMPC_to:
-return llvm::StringSwitch(Str)
-#define OPENMP_TO_MODIFIER_KIND(Name)  
\
-  .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
-#include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_TO_MODIFIER_unknown);
   case OMPC_from:
 return llvm::StringSwitch(Str)
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  
\
+  .Case(#Name, static_cast(OMPC_MOTION_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_FROM_MODIFIER_unknown);
+.Default(OMPC_MOTION_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -258,29 +253,18 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 llvm_unreachable("Invalid OpenMP 'map' clause type");
   case OMPC_to:
-switch (Type) {
-case OMPC_TO_MODIFIER_unknown:
-  return "unknown";
-#define OPENMP_TO_MODIFIER_KIND(Name)   

[clang] f250eb3 - [OpenMP][Docs] Update `present` modifier status

2020-07-27 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-27T19:23:55-04:00
New Revision: f250eb37cd4fabcc9f222ca2da80b62d110d9fff

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

LOG: [OpenMP][Docs] Update `present` modifier status

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 26fbfab96bc8..a1d1b120bcec 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,5 +268,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`worked on`| D83061, D83062  
  |
+| device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
++--+--+--+---+
+| device extension | 'present' motion modifier 
   | :part:`worked on`| D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] d6e79e3 - [OpenMP][Docs] Update `present` map type modifier status

2020-07-15 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-15T11:17:00-04:00
New Revision: d6e79e3dd6df63425eb098f482be2c9744ad48eb

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

LOG: [OpenMP][Docs] Update `present` map type modifier status

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 000f23141af3..26fbfab96bc8 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,5 +268,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`claimed`  | 
  |
+| device extension | 'present' map type modifier   
   | :part:`worked on`| D83061, D83062  
  |
 
+--+--+--+---+



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


[clang] ed39bec - [OpenMP][NFC] Remove hard-coded line numbers from more tests

2020-07-07 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-07T09:48:22-04:00
New Revision: ed39becd274dae5537c24b2107737d718527e718

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

LOG: [OpenMP][NFC] Remove hard-coded line numbers from more tests

This is a continuation of D82224.

Reviewed By: grokos

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

Added: 


Modified: 
clang/test/OpenMP/target_defaultmap_codegen.cpp
clang/test/OpenMP/target_map_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_defaultmap_codegen.cpp 
b/clang/test/OpenMP/target_defaultmap_codegen.cpp
index 140574c18c74..3deff63273d5 100644
--- a/clang/test/OpenMP/target_defaultmap_codegen.cpp
+++ b/clang/test/OpenMP/target_defaultmap_codegen.cpp
@@ -20,7 +20,7 @@
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
-allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY10 %s
 // SIMD-ONLY10-NOT: {{__kmpc|__tgt}}
 
-// CK1-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l44.region_id = 
weak constant i8 0
+// CK1-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id
 = weak constant i8 0
 
 // CK1-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544
@@ -70,7 +70,7 @@ void implicit_maps_double_complex (int a){
 // SIMD-ONLY10-NOT: {{__kmpc|__tgt}}
 #ifdef CK2
 
-// CK2-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l94.region_id = 
weak constant i8 0
+// CK2-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id
 = weak constant i8 0
 
 // CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TO  | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545
@@ -120,7 +120,7 @@ void implicit_maps_double_complex (int a){
 // SIMD-ONLY10-NOT: {{__kmpc|__tgt}}
 #ifdef CK3
 
-// CK3-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l144.region_id = 
weak constant i8 0
+// CK3-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id
 = weak constant i8 0
 
 // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546
@@ -173,7 +173,7 @@ void implicit_maps_double_complex (int a){
 // For a 32-bit targets, the value doesn't fit the size of the pointer,
 // therefore it is passed by reference with a map 'to' specification.
 
-// CK4-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l209.region_id = weak 
constant i8 0
+// CK4-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 
 // CK4-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 
800
@@ -242,7 +242,7 @@ void implicit_maps_double (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK5
 
-// CK5-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l266.region_id = weak 
constant i8 0
+// CK5-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK5-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544
@@ -293,7 +293,7 @@ void implicit_maps_array (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK6
 
-// CK6-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l317.region_id = weak 
constant i8 0
+// CK6-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK6-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TO | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545
@@ -344,7 +344,7 @@ void implicit_maps_array (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK7
 
-// CK7-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l368.region_id = weak 
constant i8 0
+// CK7-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK7-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546
@@ -395,7 +395,7 @@ void implicit_maps_array (int a){
 // SIMD-ONLY8-NOT: {{__kmpc|__tgt}}
 #ifdef CK8
 
-// CK8-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l419.region_id = weak 
constant i8 0
+// CK8-LABEL: 
@.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak 
constant i8 0
 
 // CK8-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16]
 // Map types: OMP_MAP_TO | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | 

[clang] 01ddb2a - [OpenMP][NFC] Remove hard-coded line numbers from test

2020-06-24 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-06-24T14:35:01-04:00
New Revision: 01ddb2a7b044f697a15043e47acdb93e2825809a

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

LOG: [OpenMP][NFC] Remove hard-coded line numbers from test

Otherwise, it's painful to insert new code.  There are many existing
examples in the same test file where the line numbers are not
hard-coded.

I intend to do the same for several other OpenMP tests, but I want to
be sure there are no objections before I spend time on it.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/test/OpenMP/target_map_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_map_codegen.cpp 
b/clang/test/OpenMP/target_map_codegen.cpp
index ecfe50c01ea6..7fc4fcb71911 100644
--- a/clang/test/OpenMP/target_map_codegen.cpp
+++ b/clang/test/OpenMP/target_map_codegen.cpp
@@ -1323,173 +1323,173 @@ void implicit_maps_template_type_capture (int a){
 // SIMD-ONLY18-NOT: {{__kmpc|__tgt}}
 #ifdef CK19
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1514.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE00:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1535.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1557.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE01:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE01:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1576.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE02:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE02:@.+]] = private {{.*}}constant [1 x i64] [i64 34]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1595.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE03:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE03:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1614.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE04:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE04:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1633.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE05:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE05:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1656.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[MTYPE06:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1679.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[MTYPE07:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1698.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE08:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE08:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1719.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = 
weak constant i8 0
 // CK19: [[SIZE09:@.+]] = private {{.*}}constant [1 x 

[clang] 3fa666b - [OpenMP][Docs] Mark TR8 `present` as claimed in docs

2020-06-24 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-06-24T14:21:11-04:00
New Revision: 3fa666b883625a678cfcfd9ad96b2daabcef09e8

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

LOG: [OpenMP][Docs] Mark TR8 `present` as claimed in docs

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 0b6a183e5345..000f23141af3 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,3 +268,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
+| device extension | 'present' map type modifier   
   | :part:`claimed`  | 
  |
++--+--+--+---+



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


[clang] a1fd188 - [FileCheck] Support comment directives

2020-05-13 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-13T11:29:48-04:00
New Revision: a1fd188223d9c9b404dccd3511fe8b63ef022a13

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

LOG: [FileCheck] Support comment directives

Sometimes you want to disable a FileCheck directive without removing
it entirely, or you want to write comments that mention a directive by
name.  The `COM:` directive makes it easy to do this.  For example,
you might have:

```
; X32: pinsrd_1:
; X32:pinsrd $1, 4(%esp), %xmm0

; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but
; COM: X64 will have something similar to X32:
; COM:
; COM:   X64: pinsrd_1:
; COM:   X64:pinsrd $1, %edi, %xmm0
```

Without this patch, you need to use some combination of rewording and
directive syntax mangling to prevent FileCheck from recognizing the
commented occurrences of `X32:` and `X64:` above as directives.
Moreover, FileCheck diagnostics have been proposed that might complain
about the occurrences of `X64` that don't have the trailing `:`
because they look like directive typos:

  

I think dodging all these problems can prove tedious for test authors,
and directive syntax mangling already makes the purpose of existing
test code unclear.  `COM:` can avoid all these problems.

This patch also updates the small set of existing tests that define
`COM` as a check prefix:

- clang/test/CodeGen/default-address-space.c
- clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
- clang/test/Driver/hip-device-libs.hip
- llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll

I think lit should support `COM:` as well.  Perhaps `clang -verify`
should too.

Reviewed By: jhenderson, thopre

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

Added: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt

Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..6b3d7bc2e32a 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// COM-LABEL: define i32 @test1()
+// CHECK-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// COM-LABEL: define i32 @test2(i32 %i)
-// COM: %[[addr:.*]] = getelementptr
+// CHECK-LABEL: define i32 @test2(i32 %i)
+// CHECK: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// COM-LABEL: define void @test3()
+// CHECK-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index 35cc54c50d6f..e1f3f6fe1419 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o 

[clang] d0e7fd6 - Revert "[FileCheck] Support comment directives"

2020-05-11 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-11T19:41:22-04:00
New Revision: d0e7fd6b624b1943f3780a69883690017d2efad2

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

LOG: Revert "[FileCheck] Support comment directives"

This reverts commit 9a9a5f9893c8db05cebc8818eb8485bff61f7c74 to try to
fix a bot:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23489

Added: 


Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt



diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 6b3d7bc2e32a..21ba2b3269c2 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// CHECK-LABEL: define i32 @test1()
+// COM-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// CHECK-LABEL: define i32 @test2(i32 %i)
-// CHECK: %[[addr:.*]] = getelementptr
+// COM-LABEL: define i32 @test2(i32 %i)
+// COM: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// CHECK-LABEL: define void @test3()
+// COM-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index e1f3f6fe1419..35cc54c50d6f 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=ALL,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O0 -triple 
spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR 
%s
 
 typedef int int2 __attribute__((ext_vector_type(2)));
@@ -50,7 +50,7 @@ Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
   return out;
 }
 
-// ALL-LABEL: define {{.*}} void @ker
+// COM-LABEL: define {{.*}} void @ker
 // Expect two mem copies: one for the argument "in", and one for
 // the return value.
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
@@ -70,7 +70,7 @@ Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) {
   return out;
 }
 
-// ALL-LABEL: define {{.*}} void @ker_large
+// COM-LABEL: define {{.*}} void @ker_large
 // Expect two mem copies: one for the argument "in", and one for
 // the return value.
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*

diff  --git a/clang/test/Driver/hip-device-libs.hip 
b/clang/test/Driver/hip-device-libs.hip
index 6afc48e31dd2..cb1747c2d798 100644
--- a/clang/test/Driver/hip-device-libs.hip
+++ b/clang/test/Driver/hip-device-libs.hip
@@ -10,7 +10,7 @@
 // RUN:   --cuda-gpu-arch=gfx803 \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib   \
 // RUN: 

[clang] 9a9a5f9 - [FileCheck] Support comment directives

2020-05-11 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-11T14:53:48-04:00
New Revision: 9a9a5f9893c8db05cebc8818eb8485bff61f7c74

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

LOG: [FileCheck] Support comment directives

Sometimes you want to disable a FileCheck directive without removing
it entirely, or you want to write comments that mention a directive by
name.  The `COM:` directive makes it easy to do this.  For example,
you might have:

```
; X32: pinsrd_1:
; X32:pinsrd $1, 4(%esp), %xmm0

; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but
; COM: X64 will have something similar to X32:
; COM:
; COM:   X64: pinsrd_1:
; COM:   X64:pinsrd $1, %edi, %xmm0
```

Without this patch, you need to use some combination of rewording and
directive syntax mangling to prevent FileCheck from recognizing the
commented occurrences of `X32:` and `X64:` above as directives.
Moreover, FileCheck diagnostics have been proposed that might complain
about the occurrences of `X64` that don't have the trailing `:`
because they look like directive typos:

  

I think dodging all these problems can prove tedious for test authors,
and directive syntax mangling already makes the purpose of existing
test code unclear.  `COM:` can avoid all these problems.

This patch also updates the small set of existing tests that define
`COM` as a check prefix:

- clang/test/CodeGen/default-address-space.c
- clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
- clang/test/Driver/hip-device-libs.hip
- llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll

I think lit should support `COM:` as well.  Perhaps `clang -verify`
should too.

Reviewed By: jhenderson, thopre

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

Added: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt

Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..6b3d7bc2e32a 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// COM-LABEL: define i32 @test1()
+// CHECK-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// COM-LABEL: define i32 @test2(i32 %i)
-// COM: %[[addr:.*]] = getelementptr
+// CHECK-LABEL: define i32 @test2(i32 %i)
+// CHECK: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// COM-LABEL: define void @test3()
+// CHECK-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index 35cc54c50d6f..e1f3f6fe1419 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o 

[clang] c85fa79 - [Attr] Fix `-ast-print` for `asm` attribute

2019-11-18 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2019-11-18T11:55:25-05:00
New Revision: c85fa79d3663ecb3117e178b2a79ffa721d18e32

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

LOG: [Attr] Fix `-ast-print` for `asm` attribute

Without this fix, the tests introduced here produce the following
assert fail:

```
clang: /home/jdenny/llvm/clang/include/clang/Basic/AttributeCommonInfo.h:163: 
unsigned int clang::AttributeCommonInfo::getAttributeSpellingListIndex() const: 
Assertion `(isAttributeSpellingListCalculated() || AttrName) && "Spelling 
cannot be found"' failed.
```

The bug was introduced by D67368, which caused `AsmLabelAttr`'s
spelling index to be set to `SpellingNotCalculated`.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-print-attr.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b469217108ce..6d857e832c4b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7019,8 +7019,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   }
 }
 
-NewVD->addAttr(::new (Context) AsmLabelAttr(
-Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true));
+NewVD->addAttr(AsmLabelAttr::Create(Context, Label,
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -8923,9 +8924,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
   if (Expr *E = (Expr*) D.getAsmLabel()) {
 // The parser guarantees this is a string.
 StringLiteral *SE = cast(E);
-NewFD->addAttr(::new (Context)
-   AsmLabelAttr(Context, SE->getStrTokenLoc(0),
-SE->getString(), /*IsLiteralLabel=*/true));
+NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier());

diff  --git a/clang/test/AST/ast-print-attr.c b/clang/test/AST/ast-print-attr.c
index 223e27b39790..6448437c5eab 100644
--- a/clang/test/AST/ast-print-attr.c
+++ b/clang/test/AST/ast-print-attr.c
@@ -10,3 +10,8 @@ using B = int ** __ptr32 *[3];
 // FIXME: Too many parens here!
 // CHECK: using C = int ((*))() __attribute__((cdecl));
 using C = int (*)() [[gnu::cdecl]];
+
+// CHECK: int fun_asm() asm("");
+int fun_asm() asm("");
+// CHECK: int var_asm asm("");
+int var_asm asm("");



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


[clang-tools-extra] r375058 - [lit] Fix another test case that r374652 missed

2019-10-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Oct 16 16:58:58 2019
New Revision: 375058

URL: http://llvm.org/viewvc/llvm-project?rev=375058=rev
Log:
[lit] Fix another test case that r374652 missed

Modified:
clang-tools-extra/trunk/test/clang-include-fixer/merge.test

Modified: clang-tools-extra/trunk/test/clang-include-fixer/merge.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-include-fixer/merge.test?rev=375058=375057=375058=diff
==
--- clang-tools-extra/trunk/test/clang-include-fixer/merge.test (original)
+++ clang-tools-extra/trunk/test/clang-include-fixer/merge.test Wed Oct 16 
16:58:58 2019
@@ -1,6 +1,6 @@
 # RUN: find-all-symbols -merge-dir=%S/Inputs/merge %t.merged
 # RUN: sed '/^#/d' %s > %t.golden
-# RUN: diff -u %t.golden %t.merged
+# RUN: diff --strip-trailing-cr -u %t.golden %t.merged
 ---
 Name:bar
 Contexts:


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


r369619 - [OpenMP] Permit map with DSA on combined directive

2019-08-21 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Aug 21 20:34:30 2019
New Revision: 369619

URL: http://llvm.org/viewvc/llvm-project?rev=369619=rev
Log:
[OpenMP] Permit map with DSA on combined directive

For `map`, the following restriction changed in OpenMP 5.0:

* OpenMP 4.5 [2.15.5.1, Restrictions]: "A list item cannot appear in
  both a map clause and a data-sharing attribute clause on the same
  construct.

* OpenMP 5.0 [2.19.7.1, Restrictions]: "A list item cannot appear in
  both a map clause and a data-sharing attribute clause on the same
  construct unless the construct is a combined construct."

This patch removes this restriction in the case of combined constructs
and OpenMP 5.0, and it updates Sema not to capture a scalar by copy in
the target region when `firstprivate` and `map` appear for that scalar
on a combined target construct.

This patch also adds a fixme to a test that now reveals that a
diagnostic about loop iteration variables is dropped in the case of
OpenMP 5.0.  That bug exists regardless of this patch's changes.

Reviewed By: ABataev, jdoerfert, hfinkel, kkwli0

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

Added:
cfe/trunk/test/OpenMP/target_teams_map_codegen.cpp
Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_private_messages.cpp
cfe/trunk/test/OpenMP/target_teams_map_messages.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=369619=369618=369619=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Wed Aug 21 20:34:30 2019
@@ -756,13 +756,16 @@ public:
   unsigned short CapRegionKind;
 
   unsigned short OpenMPLevel;
+  unsigned short OpenMPCaptureLevel;
 
   CapturedRegionScopeInfo(DiagnosticsEngine , Scope *S, CapturedDecl *CD,
   RecordDecl *RD, ImplicitParamDecl *Context,
-  CapturedRegionKind K, unsigned OpenMPLevel)
+  CapturedRegionKind K, unsigned OpenMPLevel,
+  unsigned OpenMPCaptureLevel)
   : CapturingScopeInfo(Diag, ImpCap_CapturedRegion),
 TheCapturedDecl(CD), TheRecordDecl(RD), TheScope(S),
-ContextParam(Context), CapRegionKind(K), OpenMPLevel(OpenMPLevel) {
+ContextParam(Context), CapRegionKind(K), OpenMPLevel(OpenMPLevel),
+OpenMPCaptureLevel(OpenMPCaptureLevel) {
 Kind = SK_CapturedRegion;
   }
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=369619=369618=369619=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug 21 20:34:30 2019
@@ -1421,8 +1421,8 @@ public:
   void RecordParsingTemplateParameterDepth(unsigned Depth);
 
   void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
-   RecordDecl *RD,
-   CapturedRegionKind K);
+   RecordDecl *RD, CapturedRegionKind K,
+   unsigned OpenMPCaptureLevel = 0);
 
   /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
   /// time after they've been popped.
@@ -3979,7 +3979,8 @@ public:
   typedef std::pair CapturedParamNameType;
   void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
 CapturedRegionKind Kind,
-ArrayRef Params);
+ArrayRef Params,
+unsigned OpenMPCaptureLevel = 0);
   StmtResult ActOnCapturedRegionEnd(Stmt *S);
   void ActOnCapturedRegionError();
   RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *,
@@ -9028,7 +9029,9 @@ public:
   /// reference.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.
-  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const;
+  /// \param OpenMPCaptureLevel Capture level within an OpenMP construct.
+  bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
+ unsigned OpenMPCaptureLevel) const;
 
   /// Check if the specified variable is used in one of 

r369049 - [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug

2019-08-15 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Aug 15 14:17:48 2019
New Revision: 369049

URL: http://llvm.org/viewvc/llvm-project?rev=369049=rev
Log:
[Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug

I'd like to add these comments to warn others of problems I
encountered when trying to use `RemoveLineIfEmpty`.  I originally
tried to fix the problem, but I realized I could implement the
functionality more easily and efficiently in my calling code where I
can make the simplifying assumption that there are no prior edits to
the line from which text is being removed.  While I've lost the
motivation to write a fix, which doesn't look easy, I figure a warning
to others is better than silence.

I've added a unit test to demonstrate the problem.  I don't know how
to mark it as an expected failure, so I just marked it disabled.

Reviewed By: jkorous

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

Modified:
cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
cfe/trunk/lib/Rewrite/Rewriter.cpp
cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp

Modified: cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Core/Rewriter.h?rev=369049=369048=369049=diff
==
--- cfe/trunk/include/clang/Rewrite/Core/Rewriter.h (original)
+++ cfe/trunk/include/clang/Rewrite/Core/Rewriter.h Thu Aug 15 14:17:48 2019
@@ -46,6 +46,17 @@ public:
 
 /// If true and removing some text leaves a blank line
 /// also remove the empty line (false by default).
+///
+/// FIXME: This sometimes corrupts the file's rewrite buffer due to
+/// incorrect indexing in the implementation (see the FIXME in
+/// clang::RewriteBuffer::RemoveText).  Moreover, it's inefficient because
+/// it must scan the buffer from the beginning to find the start of the
+/// line.  When feasible, it's better for the caller to check for a blank
+/// line and then, if found, expand the removal range to include it.
+/// Checking for a blank line is easy if, for example, the caller can
+/// guarantee this is the first edit of a line.  In that case, it can just
+/// scan before and after the removal range until the next newline or
+/// begin/end of the input.
 bool RemoveLineIfEmpty = false;
 
 RewriteOptions() {}

Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=369049=369048=369049=diff
==
--- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Rewriter.cpp Thu Aug 15 14:17:48 2019
@@ -96,6 +96,17 @@ void RewriteBuffer::RemoveText(unsigned
 }
 if (posI != end() && *posI == '\n') {
   Buffer.erase(curLineStartOffs, lineSize + 1/* + '\n'*/);
+  // FIXME: Here, the offset of the start of the line is supposed to be
+  // expressed in terms of the original input not the "real" rewrite
+  // buffer.  How do we compute that reliably?  It might be tempting to use
+  // curLineStartOffs + OrigOffset - RealOffset, but that assumes the
+  // difference between the original and real offset is the same at the
+  // removed text and at the start of the line, but that's not true if
+  // edits were previously made earlier on the line.  This bug is also
+  // documented by a FIXME on the definition of
+  // clang::Rewriter::RewriteOptions::RemoveLineIfEmpty.  A reproducer for
+  // the implementation below is the test RemoveLineIfEmpty in
+  // clang/unittests/Rewrite/RewriteBufferTest.cpp.
   AddReplaceDelta(curLineStartOffs, -(lineSize + 1/* + '\n'*/));
 }
   }

Modified: cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp?rev=369049=369048=369049=diff
==
--- cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp (original)
+++ cfe/trunk/unittests/Rewrite/RewriteBufferTest.cpp Thu Aug 15 14:17:48 2019
@@ -14,6 +14,16 @@ using namespace clang;
 
 namespace {
 
+#define EXPECT_OUTPUT(Buf, Output) EXPECT_EQ(Output, writeOutput(Buf))
+
+static std::string writeOutput(const RewriteBuffer ) {
+  std::string Result;
+  raw_string_ostream OS(Result);
+  Buf.write(OS);
+  OS.flush();
+  return Result;
+}
+
 static void tagRange(unsigned Offset, unsigned Len, StringRef tagName,
  RewriteBuffer ) {
   std::string BeginTag;
@@ -40,11 +50,64 @@ TEST(RewriteBuffer, TagRanges) {
   tagRange(Pos, TagStr.size(), "outer", Buf);
   tagRange(Pos, TagStr.size(), "inner", Buf);
 
-  std::string Result;
-  raw_string_ostream OS(Result);
-  Buf.write(OS);
-  OS.flush();
-  EXPECT_EQ(Output, Result);
+  EXPECT_OUTPUT(Buf, Output);
+}
+
+TEST(RewriteBuffer, DISABLED_RemoveLineIfEmpty_XFAIL) {
+  

r365264 - [Rewrite] Try to fix buildbot link fail left by r365263

2019-07-06 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Sat Jul  6 09:28:32 2019
New Revision: 365264

URL: http://llvm.org/viewvc/llvm-project?rev=365264=rev
Log:
[Rewrite] Try to fix buildbot link fail left by r365263

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10272

Modified:
cfe/trunk/unittests/Rewrite/CMakeLists.txt

Modified: cfe/trunk/unittests/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/CMakeLists.txt?rev=365264=365263=365264=diff
==
--- cfe/trunk/unittests/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rewrite/CMakeLists.txt Sat Jul  6 09:28:32 2019
@@ -10,5 +10,6 @@ clang_target_link_libraries(RewriteTests
   PRIVATE
   clangFrontend
   clangRewrite
+  clangSerialization
   clangTooling
   )


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


r365263 - [Rewrite] Try to fix buildbot link fail caused by r365258

2019-07-06 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Sat Jul  6 06:44:57 2019
New Revision: 365263

URL: http://llvm.org/viewvc/llvm-project?rev=365263=rev
Log:
[Rewrite] Try to fix buildbot link fail caused by r365258

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10270

Modified:
cfe/trunk/unittests/Rewrite/CMakeLists.txt

Modified: cfe/trunk/unittests/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/CMakeLists.txt?rev=365263=365262=365263=diff
==
--- cfe/trunk/unittests/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rewrite/CMakeLists.txt Sat Jul  6 06:44:57 2019
@@ -8,6 +8,7 @@ add_clang_unittest(RewriteTests
   )
 clang_target_link_libraries(RewriteTests
   PRIVATE
+  clangFrontend
   clangRewrite
   clangTooling
   )


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


r365258 - [Rewrite] Extend to further accept CharSourceRange

2019-07-05 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Jul  5 19:55:06 2019
New Revision: 365258

URL: http://llvm.org/viewvc/llvm-project?rev=365258=rev
Log:
[Rewrite] Extend to further accept CharSourceRange

Some Rewrite functions are already overloaded to accept
CharSourceRange, and this extends others in the same manner.  I'm
calling these in code that's not ready to upstream, but I figure they
might be useful to others in the meantime.

Reviewed By: jdoerfert

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

Added:
cfe/trunk/unittests/Rewrite/RewriterTest.cpp
Modified:
cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
cfe/trunk/lib/Rewrite/Rewriter.cpp
cfe/trunk/unittests/Rewrite/CMakeLists.txt

Modified: cfe/trunk/include/clang/Rewrite/Core/Rewriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Core/Rewriter.h?rev=365258=365257=365258=diff
==
--- cfe/trunk/include/clang/Rewrite/Core/Rewriter.h (original)
+++ cfe/trunk/include/clang/Rewrite/Core/Rewriter.h Fri Jul  5 19:55:06 2019
@@ -84,7 +84,16 @@ public:
   /// in different buffers, this returns an empty string.
   ///
   /// Note that this method is not particularly efficient.
-  std::string getRewrittenText(SourceRange Range) const;
+  std::string getRewrittenText(CharSourceRange Range) const;
+
+  /// getRewrittenText - Return the rewritten form of the text in the specified
+  /// range.  If the start or end of the range was unrewritable or if they are
+  /// in different buffers, this returns an empty string.
+  ///
+  /// Note that this method is not particularly efficient.
+  std::string getRewrittenText(SourceRange Range) const {
+return getRewrittenText(CharSourceRange::getTokenRange(Range));
+  }
 
   /// InsertText - Insert the specified string at the specified location in the
   /// original buffer.  This method returns true (and does nothing) if the 
input
@@ -140,6 +149,13 @@ public:
 
   /// ReplaceText - This method replaces a range of characters in the input
   /// buffer with a new string.  This is effectively a combined "remove/insert"
+  /// operation.
+  bool ReplaceText(CharSourceRange range, StringRef NewStr) {
+return ReplaceText(range.getBegin(), getRangeSize(range), NewStr);
+  }
+
+  /// ReplaceText - This method replaces a range of characters in the input
+  /// buffer with a new string.  This is effectively a combined "remove/insert"
   /// operation.
   bool ReplaceText(SourceRange range, StringRef NewStr) {
 return ReplaceText(range.getBegin(), getRangeSize(range), NewStr);

Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=365258=365257=365258=diff
==
--- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Rewriter.cpp Fri Jul  5 19:55:06 2019
@@ -170,7 +170,7 @@ int Rewriter::getRangeSize(SourceRange R
 /// in different buffers, this returns an empty string.
 ///
 /// Note that this method is not particularly efficient.
-std::string Rewriter::getRewrittenText(SourceRange Range) const {
+std::string Rewriter::getRewrittenText(CharSourceRange Range) const {
   if (!isRewritable(Range.getBegin()) ||
   !isRewritable(Range.getEnd()))
 return {};
@@ -193,7 +193,9 @@ std::string Rewriter::getRewrittenText(S
 
 // Adjust the end offset to the end of the last token, instead of being the
 // start of the last token.
-EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
+if (Range.isTokenRange())
+  EndOff +=
+  Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
 return std::string(Ptr, Ptr+EndOff-StartOff);
   }
 
@@ -203,7 +205,8 @@ std::string Rewriter::getRewrittenText(S
 
   // Adjust the end offset to the end of the last token, instead of being the
   // start of the last token.
-  EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
+  if (Range.isTokenRange())
+EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
 
   // Advance the iterators to the right spot, yay for linear time algorithms.
   RewriteBuffer::iterator Start = RB.begin();

Modified: cfe/trunk/unittests/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rewrite/CMakeLists.txt?rev=365258=365257=365258=diff
==
--- cfe/trunk/unittests/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rewrite/CMakeLists.txt Fri Jul  5 19:55:06 2019
@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(RewriteTests
   RewriteBufferTest.cpp
+  RewriterTest.cpp
   )
 clang_target_link_libraries(RewriteTests
   PRIVATE
   clangRewrite
+  clangTooling
   )

Added: cfe/trunk/unittests/Rewrite/RewriterTest.cpp
URL: 

[clang-tools-extra] r361867 - [OpenMP] Set pragma start loc to `#pragma` loc

2019-05-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 28 12:27:19 2019
New Revision: 361867

URL: http://llvm.org/viewvc/llvm-project?rev=361867=rev
Log:
[OpenMP] Set pragma start loc to `#pragma` loc

This patch adjusts `PragmaOpenMPHandler` to set the location of
`tok::annot_pragma_openmp` to the `#pragma` location instead of the
`omp` location so that the former becomes the start location of the
OpenMP AST node.  This can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.  Most of this patch updates
tests for changes to locations in diagnostics and `-ast-dump` output.

Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp?rev=361867=361866=361867=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp Tue May 
28 12:27:19 2019
@@ -23,7 +23,7 @@ void n0(const int a) {
 void p0_0() {
 #pragma omp parallel
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' does 
not specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' does 
not specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'parallel' directive can have 'default' clause, and said clause specified,
@@ -38,7 +38,7 @@ void p0_1() {
 void p0_2() {
 #pragma omp parallel default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
   // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified 
here
 }
 
@@ -49,7 +49,7 @@ void p0_2() {
 void p1_0() {
 #pragma omp task
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' does not 
specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' does not 
specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'task' directive can have 'default' clause, and said clause specified,
@@ -64,7 +64,7 @@ void p1_1() {
 void p1_2() {
 #pragma omp task default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified 
here
 }
 
@@ -76,7 +76,7 @@ void p2_0() {
 #pragma omp target
 #pragma omp teams
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' does not 
specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' does not 
specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'teams' directive can have 'default' clause, and said clause specified,
@@ -93,7 +93,7 @@ void p2_2() {
 #pragma omp target
 #pragma omp teams default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified 
here
 }
 
@@ -105,7 +105,7 @@ void p3_0(const int a) {
 #pragma omp taskloop
   for (int b = 0; b < a; b++)
 ;
-  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' does 
not specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' does 
not specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'taskloop' directive can have 'default' clause, and said clause specified,
@@ -122,7 +122,7 @@ void p3_2(const int a) {
 #pragma omp taskloop default(shared)
   for (int b = 0; b < a; b++)
 ;
-  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 

r361335 - [PragmaHandler] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 21 16:51:38 2019
New Revision: 361335

URL: http://llvm.org/viewvc/llvm-project?rev=361335=rev
Log:
[PragmaHandler] Expose `#pragma` location

Currently, a pragma AST node's recorded location starts at the
namespace token (such as `omp` in the case of OpenMP) after the
`#pragma` token, and the `#pragma` location isn't available.  However,
the `#pragma` location can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.

This patch makes `#pragma` locations available in any `PragmaHandler`
but it doesn't yet make use of them.

This patch also uses the new `struct PragmaIntroducer` to simplify
`Preprocessor::HandlePragmaDirective`.  It doesn't do the same for
`PPCallbacks::PragmaDirective` because that changes the API documented
in `clang-tools-extra/docs/pp-trace.rst`, and I'm not sure about
backward compatibility guarantees there.

Reviewed By: ABataev, lebedev.ri, aaron.ballman

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

Modified:
cfe/trunk/docs/ClangPlugins.rst
cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp
cfe/trunk/include/clang/Lex/Pragma.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp

Modified: cfe/trunk/docs/ClangPlugins.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangPlugins.rst?rev=361335=361334=361335=diff
==
--- cfe/trunk/docs/ClangPlugins.rst (original)
+++ cfe/trunk/docs/ClangPlugins.rst Tue May 21 16:51:38 2019
@@ -55,7 +55,7 @@ registering it using ``PragmaHandlerRegi
   class ExamplePragmaHandler : public PragmaHandler {
   public:
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
   Token ) {
   // Handle the pragma
 }

Modified: cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp?rev=361335=361334=361335=diff
==
--- cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp (original)
+++ cfe/trunk/examples/AnnotateFunctions/AnnotateFunctions.cpp Tue May 21 
16:51:38 2019
@@ -58,7 +58,7 @@ class PragmaAnnotateHandler : public Pra
 public:
   PragmaAnnotateHandler() : PragmaHandler("enable_annotate") { }
 
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override {
 
 Token Tok;

Modified: cfe/trunk/include/clang/Lex/Pragma.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Pragma.h?rev=361335=361334=361335=diff
==
--- cfe/trunk/include/clang/Lex/Pragma.h (original)
+++ cfe/trunk/include/clang/Lex/Pragma.h Tue May 21 16:51:38 2019
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_LEX_PRAGMA_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -46,6 +47,12 @@ class Token;
 PIK___pragma
   };
 
+  /// Describes how and where the pragma was introduced.
+  struct PragmaIntroducer {
+PragmaIntroducerKind Kind;
+SourceLocation Loc;
+  };
+
 /// PragmaHandler - Instances of this interface defined to handle the various
 /// pragmas that the language front-end uses.  Each handler optionally has a
 /// name (e.g. "pack") and the HandlePragma method is invoked when a pragma 
with
@@ -64,7 +71,7 @@ public:
   virtual ~PragmaHandler();
 
   StringRef getName() const { return Name; }
-  virtual void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  virtual void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) = 0;
 
   /// getIfNamespace - If this is a namespace, return it.  This is equivalent 
to
@@ -78,7 +85,7 @@ class EmptyPragmaHandler : public Pragma
 public:
   explicit EmptyPragmaHandler(StringRef Name = StringRef());
 
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 };
 
@@ -111,7 +118,7 @@ public:
 
   bool IsEmpty() const { return Handlers.empty(); }
 
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 
   PragmaNamespace *getIfNamespace() override { return this; }

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 

r358917 - [VerifyDiagnosticConsumer] Document -verify= in doxygen

2019-04-22 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon Apr 22 13:25:06 2019
New Revision: 358917

URL: http://llvm.org/viewvc/llvm-project?rev=358917=rev
Log:
[VerifyDiagnosticConsumer] Document -verify= in doxygen

Previously, it was only documented by `-cc1 -help`, so people weren't
aware of it, as discussed in D60732.

Reviewed By: Charusso, NoQ

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

Modified:
cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h

Modified: cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h?rev=358917=358916=358917=diff
==
--- cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h Mon Apr 22 
13:25:06 2019
@@ -33,7 +33,33 @@ class TextDiagnosticBuffer;
 /// markers in the input source to check that all the emitted diagnostics match
 /// those expected.
 ///
-/// USING THE DIAGNOSTIC CHECKER:
+/// INVOKING THE DIAGNOSTIC CHECKER:
+///
+/// VerifyDiagnosticConsumer is typically invoked via the "-verify" option to
+/// "clang -cc1".  "-verify" is equivalent to "-verify=expected", so all
+/// diagnostics are typically specified with the prefix "expected".  For
+/// example:
+///
+/// \code
+///   int A = B; // expected-error {{use of undeclared identifier 'B'}}
+/// \endcode
+///
+/// Custom prefixes can be specified as a comma-separated sequence.  Each
+/// prefix must start with a letter and contain only alphanumeric characters,
+/// hyphens, and underscores.  For example, given just "-verify=foo,bar",
+/// the above diagnostic would be ignored, but the following diagnostics would
+/// be recognized:
+///
+/// \code
+///   int A = B; // foo-error {{use of undeclared identifier 'B'}}
+///   int C = D; // bar-error {{use of undeclared identifier 'D'}}
+/// \endcode
+///
+/// Multiple occurrences accumulate prefixes.  For example,
+/// "-verify -verify=foo,bar -verify=baz" is equivalent to
+/// "-verify=expected,foo,bar,baz".
+///
+/// SPECIFYING DIAGNOSTICS:
 ///
 /// Indicating that a line expects an error or a warning is simple. Put a
 /// comment on the line that has the diagnostic, use:


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


r350441 - [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Jan  4 14:12:13 2019
New Revision: 350441

URL: http://llvm.org/viewvc/llvm-project?rev=350441=rev
Log:
[OpenMP] Refactor const restriction for linear

As discussed in D56113, this patch refactors the implementation of the
const restriction for linear to reuse a function introduced by D56113.
A side effect is that, if a variable has mutable members, this
diagnostic is now skipped, and the diagnostic for the variable not
being an integer or pointer is reported instead.

Reviewed By: ABataev

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/for_linear_messages.cpp
cfe/trunk/test/OpenMP/for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=350441=350440=350441=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jan  4 14:12:13 2019
@@ -11531,20 +11531,12 @@ bool Sema::CheckOpenMPLinearDecl(const V
   }
   Type = Type.getNonReferenceType();
 
-  // A list item must not be const-qualified.
-  if (Type.isConstant(Context)) {
-Diag(ELoc, diag::err_omp_const_variable)
-<< getOpenMPClauseName(OMPC_linear);
-if (D) {
-  bool IsDecl =
-  !VD ||
-  VD->isThisDeclarationADefinition(Context) == 
VarDecl::DeclarationOnly;
-  Diag(D->getLocation(),
-   IsDecl ? diag::note_previous_decl : diag::note_defined_here)
-  << D;
-}
+  // OpenMP 5.0 [2.19.3, List Item Privatization, Restrictions]
+  // A variable that is privatized must not have a const-qualified type
+  // unless it is of class type with a mutable member. This restriction does
+  // not apply to the firstprivate clause.
+  if (rejectConstNotMutableType(*this, D, Type, OMPC_linear, ELoc))
 return true;
-  }
 
   // A list item must be of integral or pointer type.
   Type = Type.getUnqualifiedType().getCanonicalType();

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp?rev=350441=350440=350441=diff
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp Fri 
Jan  4 14:12:13 2019
@@ -189,7 +189,7 @@ template int foomain(I
 
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{const-qualified 
variable cannot be linear}}
+#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{argument of a 
linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -294,7 +294,7 @@ int main(int argc, char **argv) {
 
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd linear (a, b) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{const-qualified 
variable cannot be linear}} expected-error {{incomplete type 'S1' where a 
complete type is required}}
+#pragma omp distribute parallel for simd linear (a, b) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{argument of a 
linear clause should be of integral or pointer type, not 'S2'}} expected-error 
{{incomplete type 'S1' where a complete type is required}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target

Modified: cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp?rev=350441=350440=350441=diff
==

r349635 - [OpenMP] Fix data sharing analysis in nested clause

2018-12-19 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Dec 19 07:59:47 2018
New Revision: 349635

URL: http://llvm.org/viewvc/llvm-project?rev=349635=rev
Log:
[OpenMP] Fix data sharing analysis in nested clause

Without this patch, clang doesn't complain that X needs explicit data
sharing attributes in the following:

```
 #pragma omp target teams default(none)
 {
   #pragma omp parallel num_threads(X)
 ;
 }
```

However, clang does produce that complaint after the braces are
removed.  With this patch, clang complains in both cases.

Reviewed By: ABataev

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_teams_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=349635=349634=349635=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 19 07:59:47 2018
@@ -2390,13 +2390,9 @@ public:
   void VisitStmt(Stmt *S) {
 for (Stmt *C : S->children()) {
   if (C) {
-if (auto *OED = dyn_cast(C)) {
-  // Check implicitly captured variables in the task-based directives 
to
-  // check if they must be firstprivatized.
-  VisitSubCaptures(OED);
-} else {
-  Visit(C);
-}
+// Check implicitly captured variables in the task-based directives to
+// check if they must be firstprivatized.
+Visit(C);
   }
 }
   }

Modified: cfe/trunk/test/OpenMP/target_teams_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_messages.cpp?rev=349635=349634=349635=diff
==
--- cfe/trunk/test/OpenMP/target_teams_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_messages.cpp Wed Dec 19 07:59:47 2018
@@ -50,6 +50,16 @@ int main(int argc, char **argv) {
 #pragma omp target teams default(none)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified 
data sharing attributes}}
 
+#pragma omp target teams default(none)
+#pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' 
must have explicitly specified data sharing attributes}}
+  ;
+
+#pragma omp target teams default(none)
+  {
+#pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' 
must have explicitly specified data sharing attributes}}
+;
+  }
+
   goto L2; // expected-error {{use of undeclared label 'L2'}}
 #pragma omp target teams
   L2:


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


r348504 - [CUDA] Fix nvidia-cuda-toolkit detection on Ubuntu

2018-12-06 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Dec  6 09:46:17 2018
New Revision: 348504

URL: http://llvm.org/viewvc/llvm-project?rev=348504=rev
Log:
[CUDA] Fix nvidia-cuda-toolkit detection on Ubuntu

This just extends D40453 (r319317) to Ubuntu.

Reviewed By: Hahnfeld, tra

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=348504=348503=348504=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Dec  6 09:46:17 2018
@@ -114,7 +114,7 @@ CudaInstallationDetector::CudaInstallati
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-if (Distro(D.getVFS()).IsDebian())
+if (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");


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


r347351 - [OpenMP] Update CHECK-DAG usage in target_parallel_codegen.cpp

2018-11-20 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Nov 20 14:05:23 2018
New Revision: 347351

URL: http://llvm.org/viewvc/llvm-project?rev=347351=rev
Log:
[OpenMP] Update CHECK-DAG usage in target_parallel_codegen.cpp

This patch adjusts a test not to depend on deprecated FileCheck
behavior that permits overlapping matches within a block of CHECK-DAG
directives.  Thus, this patch also removes uses of FileCheck's
-allow-deprecated-dag-overlap command-line option.

There were two issues in this test:

1. There were sets of patterns for store instructions in which a
pattern X could match a superset of a pattern Y.  While X appeared
before Y, Y's intended match appeared before X's intended match.  The
result was that X matched Y's intended match.  Under the old
overlapping behavior, Y also matched Y's intended match.  Under the
new non-overlapping behavior, Y had nothing left to match.  This patch
fixes this by gathering these sets in one place and putting the most
specific patterns (Y) before the more general patterns (X).

2. The CHECK-DAG patterns involving the variables CBPADDR3 and
CBPADDR4 were the same, but there was only one match in the text, so
CBPADDR4 patterns had nothing to match under the new non-overlapping
behavior.  Moreover, a preceding related series of directives had
variables (SADDR0, BPADDR0, etc.) numbered only 0 through 4, but this
series had variables numbered 0 through 5.  Assuming CBPADDR4's
directives were not intended, this patch removes them.

Reviewed By: ABataev

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

Modified:
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_codegen.cpp?rev=347351=347350=347351=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_codegen.cpp Tue Nov 20 14:05:23 2018
@@ -1,37 +1,37 @@
 // Test host codegen.
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefix 
CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
-allow-deprecated-dag-overlap  %s --check-prefix CHECK --check-prefix CHECK-64
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck -allow-deprecated-dag-overlap  %s --check-prefix CHECK --check-prefix 
CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s 
--check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix 
SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
-// RUN: %clang_cc1 

r347350 - [OpenMP] Update CHECK-DAG usage in for_codegen.cpp

2018-11-20 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Nov 20 14:04:45 2018
New Revision: 347350

URL: http://llvm.org/viewvc/llvm-project?rev=347350=rev
Log:
[OpenMP] Update CHECK-DAG usage in for_codegen.cpp

This patch adjusts a test not to depend on deprecated FileCheck
behavior that permits overlapping matches within a block of CHECK-DAG
directives.  Thus, this patch also removes uses of FileCheck's
-allow-deprecated-dag-overlap command-line option.

Specifically, the FileCheck variables DBG_LOC_START, DBG_LOC_END, and
DBG_LOC_CANCEL were all set to the same value.  As a result, three
TERM_DEBUG-DAG patterns, one for each variable, all matched the same
text under the old overlapping behavior.  Under the new
non-overlapping behavior, that's not permitted.  This patch's solution
is to replace these variables with one variable and replace these
patterns with one pattern.

Reviewed By: ABataev

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

Modified:
cfe/trunk/test/OpenMP/for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_codegen.cpp?rev=347350=347349=347350=diff
==
--- cfe/trunk/test/OpenMP/for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_codegen.cpp Tue Nov 20 14:04:45 2018
@@ -1,14 +1,14 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - 
-fsanitize-address-use-after-scope | FileCheck -allow-deprecated-dag-overlap %s 
--check-prefix=CHECK --check-prefix=LIFETIME
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - 
-fsanitize-address-use-after-scope | FileCheck %s --check-prefix=CHECK 
--check-prefix=LIFETIME
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck -allow-deprecated-dag-overlap %s --check-prefix=TERM_DEBUG
-// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROF-INSTR-PATH
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TERM_DEBUG
+// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck %s --check-prefix=PROF-INSTR-PATH
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck 
-allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix 
SIMD-ONLY0 %s
-// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -main-file-name for_codegen.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang -fprofile-instrument-path=for_codegen-test.profraw | 
FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: 

r335911 - [OPENMP] Fix incomplete type check for array reductions

2018-06-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Jun 28 12:54:49 2018
New Revision: 335911

URL: http://llvm.org/viewvc/llvm-project?rev=335911=rev
Log:
[OPENMP] Fix incomplete type check for array reductions

A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

Reviewed By: ABataev

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

Added:
cfe/trunk/test/OpenMP/parallel_reduction_messages.c
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=335911=335910=335911=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 28 12:54:49 2018
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
 // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
 //  A variable that appears in a private clause must not have an incomplete
 //  type or a reference type.
-if (S.RequireCompleteType(ELoc, Type,
+if (S.RequireCompleteType(ELoc, D->getType(),
   diag::err_omp_reduction_incomplete_type))
   continue;
 // OpenMP [2.14.3.6, reduction clause, Restrictions]

Added: cfe/trunk/test/OpenMP/parallel_reduction_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.c?rev=335911=auto
==
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.c (added)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.c Thu Jun 28 12:54:49 2018
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
+
+int incomplete[];
+
+void test() {
+#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction 
list item with incomplete type 'int []'}}
+  ;
+}
+
+// complete to suppress an additional warning, but it's too late for pragmas
+int incomplete[3];


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


r335910 - Revert r335907: [OPENMP] Fix incomplete type check for array reductions

2018-06-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Jun 28 12:54:27 2018
New Revision: 335910

URL: http://llvm.org/viewvc/llvm-project?rev=335910=rev
Log:
Revert r335907: [OPENMP] Fix incomplete type check for array reductions

Sorry, forgot to add commit log attributes again.

Removed:
cfe/trunk/test/OpenMP/parallel_reduction_messages.c
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=335910=335909=335910=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 28 12:54:27 2018
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
 // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
 //  A variable that appears in a private clause must not have an incomplete
 //  type or a reference type.
-if (S.RequireCompleteType(ELoc, D->getType(),
+if (S.RequireCompleteType(ELoc, Type,
   diag::err_omp_reduction_incomplete_type))
   continue;
 // OpenMP [2.14.3.6, reduction clause, Restrictions]

Removed: cfe/trunk/test/OpenMP/parallel_reduction_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.c?rev=335909=auto
==
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.c (original)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
-
-int incomplete[];
-
-void test() {
-#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction 
list item with incomplete type 'int []'}}
-  ;
-}
-
-// complete to suppress an additional warning, but it's too late for pragmas
-int incomplete[3];


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


r335907 - [OPENMP] Fix incomplete type check for array reductions

2018-06-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu Jun 28 12:46:10 2018
New Revision: 335907

URL: http://llvm.org/viewvc/llvm-project?rev=335907=rev
Log:
[OPENMP] Fix incomplete type check for array reductions

A reduction for an incomplete array type used to produce an assert
fail during codegen.  Now it produces a diagnostic.

Added:
cfe/trunk/test/OpenMP/parallel_reduction_messages.c
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=335907=335906=335907=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 28 12:46:10 2018
@@ -10335,7 +10335,7 @@ static bool actOnOMPReductionKindClause(
 // OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
 //  A variable that appears in a private clause must not have an incomplete
 //  type or a reference type.
-if (S.RequireCompleteType(ELoc, Type,
+if (S.RequireCompleteType(ELoc, D->getType(),
   diag::err_omp_reduction_incomplete_type))
   continue;
 // OpenMP [2.14.3.6, reduction clause, Restrictions]

Added: cfe/trunk/test/OpenMP/parallel_reduction_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_messages.c?rev=335907=auto
==
--- cfe/trunk/test/OpenMP/parallel_reduction_messages.c (added)
+++ cfe/trunk/test/OpenMP/parallel_reduction_messages.c Thu Jun 28 12:46:10 2018
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
+
+int incomplete[];
+
+void test() {
+#pragma omp parallel reduction(+ : incomplete) // expected-error {{a reduction 
list item with incomplete type 'int []'}}
+  ;
+}
+
+// complete to suppress an additional warning, but it's too late for pragmas
+int incomplete[3];


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


r333574 - [AST] Fix loss of enum forward decl from decl context

2018-05-30 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 30 11:33:53 2018
New Revision: 333574

URL: http://llvm.org/viewvc/llvm-project?rev=333574=rev
Log:
[AST] Fix loss of enum forward decl from decl context

For example, given:

  enum __attribute__((deprecated)) T *p;

-ast-print produced:

  enum T *p;

The attribute was lost because the enum forward decl was lost.

Another example is the loss of enum forward decls from C++ namespaces
(in MS compatibility mode).

The trouble was that the EnumDecl node was suppressed, as revealed by
-ast-dump.  The suppression of the EnumDecl was intentional in
r116122, but I don't understand why.  The suppression isn't needed for
the test suite to behave.

Reviewed by: rsmith

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/ast-print.c
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=333574=333573=333574=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 30 11:33:53 2018
@@ -14287,7 +14287,6 @@ CreateNewDecl:
   // PrevDecl.
   TagDecl *New;
 
-  bool IsForwardReference = false;
   if (Kind == TTK_Enum) {
 // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
 // enum X { A, B, C } D;D should chain to X.
@@ -14317,12 +14316,6 @@ CreateNewDecl:
 else if (getLangOpts().CPlusPlus)
   DiagID = diag::err_forward_ref_enum;
 Diag(Loc, DiagID);
-
-// If this is a forward-declared reference to an enumeration, make a
-// note of it; we won't actually be introducing the declaration into
-// the declaration context.
-if (TUK == TUK_Reference)
-  IsForwardReference = true;
   }
 }
 
@@ -14480,9 +14473,7 @@ CreateNewDecl:
 PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false);
   } else if (Name) {
 S = getNonFieldDeclScope(S);
-PushOnScopeChains(New, S, !IsForwardReference);
-if (IsForwardReference)
-  SearchDC->makeDeclVisibleInContext(New);
+PushOnScopeChains(New, S, true);
   } else {
 CurContext->addDecl(New);
   }

Modified: cfe/trunk/test/Sema/ast-print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=333574=333573=333574=diff
==
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Wed May 30 11:33:53 2018
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been 
explicitly marked deprecated here}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
@@ -86,8 +88,7 @@ enum EnumWithAttributes { // expected-wa
   // CHECK-NEXT: } *EnumWithAttributesPtr;
 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
 
-// FIXME: If enum is forward-declared at file scope, attributes are lost.
-// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 
*EnumWithAttributes2Ptr;
 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=333574=333573=333574=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Wed May 30 11:33:53 2018
@@ -239,6 +239,15 @@ enum ENUM2 {
ENUM2_c = 0x1 // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwardDecl::E NsEnumForwardDecl_e;

r332481 - [Attr] Don't print fake MSInheritance argument

2018-05-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 16 08:18:30 2018
New Revision: 332481

URL: http://llvm.org/viewvc/llvm-project?rev=332481=rev
Log:
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332481=332480=332481=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 08:18:30 2018
@@ -184,7 +184,8 @@ class VersionArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument : BoolArgument {
+class DefaultBoolArgument
+: BoolArgument {
   bit Default = default;
 }
 
@@ -2624,7 +2625,7 @@ def UPtr : TypeAttr {
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", 1>];
+  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=332481=332480=332481=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Wed May 16 08:18:30 2018
@@ -34,3 +34,12 @@ class __attribute__((consumable(unknown)
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: class __multiple_inheritance MultipleInheritance;
+class __multiple_inheritance MultipleInheritance;
+
+// CHECK: class __virtual_inheritance VirtualInheritance;
+class __virtual_inheritance VirtualInheritance;


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


r332480 - Revert r332474: [Attr] Don't print fake MSInheritance argument

2018-05-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 16 08:18:27 2018
New Revision: 332480

URL: http://llvm.org/viewvc/llvm-project?rev=332480=rev
Log:
Revert r332474: [Attr] Don't print fake MSInheritance argument

I botched the commit log attributes.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332480=332479=332480=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 08:18:27 2018
@@ -184,8 +184,7 @@ class VersionArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument
-: BoolArgument {
+class DefaultBoolArgument : BoolArgument {
   bit Default = default;
 }
 
@@ -2625,7 +2624,7 @@ def UPtr : TypeAttr {
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
+  let Args = [DefaultBoolArgument<"BestCase", 1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=332480=332479=332480=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Wed May 16 08:18:27 2018
@@ -34,12 +34,3 @@ class __attribute__((consumable(unknown)
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
-
-// CHECK: class __single_inheritance SingleInheritance;
-class __single_inheritance SingleInheritance;
-
-// CHECK: class __multiple_inheritance MultipleInheritance;
-class __multiple_inheritance MultipleInheritance;
-
-// CHECK: class __virtual_inheritance VirtualInheritance;
-class __virtual_inheritance VirtualInheritance;


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


r332474 - [Attr] Don't print fake MSInheritance argument

2018-05-16 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 16 07:51:18 2018
New Revision: 332474

URL: http://llvm.org/viewvc/llvm-project?rev=332474=rev
Log:
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

https://reviews.llvm.org/D46905

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaCXX/attr-print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332474=332473=332474=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 16 07:51:18 2018
@@ -184,7 +184,8 @@ class VersionArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument : BoolArgument {
+class DefaultBoolArgument
+: BoolArgument {
   bit Default = default;
 }
 
@@ -2624,7 +2625,7 @@ def UPtr : TypeAttr {
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", 1>];
+  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,

Modified: cfe/trunk/test/SemaCXX/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-print.cpp?rev=332474=332473=332474=diff
==
--- cfe/trunk/test/SemaCXX/attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-print.cpp Wed May 16 07:51:18 2018
@@ -34,3 +34,12 @@ class __attribute__((consumable(unknown)
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: class __multiple_inheritance MultipleInheritance;
+class __multiple_inheritance MultipleInheritance;
+
+// CHECK: class __virtual_inheritance VirtualInheritance;
+class __virtual_inheritance VirtualInheritance;


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


r332411 - [Attr] Don't print implicit attributes

2018-05-15 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 15 15:16:47 2018
New Revision: 332411

URL: http://llvm.org/viewvc/llvm-project?rev=332411=rev
Log:
[Attr] Don't print implicit attributes

Fixes bug reported at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-record-decl.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=332411=332410=332411=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue May 15 15:16:47 2018
@@ -215,7 +215,7 @@ void DeclPrinter::prettyPrintAttributes(
   if (D->hasAttrs()) {
 AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
-  if (A->isInherited())
+  if (A->isInherited() || A->isImplicit())
 continue;
   switch (A->getKind()) {
 #define ATTR(X)

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-record-decl.c?rev=332411=332410=332411=diff
==
--- cfe/trunk/test/Misc/ast-print-record-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-record-decl.c Tue May 15 15:16:47 2018
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct 
-DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:   -DBASES=' : B' %s --input-file %t.cpp
+//
+//   RUN: cat %t.diags >> %t.cpp
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN: -DBASES=' : B' %s
 
@@ -236,6 +250,9 @@ void inInit() {
 #ifdef __cplusplus
 // PRINT-CXX-LABEL: inMemberPtr
 void inMemberPtr() {
+  // Under windows, the implicit attribute __single_inheritance used to print
+  // between KW and T1 here, but that wasn't faithful to the original source.
+  //
   // PRINT-CXX-NEXT: [[KW]] T1 {
   // PRINT-CXX-NEXT:   int i;
   // PRINT-CXX-NEXT: };


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


Re: r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-15 Thread Joel E. Denny via cfe-commits
Hi Hans,

On Tue, May 15, 2018 at 6:23 AM, Hans Wennborg <h...@chromium.org> wrote:

> This broke the ast-print-record-decl.c test on Windows, see for
> example http://lab.llvm.org:8011/builders/clang-with-thin-lto-
> windows/builds/9066
>
> One way to reproduce the failure on Linux is to pass a Windows triple
> to this ast-print command:
>
> --- a/test/Misc/ast-print-record-decl.c
> +++ b/test/Misc/ast-print-record-decl.c
> @@ -54,7 +54,7 @@
>  //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
>  //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
>  //
> -//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++
> %s \
> +//   RUN: %clang_cc1 -verify -triple i686-pc-win32 -ast-print
> -DKW=struct -DBASES=' : B' -xc++ %s \
>  //   RUN: > %t.cpp
>  //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
>  //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
>
> What's happening is that on Windows, "__single_inheritance(1)" is
> printed before T1. But if I change the test to allow that in the
> output, it still doesn't pass as Clang doesn't seem able to parse it.
>

The underlying bug is present at least as far back as 4.0.1.  The bug is
revealed by an earlier patch, r332281, simply because it introduces this
test.

There are two parts to this bug.  First, implicit attributes shouldn't
print as that's not faithful to the original source.  I'm addressing that at

https://reviews.llvm.org/D46894

Second, when this attribute is explicit, the "(1)" shouldn't print as it's
not part of the accepted syntax.  I'll address that in another patch.

Thanks.

Joel



>
> I've worked around the problem by adding a Linux triple here in
> r332335, but someone should probably look into it properly.
>
> Thanks,
> Hans
>
> On Tue, May 15, 2018 at 2:44 AM, Joel E. Denny via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
> > Author: jdenny
> > Date: Mon May 14 17:44:14 2018
> > New Revision: 332314
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332314=rev
> > Log:
> > [AST] Fix printing tag decl groups in decl contexts
> >
> > For example, given:
> >
> >   struct T1 {
> > struct T2 *p0;
> >   };
> >
> > -ast-print produced:
> >
> >   struct T1 {
> > struct T2;
> > struct T2 *p0;
> >   };
> >
> > Compiling that produces a warning that the first struct T2 declaration
> > does not declare anything.
> >
> > Details:
> >
> > A tag decl group is one or more decls that share a type specifier that
> > is a tag decl (that is, a struct/union/class/enum decl).  Within
> > functions, the parser builds such a tag decl group as part of a
> > DeclStmt.  However, in decl contexts, such as file scope or a member
> > list, the parser does not group together the members of a tag decl
> > group.  Previously, detection of tag decl groups during printing was
> > implemented but only if the tag decl was unnamed.  Otherwise, as in
> > the above example, the members of the group did not print together and
> > so sometimes introduced warnings.
> >
> > This patch extends detection of tag decl groups in decl contexts to
> > any tag decl that is recorded in the AST as not free-standing.
> >
> > Reviewed by: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D45465
> >
> > Modified:
> > cfe/trunk/lib/AST/DeclPrinter.cpp
> > cfe/trunk/test/Misc/ast-print-enum-decl.c
> > cfe/trunk/test/Misc/ast-print-record-decl.c
> > cfe/trunk/test/Sema/ast-print.c
> > cfe/trunk/test/SemaCXX/ast-print.cpp
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-15 Thread Joel E. Denny via cfe-commits
Hi Hans,

Thanks.  Sorry for the trouble.  I'll look into it.

Joel

On Tue, May 15, 2018 at 6:23 AM, Hans Wennborg <h...@chromium.org> wrote:

> This broke the ast-print-record-decl.c test on Windows, see for
> example http://lab.llvm.org:8011/builders/clang-with-thin-lto-
> windows/builds/9066
>
> One way to reproduce the failure on Linux is to pass a Windows triple
> to this ast-print command:
>
> --- a/test/Misc/ast-print-record-decl.c
> +++ b/test/Misc/ast-print-record-decl.c
> @@ -54,7 +54,7 @@
>  //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
>  //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
>  //
> -//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++
> %s \
> +//   RUN: %clang_cc1 -verify -triple i686-pc-win32 -ast-print
> -DKW=struct -DBASES=' : B' -xc++ %s \
>  //   RUN: > %t.cpp
>  //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
>  //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
>
> What's happening is that on Windows, "__single_inheritance(1)" is
> printed before T1. But if I change the test to allow that in the
> output, it still doesn't pass as Clang doesn't seem able to parse it.
>
> I've worked around the problem by adding a Linux triple here in
> r332335, but someone should probably look into it properly.
>
> Thanks,
> Hans
>
> On Tue, May 15, 2018 at 2:44 AM, Joel E. Denny via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
> > Author: jdenny
> > Date: Mon May 14 17:44:14 2018
> > New Revision: 332314
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332314=rev
> > Log:
> > [AST] Fix printing tag decl groups in decl contexts
> >
> > For example, given:
> >
> >   struct T1 {
> > struct T2 *p0;
> >   };
> >
> > -ast-print produced:
> >
> >   struct T1 {
> > struct T2;
> > struct T2 *p0;
> >   };
> >
> > Compiling that produces a warning that the first struct T2 declaration
> > does not declare anything.
> >
> > Details:
> >
> > A tag decl group is one or more decls that share a type specifier that
> > is a tag decl (that is, a struct/union/class/enum decl).  Within
> > functions, the parser builds such a tag decl group as part of a
> > DeclStmt.  However, in decl contexts, such as file scope or a member
> > list, the parser does not group together the members of a tag decl
> > group.  Previously, detection of tag decl groups during printing was
> > implemented but only if the tag decl was unnamed.  Otherwise, as in
> > the above example, the members of the group did not print together and
> > so sometimes introduced warnings.
> >
> > This patch extends detection of tag decl groups in decl contexts to
> > any tag decl that is recorded in the AST as not free-standing.
> >
> > Reviewed by: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D45465
> >
> > Modified:
> > cfe/trunk/lib/AST/DeclPrinter.cpp
> > cfe/trunk/test/Misc/ast-print-enum-decl.c
> > cfe/trunk/test/Misc/ast-print-record-decl.c
> > cfe/trunk/test/Sema/ast-print.c
> > cfe/trunk/test/SemaCXX/ast-print.cpp
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 17:44:14 2018
New Revision: 332314

URL: http://llvm.org/viewvc/llvm-project?rev=332314=rev
Log:
[AST] Fix printing tag decl groups in decl contexts

For example, given:

  struct T1 {
struct T2 *p0;
  };

-ast-print produced:

  struct T1 {
struct T2;
struct T2 *p0;
  };

Compiling that produces a warning that the first struct T2 declaration
does not declare anything.

Details:

A tag decl group is one or more decls that share a type specifier that
is a tag decl (that is, a struct/union/class/enum decl).  Within
functions, the parser builds such a tag decl group as part of a
DeclStmt.  However, in decl contexts, such as file scope or a member
list, the parser does not group together the members of a tag decl
group.  Previously, detection of tag decl groups during printing was
implemented but only if the tag decl was unnamed.  Otherwise, as in
the above example, the members of the group did not print together and
so sometimes introduced warnings.

This patch extends detection of tag decl groups in decl contexts to
any tag decl that is recorded in the AST as not free-standing.

Reviewed by: rsmith

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-enum-decl.c
cfe/trunk/test/Misc/ast-print-record-decl.c
cfe/trunk/test/Sema/ast-print.c
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=332314=332313=332314=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon May 14 17:44:14 2018
@@ -375,21 +375,23 @@ void DeclPrinter::VisitDeclContext(DeclC
   !isa(DC))
 continue;
 
-// The next bits of code handles stuff like "struct {int x;} a,b"; we're
+// The next bits of code handle stuff like "struct {int x;} a,b"; we're
 // forced to merge the declarations because there's no other way to
-// refer to the struct in question.  This limited merging is safe without
-// a bunch of other checks because it only merges declarations directly
-// referring to the tag, not typedefs.
+// refer to the struct in question.  When that struct is named instead, we
+// also need to merge to avoid splitting off a stand-alone struct
+// declaration that produces the warning ext_no_declarators in some
+// contexts.
+//
+// This limited merging is safe without a bunch of other checks because it
+// only merges declarations directly referring to the tag, not typedefs.
 //
 // Check whether the current declaration should be grouped with a previous
-// unnamed struct.
+// non-free-standing tag declaration.
 QualType CurDeclType = getDeclType(*D);
 if (!Decls.empty() && !CurDeclType.isNull()) {
   QualType BaseType = GetBaseType(CurDeclType);
-  if (!BaseType.isNull() && isa(BaseType))
-BaseType = cast(BaseType)->getNamedType();
-  if (!BaseType.isNull() && isa(BaseType) &&
-  cast(BaseType)->getDecl() == Decls[0]) {
+  if (!BaseType.isNull() && isa(BaseType) &&
+  cast(BaseType)->getOwnedTagDecl() == Decls[0]) {
 Decls.push_back(*D);
 continue;
   }
@@ -399,9 +401,9 @@ void DeclPrinter::VisitDeclContext(DeclC
 if (!Decls.empty())
   ProcessDeclGroup(Decls);
 
-// If the current declaration is an unnamed tag type, save it
+// If the current declaration is not a free standing declaration, save it
 // so we can merge it with the subsequent declaration(s) using it.
-if (isa(*D) && !cast(*D)->getIdentifier()) {
+if (isa(*D) && !cast(*D)->isFreeStanding()) {
   Decls.push_back(*D);
   continue;
 }

Modified: cfe/trunk/test/Misc/ast-print-enum-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-enum-decl.c?rev=332314=332313=332314=diff
==
--- cfe/trunk/test/Misc/ast-print-enum-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-enum-decl.c Mon May 14 17:44:14 2018
@@ -83,3 +83,23 @@ void declsOnly() {
   // PRINT-NEXT: enum T *p4;
   enum T *p4;
 }
+
+// Check that tag decl groups stay together in decl contexts.
+
+// PRINT-LABEL: enum DeclGroupAtFileScope {
+// PRINT-NEXT:DeclGroupAtFileScope0
+// PRINT-NEXT:  } *DeclGroupAtFileScopePtr;
+enum DeclGroupAtFileScope { DeclGroupAtFileScope0 } *DeclGroupAtFileScopePtr;
+
+// PRINT-LABEL: struct DeclGroupInMemberList
+struct DeclGroupInMemberList {
+  // PRINT-NEXT:  enum T1 {
+  // PRINT-NEXT:T10
+  // PRINT-NEXT:  } *p0;
+  enum T1 { T10 } *p0;
+  // PRINT-NEXT:  enum T2 {
+  // PRINT-NEXT:T20
+  // PRINT-NEXT:  } *p1, *p2;
+  enum T2 { T20 } *p1, *p2;
+  // PRINT-NEXT: };
+};

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c

r332294 - Fix test fail on some buildbots, caused by r332281.

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 14:06:04 2018
New Revision: 332294

URL: http://llvm.org/viewvc/llvm-project?rev=332294=rev
Log:
Fix test fail on some buildbots, caused by r332281.

Modified:
cfe/trunk/test/Misc/ast-print-record-decl.c

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-record-decl.c?rev=332294=332293=332294=diff
==
--- cfe/trunk/test/Misc/ast-print-record-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-record-decl.c Mon May 14 14:06:04 2018
@@ -2,7 +2,8 @@
 //
 //   First check compiling and printing of this file.
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES= -o - %s \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm \
+//   RUN:-DKW=struct -DBASES= -o - %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES= %s > %t.c
@@ -14,7 +15,7 @@
 //   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
 //   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.c
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - %t.c \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.c \
@@ -24,7 +25,8 @@
 //
 //   First check compiling and printing of this file.
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=union -DBASES= -o - %s \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm \
+//   RUN:-DKW=union -DBASES= -o - %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=union -DBASES= %s > %t.c
@@ -36,7 +38,7 @@
 //   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
 //   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.c
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - %t.c \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.c \
@@ -46,8 +48,8 @@
 //
 //   First check compiling and printing of this file.
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES=' : B' -o - 
\
-//   RUN:-xc++ %s \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm \
+//   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
@@ -60,7 +62,7 @@
 //   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
 //   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
 //
-//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.cpp \
+//   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.cpp \


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


r332281 - [AST] Print correct tag decl for tag specifier

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 12:36:45 2018
New Revision: 332281

URL: http://llvm.org/viewvc/llvm-project?rev=332281=rev
Log:
[AST] Print correct tag decl for tag specifier

For example, given:

  void fn() {
struct T *p0;
struct T { int i; } *p1;
  }

-ast-print produced:

  void fn() {
struct T { int i; } *p0;
struct T { int i; } *p1;
  }

Compiling that fails with a redefinition error.

Given:

  void fn() {
struct T *p0;
struct __attribute__((deprecated)) T *p1;
  }

-ast-print dropped the attribute.

Details:

For a tag specifier (that is, struct/union/class/enum used as a type
specifier in a declaration) that was also a tag declaration (that is,
first occurrence of the tag) or tag redeclaration (that is, later
occurrence that specifies attributes or a member list), clang printed
the tag specifier as either (1) the full tag definition if one
existed, or (2) the first tag declaration otherwise.  Redefinition
errors were sometimes introduced, as in the first example above.  Even
when that was impossible because no member list was ever specified,
attributes were sometimes lost, thus changing semantics and
diagnostics, as in the second example above.

This patch fixes a major culprit for these problems.  It does so by
creating an ElaboratedType with a new OwnedDecl member wherever an
occurrence of a tag type is a (re)declaration of that tag type.
PrintingPolicy's IncludeTagDefinition used to trigger printing of the
member list, attributes, etc. for a tag specifier by using a tag
(re)declaration selected as described above.  Now, it triggers the
same thing except it uses the tag (re)declaration stored in the
OwnedDecl.  Of course, other tooling can now make use of the new
OwnedDecl as well.

Also, to be more faithful to the original source, this patch
suppresses printing of attributes inherited from previous
declarations.

Reviewed by: rsmith, aaron.ballman

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

Added:
cfe/trunk/test/Misc/ast-print-enum-decl.c
cfe/trunk/test/Misc/ast-print-record-decl.c
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=332281=332280=332281=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon May 14 12:36:45 2018
@@ -1419,8 +1419,8 @@ public:
   QualType getParenType(QualType NamedType) const;
 
   QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
- NestedNameSpecifier *NNS,
- QualType NamedType) const;
+ NestedNameSpecifier *NNS, QualType NamedType,
+ TagDecl *OwnedTagDecl = nullptr) const;
   QualType getDependentNameType(ElaboratedTypeKeyword Keyword,
 NestedNameSpecifier *NNS,
 const IdentifierInfo *Name,

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=332281=332280=332281=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon May 14 12:36:45 2018
@@ -56,6 +56,7 @@ namespace clang {
 
 class ExtQuals;
 class QualType;
+class TagDecl;
 class Type;
 
 enum {
@@ -4865,14 +4866,18 @@ class ElaboratedType : public TypeWithKe
   /// The type that this qualified name refers to.
   QualType NamedType;
 
+  /// The (re)declaration of this tag type owned by this occurrence, or nullptr
+  /// if none.
+  TagDecl *OwnedTagDecl;
+
   ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
- QualType NamedType, QualType CanonType)
+ QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl)
 : TypeWithKeyword(Keyword, Elaborated, CanonType,
   NamedType->isDependentType(),
   NamedType->isInstantiationDependentType(),
   NamedType->isVariablyModifiedType(),
   NamedType->containsUnexpandedParameterPack()),
-  NNS(NNS), NamedType(NamedType) {
+  NNS(NNS), NamedType(NamedType), OwnedTagDecl(OwnedTagDecl) {
 assert(!(Keyword == ETK_None && NNS == nullptr) &&
"ElaboratedType cannot have elaborated type keyword "
"and name qualifier both null.");
@@ -4893,15 +4898,21 @@ public:
   

r332275 - [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-14 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon May 14 11:41:44 2018
New Revision: 332275

URL: http://llvm.org/viewvc/llvm-project?rev=332275=rev
Log:
[AST] Fix -ast-print for _Bool when have diagnostics

For example, given:

  #define bool _Bool
  _Bool i;
  void fn() { 1; }

-ast-print produced:

  tmp.c:3:13: warning: expression result unused
  void fn() { 1; }
  ^
  bool i;
  void fn() {
  1;
  }

That fails to compile because bool is undefined.

Details:

Diagnostics print _Bool as bool when the latter is defined as the
former.  However, diagnostics were altering the printing policy for
-ast-print as well.  The printed source was then invalid because the
preprocessor eats the bool definition.

Problematic diagnostics included suppressed warnings (e.g., add
-Wno-unused-value to the above example), including those that are
suppressed by default.

This patch fixes this bug and cleans up some related comments.

Reviewed by: aaron.ballman, rsmith

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

Added:
cfe/trunk/test/Misc/ast-print-bool.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=332275=332274=332275=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon May 14 11:41:44 2018
@@ -2113,12 +2113,12 @@ public:
   void checkPartialSpecializationVisibility(SourceLocation Loc,
 NamedDecl *Spec);
 
-  /// Retrieve a suitable printing policy.
+  /// Retrieve a suitable printing policy for diagnostics.
   PrintingPolicy getPrintingPolicy() const {
 return getPrintingPolicy(Context, PP);
   }
 
-  /// Retrieve a suitable printing policy.
+  /// Retrieve a suitable printing policy for diagnostics.
   static PrintingPolicy getPrintingPolicy(const ASTContext ,
   const Preprocessor );
 

Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=332275=332274=332275=diff
==
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Mon May 14 11:41:44 2018
@@ -87,9 +87,10 @@ namespace {
 << DC->getPrimaryContext() << "\n";
 } else
   Out << "Not a DeclContext\n";
-  } else if (OutputKind == Print)
-D->print(Out, /*Indentation=*/0, /*PrintInstantiation=*/true);
-  else if (OutputKind != None)
+  } else if (OutputKind == Print) {
+PrintingPolicy Policy(D->getASTContext().getLangOpts());
+D->print(Out, Policy, /*Indentation=*/0, /*PrintInstantiation=*/true);
+  } else if (OutputKind != None)
 D->dump(Out, OutputKind == DumpFull);
 }
 

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=332275=332274=332275=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon May 14 11:41:44 2018
@@ -52,8 +52,8 @@ ModuleLoader ::getModuleLoader() co
 PrintingPolicy Sema::getPrintingPolicy(const ASTContext ,
const Preprocessor ) {
   PrintingPolicy Policy = Context.getPrintingPolicy();
-  // Our printing policy is copied over the ASTContext printing policy whenever
-  // a diagnostic is emitted, so recompute it.
+  // In diagnostics, we print _Bool as bool if the latter is defined as the
+  // former.
   Policy.Bool = Context.getLangOpts().Bool;
   if (!Policy.Bool) {
 if (const MacroInfo *BoolMacro = PP.getMacroInfo(Context.getBoolName())) {
@@ -1287,7 +1287,8 @@ void Sema::EmitCurrentDiagnostic(unsigne
 }
   }
 
-  // Set up the context's printing policy based on our current state.
+  // Copy the diagnostic printing policy over the ASTContext printing policy.
+  // TODO: Stop doing that.  See: https://reviews.llvm.org/D45093#1090292
   Context.setPrintingPolicy(getPrintingPolicy());
 
   // Emit the diagnostic.

Added: cfe/trunk/test/Misc/ast-print-bool.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-bool.c?rev=332275=auto
==
--- cfe/trunk/test/Misc/ast-print-bool.c (added)
+++ cfe/trunk/test/Misc/ast-print-bool.c Mon May 14 11:41:44 2018
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL -DDIAG \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL
+//
+// RUN: 

r331468 - Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:22:01 2018
New Revision: 331468

URL: http://llvm.org/viewvc/llvm-project?rev=331468=rev
Log:
Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"

Sorry, forgot to add commit log attributes.

Modified:
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331468=331467=331468=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:22:01 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331468=331467=331468=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:22:01 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} 

r331469 - [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:22:04 2018
New Revision: 331469

URL: http://llvm.org/viewvc/llvm-project?rev=331469=rev
Log:
[OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

Reviewed by: ABataev

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

Modified:
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331469=331468=331469=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:22:04 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331469=331468=331469=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:22:04 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} 

r331466 - [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:15:44 2018
New Revision: 331466

URL: http://llvm.org/viewvc/llvm-project?rev=331466=rev
Log:
[OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

Modified:
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331466=331465=331466=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:15:44 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331466=331465=331466=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:15:44 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// 

r330722 - [Attr] Print enum attributes at correct position

2018-04-24 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Apr 24 07:50:23 2018
New Revision: 330722

URL: http://llvm.org/viewvc/llvm-project?rev=330722=rev
Log:
[Attr] Print enum attributes at correct position

For example, given:

  void fn() {
enum __attribute__((deprecated)) T *p;
  }

-ast-print produced:

  void fn() {
enum T __attribute__((deprecated(""))) *p;
  }

-ast-print on that produced:

  void fn() {
enum T *p __attribute__((deprecated("")));
  }

The attribute is on enum T in the first case, but it's on p in the
other cases.

Details:

Within enum declarations, enum attributes were always printed after
the tag and any member list.  When no member list was present but the
enum was a type specifier in a variable declaration, the attribute
then applied to the variable not the enum, changing the semantics.

This patch fixes that by always printing attributes between the enum's
keyword and tag, as clang already does for structs, unions, and
classes.

Reviewed By: rsmith

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Sema/ast-print.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=330722=330721=330722=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Apr 24 07:50:23 2018
@@ -496,14 +496,17 @@ void DeclPrinter::VisitTypeAliasDecl(Typ
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-  Out << "class ";
+  Out << " class";
 else
-  Out << "struct ";
+  Out << " struct";
   }
-  Out << *D;
+
+  prettyPrintAttributes(D);
+
+  Out << ' ' << *D;
 
   if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
 Out << " : " << D->getIntegerType().stream(Policy);
@@ -513,7 +516,6 @@ void DeclPrinter::VisitEnumDecl(EnumDecl
 VisitDeclContext(D);
 Indent() << "}";
   }
-  prettyPrintAttributes(D);
 }
 
 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {

Modified: cfe/trunk/test/Sema/ast-print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=330722=330721=330722=diff
==
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Tue Apr 24 07:50:23 2018
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
 
 typedef void func_typedef();
 func_typedef xxx;
@@ -58,7 +65,7 @@ struct pair_t {
 };
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style 
field designator extension}}
 
 void initializers() {
   // CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -70,11 +77,30 @@ void initializers() {
   } z = {(struct Z){}};
 }
 
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is 
deprecated}}
   // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+  // CHECK-NEXT: };
+  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// FIXME: If enum is forward-declared at file scope, attributes are lost.
+// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
+

r329005 - [Attr] [NFC] Revert accidental change from r327405

2018-04-02 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Mon Apr  2 12:43:34 2018
New Revision: 329005

URL: http://llvm.org/viewvc/llvm-project?rev=329005=rev
Log:
[Attr] [NFC] Revert accidental change from r327405

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=329005=329004=329005=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Mon Apr  2 12:43:34 
2018
@@ -1231,7 +1231,7 @@ MallocChecker::MallocMemReturnsAttr(Chec
   if (Att->getModule() != II_malloc)
 return nullptr;
 
-  ParamIdx *I = Att->args_begin(), *E = Att->args_end();
+  OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
   if (I != E) {
 return MallocMemAux(C, CE, CE->getArg(I->getASTIndex()), UndefinedVal(),
 State);


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


r327456 - [Attr] Merge two dependent tests from different directories

2018-03-13 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Mar 13 15:18:29 2018
New Revision: 327456

URL: http://llvm.org/viewvc/llvm-project?rev=327456=rev
Log:
[Attr] Merge two dependent tests from different directories

Suggested at: https://reviews.llvm.org/D43248

Added:
cfe/trunk/test/Misc/attr-print-emit.cpp
  - copied, changed from r327455, cfe/trunk/test/Sema/attr-print.cpp
Removed:
cfe/trunk/test/Frontend/ast-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp

Removed: cfe/trunk/test/Frontend/ast-attr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/ast-attr.cpp?rev=327455=auto
==
--- cfe/trunk/test/Frontend/ast-attr.cpp (original)
+++ cfe/trunk/test/Frontend/ast-attr.cpp (removed)
@@ -1,5 +0,0 @@
-// RUN: %clang -emit-ast -o %t.ast %S/../Sema/attr-print.cpp
-// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %S/../Sema/attr-print.cpp
-
-// %S/../Sema/attr-print.cpp exercises many different attributes, so we reuse
-// it here to check -emit-ast for attributes.

Copied: cfe/trunk/test/Misc/attr-print-emit.cpp (from r327455, 
cfe/trunk/test/Sema/attr-print.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/attr-print-emit.cpp?p2=cfe/trunk/test/Misc/attr-print-emit.cpp=cfe/trunk/test/Sema/attr-print.cpp=327455=327456=327456=diff
==
--- cfe/trunk/test/Sema/attr-print.cpp (original)
+++ cfe/trunk/test/Misc/attr-print-emit.cpp Tue Mar 13 15:18:29 2018
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -ast-print | FileCheck %s
-
-// This file is also used as input for %S/../Frontend/ast-attr.cpp.
+// RUN: %clang -emit-ast -o %t.ast %s
+// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
 
 // CHECK: void xla(int a) __attribute__((xray_log_args(1)));
 void xla(int a) __attribute__((xray_log_args(1)));

Removed: cfe/trunk/test/Sema/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-print.cpp?rev=327455=auto
==
--- cfe/trunk/test/Sema/attr-print.cpp (original)
+++ cfe/trunk/test/Sema/attr-print.cpp (removed)
@@ -1,69 +0,0 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-
-// This file is also used as input for %S/../Frontend/ast-attr.cpp.
-
-// CHECK: void xla(int a) __attribute__((xray_log_args(1)));
-void xla(int a) __attribute__((xray_log_args(1)));
-
-// CHECK: void *as2(int, int) __attribute__((alloc_size(1, 2)));
-void *as2(int, int) __attribute__((alloc_size(1, 2)));
-// CHECK: void *as1(void *, int) __attribute__((alloc_size(2)));
-void *as1(void *, int) __attribute__((alloc_size(2)));
-
-// CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 
3)));
-void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
-
-// CHECK: char *fmta(int, const char *) __attribute__((format_arg(2)));
-char *fmta(int, const char *) __attribute__((format_arg(2)));
-
-// CHECK: void nn(int *, int *) __attribute__((nonnull(1, 2)));
-void nn(int *, int *) __attribute__((nonnull(1, 2)));
-
-// CHECK: int *aa(int i) __attribute__((alloc_align(1)));
-int *aa(int i) __attribute__((alloc_align(1)));
-
-// CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
-void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
-// CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
-void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
-// CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
-void ownr(int) __attribute__((ownership_returns(foo, 1)));
-
-// CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 
3, 2)));
-void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
-// CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 
2)));
-void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
-
-class C {
-  // CHECK: void xla(int a) __attribute__((xray_log_args(2)));
-  void xla(int a) __attribute__((xray_log_args(2)));
-
-  // CHECK: void *as2(int, int) __attribute__((alloc_size(2, 3)));
-  void *as2(int, int) __attribute__((alloc_size(2, 3)));
-  // CHECK: void *as1(void *, int) __attribute__((alloc_size(3)));
-  void *as1(void *, int) __attribute__((alloc_size(3)));
-
-  // CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 3, 
4)));
-  void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));
-
-  // CHECK: char *fmta(int, const char *) __attribute__((format_arg(3)));
-  char *fmta(int, const char *) __attribute__((format_arg(3)));
-
-  // CHECK: void nn(int *, int *) __attribute__((nonnull(2, 3)));
-  void nn(int *, int *) __attribute__((nonnull(2, 3)));
-
-  // CHECK: int *aa(int i) __attribute__((alloc_align(2)));
-  int *aa(int i) __attribute__((alloc_align(2)));
-
-  // CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 2, 

r327405 - Reland "[Attr] Fix parameter indexing for several attributes"

2018-03-13 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Mar 13 07:51:22 2018
New Revision: 327405

URL: http://llvm.org/viewvc/llvm-project?rev=327405=rev
Log:
Reland "[Attr] Fix parameter indexing for several attributes"

Relands r326602 (reverted in r326862) with new test and fix for
PR36620.

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

Added:
cfe/trunk/test/Frontend/ast-attr.cpp
cfe/trunk/test/Sema/attr-ownership.cpp
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/CodeGenCXX/alloc-size.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp
cfe/trunk/test/Sema/error-type-safety.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=327405=327404=327405=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Tue Mar 13 07:51:22 2018
@@ -195,6 +195,128 @@ public:
}
 };
 
+/// A single parameter index whose accessors require each use to make explicit
+/// the parameter index encoding needed.
+class ParamIdx {
+  // Idx is exposed only via accessors that specify specific encodings.
+  unsigned Idx : 30;
+  unsigned HasThis : 1;
+  unsigned IsValid : 1;
+
+  void assertComparable(const ParamIdx ) const {
+assert(isValid() && I.isValid() &&
+   "ParamIdx must be valid to be compared");
+// It's possible to compare indices from separate functions, but so far
+// it's not proven useful.  Moreover, it might be confusing because a
+// comparison on the results of getASTIndex might be inconsistent with a
+// comparison on the ParamIdx objects themselves.
+assert(HasThis == I.HasThis &&
+   "ParamIdx must be for the same function to be compared");
+  }
+
+public:
+  /// Construct an invalid parameter index (\c isValid returns false and
+  /// accessors fail an assert).
+  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param D is the declaration containing the parameters.  It is used to
+  /// determine if there is a C++ implicit this parameter.
+  ParamIdx(unsigned Idx, const Decl *D)
+  : Idx(Idx), HasThis(false), IsValid(true) {
+assert(Idx >= 1 && "Idx must be one-origin");
+if (const auto *FD = dyn_cast(D))
+  HasThis = FD->isCXXInstanceMember();
+  }
+
+  /// A type into which \c ParamIdx can be serialized.
+  ///
+  /// A static assertion that it's of the correct size follows the \c ParamIdx
+  /// class definition.
+  typedef uint32_t SerialType;
+
+  /// Produce a representation that can later be passed to \c deserialize to
+  /// construct an equivalent \c ParamIdx.
+  SerialType serialize() const {
+return *reinterpret_cast(this);
+  }
+
+  /// Construct from a result from \c serialize.
+  static ParamIdx deserialize(SerialType S) {
+ParamIdx P(*reinterpret_cast());
+assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin");
+return P;
+  }
+
+  /// Is this parameter index valid?
+  bool isValid() const { return IsValid; }
+
+  /// Get the parameter index as it would normally be encoded for attributes at
+  /// the source level of representation: one-origin including any C++ implicit
+  /// this parameter.
+  ///
+  /// This encoding thus makes sense for diagnostics, pretty printing, and
+  /// constructing new attributes from a source-like specification.
+  unsigned getSourceIndex() const {
+assert(isValid() && "ParamIdx must be valid");
+return Idx;
+  }
+
+  /// Get the parameter index as it would normally be encoded at the AST level
+  /// of representation: zero-origin not including any C++ implicit this
+  /// parameter.
+  ///
+  /// This is the encoding primarily used in Sema.  However, in diagnostics,
+  /// Sema uses \c getSourceIndex instead.
+  unsigned getASTIndex() const {
+assert(isValid() && "ParamIdx must be valid");
+assert(Idx >= 1 + HasThis &&
+   "stored index must be base-1 and not specify C++ implicit this");
+return Idx - 1 - HasThis;
+  }
+
+  /// Get the parameter index as it would normally be encoded at the LLVM level
+  /// of representation: zero-origin including any C++ implicit this parameter.
+  ///
+  /// This is the encoding primarily used in CodeGen.
+  unsigned getLLVMIndex() const 

r326603 - [Attr] Use -fsyntax-only in test

2018-03-02 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Mar  2 11:03:27 2018
New Revision: 326603

URL: http://llvm.org/viewvc/llvm-project?rev=326603=rev
Log:
[Attr] Use -fsyntax-only in test

Suggested at: https://reviews.llvm.org/D43248

Modified:
cfe/trunk/test/Sema/attr-ownership.c

Modified: cfe/trunk/test/Sema/attr-ownership.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ownership.c?rev=326603=326602=326603=diff
==
--- cfe/trunk/test/Sema/attr-ownership.c (original)
+++ cfe/trunk/test/Sema/attr-ownership.c Fri Mar  2 11:03:27 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -fsyntax-only
 
 void f1(void) __attribute__((ownership_takes("foo"))); // expected-error 
{{'ownership_takes' attribute requires parameter 1 to be an identifier}}
 void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // 
expected-error {{'ownership_returns' attribute takes no more than 1 argument}}


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


r326602 - [Attr] Fix parameter indexing for several attributes

2018-03-02 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Mar  2 11:03:22 2018
New Revision: 326602

URL: http://llvm.org/viewvc/llvm-project?rev=326602=rev
Log:
[Attr] Fix parameter indexing for several attributes

The patch fixes a number of bugs related to parameter indexing in
attributes:

* Parameter indices in some attributes (argument_with_type_tag,
  pointer_with_type_tag, nonnull, ownership_takes, ownership_holds,
  and ownership_returns) are specified in source as one-origin
  including any C++ implicit this parameter, were stored as
  zero-origin excluding any this parameter, and were erroneously
  printing (-ast-print) and confusingly dumping (-ast-dump) as the
  stored values.

* For alloc_size, the C++ implicit this parameter was not subtracted
  correctly in Sema, leading to assert failures or to silent failures
  of __builtin_object_size to compute a value.

* For argument_with_type_tag, pointer_with_type_tag, and
  ownership_returns, the C++ implicit this parameter was not added
  back to parameter indices in some diagnostics.

This patch fixes the above bugs and aims to prevent similar bugs in
the future by introducing careful mechanisms for handling parameter
indices in attributes.  ParamIdx stores a parameter index and is
designed to hide the stored encoding while providing accessors that
require each use (such as printing) to make explicit the encoding that
is needed.  Attribute declarations declare parameter index arguments
as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*].  This
patch rewrites all attribute arguments that are processed by
checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared
as [Variadic]ParamIdxArgument.  The only exception is xray_log_args's
argument, which is encoded as a count not an index.

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

Added:
cfe/trunk/test/Sema/attr-ownership.cpp
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/CodeGenCXX/alloc-size.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp
cfe/trunk/test/Sema/error-type-safety.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=326602=326601=326602=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Fri Mar  2 11:03:22 2018
@@ -195,6 +195,120 @@ public:
}
 };
 
+/// A single parameter index whose accessors require each use to make explicit
+/// the parameter index encoding needed.
+class ParamIdx {
+  // Idx is exposed only via accessors that specify specific encodings.
+  unsigned Idx : 30;
+  unsigned HasThis : 1;
+  unsigned IsValid : 1;
+
+  void assertComparable(const ParamIdx ) const {
+assert(isValid() && I.isValid() &&
+   "ParamIdx must be valid to be compared");
+// It's possible to compare indices from separate functions, but so far
+// it's not proven useful.  Moreover, it might be confusing because a
+// comparison on the results of getASTIndex might be inconsistent with a
+// comparison on the ParamIdx objects themselves.
+assert(HasThis == I.HasThis &&
+   "ParamIdx must be for the same function to be compared");
+  }
+
+public:
+  /// Construct an invalid parameter index (\c isValid returns false and
+  /// accessors fail an assert).
+  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param D is the declaration containing the parameters.  It is used to
+  /// determine if there is a C++ implicit this parameter.
+  ParamIdx(unsigned Idx, const Decl *D)
+  : Idx(Idx), HasThis(false), IsValid(true) {
+if (const auto *FD = dyn_cast(D))
+  HasThis = FD->isCXXInstanceMember();
+  }
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param HasThis specifies whether the function has a C++ implicit this
+  /// parameter.
+  ParamIdx(unsigned Idx, bool HasThis)
+  : Idx(Idx), HasThis(HasThis), IsValid(true) {}
+
+  /// Is this parameter index valid?
+  bool isValid() const { return IsValid; }
+
+  /// Is there a C++ implicit this parameter?
+  bool hasThis() const {
+assert(isValid() && "ParamIdx 

r326332 - Test commit access: apply clang-format suggestion

2018-02-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Feb 28 08:57:33 2018
New Revision: 326332

URL: http://llvm.org/viewvc/llvm-project?rev=326332=rev
Log:
Test commit access: apply clang-format suggestion

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=326332=326331=326332=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Feb 28 08:57:33 2018
@@ -3823,8 +3823,8 @@ static void WriteDocumentation(RecordKee
 const Record  = *Doc.Documentation->getValueAsDef("Deprecated");
 const StringRef Replacement = Deprecated.getValueAsString("Replacement");
 if (!Replacement.empty())
-  OS << "  This attribute has been superseded by ``"
- << Replacement << "``.";
+  OS << "  This attribute has been superseded by ``" << Replacement
+ << "``.";
 OS << "\n\n";
   }
 


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