Re: r270373 - [driver][mips] Support new versions of MIPS CodeScape toolchains

2016-05-24 Thread Ismail Donmez via cfe-commits
On Tue, May 24, 2016 at 4:18 PM, Simon Atanasyan  wrote:
> /home/abuild/rpmbuild/BUILD/llvm/stage2/bin/clang -no-canonical-prefixes \
>   /home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/mips-img-v2.cpp \
>   -### -o 
> /home/abuild/rpmbuild/BUILD/llvm/stage2/tools/clang/test/Driver/Output/mips-img-v2.cpp.tmp.o
> \
>   --target=mips-img-linux-gnu \
>   
> --gcc-toolchain=/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree
> \
>   -EB -mips32r6 -mhard-float -mabi=32

Here is the output:

openSUSE Linux clang version 3.9.0 (trunk 270535) (based on LLVM 3.9.0svn)
Target: mips-img-linux-gnu
Thread model: posix
InstalledDir: /home/abuild/rpmbuild/BUILD/llvm/stage2/bin
 "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/clang" "-cc1" "-triple"
"mips-img-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name"
"mips-img-v2.cpp" "-mrelocation-model" "static" "-mthread-model"
"posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose"
"-mconstructor-aliases" "-fuse-init-array" "-target-cpu" "mips32r6"
"-target-abi" "o32" "-mfloat-abi" "hard" "-dwarf-column-info"
"-debugger-tuning=gdb" "-resource-dir"
"/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0"
"-internal-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../include/c++/v1"
"-internal-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/usr/local/include"
"-internal-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0/include"
"-internal-externc-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/lib/../usr/include"
"-internal-externc-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/include"
"-internal-externc-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/usr/include"
"-fdeprecated-macro" "-fdebug-compilation-dir" "/home/abuild"
"-ferror-limit" "19" "-fmessage-length" "130" "-fobjc-runtime=gcc"
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o"
"/tmp/mips-img-v2-677094.o" "-x" "c++"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/mips-img-v2.cpp"
 "/usr/bin/ld" "-z" "relro"
"--sysroot=/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard"
"--build-id" "--enable-new-dtags" "--eh-frame-hdr" "-m" "elf32btsmip"
"-dynamic-linker" "/lib/ld-linux-mipsn8.so.1" "-o"
"/home/abuild/rpmbuild/BUILD/llvm/stage2/tools/clang/test/Driver/Output/mips-img-v2.cpp.tmp.o"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/usr/lib/../lib/crt1.o"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/usr/lib/../lib/crti.o"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/mips-r6-hard/lib/crtbegin.o"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../mips-img-linux-gnu/lib/mips-r6-hard/lib"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/mips-r6-hard/lib"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../mips-img-linux-gnu/lib/../lib/mips-r6-hard"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/lib/../lib"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/usr/lib/../lib"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../mips-img-linux-gnu/lib/mips-r6-hard"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/lib"
"-L/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/../../../../sysroot/mips-r6-hard/usr/lib"
"/tmp/mips-img-v2-677094.o" "-lgcc" "--as-needed" "-lgcc_s"
"--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s"
"--no-as-needed"
"/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/Inputs/mips_img_v2_tree/lib/gcc/mips-img-linux-gnu/4.9.2/mips-r6-hard/lib/crtend.o"
"/home/abuild/rpmbuild/BUILD/llvm/to

Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.
rmaprath added a comment.

Looks like I've completely missed this patch somehow. Will try to find some 
time (or someone) to have a look at it from an embedded-systems / ARM point of 
view asap.

Great work!!!


http://reviews.llvm.org/D16948



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


Re: [PATCH] D20574: [libcxxabi] Allow explicit pthread opt-in

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath accepted this revision.
rmaprath added a comment.
This revision is now accepted and ready to land.

LGTM.

(I don't have powers to accept libcxx patches in general, but this patch is 
quite small and related to something I plugged in, so, I think it's OK in this 
instance)


http://reviews.llvm.org/D20574



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


Re: [PATCH] D20573: [libcxx] Allow explicit pthread opt-in

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath accepted this revision.
rmaprath added a comment.
This revision is now accepted and ready to land.

LGTM.

(I don't have powers to accept libcxx patches in general, but this patch is 
quite small and related to something I plugged in, so, I think it's OK in this 
instance)


http://reviews.llvm.org/D20573



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


Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Bob Wilson via cfe-commits

> On May 24, 2016, at 11:46 AM, Manman Ren  wrote:
> 
>> 
>> On May 24, 2016, at 11:42 AM, Bob Wilson > > wrote:
>> 
>>> 
>>> On May 24, 2016, at 11:21 AM, Manman >> > wrote:
>>> 
>>> 
 On May 23, 2016, at 8:15 PM, Bob Wilson >>> > wrote:
 
 Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
 Objective-C properties marked with the IBOutlet attribute. Those 
 properties are supposed to be weak but they are only accessed from the 
 main thread so there is no risk of asynchronous updates setting them to 
 nil. That combination makes -Warc-repeated-use-of-weak very noisy. The 
 previous change only handled one kind of access to weak IBOutlet 
 properties. Instead of trying to add checks for all the different kinds of 
 property accesses, this patch removes the previous special case check and 
 adds a check at the point where the diagnostic is reported.
>>> 
>>> The approach looks good to me in general. 
 diff --git lib/Sema/AnalysisBasedWarnings.cpp 
 lib/Sema/AnalysisBasedWarnings.cpp
 index 3f2c41b..eb45315 100644
 --- lib/Sema/AnalysisBasedWarnings.cpp
 +++ lib/Sema/AnalysisBasedWarnings.cpp
 @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
else
  llvm_unreachable("Unexpected weak object kind!");
 
 +// Do not warn about IBOutlet weak property receivers being set to 
 null
 +// since they are typically only used from the main thread.
 +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
 +  if (Prop->hasAttr())
 +continue;
 +
// Show the first time the object was read.
S.Diag(FirstRead->getLocStart(), DiagKind)
  << int(ObjectKind) << D << int(FunctionKind)
>>> 
>>> Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking 
>>> the decl inside a loop in diagnoseRepeatedUseOfWeak?
>>> 
>>> if (S.getLangOpts().ObjCWeak &&
>>> !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
>>>   diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
>>> —> check IBOutlet here?
>> 
>> diagnoseRepeatedUseOfWeak is used to report all of the issues within a 
>> function. Some of those may involve IBOutlet properties and others not. We 
>> have to check each one separately.
>> 
>> Your comment prompted me to look more closely and I realized that the code 
>> is confusing because there is a local variable “D” that shadows the “const 
>> Decl *D” argument of diagnoseRepeatedUseOfWeak:
>> 
>>const NamedDecl *D = Key.getProperty();
>> 
>> We should rename that to avoid potential confusion. I can do that as a 
>> follow-up change.
> 
> Yes, I missed the local variable “D”.
> 
>> 
>>> 
 diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
 index 62c823b..c93d800 100644
 --- lib/Sema/SemaPseudoObject.cpp
 +++ lib/Sema/SemaPseudoObject.cpp
 @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
  if (RefExpr->isExplicitProperty()) {
const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
 -  return !Prop->hasAttr();
 +  return true;
 
T = Prop->getType();
  } else if (Getter) {
>>> 
>>> I wonder if this change is necessary to make the testing case pass, or is 
>>> it introduced for clarity, to better reflect the function name 
>>> isWeakProperty?
>> 
>> This is the one special-case check that was introduced by r211132. I removed 
>> it because there is no need for it after we add the check in 
>> diagnoseRepeatedUseOfWeak.
> 
> Thanks for the explanation!
> 
> Patch looks good to me,
> Manman

Thanks for the review.
Patch is in r270665.
I renamed the variable to fix the parameter shadowing in r270666.

> 
>> 
>>> 
>>> Thanks,
>>> Manman
>>> 
 rdar://problem/21366461 
 
 

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


r270665 - arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Wed May 25 00:41:57 2016
New Revision: 270665

URL: http://llvm.org/viewvc/llvm-project?rev=270665&view=rev
Log:
arc-repeated-use-of-weak should not warn about IBOutlet properties

Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for
Objective-C properties marked with the IBOutlet attribute. Those properties
are supposed to be weak but they are only accessed from the main thread
so there is no risk of asynchronous updates setting them to nil. That
combination makes -Warc-repeated-use-of-weak very noisy. The previous
change only handled one kind of access to weak IBOutlet properties.
Instead of trying to add checks for all the different kinds of property
accesses, this patch removes the previous special case check and adds a
check at the point where the diagnostic is reported. rdar://21366461

Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/test/SemaObjC/iboutlet.m

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=270665&r1=270664&r2=270665&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Wed May 25 00:41:57 2016
@@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Se
 else
   llvm_unreachable("Unexpected weak object kind!");
 
+// Do not warn about IBOutlet weak property receivers being set to null
+// since they are typically only used from the main thread.
+if (const ObjCPropertyDecl *Prop = dyn_cast(D))
+  if (Prop->hasAttr())
+continue;
+
 // Show the first time the object was read.
 S.Diag(FirstRead->getLocStart(), DiagKind)
   << int(ObjectKind) << D << int(FunctionKind)

Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=270665&r1=270664&r2=270665&view=diff
==
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Wed May 25 00:41:57 2016
@@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProper
   if (RefExpr->isExplicitProperty()) {
 const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
 if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
-  return !Prop->hasAttr();
+  return true;
 
 T = Prop->getType();
   } else if (Getter) {

Modified: cfe/trunk/test/SemaObjC/iboutlet.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/iboutlet.m?rev=270665&r1=270664&r2=270665&view=diff
==
--- cfe/trunk/test/SemaObjC/iboutlet.m (original)
+++ cfe/trunk/test/SemaObjC/iboutlet.m Wed May 25 00:41:57 2016
@@ -41,6 +41,7 @@ IBInspectable @property (readonly) IBOut
 
 // rdar://15885642
 @interface WeakOutlet 
+@property int Number;
 @property IBOutlet __weak WeakOutlet* WeakProp;
 @end
 
@@ -50,3 +51,9 @@ WeakOutlet* func() {
   pwi.WeakProp = pwi.WeakProp;
   return pwi.WeakProp;
 }
+
+WeakOutlet* func2(WeakOutlet* pwi) {
+  [[pwi WeakProp] setNumber:0];
+  [[pwi WeakProp] setNumber:1];
+  return [pwi WeakProp];
+}


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


r270666 - Rename a variable to avoid shadowing function parameter. NFC.

2016-05-24 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Wed May 25 00:42:00 2016
New Revision: 270666

URL: http://llvm.org/viewvc/llvm-project?rev=270666&view=rev
Log:
Rename a variable to avoid shadowing function parameter. NFC.

Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=270666&r1=270665&r2=270666&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Wed May 25 00:42:00 2016
@@ -1322,27 +1322,27 @@ static void diagnoseRepeatedUseOfWeak(Se
   Ivar
 } ObjectKind;
 
-const NamedDecl *D = Key.getProperty();
-if (isa(D))
+const NamedDecl *KeyProp = Key.getProperty();
+if (isa(KeyProp))
   ObjectKind = Variable;
-else if (isa(D))
+else if (isa(KeyProp))
   ObjectKind = Property;
-else if (isa(D))
+else if (isa(KeyProp))
   ObjectKind = ImplicitProperty;
-else if (isa(D))
+else if (isa(KeyProp))
   ObjectKind = Ivar;
 else
   llvm_unreachable("Unexpected weak object kind!");
 
 // Do not warn about IBOutlet weak property receivers being set to null
 // since they are typically only used from the main thread.
-if (const ObjCPropertyDecl *Prop = dyn_cast(D))
+if (const ObjCPropertyDecl *Prop = dyn_cast(KeyProp))
   if (Prop->hasAttr())
 continue;
 
 // Show the first time the object was read.
 S.Diag(FirstRead->getLocStart(), DiagKind)
-  << int(ObjectKind) << D << int(FunctionKind)
+  << int(ObjectKind) << KeyProp << int(FunctionKind)
   << FirstRead->getSourceRange();
 
 // Print all the other accesses as notes.


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


Re: [PATCH] D20510: [PATCH] Fix for bug 27802 misc-macro-parentheses breaks variadic macros

2016-05-24 Thread Mads Ravn via cfe-commits
madsravn closed this revision.
madsravn added a comment.

Code committed.


http://reviews.llvm.org/D20510



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


r270664 - [X86] Update test cases to make sure storeu builtins use the storeu instrinsics. We were previously matching on other stores in the IR from this being an -O0 test.

2016-05-24 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed May 25 00:26:23 2016
New Revision: 270664

URL: http://llvm.org/viewvc/llvm-project?rev=270664&view=rev
Log:
[X86] Update test cases to make sure storeu builtins use the storeu 
instrinsics. We were previously matching on other stores in the IR from this 
being an -O0 test.

We should probably look into making the storeu builtins just emit a normal 
store with an alignment of 1.

Modified:
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=270664&r1=270663&r2=270664&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Wed May 25 00:26:23 2016
@@ -665,7 +665,7 @@ void test_mm_store_ss(float* x, __m128 y
 void test_mm_store1_ps(float* x, __m128 y) {
   // CHECK-LABEL: test_mm_store1_ps
   // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
zeroinitializer
-  // CHECK: store <4 x float> %{{.*}}, <4 x float>* {{.*}}, align 16
+  // CHECK: call void @llvm.x86.sse.storeu.ps(i8* %{{.*}}, <4 x float> %{{.*}})
   _mm_store1_ps(x, y);
 }
 
@@ -694,7 +694,7 @@ void test_mm_storer_ps(float* x,  __m128
 
 void test_mm_storeu_ps(float* x,  __m128 y) {
   // CHECK-LABEL: test_mm_storeu_ps
-  // CHECK: store <4 x float> %{{.*}}, <4 x float>* {{.*}}, align 1
+  // CHECK: call void @llvm.x86.sse.storeu.ps(i8* %{{.*}}, <4 x float> %{{.*}})
   _mm_storeu_ps(x, y);
 }
 

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=270664&r1=270663&r2=270664&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Wed May 25 00:26:23 2016
@@ -1256,13 +1256,13 @@ void test_mm_storer_pd(__m128d A, double
 
 void test_mm_storeu_pd(double* A, __m128d B) {
   // CHECK-LABEL: test_mm_storeu_pd
-  // CHECK: store <2 x double> %{{.*}}, <2 x double>* %{{.*}}, align 1
+  // CHECK: call void @llvm.x86.sse2.storeu.pd(i8* %{{.*}}, <2 x double> 
%{{.*}})
   _mm_storeu_pd(A, B);
 }
 
 void test_mm_storeu_si128(__m128i* A, __m128i B) {
   // CHECK-LABEL: test_mm_storeu_si128
-  // CHECK: store <2 x i64> %{{.*}}, <2 x i64>* %{{.*}}, align 1
+  // CHECK: call void @llvm.x86.sse2.storeu.dq(i8* %{{.*}}, <16 x i8> %{{.*}})
   _mm_storeu_si128(A, B);
 }
 


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


Re: [PATCH] D18488: [OpenMP] Parsing and sema support for the from clause

2016-05-24 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Missed a test for printing and serialization/deserialization



Comment at: test/OpenMP/nesting_of_regions.cpp:1832
@@ -1831,3 +1831,3 @@
   for (int i = 0; i < 10; ++i) {
-#pragma omp target update to(a)
+#pragma omp target update from(a)
   }

Again, this test must be updated only for new directives, not clauses


http://reviews.llvm.org/D18488



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


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-05-24 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Add a test for nesting of regions here



Comment at: lib/Parse/ParseOpenMP.cpp:42
@@ -42,1 +41,3 @@
+  OMPD_target_exit,
+  OMPD_update
 };

Please, add a comma after 'OMPD_update' to reduce number of changes in the next 
modification of this enum.


http://reviews.llvm.org/D15944



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


Re: [PATCH] D18597: [OpenMP] Parsing and sema support for the to clause

2016-05-24 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:10218-10220
@@ +10217,5 @@
+Sema &SemaRef, DSAStackTy *DSAS, OpenMPClauseKind CKind,
+ArrayRef VarList, SmallVector &Vars,
+OMPClauseMappableExprCommon::MappableExprComponentLists &ClauseComponents,
+SmallVector &ClauseBaseDeclarations,
+SourceLocation StartLoc, OpenMPMapClauseKind MapType = OMPC_MAP_unknown,

1. Use SmallVectorImpl instead of SmallVector.
2. Is it possible to reduce number of arguments of this function by gathering 
them into a record?


Comment at: lib/Sema/SemaOpenMP.cpp:10237-10241
@@ -10210,6 +10236,7 @@
+assert(RE && "Null expr in omp to/map clause");
 if (isa(RE)) {
   // It will be analyzed later.
   Vars.push_back(RE);
   continue;
 }
 SourceLocation ELoc = RE->getExprLoc();

Still think that this check is not required.


Comment at: lib/Sema/SemaOpenMP.cpp:10353
@@ +10352,3 @@
+  // from, release, or delete.
+  DKind = DSAS->getCurrentDirective();
+  if (DKind == OMPD_target_exit_data &&

You already get DKind few lines above, why need to update it?


Comment at: test/OpenMP/nesting_of_regions.cpp:136
@@ -135,1 +135,3 @@
   }
+#pragma omp parallel
+  {

Test 'nesting_of_regions.cpp' should be updated only when adding a new 
directive, not a clause.


http://reviews.llvm.org/D18597



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


Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-24 Thread jojo.ma via cfe-commits
jojo added inline comments.


Comment at: include/llvm/Support/TargetParser.h:173
@@ +172,3 @@
+StringRef getArchName(unsigned ArchKind);
+bool getArchFeatures(unsigned ArchKind, std::vector &Features);
+unsigned getArchAttr(unsigned ArchKind);

rengolin wrote:
> Nitpick, move this declaration with the others that use &Features.
That would be more reasonable.


Comment at: include/llvm/Support/TargetParser.h:184
@@ +183,3 @@
+unsigned  getDefaultExtensions(StringRef CPU, unsigned ArchKind);
+StringRef getDefaultCPU(StringRef Arch, std::vector &Features);
+

rengolin wrote:
> You don't need the &Features any more. Same of the implementation in the cpp 
> file.
Sorry, I missed it.


Repository:
  rL LLVM

http://reviews.llvm.org/D20089



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


Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-24 Thread jojo.ma via cfe-commits
jojo updated this revision to Diff 58381.
jojo added a comment.

1.include/llvm/Support/TargetParser.h

  Move move the declaration of getArchFeatures to a more reasonable place.
  Remove unnecessary parameter for getDefaultCPU.

2.lib/Support/TargetParser.cpp

  Make adjustments according to TargetParser.h.


Repository:
  rL LLVM

http://reviews.llvm.org/D20089

Files:
  include/llvm/Support/AArch64TargetParser.def
  include/llvm/Support/ARMTargetParser.def
  include/llvm/Support/TargetParser.h
  lib/Support/TargetParser.cpp

Index: lib/Support/TargetParser.cpp
===
--- lib/Support/TargetParser.cpp
+++ lib/Support/TargetParser.cpp
@@ -21,6 +21,7 @@
 
 using namespace llvm;
 using namespace ARM;
+using namespace AArch64;
 
 namespace {
 
@@ -75,6 +76,11 @@
   {NAME, sizeof(NAME) - 1, CPU_ATTR, sizeof(CPU_ATTR) - 1, SUB_ARCH,   \
sizeof(SUB_ARCH) - 1, ARCH_FPU, ARCH_BASE_EXT, ID, ARCH_ATTR},
 #include "llvm/Support/ARMTargetParser.def"
+},AArch64ARCHNames[] = {
+#define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT)   \
+  {NAME, sizeof(NAME) - 1, CPU_ATTR, sizeof(CPU_ATTR) - 1, SUB_ARCH,   \
+   sizeof(SUB_ARCH) - 1, ARCH_FPU, ARCH_BASE_EXT, ID, ARCH_ATTR},
+#include "llvm/Support/AArch64TargetParser.def"
 };
 
 // List of Arch Extension names.
@@ -91,6 +97,10 @@
 #define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
   { NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE },
 #include "llvm/Support/ARMTargetParser.def"
+},AArch64ARCHExtNames[] = {
+#define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
+  { NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE },
+#include "llvm/Support/AArch64TargetParser.def"
 };
 
 // List of HWDiv names (use getHWDivSynonym) and which architectural
@@ -124,6 +134,10 @@
 #define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
   { NAME, sizeof(NAME) - 1, ID, IS_DEFAULT, DEFAULT_EXT },
 #include "llvm/Support/ARMTargetParser.def"
+},AArch64CPUNames[] = {
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+  { NAME, sizeof(NAME) - 1, ID, IS_DEFAULT, DEFAULT_EXT },
+#include "llvm/Support/AArch64TargetParser.def"
 };
 
 } // namespace
@@ -369,6 +383,153 @@
   return "generic";
 }
 
+StringRef llvm::AArch64::getFPUName(unsigned FPUKind) {
+  return ARM::getFPUName(FPUKind);
+}
+
+unsigned llvm::AArch64::getFPUVersion(unsigned FPUKind) {
+  return ARM::getFPUVersion(FPUKind);
+}
+
+unsigned llvm::AArch64::getFPUNeonSupportLevel(unsigned FPUKind) {
+  return ARM::getFPUNeonSupportLevel( FPUKind);
+}
+
+unsigned llvm::AArch64::getFPURestriction(unsigned FPUKind) {
+  return ARM::getFPURestriction(FPUKind);
+}
+
+unsigned llvm::AArch64::getDefaultFPU(StringRef CPU, unsigned ArchKind) {
+  if (CPU == "generic")
+return AArch64ARCHNames[ArchKind].DefaultFPU;
+
+  return StringSwitch(CPU)
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+.Case(NAME, DEFAULT_FPU)
+#include "llvm/Support/AArch64TargetParser.def"
+.Default(ARM::FK_INVALID);
+}
+
+unsigned llvm::AArch64::getDefaultExtensions(StringRef CPU, unsigned ArchKind) {
+  if (CPU == "generic")
+return AArch64ARCHNames[ArchKind].ArchBaseExtensions;
+
+  return StringSwitch(CPU)
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+.Case(NAME, AArch64ARCHNames[ID].ArchBaseExtensions | DEFAULT_EXT)
+#include "llvm/Support/AArch64TargetParser.def"
+.Default(AArch64::AEK_INVALID);
+}
+
+bool llvm::AArch64::getExtensionFeatures(unsigned Extensions,
+ std::vector &Features) {
+
+  if (Extensions == AArch64::AEK_INVALID)
+return false;
+
+  if (Extensions & AArch64::AEK_FP)
+Features.push_back("+fp-armv8");
+  if (Extensions & AArch64::AEK_SIMD)
+Features.push_back("+neon");
+  if (Extensions & AArch64::AEK_CRC)
+Features.push_back("+crc");
+  if (Extensions & AArch64::AEK_CRYPTO)
+Features.push_back("+crypto");
+  if (Extensions & AArch64::AEK_FP16)
+Features.push_back("+fullfp16");
+  if (Extensions & AArch64::AEK_PROFILE)
+Features.push_back("+spe");
+
+  return true;
+}
+
+bool llvm::AArch64::getFPUFeatures(unsigned FPUKind,
+   std::vector &Features) {
+  return ARM::getFPUFeatures(FPUKind, Features);
+}
+
+bool llvm::AArch64::getArchFeatures(unsigned ArchKind,
+ std::vector &Features) {
+  if (ArchKind == ARM::AK_INVALID || ArchKind >= ARM::AK_LAST)
+return false;
+
+  if (ArchKind == ARM::AK_ARMV8_1A)
+Features.push_back("+v8.1a");
+  if (ArchKind == ARM::AK_ARMV8_2A)
+Features.push_back("+v8.2a");
+
+  return true;
+}
+
+StringRef llvm::AArch64::getArchName(unsigned ArchKind) {
+  if (ArchKind >= ARM::AK_LAST)
+return StringRef();
+  return AArch64ARCHNames[ArchKind].getName();
+}
+
+StringRef llvm::AArch64::getCPUAttr(unsigned ArchKind) {
+  if (ArchKind == A

Re: [PATCH] D20112: [OpenMP] Add support for the 'private pointer' flag to signal variables captured in target regions and used in first-private clauses.

2016-05-24 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5630-5639
@@ -5599,6 +5629,12 @@
   // type, the default is 'tofrom'.
   CurMapTypes.push_back(ElementType->isAggregateType()
 ? (MappableExprsHandler::OMP_MAP_TO |
MappableExprsHandler::OMP_MAP_FROM)
 : MappableExprsHandler::OMP_MAP_TO);
+
+  // If we have a capture by reference we may need to add the private
+  // pointer flag if the base declaration shows in some first-private
+  // clause.
+  CurMapTypes.back() = MCHandler.adjustMapModifiersForPrivateClauses(
+  CI, CurMapTypes.back());
 }

Maybe it is better to join all this code into a single function?


http://reviews.llvm.org/D20112



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


Re: [PATCH] D20111: [OpenMP] Adjust map type bits according to latest spec and use zero size array sections for pointers.

2016-05-24 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4874-4878
@@ -4881,1 +4873,7 @@
+OMP_MAP_IS_PTR = 0x10,
+/// \brief This flags signals that an argument is the first one relating to
+/// a map/private clause expression. For some cases a single
+/// map/privatization results in multiple arguments passed to the runtime
+/// library.
+OMP_MAP_FIRST_REF = 0x20,
 /// \brief Pass the element to the device by value.

The question is not answered yet.


http://reviews.llvm.org/D20111



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


Re: [PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-24 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer added a comment.

Does this change our behavior for mingw?


http://reviews.llvm.org/D20608



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


Re: [PATCH] D18540: [Sema] Note when we've actually encountered a failure in ExprConstant, and take that into account when looking up objects.

2016-05-24 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM with or without the `SpeculativeEvaluationRAII` refactor (which is 
ultimately pre-existing duplication).

Please commit the rename of `keepEvaluatingAfterFailure` -> `noteFailure` 
separately.



Comment at: lib/AST/ExprConstant.cpp:4104-4105
@@ -4072,4 +4103,4 @@
   return false;
 }
 
 Expr *EvalExpr = BoolResult ? E->getTrueExpr() : E->getFalseExpr();

The relevant case is when we're checking the body of a `constexpr` function to 
see whether it could possibly be a constant expression. In that case, what we 
do next should depend on whether we've already found something that is known to 
never be constant. If so (which is indicated by us having a diagnostic), we 
should bail out. If not, we should check both arms of the conditional operator 
and report a problem if neither of them can be constant.

I think the upshot of all of that is that `keepEvaluatingAfterFailure` should 
return false for `EM_PotentialConstantExpression*` if we have already produced 
a diagnostic. But that's not relevant for this particular patch, so let's leave 
it as you have it for now. We can revisit this.


Comment at: lib/AST/ExprConstant.cpp:7103
@@ -7067,2 +7102,3 @@
 Expr::EvalStatus OldEvalStatus;
+bool WasSpecEval;
   };

george.burgess.iv wrote:
> I'm happy to make SpeculativeEvalRAII a type that optionally restores state, 
> if you think that would be better. That way, we don't need to duplicate this 
> logic...
> 
> Also, I can't figure out how to test this, because it's only ever run after 
> `HasSideEffects = true`, and the only thing that (I think) checks for if 
> we're speculatively evaluating *also* fails in exactly the same way if we 
> have side effects.
Yes, if we can reuse `SpeculativeEvaluationRAII` here, or otherwise factor out 
the duplication, that would be better. Also I think you're probably right that 
this is not observable right now.


Comment at: test/SemaCXX/constant-expression-cxx1y.cpp:942
@@ +941,3 @@
+  // Ensure that we don't try to speculatively evaluate writes.
+  constexpr int add(int a, int b) { return a + b; }
+

Unused?


http://reviews.llvm.org/D18540



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


Re: [PATCH] D18488: [OpenMP] Parsing and sema support for the from clause

2016-05-24 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58371.
sfantao added a comment.

Implementation and tests only for the `from` clause. Similarly to the `to` 
clause, the implementation is based on the infrastructure contributed before 
for the `map` clause.


http://reviews.llvm.org/D18488

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_from_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/target_update_to_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2249,6 +2249,9 @@
 void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_update_to_messages.cpp
===
--- test/OpenMP/target_update_to_messages.cpp
+++ test/OpenMP/target_update_to_messages.cpp
@@ -97,7 +97,7 @@
 #pragma omp target update to(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
 #pragma omp target update to(ba) // expected-error 2 {{type 'S2' is not mappable to target}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(h) // expected-error {{threadprivate variables are not allowed in 'to' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
-#pragma omp target update to(k), to(k) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
+#pragma omp target update to(k), from(k) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
 #pragma omp target update to(t), to(t[:5]) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
 #pragma omp target update to(da)
 #pragma omp target update to(da[:4])
@@ -150,7 +150,7 @@
 #pragma omp target update to(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
 #pragma omp target update to(ba) // expected-error 2 {{type 'S2' is not mappable to target}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(h) // expected-error {{threadprivate variables are not allowed in 'to' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
-#pragma omp target update to(k), to(k) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
+#pragma omp target update to(k), from(k) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
 #pragma omp target update to(t), to(t[:5]) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
 #pragma omp target update to(da)
 #pragma omp target update to(da[:4])
Index: test/OpenMP/target_update_messages.cpp
===
--- test/OpenMP/target_update_messages.cpp
+++ test/OpenMP/target_update_messages.cpp
@@ -24,7 +24,7 @@
   #pragma omp target update to(m) ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
   #pragma omp target update to(m) ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
 
-  #pragma omp target update to(m) // OK
+  #pragma omp target update from(m) // OK
   {
 foo();
   }
Index: test/OpenMP/target_update_if_messages.cpp
===
--- test/OpenMP/target_update_if_messages.cpp
+++ test/OpenMP/target_update_if_messages.cpp
@@ -13,46 +13,46 @@
 int tmain(T argc, S **argv) {
   int n;
 #pragma omp target update to(n) if // expected-error {{expected '(' after 'if'}}
-#pragm

Re: [PATCH] D18597: [OpenMP] Parsing and sema support for the to clause

2016-05-24 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58370.
sfantao added a comment.

Add implementation and tests only for the `to` clause. The implementation is 
based on the existing infrastructure used by the `map` clause already available 
upstream.


http://reviews.llvm.org/D18597

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/target_update_to_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2246,6 +2246,9 @@
 }
 void OMPClauseEnqueue::VisitOMPDefaultmapClause(
 const OMPDefaultmapClause * /*C*/) {}
+void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_update_to_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_to_messages.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 &s2):a(s2.a) { }
+  static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
+  static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 &s3):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4);
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 &s5):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+struct S6 {
+  int ii;
+  int aa[30];
+  float xx;
+  double *pp;
+};
+struct S7 {
+  int i;
+  int a[50];
+  float x;
+  S6 s6[5];
+  double *p;
+  unsigned bfa : 4;
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+typedef int from;
+
+template  // expected-note {{declared here}}
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T *m;
+  T i, t[20];
+  T &j = i;
+  T *k = &j;
+  T x;
+  T y;
+  T to;
+  const T (&l)[5] = da;
+  S7 s7;
+
+#pragma omp target update to // expected-error {{expected '(' after 'to'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to() // expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update() // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(alloc) // expected-error {{use of undeclared identifier 'alloc'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(x)
+#pragma omp target update to(t[:I])
+#pragma omp target update to(T) // expected-error {{'T' does not refer to a value}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
+#pragma omp target update to(S2::S2s)
+#pragma omp target update to(S2::S2sc)
+#pragma omp target update to(to)
+#pragma omp target update to(y x) // expected-error {{expected ',' or ')' in 'to' clause}}
+#pragma omp target update to(argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member

Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-05-24 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 58368.
sfantao added a comment.

Add parsing and sema support only for target update and already existing 
clauses (if and device).


http://reviews.llvm.org/D15944

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -612,6 +612,9 @@
   case Stmt::OMPTargetParallelForDirectiveClass:
 K = CXCursor_OMPTargetParallelForDirective;
 break;
+  case Stmt::OMPTargetUpdateDirectiveClass:
+K = CXCursor_OMPTargetUpdateDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4798,6 +4798,8 @@
 return cxstring::createRef("OMPTargetParallelDirective");
   case CXCursor_OMPTargetParallelForDirective:
 return cxstring::createRef("OMPTargetParallelForDirective");
+  case CXCursor_OMPTargetUpdateDirective:
+return cxstring::createRef("OMPTargetUpdateDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_update_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_messages.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // Aexpected-note {{declared here}}
+
+template  // Aexpected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  int n;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  int m;
+  #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update { // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update ( // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update [ // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {
+foo();
+  }
+  return tmain(argc, argv);
+}
Index: test/OpenMP/target_update_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_if_messages.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template  // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  int n;
+#pragma omp target update if // expected-error {{expected '(' after 'if'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{ex

[PATCH] D20608: clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)

2016-05-24 Thread Hans Wennborg via cfe-commits
hans created this revision.
hans added reviewers: rnk, thakis.
hans added a subscriber: cfe-commits.

This matches what MSVC does, and should make compiles faster by avoiding to 
unnecessarily emit a lot of code.

http://reviews.llvm.org/D20608

Files:
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport.cpp

Index: test/CodeGenCXX/dllimport.cpp
===
--- test/CodeGenCXX/dllimport.cpp
+++ test/CodeGenCXX/dllimport.cpp
@@ -656,7 +656,7 @@
 
 namespace Vtordisp {
   // Don't dllimport the vtordisp.
-  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPM@A@AEXXZ"
+  // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@H@Vtordisp@@$4PPPM@A@AEXXZ"
 
   class Base {
 virtual void f() {}
@@ -667,7 +667,7 @@
 C() {}
 virtual void f() {}
   };
-  template class C;
+  USECLASS(C);
 }
 
 namespace ClassTemplateStaticDef {
@@ -698,26 +698,31 @@
   template  struct A { static NonPOD x; };
   template  NonPOD A::x;
   template struct __declspec(dllimport) A;
-  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = available_externally dllimport global %"struct.PR19933::NonPOD" zeroinitializer
+  USEVARTYPE(NonPOD, A::x);
+  // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = external dllimport global %"struct.PR19933::NonPOD"
 
   int f();
   template  struct B { static int x; };
   template  int B::x = f();
   template struct __declspec(dllimport) B;
-  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(B::x);
+  // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = external dllimport global i32
 
   constexpr int g() { return 42; }
   template  struct C { static int x; };
   template  int C::x = g();
   template struct __declspec(dllimport) C;
-  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42
+  USEVAR(C::x);
+  // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = external dllimport global i32
 
   template  struct D { static int x, y; };
   template  int D::x = I + 1;
   template  int D::y = I + f();
   template struct __declspec(dllimport) D<42>;
-  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 43
-  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
+  USEVAR(D<42>::x);
+  USEVAR(D<42>::y);
+  // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
+  // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = external dllimport global i32
 }
 
 namespace PR21355 {
@@ -805,6 +810,36 @@
 USEMEMFUNC(PR23770BaseTemplate, f);
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01?f@?$PR23770BaseTemplate@H@@QAEXXZ"
 
+namespace PR27810 {
+  template 
+  struct basic_ostream {
+struct sentry {
+  sentry() { }
+  void foo() { }
+};
+  };
+  template class __declspec(dllimport) basic_ostream;
+  // The explicit instantiation definition acts as an explicit instantiation
+  // *declaration*, dllimport is not inherited by the inner class, and no
+  // functions are emitted unless they are used.
+
+  USEMEMFUNC(basic_ostream::sentry, foo);
+  // M32-DAG: {{declare|define available_externally}} x86_thiscallcc void @"\01?foo@sentry@?$basic_ostream@D@PR27810@@QAEXXZ"
+  // M32-NOT: ??0sentry@?$basic_ostream@D@PR27810@@QAE@XZ
+}
+
+namespace PR27811 {
+  template  struct codecvt {
+virtual ~codecvt() { }
+  };
+  template class __declspec(dllimport) codecvt;
+
+  // dllimport means this explicit instantiation definition gets treated as a
+  // declaration. Thus, the vtable should not be marked used, and in fact
+  // nothing for this class should be emitted at all since it's not used.
+  // M32-NOT: codecvt
+}
+
 //===--===//
 // Classes with template base classes
 //===--===//
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -958,14 +958,6 @@
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
 
-template  struct ExplicitInstantiationDeclTemplateBase2 { void func() {} };
-extern template struct ExplicitInstantiationDeclTemplateBase2;
-struct __declspec(dllexport) DerivedFromExplicitInstantiationDeclTemplateBase2 : public ExplicitInstantiationDeclTemplateBase2 {};
-template struct __declspec(dllimport) ExplicitInstantiationDeclTemplateBase2;
-USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2, func)
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
-// G32-DAG: define weak_odr x86_thiscallcc void @_ZN38ExplicitInsta

r270642 - clang-cl: Fix unused argument warning when combining /O2 and /Ob2

2016-05-24 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May 24 19:43:45 2016
New Revision: 270642

URL: http://llvm.org/viewvc/llvm-project?rev=270642&view=rev
Log:
clang-cl: Fix unused argument warning when combining /O2 and /Ob2

Modified:
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=270642&r1=270641&r2=270642&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Tue May 24 19:43:45 2016
@@ -819,7 +819,12 @@ MSVCToolChain::TranslateArgs(const llvm:
   continue;
 StringRef OptStr = A->getValue();
 for (size_t I = 0, E = OptStr.size(); I != E; ++I) {
-  const char &OptChar = *(OptStr.data() + I);
+  char OptChar = OptStr[I];
+  char PrevChar = I > 0 ? OptStr[I - 1] : '0';
+  if (PrevChar == 'b') {
+// OptChar does not expand; it's an argument to the previous char.
+continue;
+  }
   if (OptChar == '1' || OptChar == '2' || OptChar == 'x' || OptChar == 'd')
 ExpandChar = OptStr.data() + I;
 }

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=270642&r1=270641&r2=270642&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue May 24 19:43:45 2016
@@ -99,6 +99,8 @@
 
 // RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
 // RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2-NOT: warning: argument unused during compilation: '/O2'
 // Ob2: -finline-functions
 
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s


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


r270641 - [esan|wset] Add working set tool driver flags

2016-05-24 Thread Derek Bruening via cfe-commits
Author: bruening
Date: Tue May 24 19:41:24 2016
New Revision: 270641

URL: http://llvm.org/viewvc/llvm-project?rev=270641&view=rev
Log:
[esan|wset] Add working set tool driver flags

Summary:
Adds a new -fsanitize=efficiency-working-set flag to enable esan's working
set tool.  Adds appropriate tests for the new flag.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits

Differential Revision: http://reviews.llvm.org/D20484

Modified:
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/Driver/esan.c
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitize_unwind_tables.c
cfe/trunk/test/Driver/sanitizer-ld.c
cfe/trunk/test/Lexer/has_feature_efficiency_sanitizer.cpp

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=270641&r1=270640&r2=270641&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Tue May 24 19:41:24 2016
@@ -116,8 +116,10 @@ SANITIZER_GROUP("bounds", Bounds, ArrayB
 
 // EfficiencySanitizer
 SANITIZER("efficiency-cache-frag", EfficiencyCacheFrag)
+SANITIZER("efficiency-working-set", EfficiencyWorkingSet)
 // Meta-group only used internally.
-SANITIZER_GROUP("efficiency-all", Efficiency, EfficiencyCacheFrag)
+SANITIZER_GROUP("efficiency-all", Efficiency,
+EfficiencyCacheFrag | EfficiencyWorkingSet)
 
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=270641&r1=270640&r2=270641&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue May 24 19:41:24 2016
@@ -258,6 +258,8 @@ static void addEfficiencySanitizerPass(c
   EfficiencySanitizerOptions Opts;
   if (LangOpts.Sanitize.has(SanitizerKind::EfficiencyCacheFrag))
 Opts.ToolType = EfficiencySanitizerOptions::ESAN_CacheFrag;
+  else if (LangOpts.Sanitize.has(SanitizerKind::EfficiencyWorkingSet))
+Opts.ToolType = EfficiencySanitizerOptions::ESAN_WorkingSet;
   PM.add(createEfficiencySanitizerPass(Opts));
 }
 

Modified: cfe/trunk/test/Driver/esan.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/esan.c?rev=270641&r1=270640&r2=270641&view=diff
==
--- cfe/trunk/test/Driver/esan.c (original)
+++ cfe/trunk/test/Driver/esan.c Tue May 24 19:41:24 2016
@@ -2,8 +2,11 @@
 // RUN: %clang -O1 -target x86_64-unknown-linux 
-fsanitize=efficiency-cache-frag %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O2 -target x86_64-unknown-linux 
-fsanitize=efficiency-cache-frag %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -target x86_64-unknown-linux 
-fsanitize=efficiency-cache-frag %s -S -emit-llvm -o - | FileCheck %s
-// RUN: %clang -target x86_64-unknown-linux 
-fsanitize=efficiency-cache-frag  %s -S -emit-llvm -o - | FileCheck %s
-// Verify that -fsanitize=efficiency-cache-frag invokes esan instrumentation.
+// RUN: %clang -target x86_64-unknown-linux 
-fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -target x86_64-unknown-linux 
-fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -target x86_64-unknown-linux 
-fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -target x86_64-unknown-linux 
-fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s
+// Verify that -fsanitize=efficiency-* invokes esan instrumentation.
 
 int foo(int *a) { return *a; }
 // CHECK: __esan_init

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=270641&r1=270640&r2=270641&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue May 24 19:41:24 2016
@@ -84,19 +84,24 @@
 // CHECK-SANKA-SANL: '-fsanitize=kernel-address' not allowed with 
'-fsanitize=leak'
 
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=efficiency-cache-frag,address -pie -fno-rtti %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANE-SANA
-// CHECK-SANE-SANA: '-fsanitize=efficiency-cache-frag' not allowed with 
'-fsanitize=address'
+// RUN: %clang -target x86_64-linux-gnu 
-fsanitize=efficiency-working-set,address -pie -fno-rtti %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANE-SANA
+// CHECK-SANE-SANA: '-fsanitize=efficiency-{{.*}}' not allowed with 
'-fsanitize=address'
 

Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-24 Thread Richard Smith via cfe-commits
rsmith added a comment.

In http://reviews.llvm.org/D20602#438643, @srhines wrote:

> In http://reviews.llvm.org/D20602#438528, @rsmith wrote:
>
> > Looks like this extension was added at some point between 1.1 and 2.1. It 
> > would make sense to produce an `ExtWarn` for it if the OpenCL standard 
> > version is less than the one that introduced it (whenever that was) -- that 
> > would match what we do for extensions in other languages.
>
>
> This isn't just for OpenCL (actually we don't care about it in the context of 
> OpenCL at all). We really are adding this as more of an extension for C99, 
> where Android has used this in the past. In the case of OpenCL, I also don't 
> know that it should be recognized as invalid, because it can be lowered to an 
> appropriate construct on any implementation (since they all have to support 
> regular 4-vectors).


I'm not suggesting it be treated as invalid. This extension is part of at least 
OpenCL 2.1, but it's not part of OpenCL 1.0. `ext_vector_type` is Clang's 
implementation of the OpenCL vector type. Therefore if the user asks us to 
support OpenCL 1.0, we should give them a warning if they use this syntax.

If we're not building an OpenCL source file, then yes, this is our extension 
and it makes sense for it to be available unconditionally (without a warning).


http://reviews.llvm.org/D20602



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


LLVM buildmaster will be restarted tonight

2016-05-24 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-24 Thread Stephen Hines via cfe-commits
srhines added a comment.

In http://reviews.llvm.org/D20602#438528, @rsmith wrote:

> Looks like this extension was added at some point between 1.1 and 2.1. It 
> would make sense to produce an `ExtWarn` for it if the OpenCL standard 
> version is less than the one that introduced it (whenever that was) -- that 
> would match what we do for extensions in other languages.


This isn't just for OpenCL (actually we don't care about it in the context of 
OpenCL at all). We really are adding this as more of an extension for C99, 
where Android has used this in the past. In the case of OpenCL, I also don't 
know that it should be recognized as invalid, because it can be lowered to an 
appropriate construct on any implementation (since they all have to support 
regular 4-vectors).


http://reviews.llvm.org/D20602



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


Re: [PATCH] D20519: [clang-tidy] Ignore ADL-style using decls in unused-using-decls check.

2016-05-24 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:47
@@ +46,3 @@
+  return;
+// Ignores using-declarations defined in function definitions to avoid
+// arguement-dependent lookup.

hokein wrote:
> alexfh wrote:
> > I don't think using declarations in functions are inherently related to 
> > ADL. This check doesn't seem like a useful heuristic.
> Yeah, the current work around is only to ignore all using-decls in function 
> context which is not perfect. I didn't find out a better way.
If we're talking about this pattern:

  using std::swap;
  ...
  ::ns::T x, y;
  swap(x, y); // ::ns::swap() is used

then for each function name resolved using ADL, we can find all using 
declarations for the same name in different namespaces and mark them used. WDYT?


http://reviews.llvm.org/D20519



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
hans added a comment.

In http://reviews.llvm.org/D20576#438581, @Ilod wrote:

> It seems the new test was commited as .cc instead of .c, which changes the 
> name mangling, making // NOINLINE-LABEL: @foo fail.
>  Either the file should be renamed, or -x c should be added to clang 
> invocation, or LABEL check updated.


Sigh, I'm not getting many points today.

I renamed the test because when I tried it, the inline_hint() function didn't 
get inlined in C mode, but it did in C++ mode. But in so doing, I renamed it to 
.cc, which means the test didn't run at all (it should be .cpp), which is why I 
didn't notice that the test doesn't pass.

The reason inlining didn't happen was probably because I ran the test for a 
different target than you did. Which reminds me, the test needs to specify a 
target triple.

Hopefully I managed to make things right in r270633


Repository:
  rL LLVM

http://reviews.llvm.org/D20576



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


r270634 - docs: Document how safestack handles setjmp and exceptions.

2016-05-24 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue May 24 18:38:02 2016
New Revision: 270634

URL: http://llvm.org/viewvc/llvm-project?rev=270634&view=rev
Log:
docs: Document how safestack handles setjmp and exceptions.

Modified:
cfe/trunk/docs/SafeStack.rst

Modified: cfe/trunk/docs/SafeStack.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SafeStack.rst?rev=270634&r1=270633&r2=270634&view=diff
==
--- cfe/trunk/docs/SafeStack.rst (original)
+++ cfe/trunk/docs/SafeStack.rst Tue May 24 18:38:02 2016
@@ -178,6 +178,17 @@ Please refer to the `Code-Pointer Integr
 project page for more information about the design of the SafeStack and its
 related technologies.
 
+setjmp and exception handling
+-
+
+The `OSDI'14 paper `_ mentions that
+on Linux the instrumentation pass finds calls to setjmp or functions that
+may throw an exception, and inserts required instrumentation at their call
+sites. Specifically, the instrumentation pass saves the shadow stack pointer
+on the safe stack before the call site, and restores it either after the
+call to setjmp or after an exception has been caught. This is implemented
+in the function ``SafeStack::createStackRestorePoints``.
+
 Publications
 
 


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


r270633 - Rename test/CodeGen/inline-optim.cc to .c and provide a triple

2016-05-24 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May 24 18:37:56 2016
New Revision: 270633

URL: http://llvm.org/viewvc/llvm-project?rev=270633&view=rev
Log:
Rename test/CodeGen/inline-optim.cc to .c and provide a triple

Added:
cfe/trunk/test/CodeGen/inline-optim.c
  - copied, changed from r270615, cfe/trunk/test/CodeGen/inline-optim.cc
Removed:
cfe/trunk/test/CodeGen/inline-optim.cc

Copied: cfe/trunk/test/CodeGen/inline-optim.c (from r270615, 
cfe/trunk/test/CodeGen/inline-optim.cc)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-optim.c?p2=cfe/trunk/test/CodeGen/inline-optim.c&p1=cfe/trunk/test/CodeGen/inline-optim.cc&r1=270615&r2=270633&rev=270633&view=diff
==
--- cfe/trunk/test/CodeGen/inline-optim.cc (original)
+++ cfe/trunk/test/CodeGen/inline-optim.c Tue May 24 18:37:56 2016
@@ -1,8 +1,8 @@
 // Make sure -finline-functions family flags are behaving correctly.
 
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
-// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck 
-check-prefix=NOINLINE %s
-// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck 
-check-prefix=INLINE %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm %s -o - | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -O3 -fno-inline-functions -emit-llvm 
%s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -finline-functions -emit-llvm %s -o - 
| FileCheck -check-prefix=INLINE %s
 
 inline int inline_hint(int a, int b) { return(a+b); }
 

Removed: cfe/trunk/test/CodeGen/inline-optim.cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-optim.cc?rev=270632&view=auto
==
--- cfe/trunk/test/CodeGen/inline-optim.cc (original)
+++ cfe/trunk/test/CodeGen/inline-optim.cc (removed)
@@ -1,26 +0,0 @@
-// Make sure -finline-functions family flags are behaving correctly.
-
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
-// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck 
-check-prefix=NOINLINE %s
-// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck 
-check-prefix=INLINE %s
-
-inline int inline_hint(int a, int b) { return(a+b); }
-
-int inline_no_hint(int a, int b) { return (a/b); }
-
-inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { 
return(a*b); }
-
-volatile int *pa = (int*) 0x1000;
-void foo() {
-// NOINLINE-LABEL: @foo
-// INLINE-LABEL: @foo
-// NOINLINE: call i32 @inline_hint
-// INLINE-NOT: call i32 @inline_hint
-pa[0] = inline_hint(pa[1],pa[2]);
-// NOINLINE-NOT: call i32 @inline_always
-// INLINE-NOT: call i32 @inline_always
-pa[3] = inline_always(pa[4],pa[5]);
-// NOINLINE: call i32 @inline_no_hint
-// INLINE-NOT: call i32 @inline_no_hint
-pa[6] = inline_no_hint(pa[7], pa[8]);
-}


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


Re: [PATCH] D20510: [PATCH] Fix for bug 27802 misc-macro-parentheses breaks variadic macros

2016-05-24 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20510



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


Re: [PATCH] D20512: [PATCH] Bug 27475 - Request header guard check processes .hpp files as well as .h files

2016-05-24 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/llvm/HeaderGuardCheck.cpp:18
@@ +17,3 @@
+  const std::string RawStringHeaderFileExtensions(
+  Options.getLocalOrGlobal("HeaderFileExtensions", 
",h,hh,hpp,hxx"));
+  utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,

This should be done in the constructor, not on each call to this method.


http://reviews.llvm.org/D20512



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-24 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Headers/opencl-c.h:143
@@ +142,3 @@
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#define NULL  ((void*)0)
+#endif

Anastasia wrote:
> indentation seems wrong!
fixed.


Comment at: lib/Headers/opencl-c.h:175
@@ +174,3 @@
+ */
+#define NAN as_float(INT_MAX)
+

Anastasia wrote:
> Is this a part of spec? I don't see it in s6.13.2.1.
see v1.1 s6.11.2.


Comment at: lib/Headers/opencl-c.h:7953
@@ +7952,3 @@
+/**
+ * Compute the base e exponential of x.
+ */

Anastasia wrote:
> Ping!
I think "base e exponential" is the correct name. It could be renamed as "base 
e exponential function" to be more clear.

"exponent" is the 'superscript' part of an exponential. e.g. in e^n, n is the 
exponent.


Comment at: lib/Headers/opencl-c.h:8307
@@ +8306,3 @@
+#else
+float _ovld fract(float x, __global float *iptr);
+float2 _ovld fract(float2 x, __global float2 *iptr);

Anastasia wrote:
> Any problem with doing this unconditionally?
This requires vendors to implement functions not required by OpenCL 2.0 spec. 
For example, in our 2.0 builtin library we don't have such functions.


Comment at: lib/Headers/opencl-c.h:8458
@@ +8457,3 @@
+/**
+ * Compute the value of the square root of x^2+ y^2
+ * without undue overflow or underflow.

Anastasia wrote:
> Ping!
Fixed.


Comment at: lib/Headers/opencl-c.h:12773
@@ +12772,3 @@
+#ifdef cl_khr_fp16
+half _ovld vload(size_t offset, const half *p);
+half2 _ovld vload2(size_t offset, const half *p);

Anastasia wrote:
> Ping!
no. they are different. see OpenCL extensions v1.1 s9.6.6, v1.2 s9.5.6, v2.0 
s9.4.6


http://reviews.llvm.org/D18369



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod added a comment.

Hello,

It seems the new test was commited as .cc instead of .c, which changes the name 
mangling, making // NOINLINE-LABEL: @foo fail.
Either the file should be renamed, or -x c should be added to clang invocation, 
or LABEL check updated.


Repository:
  rL LLVM

http://reviews.llvm.org/D20576



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


Re: [PATCH] D20597: Speed up check by using a recursive visitor.

2016-05-24 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!



Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:25
@@ +24,3 @@
+  bool TraverseStmt(Stmt* Node) {
+if (!Node) return Base::TraverseStmt(Node);
+

nit: clang-format -style=file


http://reviews.llvm.org/D20597



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


Re: [PATCH] D20423: [Clang][LLVMGold] Passing LLVM arguments to gold plugin

2016-05-24 Thread Mailing List "llvm-commits" via cfe-commits
llvm-commits added a subscriber: llvm-commits.
llvm-commits added a comment.

This seems strange to me.  For example, it breaks the otherwise very convenient:


$ clang -flto t.c -mllvm -some-internal-option-for-cc1
--

I don't understand how it's better.


http://reviews.llvm.org/D20423



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-24 Thread Richard Smith via cfe-commits
rsmith added a comment.

Looks like this extension was added at some point between 1.1 and 2.1. It would 
make sense to produce an `ExtWarn` for it if the OpenCL standard version is 
less than the one that introduced it (whenever that was) -- that would match 
what we do for extensions in other languages.


http://reviews.llvm.org/D20602



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


Re: [PATCH] D20563: Add load/store co-processor intrinsics

2016-05-24 Thread Tim Northover via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a reviewer: t.p.northover.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Thanks Ranjeet. LGTM!

Tim.


http://reviews.llvm.org/D20563



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


r270625 - Make the altivec intrinsics that require immediate constant propagation

2016-05-24 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue May 24 17:25:06 2016
New Revision: 270625

URL: http://llvm.org/viewvc/llvm-project?rev=270625&view=rev
Log:
Make the altivec intrinsics that require immediate constant propagation
macros rather than functions.

Unfortunately couldn't come up with a simple testcase that didn't need
code generation to verify what was going on.

Modified:
cfe/trunk/lib/Headers/altivec.h

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=270625&r1=270624&r2=270625&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Tue May 24 17:25:06 2016
@@ -2102,32 +2102,24 @@ static __inline__ void __attribute__((__
 }
 
 /* vec_dst */
-
-static __inline__ void __attribute__((__always_inline__))
-vec_dst(const void *__a, int __b, int __c) {
-  __builtin_altivec_dst(__a, __b, __c);
-}
+#define vec_dst(__PTR, __CW, __STR) \
+  __extension__(\
+  { __builtin_altivec_dst((const void *)(__PTR), (__CW), (__STR)); })
 
 /* vec_dstst */
-
-static __inline__ void __attribute__((__always_inline__))
-vec_dstst(const void *__a, int __b, int __c) {
-  __builtin_altivec_dstst(__a, __b, __c);
-}
+#define vec_dstst(__PTR, __CW, __STR) \
+  __extension__(  \
+  { __builtin_altivec_dstst((const void *)(__PTR), (__CW), (__STR)); })
 
 /* vec_dststt */
-
-static __inline__ void __attribute__((__always_inline__))
-vec_dststt(const void *__a, int __b, int __c) {
-  __builtin_altivec_dststt(__a, __b, __c);
-}
+#define vec_dststt(__PTR, __CW, __STR) \
+  __extension__(   \
+  { __builtin_altivec_dststt((const void *)(__PTR), (__CW), (__STR)); })
 
 /* vec_dstt */
-
-static __inline__ void __attribute__((__always_inline__))
-vec_dstt(const void *__a, int __b, int __c) {
-  __builtin_altivec_dstt(__a, __b, __c);
-}
+#define vec_dstt(__PTR, __CW, __STR) \
+  __extension__( \
+  { __builtin_altivec_dstt((const void *)(__PTR), (__CW), (__STR)); })
 
 /* vec_eqv */
 


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


[PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-05-24 Thread Pirama Arumuga Nainar via cfe-commits
pirama created this revision.
pirama added subscribers: cfe-commits, srhines.

This patch enables .rgba accessors to ext_vector_type types and adds
tests for syntax validation and code generation.

'a' and 'b' can appear either in the point access mode or the numeric
access mode (for indices 10 and 11).  To disambiguate between the two
usages, the accessor type is explicitly passed to relevant methods.

http://reviews.llvm.org/D20602

Files:
  include/clang/AST/Type.h
  lib/AST/Expr.cpp
  lib/Sema/SemaExprMember.cpp
  test/CodeGen/ext-vector.c
  test/Sema/ext_vector_components.c

Index: test/Sema/ext_vector_components.c
===
--- test/Sema/ext_vector_components.c
+++ test/Sema/ext_vector_components.c
@@ -39,6 +39,33 @@
 vec4.x = vec16.sF;
   
 vec4p->yz = vec4p->xy;
+
+vec2.a; // expected-error {{vector component access exceeds type 'float2'}}
+vec2.rgba; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.rgba; // expected-warning {{expression result unused}}
+vec4.rgbz; // expected-error {{illegal vector component name 'z'}}
+vec4.rgbc; // expected-error {{illegal vector component name 'c'}}
+vec4.xyzr; // expected-error {{illegal vector component name 'r'}}
+vec4.s01b; // expected-error {{vector component access exceeds type 'float4'}}
+
+vec3 = vec4.rgb; // legal, shorten
+f = vec2.r; // legal, shorten
+f = vec4.rg.r; // legal, shorten
+vec4_2.rgba = vec4.xyzw; // legal, no intermingling
+
+vec4_2.rgbr = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgbb = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec4_2.rgga = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.x = f;
+vec2.rr = vec2_2.rg; // expected-error {{vector is not assignable (contains duplicate components)}}
+vec2.gr = vec2_2.rg;
+vec2.gr.g = vec2_2.r;
+vec4 = (float4){ 1,2,3,4 };
+vec4.rg.b; // expected-error {{vector component access exceeds type 'float2'}}
+vec4.r = vec16.sf;
+vec4.g = vec16.sF;
+
+vec4p->gb = vec4p->rg;
 }
 
 float2 lo(float3 x) { return x.lo; }
Index: test/CodeGen/ext-vector.c
===
--- test/CodeGen/ext-vector.c
+++ test/CodeGen/ext-vector.c
@@ -301,3 +301,40 @@
   char valC;
   char16 destVal = valC ? valA : valB;
 }
+
+typedef __attribute__(( ext_vector_type(16) )) float float16;
+
+float16 vec16, vec16_2;
+
+// CHECK: @test_rgba
+void test_rgba() {
+  // CHECK: fadd <4 x float>
+  vec4_2 = vec4.abgr + vec4;
+
+  // CHECK: shufflevector {{.*}} 
+  vec2 = vec4.rg;
+  // CHECK: shufflevector {{.*}} 
+  vec2_2 = vec4.ba;
+  // CHECK: extractelement {{.*}} 2
+  f = vec4.b;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec4_2.;
+
+  // CHECK: insertelement {{.*}} 0
+  vec2.r = f;
+  // CHECK: shufflevector {{.*}} 
+  vec2.gr = vec2;
+
+  // CHECK: extractelement {{.*}} 0
+  f = vec4_2.rg.r;
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  // CHECK: shufflevector {{.*}} 
+  vec4.rgb = vec4.bgr;
+
+  // CHECK: extractelement {{.*}} 11
+  // CHECK: insertelement {{.*}} 2
+  vec4.b = vec16.sb;
+  // CHECK: shufflevector {{.*}} 
+  vec4_2 = vec16.sabcd;
+}
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -268,6 +268,20 @@
   llvm_unreachable("unexpected instance member access kind");
 }
 
+/// Determine whether input char is from rgba component set.
+static bool
+IsRGBA(char c) {
+  switch (c) {
+  case 'r':
+  case 'g':
+  case 'b':
+  case 'a':
+return true;
+  default:
+return false;
+  }
+}
+
 /// Check an ext-vector component access expression.
 ///
 /// VK should be set in advance to the value kind of the base
@@ -307,7 +321,11 @@
 HalvingSwizzle = true;
   } else if (!HexSwizzle &&
  (Idx = vecType->getPointAccessorIdx(*compStr)) != -1) {
+bool HasRGBA = IsRGBA(*compStr);
 do {
+  // Ensure that xyzw and rgba components don't intermingle.
+  if (HasRGBA != IsRGBA(*compStr))
+break;
   if (HasIndex[Idx]) HasRepeated = true;
   HasIndex[Idx] = true;
   compStr++;
@@ -338,7 +356,7 @@
   compStr++;
 
 while (*compStr) {
-  if (!vecType->isAccessorWithinNumElements(*compStr++)) {
+  if (!vecType->isAccessorWithinNumElements(*compStr++, HexSwizzle)) {
 S.Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)
   << baseType << SourceRange(CompLoc);
 return QualType();
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -3383,8 +3383,11 @@
 void ExtVectorElementExpr::getEncodedElementAccess(
 SmallVectorImpl &

Re: [PATCH] D20573: [libcxx] Allow explicit pthread opt-in

2016-05-24 Thread Ben Craig via cfe-commits
bcraig marked 2 inline comments as done.
bcraig added a comment.

http://reviews.llvm.org/D20573



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


Re: [PATCH] D20573: [libcxx] Allow explicit pthread opt-in

2016-05-24 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 58320.

http://reviews.llvm.org/D20573

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -19,14 +19,14 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 // Mutex
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -194,7 +194,7 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#else // !_LIBCPP_HAS_THREAD_API_PTHREAD
   #error "No thread API selected."
 #endif
 
Index: include/__config_site.in
===
--- include/__config_site.in
+++ include/__config_site.in
@@ -19,5 +19,6 @@
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
+#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 
 #endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -813,19 +813,23 @@
 #endif
 
 // Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \
 defined(__NetBSD__) || \
 defined(__linux__) || \
 defined(__APPLE__) || \
 defined(__CloudABI__) || \
 defined(__sun__)
-#  define _LIBCPP_THREAD_API_PTHREAD
+#  define _LIBCPP_HAS_THREAD_API_PTHREAD
 # else
 #  error "No thread API"
-# endif // _LIBCPP_THREAD_API
+# endif // _LIBCPP_HAS_THREAD_API
 #endif // _LIBCPP_HAS_NO_THREADS
 
+#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#  error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
+ _LIBCPP_HAS_NO_THREADS is not defined.
+#endif
 
 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
 #  error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -126,6 +126,7 @@
   "Build libc++ with support for a monotonic clock.
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
 option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
+option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
 
 # Misc options 
 # FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -172,6 +173,11 @@
   " when LIBCXX_ENABLE_THREADS is also set to OFF.")
 endif()
 
+if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
+  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
+  " when LIBCXX_ENABLE_THREADS is also set to ON.")
+endif()
+
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
 # is ON.
 if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
@@ -384,6 +390,7 @@
 config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
 
+config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 
 if (LIBCXX_NEEDS_SITE_CONFIG)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
hans added a subscriber: majnemer.
hans added a comment.

majnemer reminded me that /O options can be combined, so e.g. /Odb2 would be a 
valid combination. I've followed up with r270614 to move the /Ob flags into 
that mechanism.


Repository:
  rL LLVM

http://reviews.llvm.org/D20576



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


Re: [PATCH] D20500: [ms] Allow more unqualified lookup of types in dependent base classes

2016-05-24 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270615: [ms] Allow more unqualified lookup of types in 
dependent base classes (authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D20500?vs=58316&id=58319#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20500

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaTemplate/ms-delayed-default-template-args.cpp
  cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp

Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -473,17 +473,53 @@
   llvm_unreachable("something isn't in TU scope?");
 }
 
-ParsedType Sema::ActOnDelayedDefaultTemplateArg(const IdentifierInfo &II,
-SourceLocation NameLoc) {
-  // Accepting an undeclared identifier as a default argument for a template
-  // type parameter is a Microsoft extension.
-  Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
-
-  // Build a fake DependentNameType that will perform lookup into CurContext at
-  // instantiation time.  The name specifier isn't dependent, so template
-  // instantiation won't transform it.  It will retry the lookup, however.
-  NestedNameSpecifier *NNS =
-  synthesizeCurrentNestedNameSpecifier(Context, CurContext);
+/// Find the parent class with dependent bases of the innermost enclosing method
+/// context. Do not look for enclosing CXXRecordDecls directly, or we will end
+/// up allowing unqualified dependent type names at class-level, which MSVC
+/// correctly rejects.
+static const CXXRecordDecl *
+findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC) {
+  for (; DC && DC->isDependentContext(); DC = DC->getLookupParent()) {
+DC = DC->getPrimaryContext();
+if (const auto *MD = dyn_cast(DC))
+  if (MD->getParent()->hasAnyDependentBases())
+return MD->getParent();
+  }
+  return nullptr;
+}
+
+ParsedType Sema::ActOnMSVCUnknownTypeName(const IdentifierInfo &II,
+  SourceLocation NameLoc,
+  bool IsTemplateTypeArg) {
+  assert(getLangOpts().MSVCCompat && "shouldn't be called in non-MSVC mode");
+
+  NestedNameSpecifier *NNS = nullptr;
+  if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
+// If we weren't able to parse a default template argument, delay lookup
+// until instantiation time by making a non-dependent DependentTypeName. We
+// pretend we saw a NestedNameSpecifier referring to the current scope, and
+// lookup is retried.
+// FIXME: This hurts our diagnostic quality, since we get errors like "no
+// type named 'Foo' in 'current_namespace'" when the user didn't write any
+// name specifiers.
+NNS = synthesizeCurrentNestedNameSpecifier(Context, CurContext);
+Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
+  } else if (const CXXRecordDecl *RD =
+ findRecordWithDependentBasesOfEnclosingMethod(CurContext)) {
+// Build a DependentNameType that will perform lookup into RD at
+// instantiation time.
+NNS = NestedNameSpecifier::Create(Context, nullptr, RD->isTemplateDecl(),
+  RD->getTypeForDecl());
+
+// Diagnose that this identifier was undeclared, and retry the lookup during
+// template instantiation.
+Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
+  << RD;
+  } else {
+// This is not a situation that we should recover from.
+return ParsedType();
+  }
+
   QualType T = Context.getDependentNameType(ETK_None, NNS, &II);
 
   // Build type location information.  We synthesized the qualifier, so we have
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -2279,6 +2279,24 @@
 return false;
   }
 
+  if (getLangOpts().CPlusPlus && (!SS || SS->isEmpty()) &&
+  getLangOpts().MSVCCompat) {
+// Lookup of an unqualified type name has failed in MSVC compatibility mode.
+// Give Sema a chance to recover if we are in a template with dependent base
+// classes.
+if (ParsedType T = Actions.ActOnMSVCUnknownTypeName(
+*Tok.getIdentifierInfo(), Tok.getLocation(),
+DSC == DSC_template_type_arg)) {
+  const char *PrevSpec;
+  unsigned DiagID;
+  DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
+ Actions.getASTContext().getPrintingPolicy());
+  DS.SetRangeEnd(Tok.getLocation());
+  ConsumeToken();
+  return false;
+}
+  }
+
   // Otherwise, if we don'

r270615 - [ms] Allow more unqualified lookup of types in dependent base classes

2016-05-24 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May 24 16:23:54 2016
New Revision: 270615

URL: http://llvm.org/viewvc/llvm-project?rev=270615&view=rev
Log:
[ms] Allow more unqualified lookup of types in dependent base classes

Summary:
In dependent contexts where we know a type name is required, such as a
new expression, we can recover by forming a DependentNameType.

This generalizes our existing compatibility hack for default arguments
for template type parameters.

Works towards parsing atlctrlw.h, which is PR26748.

Reviewers: avt77, rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20500

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaTemplate/ms-delayed-default-template-args.cpp
cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=270615&r1=270614&r2=270615&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May 24 16:23:54 2016
@@ -1529,12 +1529,13 @@ public:
ParsedType &SuggestedType,
bool AllowClassTemplates = false);
 
-  /// \brief For compatibility with MSVC, we delay parsing of some default
-  /// template type arguments until instantiation time.  Emits a warning and
-  /// returns a synthesized DependentNameType that isn't really dependent on 
any
-  /// other template arguments.
-  ParsedType ActOnDelayedDefaultTemplateArg(const IdentifierInfo &II,
-SourceLocation NameLoc);
+  /// Attempt to behave like MSVC in situations where lookup of an unqualified
+  /// type name has failed in a dependent context. In these situations, we
+  /// automatically form a DependentTypeName that will retry lookup in a 
related
+  /// scope during instantiation.
+  ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II,
+  SourceLocation NameLoc,
+  bool IsTemplateTypeArg);
 
   /// \brief Describes the result of the name lookup and resolution performed
   /// by \c ClassifyName().

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=270615&r1=270614&r2=270615&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue May 24 16:23:54 2016
@@ -2279,6 +2279,24 @@ bool Parser::ParseImplicitInt(DeclSpec &
 return false;
   }
 
+  if (getLangOpts().CPlusPlus && (!SS || SS->isEmpty()) &&
+  getLangOpts().MSVCCompat) {
+// Lookup of an unqualified type name has failed in MSVC compatibility 
mode.
+// Give Sema a chance to recover if we are in a template with dependent 
base
+// classes.
+if (ParsedType T = Actions.ActOnMSVCUnknownTypeName(
+*Tok.getIdentifierInfo(), Tok.getLocation(),
+DSC == DSC_template_type_arg)) {
+  const char *PrevSpec;
+  unsigned DiagID;
+  DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
+ Actions.getASTContext().getPrintingPolicy());
+  DS.SetRangeEnd(Tok.getLocation());
+  ConsumeToken();
+  return false;
+}
+  }
+
   // Otherwise, if we don't consume this token, we are going to emit an
   // error anyway.  Try to recover from various common problems.  Check
   // to see if this was a reference to a tag name without a tag specified.
@@ -2986,16 +3004,6 @@ void Parser::ParseDeclarationSpecifiers(
 Actions.getTypeName(*Tok.getIdentifierInfo(),
 Tok.getLocation(), getCurScope());
 
-  // MSVC: If we weren't able to parse a default template argument, and 
it's
-  // just a simple identifier, create a DependentNameType.  This will allow
-  // us to defer the name lookup to template instantiation time, as long we
-  // forge a NestedNameSpecifier for the current context.
-  if (!TypeRep && DSContext == DSC_template_type_arg &&
-  getLangOpts().MSVCCompat && getCurScope()->isTemplateParamScope()) {
-TypeRep = Actions.ActOnDelayedDefaultTemplateArg(
-*Tok.getIdentifierInfo(), Tok.getLocation());
-  }
-
   // If this is not a typedef name, don't parse it as part of the declspec,
   // it must be an implicit int or an error.
   if (!TypeRep) {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=270615&r1=270614&r2=270615&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/l

Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

For reference here's the current test coverage: 
http://efcs.ca/filesystem-coverage/


http://reviews.llvm.org/D16948



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


r270614 - clang-cl: Bake /Ob0 and /Ob2 into the general /O option handling

2016-05-24 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May 24 16:23:29 2016
New Revision: 270614

URL: http://llvm.org/viewvc/llvm-project?rev=270614&view=rev
Log:
clang-cl: Bake /Ob0 and /Ob2 into the general /O option handling

This is a follow-up to r270609, wherein I forgot that /O options can
be combined, and e.g. /Odb2 is a valid combination.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=270614&r1=270613&r2=270614&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue May 24 16:23:29 2016
@@ -100,10 +100,6 @@ def _SLASH_J : CLFlag<"J">, HelpText<"Ma
 def _SLASH_O0 : CLFlag<"O0">, Alias;
 // /Oy- is handled by the /O option because /Oy- only has an effect on 32-bit.
 def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">;
-def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">,
-  Alias;
-def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">,
-  Alias;
 def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias;
 def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">,
   Alias;

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=270614&r1=270613&r2=270614&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Tue May 24 16:23:29 2016
@@ -722,8 +722,20 @@ static void TranslateOptArg(Arg *A, llvm
   }
   break;
 case 'b':
-  if (I + 1 != E && isdigit(OptStr[I + 1]))
+  if (I + 1 != E && isdigit(OptStr[I + 1])) {
+switch (OptStr[I + 1]) {
+case '0':
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_inline));
+  break;
+case '1':
+  // TODO: Inline calls to 'inline functions' only.
+  break;
+case '2':
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT_finline_functions));
+  break;
+}
 ++I;
+  }
   break;
 case 'g':
   break;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=270614&r1=270613&r2=270614&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue May 24 16:23:29 2016
@@ -98,6 +98,7 @@
 // Ob0: -fno-inline
 
 // RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
 // Ob2: -finline-functions
 
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s


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


Re: [PATCH] D20500: [ms] Allow more unqualified lookup of types in dependent base classes

2016-05-24 Thread Reid Kleckner via cfe-commits
rnk updated this revision to Diff 58316.
rnk added a comment.

- fix the diff


http://reviews.llvm.org/D20500

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaTemplate/ms-delayed-default-template-args.cpp
  test/SemaTemplate/ms-lookup-template-base-classes.cpp

Index: test/SemaTemplate/ms-lookup-template-base-classes.cpp
===
--- test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1y -fms-compatibility -fno-spell-checking -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++1y -fms-compatibility -fno-spell-checking -fsyntax-only -verify %s
 
 
 template 
@@ -573,3 +573,33 @@
 template  decltype(h(T())) check2(); // expected-note{{candidate template ignored: substitution failure [with T = int]: no matching function for call to 'h'}}
 decltype(check2()) y; // expected-error{{no matching function for call to 'check2'}}
 }
+
+// We also allow unqualified lookup into bases in contexts where the we know the
+// undeclared identifier *must* be a type, such as a new expression or catch
+// parameter type.
+template 
+struct UseUnqualifiedTypeNames : T {
+  void foo() {
+void *P = new TheType; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+size_t x = __builtin_offsetof(TheType, f2); // expected-warning {{unqualified lookup}} expected-error {{no type}}
+try {
+} catch (TheType) { // expected-warning {{unqualified lookup}} expected-error {{no type}}
+}
+enum E : IntegerType { E0 = 42 }; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+_Atomic(TheType) a; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+  }
+  void out_of_line();
+};
+template 
+void UseUnqualifiedTypeNames::out_of_line() {
+  void *p = new TheType; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+}
+struct Base {
+  typedef int IntegerType;
+  struct TheType {
+int f1, f2;
+  };
+};
+template struct UseUnqualifiedTypeNames;
+struct BadBase { };
+template struct UseUnqualifiedTypeNames; // expected-note-re 2 {{in instantiation {{.*}} requested here}}
Index: test/SemaTemplate/ms-delayed-default-template-args.cpp
===
--- test/SemaTemplate/ms-delayed-default-template-args.cpp
+++ test/SemaTemplate/ms-delayed-default-template-args.cpp
@@ -55,6 +55,15 @@
 typedef int Weber;
 }
 
+// MSVC accepts this, but Clang doesn't.
+namespace test_scope_spec {
+template   // expected-error {{use of undeclared identifier 'ns'}}
+struct Foo {
+  static_assert(sizeof(T) == 4, "Bar should have gotten int");
+};
+namespace ns { typedef int Bar; }
+}
+
 #ifdef __clang__
 // These are negative test cases that MSVC doesn't compile either.  Try to use
 // unique undeclared identifiers so typo correction doesn't find types declared
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -473,17 +473,53 @@
   llvm_unreachable("something isn't in TU scope?");
 }
 
-ParsedType Sema::ActOnDelayedDefaultTemplateArg(const IdentifierInfo &II,
-SourceLocation NameLoc) {
-  // Accepting an undeclared identifier as a default argument for a template
-  // type parameter is a Microsoft extension.
-  Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
-
-  // Build a fake DependentNameType that will perform lookup into CurContext at
-  // instantiation time.  The name specifier isn't dependent, so template
-  // instantiation won't transform it.  It will retry the lookup, however.
-  NestedNameSpecifier *NNS =
-  synthesizeCurrentNestedNameSpecifier(Context, CurContext);
+/// Find the parent class with dependent bases of the innermost enclosing method
+/// context. Do not look for enclosing CXXRecordDecls directly, or we will end
+/// up allowing unqualified dependent type names at class-level, which MSVC
+/// correctly rejects.
+static const CXXRecordDecl *
+findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC) {
+  for (; DC && DC->isDependentContext(); DC = DC->getLookupParent()) {
+DC = DC->getPrimaryContext();
+if (const auto *MD = dyn_cast(DC))
+  if (MD->getParent()->hasAnyDependentBases())
+return MD->getParent();
+  }
+  return nullptr;
+}
+
+ParsedType Sema::ActOnMSVCUnknownTypeName(const IdentifierInfo &II,
+  SourceLocation NameLoc,
+  bool IsTemplateTypeArg) {
+  assert(getLangOpts().MSVCCompat && "shouldn't be called in non-MSVC mode");
+
+  NestedNameSpecifier *NNS = nullptr;
+  if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
+// If we weren't able to parse a def

Re: [PATCH] D20574: [libcxxabi] Allow explicit pthread opt-in

2016-05-24 Thread Ben Craig via cfe-commits
bcraig marked an inline comment as done.
bcraig added a comment.

http://reviews.llvm.org/D20574



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


Re: [PATCH] D20574: [libcxxabi] Allow explicit pthread opt-in

2016-05-24 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 58317.

http://reviews.llvm.org/D20574

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -113,6 +113,7 @@
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
+option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of 
pthread API" OFF)
 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
 
@@ -271,9 +272,18 @@
 endif()
 
 if (NOT LIBCXXABI_ENABLE_THREADS)
+  if (LIBCXXABI_HAS_PTHREAD_API)
+message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
+" be set to ON when LIBCXXABI_ENABLE_THREADS"
+" is also set to ON.")
+  endif()
   add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
 endif()
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -113,6 +113,7 @@
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
+option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
 
@@ -271,9 +272,18 @@
 endif()
 
 if (NOT LIBCXXABI_ENABLE_THREADS)
+  if (LIBCXXABI_HAS_PTHREAD_API)
+message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
+" be set to ON when LIBCXXABI_ENABLE_THREADS"
+" is also set to ON.")
+  endif()
   add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
 endif()
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20563: Add load/store co-processor intrinsics

2016-05-24 Thread Ranjeet Singh via cfe-commits
rs marked an inline comment as done.
rs added a comment.

Tim thanks for reviewing this patch. I've uploaded a new one with your 
suggested change. If I don't respond to any further comments after today it'll 
be because I'm on holiday and won't be back till next week.


http://reviews.llvm.org/D20563



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


Re: [PATCH] D20500: [ms] Allow more unqualified lookup of types in dependent base classes

2016-05-24 Thread Reid Kleckner via cfe-commits
rnk updated this revision to Diff 58315.
rnk added a comment.
Herald added a subscriber: jyknight.

- nits


http://reviews.llvm.org/D20500

Files:
  include/clang-c/Index.h
  include/clang/AST/RecordLayout.h
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  include/clang/Sema/Sema.h
  lib/AST/RecordLayout.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/avxintrin.h
  lib/Headers/emmintrin.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaTemplate.cpp
  test/CodeGen/avx-builtins.c
  test/CodeGen/builtins-x86.c
  test/CodeGen/function-target-features.c
  test/CodeGen/inline-optim.cc
  test/CodeGen/ms-volatile.c
  test/CodeGen/sse2-builtins.c
  test/CodeGen/target-builtin-error-2.c
  test/CodeGenCXX/dllexport-members.cpp
  test/CodeGenCXX/dllexport.cpp
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c
  test/Driver/sparc-float.c
  test/Lexer/has_feature_type_traits.cpp
  test/Modules/Inputs/PR27739/DataInputHandler.h
  test/Modules/Inputs/PR27739/Types.h
  test/Modules/Inputs/PR27739/map
  test/Modules/Inputs/PR27739/module.modulemap
  test/Modules/pr27739.cpp
  test/OpenMP/sections_firstprivate_codegen.cpp
  test/OpenMP/single_firstprivate_codegen.cpp
  test/SemaCXX/friend.cpp
  test/SemaTemplate/ms-delayed-default-template-args.cpp
  test/SemaTemplate/ms-lookup-template-base-classes.cpp
  utils/ClangVisualizers/clang.natvis

Index: utils/ClangVisualizers/clang.natvis
===
--- utils/ClangVisualizers/clang.natvis
+++ utils/ClangVisualizers/clang.natvis
@@ -113,8 +113,11 @@
 Destructor {{~{Name,view(cpp)}()}}
   
   
-class {Name,view(cpp)}
-typename {Name,view(cpp)}
+typename
+class
+...
+
+{*this,view(TorC)} {*this,view(MaybeEllipses)}{Name,view(cpp)} 
   
   
 template{*TemplateParams} {*TemplatedDecl};
@@ -231,9 +234,14 @@
   
   
 {*(clang::QualType *)&TypeOrValue.V,view(cpp)}
-{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en} template parameter: {*(clang::QualType *)&TypeOrValue.V}
+{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en} template parameter: {*(clang::QualType *)&TypeOrValue.V}
+{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en}
 
   *(clang::QualType *)&TypeOrValue.V
+  
+Args.NumArgs
+Args.Args
+  
   
 
   
Index: test/SemaTemplate/ms-lookup-template-base-classes.cpp
===
--- test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1y -fms-compatibility -fno-spell-checking -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++1y -fms-compatibility -fno-spell-checking -fsyntax-only -verify %s
 
 
 template 
@@ -573,3 +573,33 @@
 template  decltype(h(T())) check2(); // expected-note{{candidate template ignored: substitution failure [with T = int]: no matching function for call to 'h'}}
 decltype(check2()) y; // expected-error{{no matching function for call to 'check2'}}
 }
+
+// We also allow unqualified lookup into bases in contexts where the we know the
+// undeclared identifier *must* be a type, such as a new expression or catch
+// parameter type.
+template 
+struct UseUnqualifiedTypeNames : T {
+  void foo() {
+void *P = new TheType; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+size_t x = __builtin_offsetof(TheType, f2); // expected-warning {{unqualified lookup}} expected-error {{no type}}
+try {
+} catch (TheType) { // expected-warning {{unqualified lookup}} expected-error {{no type}}
+}
+enum E : IntegerType { E0 = 42 }; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+_Atomic(TheType) a; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+  }
+  void out_of_line();
+};
+template 
+void UseUnqualifiedTypeNames::out_of_line() {
+  void *p = new TheType; // expected-warning {{unqualified lookup}} expected-error {{no type}}
+}
+struct Base {
+  typedef int IntegerType;
+  struct TheType {
+int f1, f2;
+  };
+};
+template struct UseUnqualifiedTypeNames;
+struct BadBase { };
+template struct UseUnqualifiedTypeNames; // expected-note-re 2 {{in instantiation {{.*}} requested here}}
Index: test/SemaTemplate/ms-delayed-default-template-args.cpp
===
--- test/SemaTemplate/ms-delayed-default-template-args.cpp
+++ test/SemaTemplate/ms-delayed-default-template-args.cpp
@@ -55,6 +55,15 @@
 t

Re: [PATCH] D20500: [ms] Allow more unqualified lookup of types in dependent base classes

2016-05-24 Thread Reid Kleckner via cfe-commits
rnk marked 4 inline comments as done.


Comment at: lib/Sema/SemaDecl.cpp:559-562
@@ -521,6 +558,6 @@
   }
 }
 
   return DeclSpec::TST_unspecified;
 }
 

rsmith wrote:
> Doesn't seem to be done? I can easily believe there's a good reason why we 
> want two different paths for building a recovery nested name specifier, but 
> I'd like to know what it is at least.
We should already be handling the case you are thinking of. We don't recover by 
using a dependent base in the NNS. We recover by using the class *deriving* 
from those bases in the NNS, like this:
  template 
  struct A : T, U {
void *p() { return new /*A::*/ X; } // We hallucinate the commented out 
specifier
  };

`synthesizeCurrentNestedNameSpecifier` is doing something different. It's just 
looking for the nearest parent scope that can legitimately form an NNS, which 
means global scope, namespace scope, or record scope, mainly by skipping 
function scopes. This is sort of what it looks like:
  template  struct A { ... };
  namespace ns {
  template  struct B { ... };
  }




http://reviews.llvm.org/D20500



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


Re: [PATCH] D20563: Add load/store co-processor intrinsics

2016-05-24 Thread Ranjeet Singh via cfe-commits
rs updated this revision to Diff 58314.

http://reviews.llvm.org/D20563

Files:
  include/clang/Basic/BuiltinsARM.def
  test/CodeGen/builtins-arm.c
  test/Sema/builtins-arm.c

Index: test/Sema/builtins-arm.c
===
--- test/Sema/builtins-arm.c
+++ test/Sema/builtins-arm.c
@@ -48,6 +48,38 @@
 }
 
 void test6(int a, int b, int c) {
+  __builtin_arm_ldc(1, 2, &a);
+  __builtin_arm_ldc(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
+  __builtin_arm_ldc(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
+
+  __builtin_arm_ldcl(1, 2, &a);
+  __builtin_arm_ldcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
+  __builtin_arm_ldcl(1, a, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
+
+  __builtin_arm_ldc2(1, 2, &a);
+  __builtin_arm_ldc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
+  __builtin_arm_ldc2(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
+
+  __builtin_arm_ldc2l(1, 2, &a);
+  __builtin_arm_ldc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
+  __builtin_arm_ldc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
+
+  __builtin_arm_stc(1, 2, &a);
+  __builtin_arm_stc(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
+  __builtin_arm_stc(1, a, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
+
+  __builtin_arm_stcl(1, 2, &a);
+  __builtin_arm_stcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
+  __builtin_arm_stcl(1, a, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
+
+  __builtin_arm_stc2(1, 2, &a);
+  __builtin_arm_stc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
+  __builtin_arm_stc2(1, a, &a); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
+
+  __builtin_arm_stc2l(1, 2, &a);
+  __builtin_arm_stc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
+  __builtin_arm_stc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
+
   __builtin_arm_cdp(a, 2, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
   __builtin_arm_cdp(1, a, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
   __builtin_arm_cdp(1, 2, a, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
Index: test/CodeGen/builtins-arm.c
===
--- test/CodeGen/builtins-arm.c
+++ test/CodeGen/builtins-arm.c
@@ -84,6 +84,62 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void ldc(const void *i) {
+  // CHECK: define void @ldc(i8* %i)
+  // CHECK: call void @llvm.arm.ldc(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldc(1, 2, i);
+}
+
+void ldcl(const void *i) {
+  // CHECK: define void @ldcl(i8* %i)
+  // CHECK: call void @llvm.arm.ldcl(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldcl(1, 2, i);
+}
+
+void ldc2(const void *i) {
+  // CHECK: define void @ldc2(i8* %i)
+  // CHECK: call void @llvm.arm.ldc2(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldc2(1, 2, i);
+}
+
+void ldc2l(const void *i) {
+  // CHECK: define void @ldc2l(i8* %i)
+  // CHECK: call void @llvm.arm.ldc2l(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_ldc2l(1, 2, i);
+}
+
+void stc(void *i) {
+  // CHECK: define void @stc(i8* %i)
+  // CHECK: call void @llvm.arm.stc(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stc(1, 2, i);
+}
+
+void stcl(void *i) {
+  // CHECK: define void @stcl(i8* %i)
+  // CHECK: call void @llvm.arm.stcl(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stcl(1, 2, i);
+}
+
+void stc2(void *i) {
+  // CHECK: define void @stc2(i8* %i)
+  // CHECK: call void @llvm.arm.stc2(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stc2(1, 2, i);
+}
+
+void stc2l(void *i) {
+  // CHECK: define void @stc2l(i8* %i)
+  // CHECK: call void @llvm.arm.stc2l(i32 1, i32 2, i8* %i)
+  // CHECK-NEXT: ret void
+  __builtin_arm_stc2l(1, 2, i);
+}
+
 void cdp() {
   // CHECK: define void @cdp()
   // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
Index: include/clang/Basic/BuiltinsARM.def
===
--- include/clang/Basic/BuiltinsARM.def
+++ include/clang/Basic/BuiltinsARM.def
@@ -48,6 +48,16 @@
 BUILTIN(__builtin_ar

Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-05-24 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 58313.
Prazek added a comment.
Herald added a reviewer: deadalnix.

Fixed many stuff.

Note that I won't push this patch mainly because of LLVMBool stuff and some 
other small issues. I don't think there can be done anything more for this 
check.


http://reviews.llvm.org/D19105

Files:
  include/clang-c/Documentation.h
  include/clang-c/Index.h
  include/llvm-c/Core.h
  include/llvm-c/Disassembler.h
  include/llvm-c/Object.h
  include/llvm-c/Support.h
  include/llvm-c/TargetMachine.h
  include/llvm/ADT/APInt.h
  include/llvm/Object/MachO.h
  lib/AST/Decl.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/DeclarationName.cpp
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Writer/BitWriter.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/CodeGen/SplitKit.h
  lib/ExecutionEngine/Interpreter/Execution.cpp
  lib/IR/Core.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/MC/MCContext.cpp
  lib/MC/MCDisassembler/Disassembler.cpp
  lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
  lib/Object/MachOObjectFile.cpp
  lib/Object/Object.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Support/APInt.cpp
  lib/Support/DynamicLibrary.cpp
  lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
  lib/Target/AArch64/Disassembler/AArch64ExternalSymbolizer.cpp
  lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
  lib/Target/AMDGPU/R600InstrInfo.cpp
  lib/Target/AMDGPU/SIMachineScheduler.cpp
  lib/Target/ARM/ARMBaseInstrInfo.cpp
  lib/Target/ARM/ARMBaseInstrInfo.h
  lib/Target/ARM/ARMConstantIslandPass.cpp
  lib/Target/ARM/ARMFastISel.cpp
  lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
  lib/Target/Hexagon/HexagonOptAddrMode.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp
  lib/Target/Mips/MipsConstantIslandPass.cpp
  lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
  lib/Target/TargetMachineC.cpp
  lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
  lib/Target/X86/X86FrameLowering.cpp
  lib/Transforms/IPO/MergeFunctions.cpp
  lib/Transforms/Scalar/GVN.cpp
  lib/Transforms/Scalar/LoopInstSimplify.cpp
  lib/Transforms/Scalar/LoopUnrollPass.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXComment.cpp
  tools/libclang/CXCursor.cpp
  tools/libclang/CXIndexDataConsumer.cpp
  tools/libclang/CXSourceLocation.cpp
  tools/libclang/CXType.cpp
  tools/libclang/Indexing.cpp
  tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
  tools/llvm-c-test/echo.cpp
  tools/llvm-mc/llvm-mc.cpp
  tools/llvm-nm/llvm-nm.cpp
  tools/llvm-pdbdump/llvm-pdbdump.cpp
  unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
  unittests/IR/ValueMapTest.cpp
  unittests/Support/CommandLineTest.cpp
  unittests/libclang/LibclangTest.cpp
  utils/TableGen/CTagsEmitter.cpp

Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -193,7 +193,7 @@
   "}\n";
   TestVFO T(contents);
   T.map("/path/virtual/foo.h", "/real/foo.h");
-  clang_VirtualFileOverlay_setCaseSensitivity(T.VFO, false);
+  clang_VirtualFileOverlay_setCaseSensitivity(T.VFO, 0);
 }
 
 TEST(libclang, VirtualFileOverlay_SharedPrefix) {
Index: tools/libclang/Indexing.cpp
===
--- tools/libclang/Indexing.cpp
+++ tools/libclang/Indexing.cpp
@@ -688,7 +688,7 @@
 
 extern "C" {
 
-int clang_index_isEntityObjCContainerKind(CXIdxEntityKind K) {
+bool clang_index_isEntityObjCContainerKind(CXIdxEntityKind K) {
   return CXIdxEntity_ObjCClass <= K && K <= CXIdxEntity_ObjCCategory;
 }
 
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -333,17 +333,17 @@
 TU);
 }
 
-unsigned clang_isConstQualifiedType(CXType CT) {
+bool clang_isConstQualifiedType(CXType CT) {
   QualType T = GetQualType(CT);
   return T.isLocalConstQualified();
 }
 
-unsigned clang_isVolatileQualifiedType(CXType CT) {
+bool clang_isVolatileQualifiedType(CXType CT) {
   QualType T = GetQualType(CT);
   return T.isLocalVolatileQualified();
 }
 
-unsigned clang_isRestrictQualifiedType(CXType CT) {
+bool clang_isRestrictQualifiedType(CXType CT) {
   QualType T = GetQualType(CT);
   return T.isLocalRestrictQualified();
 }
@@ -500,7 +500,7 @@
   return cxstring::createRef(s);
 }
 
-unsigned clang_equalTypes(CXType A, CXType B) {
+bool clang_equalTypes(CXType A, CXType B) {
   return A.data[0] == B.data[0] && A.data[1] == B.data[1];
 }
 
@@ 

[PATCH] D20597: Speed up check by using a recursive visitor.

2016-05-24 Thread Samuel Benzaquen via cfe-commits
sbenza created this revision.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.

Use a recursive visitor instead of forEachDescendant() matcher.
The latter requires several layers of virtual function calls for each node and
it is more expensive than the visitor.
Benchmark results show improvement of ~6% walltime in clang-tidy.

http://reviews.llvm.org/D20597

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h

Index: clang-tidy/readability/FunctionSizeCheck.h
===
--- clang-tidy/readability/FunctionSizeCheck.h
+++ clang-tidy/readability/FunctionSizeCheck.h
@@ -34,21 +34,11 @@
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-  void onEndOfTranslationUnit() override;
 
 private:
-  struct FunctionInfo {
-FunctionInfo() : Lines(0), Statements(0), Branches(0) {}
-unsigned Lines;
-unsigned Statements;
-unsigned Branches;
-  };
-
   const unsigned LineThreshold;
   const unsigned StatementThreshold;
   const unsigned BranchThreshold;
-
-  llvm::DenseMap FunctionInfos;
 };
 
 } // namespace readability
Index: clang-tidy/readability/FunctionSizeCheck.cpp
===
--- clang-tidy/readability/FunctionSizeCheck.cpp
+++ clang-tidy/readability/FunctionSizeCheck.cpp
@@ -8,14 +8,64 @@
 //===--===//
 
 #include "FunctionSizeCheck.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace readability {
 
+class FunctionASTVisitor : public RecursiveASTVisitor {
+  using Base = RecursiveASTVisitor;
+
+ public:
+  bool TraverseStmt(Stmt* Node) {
+if (!Node) return Base::TraverseStmt(Node);
+
+if (TrackedParent.back() && !isa(Node)) ++Info.Statements;
+
+switch (Node->getStmtClass()) {
+  case Stmt::IfStmtClass:
+  case Stmt::WhileStmtClass:
+  case Stmt::DoStmtClass:
+  case Stmt::CXXForRangeStmtClass:
+  case Stmt::ForStmtClass:
+  case Stmt::SwitchStmtClass:
+++Info.Branches;
+// fallthrough
+  case Stmt::CompoundStmtClass:
+TrackedParent.push_back(true);
+break;
+  default:
+TrackedParent.push_back(false);
+break;
+}
+
+Base::TraverseStmt(Node);
+
+TrackedParent.pop_back();
+return true;
+  }
+
+  bool TraverseDecl(Decl* Node) {
+TrackedParent.push_back(false);
+Base::TraverseDecl(Node);
+TrackedParent.pop_back();
+return true;
+  }
+
+  struct FunctionInfo {
+FunctionInfo() : Lines(0), Statements(0), Branches(0) {}
+unsigned Lines;
+unsigned Statements;
+unsigned Branches;
+  };
+  FunctionInfo Info;
+  std::vector TrackedParent;
+};
+
 FunctionSizeCheck::FunctionSizeCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   LineThreshold(Options.get("LineThreshold", -1U)),
@@ -29,76 +79,52 @@
 }
 
 void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  functionDecl(
-  unless(isInstantiated()),
-  forEachDescendant(
-  stmt(unless(compoundStmt()),
-   hasParent(stmt(anyOf(compoundStmt(), ifStmt(),
-anyOf(whileStmt(), doStmt(),
-  cxxForRangeStmt(), forStmt())
-  .bind("stmt"))).bind("func"),
-  this);
+  Finder->addMatcher(functionDecl(unless(isInstantiated())).bind("func"), this);
 }
 
 void FunctionSizeCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Func = Result.Nodes.getNodeAs("func");
 
-  FunctionInfo &FI = FunctionInfos[Func];
+  FunctionASTVisitor Visitor;
+  Visitor.TraverseDecl(const_cast(Func));
+  auto& FI = Visitor.Info;
+
+  if (FI.Statements == 0) return;
 
   // Count the lines including whitespace and comments. Really simple.
-  if (!FI.Lines) {
-if (const Stmt *Body = Func->getBody()) {
-  SourceManager *SM = Result.SourceManager;
-  if (SM->isWrittenInSameFile(Body->getLocStart(), Body->getLocEnd())) {
-FI.Lines = SM->getSpellingLineNumber(Body->getLocEnd()) -
-   SM->getSpellingLineNumber(Body->getLocStart());
-  }
+  if (const Stmt *Body = Func->getBody()) {
+SourceManager *SM = Result.SourceManager;
+if (SM->isWrittenInSameFile(Body->getLocStart(), Body->getLocEnd())) {
+  FI.Lines = SM->getSpellingLineNumber(Body->getLocEnd()) -
+   SM->getSpellingLineNumber(Body->getLocStart());
 }
   }
 
-  const auto *Statement = Result.Nodes.getNodeAs("stmt");
-  ++FI.Statements;
-
-  // TODO: sw

Re: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

2016-05-24 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 58309.
Prazek added a comment.

Some small bugfixes afeter running it on llvm


http://reviews.llvm.org/D18821

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/bugprone/BoolToIntegerConversionCheck.cpp
  clang-tidy/bugprone/BoolToIntegerConversionCheck.h
  clang-tidy/bugprone/BugProneModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/bugprone-bool-to-integer-conversion.cpp

Index: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
@@ -0,0 +1,200 @@
+// RUN: %check_clang_tidy %s bugprone-bool-to-integer-conversion %t
+
+const int is42Answer = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+// CHECK-FIXES: const int is42Answer = 1;{{$}}
+
+volatile int noItsNot = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicitly converting bool literal to 'int'; {{..}}
+// CHECK-FIXES: volatile int noItsNot = 0;{{$}}
+int a = 42;
+int az = a;
+
+long long ll = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting bool literal to 'long long';{{..}}
+// CHECK-FIXES: long long ll = 1;{{$}}
+
+void fun(int) {}
+#define ONE true
+
+// No fixup for macros.
+int one = ONE;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+
+void test() {
+  fun(ONE);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly converting bool{{..}}
+
+  fun(42);
+  fun(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly {{..}}
+// CHECK-FIXES: fun(1);{{$}}
+}
+
+char c = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly {{..}}
+// CHECK-FIXES: char c = 1;
+
+float f = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'float';{{..}}
+// CHECK-FIXES: float f = 0;
+
+struct Blah {
+  Blah(int blah) { }
+};
+
+const int &ref = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: const int &ref = 0;
+
+Blah bla = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: Blah bla = 1;
+
+Blah bla2 = 1;
+
+char c2 = 1;
+char c3 = '0';
+bool b = true;
+
+// Don't warn of bitfields of size 1. Unfortunately we can't just
+// change type of flag to bool, because some compilers like MSVC doesn't
+// pack bitfields of different types.
+struct BitFields {
+  BitFields() : a(true), flag(false) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: implicitly converting
+// CHECK-FIXES: BitFields() : a(1), flag(false) {}
+
+  unsigned a : 3;
+  unsigned flag : 1;
+};
+
+struct some_struct {
+  bool p;
+  int z;
+};
+
+void testBitFields() {
+  BitFields b;
+  b.flag = true;
+  b.a = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicitly converting
+// CHECK-FIXES: b.a = 1;
+
+  b.flag |= true;
+  some_struct s;
+  s.p |= true;
+  s.z |= true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly converting
+// CHECK-FIXES: s.z |= 1;
+}
+
+bool returnsBool() { return true; }
+
+void test_operators() {
+  bool p = false;
+  if (p == false) {
+
+  }
+  int z = 1;
+  if (z == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting
+// CHECK-FIXES: if (z == 1) {
+
+  }
+  bool p2 = false != p;
+
+  int z2 = z - true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting
+// CHECK-FIXES: int z2 = z - 1;
+
+  bool p3 = z + true;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: implicitly converting
+// CHECK-FIXES: bool p3 = z + 1;
+
+  if(true && p == false) {}
+  if (returnsBool() == false) {}
+}
+
+bool ok() {
+  return true;
+  {
+return false;
+  }
+  bool z;
+  return z;
+}
+
+int change_type();
+// CHECK-FIXES: bool change_type();
+
+// This function returns only bools
+int change_type() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function has return type 'int' but returns only bools [bugprone-bool-to-integer-conversion]
+  // CHECK-FIXES: bool change_type() {
+
+  bool p;
+  return p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: note: converting bool to 'int' here
+
+  return true;
+  {
+return false;
+  }
+  return ok();
+}
+
+int change_type(int);
+
+char change_type2() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function has return type 'char' but returns only bools [bugprone-bool-to-integer-conversion]
+  // CHECK-FIXES: bool change_type2() {
+
+  bool z;
+  return z;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: note: converting bool to

Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270609: [Driver] Add support for -finline-functions and /Ob2 
flags (authored by hans).

Changed prior to commit:
  http://reviews.llvm.org/D20576?vs=58302&id=58308#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20576

Files:
  cfe/trunk/include/clang/Driver/CLCompatOptions.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/inline-optim.cc
  cfe/trunk/test/Driver/cl-options.c
  cfe/trunk/test/Driver/clang_f_opts.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -741,7 +741,7 @@
 def fheinous_gnu_extensions : Flag<["-"], "fheinous-gnu-extensions">, Flags<[CC1Option]>;
 def filelist : Separate<["-"], "filelist">, Flags<[LinkerInput]>;
 def : Flag<["-"], "findirect-virtual-calls">, Alias;
-def finline_functions : Flag<["-"], "finline-functions">, Group;
+def finline_functions : Flag<["-"], "finline-functions">, Group, Flags<[CC1Option]>;
 def finline : Flag<["-"], "finline">, Group;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td
===
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td
@@ -102,6 +102,8 @@
 def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">;
 def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">,
   Alias;
+def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">,
+  Alias;
 def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias;
 def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">,
   Alias;
@@ -293,7 +295,6 @@
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
 def _SLASH_Ob1 : CLIgnoredFlag<"Ob1">;
-def _SLASH_Ob2 : CLIgnoredFlag<"Ob2">;
 def _SLASH_Og : CLIgnoredFlag<"Og">;
 def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -97,6 +97,9 @@
 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
 // Ob0: -fno-inline
 
+// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2: -finline-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -265,7 +268,6 @@
 // RUN:/kernel- \
 // RUN:/nologo \
 // RUN:/Ob1 \
-// RUN:/Ob2 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: cfe/trunk/test/Driver/clang_f_opts.c
===
--- cfe/trunk/test/Driver/clang_f_opts.c
+++ cfe/trunk/test/Driver/clang_f_opts.c
@@ -285,7 +285,6 @@
 // RUN: -fexpensive-optimizations \
 // RUN: -fno-expensive-optimizations  \
 // RUN: -fno-defer-pop\
-// RUN: -finline-functions\
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
@@ -353,7 +352,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
-// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
Index: cfe/trunk/test/CodeGen/inline-optim.cc
===
--- cfe/trunk/test/CodeGen/inline-optim.cc
+++ cfe/trunk/test/CodeGen/inline-optim.cc
@@ -0,0 +1,26 @@
+// Make sure -finline-functions family flags are behaving correctly.
+
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s
+
+inline int inline_hint(int a, int b) { return(a+b); }
+
+int inline_no

r270609 - [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May 24 15:40:51 2016
New Revision: 270609

URL: http://llvm.org/viewvc/llvm-project?rev=270609&view=rev
Log:
[Driver] Add support for -finline-functions and /Ob2 flags

-finline-functions and /Ob2 are currently ignored by Clang. The only way to
enable inlining is to use the global O flags, which also enable other options,
or to emit LLVM bitcode using Clang, then running opt by hand with the inline
pass.

This patch allows to simply use the -finline-functions flag (same as GCC) or
/Ob2 in clang-cl mode to enable inlining without other optimizations.

This is the first patch of a serie to improve support for the /Ob flags.

Patch by Rudy Pons !

Differential Revision: http://reviews.llvm.org/D20576

Added:
cfe/trunk/test/CodeGen/inline-optim.cc
Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/cl-options.c
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue May 24 15:40:51 2016
@@ -102,6 +102,8 @@ def _SLASH_O0 : CLFlag<"O0">, Alias;
 def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">;
 def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">,
   Alias;
+def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">,
+  Alias;
 def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias;
 def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">,
   Alias;
@@ -293,7 +295,6 @@ def _SLASH_GS_ : CLIgnoredFlag<"GS-">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
 def _SLASH_Ob1 : CLIgnoredFlag<"Ob1">;
-def _SLASH_Ob2 : CLIgnoredFlag<"Ob2">;
 def _SLASH_Og : CLIgnoredFlag<"Og">;
 def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 24 15:40:51 2016
@@ -741,7 +741,7 @@ def fgnu_runtime : Flag<["-"], "fgnu-run
 def fheinous_gnu_extensions : Flag<["-"], "fheinous-gnu-extensions">, 
Flags<[CC1Option]>;
 def filelist : Separate<["-"], "filelist">, Flags<[LinkerInput]>;
 def : Flag<["-"], "findirect-virtual-calls">, Alias;
-def finline_functions : Flag<["-"], "finline-functions">, 
Group;
+def finline_functions : Flag<["-"], "finline-functions">, 
Group, Flags<[CC1Option]>;
 def finline : Flag<["-"], "finline">, Group;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue May 24 15:40:51 2016
@@ -5332,8 +5332,9 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.hasArg(options::OPT_fno_inline))
 CmdArgs.push_back("-fno-inline");
 
-  if (Args.hasArg(options::OPT_fno_inline_functions))
-CmdArgs.push_back("-fno-inline-functions");
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
+   options::OPT_fno_inline_functions))
+InlineArg->render(Args, CmdArgs);
 
   ObjCRuntime objcRuntime = AddObjCRuntimeArgs(Args, CmdArgs, rewriteKind);
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=270609&r1=270608&r2=270609&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May 24 15:40:51 2016
@@ -441,8 +441,12 @@ static bool ParseCodeGenArgs(CodeGenOpti
  : CodeGenOptions::OnlyAlwaysInlining);
   // -fno-inline-functions overrides OptimizationLevel > 1.
   Opts.NoInline = Args.hasArg(OPT_fno_inline);
-  Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
- CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
+ 

Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

bcraig wrote:
> rmaprath wrote:
> > bcraig wrote:
> > > rmaprath wrote:
> > > > bcraig wrote:
> > > > > I'm not sure I like taking the freedom to define 
> > > > > _LIBCPP_MUTEX_INITIALIZER away from implementers.
> > > > > 
> > > > > Would it be too terrible to replace this entire #elif block with 
> > > > > something like the following?
> > > > > 
> > > > > ```
> > > > > #if !defined(__has_include) || __has_include()
> > > > > #include 
> > > > > #else
> > > > > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to 
> > > > > provide  in the include path"
> > > > > #endif
> > > > > ```
> > > > > 
> > > > > 
> > > > The problem is that, `std::mutex` constructor needs to be `constexpr` 
> > > > (as you pointed out earlier). And since `__libcpp_mutex_t` is a pointer 
> > > > type (for this externally threaded variant), sensible definitions for 
> > > > `_LIBCPP_MUTEX_INITIALIZER` are limited.
> > > > 
> > > > Other than `nullptr`, one may be able to define 
> > > > `_LIBCPP_MUTEX_INITIALIZER` to be a pointer to some constant mutex 
> > > > (presuming that make it `constexpr` OK?) but I'm not convinced if such 
> > > > a setup would be very useful.
> > > > 
> > > > Hope that sounds sensible?
> > > If the implementer gets to provide an entire header, then they also get 
> > > to choose what libcpp_mutex_t will be.  They could make it a struct.
> > This externally-threaded library variant needs to be compiled against a set 
> > API, so we have this header with declarations like `__libcpp_mutex_lock()` 
> > which are referred from within the library sources (same function 
> > signatures as those used in `LIBCPP_THREAD_API_PTHREAD` - this allows us to 
> > keep the library source changes to a minimum).
> > 
> > Now, in this particular library variant, we want to differ these calls to 
> > runtime rather than libcxx compile-time! 
> > 
> > On the other hand, I think you are proposing a compile-time (static) thread 
> > porting setup where the platform vendors need to supply a header file with 
> > appropriate definitions for these functions / types, and they would compile 
> > libcxx themselves? That sounds like a good idea, but the current patch is 
> > aiming for a different goal: we provide a pre-compiled libcxx library which 
> > calls out to those `__libcpp_xxx` functions at runtime, and platform 
> > vendors need to provide those functions, they don't have to compile libcxx 
> > themselves. This is what forces us to use opaque pointer types to capture 
> > platform-defined threading primitives.
> > 
> > Perhaps I could improve the naming here, may be 
> > `LIBCPP_HAS_RUNTIME_THREAD_API`? Or `LIBCPP_HAS_DYNAMIC_THREAD_API`?
> That is an excellent summary, and it does a good job of explaining the 
> disconnect we were having.  I'm going to push forward with the disconnect 
> though :)
> 
> I think you can implement the dynamic case in terms of the static case 
> without loss of generality or performance.  You ("Vendor X") could 
> pre-compile your library with a pointer-sized libcpp_mutex_t defined in 
> , and at runtime call out to a different library that 
> has an implementation of libcpp_mutex_lock.  Someone else ("Vendor Y") could 
> have a larger libcpp_mutex_t defined, and provide a static inline definition 
> of libcpp_mutex_lock.
OK, I think I understand your point :)

Will meditate on it a bit and spin a new patch tomorrow. Thanks!




http://reviews.llvm.org/D20328



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


[PATCH] D20596: [libcxx] Refactor locale switching, creation, and destruction

2016-05-24 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: mclow.lists, EricWF, joerg, jroelofs.
bcraig added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

This patch cleans up libcxx's usage of newlocale, freelocale, uselocale, and 
locale_t.

First, libcxx no longer defines the posix newlocale, freelocale, uselocale, and 
locale_t names on non-posix compliant systems.  Those names don't belong to 
libcxx, so _libcpp variants and forwarders have been created.  The renaming is 
the bulk of the diff.

Second, improved locale management RAII objects have been created and used.  
_locale_raii was a typedef for a unique_ptr with a function pointer deleter.  
That requires a fatter object and an indirect call.  Instead, a small, custom 
RAII object was added to manage the switching of locales with uselocale.  This 
also allows for a terser syntax.  An RAII object for the newlocale / freelocale 
pair was also created, as was a fancier RAII object to handle the case when we 
are handed a locale that (maybe) isn't supposed to be deleted.

The last significant change is that the nop_locale_mgmt's newlocale (used by 
newlib) will now attempt to support the "C" and "POSIX" locales, rather than 
return 0.

Tested on Linux x64, and on an embedded target that also happens to use all the 
trivial locale wrappers (like nop_locale_mgmt).

http://reviews.llvm.org/D20596

Files:
  include/__bsd_locale_fallbacks.h
  include/__locale
  include/__locale_mgmt.h
  include/__posix_locale_mgmt_defaults.h
  include/locale
  include/support/ibm/locale_mgmt_aix.h
  include/support/ibm/xlocale.h
  include/support/musl/xlocale.h
  include/support/solaris/xlocale.h
  include/support/win32/locale_mgmt_win32.h
  include/support/win32/locale_win32.h
  include/support/xlocale/__nop_locale_mgmt.h
  include/support/xlocale/__posix_l_fallback.h
  include/support/xlocale/__strtonum_fallback.h
  src/locale.cpp
  src/support/solaris/mbsnrtowcs.inc
  src/support/solaris/wcsnrtombs.inc
  src/support/solaris/xlocale.c
  src/support/win32/locale_win32.cpp

Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -12,13 +12,13 @@
 #include  // va_start, va_end
 
 // FIXME: base currently unused. Needs manual work to construct the new locale
-locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
+__libcpp_locale_t newlocale( int mask, const char * locale, __libcpp_locale_t /*base*/ )
 {
 return _create_locale( mask, locale );
 }
-locale_t uselocale( locale_t newloc )
+__libcpp_locale_t uselocale( __libcpp_locale_t newloc )
 {
-locale_t old_locale = _get_current_locale();
+__libcpp_locale_t old_locale = _get_current_locale();
 if ( newloc == NULL )
 return old_locale;
 // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
@@ -28,61 +28,61 @@
 // uselocale returns the old locale_t
 return old_locale;
 }
-lconv *localeconv_l( locale_t loc )
+lconv *localeconv_l( __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return localeconv();
 }
 size_t mbrlen_l( const char *__restrict s, size_t n,
- mbstate_t *__restrict ps, locale_t loc )
+ mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbrlen( s, n, ps );
 }
 size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
-size_t len, mbstate_t *__restrict ps, locale_t loc )
+size_t len, mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbsrtowcs( dst, src, len, ps );
 }
 size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
-  locale_t loc )
+  __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return wcrtomb( s, wc, ps );
 }
 size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
-  size_t n, mbstate_t *__restrict ps, locale_t loc )
+  size_t n, mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbrtowc( pwc, s, n, ps );
 }
 size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
- size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc )
+ size_t nms, size_t len, mbstate_t *__restrict ps, __libcpp_locale_t loc )
 {
-__locale_raii __current( uselocale(loc), uselocale );
+std::__locale_sentry __current(loc);
 return mbs

Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod added a comment.

I don't have commit access, so you can do it for me, thanks.


http://reviews.llvm.org/D20576



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me!

Do you have commit access, or would you like me to commit this for you?


http://reviews.llvm.org/D20576



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


Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-05-24 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D17462



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


Re: [PATCH] D18540: [Sema] Note when we've actually encountered a failure in ExprConstant, and take that into account when looking up objects.

2016-05-24 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D18540



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


Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod updated this revision to Diff 58302.
Ilod added a comment.

Thanks!

Updated to respect the 80-columns limit.
Updated the tests to have a clearer checks. (I don't know well the FileCheck, 
so I took example from test/CodeGen/noinline.c, but this is indeed more 
comprehensible).


http://reviews.llvm.org/D20576

Files:
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/inline-optim.c
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -285,7 +285,6 @@
 // RUN: -fexpensive-optimizations \
 // RUN: -fno-expensive-optimizations  \
 // RUN: -fno-defer-pop\
-// RUN: -finline-functions\
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
@@ -353,7 +352,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
-// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -97,6 +97,9 @@
 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
 // Ob0: -fno-inline
 
+// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2: -finline-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -265,7 +268,6 @@
 // RUN:/kernel- \
 // RUN:/nologo \
 // RUN:/Ob1 \
-// RUN:/Ob2 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: test/CodeGen/inline-optim.c
===
--- test/CodeGen/inline-optim.c
+++ test/CodeGen/inline-optim.c
@@ -0,0 +1,26 @@
+// Make sure -finline-functions family flags are behaving correctly.
+
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s
+
+inline int inline_hint(int a, int b) { return(a+b); }
+
+int inline_no_hint(int a, int b) { return (a/b); }
+
+inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { return(a*b); }
+
+volatile int *pa = (int*) 0x1000;
+void foo() {
+// NOINLINE-LABEL: @foo
+// INLINE-LABEL: @foo
+// NOINLINE: call i32 @inline_hint
+// INLINE-NOT: call i32 @inline_hint
+pa[0] = inline_hint(pa[1],pa[2]);	
+// NOINLINE-NOT: call i32 @inline_always
+// INLINE-NOT: call i32 @inline_always
+pa[3] = inline_always(pa[4],pa[5]);
+// NOINLINE: call i32 @inline_no_hint
+// INLINE-NOT: call i32 @inline_no_hint
+pa[6] = inline_no_hint(pa[7], pa[8]);
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -441,8 +441,12 @@
  : CodeGenOptions::OnlyAlwaysInlining);
   // -fno-inline-functions overrides OptimizationLevel > 1.
   Opts.NoInline = Args.hasArg(OPT_fno_inline);
-  Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
- CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
+   options::OPT_fno_inline_functions)) {
+Opts.setInlining(
+  InlineArg->getOption().matches(options::OPT_finline_functions) ?
+CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
+  }
 
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5332,8 +5332,9 @@
   if (Args.hasArg(options::OPT_fno_inline))
 CmdArgs.push_back("-fno-inline");
 
-  if (Args.hasArg(options::OPT_fno_inline_functions))
-CmdArgs.push_ba

Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

rmaprath wrote:
> bcraig wrote:
> > rmaprath wrote:
> > > bcraig wrote:
> > > > I'm not sure I like taking the freedom to define 
> > > > _LIBCPP_MUTEX_INITIALIZER away from implementers.
> > > > 
> > > > Would it be too terrible to replace this entire #elif block with 
> > > > something like the following?
> > > > 
> > > > ```
> > > > #if !defined(__has_include) || __has_include()
> > > > #include 
> > > > #else
> > > > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
> > > >  in the include path"
> > > > #endif
> > > > ```
> > > > 
> > > > 
> > > The problem is that, `std::mutex` constructor needs to be `constexpr` (as 
> > > you pointed out earlier). And since `__libcpp_mutex_t` is a pointer type 
> > > (for this externally threaded variant), sensible definitions for 
> > > `_LIBCPP_MUTEX_INITIALIZER` are limited.
> > > 
> > > Other than `nullptr`, one may be able to define 
> > > `_LIBCPP_MUTEX_INITIALIZER` to be a pointer to some constant mutex 
> > > (presuming that make it `constexpr` OK?) but I'm not convinced if such a 
> > > setup would be very useful.
> > > 
> > > Hope that sounds sensible?
> > If the implementer gets to provide an entire header, then they also get to 
> > choose what libcpp_mutex_t will be.  They could make it a struct.
> This externally-threaded library variant needs to be compiled against a set 
> API, so we have this header with declarations like `__libcpp_mutex_lock()` 
> which are referred from within the library sources (same function signatures 
> as those used in `LIBCPP_THREAD_API_PTHREAD` - this allows us to keep the 
> library source changes to a minimum).
> 
> Now, in this particular library variant, we want to differ these calls to 
> runtime rather than libcxx compile-time! 
> 
> On the other hand, I think you are proposing a compile-time (static) thread 
> porting setup where the platform vendors need to supply a header file with 
> appropriate definitions for these functions / types, and they would compile 
> libcxx themselves? That sounds like a good idea, but the current patch is 
> aiming for a different goal: we provide a pre-compiled libcxx library which 
> calls out to those `__libcpp_xxx` functions at runtime, and platform vendors 
> need to provide those functions, they don't have to compile libcxx 
> themselves. This is what forces us to use opaque pointer types to capture 
> platform-defined threading primitives.
> 
> Perhaps I could improve the naming here, may be 
> `LIBCPP_HAS_RUNTIME_THREAD_API`? Or `LIBCPP_HAS_DYNAMIC_THREAD_API`?
That is an excellent summary, and it does a good job of explaining the 
disconnect we were having.  I'm going to push forward with the disconnect 
though :)

I think you can implement the dynamic case in terms of the static case without 
loss of generality or performance.  You ("Vendor X") could pre-compile your 
library with a pointer-sized libcpp_mutex_t defined in , 
and at runtime call out to a different library that has an implementation of 
libcpp_mutex_lock.  Someone else ("Vendor Y") could have a larger 
libcpp_mutex_t defined, and provide a static inline definition of 
libcpp_mutex_lock.


http://reviews.llvm.org/D20328



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


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a module

2016-05-24 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 58297.
yaxunl added a comment.

Fix regressions in unit test due to ConstructJob disables builtin include path.


http://reviews.llvm.org/D20444

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CompilerInvocation.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/module.modulemap
  test/CodeGenOpenCL/bool_cast.cl
  test/Headers/opencl-c-header.cl
  test/Parser/opencl-atomics-cl20.cl
  unittests/AST/MatchVerifier.h

Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -114,6 +114,10 @@
 FileName = "input.cc";
 break;
   case Lang_OpenCL:
+// ConstructJob disables builtin include path which is required by OpenCL
+// default header file, therefore default header needs to be disabled.
+Args.push_back("-Xclang");
+Args.push_back("-fno-default-header");
 FileName = "input.cl";
 break;
   case Lang_OBJCXX:
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// ToDo: a bug causing cached AST of header containing typedef of atomic_int for CL1.0. After the bug is fixed
+// -fno-default-header should be removed.
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -fno-default-header
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
 
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -1,9 +1,14 @@
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
 
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -verify -fno-default-header -DNO_HEADER %s
 // CHECK: _Z16convert_char_rtec
 char f(char x) {
   return convert_char_rte(x);
+#ifdef NO_HEADER
+  //expected-warning@-2{{implicit declaration of function 'convert_char_rte' is invalid in C99}}
+#endif
 }
Index: test/CodeGenOpenCL/bool_cast.cl
===
--- test/CodeGenOpenCL/bool_cast.cl
+++ test/CodeGenOpenCL/bool_cast.cl
@@ -1,9 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
 
-typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
-typedef unsigned int int4 __attribute((ext_vector_type(4)));
-typedef float float4 __attribute((ext_vector_type(4)));
-
 // CHECK-LABEL: define void @ker()
 void kernel ker() {
   bool t = true;
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -155,6 +155,11 @@
   header "vecintrin.h"
 }
   }
+  
+  explicit module opencl_c {
+requires opencl
+header "opencl-c.h"
+  }
 }
 
 module _Builtin_stddef_max_align_t [system] [extern_c] {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1400,6 +1400,7 @@
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
  const llvm::Triple &T,
+ PreprocessorOptions &PPOpts,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be nice
   // to move these to the language standard, and have the driver resolve the
@@ -1481,6 +1482,12 @@
 Opts.DefaultFPCon

Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

bcraig wrote:
> rmaprath wrote:
> > bcraig wrote:
> > > I'm not sure I like taking the freedom to define 
> > > _LIBCPP_MUTEX_INITIALIZER away from implementers.
> > > 
> > > Would it be too terrible to replace this entire #elif block with 
> > > something like the following?
> > > 
> > > ```
> > > #if !defined(__has_include) || __has_include()
> > > #include 
> > > #else
> > > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
> > >  in the include path"
> > > #endif
> > > ```
> > > 
> > > 
> > The problem is that, `std::mutex` constructor needs to be `constexpr` (as 
> > you pointed out earlier). And since `__libcpp_mutex_t` is a pointer type 
> > (for this externally threaded variant), sensible definitions for 
> > `_LIBCPP_MUTEX_INITIALIZER` are limited.
> > 
> > Other than `nullptr`, one may be able to define `_LIBCPP_MUTEX_INITIALIZER` 
> > to be a pointer to some constant mutex (presuming that make it `constexpr` 
> > OK?) but I'm not convinced if such a setup would be very useful.
> > 
> > Hope that sounds sensible?
> If the implementer gets to provide an entire header, then they also get to 
> choose what libcpp_mutex_t will be.  They could make it a struct.
This externally-threaded library variant needs to be compiled against a set 
API, so we have this header with declarations like `__libcpp_mutex_lock()` 
which are referred from within the library sources (same function signatures as 
those used in `LIBCPP_THREAD_API_PTHREAD` - this allows us to keep the library 
source changes to a minimum).

Now, in this particular library variant, we want to differ these calls to 
runtime rather than libcxx compile-time! 

On the other hand, I think you are proposing a compile-time (static) thread 
porting setup where the platform vendors need to supply a header file with 
appropriate definitions for these functions / types, and they would compile 
libcxx themselves? That sounds like a good idea, but the current patch is 
aiming for a different goal: we provide a pre-compiled libcxx library which 
calls out to those `__libcpp_xxx` functions at runtime, and platform vendors 
need to provide those functions, they don't have to compile libcxx themselves. 
This is what forces us to use opaque pointer types to capture platform-defined 
threading primitives.

Perhaps I could improve the naming here, may be 
`LIBCPP_HAS_RUNTIME_THREAD_API`? Or `LIBCPP_HAS_DYNAMIC_THREAD_API`?


http://reviews.llvm.org/D20328



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


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-05-24 Thread Jan Vesely via cfe-commits
jvesely added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

Anastasia wrote:
> jvesely wrote:
> > Anastasia wrote:
> > > Could you use standard diagnostic check please:
> > >   expected-warning{{unknown OpenCL extension ...
> > > 
> > > Similarly to SemaOpenCL/extensions.cl
> > not sure I follow, the test does not trigger any diagnostics (by design).
> > are you saying that I should introduce negative checks to make sure 
> > extensions are not available outside of their respective context?
> > Is there a way to filter verifier tags based on clang invocation? 
> > (something like FileCheck prefix)
> Exactly, you should check that the extensions are enabled correctly based on 
> CL versions.
> 
> For example if you compile this without passing -cl-std=CL1.2:
>   #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable
> the following error is produced:
>   unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring
> 
> You can condition error directives on CL version passed as it's done in the 
> example test SemaOpenCL/extensions.cl.
> 
> So what is the original intension of this tests? Not sure I understand what 
> you are trying to test.
it's a positive test that checks that extensions are available (both that the 
define is present, and that #pragma passes without error).

I did not include negative tests (check that extension is not available outside 
of its respective context), because I think it's a bit overzealous reading of 
the specs.
For example cl_khr_d3d10_sharing is first mentioned in OpenCL 1.1 specs, but 
the text of the extension says that it is written against OpenCL 1.0.48 spec. 
(I moved cl_khr_icd to 1.0 for the same reason). I think if a vendor can add 
vendor specific extensions to the list of supported extensions, it should be 
possible to add extensions from higher CL versions.

similarly, I would argue against warnings for extensions promoted to core 
features (or at least hide the warning behind -pedantic). they are listed in 
CL_DEVICE_EXTENSIONS for backwards compatibility so I'd say it is OK to allow 
pragmas in higher CLC versions for backward compatibility.


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

rmaprath wrote:
> bcraig wrote:
> > I'm not sure I like taking the freedom to define _LIBCPP_MUTEX_INITIALIZER 
> > away from implementers.
> > 
> > Would it be too terrible to replace this entire #elif block with something 
> > like the following?
> > 
> > ```
> > #if !defined(__has_include) || __has_include()
> > #include 
> > #else
> > #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
> >  in the include path"
> > #endif
> > ```
> > 
> > 
> The problem is that, `std::mutex` constructor needs to be `constexpr` (as you 
> pointed out earlier). And since `__libcpp_mutex_t` is a pointer type (for 
> this externally threaded variant), sensible definitions for 
> `_LIBCPP_MUTEX_INITIALIZER` are limited.
> 
> Other than `nullptr`, one may be able to define `_LIBCPP_MUTEX_INITIALIZER` 
> to be a pointer to some constant mutex (presuming that make it `constexpr` 
> OK?) but I'm not convinced if such a setup would be very useful.
> 
> Hope that sounds sensible?
If the implementer gets to provide an entire header, then they also get to 
choose what libcpp_mutex_t will be.  They could make it a struct.


http://reviews.llvm.org/D20328



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


Re: [PATCH] D20537: clang-rename: fix renaming non-members variables when referenced as macro arguments

2016-05-24 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270599: clang-rename: fix renaming non-members variables 
when referenced as macro… (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20537?vs=58136&id=58290#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20537

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp

Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
+++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  static int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C::X = 1; // CHECK: C::Y
+  FOO(C::X); // CHECK: C::Y
+  int y = C::X; // CHECK: C::Y
+}
+
+// Use grep -FUbo 'X'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -94,7 +94,9 @@
 
 checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getLocation());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
+  LocationsFound.push_back(Location);
 }
 
 return true;


Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
+++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  static int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C::X = 1; // CHECK: C::Y
+  FOO(C::X); // CHECK: C::Y
+  int y = C::X; // CHECK: C::Y
+}
+
+// Use grep -FUbo 'X'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -94,7 +94,9 @@
 
 checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getLocation());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
+  LocationsFound.push_back(Location);
 }
 
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r270599 - clang-rename: fix renaming non-members variables when referenced as macro arguments

2016-05-24 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue May 24 14:08:53 2016
New Revision: 270599

URL: http://llvm.org/viewvc/llvm-project?rev=270599&view=rev
Log:
clang-rename: fix renaming non-members variables when referenced as macro 
arguments

The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y).

Reviewers: klimek

Differential Revision: http://reviews.llvm.org/D20537

Added:
clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=270599&r1=270598&r2=270599&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Tue May 24 14:08:53 
2016
@@ -94,7 +94,9 @@ public:
 
 checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getLocation());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
+  LocationsFound.push_back(Location);
 }
 
 return true;

Added: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp?rev=270599&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp Tue May 24 
14:08:53 2016
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  static int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C::X = 1; // CHECK: C::Y
+  FOO(C::X); // CHECK: C::Y
+  int y = C::X; // CHECK: C::Y
+}
+
+// Use grep -FUbo 'X'  to get the correct offset of foo when changing
+// this file.


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


RE: r267590 - [OpenCL] Add predefined macros.

2016-05-24 Thread Liu, Yaxun (Sam) via cfe-commits
Did clang accept -std=CL2.0 before this change?

According to this diff, the only accepted option for -std= is c99 when 
compiling OpenCL programs.

Sam

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com] 
Sent: Tuesday, May 24, 2016 2:48 PM
To: Liu, Yaxun (Sam) ; cfe-commits@lists.llvm.org
Cc: nd 
Subject: RE: r267590 - [OpenCL] Add predefined macros.

Hi Sam,

I think this commit broke Clang.

It seems we are no longer able to pass the -std=CL2.0, which is important for 
the standalone Clang OpenCL users as -cl-std is frontend only option.
 
clang  -std=CL2.0 test.cl
error: invalid argument '-std=CL2.0' not allowed with 'OpenCL'

We might have to revert or rework this bit:

--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Do you think you could look into this?

Thanks,
Anastasia

-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Yaxun Liu via cfe-commits
Sent: 26 April 2016 20:26
To: cfe-commits@lists.llvm.org
Subject: r267590 - [OpenCL] Add predefined macros.

Author: yaxunl
Date: Tue Apr 26 14:25:46 2016
New Revision: 267590

URL: http://llvm.org/viewvc/llvm-project?rev=267590&view=rev
Log:
[OpenCL] Add predefined macros.

OpenCL spec requires __OPENCL_C_VERSION__ to be defined based on -cl-std 
option. This patch implements that.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math 
option.

Also fixed a test using -std=c99 for OpenCL program. Limit allowed language 
standard of OpenCL to be OpenCL standards.

Differential Revision: http://reviews.llvm.org/D19071

Removed:
cfe/trunk/test/Frontend/std.cl
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Frontend/stdlang.c
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Apr 26 14:25:46 2016
@@ -408,6 +408,39 @@ static void InitializeStandardPredefined
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+Builder.defineMacro("CL_VERSION_1_1", "110");
+Build

RE: r267590 - [OpenCL] Add predefined macros.

2016-05-24 Thread Anastasia Stulova via cfe-commits
Hi Sam,

I think this commit broke Clang.

It seems we are no longer able to pass the -std=CL2.0, which is important for 
the standalone Clang OpenCL users as -cl-std is frontend only option.
 
clang  -std=CL2.0 test.cl
error: invalid argument '-std=CL2.0' not allowed with 'OpenCL'

We might have to revert or rework this bit:

--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46 
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Do you think you could look into this?

Thanks,
Anastasia

-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Yaxun Liu via cfe-commits
Sent: 26 April 2016 20:26
To: cfe-commits@lists.llvm.org
Subject: r267590 - [OpenCL] Add predefined macros.

Author: yaxunl
Date: Tue Apr 26 14:25:46 2016
New Revision: 267590

URL: http://llvm.org/viewvc/llvm-project?rev=267590&view=rev
Log:
[OpenCL] Add predefined macros.

OpenCL spec requires __OPENCL_C_VERSION__ to be defined based on -cl-std 
option. This patch implements that.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math 
option.

Also fixed a test using -std=c99 for OpenCL program. Limit allowed language 
standard of OpenCL to be OpenCL standards.

Differential Revision: http://reviews.llvm.org/D19071

Removed:
cfe/trunk/test/Frontend/std.cl
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Frontend/stdlang.c
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46 
+++ 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions &O
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=267590&r1=267589&r2=267590&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Apr 26 14:25:46 2016
@@ -408,6 +408,39 @@ static void InitializeStandardPredefined
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+Builder.defineMacro("CL_VERSION_1_1", "110");
+Builder.defineMacro("CL_VERSION_1_2", "120");
+Builder.defineMacro("CL_VERSION_2_0", "200");
+
+if (LangOpts.FastRelaxedMath)
+  Builder.defineMacro("__FAST_RELAXED_MATH__");
+  }
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");

Removed: cfe/trunk/test/Frontend/std.cl
URL: 
http://ll

Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Manman Ren via cfe-commits

> On May 24, 2016, at 11:42 AM, Bob Wilson  wrote:
> 
>> 
>> On May 24, 2016, at 11:21 AM, Manman  wrote:
>> 
>> 
>>> On May 23, 2016, at 8:15 PM, Bob Wilson  wrote:
>>> 
>>> Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
>>> Objective-C properties marked with the IBOutlet attribute. Those properties 
>>> are supposed to be weak but they are only accessed from the main thread so 
>>> there is no risk of asynchronous updates setting them to nil. That 
>>> combination makes -Warc-repeated-use-of-weak very noisy. The previous 
>>> change only handled one kind of access to weak IBOutlet properties. Instead 
>>> of trying to add checks for all the different kinds of property accesses, 
>>> this patch removes the previous special case check and adds a check at the 
>>> point where the diagnostic is reported.
>> 
>> The approach looks good to me in general. 
>>> diff --git lib/Sema/AnalysisBasedWarnings.cpp 
>>> lib/Sema/AnalysisBasedWarnings.cpp
>>> index 3f2c41b..eb45315 100644
>>> --- lib/Sema/AnalysisBasedWarnings.cpp
>>> +++ lib/Sema/AnalysisBasedWarnings.cpp
>>> @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
>>>else
>>>  llvm_unreachable("Unexpected weak object kind!");
>>> 
>>> +// Do not warn about IBOutlet weak property receivers being set to null
>>> +// since they are typically only used from the main thread.
>>> +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
>>> +  if (Prop->hasAttr())
>>> +continue;
>>> +
>>>// Show the first time the object was read.
>>>S.Diag(FirstRead->getLocStart(), DiagKind)
>>>  << int(ObjectKind) << D << int(FunctionKind)
>> 
>> Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking 
>> the decl inside a loop in diagnoseRepeatedUseOfWeak?
>> 
>> if (S.getLangOpts().ObjCWeak &&
>> !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
>>   diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
>> —> check IBOutlet here?
> 
> diagnoseRepeatedUseOfWeak is used to report all of the issues within a 
> function. Some of those may involve IBOutlet properties and others not. We 
> have to check each one separately.
> 
> Your comment prompted me to look more closely and I realized that the code is 
> confusing because there is a local variable “D” that shadows the “const Decl 
> *D” argument of diagnoseRepeatedUseOfWeak:
> 
>const NamedDecl *D = Key.getProperty();
> 
> We should rename that to avoid potential confusion. I can do that as a 
> follow-up change.

Yes, I missed the local variable “D”.

> 
>> 
>>> diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
>>> index 62c823b..c93d800 100644
>>> --- lib/Sema/SemaPseudoObject.cpp
>>> +++ lib/Sema/SemaPseudoObject.cpp
>>> @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
>>>  if (RefExpr->isExplicitProperty()) {
>>>const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
>>>if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
>>> -  return !Prop->hasAttr();
>>> +  return true;
>>> 
>>>T = Prop->getType();
>>>  } else if (Getter) {
>> 
>> I wonder if this change is necessary to make the testing case pass, or is it 
>> introduced for clarity, to better reflect the function name isWeakProperty?
> 
> This is the one special-case check that was introduced by r211132. I removed 
> it because there is no need for it after we add the check in 
> diagnoseRepeatedUseOfWeak.

Thanks for the explanation!

Patch looks good to me,
Manman

> 
>> 
>> Thanks,
>> Manman
>> 
>>> rdar://problem/21366461 
>>> 
>>> 

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


Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Bob Wilson via cfe-commits

> On May 24, 2016, at 11:21 AM, Manman  wrote:
> 
> 
>> On May 23, 2016, at 8:15 PM, Bob Wilson  wrote:
>> 
>> Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
>> Objective-C properties marked with the IBOutlet attribute. Those properties 
>> are supposed to be weak but they are only accessed from the main thread so 
>> there is no risk of asynchronous updates setting them to nil. That 
>> combination makes -Warc-repeated-use-of-weak very noisy. The previous change 
>> only handled one kind of access to weak IBOutlet properties. Instead of 
>> trying to add checks for all the different kinds of property accesses, this 
>> patch removes the previous special case check and adds a check at the point 
>> where the diagnostic is reported.
> 
> The approach looks good to me in general. 
>> diff --git lib/Sema/AnalysisBasedWarnings.cpp 
>> lib/Sema/AnalysisBasedWarnings.cpp
>> index 3f2c41b..eb45315 100644
>> --- lib/Sema/AnalysisBasedWarnings.cpp
>> +++ lib/Sema/AnalysisBasedWarnings.cpp
>> @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
>> else
>>   llvm_unreachable("Unexpected weak object kind!");
>> 
>> +// Do not warn about IBOutlet weak property receivers being set to null
>> +// since they are typically only used from the main thread.
>> +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
>> +  if (Prop->hasAttr())
>> +continue;
>> +
>> // Show the first time the object was read.
>> S.Diag(FirstRead->getLocStart(), DiagKind)
>>   << int(ObjectKind) << D << int(FunctionKind)
> 
> Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking 
> the decl inside a loop in diagnoseRepeatedUseOfWeak?
> 
>  if (S.getLangOpts().ObjCWeak &&
>  !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
>diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
> —> check IBOutlet here?

diagnoseRepeatedUseOfWeak is used to report all of the issues within a 
function. Some of those may involve IBOutlet properties and others not. We have 
to check each one separately.

Your comment prompted me to look more closely and I realized that the code is 
confusing because there is a local variable “D” that shadows the “const Decl 
*D” argument of diagnoseRepeatedUseOfWeak:

const NamedDecl *D = Key.getProperty();

We should rename that to avoid potential confusion. I can do that as a 
follow-up change.

> 
>> diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
>> index 62c823b..c93d800 100644
>> --- lib/Sema/SemaPseudoObject.cpp
>> +++ lib/Sema/SemaPseudoObject.cpp
>> @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
>>   if (RefExpr->isExplicitProperty()) {
>> const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
>> if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
>> -  return !Prop->hasAttr();
>> +  return true;
>> 
>> T = Prop->getType();
>>   } else if (Getter) {
> 
> I wonder if this change is necessary to make the testing case pass, or is it 
> introduced for clarity, to better reflect the function name isWeakProperty?

This is the one special-case check that was introduced by r211132. I removed it 
because there is no need for it after we add the check in 
diagnoseRepeatedUseOfWeak.

> 
> Thanks,
> Manman
> 
>> rdar://problem/21366461
>> 
>> 
> 

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


Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

bcraig wrote:
> I'm not sure I like taking the freedom to define _LIBCPP_MUTEX_INITIALIZER 
> away from implementers.
> 
> Would it be too terrible to replace this entire #elif block with something 
> like the following?
> 
> ```
> #if !defined(__has_include) || __has_include()
> #include 
> #else
> #error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
>  in the include path"
> #endif
> ```
> 
> 
The problem is that, `std::mutex` constructor needs to be `constexpr` (as you 
pointed out earlier). And since `__libcpp_mutex_t` is a pointer type (for this 
externally threaded variant), sensible definitions for 
`_LIBCPP_MUTEX_INITIALIZER` are limited.

Other than `nullptr`, one may be able to define `_LIBCPP_MUTEX_INITIALIZER` to 
be a pointer to some constant mutex (presuming that make it `constexpr` OK?) 
but I'm not convinced if such a setup would be very useful.

Hope that sounds sensible?


http://reviews.llvm.org/D20328



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


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

jvesely wrote:
> Anastasia wrote:
> > Could you use standard diagnostic check please:
> >   expected-warning{{unknown OpenCL extension ...
> > 
> > Similarly to SemaOpenCL/extensions.cl
> not sure I follow, the test does not trigger any diagnostics (by design).
> are you saying that I should introduce negative checks to make sure 
> extensions are not available outside of their respective context?
> Is there a way to filter verifier tags based on clang invocation? (something 
> like FileCheck prefix)
Exactly, you should check that the extensions are enabled correctly based on CL 
versions.

For example if you compile this without passing -cl-std=CL1.2:
  #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable
the following error is produced:
  unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring

You can condition error directives on CL version passed as it's done in the 
example test SemaOpenCL/extensions.cl.

So what is the original intension of this tests? Not sure I understand what you 
are trying to test.


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [PATCH] D20574: [libcxxabi] Allow explicit pthread opt-in

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: CMakeLists.txt:278
@@ -277,1 +277,3 @@
 
+if (LIBCXXABI_HAS_PTHREAD_API)
+  add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)

Shouldn't there be an `option()` line for this new build option? Also a check 
for compatibility with the `LIBCXXABI_ENABLE_THREADS` option?


http://reviews.llvm.org/D20574



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


Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-05-24 Thread Edoardo P. via cfe-commits
Ping,

who's going to merge? I have no commit access.

Cheers,
Edward-san


2016-05-20 18:34 GMT+02:00 Tom Stellard :
> Hi,
>
> This looks fine to me, go ahead and merge.
>
> -Tom
>
> On Thu, May 19, 2016 at 08:29:14PM +0200, Alexander Kornienko wrote:
>> On Thu, May 19, 2016 at 4:45 PM, Hans Wennborg  wrote:
>>
>> > +Tom who manages 3.8.1
>> > +Alex who's owner of clang-tidy: is this ok for 3.8.1?
>> >
>>
>> Yes, would be nice to have this in 3.8.1. This fixes a rather annoying
>> problem.
>>
>>
>> >
>> > On Thu, May 19, 2016 at 1:56 AM, Edoardo P. via cfe-commits
>> >  wrote:
>> > > Is it possible to port this commit to 3.8.1?
>> > >
>> > > Cheers,
>> > > Edward-san
>> > >
>> > > 2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
>> > > :
>> > >> Author: hokein
>> > >> Date: Fri Feb 26 03:19:33 2016
>> > >> New Revision: 261991
>> > >>
>> > >> URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
>> > >> Log:
>> > >> [clang-tidy] Fix a crash issue when clang-tidy runs with compilation
>> > database.
>> > >>
>> > >> Summary:
>> > >> The clang-tidy will trigger an assertion if it's not in the building
>> > directory.
>> > >>
>> > >> TEST:
>> > >> cd /
>> > >> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build
>> > tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
>> > >>
>> > >> The crash issue is gone after applying this patch.
>> > >>
>> > >> Fixes PR24834, PR26241
>> > >>
>> > >> Reviewers: bkramer, alexfh
>> > >>
>> > >> Subscribers: rizsotto.mailinglist, cfe-commits
>> > >>
>> > >> Differential Revision: http://reviews.llvm.org/D17335
>> > >>
>> > >> Added:
>> > >> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
>> > >>
>> >  
>> > clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
>> > >>
>> >  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
>> > >> Modified:
>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
>> > >>
>> > >> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
>> > >> URL:
>> > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
>> > >>
>> > ==
>> > >> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
>> > >> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26
>> > 03:19:33 2016
>> > >> @@ -107,6 +107,10 @@ public:
>> > >>  DiagPrinter->BeginSourceFile(LangOpts);
>> > >>}
>> > >>
>> > >> +  SourceManager& getSourceManager() {
>> > >> +return SourceMgr;
>> > >> +  }
>> > >> +
>> > >>void reportDiagnostic(const ClangTidyError &Error) {
>> > >>  const ClangTidyMessage &Message = Error.Message;
>> > >>  SourceLocation Loc = getLocation(Message.FilePath,
>> > Message.FileOffset);
>> > >> @@ -124,7 +128,10 @@ public:
>> > >>auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0
>> > [%1]"))
>> > >><< Message.Message << Name;
>> > >>for (const tooling::Replacement &Fix : Error.Fix) {
>> > >> -SourceLocation FixLoc = getLocation(Fix.getFilePath(),
>> > Fix.getOffset());
>> > >> +SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
>> > >> +Files.makeAbsolutePath(FixAbsoluteFilePath);
>> > >> +SourceLocation FixLoc =
>> > >> +getLocation(FixAbsoluteFilePath, Fix.getOffset());
>> > >>  SourceLocation FixEndLoc =
>> > FixLoc.getLocWithOffset(Fix.getLength());
>> > >>  Diag << FixItHint::CreateReplacement(SourceRange(FixLoc,
>> > FixEndLoc),
>> > >>   Fix.getReplacementText());
>> > >> @@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
>> > >>Context.setCurrentFile(File);
>> > >>Context.setASTContext(&Compiler.getASTContext());
>> > >>
>> > >> +  auto WorkingDir = Compiler.getSourceManager()
>> > >> +.getFileManager()
>> > >> +.getVirtualFileSystem()
>> > >> +->getCurrentWorkingDirectory();
>> > >> +  if (WorkingDir)
>> > >> +Context.setCurrentBuildDirectory(WorkingDir.get());
>> > >> +
>> > >>std::vector> Checks;
>> > >>CheckFactories->createChecks(&Context, Checks);
>> > >>
>> > >> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr> > >>  void handleErrors(const std::vector &Errors, bool Fix,
>> > >>unsigned &WarningsAsErrorsCount) {
>> > >>ErrorReporter Reporter(Fix);
>> > >> -  for (const ClangTidyError &Error : Errors)
>> > >> +  vfs::FileSystem &FileSystem =
>> > >> +
>> > *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
>> > >> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
>> > >> +  if (!InitialWorkingD

Re: [PATCH] D20573: [libcxx] Allow explicit pthread opt-in

2016-05-24 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Couple of minor comments. LGTM otherwise.

/ Asiri



Comment at: CMakeLists.txt:387
@@ -386,2 +386,3 @@
 
+config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)

I think we should put in a check to make sure that `LIBCXX_HAS_PTHREAD_API` is 
only enabled when `LIBCXX_ENABLE_THREADS` is also enabled.


Comment at: include/__config:816
@@ -815,3 +815,3 @@
 // Thread API
-#ifndef _LIBCPP_HAS_NO_THREADS
+#if !defined(_LIBCPP_HAS_NO_THREADS) && 
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \

Similarly here. For example, there is a similar check for 
`_LIBCPP_HAS_NO_MONOTONIC_CLOCK` compatibility with the `LIBCXX_ENABLE_THREADS` 
flag.


http://reviews.llvm.org/D20573



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


Re: [PATCH] arc-repeated-use-of-weak should not warn about IBOutlet properties

2016-05-24 Thread Manman via cfe-commits

> On May 23, 2016, at 8:15 PM, Bob Wilson  wrote:
> 
> Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for 
> Objective-C properties marked with the IBOutlet attribute. Those properties 
> are supposed to be weak but they are only accessed from the main thread so 
> there is no risk of asynchronous updates setting them to nil. That 
> combination makes -Warc-repeated-use-of-weak very noisy. The previous change 
> only handled one kind of access to weak IBOutlet properties. Instead of 
> trying to add checks for all the different kinds of property accesses, this 
> patch removes the previous special case check and adds a check at the point 
> where the diagnostic is reported.

The approach looks good to me in general. 
> diff --git lib/Sema/AnalysisBasedWarnings.cpp 
> lib/Sema/AnalysisBasedWarnings.cpp
> index 3f2c41b..eb45315 100644
> --- lib/Sema/AnalysisBasedWarnings.cpp
> +++ lib/Sema/AnalysisBasedWarnings.cpp
> @@ -1334,6 +1334,12 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
>  else
>llvm_unreachable("Unexpected weak object kind!");
>  
> +// Do not warn about IBOutlet weak property receivers being set to null
> +// since they are typically only used from the main thread.
> +if (const ObjCPropertyDecl *Prop = dyn_cast(D))
> +  if (Prop->hasAttr())
> +continue;
> +
>  // Show the first time the object was read.
>  S.Diag(FirstRead->getLocStart(), DiagKind)
><< int(ObjectKind) << D << int(FunctionKind)

Should we guard the call to diagnoseRepeatedUseOfWeak, instead of checking the 
decl inside a loop in diagnoseRepeatedUseOfWeak?

  if (S.getLangOpts().ObjCWeak &&
  !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getLocStart()))
diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());
—> check IBOutlet here?

> diff --git lib/Sema/SemaPseudoObject.cpp lib/Sema/SemaPseudoObject.cpp
> index 62c823b..c93d800 100644
> --- lib/Sema/SemaPseudoObject.cpp
> +++ lib/Sema/SemaPseudoObject.cpp
> @@ -578,7 +578,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
>if (RefExpr->isExplicitProperty()) {
>  const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
>  if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
> -  return !Prop->hasAttr();
> +  return true;
>  
>  T = Prop->getType();
>} else if (Getter) {

I wonder if this change is necessary to make the testing case pass, or is it 
introduced for clarity, to better reflect the function name isWeakProperty?

Thanks,
Manman

> rdar://problem/21366461
> 
> 

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


Re: [PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-24 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

My understanding is that typically std::ends is explicitly appended to 
null-terminate the stream buffer. The test case in the example does that.

http://en.cppreference.com/w/cpp/io/ostrstream/str


http://reviews.llvm.org/D20334



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


r270591 - [RecordLayout] Use an ASTVector instead of using a separate pointer and counter

2016-05-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue May 24 13:10:50 2016
New Revision: 270591

URL: http://llvm.org/viewvc/llvm-project?rev=270591&view=rev
Log:
[RecordLayout] Use an ASTVector instead of using a separate pointer and counter

No functional change is intended.

Modified:
cfe/trunk/include/clang/AST/RecordLayout.h
cfe/trunk/lib/AST/RecordLayout.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=270591&r1=270590&r2=270591&view=diff
==
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Tue May 24 13:10:50 2016
@@ -71,10 +71,7 @@ private:
   CharUnits RequiredAlignment;
 
   /// FieldOffsets - Array of field offsets in bits.
-  uint64_t *FieldOffsets;
-
-  // FieldCount - Number of fields.
-  unsigned FieldCount;
+  ASTVector FieldOffsets;
 
   /// CXXRecordLayoutInfo - Contains C++ specific layout information.
   struct CXXRecordLayoutInfo {
@@ -136,9 +133,8 @@ private:
   friend class ASTContext;
 
   ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment,
-  CharUnits requiredAlignment,
-  CharUnits datasize, const uint64_t *fieldoffsets,
-  unsigned fieldcount);
+  CharUnits requiredAlignment, CharUnits datasize,
+  ArrayRef fieldoffsets);
 
   // Constructor for C++ records.
   typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
@@ -148,7 +144,7 @@ private:
   bool hasOwnVFPtr, bool hasExtendableVFPtr,
   CharUnits vbptroffset,
   CharUnits datasize,
-  const uint64_t *fieldoffsets, unsigned fieldcount,
+  ArrayRef fieldoffsets,
   CharUnits nonvirtualsize, CharUnits nonvirtualalignment,
   CharUnits SizeOfLargestEmptySubobject,
   const CXXRecordDecl *PrimaryBase,
@@ -174,12 +170,11 @@ public:
   CharUnits getSize() const { return Size; }
 
   /// getFieldCount - Get the number of fields in the layout.
-  unsigned getFieldCount() const { return FieldCount; }
+  unsigned getFieldCount() const { return FieldOffsets.size(); }
 
   /// getFieldOffset - Get the offset of the given field index, in
   /// bits.
   uint64_t getFieldOffset(unsigned FieldNo) const {
-assert (FieldNo < FieldCount && "Invalid Field No");
 return FieldOffsets[FieldNo];
   }
 

Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=270591&r1=270590&r2=270591&view=diff
==
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Tue May 24 13:10:50 2016
@@ -18,8 +18,6 @@
 using namespace clang;
 
 void ASTRecordLayout::Destroy(ASTContext &Ctx) {
-  if (FieldOffsets)
-Ctx.Deallocate(FieldOffsets);
   if (CXXInfo) {
 CXXInfo->~CXXRecordLayoutInfo();
 Ctx.Deallocate(CXXInfo);
@@ -29,18 +27,13 @@ void ASTRecordLayout::Destroy(ASTContext
 }
 
 ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
- CharUnits alignment, 
+ CharUnits alignment,
  CharUnits requiredAlignment,
  CharUnits datasize,
- const uint64_t *fieldoffsets,
- unsigned fieldcount)
-  : Size(size), DataSize(datasize), Alignment(alignment),
-RequiredAlignment(requiredAlignment), FieldOffsets(nullptr),
-FieldCount(fieldcount), CXXInfo(nullptr) {
-  if (FieldCount > 0)  {
-FieldOffsets = new (Ctx) uint64_t[FieldCount];
-memcpy(FieldOffsets, fieldoffsets, FieldCount * sizeof(*FieldOffsets));
-  }
+ ArrayRef fieldoffsets)
+: Size(size), DataSize(datasize), Alignment(alignment),
+  RequiredAlignment(requiredAlignment), CXXInfo(nullptr) {
+  FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
 }
 
 // Constructor for C++ records.
@@ -50,8 +43,7 @@ ASTRecordLayout::ASTRecordLayout(const A
  bool hasOwnVFPtr, bool hasExtendableVFPtr,
  CharUnits vbptroffset,
  CharUnits datasize,
- const uint64_t *fieldoffsets,
- unsigned fieldcount,
+ ArrayRef fieldoffsets,
  CharUnits nonvirtualsize,
  CharUnits nonvirtualalignment,
  CharUnits SizeOfLargestEmptySubobject,
@@ -63,13 +55,9 @@ ASTRecordLayout::ASTRecordLayout(const A

Re: [PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Hans Wennborg via cfe-commits
hans added a comment.

Thanks! Some comments below:



Comment at: lib/Driver/Tools.cpp:5335
@@ -5334,3 +5334,3 @@
 
-  if (Args.hasArg(options::OPT_fno_inline_functions))
-CmdArgs.push_back("-fno-inline-functions");
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, 
options::OPT_fno_inline_functions)) {
+
CmdArgs.push_back(InlineArg->getOption().matches(options::OPT_finline_functions)
 ?

Please line break this; lines should be <= 80 columns wide.


Comment at: lib/Driver/Tools.cpp:5337
@@ +5336,3 @@
+
CmdArgs.push_back(InlineArg->getOption().matches(options::OPT_finline_functions)
 ?
+"-finline-functions" : "-fno-inline-functions");
+  }

I think this can be:

```
InlineArg->render(Args, CmdArgs)
```
instead


Comment at: lib/Frontend/CompilerInvocation.cpp:446
@@ +445,3 @@
+
Opts.setInlining(InlineArg->getOption().matches(options::OPT_finline_functions) 
?
+CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
+  }

This line and 444 need line breaks too.


Comment at: test/CodeGen/inline-optim.c:16
@@ +15,3 @@
+// NOINLINE: @foo
+// INLINE: @foo
+// NOINLINE: inline_hint

I'd suggest using "check-label" for the @foo checks. See 
http://llvm.org/docs/CommandGuide/FileCheck.html#the-check-label-directive


Comment at: test/CodeGen/inline-optim.c:24
@@ +23,3 @@
+// NOINLINE: inline_no_hint
+// INLINE-NOT: inline_no_hint
+pa[6] = inline_no_hint(pa[7], pa[8]);

For all these checks, I'd suggest matching e.g.

 "call i32 @inline_hint"

to make it a little easier to see what' being matched for. I suppose your 
checks could match either the calls, or the definitions of the called function.


http://reviews.llvm.org/D20576



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


Re: [PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

I don't believe this is a libcxx bug, but it is a bug in the test code.  
oss.str(); isn't required to return a null terminated string.  std::cout << 
(char *) requires a null terminated string though.


http://reviews.llvm.org/D20334



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


Re: [PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-24 Thread Akira Hatanaka via cfe-commits
ping.

> On May 17, 2016, at 12:20 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> ahatanak created this revision.
> ahatanak added reviewers: mclow.lists, EricWF, howard.hinnant.
> ahatanak added a subscriber: cfe-commits.
> 
> The end pointer should point to one past the end of the newly allocated 
> buffer.
> 
> Without this fix, asan reports an error when the following code is compiled 
> and executed:
> 
> $ cat test.cpp
> 
> ```
> std::string stringOfLength(const size_t length) {
>  std::string s("");
> 
>  std::string characters("abcdefghijklmnopqrstuvwxyz0123456789+-*/");
>  for (size_t i = 0; i < length; ++i) {
>s += characters[i % characters.size()];
>  }
> 
>  return s;
> }
> 
> int main(int, char const **argv) {
>  std::ostrstream oss;
> 
>  oss << stringOfLength(atoi(argv[1])) << std::ends;
>  std::cout << oss.str();
>  oss.freeze(false);
> 
>  return 0;
> }```
> 
> $ clang++  -fsanitize=address test.cpp && ./a.out 4096
> ==18970==ERROR: AddressSanitizer: heap-buffer-overflow on address 
> 0x6211dd00 at pc 0x00010277c45d bp 0x7fff5d4ce6e0 sp 0x7fff5d4cdea0
> READ of size 4097 at 0x6211dd00 thread T0
>#0 0x10277c45c in wrap_strlen (libclang_rt.asan_osx_dynamic.dylib+0x4345c)
>#1 0x102733954 in std::__1::char_traits::length(char const*) 
> (a.out+0x12954)
>#2 0x10273390b in std::__1::basic_ostream std::__1::char_traits >& 
> std::__1::operator<< 
> >(std::__1::basic_ostream >&, char const*) 
> (a.out+0x1290b)
>#3 0x102733346 in main (a.out+0x12346)
>#4 0x7fff901905ac in start (libdyld.dylib+0x35ac)
>#5 0x1  ()
> 
> 0x6211dd00 is located 0 bytes to the right of 4096-byte region 
> [0x6211cd00,0x6211dd00)
> allocated by thread T0 here:
>#0 0x10278d42b in wrap__Znam (libclang_rt.asan_osx_dynamic.dylib+0x5442b)
>#1 0x7fff9bdc9fa1 in std::__1::strstreambuf::overflow(int) 
> (libc++.1.dylib+0x44fa1)
>#2 0x7fff9bd901cc in std::__1::basic_streambuf std::__1::char_traits >::xsputn(char const*, long) 
> (libc++.1.dylib+0xb1cc)
>#3 0x10273547c in std::__1::ostreambuf_iterator std::__1::char_traits > std::__1::__pad_and_output std::__1::char_traits >(std::__1::ostreambuf_iterator std::__1::char_traits >, char const*, char const*, char const*, 
> std::__1::ios_base&, char) (a.out+0x1447c)
>#4 0x102734312 in std::__1::basic_ostream std::__1::char_traits >& std::__1::__put_character_sequence std::__1::char_traits >(std::__1::basic_ostream std::__1::char_traits >&, char const*, unsigned long) 
> (a.out+0x13312)
>#5 0x10273389d in std::__1::basic_ostream std::__1::char_traits >& std::__1::operator<< std::__1::char_traits, std::__1::allocator 
> >(std::__1::basic_ostream >&, 
> std::__1::basic_string, 
> std::__1::allocator > const&) (a.out+0x1289d)
>#6 0x1027332c4 in main (a.out+0x122c4)
>#7 0x7fff901905ac in start (libdyld.dylib+0x35ac)
>#8 0x1  ()
> 
> http://reviews.llvm.org/D20334
> 
> Files:
>  src/strstream.cpp
> 
> Index: src/strstream.cpp
> ===
> --- src/strstream.cpp
> +++ src/strstream.cpp
> @@ -180,7 +180,7 @@
> delete [] eback();
> }
> setg(buf, buf + ninp, buf + einp);
> -setp(buf + einp, buf + einp + eout);
> +setp(buf + einp, buf + new_size);
> pbump(static_cast(nout));
> __strmode_ |= __allocated;
> }
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D20581: [include-fixer] Simplify the code since we won't handle multiple includes at once.

2016-05-24 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20581

Files:
  include-fixer/IncludeFixer.cpp

Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -282,64 +282,46 @@
clang::HeaderSearch &HeaderSearch,
std::set &Headers,
std::vector &Replacements) {
-if (Untried.empty())
+if (SymbolQueryResults.empty())
   return false;
 
-const auto &ToTry = UntriedList.front();
+// FIXME: Rank the results and pick the best one instead of the first one.
+const auto &ToTry = SymbolQueryResults.front();
 Headers.insert(minimizeInclude(ToTry, SourceManager, HeaderSearch));
 
 StringRef Code = 
SourceManager.getBufferData(SourceManager.getMainFileID());
 Replacements = CreateReplacementsForHeaders(Code, Headers);
 
 // We currently abort after the first inserted include. The more
 // includes we have the less safe this becomes due to error recovery
 // changing the results.
-// FIXME: Handle multiple includes at once.
 return true;
   }
 
   /// Sets the location at the very top of the file.
   void setFileBegin(clang::SourceLocation Location) { FileBegin = Location; }
 
-  /// Add an include to the set of includes to try.
-  /// \param include_path The include path to try.
-  void TryInclude(const std::string &query, const std::string &include_path) {
-if (Untried.insert(include_path).second)
-  UntriedList.push_back(include_path);
-  }
-
 private:
   /// Query the database for a given identifier.
   bool query(StringRef Query, SourceLocation Loc) {
 assert(!Query.empty() && "Empty query!");
 
-// Save database lookups by not looking up identifiers multiple times.
-if (!SeenQueries.insert(Query).second)
-  return true;
+// Skip other identifers once we have discovered an identfier successfully.
+if (!SymbolQueryResults.empty())
+  return false;
 
 DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
 DEBUG(Loc.print(llvm::dbgs(), getCompilerInstance().getSourceManager()));
 DEBUG(llvm::dbgs() << " ...");
 
-std::string error_text;
-auto SearchReply = SymbolIndexMgr.search(Query);
-DEBUG(llvm::dbgs() << SearchReply.size() << " replies\n");
-if (SearchReply.empty())
-  return false;
-
-// Add those files to the set of includes to try out.
-// FIXME: Rank the results and pick the best one instead of the first one.
-TryInclude(Query, SearchReply[0]);
-
-return true;
+SymbolQueryResults = SymbolIndexMgr.search(Query);
+DEBUG(llvm::dbgs() << SymbolQueryResults.size() << " replies\n");
+return !SymbolQueryResults.empty();
   }
 
   /// The client to use to find cross-references.
   SymbolIndexManager &SymbolIndexMgr;
 
-  // Remeber things we looked up to avoid querying things twice.
-  llvm::StringSet<> SeenQueries;
-
   /// The absolute path to the file being processed.
   std::string Filename;
 
@@ -354,11 +336,9 @@
   /// clang-format config file found.
   std::string FallbackStyle;
 
-  /// Includes we have left to try. A set to unique them and a list to keep
-  /// track of the order. We prefer includes that were discovered early to 
avoid
-  /// getting caught in results from error recovery.
-  std::set Untried;
-  std::vector UntriedList;
+  /// The query results of an identifier. We only include the first discovered
+  /// identifier to avoid getting caught in results from error recovery.
+  std::vector SymbolQueryResults;
 
   /// Whether we should use the smallest possible include path.
   bool MinimizeIncludePaths = true;


Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -282,64 +282,46 @@
clang::HeaderSearch &HeaderSearch,
std::set &Headers,
std::vector &Replacements) {
-if (Untried.empty())
+if (SymbolQueryResults.empty())
   return false;
 
-const auto &ToTry = UntriedList.front();
+// FIXME: Rank the results and pick the best one instead of the first one.
+const auto &ToTry = SymbolQueryResults.front();
 Headers.insert(minimizeInclude(ToTry, SourceManager, HeaderSearch));
 
 StringRef Code = SourceManager.getBufferData(SourceManager.getMainFileID());
 Replacements = CreateReplacementsForHeaders(Code, Headers);
 
 // We currently abort after the first inserted include. The more
 // includes we have the less safe this becomes due to error recovery
 // changing the results.
-// FIXME: Handle multiple includes at once.
 return true;
   }
 
   /// Sets the location at the very top of the file.
   void setFileBegin(clang::SourceLocation Location) { FileBegin = Location; }
 
-  /// Add

Re: r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread David Majnemer via cfe-commits
Done with r270583, I added a note in a comment to avoid this situation in
the future.

On Tue, May 24, 2016 at 10:26 AM, Richard Smith 
wrote:

> On 24 May 2016 10:15 a.m., "Richard Smith"  wrote:
> >
> > As I recall, this was intentional. The supported way to check for these
> is has_builtin. The has_feature support is provided only for backwards
> compatibility.
>
> See documentation here:
>
> http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives
>
> These should be covered only by has_extension, not by has_feature.
>
> > On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: majnemer
> >> Date: Tue May 24 11:53:13 2016
> >> New Revision: 270580
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
> >> Log:
> >> [Lex] Support more type-traits in __has_feature
> >>
> >> It looks like we forgot to update the __has_feature support when we
> >> added some of the type traits.
> >>
> >> Modified:
> >> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >> cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> >>
> >> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
> >>
> ==
> >> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> >> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
> >> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
> >>.Case("has_nothrow_copy", LangOpts.CPlusPlus)
> >>.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
> >>.Case("has_trivial_assign", LangOpts.CPlusPlus)
> >> +  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
> >>.Case("has_trivial_copy", LangOpts.CPlusPlus)
> >>.Case("has_trivial_constructor", LangOpts.CPlusPlus)
> >> +  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
> >>.Case("has_trivial_destructor", LangOpts.CPlusPlus)
> >>.Case("has_virtual_destructor", LangOpts.CPlusPlus)
> >>.Case("is_abstract", LangOpts.CPlusPlus)
> >> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
> >>.Case("is_class", LangOpts.CPlusPlus)
> >>.Case("is_constructible", LangOpts.CPlusPlus)
> >>.Case("is_convertible_to", LangOpts.CPlusPlus)
> >> +  .Case("is_destructible",
> >> +LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
> >>.Case("is_empty", LangOpts.CPlusPlus)
> >>.Case("is_enum", LangOpts.CPlusPlus)
> >>.Case("is_final", LangOpts.CPlusPlus)
> >>.Case("is_literal", LangOpts.CPlusPlus)
> >> -  .Case("is_standard_layout", LangOpts.CPlusPlus)
> >> +  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
> >> +  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
> >> +  .Case("is_nothrow_destructible",
> >> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> >>.Case("is_pod", LangOpts.CPlusPlus)
> >>.Case("is_polymorphic", LangOpts.CPlusPlus)
> >> -  .Case("is_sealed", LangOpts.MicrosoftExt)
> >> +  .Case("is_sealed",
> >> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> >> +  .Case("is_standard_layout", LangOpts.CPlusPlus)
> >>.Case("is_trivial", LangOpts.CPlusPlus)
> >>.Case("is_trivially_assignable", LangOpts.CPlusPlus)
> >>.Case("is_trivially_constructible", LangOpts.CPlusPlus)
> >>
> >> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
> >>
> ==
> >> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
> >> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24
> 11:53:13 2016
> >> @@ -20,6 +20,16 @@ int has_trivial_assign();
> >>  #endif
> >>  // CHECK: int has_trivial_assign();
> >>
> >> +#if __has_feature(has_trivial_move_assign)
> >> +int has_trivial_move_assign();
> >> +#endif
> >> +// CHECK: int has_trivial_move_assign();
> >> +
> >> +#if __has_feature(has_trivial_move_constructor)
> >> +int has_trivial_move_constructor();
> >> +#endif
> >> +// CHECK: int has_trivial_move_constructor();
> >> +
> >>  #if __has_feature(has_trivial_copy)
> >>  int has_trivial_copy();
> >>  #endif
> >> @@ -105,6 +115,16 @@ int is_literal();
> >>  #endif
> >>  // CHECK: int is_literal();
> >>
> >> +#if __has_feature(is_nothrow_assignable)
> >> +int is_nothrow_assignable();
> >> +#endif
> >> +// CHECK: int is_nothrow_assignable();
> >> +
> >> +#if __has_feature(is_nothrow_constructible)
> >> +int is_nothrow_constructible();
> >> +#endif
> >> +// CHECK: int is_nothrow_constructible();
> >> +
> >>  #if __has_feature(is_standard_layout)
> >>  int is_standard_layout();
> >>  #endif

r270583 - Revert "[Lex] Support more type-traits in __has_feature"

2016-05-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue May 24 12:21:42 2016
New Revision: 270583

URL: http://llvm.org/viewvc/llvm-project?rev=270583&view=rev
Log:
Revert "[Lex] Support more type-traits in __has_feature"

This reverts commit r270580.  Using __has_feature to test for
type-traits is deprecated.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Lexer/has_feature_type_traits.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270583&r1=270582&r2=270583&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 12:21:42 2016
@@ -1187,37 +1187,29 @@ static bool HasFeature(const Preprocesso
   // FIXME: Should this be __has_feature or __has_extension?
   //.Case("raw_invocation_type", LangOpts.CPlusPlus)
   // Type traits
+  // N.B. Additional type traits should not be added to the following list.
+  // Instead, they should be detected by has_extension.
   .Case("has_nothrow_assign", LangOpts.CPlusPlus)
   .Case("has_nothrow_copy", LangOpts.CPlusPlus)
   .Case("has_nothrow_constructor", LangOpts.CPlusPlus)
   .Case("has_trivial_assign", LangOpts.CPlusPlus)
-  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
   .Case("has_trivial_copy", LangOpts.CPlusPlus)
   .Case("has_trivial_constructor", LangOpts.CPlusPlus)
-  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
   .Case("has_trivial_destructor", LangOpts.CPlusPlus)
   .Case("has_virtual_destructor", LangOpts.CPlusPlus)
   .Case("is_abstract", LangOpts.CPlusPlus)
-  .Case("is_assignable", LangOpts.CPlusPlus)
   .Case("is_base_of", LangOpts.CPlusPlus)
   .Case("is_class", LangOpts.CPlusPlus)
   .Case("is_constructible", LangOpts.CPlusPlus)
   .Case("is_convertible_to", LangOpts.CPlusPlus)
-  .Case("is_destructible",
-LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
   .Case("is_empty", LangOpts.CPlusPlus)
   .Case("is_enum", LangOpts.CPlusPlus)
   .Case("is_final", LangOpts.CPlusPlus)
   .Case("is_literal", LangOpts.CPlusPlus)
-  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
-  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
-  .Case("is_nothrow_destructible",
-LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
+  .Case("is_standard_layout", LangOpts.CPlusPlus)
   .Case("is_pod", LangOpts.CPlusPlus)
   .Case("is_polymorphic", LangOpts.CPlusPlus)
-  .Case("is_sealed",
-LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
-  .Case("is_standard_layout", LangOpts.CPlusPlus)
+  .Case("is_sealed", LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
   .Case("is_trivial", LangOpts.CPlusPlus)
   .Case("is_trivially_assignable", LangOpts.CPlusPlus)
   .Case("is_trivially_constructible", LangOpts.CPlusPlus)

Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270583&r1=270582&r2=270583&view=diff
==
--- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 12:21:42 2016
@@ -20,16 +20,6 @@ int has_trivial_assign();
 #endif
 // CHECK: int has_trivial_assign();
 
-#if __has_feature(has_trivial_move_assign)
-int has_trivial_move_assign();
-#endif
-// CHECK: int has_trivial_move_assign();
-
-#if __has_feature(has_trivial_move_constructor)
-int has_trivial_move_constructor();
-#endif
-// CHECK: int has_trivial_move_constructor();
-
 #if __has_feature(has_trivial_copy)
 int has_trivial_copy();
 #endif
@@ -55,11 +45,6 @@ int is_abstract();
 #endif
 // CHECK: int is_abstract();
 
-#if __has_feature(is_assignable)
-int is_assignable();
-#endif
-// CHECK: int is_assignable();
-
 #if __has_feature(is_base_of)
 int is_base_of();
 #endif
@@ -115,16 +100,6 @@ int is_literal();
 #endif
 // CHECK: int is_literal();
 
-#if __has_feature(is_nothrow_assignable)
-int is_nothrow_assignable();
-#endif
-// CHECK: int is_nothrow_assignable();
-
-#if __has_feature(is_nothrow_constructible)
-int is_nothrow_constructible();
-#endif
-// CHECK: int is_nothrow_constructible();
-
 #if __has_feature(is_standard_layout)
 int is_standard_layout();
 #endif


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


Re: r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread Richard Smith via cfe-commits
On 24 May 2016 10:15 a.m., "Richard Smith"  wrote:
>
> As I recall, this was intentional. The supported way to check for these
is has_builtin. The has_feature support is provided only for backwards
compatibility.

See documentation here:
http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives

These should be covered only by has_extension, not by has_feature.

> On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>>
>> Author: majnemer
>> Date: Tue May 24 11:53:13 2016
>> New Revision: 270580
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
>> Log:
>> [Lex] Support more type-traits in __has_feature
>>
>> It looks like we forgot to update the __has_feature support when we
>> added some of the type traits.
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> cfe/trunk/test/Lexer/has_feature_type_traits.cpp
>>
>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
>>
==
>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
>> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
>>.Case("has_nothrow_copy", LangOpts.CPlusPlus)
>>.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
>>.Case("has_trivial_assign", LangOpts.CPlusPlus)
>> +  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
>>.Case("has_trivial_copy", LangOpts.CPlusPlus)
>>.Case("has_trivial_constructor", LangOpts.CPlusPlus)
>> +  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
>>.Case("has_trivial_destructor", LangOpts.CPlusPlus)
>>.Case("has_virtual_destructor", LangOpts.CPlusPlus)
>>.Case("is_abstract", LangOpts.CPlusPlus)
>> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
>>.Case("is_class", LangOpts.CPlusPlus)
>>.Case("is_constructible", LangOpts.CPlusPlus)
>>.Case("is_convertible_to", LangOpts.CPlusPlus)
>> +  .Case("is_destructible",
>> +LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
>>.Case("is_empty", LangOpts.CPlusPlus)
>>.Case("is_enum", LangOpts.CPlusPlus)
>>.Case("is_final", LangOpts.CPlusPlus)
>>.Case("is_literal", LangOpts.CPlusPlus)
>> -  .Case("is_standard_layout", LangOpts.CPlusPlus)
>> +  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
>> +  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
>> +  .Case("is_nothrow_destructible",
>> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
>>.Case("is_pod", LangOpts.CPlusPlus)
>>.Case("is_polymorphic", LangOpts.CPlusPlus)
>> -  .Case("is_sealed", LangOpts.MicrosoftExt)
>> +  .Case("is_sealed",
>> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
>> +  .Case("is_standard_layout", LangOpts.CPlusPlus)
>>.Case("is_trivial", LangOpts.CPlusPlus)
>>.Case("is_trivially_assignable", LangOpts.CPlusPlus)
>>.Case("is_trivially_constructible", LangOpts.CPlusPlus)
>>
>> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
>> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
>>
==
>> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
>> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 11:53:13
2016
>> @@ -20,6 +20,16 @@ int has_trivial_assign();
>>  #endif
>>  // CHECK: int has_trivial_assign();
>>
>> +#if __has_feature(has_trivial_move_assign)
>> +int has_trivial_move_assign();
>> +#endif
>> +// CHECK: int has_trivial_move_assign();
>> +
>> +#if __has_feature(has_trivial_move_constructor)
>> +int has_trivial_move_constructor();
>> +#endif
>> +// CHECK: int has_trivial_move_constructor();
>> +
>>  #if __has_feature(has_trivial_copy)
>>  int has_trivial_copy();
>>  #endif
>> @@ -105,6 +115,16 @@ int is_literal();
>>  #endif
>>  // CHECK: int is_literal();
>>
>> +#if __has_feature(is_nothrow_assignable)
>> +int is_nothrow_assignable();
>> +#endif
>> +// CHECK: int is_nothrow_assignable();
>> +
>> +#if __has_feature(is_nothrow_constructible)
>> +int is_nothrow_constructible();
>> +#endif
>> +// CHECK: int is_nothrow_constructible();
>> +
>>  #if __has_feature(is_standard_layout)
>>  int is_standard_layout();
>>  #endif
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20447: [OpenCL] Fixup extension list

2016-05-24 Thread Jan Vesely via cfe-commits
jvesely added inline comments.


Comment at: test/SemaOpenCL/extension-version.cl:11
@@ +10,3 @@
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+

Anastasia wrote:
> Could you use standard diagnostic check please:
>   expected-warning{{unknown OpenCL extension ...
> 
> Similarly to SemaOpenCL/extensions.cl
not sure I follow, the test does not trigger any diagnostics (by design).
are you saying that I should introduce negative checks to make sure extensions 
are not available outside of their respective context?
Is there a way to filter verifier tags based on clang invocation? (something 
like FileCheck prefix)


Repository:
  rL LLVM

http://reviews.llvm.org/D20447



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


Re: [clang-tools-extra] r270575 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Mads Ravn via cfe-commits
I'm glad. I'm finally getting the hang of this (I think) :)

Best regards,
Mads Ravn

On Tue, May 24, 2016 at 7:01 PM Renato Golin 
wrote:

> On 24 May 2016 at 17:09, Mads Ravn via cfe-commits
>  wrote:
> > Author: madsravn
> > Date: Tue May 24 11:09:24 2016
> > New Revision: 270575
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=270575&view=rev
> > Log:
> > [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
>
> This seems to have done the trick, thanks!
>
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20576: [Driver] Add support for -finline-functions and /Ob2 flags

2016-05-24 Thread Rudy Pons via cfe-commits
Ilod created this revision.
Ilod added a reviewer: hans.
Ilod added a subscriber: cfe-commits.

-finline-functions and /Ob2 are currently ignored by Clang. The only way to 
enable inlining is to use the global O flags, which also enable other options, 
or to emit LLVM bitcode using Clang, then running opt by hand with the inline 
pass.
This patch allows to simply use the -finline-functions flag (same as GCC) or 
/Ob2 in clang-cl mode to enable inlining without other optimizations.
This is the first patch of a serie to improve support for the /Ob flags.

http://reviews.llvm.org/D20576

Files:
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/inline-optim.c
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -285,7 +285,6 @@
 // RUN: -fexpensive-optimizations \
 // RUN: -fno-expensive-optimizations  \
 // RUN: -fno-defer-pop\
-// RUN: -finline-functions\
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
@@ -353,7 +352,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
-// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -97,6 +97,9 @@
 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
 // Ob0: -fno-inline
 
+// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
+// Ob2: -finline-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -265,7 +268,6 @@
 // RUN:/kernel- \
 // RUN:/nologo \
 // RUN:/Ob1 \
-// RUN:/Ob2 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: test/CodeGen/inline-optim.c
===
--- test/CodeGen/inline-optim.c
+++ test/CodeGen/inline-optim.c
@@ -0,0 +1,26 @@
+// Make sure -finline-functions family flags are behaving correctly.
+
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s
+
+inline int inline_hint(int a, int b) { return(a+b); }
+
+int inline_no_hint(int a, int b) { return (a/b); }
+
+inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { return(a*b); }
+
+volatile int *pa = (int*) 0x1000;
+void foo() {
+// NOINLINE: @foo
+// INLINE: @foo
+// NOINLINE: inline_hint
+// INLINE-NOT: inline_hint
+pa[0] = inline_hint(pa[1],pa[2]);	
+// NOINLINE-NOT: inline_always
+// INLINE-NOT: inline_always
+pa[3] = inline_always(pa[4],pa[5]);
+// NOINLINE: inline_no_hint
+// INLINE-NOT: inline_no_hint
+pa[6] = inline_no_hint(pa[7], pa[8]);
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -441,8 +441,10 @@
  : CodeGenOptions::OnlyAlwaysInlining);
   // -fno-inline-functions overrides OptimizationLevel > 1.
   Opts.NoInline = Args.hasArg(OPT_fno_inline);
-  Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
- CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, options::OPT_fno_inline_functions)) {
+Opts.setInlining(InlineArg->getOption().matches(options::OPT_finline_functions) ?
+CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
+  }
 
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5332,8 +5332,10 @@
   if 

Re: r270580 - [Lex] Support more type-traits in __has_feature

2016-05-24 Thread Richard Smith via cfe-commits
As I recall, this was intentional. The supported way to check for these is
has_builtin. The has_feature support is provided only for backwards
compatibility.
On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Tue May 24 11:53:13 2016
> New Revision: 270580
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
> Log:
> [Lex] Support more type-traits in __has_feature
>
> It looks like we forgot to update the __has_feature support when we
> added some of the type traits.
>
> Modified:
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/test/Lexer/has_feature_type_traits.cpp
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
>.Case("has_nothrow_copy", LangOpts.CPlusPlus)
>.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
>.Case("has_trivial_assign", LangOpts.CPlusPlus)
> +  .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
>.Case("has_trivial_copy", LangOpts.CPlusPlus)
>.Case("has_trivial_constructor", LangOpts.CPlusPlus)
> +  .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
>.Case("has_trivial_destructor", LangOpts.CPlusPlus)
>.Case("has_virtual_destructor", LangOpts.CPlusPlus)
>.Case("is_abstract", LangOpts.CPlusPlus)
> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
>.Case("is_class", LangOpts.CPlusPlus)
>.Case("is_constructible", LangOpts.CPlusPlus)
>.Case("is_convertible_to", LangOpts.CPlusPlus)
> +  .Case("is_destructible",
> +LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
>.Case("is_empty", LangOpts.CPlusPlus)
>.Case("is_enum", LangOpts.CPlusPlus)
>.Case("is_final", LangOpts.CPlusPlus)
>.Case("is_literal", LangOpts.CPlusPlus)
> -  .Case("is_standard_layout", LangOpts.CPlusPlus)
> +  .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
> +  .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
> +  .Case("is_nothrow_destructible",
> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
>.Case("is_pod", LangOpts.CPlusPlus)
>.Case("is_polymorphic", LangOpts.CPlusPlus)
> -  .Case("is_sealed", LangOpts.MicrosoftExt)
> +  .Case("is_sealed",
> +LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> +  .Case("is_standard_layout", LangOpts.CPlusPlus)
>.Case("is_trivial", LangOpts.CPlusPlus)
>.Case("is_trivially_assignable", LangOpts.CPlusPlus)
>.Case("is_trivially_constructible", LangOpts.CPlusPlus)
>
> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
>
> ==
> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24 11:53:13
> 2016
> @@ -20,6 +20,16 @@ int has_trivial_assign();
>  #endif
>  // CHECK: int has_trivial_assign();
>
> +#if __has_feature(has_trivial_move_assign)
> +int has_trivial_move_assign();
> +#endif
> +// CHECK: int has_trivial_move_assign();
> +
> +#if __has_feature(has_trivial_move_constructor)
> +int has_trivial_move_constructor();
> +#endif
> +// CHECK: int has_trivial_move_constructor();
> +
>  #if __has_feature(has_trivial_copy)
>  int has_trivial_copy();
>  #endif
> @@ -105,6 +115,16 @@ int is_literal();
>  #endif
>  // CHECK: int is_literal();
>
> +#if __has_feature(is_nothrow_assignable)
> +int is_nothrow_assignable();
> +#endif
> +// CHECK: int is_nothrow_assignable();
> +
> +#if __has_feature(is_nothrow_constructible)
> +int is_nothrow_constructible();
> +#endif
> +// CHECK: int is_nothrow_constructible();
> +
>  #if __has_feature(is_standard_layout)
>  int is_standard_layout();
>  #endif
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-24 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Sam, there are a few small comments, otherwise it seems to be in a good shape.

@rsmith, do you think you could take a look here? The OpenCL side is fine, but 
I was just wondering if you see any issue with us adding a header of ~17K 
lines. It is all part of OpenCL standard libraries though and would be very 
helpful to have it upstream for all of us. Any suggestion on testing would be 
useful too as it's a bit simplified for now due to its size.



Comment at: lib/Headers/opencl-c.h:19
@@ +18,3 @@
+
+#define _ovld __attribute__((overloadable))
+

Could we change to ovld and cnfn with double underscores please?


Comment at: lib/Headers/opencl-c.h:143
@@ +142,3 @@
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#define NULL  ((void*)0)
+#endif

indentation seems wrong!


Comment at: lib/Headers/opencl-c.h:175
@@ +174,3 @@
+ */
+#define NAN as_float(INT_MAX)
+

Is this a part of spec? I don't see it in s6.13.2.1.


Comment at: lib/Headers/opencl-c.h:7953
@@ +7952,3 @@
+/**
+ * Compute the base e exponential of x.
+ */

Ping!


Comment at: lib/Headers/opencl-c.h:8307
@@ +8306,3 @@
+#else
+float _ovld fract(float x, __global float *iptr);
+float2 _ovld fract(float2 x, __global float2 *iptr);

Any problem with doing this unconditionally?


Comment at: lib/Headers/opencl-c.h:8458
@@ +8457,3 @@
+/**
+ * Compute the value of the square root of x^2+ y^2
+ * without undue overflow or underflow.

Ping!


Comment at: lib/Headers/opencl-c.h:12646
@@ +12645,3 @@
+/**
+ * Return sizeof (gentypen) bytes of data read
+ * from address (p + (offset * n)). The address

This description is missing explaining what gentype is! The same happens in 
other places too.


Comment at: lib/Headers/opencl-c.h:12773
@@ +12772,3 @@
+#ifdef cl_khr_fp16
+half _ovld vload(size_t offset, const half *p);
+half2 _ovld vload2(size_t offset, const half *p);

Ping!


Comment at: lib/Headers/opencl-c.h:14004
@@ +14003,3 @@
+
+// Builtin functions to_global, to_local, and to_private need to be declared 
as Clang builtin functions
+// and checked in Sema since they should be declared as

Formatting is wrong!


http://reviews.llvm.org/D18369



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


Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-24 Thread Ben Craig via cfe-commits
bcraig added a comment.

Note: You'll want to look at http://reviews.llvm.org/D20573, as there will be 
confilicts for whoever submits second.



Comment at: include/__threading_support:201
@@ +200,3 @@
+// Mutex
+#define _LIBCPP_MUTEX_INITIALIZER nullptr
+struct __libcpp_platform_mutex_t;

I'm not sure I like taking the freedom to define _LIBCPP_MUTEX_INITIALIZER away 
from implementers.

Would it be too terrible to replace this entire #elif block with something like 
the following?

```
#if !defined(__has_include) || __has_include()
#include 
#else
#error "_LIBCPP_THREAD_API_EXTERNAL requires the implementer to provide 
 in the include path"
#endif
```




http://reviews.llvm.org/D20328



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


Re: [clang-tools-extra] r270575 - [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

2016-05-24 Thread Renato Golin via cfe-commits
On 24 May 2016 at 17:09, Mads Ravn via cfe-commits
 wrote:
> Author: madsravn
> Date: Tue May 24 11:09:24 2016
> New Revision: 270575
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270575&view=rev
> Log:
> [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test

This seems to have done the trick, thanks!

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


  1   2   >