This is a minimal patch to support parsing for "omp assume" directives. These are meant to be hints to a compiler's optimisers: as such, it is legitimate (if not very useful) to ignore them. The patch builds on top of the existing support for "omp assumes" directives (note spelling!). Unlike the "omp [begin/end] assumes" directives, "omp assume" is associated with a compound statement, i.e. it can appear within a function. The "holds" assumption could (theoretically) be mapped onto the existing builtin "__builtin_assume", though the latter applies to a single point in the program, and the former to a range (i.e. the whole of the associated compound statement). This patch fixes sollve's OpenMP 5.1 "omp assume"-based tests.
43 lines
833 B
C++
43 lines
833 B
C++
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
|
|
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
|
|
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
|
|
// expected-no-diagnostics
|
|
|
|
#ifndef HEADER
|
|
#define HEADER
|
|
|
|
extern int qux(int);
|
|
|
|
template<typename T>
|
|
int foo(T arg)
|
|
{
|
|
#pragma omp assume no_openmp_routines
|
|
{
|
|
auto fn = [](int x) { return qux(x); };
|
|
// CHECK: auto fn = [](int x) {
|
|
return fn(5);
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
class C {
|
|
T m;
|
|
|
|
public:
|
|
T bar(T a);
|
|
};
|
|
|
|
// We're really just checking this parses. All the assumptions are thrown
|
|
// away immediately for now.
|
|
template<typename T>
|
|
T C<T>::bar(T a)
|
|
{
|
|
#pragma omp assume holds(sizeof(T) == 8) absent(parallel)
|
|
{
|
|
return (T)qux((int)a);
|
|
// CHECK: return (T)qux((int)a);
|
|
}
|
|
}
|
|
|
|
#endif
|