Re: [PATCH] D20422: [MSVC2015] dllexport for defaulted special class members

2016-05-19 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added inline comments.


Comment at: lib/Sema/SemaDeclCXX.cpp:13111
@@ -13090,3 +13110,3 @@
   llvm_unreachable("Invalid special member.");
 }
   } else {

rnk wrote:
> Can we add `if (InClassDef) ActOnFinishInlineFunctionDef(MD);` here instead? 
> If the decl doesn't have dllexport, we will just defer it until its 
> referenced, which seems OK.
We can move this check here but condition has to be more complicated because 
MSVC2015 doesn't export trivial defaulted c-tors even if they were explicitly 
declared dllexport, see my check on line 4822.


http://reviews.llvm.org/D20422



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


Re: [PATCH] D20422: [MSVC2015] dllexport for defaulted special class members

2016-05-19 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 57896.
DmitryPolukhin marked 2 inline comments as done.
DmitryPolukhin added a comment.

Comments resolved, PTAL.


http://reviews.llvm.org/D20422

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport-members.cpp
  test/CodeGenCXX/dllexport.cpp

Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 %s
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 -check-prefix=M32MSVC2015 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 -check-prefix=M32MSVC2013 %s
 
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 -check-prefix=M64MSVC2015 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 -check-prefix=M64MSVC2013 %s
 
 // RUN: %clang_cc1 -triple i686-windows-gnu-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G64 %s
@@ -561,7 +561,7 @@
 
   // Explicitly defaulted copy constructur:
   T(const T&) = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.T* @"\01??0T@@QAE@ABU0@@Z"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.T* @"\01??0T@@QAE@ABU0@@Z"
 
   void a() {}
   // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?a@T@@QAEXXZ"
@@ -647,9 +647,34 @@
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
   DefaultedCtorsDtors() = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.DefaultedCtorsDtors* @"\01??0DefaultedCtorsDtors@@QAE@XZ"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.DefaultedCtorsDtors* @"\01??0DefaultedCtorsDtors@@QAE@XZ"
   ~DefaultedCtorsDtors() = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1DefaultedCtorsDtors@@QAE@XZ"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1DefaultedCtorsDtors@@QAE@XZ"
+};
+
+// Export defaulted member function definitions declared inside class.
+struct __declspec(dllexport) ExportDefaultedInclassDefs {
+  ExportDefaultedInclassDefs() = default;
+  // M32VS2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QAE@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M64VS2013-DAG: define weak_odr dllexport%struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QEAA@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M32VS2015-NOT: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QAE@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M64VS2015-NOT: define weak_odr dllexport%struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QEAA@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+
+  ~ExportDefaultedInclassDefs() = default;
+  // 

Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-05-19 Thread Bittner Barni via cfe-commits
bittnerbarni updated this revision to Diff 57894.

http://reviews.llvm.org/D20196

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientStringAdditionCheck.cpp
  clang-tidy/performance/InefficientStringAdditionCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-string-addition.rst
  test/clang-tidy/performance-inefficient-string-addition.cpp

Index: test/clang-tidy/performance-inefficient-string-addition.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-string-addition.cpp
@@ -0,0 +1,44 @@
+// RUN: %check_clang_tidy %s performance-inefficient-string-addition %t
+
+namespace std {
+template 
+class basic_string {
+public:
+  basic_string() {}
+  ~basic_string() {}
+  basic_string *operator+=(const basic_string &) {}
+  friend basic_string operator+(const basic_string &, const basic_string &) {}
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f(std::string) {}
+std::string g(std::string) {}
+
+int main() {
+  std::string mystr1, mystr2;
+  std::wstring mywstr1, mywstr2;
+
+  for (int i = 0; i < 10; ++i) {
+f(mystr1 + mystr2 + mystr1);
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: inefficient string concatenation
+mystr1 = mystr1 + mystr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ineff
+mystr1 = mystr2 + mystr2 + mystr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: ineff
+mystr1 = mystr2 + mystr1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ineff
+mywstr1 = mywstr2 + mywstr1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ineff
+mywstr1 = mywstr2 + mywstr2 + mywstr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: ineff
+
+mywstr1 = mywstr2 + mywstr2;
+mystr1 = mystr2 + mystr2;
+mystr1 += mystr2;
+f(mystr2 + mystr1);
+mystr1 = g(mystr1);
+  }
+  return 0;
+}
Index: docs/clang-tidy/checks/performance-inefficient-string-addition.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/performance-inefficient-string-addition.rst
@@ -0,0 +1,55 @@
+.. title:: clang-tidy - performance-inefficient-string-addition
+
+performance-inefficient-string-addition
+===
+
+The problem
+---
+This check is to warn about the performance overhead arising from concatenating strings, using the ``operator+``, for instance:
+
+.. code:: c++
+
+std::string a("Foo"), b("Bar");
+a = a + b;
+
+Instead of this structure you should use ``operator+=`` or std::string's (std::basic_string) class member function ``append``. For instance:
+   
+.. code:: c++
+
+   std::string a("Foo"), b("Baz");
+   for(int i = 0; i < 2; ++i)
+   {
+   a = a + "Bar" + b;
+   }
+
+Could be rewritten in a greatly more efficient way like:
+
+.. code:: c++
+
+   std::string a("Foo"), b("Baz");
+   for(int i = 0; i < 2; ++i)
+   {
+   a.append("Bar").append(b);
+   } 
+
+And this can be rewritten too:
+ 
+ .. code:: c++
+  
+   void f(const std::string&){}
+   std::string a("Foo"), b("Baz");
+   void g()
+   {
+   f(a + "Bar" + b);
+   }
+
+In a slightly more efficient way like:
+
+.. code:: c++
+
+   void f(const std::string&){}
+   std::string a("Foo"), b("Baz");
+   void g()
+   {
+   f(std::string(a).append("Bar").append(b));
+   }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -102,6 +102,7 @@
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
+   performance-inefficient-string-addition
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
readability-avoid-const-params-in-decls
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -184,6 +184,12 @@
   Warns about range-based loop with a loop variable of const ref type where the
   type of the variable does not match the one returned by the iterator.
 
+- New `performance-inefficient-string-addition
+  `_ check
+
+  This check is to warn about the performance overhead arising from concatenating 
+  strings, using the ``operator+``, instead of ``operator+=``.
+  
 - New `performance-unnecessary-value-param
   `_ check
 
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -10,6 +10,7 @@
 

Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-05-19 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.

Sorry about late reply.
LGTM!


http://reviews.llvm.org/D17578



___
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-19 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.

LGTM!
I think we may add optimization on this base later.


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: r266719 - Warn if function or variable cannot be implicitly instantiated

2016-05-19 Thread Sean Silva via cfe-commits
On Thu, May 19, 2016 at 12:13 PM, Serge Pavlov  wrote:

> In this case moving implementation of `Singleton::getInstance()` into a
> .cpp file would prevent compiler from instantiation of the method body when
> it sees `Singleton::getInstance()`. In this case
> `Singleton::getInstance()` must be instantiated in some source file
> either explicitly or implicitly. If inline implementation for
> `Singleton::getInstance()` is provided in the header, where
> `Singleton` is defined, the method body is instantiated implicitly when
> it is required. But the static field `instance` referenced in the method
> still must be instantiated in some source file explicitly or implicitly. So
> from viewpoint of convenience, moving the implementation of template
> `Singleton::getInstance()` into source file does not look as more
> inflexible solution.
>
> Probably it is more convenient to put the template for the static member
> to header file too:
>
> template 
> T *Singleton::instance = nullptr;
>
>
> In this case both the method and corresponding static member are
> instantiated implicitly by compiler, no warning occurs.
> Can it be an acceptable solution?
>

I think that is what makes the most sense in this scenario (and it
simplifies things for clients of the library).
Unfortunately, for the library that was producing this warning they already
required clients to provide explicit instantiations in a .cpp file (they
had a macro like `DEFINE_SINGLETON_INSTANCE(T)` which a user would place in
a .cpp file to instantiate Singleton::instance for their type).

So fixing this warning like this would have a compatibility concern.

Thankfully, it seems like some compilers (not clang) have a bug in that
they will emit Singleton::instance any time that Singleton is
instantiated unless they have already seen an explicit instantiation
declaration of Singleton::instance in a header, so this library
already had (under an #if) explicit instantiations for
Singleton::instance for all classes that needed it in order to work
around this compiler bug. So in the end I fixed this by just enabling those
ifdefs so that clang would see the Singleton::instance explicitly
declared in the header.
(This is sort of a strange coincidence, but it worked out nicely)



>
> If there is intention to limit `Singleton` to some selected types,
> explicit instantiation declaration may help. Adding the declarations like:
>
> extern template Foo *Singleton::instance;
>
>
> prevents from warnings.
>
> Or you think that the message should propose moving static member
> definition into header file as well?
>

I'm not sure, but I think that the current diagnostics are not very
actionable. Hopefully google will lead users to your description in this
thread. I wish we had something like
https://doc.rust-lang.org/error-index.html where we could officially
provide a more in-depth explanation similar to your posts in this thread.

-- Sean Silva


>
>
> Thanks,
> --Serge
>
> 2016-05-19 9:15 GMT+06:00 Sean Silva :
>
>>
>>
>> On Thu, Apr 21, 2016 at 12:44 AM, Serge Pavlov 
>> wrote:
>>
>>> Let me demonstrate the problem using excerpt from v8 sources:
>>>
>>> -- lithium.h 
>>> template 
>>> struct LSubKindOperand {
>>>   static int* Create(int index) { return [index]; }
>>>   static void SetUpCache();
>>>   static int* cache;
>>> };
>>>
>>> struct LOperand {
>>>   static void SetUpCaches();
>>> };
>>>
>>> #define LITHIUM_OPERAND_LIST(V)   \
>>>   V(DoubleRegister,  1,   16)
>>>
>>> #define LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number)   \
>>> typedef LSubKindOperand L##name;
>>> LITHIUM_OPERAND_LIST(LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS)
>>> /* Expands to: typedef LSubKindOperand<1, 16> LDoubleRegister; */
>>> #undef LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS
>>>
>>> -- lithium.cc
>>> #include "lithium.h"
>>>
>>> template
>>> int* LSubKindOperand::cache = 0;
>>>
>>> template
>>> void LSubKindOperand::SetUpCache() {
>>>   cache = new int[kNumCachedOperands];
>>> }
>>>
>>> void LOperand::SetUpCaches() {
>>> #define LITHIUM_OPERAND_SETUP(name, type, number) L##name::SetUpCache();
>>>   LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP)
>>>   /* Expands to: LDoubleRegister::SetUpCache(); */
>>> #undef LITHIUM_OPERAND_SETUP
>>> }
>>>
>>> -- lithium-x64.cc ---
>>> #include "lithium.h"
>>>
>>> int* GetNextSpillSlot(int kind) {
>>>   return LSubKindOperand<1,16>::Create(0);
>>> }
>>>
>>> int main(int argc, char *argv[]) {
>>>   return 0;
>>> }
>>>
>>> -- build.sh -
>>> g++ lithium.cc lithium-x64.cc
>>> -
>>>
>>> When compiler generates code for 

r270180 - CodeGen: address -Wcast-qual warning

2016-05-19 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu May 19 22:58:12 2016
New Revision: 270180

URL: http://llvm.org/viewvc/llvm-project?rev=270180=rev
Log:
CodeGen: address -Wcast-qual warning

Add a const_cast rather than the C-style cast.  NFC.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=270180=270179=270180=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu May 19 22:58:12 2016
@@ -853,7 +853,7 @@ void clang::EmbedBitcode(llvm::Module *M
   // Skip if only bitcode needs to be embedded.
   if (CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Bitcode) {
 // Embed command-line options.
-ArrayRef CmdData((uint8_t*)CGOpts.CmdArgs.data(),
+ArrayRef CmdData(const_cast(CGOpts.CmdArgs.data()),
   CGOpts.CmdArgs.size());
 llvm::Constant *CmdConstant =
   llvm::ConstantDataArray::get(M->getContext(), CmdData);


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


Re: r270089 - [MS ABI] Ignore transparent contexts when determining the effective context

2016-05-19 Thread Richard Smith via cfe-commits
On Thu, May 19, 2016 at 11:15 AM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Thu May 19 13:15:53 2016
> New Revision: 270089
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270089=rev
> Log:
> [MS ABI] Ignore transparent contexts when determining the effective context
>
> We didn't skip over extern "C++" contexts, causing us to mangle things
> which don't need to be mangled.
>

Hah, I guess I should have checked MS ABI when I fixed the same bug for
Itanium a week or two ago :)


> Modified:
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
>
> Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=270089=270088=270089=diff
>
> ==
> --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
> +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu May 19 13:15:53 2016
> @@ -94,7 +94,7 @@ static const DeclContext *getEffectiveDe
>  return getEffectiveDeclContext(cast(DC));
>}
>
> -  return DC;
> +  return DC->getRedeclContext();
>  }
>
>  static const DeclContext *getEffectiveParentContext(const DeclContext
> *DC) {
>
> Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=270089=270088=270089=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Thu May 19 13:15:53 2016
> @@ -4,6 +4,11 @@
>  int a;
>  // CHECK-DAG: @"\01?a@@3HA"
>
> +extern "C++" {
> +static int __attribute__((used)) ignore_transparent_context;
> +// CHECK-DAG: @ignore_transparent_context
> +}
> +
>  namespace N {
>int b;
>  // CHECK-DAG: @"\01?b@N@@3HA"
>
>
> ___
> 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] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

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

In http://reviews.llvm.org/D20407#433915, @rjmccall wrote:

> _Atomic is functionally a type qualifier and should be removed in Sema when 
> computing the result type of the getter and the parameter type of the setter. 
>  That is, if the user declares a property of type _Atomic(_Bool), we should 
> pretend that the property has type _Bool when creating the getter and setter.


That sounds like a more principled way to fix the problem. We'll have to remove 
_Atomic from return types of normal functions too, not just objective-c getters 
and setters, because otherwise programs like this won't compile:

  _Atomic(_Bool) foo1() {
A *a = [A new];
return a.p;
  }


http://reviews.llvm.org/D20407



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


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

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

Sorry for the delay, this all LGTM. Do you need someone to commit it for you?



Comment at: lib/Sema/SemaTemplate.cpp:2082-2085
@@ +2081,6 @@
+// If the Index is out of bounds, the program is ill-formed.
+//
+// TODO:
+// This is not actually mandated by the standard, of course, so does it
+// have its place here?
+TemplateArgument IndexArg = Converted[0], Ts = Converted[1];

This is fine; we get to specify how our extensions work, so we can say that an 
`Index` that's out of bounds is ill-formed.


http://reviews.llvm.org/D15421



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


Re: [PATCH] D20457: Update -ffast-math documentation to match reality.

2016-05-19 Thread Richard Smith via cfe-commits
On Thu, May 19, 2016 at 6:11 PM, Justin Lebar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> jlebar created this revision.
> jlebar added a reviewer: rsmith.
> jlebar added a subscriber: cfe-commits.
>
> http://reviews.llvm.org/D20457
>
> Files:
>   include/clang/Basic/LangOptions.def
>   include/clang/Driver/Options.td
>
> Index: include/clang/Driver/Options.td
> ===
> --- include/clang/Driver/Options.td
> +++ include/clang/Driver/Options.td
> @@ -592,9 +592,13 @@
>  def : Flag<["-"], "fno-extended-identifiers">, Group,
> Flags<[Unsupported]>;
>  def fhosted : Flag<["-"], "fhosted">, Group;
>  def ffast_math : Flag<["-"], "ffast-math">, Group,
> Flags<[CC1Option]>,
> -  HelpText<"Enable the *frontend*'s 'fast-math' mode. This has no effect
> on "
> -   "optimizations, but provides a preprocessor macro
> __FAST_MATH__ the "
> -   "same as GCC's -ffast-math flag">;
> +  HelpText<"Enable fast-math mode. This defines the __FAST_MATH__
> preprocessor "
> +   "macro, and lets the compiler make aggressive, potentially
> unsafe "
> +   "assumptions about floating-point math.  These include: "
> +   "Floating-point math obeys regular algebraic rules for real "
> +   "numbers (e.g. + and * are associative, and x/y == x * (1/y)),
> "
> +   "operands to fp operations are not equal to NaN and Inf, and
> +0 "
> +   "and -0 are interchangeable.">;
>

This is significantly too long for HelpText. The current help text for this
flag is already too long:

$ clang --help
[...]
  -fembed-bitcode Embed LLVM IR bitcode as data
  -femit-all-declsEmit all declarations, even if unused
  -femulated-tls  Use emutls functions to access thread_local
variables
  -fexceptionsEnable support for exception handling
  -ffast-math Enable the *frontend*'s 'fast-math' mode. This
has no effect on optimizations, but provides a preprocessor macro
__FAST_MATH__ the same as GCC's -ffast-math flag
  -ffixed-r9  Reserve the r9 register (ARM only)
  -ffixed-x18 Reserve the x18 register (AArch64 only)
[...]

Can you move this to UsersManual.rst instead, and put something short here
instead, like "Allow aggressive, lossy floating-point optimizations"?

 def fno_fast_math : Flag<["-"], "fno-fast-math">, Group;
>  def fmath_errno : Flag<["-"], "fmath-errno">, Group,
> Flags<[CC1Option]>,
>HelpText<"Require math functions to indicate errors by setting errno">;
> Index: include/clang/Basic/LangOptions.def
> ===
> --- include/clang/Basic/LangOptions.def
> +++ include/clang/Basic/LangOptions.def
> @@ -162,7 +162,7 @@
>  COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
>  COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined
> macro")
>  COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined
> macro")
> -COMPATIBLE_LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined
> macro")
> +COMPATIBLE_LANGOPT(FastMath  , 1, 0, "Fast fp math optimizations,
> and __FAST_MATH__ predefined macro")
>

Something like "fast FP math [...]" would fit better into the diagnostics
where this appears.


>  COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__
> predefined macro")
>  COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
>
>
>
>
> ___
> 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


r270169 - Revert incorrect module map changes in r269907 and replace them with the

2016-05-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May 19 20:06:47 2016
New Revision: 270169

URL: http://llvm.org/viewvc/llvm-project?rev=270169=rev
Log:
Revert incorrect module map changes in r269907 and replace them with the
appropriate changes.

Modified:
cfe/trunk/lib/Headers/module.modulemap

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=270169=270168=270169=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Thu May 19 20:06:47 2016
@@ -60,6 +60,7 @@ module _Builtin_intrinsics [system] [ext
 textual header "lzcntintrin.h"
 textual header "xopintrin.h"
 textual header "fma4intrin.h"
+textual header "mwaitxintrin.h"
 
 explicit module mm_malloc {
   header "mm_malloc.h"
@@ -125,10 +126,6 @@ module _Builtin_intrinsics [system] [ext
   export pclmul
 }
 
-explicit module mwaitx {
-  header "mwaitxintrin.h"
-}
-
 explicit module aes {
   header "__wmmintrin_aes.h"
 }


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


r270170 - Re-alphabetize this file list.

2016-05-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May 19 20:07:10 2016
New Revision: 270170

URL: http://llvm.org/viewvc/llvm-project?rev=270170=rev
Log:
Re-alphabetize this file list.

Modified:
cfe/trunk/lib/Headers/CMakeLists.txt

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=270170=270169=270170=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Thu May 19 20:07:10 2016
@@ -6,17 +6,18 @@ set(files
   avx2intrin.h
   avx512bwintrin.h
   avx512cdintrin.h
+  avx512dqintrin.h
   avx512erintrin.h
   avx512fintrin.h
+  avx512ifmaintrin.h
+  avx512ifmavlintrin.h
   avx512pfintrin.h
+  avx512vbmiintrin.h
+  avx512vbmivlintrin.h
   avx512vlbwintrin.h
-  avx512vlintrin.h
   avx512vlcdintrin.h
-  avx512dqintrin.h
   avx512vldqintrin.h
-  avx512vbmiintrin.h
-  avx512vbmivlintrin.h
-  pkuintrin.h
+  avx512vlintrin.h
   avxintrin.h
   bmi2intrin.h
   bmiintrin.h
@@ -45,7 +46,9 @@ set(files
   mmintrin.h
   mm_malloc.h
   module.modulemap
+  mwaitxintrin.h
   nmmintrin.h
+  pkuintrin.h
   pmmintrin.h
   popcntintrin.h
   prfchwintrin.h
@@ -69,20 +72,17 @@ set(files
   vadefs.h
   varargs.h
   vecintrin.h
-  __wmmintrin_aes.h
   wmmintrin.h
+  __wmmintrin_aes.h
   __wmmintrin_pclmul.h
   x86intrin.h
   xmmintrin.h
   xopintrin.h
+  xsavecintrin.h
   xsaveintrin.h
   xsaveoptintrin.h
-  xsavecintrin.h
   xsavesintrin.h
-  mwaitxintrin.h
   xtestintrin.h
-  avx512ifmaintrin.h
-  avx512ifmavlintrin.h
   )
 
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)


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


Re: r269907 - Add new intrinsic support for MONITORX and MWAITX instructions

2016-05-19 Thread Richard Smith via cfe-commits
Fixed in r270169.

On Thu, May 19, 2016 at 2:13 PM, Richard Smith 
wrote:

> The modules buildbot has been broken since this commit landed:
>
>
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/15761/steps/compile.llvm.stage2/logs/stdio
>
> Please fix or revert.
>
> On Wed, May 18, 2016 at 4:56 AM, Ashutosh Nema via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ashutosh
>> Date: Wed May 18 06:56:23 2016
>> New Revision: 269907
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269907=rev
>> Log:
>> Add new intrinsic support for MONITORX and MWAITX instructions
>>
>> Summary:
>> MONITORX/MWAITX instructions provide similar capability to the
>> MONITOR/MWAIT
>> pair while adding a timer function, such that another termination of the
>> MWAITX
>> instruction occurs when the timer expires. The presence of the MONITORX
>> and
>> MWAITX instructions is indicated by CPUID 8000_0001, ECX, bit 29.
>>
>> The MONITORX and MWAITX instructions are intercepted by the same bits that
>> intercept MONITOR and MWAIT. MONITORX instruction establishes a range to
>> be
>> monitored. MWAITX instruction causes the processor to stop instruction
>> execution and enter an implementation-dependent optimized state until
>> occurrence of a class of events.
>>
>> Opcode of MONITORX instruction is "0F 01 FA". Opcode of MWAITX
>> instruction is
>> "0F 01 FB". These opcode information is used in adding tests for the
>> disassembler.
>>
>> These instructions are enabled for AMD's bdver4 architecture.
>>
>> Patch by Ganesh Gopalasubramanian!
>>
>> Reviewers: echristo, craig.topper
>>
>> Subscribers: RKSimon, joker.eph, llvm-commits, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D19796
>>
>> Added:
>> cfe/trunk/lib/Headers/mwaitxintrin.h
>> Modified:
>> cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/Basic/Targets.cpp
>> cfe/trunk/lib/Headers/CMakeLists.txt
>> cfe/trunk/lib/Headers/module.modulemap
>> cfe/trunk/lib/Headers/x86intrin.h
>> cfe/trunk/test/CodeGen/builtins-x86.c
>>
>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269907=269906=269907=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May 18 06:56:23 2016
>> @@ -2272,5 +2272,9 @@ TARGET_BUILTIN(__builtin_ia32_cvtusi2sd6
>>  TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")
>>  TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fULLiIi","","avx512f")
>>
>> +// MONITORX/MWAITX
>> +TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
>> +TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
>> +
>>  #undef BUILTIN
>>  #undef TARGET_BUILTIN
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269907=269906=269907=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Wed May 18 06:56:23 2016
>> @@ -1425,6 +1425,7 @@ def mno_xsave : Flag<["-"], "mno-xsave">
>>  def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">,
>> Group;
>>  def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
>>  def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
>> +def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
>>  def mno_pku : Flag<["-"], "mno-pku">, Group;
>>
>>  def munaligned_access : Flag<["-"], "munaligned-access">,
>> Group,
>> @@ -1610,6 +1611,7 @@ def mxsave : Flag<["-"], "mxsave">, Grou
>>  def mxsaveopt : Flag<["-"], "mxsaveopt">, Group;
>>  def mxsavec : Flag<["-"], "mxsavec">, Group;
>>  def mxsaves : Flag<["-"], "mxsaves">, Group;
>> +def mmwaitx : Flag<["-"], "mmwaitx">, Group;
>>  def mips16 : Flag<["-"], "mips16">, Group;
>>  def mno_mips16 : Flag<["-"], "mno-mips16">, Group;
>>  def mmicromips : Flag<["-"], "mmicromips">, Group;
>>
>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=269907=269906=269907=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets.cpp Wed May 18 06:56:23 2016
>> @@ -2273,6 +2273,7 @@ class X86TargetInfo : public TargetInfo
>>bool HasXSAVEOPT = false;
>>bool HasXSAVEC = false;
>>bool HasXSAVES = false;
>> +  bool HasMWAITX = false;
>>bool HasPKU = false;
>>bool HasCLFLUSHOPT = false;
>>bool HasPCOMMIT = false;
>> @@ -2947,6 +2948,7 @@ bool X86TargetInfo::initFeatureMap(
>>case CK_BDVER4:
>>  setFeatureEnabledImpl(Features, "avx2", 

[PATCH] D20457: Update -ffast-math documentation to match reality.

2016-05-19 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added a subscriber: cfe-commits.

http://reviews.llvm.org/D20457

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -592,9 +592,13 @@
 def : Flag<["-"], "fno-extended-identifiers">, Group, 
Flags<[Unsupported]>;
 def fhosted : Flag<["-"], "fhosted">, Group;
 def ffast_math : Flag<["-"], "ffast-math">, Group, Flags<[CC1Option]>,
-  HelpText<"Enable the *frontend*'s 'fast-math' mode. This has no effect on "
-   "optimizations, but provides a preprocessor macro __FAST_MATH__ the 
"
-   "same as GCC's -ffast-math flag">;
+  HelpText<"Enable fast-math mode. This defines the __FAST_MATH__ preprocessor 
"
+   "macro, and lets the compiler make aggressive, potentially unsafe "
+   "assumptions about floating-point math.  These include: "
+   "Floating-point math obeys regular algebraic rules for real "
+   "numbers (e.g. + and * are associative, and x/y == x * (1/y)), "
+   "operands to fp operations are not equal to NaN and Inf, and +0 "
+   "and -0 are interchangeable.">;
 def fno_fast_math : Flag<["-"], "fno-fast-math">, Group;
 def fmath_errno : Flag<["-"], "fmath-errno">, Group, 
Flags<[CC1Option]>,
   HelpText<"Require math functions to indicate errors by setting errno">;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -162,7 +162,7 @@
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined macro")
+COMPATIBLE_LANGOPT(FastMath  , 1, 0, "Fast fp math optimizations, and 
__FAST_MATH__ predefined macro")
 COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")
 COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
 


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -592,9 +592,13 @@
 def : Flag<["-"], "fno-extended-identifiers">, Group, Flags<[Unsupported]>;
 def fhosted : Flag<["-"], "fhosted">, Group;
 def ffast_math : Flag<["-"], "ffast-math">, Group, Flags<[CC1Option]>,
-  HelpText<"Enable the *frontend*'s 'fast-math' mode. This has no effect on "
-   "optimizations, but provides a preprocessor macro __FAST_MATH__ the "
-   "same as GCC's -ffast-math flag">;
+  HelpText<"Enable fast-math mode. This defines the __FAST_MATH__ preprocessor "
+   "macro, and lets the compiler make aggressive, potentially unsafe "
+   "assumptions about floating-point math.  These include: "
+   "Floating-point math obeys regular algebraic rules for real "
+   "numbers (e.g. + and * are associative, and x/y == x * (1/y)), "
+   "operands to fp operations are not equal to NaN and Inf, and +0 "
+   "and -0 are interchangeable.">;
 def fno_fast_math : Flag<["-"], "fno-fast-math">, Group;
 def fmath_errno : Flag<["-"], "fmath-errno">, Group, Flags<[CC1Option]>,
   HelpText<"Require math functions to indicate errors by setting errno">;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -162,7 +162,7 @@
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined macro")
+COMPATIBLE_LANGOPT(FastMath  , 1, 0, "Fast fp math optimizations, and __FAST_MATH__ predefined macro")
 COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined macro")
 COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270164 - Avoid depending on test inputes that aren't in Inputs

2016-05-19 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu May 19 19:38:25 2016
New Revision: 270164

URL: http://llvm.org/viewvc/llvm-project?rev=270164=rev
Log:
Avoid depending on test inputes that aren't in Inputs

Some people have weird CI systems that run each test subdirectory
independently without access to other parallel trees.

Unfortunately, this means we have to suffer some duplication until Art
can sort out how to share these types.

Added:
cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h
cfe/trunk/test/SemaCUDA/Inputs/cuda-initializers.h
Modified:
cfe/trunk/test/CodeGenCUDA/device-var-init.cu
cfe/trunk/test/SemaCUDA/device-var-init.cu

Added: cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h?rev=270164=auto
==
--- cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h (added)
+++ cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h Thu May 19 19:38:25 
2016
@@ -0,0 +1,145 @@
+// CUDA struct types with interesting initialization properties.
+// Keep in sync with ../SemaCUDA/Inputs/cuda-initializers.h.
+
+// Base classes with different initializer variants.
+
+// trivial constructor -- allowed
+struct T {
+  int t;
+};
+
+// empty constructor
+struct EC {
+  int ec;
+  __device__ EC() {} // -- allowed
+  __device__ EC(int) {}  // -- not allowed
+};
+
+// empty destructor
+struct ED {
+  __device__ ~ED() {} // -- allowed
+};
+
+struct ECD {
+  __device__ ECD() {} // -- allowed
+  __device__ ~ECD() {}// -- allowed
+};
+
+// empty templated constructor -- allowed with no arguments
+struct ETC {
+  template  __device__ ETC(T...) {}
+};
+
+// undefined constructor -- not allowed
+struct UC {
+  int uc;
+  __device__ UC();
+};
+
+// undefined destructor -- not allowed
+struct UD {
+  int ud;
+  __device__ ~UD();
+};
+
+// empty constructor w/ initializer list -- not allowed
+struct ECI {
+  int eci;
+  __device__ ECI() : eci(1) {}
+};
+
+// non-empty constructor -- not allowed
+struct NEC {
+  int nec;
+  __device__ NEC() { nec = 1; }
+};
+
+// non-empty destructor -- not allowed
+struct NED {
+  int ned;
+  __device__ ~NED() { ned = 1; }
+};
+
+// no-constructor,  virtual method -- not allowed
+struct NCV {
+  int ncv;
+  __device__ virtual void vm() {}
+};
+
+// virtual destructor -- not allowed.
+struct VD {
+  __device__ virtual ~VD() {}
+};
+
+// dynamic in-class field initializer -- not allowed
+__device__ int f();
+struct NCF {
+  int ncf = f();
+};
+
+// static in-class field initializer.  NVCC does not allow it, but
+// clang generates static initializer for this, so we'll accept it.
+// We still can't use it on __shared__ vars as they don't allow *any*
+// initializers.
+struct NCFS {
+  int ncfs = 3;
+};
+
+// undefined templated constructor -- not allowed
+struct UTC {
+  template  __device__ UTC(T...);
+};
+
+// non-empty templated constructor -- not allowed
+struct NETC {
+  int netc;
+  template  __device__ NETC(T...) { netc = 1; }
+};
+
+// Regular base class -- allowed
+struct T_B_T : T {};
+
+// Incapsulated object of allowed class -- allowed
+struct T_F_T {
+  T t;
+};
+
+// array of allowed objects -- allowed
+struct T_FA_T {
+  T t[2];
+};
+
+
+// Calling empty base class initializer is OK
+struct EC_I_EC : EC {
+  __device__ EC_I_EC() : EC() {}
+};
+
+// .. though passing arguments is not allowed.
+struct EC_I_EC1 : EC {
+  __device__ EC_I_EC1() : EC(1) {}
+};
+
+// Virtual base class -- not allowed
+struct T_V_T : virtual T {};
+
+// Inherited from or incapsulated class with non-empty constructor --
+// not allowed
+struct T_B_NEC : NEC {};
+struct T_F_NEC {
+  NEC nec;
+};
+struct T_FA_NEC {
+  NEC nec[2];
+};
+
+
+// Inherited from or incapsulated class with non-empty desstructor --
+// not allowed
+struct T_B_NED : NED {};
+struct T_F_NED {
+  NED ned;
+};
+struct T_FA_NED {
+  NED ned[2];
+};

Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=270164=270163=270164=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Thu May 19 19:38:25 2016
@@ -10,100 +10,8 @@
 #include "Inputs/cuda.h"
 #endif
 
-// Base classes with different initializer variants.
-
-// trivial constructor -- allowed
-struct T {
-  int t;
-};
-
-// empty constructor
-struct EC {
-  int ec;
-  __device__ EC() {} // -- allowed
-  __device__ EC(int) {}  // -- not allowed
-};
-
-// empty destructor
-struct ED {
-  __device__ ~ED() {} // -- allowed
-};
-
-struct ECD {
-  __device__ ECD() {} // -- allowed
-  __device__ ~ECD() {}// -- allowed
-};
-
-// empty templated constructor -- allowed with no arguments
-struct ETC {
-  template  __device__ ETC(T...) {}
-};
-
-// undefined constructor 

Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-05-19 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

Thanks for this! Sorry for the delay on the review side. Generally, the 
approach here looks fine, and I don't have any high-level concerns beyond a 
performance concern over whatever dark magic you're doing on the LLVM side to 
get this filename.

Please add some tests for the `FixItHint` replacement text. See test/FixIt for 
examples of how to do this.

I've left a handful of mostly-stylistic comments inline.



Comment at: include/clang/Basic/DiagnosticLexKinds.td:278
@@ +277,3 @@
+def pp_nonportable_path : Warning<
+  "Non-portable path '%0' found in preprocessor directive.">,
+  InGroup;

Diagnostics should start with a lowercase letter and not end in a period.


Comment at: lib/Lex/PPDirectives.cpp:1503-1504
@@ -1499,1 +1502,4 @@
 
+namespace
+{
+  // Given a vector of path components and a string containing the real

`{` on previous line, please.


Comment at: lib/Lex/PPDirectives.cpp:1508
@@ +1507,3 @@
+  // and return true if the replacement should be suggested.
+  bool TrySimplifyPath(SmallVectorImpl& Components,
+   StringRef RealPathName) {

`&` on the right.


Comment at: lib/Lex/PPDirectives.cpp:1510-1511
@@ +1509,4 @@
+   StringRef RealPathName) {
+auto iRealPathComponent = llvm::sys::path::rbegin(RealPathName);
+auto iRealPathComponentEnd = llvm::sys::path::rend(RealPathName);
+int Cnt = 0;

Local variable names should start with an uppercase letter.


Comment at: lib/Lex/PPDirectives.cpp:1514
@@ +1513,3 @@
+bool SuggestReplacement = false;
+for(auto& Component : llvm::reverse(Components)) {
+  if ("." == Component) {

`&` on the right.


Comment at: lib/Lex/PPDirectives.cpp:1516-1519
@@ +1515,6 @@
+  if ("." == Component) {
+  } else if (".." == Component) {
+++Cnt;
+  } else if (Cnt) {
+--Cnt;
+  } else if (iRealPathComponent != iRealPathComponentEnd) {

Hmm. A `..` doesn't necessarily remove the prior path component, especially in 
the presence of directory symlinks. I suspect it's not worth the trouble of 
trying to get this right, but a comment saying that this is a best-effort 
attempt to handle `..`s would be useful.


Comment at: lib/Lex/PPDirectives.cpp:1704-1705
@@ +1703,4 @@
+  //
+  // Because testing for non-portable paths is expensive, only do it if the
+  // warning is not currently ignored.
+  const bool CheckIncludePathPortability =

Checking whether a warning is enabled can be surprisingly expensive; 
`TrySimplifyPath` might actually be cheaper.


Comment at: test/Lexer/case-insensitive-include.c:4
@@ +3,3 @@
+// RUN: mkdir -p %T/apath
+// RUN: cp %S/Inputs/case-insensitive-include.h %T
+// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify

Please explicitly `cd` to somewhere around `%T` here rather than assuming you 
know where it is relative to the current directory; we do not guarantee which 
directory the test will be run from and it does differ in practice between 
different ways of running the tests.


Comment at: test/Lexer/case-insensitive-include.c:8-11
@@ +7,6 @@
+// RUN: cp %S/Inputs/case-insensitive-include.h %T
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -DMS_COMPATIBILITY %s 
-include %s -I %T -verify
+
+#ifndef HEADER
+#define HEADER
+

What's the reason for this test including this file twice?


http://reviews.llvm.org/D19843



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


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

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

LG with a couple of nits.



Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:22
@@ +21,3 @@
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class

`ShouldCheckDecl` might convey the idea better.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:59
@@ -59,1 +58,3 @@
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();

It's not iterator, so `It` is a confusing name. Something along the lines of 
`Shadow` or `UsingShadow` should be better.


http://reviews.llvm.org/D20429



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


Re: [PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270160: [Lexer] Don't merge macro args from different macro 
files (authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D20401?vs=57810=57880#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20401

Files:
  cfe/trunk/lib/Lex/TokenLexer.cpp
  cfe/trunk/test/CoverageMapping/Inputs/macros.h
  cfe/trunk/test/CoverageMapping/include-macros.c
  cfe/trunk/unittests/Lex/LexerTest.cpp

Index: cfe/trunk/test/CoverageMapping/Inputs/macros.h
===
--- cfe/trunk/test/CoverageMapping/Inputs/macros.h
+++ cfe/trunk/test/CoverageMapping/Inputs/macros.h
@@ -0,0 +1,13 @@
+// Assorted macros to help test #include behavior across file boundaries.
+
+#define helper1 0
+
+void helper2(const char *, ...);
+
+#define M1(a, ...) helper2(a, ##__VA_ARGS__);
+
+// Note: M2 stresses vararg macro functions with macro arguments. The spelling
+// locations of the args used to be set to the expansion site, leading to
+// crashes (region LineEnd < LineStart). The regression test requires M2's line
+// number to be greater than the line number containing the expansion.
+#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__);
Index: cfe/trunk/test/CoverageMapping/include-macros.c
===
--- cfe/trunk/test/CoverageMapping/include-macros.c
+++ cfe/trunk/test/CoverageMapping/include-macros.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name include-macros.c %s | FileCheck %s
+
+#include "Inputs/macros.h"
+
+void f1() {
+  M2("a", "b");
+}
+
+// CHECK-LABEL: f1:
+// CHECK-NEXT:   File 0, 5:11 -> 7:2 = #0
+// CHECK-NEXT:   Expansion,File 0, 6:3 -> 6:5 = #0 (Expanded file = 1)
+// CHECK-NEXT:   File 1, 13:20 -> 13:50 = #0
+// CHECK-NEXT:   Expansion,File 1, 13:20 -> 13:22 = #0 (Expanded file = 2)
+// CHECK-NEXT:   File 2, 7:20 -> 7:46 = #0
+// CHECK-NEXT:   Expansion,File 2, 7:33 -> 7:44 = #0 (Expanded file = 3)
+// CHECK-NEXT:   File 3, 13:26 -> 13:34 = #0
+// CHECK-NEXT:   Expansion,File 3, 13:26 -> 13:33 = #0 (Expanded file = 4)
+// CHECK-NEXT:   File 4, 3:17 -> 3:18 = #0
Index: cfe/trunk/lib/Lex/TokenLexer.cpp
===
--- cfe/trunk/lib/Lex/TokenLexer.cpp
+++ cfe/trunk/lib/Lex/TokenLexer.cpp
@@ -787,6 +787,9 @@
 if (CurLoc.isFileID() != NextLoc.isFileID())
   break; // Token from different kind of FileID.
 
+if (CurLoc.isMacroID() && !SM.isWrittenInSameFile(CurLoc, NextLoc))
+  break; // Token from a different macro.
+
 int RelOffs;
 if (!SM.isInSameSLocAddrSpace(CurLoc, NextLoc, ))
   break; // Token from different local/loaded location.
Index: cfe/trunk/unittests/Lex/LexerTest.cpp
===
--- cfe/trunk/unittests/Lex/LexerTest.cpp
+++ cfe/trunk/unittests/Lex/LexerTest.cpp
@@ -58,8 +58,7 @@
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  std::vector CheckLex(StringRef Source,
-  ArrayRef ExpectedTokens) {
+  std::vector Lex(StringRef Source) {
 std::unique_ptr Buf =
 llvm::MemoryBuffer::getMemBuffer(Source);
 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
@@ -82,6 +81,12 @@
   toks.push_back(tok);
 }
 
+return toks;
+  }
+
+  std::vector CheckLex(StringRef Source,
+  ArrayRef ExpectedTokens) {
+auto toks = Lex(Source);
 EXPECT_EQ(ExpectedTokens.size(), toks.size());
 for (unsigned i = 0, e = ExpectedTokens.size(); i != e; ++i) {
   EXPECT_EQ(ExpectedTokens[i], toks[i].getKind());
@@ -358,4 +363,21 @@
   EXPECT_EQ("N", Lexer::getImmediateMacroName(idLoc4, SourceMgr, LangOpts));
 }
 
+TEST_F(LexerTest, DontMergeMacroArgsFromDifferentMacroFiles) {
+  std::vector toks =
+  Lex("#define helper1 0\n"
+  "void helper2(const char *, ...);\n"
+  "#define M1(a, ...) helper2(a, ##__VA_ARGS__)\n"
+  "#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__)\n"
+  "void f1() { M2(\"a\", \"b\"); }");
+
+  // Check the file corresponding to the "helper1" macro arg in M2.
+  //
+  // The lexer used to report its size as 31, meaning that the end of the
+  // expansion would be on the *next line* (just past `M2("a", "b")`). Make
+  // sure that we get the correct end location (the comma after "helper1").
+  SourceLocation helper1ArgLoc = toks[20].getLocation();
+  EXPECT_EQ(SourceMgr.getFileIDSize(SourceMgr.getFileID(helper1ArgLoc)), 8U);
+}
+
 } // anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270160 - [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu May 19 18:44:02 2016
New Revision: 270160

URL: http://llvm.org/viewvc/llvm-project?rev=270160=rev
Log:
[Lexer] Don't merge macro args from different macro files

The lexer sets the end location of macro arguments incorrectly *if*,
while merging consecutive args to fit into a single SLocEntry, it finds
args which come from different macro files.

Fix the issue by using separate SLocEntries in this situation.

This fixes a code coverage crasher (rdar://problem/26181005). Because
the lexer reported end locations for certain macro args incorrectly, we
would generate bogus coverage mappings with negative line offsets.

Reviewed-by: akyrtzi

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

Added:
cfe/trunk/test/CoverageMapping/Inputs/macros.h
cfe/trunk/test/CoverageMapping/include-macros.c
Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=270160=270159=270160=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Thu May 19 18:44:02 2016
@@ -787,6 +787,9 @@ static void updateConsecutiveMacroArgTok
 if (CurLoc.isFileID() != NextLoc.isFileID())
   break; // Token from different kind of FileID.
 
+if (CurLoc.isMacroID() && !SM.isWrittenInSameFile(CurLoc, NextLoc))
+  break; // Token from a different macro.
+
 int RelOffs;
 if (!SM.isInSameSLocAddrSpace(CurLoc, NextLoc, ))
   break; // Token from different local/loaded location.

Added: cfe/trunk/test/CoverageMapping/Inputs/macros.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/Inputs/macros.h?rev=270160=auto
==
--- cfe/trunk/test/CoverageMapping/Inputs/macros.h (added)
+++ cfe/trunk/test/CoverageMapping/Inputs/macros.h Thu May 19 18:44:02 2016
@@ -0,0 +1,13 @@
+// Assorted macros to help test #include behavior across file boundaries.
+
+#define helper1 0
+
+void helper2(const char *, ...);
+
+#define M1(a, ...) helper2(a, ##__VA_ARGS__);
+
+// Note: M2 stresses vararg macro functions with macro arguments. The spelling
+// locations of the args used to be set to the expansion site, leading to
+// crashes (region LineEnd < LineStart). The regression test requires M2's line
+// number to be greater than the line number containing the expansion.
+#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__);

Added: cfe/trunk/test/CoverageMapping/include-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/include-macros.c?rev=270160=auto
==
--- cfe/trunk/test/CoverageMapping/include-macros.c (added)
+++ cfe/trunk/test/CoverageMapping/include-macros.c Thu May 19 18:44:02 2016
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name include-macros.c %s | 
FileCheck %s
+
+#include "Inputs/macros.h"
+
+void f1() {
+  M2("a", "b");
+}
+
+// CHECK-LABEL: f1:
+// CHECK-NEXT:   File 0, 5:11 -> 7:2 = #0
+// CHECK-NEXT:   Expansion,File 0, 6:3 -> 6:5 = #0 (Expanded file = 1)
+// CHECK-NEXT:   File 1, 13:20 -> 13:50 = #0
+// CHECK-NEXT:   Expansion,File 1, 13:20 -> 13:22 = #0 (Expanded file = 2)
+// CHECK-NEXT:   File 2, 7:20 -> 7:46 = #0
+// CHECK-NEXT:   Expansion,File 2, 7:33 -> 7:44 = #0 (Expanded file = 3)
+// CHECK-NEXT:   File 3, 13:26 -> 13:34 = #0
+// CHECK-NEXT:   Expansion,File 3, 13:26 -> 13:33 = #0 (Expanded file = 4)
+// CHECK-NEXT:   File 4, 3:17 -> 3:18 = #0

Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=270160=270159=270160=diff
==
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Thu May 19 18:44:02 2016
@@ -58,8 +58,7 @@ protected:
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  std::vector CheckLex(StringRef Source,
-  ArrayRef ExpectedTokens) {
+  std::vector Lex(StringRef Source) {
 std::unique_ptr Buf =
 llvm::MemoryBuffer::getMemBuffer(Source);
 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
@@ -82,6 +81,12 @@ protected:
   toks.push_back(tok);
 }
 
+return toks;
+  }
+
+  std::vector CheckLex(StringRef Source,
+  ArrayRef ExpectedTokens) {
+auto toks = Lex(Source);
 EXPECT_EQ(ExpectedTokens.size(), toks.size());
 for (unsigned i = 0, e = ExpectedTokens.size(); i != e; ++i) {
   EXPECT_EQ(ExpectedTokens[i], toks[i].getKind());
@@ -358,4 +363,21 @@ TEST_F(LexerTest, LexAPI) {
   EXPECT_EQ("N", 

r270154 - [analyzer] Fix for PR23790 : constrain return value of strcmp() rather than returning a concrete value.

2016-05-19 Thread Anton Yartsev via cfe-commits
Author: ayartsev
Date: Thu May 19 18:03:49 2016
New Revision: 270154

URL: http://llvm.org/viewvc/llvm-project?rev=270154=rev
Log:
[analyzer] Fix for PR23790 : constrain return value of strcmp() rather than 
returning a concrete value.

The function strcmp() can return any value, not just {-1,0,1} : "The 
strcmp(const char *s1, const char *s2) function returns an integer greater 
than, equal to, or less than zero, accordingly as the string pointed to by s1 
is greater than, equal to, or less than the string pointed to by s2." [C11 
7.24.4.2p3]
https://llvm.org/bugs/show_bug.cgi?id=23790
http://reviews.llvm.org/D16317

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/test/Analysis/string.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=270154=270153=270154=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Thu May 19 
18:03:49 2016
@@ -1837,6 +1837,8 @@ void CStringChecker::evalStrcmpCommon(Ch
   const StringLiteral *s1StrLiteral = getCStringLiteral(C, state, s1, s1Val);
   const StringLiteral *s2StrLiteral = getCStringLiteral(C, state, s2, s2Val);
   bool canComputeResult = false;
+  SVal resultVal = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx,
+C.blockCount());
 
   if (s1StrLiteral && s2StrLiteral) {
 StringRef s1StrRef = s1StrLiteral->getString();
@@ -1870,28 +1872,29 @@ void CStringChecker::evalStrcmpCommon(Ch
 s2StrRef = s2StrRef.substr(0, s2Term);
 
   // Use StringRef's comparison methods to compute the actual result.
-  int result;
+  int compareRes = ignoreCase ? s1StrRef.compare_lower(s2StrRef)
+  : s1StrRef.compare(s2StrRef);
 
-  if (ignoreCase) {
-// Compare string 1 to string 2 the same way strcasecmp() does.
-result = s1StrRef.compare_lower(s2StrRef);
-  } else {
-// Compare string 1 to string 2 the same way strcmp() does.
-result = s1StrRef.compare(s2StrRef);
+  // The strcmp function returns an integer greater than, equal to, or less
+  // than zero, [c11, p7.24.4.2].
+  if (compareRes == 0) {
+resultVal = svalBuilder.makeIntVal(compareRes, CE->getType());
+  }
+  else {
+DefinedSVal zeroVal = svalBuilder.makeIntVal(0, CE->getType());
+// Constrain strcmp's result range based on the result of StringRef's
+// comparison methods.
+BinaryOperatorKind op = (compareRes == 1) ? BO_GT : BO_LT;
+SVal compareWithZero =
+  svalBuilder.evalBinOp(state, op, resultVal, zeroVal,
+svalBuilder.getConditionType());
+DefinedSVal compareWithZeroVal = compareWithZero.castAs();
+state = state->assume(compareWithZeroVal, true);
   }
-
-  // Build the SVal of the comparison and bind the return value.
-  SVal resultVal = svalBuilder.makeIntVal(result, CE->getType());
-  state = state->BindExpr(CE, LCtx, resultVal);
 }
   }
 
-  if (!canComputeResult) {
-// Conjure a symbolic value. It's the best we can do.
-SVal resultVal = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx,
-  C.blockCount());
-state = state->BindExpr(CE, LCtx, resultVal);
-  }
+  state = state->BindExpr(CE, LCtx, resultVal);
 
   // Record this as a possible path.
   C.addTransition(state);

Modified: cfe/trunk/test/Analysis/string.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/string.c?rev=270154=270153=270154=diff
==
--- cfe/trunk/test/Analysis/string.c (original)
+++ cfe/trunk/test/Analysis/string.c Thu May 19 18:03:49 2016
@@ -680,6 +680,18 @@ void strncat_empty() {
 #define strcmp BUILTIN(strcmp)
 int strcmp(const char * s1, const char * s2);
 
+void strcmp_check_modelling() {
+  char *x = "aa";
+  char *y = "a";
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) <= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strcmp(x, y) > 1); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(strcmp(y, x) < 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(y, x) >= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strcmp(y, x) < -1); // expected-warning{{UNKNOWN}}
+}
+
 void strcmp_constant0() {
   clang_analyzer_eval(strcmp("123", "123") == 0); // expected-warning{{TRUE}}
 }
@@ -703,13 +715,13 @@ void strcmp_0() {
 void strcmp_1() {
   char *x = "234";
   char *y = "123";
-  clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) > 0); // 

Re: [PATCH] D20454: Eliminate unnecessary file access checks in Clang driver on Windows

2016-05-19 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20454



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


[PATCH] D20454: Eliminate unnecessary file access checks in Clang driver on Windows

2016-05-19 Thread Adrian McCarthy via cfe-commits
amccarth created this revision.
amccarth added a reviewer: majnemer.
amccarth added a subscriber: cfe-commits.

This fixes the problem where the driver will look for cl.exe.exe while walking 
the PATH.

I looked into changing the Windows implementation of 
llvm::sys::fs::can_execute(), but there wasn't a satisfying way to preserve the 
extra checks for the callers that depend on it.  I also looked into having it 
actually check that the file is an executable, but this seemed to add little 
value at the cost of more file i/o.

http://reviews.llvm.org/D20454

Files:
  lib/Driver/MSVCToolChain.cpp

Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -408,7 +408,10 @@
 
 SmallString<128> FilePath(PathSegment);
 llvm::sys::path::append(FilePath, "cl.exe");
-if (llvm::sys::fs::can_execute(FilePath.c_str()) &&
+// Checking if cl.exe exists is a small optimization over calling
+// can_execute, which really only checks for existence but will also do
+// extra checks for cl.exe.exe.  These add up when walking a long path.
+if (llvm::sys::fs::exists(FilePath.c_str()) &&
 !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) {
   // If we found it on the PATH, use it exactly as is with no
   // modifications.


Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -408,7 +408,10 @@
 
 SmallString<128> FilePath(PathSegment);
 llvm::sys::path::append(FilePath, "cl.exe");
-if (llvm::sys::fs::can_execute(FilePath.c_str()) &&
+// Checking if cl.exe exists is a small optimization over calling
+// can_execute, which really only checks for existence but will also do
+// extra checks for cl.exe.exe.  These add up when walking a long path.
+if (llvm::sys::fs::exists(FilePath.c_str()) &&
 !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) {
   // If we found it on the PATH, use it exactly as is with no
   // modifications.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-19 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270150: [CUDA] Implement __ldg using intrinsics. (authored 
by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D19990?vs=56603=57873#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19990

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
  cfe/trunk/test/CodeGen/builtins-nvptx.c

Index: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
@@ -566,4 +566,40 @@
 BUILTIN(__nvvm_compiler_error, "vcC*4", "n")
 BUILTIN(__nvvm_compiler_warn, "vcC*4", "n")
 
+// __ldg.  This is not implemented as a builtin by nvcc.
+BUILTIN(__nvvm_ldg_c, "ccC*", "")
+BUILTIN(__nvvm_ldg_s, "ssC*", "")
+BUILTIN(__nvvm_ldg_i, "iiC*", "")
+BUILTIN(__nvvm_ldg_l, "LiLiC*", "")
+BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc, "UcUcC*", "")
+BUILTIN(__nvvm_ldg_us, "UsUsC*", "")
+BUILTIN(__nvvm_ldg_ui, "UiUiC*", "")
+BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "")
+BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f, "ffC*", "")
+BUILTIN(__nvvm_ldg_d, "ddC*", "")
+
+BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "")
+BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "")
+BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "")
+BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "")
+BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "")
+BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "")
+BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "")
+BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "")
+BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "")
+BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "")
+BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "")
+BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "")
+BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "")
+BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
+BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
+
 #undef BUILTIN
Index: cfe/trunk/test/CodeGen/builtins-nvptx.c
===
--- cfe/trunk/test/CodeGen/builtins-nvptx.c
+++ cfe/trunk/test/CodeGen/builtins-nvptx.c
@@ -1,6 +1,8 @@
 // REQUIRES: nvptx-registered-target
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | \
+// RUN:   FileCheck -check-prefix=CHECK -check-prefix=LP32 %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | \
+// RUN:   FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
 
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))
@@ -280,3 +282,103 @@
 
   // CHECK: ret
 }
+
+// CHECK-LABEL: nvvm_ldg
+__device__ void nvvm_ldg(const void *p) {
+  // CHECK: call i8 @llvm.nvvm.ldg.global.i.i8.p0i8(i8* {{%[0-9]+}}, i32 1)
+  // CHECK: call i8 @llvm.nvvm.ldg.global.i.i8.p0i8(i8* {{%[0-9]+}}, i32 1)
+  __nvvm_ldg_c((const char *)p);
+  __nvvm_ldg_uc((const unsigned char *)p);
+
+  // CHECK: call i16 @llvm.nvvm.ldg.global.i.i16.p0i16(i16* {{%[0-9]+}}, i32 2)
+  // CHECK: call i16 @llvm.nvvm.ldg.global.i.i16.p0i16(i16* {{%[0-9]+}}, i32 2)
+  __nvvm_ldg_s((const short *)p);
+  __nvvm_ldg_us((const unsigned short *)p);
+
+  // CHECK: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // CHECK: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  __nvvm_ldg_i((const int *)p);
+  __nvvm_ldg_ui((const unsigned int *)p);
+
+  // LP32: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // LP32: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // LP64: call i64 @llvm.nvvm.ldg.global.i.i64.p0i64(i64* {{%[0-9]+}}, i32 8)
+  // LP64: call i64 @llvm.nvvm.ldg.global.i.i64.p0i64(i64* {{%[0-9]+}}, i32 8)
+  __nvvm_ldg_l((const long *)p);
+  __nvvm_ldg_ul((const unsigned long *)p);
+
+  // CHECK: call float @llvm.nvvm.ldg.global.f.f32.p0f32(float* {{%[0-9]+}}, i32 4)
+  __nvvm_ldg_f((const float *)p);
+  // CHECK: call double @llvm.nvvm.ldg.global.f.f64.p0f64(double* {{%[0-9]+}}, i32 8)
+  __nvvm_ldg_d((const double *)p);
+
+  // In practice, the pointers we pass to __ldg will be aligned as appropriate
+  // for the CUDA N vector types (e.g. short4), which are not the same as
+  // the LLVM vector types.  However, each LLVM vector type has an alignment
+  // less than or equal to its corresponding CUDA type, so we're OK.
+  //
+  // PTX Interoperability section 2.2: "For a vector with an even number of
+  // elements, its alignment is set to number of elements 

r270150 - [CUDA] Implement __ldg using intrinsics.

2016-05-19 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu May 19 17:49:13 2016
New Revision: 270150

URL: http://llvm.org/viewvc/llvm-project?rev=270150=rev
Log:
[CUDA] Implement __ldg using intrinsics.

Summary:
Previously it was implemented as inline asm in the CUDA headers.

This change allows us to use the [addr+imm] addressing mode when
executing ld.global.nc instructions.  This translates into a 1.3x
speedup on some benchmarks that call this instruction from within an
unrolled loop.

Reviewers: tra, rsmith

Subscribers: jhen, cfe-commits, jholewinski

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

Added:
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=270150=270149=270150=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Thu May 19 17:49:13 2016
@@ -566,4 +566,40 @@ BUILTIN(__nvvm_atom_cas_gen_ll, "LLiLLiD
 BUILTIN(__nvvm_compiler_error, "vcC*4", "n")
 BUILTIN(__nvvm_compiler_warn, "vcC*4", "n")
 
+// __ldg.  This is not implemented as a builtin by nvcc.
+BUILTIN(__nvvm_ldg_c, "ccC*", "")
+BUILTIN(__nvvm_ldg_s, "ssC*", "")
+BUILTIN(__nvvm_ldg_i, "iiC*", "")
+BUILTIN(__nvvm_ldg_l, "LiLiC*", "")
+BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc, "UcUcC*", "")
+BUILTIN(__nvvm_ldg_us, "UsUsC*", "")
+BUILTIN(__nvvm_ldg_ui, "UiUiC*", "")
+BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "")
+BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f, "ffC*", "")
+BUILTIN(__nvvm_ldg_d, "ddC*", "")
+
+BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "")
+BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "")
+BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "")
+BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "")
+BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "")
+BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "")
+BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "")
+BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "")
+BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "")
+BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "")
+BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "")
+BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "")
+BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "")
+BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
+BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
+
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=270150=270149=270150=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu May 19 17:49:13 2016
@@ -7349,6 +7349,17 @@ Value *CodeGenFunction::EmitSystemZBuilt
 
 Value *CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID,
  const CallExpr *E) {
+  auto MakeLdg = [&](unsigned IntrinsicID) {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+AlignmentSource AlignSource;
+clang::CharUnits Align =
+getNaturalPointeeTypeAlignment(E->getArg(0)->getType(), );
+return Builder.CreateCall(
+CGM.getIntrinsic(IntrinsicID, {Ptr->getType()->getPointerElementType(),
+   Ptr->getType()}),
+{Ptr, ConstantInt::get(Builder.getInt32Ty(), Align.getQuantity())});
+  };
+
   switch (BuiltinID) {
   case NVPTX::BI__nvvm_atom_add_gen_i:
   case NVPTX::BI__nvvm_atom_add_gen_l:
@@ -7433,6 +7444,40 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 return Builder.CreateCall(FnALD32, {Ptr, Val});
   }
 
+  case NVPTX::BI__nvvm_ldg_c:
+  case NVPTX::BI__nvvm_ldg_c2:
+  case NVPTX::BI__nvvm_ldg_c4:
+  case NVPTX::BI__nvvm_ldg_s:
+  case NVPTX::BI__nvvm_ldg_s2:
+  case NVPTX::BI__nvvm_ldg_s4:
+  case NVPTX::BI__nvvm_ldg_i:
+  case NVPTX::BI__nvvm_ldg_i2:
+  case NVPTX::BI__nvvm_ldg_i4:
+  case NVPTX::BI__nvvm_ldg_l:
+  case NVPTX::BI__nvvm_ldg_ll:
+  case NVPTX::BI__nvvm_ldg_ll2:
+  case NVPTX::BI__nvvm_ldg_uc:
+  case NVPTX::BI__nvvm_ldg_uc2:
+  case NVPTX::BI__nvvm_ldg_uc4:
+  case NVPTX::BI__nvvm_ldg_us:
+  case NVPTX::BI__nvvm_ldg_us2:
+  case NVPTX::BI__nvvm_ldg_us4:
+  case NVPTX::BI__nvvm_ldg_ui:
+  case NVPTX::BI__nvvm_ldg_ui2:
+  case NVPTX::BI__nvvm_ldg_ui4:
+  case NVPTX::BI__nvvm_ldg_ul:
+  case NVPTX::BI__nvvm_ldg_ull:
+  case NVPTX::BI__nvvm_ldg_ull2:
+// PTX Interoperability section 2.2: "For a vector with an even number of
+// elements, its alignment is set to number of elements times the alignment
+// of its member: n*alignof(t)."
+return MakeLdg(Intrinsic::nvvm_ldg_global_i);
+  case 

[PATCH] D20451: [Parser] Fix look ahead after EOF while parsing objc message and lambdas

2016-05-19 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added reviewers: doug.gregor, rsmith.
bruno added a subscriber: cfe-commits.

If a closing ')' isn't found for a macro instantiation inside a '[',
the next token is EOF, this leads to crashes if we try to look ahead of
that. This could be triggered whenever trying to parse lambdas or objs
message expressions.

http://reviews.llvm.org/D20451

Files:
  lib/Parse/ParseExprCXX.cpp
  test/Parser/objcxx11-messaging-and-lambda.mm

Index: test/Parser/objcxx11-messaging-and-lambda.mm
===
--- /dev/null
+++ test/Parser/objcxx11-messaging-and-lambda.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+#define OBJCLASS(name) // expected-note {{macro 'OBJCLASS' defined here}}
+
+class NSMutableData;
+
+NSMutableData *test() { // // expected-note {{to match this '{'}}
+  NSMutableData *data = [[[OBJCLASS(NSMutableDataOBJCLASS( alloc] init] 
autorelease]; // expected-error {{unterminated function-like macro invocation}} 
\
+  // expected-error {{expected ';' at end of declaration}}
+  return data;
+} // expected-error {{expected expression}} expected-error {{expected '}'}}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -739,8 +739,11 @@
  && Tok.is(tok::l_square)
  && "Not at the start of a possible lambda expression.");
 
-  const Token Next = NextToken(), After = GetLookAheadToken(2);
+  const Token Next = NextToken();
+  if (Next.is(tok::eof)) // Nothing else to lookup here...
+return ExprEmpty();
 
+  const Token After = GetLookAheadToken(2);
   // If lookahead indicates this is a lambda...
   if (Next.is(tok::r_square) || // []
   Next.is(tok::equal) ||// [=


Index: test/Parser/objcxx11-messaging-and-lambda.mm
===
--- /dev/null
+++ test/Parser/objcxx11-messaging-and-lambda.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+#define OBJCLASS(name) // expected-note {{macro 'OBJCLASS' defined here}}
+
+class NSMutableData;
+
+NSMutableData *test() { // // expected-note {{to match this '{'}}
+  NSMutableData *data = [[[OBJCLASS(NSMutableDataOBJCLASS( alloc] init] autorelease]; // expected-error {{unterminated function-like macro invocation}} \
+  // expected-error {{expected ';' at end of declaration}}
+  return data;
+} // expected-error {{expected expression}} expected-error {{expected '}'}}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -739,8 +739,11 @@
  && Tok.is(tok::l_square)
  && "Not at the start of a possible lambda expression.");
 
-  const Token Next = NextToken(), After = GetLookAheadToken(2);
+  const Token Next = NextToken();
+  if (Next.is(tok::eof)) // Nothing else to lookup here...
+return ExprEmpty();
 
+  const Token After = GetLookAheadToken(2);
   // If lookahead indicates this is a lambda...
   if (Next.is(tok::r_square) || // []
   Next.is(tok::equal) ||// [=
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

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

After offline discussion: we don't know for sure whether we're going to hit the 
combinatorial explosion in future or not. Let's go ahead with this as-is for 
now, then, with the explicit acknowledgement that we reserve the right to 
replace these builtins with a single type-generic builtin in the future.


http://reviews.llvm.org/D19990



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


Re: [PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Vedant Kumar via cfe-commits
Yes, here are the results from the unpatched compiler:

Avg. wall time (s): 0.73241
Std. deviation: 0.05850

And here are the results from the patched compiler:

Avg. wall time (s): 0.75554
Std. deviation: 0.07492

The testing methodology was the same (100 trials), except I used `clang -x 
objective-c -Xclang -emit-pch`. There is a slight difference, but it still 
basically looks noisy to me.

vedant


> On May 19, 2016, at 2:48 PM, Argyrios Kyrtzidis  wrote:
> 
> Could you also check performance of creating a PCH file out of Cocoa.h ?
> 
>> On May 19, 2016, at 1:47 PM, Vedant Kumar  wrote:
>> 
>> vsk added a comment.
>> 
>> I discussed this bug with Argyrios off-list, who lgtm'd on the condition 
>> that it doesn't introduce a performance regression. He suggested 
>> preprocessing Cocoa.h to stress the patch. After running a stabilization 
>> script, I used this command to stress RelNoAsserts builds of clang both with 
>> and without this patch.
>> 
>> for I in $(seq 1 100); do time $CC -F 
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks
>>  -E Cocoa.h -o /dev/null; done
>> 
>> The results are basically in the noise (link to raw data: 
>> https://ghostbin.com/paste/r6cyh):
>> 
>> | Compiler   | **Unpatched** TOT | **Patched** TOT |
>> | Avg. wall time (s) | 0.21709   | 0.21608 |
>> | Std. deviation | 0.02101   | 0.02219 |
>> 
>> I also made sure that the preprocessed sources emitted by the two compilers 
>> are the same.
>> 
>> 
>> http://reviews.llvm.org/D20401
>> 
>> 
>> 
> 

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


Re: r270039 - [Sema] Allow an external sema source to handle delayed typo corrections.

2016-05-19 Thread Benjamin Kramer via cfe-commits
r270144 should fix that failure.

On Thu, May 19, 2016 at 10:17 PM, Evgenii Stepanov
 wrote:
> Looks like this commit broke the bot:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-
> bootstrap/builds/11738/steps/check-clang%20ubsan/logs/stdio
>
> On Thu, May 19, 2016 at 3:52 AM, Benjamin Kramer via cfe-commits
>  wrote:
>> Author: d0k
>> Date: Thu May 19 05:46:10 2016
>> New Revision: 270039
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=270039=rev
>> Log:
>> [Sema] Allow an external sema source to handle delayed typo corrections.
>>
>> This probably isn't perfectly perfect but allows correcting function calls
>> again.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=270039=270038=270039=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu May 19 05:46:10 2016
>> @@ -4781,11 +4781,19 @@ TypoExpr *Sema::CorrectTypoDelayed(
>>  const ObjCObjectPointerType *OPT) {
>>assert(CCC && "CorrectTypoDelayed requires a 
>> CorrectionCandidateCallback");
>>
>> -  TypoCorrection Empty;
>>auto Consumer = makeTypoCorrectionConsumer(
>>TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
>>EnteringContext, OPT, Mode == CTK_ErrorRecovery);
>>
>> +  // Give the external sema source a chance to correct the typo.
>> +  TypoCorrection ExternalTypo;
>> +  if (ExternalSource && Consumer) {
>> +ExternalTypo = ExternalSource->CorrectTypo(
>> +TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, 
>> OPT);
>> +if (ExternalTypo)
>> +  Consumer->addCorrection(ExternalTypo);
>> +  }
>> +
>>if (!Consumer || Consumer->empty())
>>  return nullptr;
>>
>> @@ -4793,7 +4801,7 @@ TypoExpr *Sema::CorrectTypoDelayed(
>>// is not more that about a third of the length of the typo's identifier.
>>unsigned ED = Consumer->getBestEditDistance(true);
>>IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
>> -  if (ED > 0 && Typo->getName().size() / ED < 3)
>> +  if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
>>  return nullptr;
>>
>>ExprEvalContexts.back().NumTypos++;
>>
>> Modified: cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp?rev=270039=270038=270039=diff
>> ==
>> --- cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp (original)
>> +++ cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp Thu May 19 05:46:10 
>> 2016
>> @@ -39,19 +39,18 @@ public:
>>bool Result;
>>  };
>>
>> -// \brief Counts the number of err_using_directive_member_suggest 
>> diagnostics
>> -// correcting from one namespace to another while still passing all 
>> diagnostics
>> -// along a chain of consumers.
>> -class NamespaceDiagnosticWatcher : public clang::DiagnosticConsumer {
>> +/// Counts the number of typo-correcting diagnostics correcting from one 
>> name to
>> +/// another while still passing all diagnostics along a chain of consumers.
>> +class DiagnosticWatcher : public clang::DiagnosticConsumer {
>>DiagnosticConsumer *Chained;
>> -  std::string FromNS;
>> -  std::string ToNS;
>> +  std::string FromName;
>> +  std::string ToName;
>>
>>  public:
>> -  NamespaceDiagnosticWatcher(StringRef From, StringRef To)
>> -  : Chained(nullptr), FromNS(From), ToNS("'"), SeenCount(0) {
>> -ToNS.append(To);
>> -ToNS.append("'");
>> +  DiagnosticWatcher(StringRef From, StringRef To)
>> +  : Chained(nullptr), FromName(From), ToName("'"), SeenCount(0) {
>> +ToName.append(To);
>> +ToName.append("'");
>>}
>>
>>void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
>> @@ -61,7 +60,12 @@ public:
>>  if (Info.getID() - 1 == diag::err_using_directive_member_suggest) {
>>const IdentifierInfo *Ident = Info.getArgIdentifier(0);
>>const std::string  = Info.getArgStdStr(1);
>> -  if (Ident->getName() == FromNS && CorrectedQuotedStr == ToNS)
>> +  if (Ident->getName() == FromName && CorrectedQuotedStr == ToName)
>> +++SeenCount;
>> +} else if (Info.getID() == diag::err_no_member_suggest) {
>> +  auto Ident = DeclarationName::getFromOpaqueInteger(Info.getRawArg(0));
>> +  const std::string  = Info.getArgStdStr(3);
>> +  if (Ident.getAsString() == FromName && CorrectedQuotedStr == ToName)
>>  ++SeenCount;
>>  }
>>}
>> @@ -78,7 +82,7 @@ public:
>>  return false;
>>}
>>
>> -  NamespaceDiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
>> +  DiagnosticWatcher 

r270144 - [Sema] Fix use after move. Found by ubsan.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 16:53:33 2016
New Revision: 270144

URL: http://llvm.org/viewvc/llvm-project?rev=270144=rev
Log:
[Sema] Fix use after move. Found by ubsan.

Modified:
cfe/trunk/include/clang/Sema/SemaInternal.h
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Sema/SemaInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaInternal.h?rev=270144=270143=270144=diff
==
--- cfe/trunk/include/clang/Sema/SemaInternal.h (original)
+++ cfe/trunk/include/clang/Sema/SemaInternal.h Thu May 19 16:53:33 2016
@@ -216,6 +216,9 @@ public:
   bool isAddressOfOperand() const { return 
CorrectionValidator->IsAddressOfOperand; }
   const CXXScopeSpec *getSS() const { return SS.get(); }
   Scope *getScope() const { return S; }
+  CorrectionCandidateCallback *getCorrectionValidator() const {
+return CorrectionValidator.get();
+  }
 
 private:
   class NamespaceSpecifierSet {

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=270144=270143=270144=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu May 19 16:53:33 2016
@@ -4789,7 +4789,8 @@ TypoExpr *Sema::CorrectTypoDelayed(
   TypoCorrection ExternalTypo;
   if (ExternalSource && Consumer) {
 ExternalTypo = ExternalSource->CorrectTypo(
-TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, 
OPT);
+TypoName, LookupKind, S, SS, *Consumer->getCorrectionValidator(),
+MemberContext, EnteringContext, OPT);
 if (ExternalTypo)
   Consumer->addCorrection(ExternalTypo);
   }


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


Re: [PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Argyrios Kyrtzidis via cfe-commits
Could you also check performance of creating a PCH file out of Cocoa.h ?

> On May 19, 2016, at 1:47 PM, Vedant Kumar  wrote:
> 
> vsk added a comment.
> 
> I discussed this bug with Argyrios off-list, who lgtm'd on the condition that 
> it doesn't introduce a performance regression. He suggested preprocessing 
> Cocoa.h to stress the patch. After running a stabilization script, I used 
> this command to stress RelNoAsserts builds of clang both with and without 
> this patch.
> 
>  for I in $(seq 1 100); do time $CC -F 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks
>  -E Cocoa.h -o /dev/null; done
> 
> The results are basically in the noise (link to raw data: 
> https://ghostbin.com/paste/r6cyh):
> 
> | Compiler   | **Unpatched** TOT | **Patched** TOT |
> | Avg. wall time (s) | 0.21709   | 0.21608 |
> | Std. deviation | 0.02101   | 0.02219 |
> 
> I also made sure that the preprocessed sources emitted by the two compilers 
> are the same.
> 
> 
> http://reviews.llvm.org/D20401
> 
> 
> 

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


Re: r269907 - Add new intrinsic support for MONITORX and MWAITX instructions

2016-05-19 Thread Richard Smith via cfe-commits
The modules buildbot has been broken since this commit landed:

http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/15761/steps/compile.llvm.stage2/logs/stdio

Please fix or revert.

On Wed, May 18, 2016 at 4:56 AM, Ashutosh Nema via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ashutosh
> Date: Wed May 18 06:56:23 2016
> New Revision: 269907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269907=rev
> Log:
> Add new intrinsic support for MONITORX and MWAITX instructions
>
> Summary:
> MONITORX/MWAITX instructions provide similar capability to the
> MONITOR/MWAIT
> pair while adding a timer function, such that another termination of the
> MWAITX
> instruction occurs when the timer expires. The presence of the MONITORX and
> MWAITX instructions is indicated by CPUID 8000_0001, ECX, bit 29.
>
> The MONITORX and MWAITX instructions are intercepted by the same bits that
> intercept MONITOR and MWAIT. MONITORX instruction establishes a range to be
> monitored. MWAITX instruction causes the processor to stop instruction
> execution and enter an implementation-dependent optimized state until
> occurrence of a class of events.
>
> Opcode of MONITORX instruction is "0F 01 FA". Opcode of MWAITX instruction
> is
> "0F 01 FB". These opcode information is used in adding tests for the
> disassembler.
>
> These instructions are enabled for AMD's bdver4 architecture.
>
> Patch by Ganesh Gopalasubramanian!
>
> Reviewers: echristo, craig.topper
>
> Subscribers: RKSimon, joker.eph, llvm-commits, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D19796
>
> Added:
> cfe/trunk/lib/Headers/mwaitxintrin.h
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Headers/CMakeLists.txt
> cfe/trunk/lib/Headers/module.modulemap
> cfe/trunk/lib/Headers/x86intrin.h
> cfe/trunk/test/CodeGen/builtins-x86.c
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269907=269906=269907=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May 18 06:56:23 2016
> @@ -2272,5 +2272,9 @@ TARGET_BUILTIN(__builtin_ia32_cvtusi2sd6
>  TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")
>  TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fULLiIi","","avx512f")
>
> +// MONITORX/MWAITX
> +TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
> +TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
> +
>  #undef BUILTIN
>  #undef TARGET_BUILTIN
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269907=269906=269907=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed May 18 06:56:23 2016
> @@ -1425,6 +1425,7 @@ def mno_xsave : Flag<["-"], "mno-xsave">
>  def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">,
> Group;
>  def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
>  def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
> +def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
>  def mno_pku : Flag<["-"], "mno-pku">, Group;
>
>  def munaligned_access : Flag<["-"], "munaligned-access">,
> Group,
> @@ -1610,6 +1611,7 @@ def mxsave : Flag<["-"], "mxsave">, Grou
>  def mxsaveopt : Flag<["-"], "mxsaveopt">, Group;
>  def mxsavec : Flag<["-"], "mxsavec">, Group;
>  def mxsaves : Flag<["-"], "mxsaves">, Group;
> +def mmwaitx : Flag<["-"], "mmwaitx">, Group;
>  def mips16 : Flag<["-"], "mips16">, Group;
>  def mno_mips16 : Flag<["-"], "mno-mips16">, Group;
>  def mmicromips : Flag<["-"], "mmicromips">, Group;
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=269907=269906=269907=diff
>
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed May 18 06:56:23 2016
> @@ -2273,6 +2273,7 @@ class X86TargetInfo : public TargetInfo
>bool HasXSAVEOPT = false;
>bool HasXSAVEC = false;
>bool HasXSAVES = false;
> +  bool HasMWAITX = false;
>bool HasPKU = false;
>bool HasCLFLUSHOPT = false;
>bool HasPCOMMIT = false;
> @@ -2947,6 +2948,7 @@ bool X86TargetInfo::initFeatureMap(
>case CK_BDVER4:
>  setFeatureEnabledImpl(Features, "avx2", true);
>  setFeatureEnabledImpl(Features, "bmi2", true);
> +setFeatureEnabledImpl(Features, "mwaitx", true);
>  // FALLTHROUGH
>case CK_BDVER3:
>  setFeatureEnabledImpl(Features, "fsgsbase", true);
> @@ -3266,6 

[PATCH] D20449: [Basic] Change x86_64-windows-macho targets to use Windows-style va_lists.

2016-05-19 Thread Charles Davis via cfe-commits
cdavis5x created this revision.
cdavis5x added a reviewer: rsmith.
cdavis5x added a subscriber: cfe-commits.

This is a very strange target. Sema thinks it's targeting a Darwin-esque
system, while IRGen thinks it's targeting a Windows'ish system. The result
is that Clang can no longer compile `__builtin_va_arg` (either for a normal
or Win64 `va_list`) properly. So, for this target, explicitly set the
`va_list` kind to `CharPtr`, the same as Win64. This is what users expect,
anyway.

Fixes PR27663.

http://reviews.llvm.org/D20449

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/windows-macho.c

Index: test/CodeGen/windows-macho.c
===
--- /dev/null
+++ test/CodeGen/windows-macho.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-windows-macho -emit-llvm -Os %s -o - \
+// RUN:| FileCheck %s
+
+// Test that, when we compile a function that uses varargs on a
+// Windows-with-Mach-O triple, we can actually compile it, and it actually
+// conforms to the Win64 ABI.
+
+// PR27663
+
+// CHECK-LABEL: i32 @va_sum
+int va_sum(unsigned int count, ...) {
+  int sum = 0;
+  __builtin_ms_va_list ap;
+
+  __builtin_ms_va_start(ap, count);
+  // CHECK: %[[AP:.*]] = alloca i8*
+  // CHECK: call void @llvm.va_start
+  while (count) {
+sum += __builtin_va_arg(ap, int);
+// CHECK: %[[AP_CUR_PRE:.*]] = load i8*, i8** %[[AP]]
+// CHECK: %[[AP_CUR:.*]] = phi i8* [ %[[AP_NEXT:.*]], {{.*}} ], [ 
%[[AP_CUR_PRE]], {{.*}} ]
+// CHECK: %[[AP_NEXT]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+// CHECK-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+// CHECK-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+--count;
+  }
+  __builtin_ms_va_end(ap);
+  return sum;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -,6 +,39 @@
   }
 };
 
+class EFIMachOX86_64TargetInfo : public DarwinX86_64TargetInfo {
+public:
+  EFIMachOX86_64TargetInfo(const llvm::Triple ,
+   const TargetOptions )
+  : DarwinX86_64TargetInfo(Triple, Opts) {}
+
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override {
+DarwinX86_64TargetInfo::getTargetDefines(Opts, Builder);
+addCygMingDefines(Opts, Builder);
+  }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::CharPtrBuiltinVaList;
+  }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_X86StdCall:
+case CC_X86ThisCall:
+case CC_X86FastCall:
+  return CCCR_Ignore;
+case CC_C:
+case CC_X86VectorCall:
+case CC_IntelOclBicc:
+case CC_X86_64SysV:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
+};
+
 class OpenBSDX86_64TargetInfo : public OpenBSDTargetInfo {
 public:
   OpenBSDX86_64TargetInfo(const llvm::Triple , const TargetOptions 
)
@@ -8362,8 +8395,11 @@
 }
 
   case llvm::Triple::x86_64:
-if (Triple.isOSDarwin() || Triple.isOSBinFormatMachO())
+if (Triple.isOSDarwin() ||
+(!Triple.isOSWindows() && Triple.isOSBinFormatMachO()))
   return new DarwinX86_64TargetInfo(Triple, Opts);
+if (Triple.isOSWindows() && Triple.isOSBinFormatMachO())
+  return new EFIMachOX86_64TargetInfo(Triple, Opts);
 
 switch (os) {
 case llvm::Triple::CloudABI:


Index: test/CodeGen/windows-macho.c
===
--- /dev/null
+++ test/CodeGen/windows-macho.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-windows-macho -emit-llvm -Os %s -o - \
+// RUN:| FileCheck %s
+
+// Test that, when we compile a function that uses varargs on a
+// Windows-with-Mach-O triple, we can actually compile it, and it actually
+// conforms to the Win64 ABI.
+
+// PR27663
+
+// CHECK-LABEL: i32 @va_sum
+int va_sum(unsigned int count, ...) {
+  int sum = 0;
+  __builtin_ms_va_list ap;
+
+  __builtin_ms_va_start(ap, count);
+  // CHECK: %[[AP:.*]] = alloca i8*
+  // CHECK: call void @llvm.va_start
+  while (count) {
+sum += __builtin_va_arg(ap, int);
+// CHECK: %[[AP_CUR_PRE:.*]] = load i8*, i8** %[[AP]]
+// CHECK: %[[AP_CUR:.*]] = phi i8* [ %[[AP_NEXT:.*]], {{.*}} ], [ %[[AP_CUR_PRE]], {{.*}} ]
+// CHECK: %[[AP_NEXT]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+// CHECK-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+// CHECK-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+--count;
+  }
+  __builtin_ms_va_end(ap);
+  return sum;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -,6 +,39 @@
   }
 };
 
+class EFIMachOX86_64TargetInfo : public DarwinX86_64TargetInfo {
+public:
+  EFIMachOX86_64TargetInfo(const llvm::Triple ,
+   const TargetOptions )
+  : 

Re: [PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Vedant Kumar via cfe-commits
vsk added a comment.

I discussed this bug with Argyrios off-list, who lgtm'd on the condition that 
it doesn't introduce a performance regression. He suggested preprocessing 
Cocoa.h to stress the patch. After running a stabilization script, I used this 
command to stress RelNoAsserts builds of clang both with and without this patch.

  for I in $(seq 1 100); do time $CC -F 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks
 -E Cocoa.h -o /dev/null; done

The results are basically in the noise (link to raw data: 
https://ghostbin.com/paste/r6cyh):

| Compiler   | **Unpatched** TOT | **Patched** TOT |
| Avg. wall time (s) | 0.21709   | 0.21608 |
| Std. deviation | 0.02101   | 0.02219 |

I also made sure that the preprocessed sources emitted by the two compilers are 
the same.


http://reviews.llvm.org/D20401



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


Re: [PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-19 Thread Charles Davis via cfe-commits
cdavis5x updated this revision to Diff 57853.
cdavis5x marked an inline comment as done.
cdavis5x added a comment.

- Add Sema tests for the `ms_hook_prologue` attribute.
- Disallow `ms_hook_prologue` on architectures that Windows doesn't support.
- Disallow `ms_hook_prologue` with the `naked` and `always_inline` attributes.


http://reviews.llvm.org/D19909

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/function-attributes.c
  test/Sema/attr-ms-hook-prologue.c

Index: test/Sema/attr-ms-hook-prologue.c
===
--- /dev/null
+++ test/Sema/attr-ms-hook-prologue.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-pc-linux -fms-extensions -fsyntax-only -verify %s
+
+int __attribute__((ms_hook_prologue)) foo(int a, int b) {
+  return a+b;
+}
+
+// expected-note@+2{{conflicting attribute is here}}
+// expected-error@+1{{'naked' and 'ms_hook_prologue' attributes are not compatible}}
+__declspec(naked) int __attribute__((ms_hook_prologue)) bar(int a, int b) {
+}
+
+// expected-note@+2{{conflicting attribute is here}}
+// expected-error@+1{{'__forceinline' and 'ms_hook_prologue' attributes are not compatible}}
+__forceinline int __attribute__((ms_hook_prologue)) baz(int a, int b) {
+  return a-b;
+}
+
+// expected-warning@+1{{'ms_hook_prologue' attribute only applies to functions}}
+int x __attribute__((ms_hook_prologue));
+
+// expected-error@+1{{'ms_hook_prologue' attribute takes no arguments}}
+int f(int a, int b) __attribute__((ms_hook_prologue(2)));
Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -108,11 +108,18 @@
   _setjmp(0);
 }
 
+// CHECK-LABEL: define void @f21
+// CHECK: [[HOTPATCH:#[0-9]+]]
+// CHECK: {
+void __attribute__((ms_hook_prologue)) f21(void) {
+}
+
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
+// CHECK: attributes [[HOTPATCH]] = { nounwind optsize{{.*}}"patchable-function"="ms-hotpatch"{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
 // CHECK: attributes [[RT_CALL]] = { optsize returns_twice }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1663,15 +1663,6 @@
 D->addAttr(CA);
 }
 
-static void handleNakedAttr(Sema , Decl *D, const AttributeList ) {
-  if (checkAttrMutualExclusion(S, D, Attr.getRange(),
- Attr.getName()))
-return;
-
-  D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
-}
-
 static void handleNoReturnAttr(Sema , Decl *D, const AttributeList ) {
   if (hasDeclarator(D)) return;
 
@@ -3672,7 +3663,9 @@
 static void handleAlwaysInlineAttr(Sema , Decl *D,
const AttributeList ) {
   if (checkAttrMutualExclusion(S, D, Attr.getRange(),
-  Attr.getName()))
+  Attr.getName()) ||
+  checkAttrMutualExclusion(S, D, Attr.getRange(),
+   Attr.getName()))
 return;
 
   if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr(
@@ -5525,7 +5518,8 @@
 handleHotAttr(S, D, Attr);
 break;
   case AttributeList::AT_Naked:
-handleNakedAttr(S, D, Attr);
+handleSimpleAttributeWithExclusions(S, D, Attr);
 break;
   case AttributeList::AT_NoReturn:
 handleNoReturnAttr(S, D, Attr);
@@ -5748,6 +5742,10 @@
 break;
 
   // Microsoft attributes:
+  case AttributeList::AT_MSHookPrologue:
+handleSimpleAttributeWithExclusions(S, D, Attr);
+break;
   case AttributeList::AT_MSNoVTable:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1749,6 +1749,10 @@
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("patchable-function", "ms-hotpatch");
+}
   }
 }
 
@@ -2079,6 +2083,10 @@
 llvm::Function *Fn 

Re: [PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-19 Thread Charles Davis via cfe-commits
cdavis5x added a comment.

For now, I've disallowed it with `naked` and `always_inline`/`__forceinline` 
attributes. Do any other attributes affect prologue generation in a way that 
might interfere with `ms_hook_prologue`? AFAICT, GCC only disallows 
`ms_hook_prologue` on a) nested functions and b) functions compiled with 
`-mfentry` (neither of which we support, AFAIK).



Comment at: include/clang/Basic/Attr.td:2032
@@ -2031,1 +2031,3 @@
 
+def MSHookPrologue : InheritableAttr {
+  let Spellings = [GCC<"ms_hook_prologue">];

aaron.ballman wrote:
> I am wondering whether we want this to be a target-specific attribute or not. 
> Right now, this attribute will be silently accepted for CPUs that MSVC does 
> not support, for instance. If we made the attribute target-specific, then 
> users would get appropriate diagnostics for those architectures.
For now, I've limited it to architectures that Windows supports.


http://reviews.llvm.org/D19909



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


Re: r270047 - [Clang][AVX512][intrinsics] continue completing missing set intrinsics

2016-05-19 Thread Steven Wu via cfe-commits
Hi Michael

This commit seems break darwin LTO bootstrap bot. 
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/7916/
Also breaks the Asan Ubsan bot:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/1742/

Can you talk a look? I don't why the failure doesn't show up in other 
configuration. Let me know if you need any help.

Thanks

Steven


> On May 19, 2016, at 5:07 AM, Michael Zuckerman via cfe-commits 
>  wrote:
> 
> Author: mzuckerm
> Date: Thu May 19 07:07:49 2016
> New Revision: 270047
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=270047=rev
> Log:
> [Clang][AVX512][intrinsics] continue completing missing set intrinsics
> 
> Differential Revision: http://reviews.llvm.org/D20160
> 
> 
> Modified:
>cfe/trunk/lib/Headers/avx512fintrin.h
>cfe/trunk/test/CodeGen/avx512f-builtins.c
> 
> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=270047=270046=270047=diff
> ==
> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512fintrin.h Thu May 19 07:07:49 2016
> @@ -8983,6 +8983,21 @@ _mm512_mask_set1_epi64 (__m512i __O, __m
>  __M);
> }
> 
> +static __inline __m512i __DEFAULT_FN_ATTRS
> +_mm512_set_epi32 (int __A, int __B, int __C, int __D,
> + int __E, int __F, int __G, int __H,
> + int __I, int __J, int __K, int __L,
> + int __M, int __N, int __O, int __P)
> +{
> +  return __extension__ (__m512i)(__v16si)
> +  { __P, __O, __N, __M, __L, __K, __J, __I,
> +__H, __G, __F, __E, __D, __C, __B, __A };
> +}
> +
> +#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7,   \
> +   e8,e9,e10,e11,e12,e13,e14,e15)  \
> +  _mm512_set_epi32(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
> +  
> static __inline__ __m512i __DEFAULT_FN_ATTRS
> _mm512_set_epi64 (long long __A, long long __B, long long __C,
>  long long __D, long long __E, long long __F,
> @@ -8992,6 +9007,9 @@ _mm512_set_epi64 (long long __A, long lo
>   { __H, __G, __F, __E, __D, __C, __B, __A };
> }
> 
> +#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7)   \
> +  _mm512_set_epi64(e7,e6,e5,e4,e3,e2,e1,e0)
> +
> static __inline__ __m512d __DEFAULT_FN_ATTRS
> _mm512_set_pd (double __A, double __B, double __C, double __D,
> double __E, double __F, double __G, double __H)
> @@ -9000,6 +9018,9 @@ _mm512_set_pd (double __A, double __B, d
>   { __H, __G, __F, __E, __D, __C, __B, __A };
> }
> 
> +#define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7)  \
> +  _mm512_set_pd(e7,e6,e5,e4,e3,e2,e1,e0)
> +
> static __inline__ __m512 __DEFAULT_FN_ATTRS
> _mm512_set_ps (float __A, float __B, float __C, float __D,
> float __E, float __F, float __G, float __H,
> @@ -9011,6 +9032,9 @@ _mm512_set_ps (float __A, float __B, flo
> __H, __G, __F, __E, __D, __C, __B, __A };
> }
> 
> +#define 
> _mm512_setr_ps(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) \
> +  _mm512_set_ps(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
> +
> #undef __DEFAULT_FN_ATTRS
> 
> #endif // __AVX512FINTRIN_H
> 
> Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=270047=270046=270047=diff
> ==
> --- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 07:07:49 2016
> @@ -6521,6 +6521,74 @@ __m512i test_mm512_mask_set1_epi32 (__m5
>   return _mm512_mask_set1_epi32 ( __O, __M, __A);
> }
> 
> +__m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D,
> +   int __E, int __F, int __G, int __H,
> +   int __I, int __J, int __K, int __L,
> +   int __M, int __N, int __O, int __P)
> +{
> + //CHECK-LABLE: @test_mm512_set_epi32
> + //CHECK: insertelement{{.*}}i32 0
> +//CHECK: insertelement{{.*}}i32 1
> +//CHECK: insertelement{{.*}}i32 2
> +//CHECK: insertelement{{.*}}i32 3
> +//CHECK: insertelement{{.*}}i32 4
> +//CHECK: insertelement{{.*}}i32 5
> +//CHECK: insertelement{{.*}}i32 6
> +//CHECK: insertelement{{.*}}i32 7
> +//CHECK: insertelement{{.*}}i32 8
> +//CHECK: insertelement{{.*}}i32 9
> +//CHECK: insertelement{{.*}}i32 10
> +//CHECK: insertelement{{.*}}i32 11
> +//CHECK: insertelement{{.*}}i32 12
> +//CHECK: insertelement{{.*}}i32 13
> +//CHECK: insertelement{{.*}}i32 14
> +//CHECK: insertelement{{.*}}i32 15
> + return _mm512_set_epi32( __A, __B, __C, __D,__E, __F, __G, __H,
> +  __I, __J, __K, __L,__M, __N, __O, __P);
> +}
> +
> +__m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D,
> +   int __E, int __F, int __G, int __H,
> +   int __I, int __J, int __K, int 

Re: r270039 - [Sema] Allow an external sema source to handle delayed typo corrections.

2016-05-19 Thread Evgenii Stepanov via cfe-commits
Looks like this commit broke the bot:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-
bootstrap/builds/11738/steps/check-clang%20ubsan/logs/stdio

On Thu, May 19, 2016 at 3:52 AM, Benjamin Kramer via cfe-commits
 wrote:
> Author: d0k
> Date: Thu May 19 05:46:10 2016
> New Revision: 270039
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270039=rev
> Log:
> [Sema] Allow an external sema source to handle delayed typo corrections.
>
> This probably isn't perfectly perfect but allows correcting function calls
> again.
>
> Modified:
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=270039=270038=270039=diff
> ==
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu May 19 05:46:10 2016
> @@ -4781,11 +4781,19 @@ TypoExpr *Sema::CorrectTypoDelayed(
>  const ObjCObjectPointerType *OPT) {
>assert(CCC && "CorrectTypoDelayed requires a CorrectionCandidateCallback");
>
> -  TypoCorrection Empty;
>auto Consumer = makeTypoCorrectionConsumer(
>TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
>EnteringContext, OPT, Mode == CTK_ErrorRecovery);
>
> +  // Give the external sema source a chance to correct the typo.
> +  TypoCorrection ExternalTypo;
> +  if (ExternalSource && Consumer) {
> +ExternalTypo = ExternalSource->CorrectTypo(
> +TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, 
> OPT);
> +if (ExternalTypo)
> +  Consumer->addCorrection(ExternalTypo);
> +  }
> +
>if (!Consumer || Consumer->empty())
>  return nullptr;
>
> @@ -4793,7 +4801,7 @@ TypoExpr *Sema::CorrectTypoDelayed(
>// is not more that about a third of the length of the typo's identifier.
>unsigned ED = Consumer->getBestEditDistance(true);
>IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
> -  if (ED > 0 && Typo->getName().size() / ED < 3)
> +  if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
>  return nullptr;
>
>ExprEvalContexts.back().NumTypos++;
>
> Modified: cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp?rev=270039=270038=270039=diff
> ==
> --- cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp (original)
> +++ cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp Thu May 19 05:46:10 
> 2016
> @@ -39,19 +39,18 @@ public:
>bool Result;
>  };
>
> -// \brief Counts the number of err_using_directive_member_suggest diagnostics
> -// correcting from one namespace to another while still passing all 
> diagnostics
> -// along a chain of consumers.
> -class NamespaceDiagnosticWatcher : public clang::DiagnosticConsumer {
> +/// Counts the number of typo-correcting diagnostics correcting from one 
> name to
> +/// another while still passing all diagnostics along a chain of consumers.
> +class DiagnosticWatcher : public clang::DiagnosticConsumer {
>DiagnosticConsumer *Chained;
> -  std::string FromNS;
> -  std::string ToNS;
> +  std::string FromName;
> +  std::string ToName;
>
>  public:
> -  NamespaceDiagnosticWatcher(StringRef From, StringRef To)
> -  : Chained(nullptr), FromNS(From), ToNS("'"), SeenCount(0) {
> -ToNS.append(To);
> -ToNS.append("'");
> +  DiagnosticWatcher(StringRef From, StringRef To)
> +  : Chained(nullptr), FromName(From), ToName("'"), SeenCount(0) {
> +ToName.append(To);
> +ToName.append("'");
>}
>
>void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
> @@ -61,7 +60,12 @@ public:
>  if (Info.getID() - 1 == diag::err_using_directive_member_suggest) {
>const IdentifierInfo *Ident = Info.getArgIdentifier(0);
>const std::string  = Info.getArgStdStr(1);
> -  if (Ident->getName() == FromNS && CorrectedQuotedStr == ToNS)
> +  if (Ident->getName() == FromName && CorrectedQuotedStr == ToName)
> +++SeenCount;
> +} else if (Info.getID() == diag::err_no_member_suggest) {
> +  auto Ident = DeclarationName::getFromOpaqueInteger(Info.getRawArg(0));
> +  const std::string  = Info.getArgStdStr(3);
> +  if (Ident.getAsString() == FromName && CorrectedQuotedStr == ToName)
>  ++SeenCount;
>  }
>}
> @@ -78,7 +82,7 @@ public:
>  return false;
>}
>
> -  NamespaceDiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
> +  DiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
>  Chained = ToChain;
>  return this;
>}
> @@ -130,11 +134,53 @@ public:
>int CallCount;
>  };
>
> -// \brief Chains together a vector of NamespaceDiagnosticWatchers and
> +class FunctionTypoProvider : public 

r270108 - [CUDA] Do not allow non-empty destructors for global device-side variables.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 15:13:53 2016
New Revision: 270108

URL: http://llvm.org/viewvc/llvm-project?rev=270108=rev
Log:
[CUDA] Do not allow non-empty destructors for global device-side variables.

According to Cuda Programming guide (v7.5, E2.3.1):
> __device__, __constant__ and __shared__ variables defined in namespace
> scope, that are of class type, cannot have a non-empty constructor or a
> non-empty destructor.

Clang already deals with device-side constructors (see D15305).
This patch enforces similar rules for destructors.

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCUDA/device-var-init.cu
cfe/trunk/test/SemaCUDA/device-var-init.cu

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=270108=270107=270108=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu May 19 15:13:53 2016
@@ -9036,6 +9036,7 @@ public:
   /// \return true if \p CD can be considered empty according to CUDA
   /// (E.2.3.1 in CUDA 7.5 Programming guide).
   bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
+  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
 
   /// \name Code completion
   //@{

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=270108=270107=270108=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Thu May 19 15:13:53 2016
@@ -372,7 +372,7 @@ bool Sema::isEmptyCudaConstructor(Source
 return false;
 
   // The only form of initializer allowed is an empty constructor.
-  // This will recursively checks all base classes and member initializers
+  // This will recursively check all base classes and member initializers
   if (!llvm::all_of(CD->inits(), [&](const CXXCtorInitializer *CI) {
 if (const CXXConstructExpr *CE =
 dyn_cast(CI->getInit()))
@@ -381,6 +381,54 @@ bool Sema::isEmptyCudaConstructor(Source
   }))
 return false;
 
+  return true;
+}
+
+bool Sema::isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *DD) {
+  // No destructor -> no problem.
+  if (!DD)
+return true;
+
+  if (!DD->isDefined() && DD->isTemplateInstantiation())
+InstantiateFunctionDefinition(Loc, DD->getFirstDecl());
+
+  // (E.2.3.1, CUDA 7.5) A destructor for a class type is considered
+  // empty at a point in the translation unit, if it is either a
+  // trivial constructor
+  if (DD->isTrivial())
+return true;
+
+  // ... or it satisfies all of the following conditions:
+  // The destructor function has been defined.
+  // and the function body is an empty compound statement.
+  if (!DD->hasTrivialBody())
+return false;
+
+  const CXXRecordDecl *ClassDecl = DD->getParent();
+
+  // Its class has no virtual functions and no virtual base classes.
+  if (ClassDecl->isDynamicClass())
+return false;
+
+  // Only empty destructors are allowed. This will recursively check
+  // destructors for all base classes...
+  if (!llvm::all_of(ClassDecl->bases(), [&](const CXXBaseSpecifier ) {
+if (CXXRecordDecl *RD = BS.getType()->getAsCXXRecordDecl())
+  return isEmptyCudaDestructor(Loc, RD->getDestructor());
+return true;
+  }))
+return false;
+
+  // ... and member fields.
+  if (!llvm::all_of(ClassDecl->fields(), [&](const FieldDecl *Field) {
+if (CXXRecordDecl *RD = Field->getType()
+->getBaseElementTypeUnsafe()
+->getAsCXXRecordDecl())
+  return isEmptyCudaDestructor(Loc, RD->getDestructor());
+return true;
+  }))
+return false;
+
   return true;
 }
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=270108=270107=270108=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu May 19 15:13:53 2016
@@ -10442,6 +10442,12 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
 AllowedInit = VD->getInit()->isConstantInitializer(
 Context, VD->getType()->isReferenceType());
 
+  // Also make sure that destructor, if there is one, is empty.
+  if (AllowedInit)
+if (CXXRecordDecl *RD = VD->getType()->getAsCXXRecordDecl())
+  AllowedInit =
+  isEmptyCudaDestructor(VD->getLocation(), RD->getDestructor());
+
   if (!AllowedInit) {
 Diag(VD->getLocation(), VD->hasAttr()
 ? 

Re: [PATCH] D20139: [CUDA] Split device-var-init.cu tests into separate Sema and CodeGen parts.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270107: [CUDA] Split device-var-init.cu tests into separate 
Sema and CodeGen parts. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20139?vs=56824=57848#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20139

Files:
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu
  cfe/trunk/test/SemaCUDA/device-var-init.cu

Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -5,8 +5,6 @@
 
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
 // RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
-// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
 
 #ifdef __clang__
 #include "Inputs/cuda.h"
@@ -89,21 +87,6 @@
 
 __device__ int d_v_i = 1;
 // CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
-#ifdef ERROR_CASE
-__shared__ int s_v_i = 1;
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-#endif
-__constant__ int c_v_i = 1;
-// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
-
-#ifdef ERROR_CASE
-__device__ int d_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ int s_v_f = f();
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ int c_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-#endif
 
 __device__ T d_t;
 // CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer
@@ -113,11 +96,7 @@
 // CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer,
 
 __device__ T d_t_i = {2};
-// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
-#ifdef ERROR_CASE
-__shared__ T s_t_i = {2};
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-#endif
+// CHECK: @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
 __constant__ T c_t_i = {2};
 // CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 },
 
@@ -128,118 +107,18 @@
 __constant__ EC c_ec;
 // CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
 
-#if ERROR_CASE
-__device__ EC d_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ EC c_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-
-__device__ EC d_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i2 = {3};
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ EC c_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-#endif
-
 __device__ ETC d_etc;
-// CHETCK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer,
+// CHECK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer,
 __shared__ ETC s_etc;
-// CHETCK: @s_etc = addrspace(3) global %struct.ETC undef,
+// CHECK: @s_etc = addrspace(3) global %struct.ETC undef,
 __constant__ ETC c_etc;
-// CHETCK: @c_etc = addrspace(4) externally_initialized global %struct.ETC zeroinitializer,
-
-#if ERROR_CASE
-__device__ ETC d_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ ETC s_etc_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ ETC c_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-
-__device__ ETC d_etc_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ ETC s_etc_i2 = {3};
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ ETC c_etc_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-
-__device__ UC d_uc;
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ UC s_uc;
-// expected-error@-1 {{initialization 

Re: [PATCH] D20140: [CUDA] Do not allow non-empty destructors for global device-side variables.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270108: [CUDA] Do not allow non-empty destructors for global 
device-side variables. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20140?vs=56829=57849#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20140

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu
  cfe/trunk/test/SemaCUDA/device-var-init.cu

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9036,6 +9036,7 @@
   /// \return true if \p CD can be considered empty according to CUDA
   /// (E.2.3.1 in CUDA 7.5 Programming guide).
   bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
+  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
 
   /// \name Code completion
   //@{
Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -24,6 +24,16 @@
   __device__ EC(int) {}  // -- not allowed
 };
 
+// empty destructor
+struct ED {
+  __device__ ~ED() {} // -- allowed
+};
+
+struct ECD {
+  __device__ ECD() {} // -- allowed
+  __device__ ~ECD() {}// -- allowed
+};
+
 // empty templated constructor -- allowed with no arguments
 struct ETC {
   template  __device__ ETC(T...) {}
@@ -35,6 +45,12 @@
   __device__ UC();
 };
 
+// undefined destructor -- not allowed
+struct UD {
+  int ud;
+  __device__ ~UD();
+};
+
 // empty constructor w/ initializer list -- not allowed
 struct ECI {
   int eci;
@@ -47,12 +63,23 @@
   __device__ NEC() { nec = 1; }
 };
 
+// non-empty destructor -- not allowed
+struct NED {
+  int ned;
+  __device__ ~NED() { ned = 1; }
+};
+
 // no-constructor,  virtual method -- not allowed
 struct NCV {
   int ncv;
   __device__ virtual void vm() {}
 };
 
+// virtual destructor -- not allowed.
+struct VD {
+  __device__ virtual ~VD() {}
+};
+
 // dynamic in-class field initializer -- not allowed
 __device__ int f();
 struct NCF {
@@ -107,6 +134,20 @@
 __constant__ EC c_ec;
 // CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
 
+__device__ ED d_ed;
+// CHECK: @d_ed = addrspace(1) externally_initialized global %struct.ED zeroinitializer,
+__shared__ ED s_ed;
+// CHECK: @s_ed = addrspace(3) global %struct.ED undef,
+__constant__ ED c_ed;
+// CHECK: @c_ed = addrspace(4) externally_initialized global %struct.ED zeroinitializer,
+
+__device__ ECD d_ecd;
+// CHECK: @d_ecd = addrspace(1) externally_initialized global %struct.ECD zeroinitializer,
+__shared__ ECD s_ecd;
+// CHECK: @s_ecd = addrspace(3) global %struct.ECD undef,
+__constant__ ECD c_ecd;
+// CHECK: @c_ecd = addrspace(4) externally_initialized global %struct.ECD zeroinitializer,
+
 __device__ ETC d_etc;
 // CHECK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer,
 __shared__ ETC s_etc;
@@ -180,6 +221,17 @@
   NEC nec[2];
 };
 
+
+// Inherited from or incapsulated class with non-empty desstructor --
+// not allowed
+struct T_B_NED : NED {};
+struct T_F_NED {
+  NED ned;
+};
+struct T_FA_NED {
+  NED ned[2];
+};
+
 // We should not emit global initializers for device-side variables.
 // CHECK-NOT: @__cxx_global_var_init
 
@@ -190,16 +242,26 @@
   // CHECK-NOT: call
   EC ec;
   // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
+  ED ed;
+  // CHECK-NOT: call
+  ECD ecd;
+  // CHECK:   call void @_ZN3ECDC1Ev(%struct.ECD* %ecd)
   ETC etc;
   // CHECK:   call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* %etc)
   UC uc;
   // CHECK:   call void @_ZN2UCC1Ev(%struct.UC* %uc)
+  UD ud;
+  // CHECK-NOT: call
   ECI eci;
   // CHECK:   call void @_ZN3ECIC1Ev(%struct.ECI* %eci)
   NEC nec;
   // CHECK:   call void @_ZN3NECC1Ev(%struct.NEC* %nec)
+  NED ned;
+  // CHECK:   call void @_ZN3NCVC1Ev(%struct.NCV* %ncv)
   NCV ncv;
   // CHECK-NOT: call
+  VD vd;
+  // CHECK:   call void @_ZN2VDC1Ev(%struct.VD* %vd)
   NCF ncf;
   // CHECK:   call void @_ZN3NCFC1Ev(%struct.NCF* %ncf)
   NCFS ncfs;
@@ -226,17 +288,31 @@
   // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
   T_FA_NEC t_fa_nec;
   // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
+  T_B_NED t_b_ned;
+  // CHECK-NOT: call
+  T_F_NED t_f_ned;
+  // CHECK-NOT: call
+  T_FA_NED t_fa_ned;
+  // CHECK-NOT: call
   static __shared__ EC s_ec;
   // CHECK-NOT: call void @_ZN2ECC1Ev(%struct.EC* addrspacecast (%struct.EC addrspace(3)* @_ZZ2dfvE4s_ec to %struct.EC*))
   static __shared__ ETC s_etc;
   // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*))
 
   // anchor point separating 

r270107 - [CUDA] Split device-var-init.cu tests into separate Sema and CodeGen parts.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 15:13:39 2016
New Revision: 270107

URL: http://llvm.org/viewvc/llvm-project?rev=270107=rev
Log:
[CUDA] Split device-var-init.cu tests into separate Sema and CodeGen parts.

Codegen tests for device-side variable initialization are subset of test
cases used to verify Sema's part of the job.
Including CodeGenCUDA/device-var-init.cu from SemaCUDA makes it easier to
keep both sides in sync.

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

Added:
cfe/trunk/test/SemaCUDA/device-var-init.cu
  - copied, changed from r270094, 
cfe/trunk/test/CodeGenCUDA/device-var-init.cu
Modified:
cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=270107=270106=270107=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Thu May 19 15:13:39 2016
@@ -5,8 +5,6 @@
 
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
 // RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
-// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
 
 #ifdef __clang__
 #include "Inputs/cuda.h"
@@ -89,21 +87,6 @@ __constant__ int c_v;
 
 __device__ int d_v_i = 1;
 // CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
-#ifdef ERROR_CASE
-__shared__ int s_v_i = 1;
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-#endif
-__constant__ int c_v_i = 1;
-// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
-
-#ifdef ERROR_CASE
-__device__ int d_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ int s_v_f = f();
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ int c_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-#endif
 
 __device__ T d_t;
 // CHECK: @d_t = addrspace(1) externally_initialized global %struct.T 
zeroinitializer
@@ -113,11 +96,7 @@ __constant__ T c_t;
 // CHECK: @c_t = addrspace(4) externally_initialized global %struct.T 
zeroinitializer,
 
 __device__ T d_t_i = {2};
-// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 
2 },
-#ifdef ERROR_CASE
-__shared__ T s_t_i = {2};
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-#endif
+// CHECK: @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 
2 },
 __constant__ T c_t_i = {2};
 // CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 
2 },
 
@@ -128,118 +107,18 @@ __shared__ EC s_ec;
 __constant__ EC c_ec;
 // CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC 
zeroinitializer,
 
-#if ERROR_CASE
-__device__ EC d_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ EC c_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-
-__device__ EC d_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i2 = {3};
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ EC c_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-#endif
-
 __device__ ETC d_etc;
-// CHETCK: @d_etc = addrspace(1) externally_initialized global %struct.ETC 
zeroinitializer,
+// CHECK: @d_etc = addrspace(1) externally_initialized global %struct.ETC 
zeroinitializer,
 __shared__ ETC s_etc;
-// CHETCK: @s_etc = addrspace(3) global %struct.ETC undef,
+// CHECK: @s_etc = addrspace(3) global %struct.ETC undef,
 __constant__ ETC c_etc;
-// CHETCK: @c_etc = addrspace(4) externally_initialized global %struct.ETC 
zeroinitializer,
-
-#if ERROR_CASE
-__device__ ETC d_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ ETC s_etc_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ ETC c_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-
-__device__ ETC d_etc_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and 

[PATCH] D20446: clang-rename: fix renaming members when referenced as macro arguments

2016-05-19 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

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

http://reviews.llvm.org/D20446

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/MemberExprMacro.cpp

Index: test/clang-rename/MemberExprMacro.cpp
===
--- /dev/null
+++ test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -103,7 +103,14 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  SourceLocation Location = Expr->getMemberLoc();
+  if (Location.isMacroID()) {
+// The location is expanded from a macro, look up the original spelling
+// location.
+const ASTContext  = Decl->getASTContext();
+Location = Context.getSourceManager().getSpellingLoc(Location);
+  }
+  LocationsFound.push_back(Location);
 }
 return true;
   }


Index: test/clang-rename/MemberExprMacro.cpp
===
--- /dev/null
+++ test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -103,7 +103,14 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  SourceLocation Location = Expr->getMemberLoc();
+  if (Location.isMacroID()) {
+// The location is expanded from a macro, look up the original spelling
+// location.
+const ASTContext  = Decl->getASTContext();
+Location = Context.getSourceManager().getSpellingLoc(Location);
+  }
+  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


Re: [PATCH] D20392: [CodeView] Modify emitTypeInformation to use MemoryTypeTableBuilder

2016-05-19 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D20392



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


Re: r266719 - Warn if function or variable cannot be implicitly instantiated

2016-05-19 Thread Serge Pavlov via cfe-commits
In this case moving implementation of `Singleton::getInstance()` into a
.cpp file would prevent compiler from instantiation of the method body when
it sees `Singleton::getInstance()`. In this case
`Singleton::getInstance()` must be instantiated in some source file
either explicitly or implicitly. If inline implementation for
`Singleton::getInstance()` is provided in the header, where
`Singleton` is defined, the method body is instantiated implicitly when
it is required. But the static field `instance` referenced in the method
still must be instantiated in some source file explicitly or implicitly. So
from viewpoint of convenience, moving the implementation of template
`Singleton::getInstance()` into source file does not look as more
inflexible solution.

Probably it is more convenient to put the template for the static member to
header file too:

template 
T *Singleton::instance = nullptr;


In this case both the method and corresponding static member are
instantiated implicitly by compiler, no warning occurs.
Can it be an acceptable solution?

If there is intention to limit `Singleton` to some selected types, explicit
instantiation declaration may help. Adding the declarations like:

extern template Foo *Singleton::instance;


prevents from warnings.

Or you think that the message should propose moving static member
definition into header file as well?


Thanks,
--Serge

2016-05-19 9:15 GMT+06:00 Sean Silva :

>
>
> On Thu, Apr 21, 2016 at 12:44 AM, Serge Pavlov 
> wrote:
>
>> Let me demonstrate the problem using excerpt from v8 sources:
>>
>> -- lithium.h 
>> template 
>> struct LSubKindOperand {
>>   static int* Create(int index) { return [index]; }
>>   static void SetUpCache();
>>   static int* cache;
>> };
>>
>> struct LOperand {
>>   static void SetUpCaches();
>> };
>>
>> #define LITHIUM_OPERAND_LIST(V)   \
>>   V(DoubleRegister,  1,   16)
>>
>> #define LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number)   \
>> typedef LSubKindOperand L##name;
>> LITHIUM_OPERAND_LIST(LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS)
>> /* Expands to: typedef LSubKindOperand<1, 16> LDoubleRegister; */
>> #undef LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS
>>
>> -- lithium.cc
>> #include "lithium.h"
>>
>> template
>> int* LSubKindOperand::cache = 0;
>>
>> template
>> void LSubKindOperand::SetUpCache() {
>>   cache = new int[kNumCachedOperands];
>> }
>>
>> void LOperand::SetUpCaches() {
>> #define LITHIUM_OPERAND_SETUP(name, type, number) L##name::SetUpCache();
>>   LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP)
>>   /* Expands to: LDoubleRegister::SetUpCache(); */
>> #undef LITHIUM_OPERAND_SETUP
>> }
>>
>> -- lithium-x64.cc ---
>> #include "lithium.h"
>>
>> int* GetNextSpillSlot(int kind) {
>>   return LSubKindOperand<1,16>::Create(0);
>> }
>>
>> int main(int argc, char *argv[]) {
>>   return 0;
>> }
>>
>> -- build.sh -
>> g++ lithium.cc lithium-x64.cc
>> -
>>
>> When compiler generates code for 'GetNextSpillSlot' it implicitly
>> instantiates the method 'Create'. It can do it as definition of the
>> template entity 'LSubKindOperand::Create' is available from lithium.h. Then
>> it attempts to instantiate static field 'LSubKindOperand::cache', as it is
>> used in the body of just instantiated method 'Create'. But definition of
>> this template entity  is not available while compiling lithium-x64.cc.
>> Failure to implicitly instantiate a template is not an error, but this
>> template must be instantiated somewhere else otherwise linker founds
>> undefined references.
>>
>> Indeed, 'LSubKindOperand<1,16>::cache' is instantiated while compiling
>> lithium.cc. Method 'LOperand::SetUpCaches' is not a template, it references
>> 'LSubKindOperand::SetUpCache', which in turn uses 'LSubKindOperand::cache'.
>> Definitions of these templates are available in lithium.cc, compiler
>> instantiates them and the program builds successfully. This solution is
>> fragile however, if lithium-x64.cc referenced
>> 'LSubKindOperand<1,1>::Create', the build would break because in lithium.cc
>> this specialization is not instantiated.
>>
>> Putting templates definitions into source files rather than headers is
>> similar to moving forward declarations into source files. It makes sense if
>> user wants to encapsulate some functionality. In this example he should
>> also move the definition 'LSubKindOperand::Create' to source file, just for
>> the sake of encapsulation. This would prevent compiler from implicit
>> instantiation of this method and thus from instantiation of the static
>> field as well.
>>
>> If encapsulation is not an aim, moving 

Re: [PATCH] D20341: [CUDA] Enable fusing FP ops for CUDA by default.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270094: [CUDA] Enable fusing FP ops (-ffp-contract=fast) for 
CUDA by default. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20341?vs=57541=57833#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20341

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCUDA/fp-contract.cu

Index: cfe/trunk/test/CodeGenCUDA/fp-contract.cu
===
--- cfe/trunk/test/CodeGenCUDA/fp-contract.cu
+++ cfe/trunk/test/CodeGenCUDA/fp-contract.cu
@@ -0,0 +1,32 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// By default we should fuse multiply/add into fma instruction.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=fast
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=on -- fusing by front-end (disabled).
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=on -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+// Explicit -ffp-contract=off should disable instruction fusing.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=off -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ float func(float a, float b, float c) { return a + b * c; }
+// ENABLED:   fma.rn.f32
+// ENABLED-NEXT:  st.param.f32
+
+// DISABLED:  mul.rn.f32
+// DISABLED-NEXT: add.rn.f32
+// DISABLED-NEXT: st.param.f32
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2255,10 +2255,15 @@
   LangOpts.ObjCExceptions = 1;
   }
 
-  // During CUDA device-side compilation, the aux triple is the triple used for
-  // host compilation.
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
-Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+  if (LangOpts.CUDA) {
+// During CUDA device-side compilation, the aux triple is the
+// triple used for host compilation.
+if (LangOpts.CUDAIsDevice)
+  Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+
+// Set default FP_CONTRACT to FAST.
+if (!Args.hasArg(OPT_ffp_contract))
+  Res.getCodeGenOpts().setFPContractMode(CodeGenOptions::FPC_Fast);
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the


Index: cfe/trunk/test/CodeGenCUDA/fp-contract.cu
===
--- cfe/trunk/test/CodeGenCUDA/fp-contract.cu
+++ cfe/trunk/test/CodeGenCUDA/fp-contract.cu
@@ -0,0 +1,32 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// By default we should fuse multiply/add into fma instruction.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=fast
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=on -- fusing by front-end (disabled).
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=on -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+// Explicit -ffp-contract=off should disable instruction fusing.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=off -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ float func(float a, float b, float c) { return a + b * c; }
+// ENABLED:   fma.rn.f32
+// ENABLED-NEXT:  st.param.f32
+
+// DISABLED:  mul.rn.f32
+// DISABLED-NEXT: add.rn.f32
+// DISABLED-NEXT: st.param.f32
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2255,10 +2255,15 @@
   LangOpts.ObjCExceptions = 1;
   }
 
-  // During CUDA device-side compilation, the aux triple is the triple used for
-  // host compilation.
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
-Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+  if (LangOpts.CUDA) {
+// During CUDA device-side compilation, the aux triple is the
+// 

r270094 - [CUDA] Enable fusing FP ops (-ffp-contract=fast) for CUDA by default.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 13:44:45 2016
New Revision: 270094

URL: http://llvm.org/viewvc/llvm-project?rev=270094=rev
Log:
[CUDA] Enable fusing FP ops (-ffp-contract=fast) for CUDA by default.

This matches default nvcc behavior and gives substantial
performance boost on GPU where fmad is much cheaper compared to add+mul.

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

Added:
cfe/trunk/test/CodeGenCUDA/fp-contract.cu
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=270094=270093=270094=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May 19 13:44:45 2016
@@ -2255,10 +2255,15 @@ bool CompilerInvocation::CreateFromArgs(
   LangOpts.ObjCExceptions = 1;
   }
 
-  // During CUDA device-side compilation, the aux triple is the triple used for
-  // host compilation.
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
-Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+  if (LangOpts.CUDA) {
+// During CUDA device-side compilation, the aux triple is the
+// triple used for host compilation.
+if (LangOpts.CUDAIsDevice)
+  Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+
+// Set default FP_CONTRACT to FAST.
+if (!Args.hasArg(OPT_ffp_contract))
+  Res.getCodeGenOpts().setFPContractMode(CodeGenOptions::FPC_Fast);
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the

Added: cfe/trunk/test/CodeGenCUDA/fp-contract.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/fp-contract.cu?rev=270094=auto
==
--- cfe/trunk/test/CodeGenCUDA/fp-contract.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/fp-contract.cu Thu May 19 13:44:45 2016
@@ -0,0 +1,32 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// By default we should fuse multiply/add into fma instruction.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=fast
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=on -- fusing by front-end (disabled).
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=on -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+// Explicit -ffp-contract=off should disable instruction fusing.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=off -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ float func(float a, float b, float c) { return a + b * c; }
+// ENABLED:   fma.rn.f32
+// ENABLED-NEXT:  st.param.f32
+
+// DISABLED:  mul.rn.f32
+// DISABLED-NEXT: add.rn.f32
+// DISABLED-NEXT: st.param.f32


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


Re: [PATCH] D20341: [CUDA] Enable fusing FP ops for CUDA by default.

2016-05-19 Thread Artem Belevich via cfe-commits
tra added a subscriber: chandlerc.
tra added a comment.

Short version of offline discussion with @chandlerc : Default of 
-ffp-contract=fast for CUDA is fine.


http://reviews.llvm.org/D20341



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


Re: [PATCH] D20341: [CUDA] Enable fusing FP ops for CUDA by default.

2016-05-19 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Well, if the CUDA documentation says so...let's do it.  :)  Thanks for your 
patience, everyone.


http://reviews.llvm.org/D20341



___
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-19 Thread Alexander Kornienko via cfe-commits
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=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=261990=261991=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 ) {
> >>  const ClangTidyMessage  = 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  : 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(());
> >>
> >> +  auto WorkingDir = Compiler.getSourceManager()
> >> +.getFileManager()
> >> +.getVirtualFileSystem()
> >> +->getCurrentWorkingDirectory();
> >> +  if (WorkingDir)
> >> +Context.setCurrentBuildDirectory(WorkingDir.get());
> >> +
> >>std::vector Checks;
> >>CheckFactories->createChecks(, Checks);
> >>
> >> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr >>  void handleErrors(const std::vector , bool Fix,
> >>unsigned ) {
> >>ErrorReporter Reporter(Fix);
> >> -  for (const ClangTidyError  : Errors)
> >> +  vfs::FileSystem  =
> >> +
> *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
> >> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
> >> +  if (!InitialWorkingDir)
> >> +llvm::report_fatal_error("Cannot get current working path.");
> >> +
> >> +  for (const ClangTidyError  : Errors) {
> >> +if (!Error.BuildDirectory.empty()) {
> >> +  // By default, the working directory of file system is the
> current
> >> +  // clang-tidy running directory.
> >> +  //
> >> +  // Change the directory to the one used during the analysis.
> >> +  FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
> >> +}
> >>  Reporter.reportDiagnostic(Error);
> >> +// Return to the initial directory to correctly resolve next Error.
> >> +

r270089 - [MS ABI] Ignore transparent contexts when determining the effective context

2016-05-19 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu May 19 13:15:53 2016
New Revision: 270089

URL: http://llvm.org/viewvc/llvm-project?rev=270089=rev
Log:
[MS ABI] Ignore transparent contexts when determining the effective context

We didn't skip over extern "C++" contexts, causing us to mangle things
which don't need to be mangled.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=270089=270088=270089=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu May 19 13:15:53 2016
@@ -94,7 +94,7 @@ static const DeclContext *getEffectiveDe
 return getEffectiveDeclContext(cast(DC));
   }
 
-  return DC;
+  return DC->getRedeclContext();
 }
 
 static const DeclContext *getEffectiveParentContext(const DeclContext *DC) {

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=270089=270088=270089=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Thu May 19 13:15:53 2016
@@ -4,6 +4,11 @@
 int a;
 // CHECK-DAG: @"\01?a@@3HA"
 
+extern "C++" {
+static int __attribute__((used)) ignore_transparent_context;
+// CHECK-DAG: @ignore_transparent_context
+}
+
 namespace N {
   int b;
 // CHECK-DAG: @"\01?b@N@@3HA"


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


Re: [PATCH] D20141: Check for nullptr argument.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270086: Check for nullptr argument. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20141?vs=56832=57825#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20141

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2082,7 +2082,7 @@
 
   // Check that D is not yet in DiagnosedConflictingDefinitions is required
   // to make sure that we issue an error only once.
-  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
   (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
 else if (D->hasAttr())


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2082,7 +2082,7 @@
 
   // Check that D is not yet in DiagnosedConflictingDefinitions is required
   // to make sure that we issue an error only once.
-  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
   (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
 else if (D->hasAttr())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270086 - Check for nullptr argument.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 13:00:18 2016
New Revision: 270086

URL: http://llvm.org/viewvc/llvm-project?rev=270086=rev
Log:
Check for nullptr argument.

Addresses static analysis report in PR15492.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=270086=270085=270086=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu May 19 13:00:18 2016
@@ -2082,7 +2082,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 
   // Check that D is not yet in DiagnosedConflictingDefinitions is required
   // to make sure that we issue an error only once.
-  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
   (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@ CharUnits CodeGenModule::GetTargetTypeSt
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
 else if (D->hasAttr())


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


r270085 - Don't rely on value numbers in test, those are fragile and change in Release (no asserts) builds.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 12:57:35 2016
New Revision: 270085

URL: http://llvm.org/viewvc/llvm-project?rev=270085=rev
Log:
Don't rely on value numbers in test, those are fragile and change in Release 
(no asserts) builds.

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=270085=270084=270085=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 12:57:35 2016
@@ -1012,13 +1012,13 @@ __m256d test_mm512_extractf64x4_pd(__m51
 }
 
 __m256d test_mm512_mask_extractf64x4_pd(__m256d  __W,__mmask8  __U,__m512d 
__A){
- //CHECK-LABLE:@test_mm512_mask_extractf64x4_pd
+ //CHECK-LABEL:@test_mm512_mask_extractf64x4_pd
  //CHECL:@llvm.x86.avx512.mask.vextractf64x4.512
  return _mm512_mask_extractf64x4_pd( __W, __U, __A, 1);
 }
 
 __m256d test_mm512_maskz_extractf64x4_pd(__mmask8  __U,__m512d __A){
- //CHECK-LABLE:@test_mm512_maskz_extractf64x4_pd
+ //CHECK-LABEL:@test_mm512_maskz_extractf64x4_pd
  //CHECL:@llvm.x86.avx512.mask.vextractf64x4.512
  return _mm512_maskz_extractf64x4_pd( __U, __A, 1);
 }
@@ -1031,13 +1031,13 @@ __m128 test_mm512_extractf32x4_ps(__m512
 }
 
 __m128 test_mm512_mask_extractf32x4_ps(__m128 __W, __mmask8  __U,__m512d __A){
- //CHECK-LABLE:@test_mm512_mask_extractf32x4_ps
+ //CHECK-LABEL:@test_mm512_mask_extractf32x4_ps
  //CHECL: @llvm.x86.avx512.mask.vextractf32x4.512
  return _mm512_mask_extractf32x4_ps( __W, __U, __A, 1);
 }
 
 __m128 test_mm512_maskz_extractf32x4_ps( __mmask8  __U,__m512d __A){
- //CHECK-LABLE:@test_mm512_maskz_extractf32x4_ps
+ //CHECK-LABEL:@test_mm512_maskz_extractf32x4_ps
  //CHECL: @llvm.x86.avx512.mask.vextractf32x4.512
  return _mm512_maskz_extractf32x4_ps(  __U, __A, 1);
 }
@@ -1453,7 +1453,7 @@ __m512i test_mm512_mask_andnot_epi32 (__
 
 __m512i test_mm512_andnot_si512(__m512i __A, __m512i __B)
 {
-  //CHECK-LABLE: @test_mm512_andnot_si512
+  //CHECK-LABEL: @test_mm512_andnot_si512
   //CHECK: load {{.*}}%__A.addr.i, align 64
   //CHECK: %neg.i = xor{{.*}}, 
   //CHECK: load {{.*}}%__B.addr.i, align 64
@@ -6516,7 +6516,7 @@ __m512i test_mm512_maskz_min_epu64 (__mm
 
 __m512i test_mm512_mask_set1_epi32 (__m512i __O, __mmask16 __M, int __A)
 {
-//CHECK-LABLE: @test_mm512_mask_set1_epi32
+//CHECK-LABEL: @test_mm512_mask_set1_epi32
 //CHECK: @llvm.x86.avx512.mask.pbroadcast.d.gpr.512
   return _mm512_mask_set1_epi32 ( __O, __M, __A);
 }
@@ -6526,7 +6526,7 @@ __m512i test_mm512_set_epi32 (int __A, i
int __I, int __J, int __K, int __L,
int __M, int __N, int __O, int __P)
 {
- //CHECK-LABLE: @test_mm512_set_epi32
+ //CHECK-LABEL: @test_mm512_set_epi32
  //CHECK: insertelement{{.*}}i32 0
 //CHECK: insertelement{{.*}}i32 1
 //CHECK: insertelement{{.*}}i32 2
@@ -6552,24 +6552,24 @@ __m512i test_mm512_setr_epi32 (int __A,
int __I, int __J, int __K, int __L,
int __M, int __N, int __O, int __P)
 {
-//CHECK-LABLE: @test_mm512_setr_epi32
- //CHECK: %0 = load{{.*}}%__P.addr, align 4
- //CHECK: %1 = load{{.*}}%__O.addr, align 4
- //CHECK: %2 = load{{.*}}%__N.addr, align 4
- //CHECK: %3 = load{{.*}}%__M.addr, align 4
- //CHECK: %4 = load{{.*}}%__L.addr, align 4
- //CHECK: %5 = load{{.*}}%__K.addr, align 4
- //CHECK: %6 = load{{.*}}%__J.addr, align 4
- //CHECK: %7 = load{{.*}}%__I.addr, align 4
- //CHECK: %8 = load{{.*}}%__H.addr, align 4
- //CHECK: %9 = load{{.*}}%__G.addr, align 4
- //CHECK: %10 = load{{.*}}%__F.addr, align 4
- //CHECK: %11 = load{{.*}}%__E.addr, align 4
- //CHECK: %12 = load{{.*}}%__D.addr, align 4
- //CHECK: %13 = load{{.*}}%__C.addr, align 4
- //CHECK: %14 = load{{.*}}%__B.addr, align 4
- //CHECK: %15 = load{{.*}}%__A.addr, align 4
- //CHECK: insertelement{{.*}}i32 0
+//CHECK-LABEL: @test_mm512_setr_epi32
+//CHECK: load{{.*}}%__P.addr, align 4
+//CHECK: load{{.*}}%__O.addr, align 4
+//CHECK: load{{.*}}%__N.addr, align 4
+//CHECK: load{{.*}}%__M.addr, align 4
+//CHECK: load{{.*}}%__L.addr, align 4
+//CHECK: load{{.*}}%__K.addr, align 4
+//CHECK: load{{.*}}%__J.addr, align 4
+//CHECK: load{{.*}}%__I.addr, align 4
+//CHECK: load{{.*}}%__H.addr, align 4
+//CHECK: load{{.*}}%__G.addr, align 4
+//CHECK: load{{.*}}%__F.addr, align 4
+//CHECK: load{{.*}}%__E.addr, align 4
+//CHECK: load{{.*}}%__D.addr, align 4
+//CHECK: load{{.*}}%__C.addr, align 4
+//CHECK: load{{.*}}%__B.addr, align 4
+//CHECK: load{{.*}}%__A.addr, align 4
+//CHECK: insertelement{{.*}}i32 0
 //CHECK: insertelement{{.*}}i32 1
 //CHECK: insertelement{{.*}}i32 2
 //CHECK: insertelement{{.*}}i32 3
@@ -6591,7 +6591,7 @@ __m512i test_mm512_setr_epi32 (int __A,
 
 __m512i test_mm512_mask_set1_epi64 (__m512i __O, __mmask8 __M, long long __A)
 {
-

Re: [PATCH] D20405: [CUDA] allow sm_50,52,53 GPUs

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270084: [CUDA] Allow sm_50,52,53 GPUs (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20405?vs=57715=57822#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20405

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/test/CodeGen/nvptx-cpus.c

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1750,6 +1750,10 @@
   } else if (GpuArch == "compute_35") {
 CudaLibDeviceMap["sm_35"] = FilePath;
 CudaLibDeviceMap["sm_37"] = FilePath;
+  } else if (GpuArch == "compute_50") {
+CudaLibDeviceMap["sm_50"] = FilePath;
+CudaLibDeviceMap["sm_52"] = FilePath;
+CudaLibDeviceMap["sm_53"] = FilePath;
   }
 }
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1689,6 +1689,9 @@
 GK_SM30,
 GK_SM35,
 GK_SM37,
+GK_SM50,
+GK_SM52,
+GK_SM53,
   } GPU;
 
 public:
@@ -1787,6 +1790,15 @@
   case GK_SM37:
 CUDAArchCode = "370";
 break;
+  case GK_SM50:
+CUDAArchCode = "500";
+break;
+  case GK_SM52:
+CUDAArchCode = "520";
+break;
+  case GK_SM53:
+CUDAArchCode = "530";
+break;
   default:
 llvm_unreachable("Unhandled target CPU");
   }
@@ -1836,6 +1848,9 @@
   .Case("sm_30", GK_SM30)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
+  .Case("sm_50", GK_SM50)
+  .Case("sm_52", GK_SM52)
+  .Case("sm_53", GK_SM53)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
Index: cfe/trunk/test/CodeGen/nvptx-cpus.c
===
--- cfe/trunk/test/CodeGen/nvptx-cpus.c
+++ cfe/trunk/test/CodeGen/nvptx-cpus.c
@@ -3,6 +3,9 @@
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_30 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_37 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_52 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 -O3 -S -o 
%t %s -emit-llvm
 
 // Make sure clang accepts all supported architectures.
 


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1750,6 +1750,10 @@
   } else if (GpuArch == "compute_35") {
 CudaLibDeviceMap["sm_35"] = FilePath;
 CudaLibDeviceMap["sm_37"] = FilePath;
+  } else if (GpuArch == "compute_50") {
+CudaLibDeviceMap["sm_50"] = FilePath;
+CudaLibDeviceMap["sm_52"] = FilePath;
+CudaLibDeviceMap["sm_53"] = FilePath;
   }
 }
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1689,6 +1689,9 @@
 GK_SM30,
 GK_SM35,
 GK_SM37,
+GK_SM50,
+GK_SM52,
+GK_SM53,
   } GPU;
 
 public:
@@ -1787,6 +1790,15 @@
   case GK_SM37:
 CUDAArchCode = "370";
 break;
+  case GK_SM50:
+CUDAArchCode = "500";
+break;
+  case GK_SM52:
+CUDAArchCode = "520";
+break;
+  case GK_SM53:
+CUDAArchCode = "530";
+break;
   default:
 llvm_unreachable("Unhandled target CPU");
   }
@@ -1836,6 +1848,9 @@
   .Case("sm_30", GK_SM30)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
+  .Case("sm_50", GK_SM50)
+  .Case("sm_52", GK_SM52)
+  .Case("sm_53", GK_SM53)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
Index: cfe/trunk/test/CodeGen/nvptx-cpus.c
===
--- cfe/trunk/test/CodeGen/nvptx-cpus.c
+++ cfe/trunk/test/CodeGen/nvptx-cpus.c
@@ -3,6 +3,9 @@
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_30 -O3 -S -o %t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 -O3 -S -o %t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_37 -O3 -S -o %t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 -O3 -S -o %t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown 

r270084 - [CUDA] Allow sm_50,52,53 GPUs

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 12:47:47 2016
New Revision: 270084

URL: http://llvm.org/viewvc/llvm-project?rev=270084=rev
Log:
[CUDA] Allow sm_50,52,53 GPUs

LLVM accepts them since r233575.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/CodeGen/nvptx-cpus.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270084=270083=270084=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu May 19 12:47:47 2016
@@ -1689,6 +1689,9 @@ class NVPTXTargetInfo : public TargetInf
 GK_SM30,
 GK_SM35,
 GK_SM37,
+GK_SM50,
+GK_SM52,
+GK_SM53,
   } GPU;
 
 public:
@@ -1787,6 +1790,15 @@ public:
   case GK_SM37:
 CUDAArchCode = "370";
 break;
+  case GK_SM50:
+CUDAArchCode = "500";
+break;
+  case GK_SM52:
+CUDAArchCode = "520";
+break;
+  case GK_SM53:
+CUDAArchCode = "530";
+break;
   default:
 llvm_unreachable("Unhandled target CPU");
   }
@@ -1836,6 +1848,9 @@ public:
   .Case("sm_30", GK_SM30)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
+  .Case("sm_50", GK_SM50)
+  .Case("sm_52", GK_SM52)
+  .Case("sm_53", GK_SM53)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270084=270083=270084=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 12:47:47 2016
@@ -1750,6 +1750,10 @@ void Generic_GCC::CudaInstallationDetect
   } else if (GpuArch == "compute_35") {
 CudaLibDeviceMap["sm_35"] = FilePath;
 CudaLibDeviceMap["sm_37"] = FilePath;
+  } else if (GpuArch == "compute_50") {
+CudaLibDeviceMap["sm_50"] = FilePath;
+CudaLibDeviceMap["sm_52"] = FilePath;
+CudaLibDeviceMap["sm_53"] = FilePath;
   }
 }
 

Modified: cfe/trunk/test/CodeGen/nvptx-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-cpus.c?rev=270084=270083=270084=diff
==
--- cfe/trunk/test/CodeGen/nvptx-cpus.c (original)
+++ cfe/trunk/test/CodeGen/nvptx-cpus.c Thu May 19 12:47:47 2016
@@ -3,6 +3,9 @@
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_30 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_37 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_52 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 -O3 -S -o 
%t %s -emit-llvm
 
 // Make sure clang accepts all supported architectures.
 


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


[PATCH] [clang] Emit ObjC method and block annotation attributes to IR

2016-05-19 Thread Max Bazaliy via cfe-commits
Hey,

For some reason clang does not emit ObjC method and block annotations to
IR. Here is a fix for that.

-- 
Max Bazaliy


objc_blocks_emit_ir.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread don hinton via cfe-commits
hintonda added a comment.

Sure that sounds good to me.  However, I would like to learn how to write 
better ASTMatchers.

In any case, this has been a great learning experience.


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D20428#434420, @hintonda wrote:

> I can already catch all of these cases, but I can't catch this one, will this 
> catch it too?
>
>   void g(void (*fp)(void) throw()) throw();
>   ^^^
>
>
> Actually, I can catch it, but I haven't been able to create an ASTMatcher 
> that will only include FunctionDecl's -- even using functionDecl() still 
> returns all Decl's, not just FunctionDecl's.


Yes, this information is also tracked as part of my patch. I've added a few 
more test cases for it, thank you!

Assuming that @rsmith thinks my direction is reasonable for tracking source 
information, I strongly prefer to gate your patch on this one. Your custom 
parser may work fine, but I don't think it should be required since we already 
have this information from the real parser. Might as well thread the 
information through so that it can be used by tooling.


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 57816.
aaron.ballman added a comment.

Added test cases for parameter types that have exception specifications.


http://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -580,5 +580,72 @@
   Language::Lang_CXX11));
 }
 
+class ExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const TypeLoc ) override {
+auto T =
+  Node.getUnqualifiedLoc().castAs();
+assert(!T.isNull());
+return T.getExceptionSpecRange();
+  }
+};
+
+class ParmVarExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const ParmVarDecl ) override {
+if (const TypeSourceInfo *TSI = Node.getTypeSourceInfo()) {
+  TypeLoc TL = TSI->getTypeLoc();
+  if (TL.getType()->isPointerType()) {
+TL = TL.getNextTypeLoc().IgnoreParens();
+if (auto FPTL = TL.getAs()) {
+  return FPTL.getExceptionSpecRange();
+}
+  }
+}
+return SourceRange();
+  }
+};
+
+TEST(FunctionDecl, ExceptionSpecifications) {
+  ExceptionSpecRangeVerifier Verifier;
+
+  Verifier.expectRange(1, 10, 1, 16);
+  EXPECT_TRUE(Verifier.match("void f() throw();\n", loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 34);
+  EXPECT_TRUE(Verifier.match("void f() throw(void(void) throw());\n",
+ loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 19);
+  std::vector Args;
+  Args.push_back("-fms-extensions");
+  EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
+ Args, Language::Lang_CXX));
+
+  Verifier.expectRange(1, 10, 1, 17);
+  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 24);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 32);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
+ loc(functionType()), Language::Lang_CXX11));
+
+  ParmVarExceptionSpecRangeVerifier Verifier2;
+  Verifier2.expectRange(1, 25, 1, 31);
+  EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) throw());\n",
+  parmVarDecl(hasType(pointerType(pointee(
+  parenType(innerType(functionType();
+
+  Verifier2.expectRange(1, 25, 1, 38);
+  EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) noexcept(true));\n",
+  parmVarDecl(hasType(pointerType(pointee(
+  parenType(innerType(functionType())),
+  Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -572,6 +572,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5812,6 +5812,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+  TL.setExceptionSpecRange(SourceRange(ReadSourceLocation(Record, Idx),
+   ReadSourceLocation(Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, ReadDeclAs(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4919,6 +4919,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); i 

Re: [PATCH] D20383: PCH + Module: make sure we write out macros associated with builtin identifiers

2016-05-19 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks Bruno



Comment at: lib/Serialization/ASTWriter.cpp:2191
@@ -2191,1 +2190,3 @@
+// We write out exported module macros for PCH as well.
+if (true) {
   auto Leafs = PP.getLeafModuleMacros(Name);

bruno wrote:
> Is this intended?
I was trying to make sure people get that it is the only thing this patch 
changes :) I will remove it if we are okay with this approach.



http://reviews.llvm.org/D20383



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


[clang-tools-extra] r270082 - [include-fixer] Fix unused variable warning in Release builds.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 11:57:57 2016
New Revision: 270082

URL: http://llvm.org/viewvc/llvm-project?rev=270082=rev
Log:
[include-fixer] Fix unused variable warning in Release builds.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=270082=270081=270082=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu May 19 11:57:57 
2016
@@ -259,10 +259,11 @@ public:
   Insertions.insert(
   clang::tooling::Replacement(Filename, FirstIncludeOffset, 0, Text));
 }
-DEBUG(llvm::dbgs() << "Header insertions:\n");
-for (const auto  : Insertions) {
-  DEBUG(llvm::dbgs() << R.toString() << "\n");
-}
+DEBUG({
+  llvm::dbgs() << "Header insertions:\n";
+  for (const auto  : Insertions)
+llvm::dbgs() << R.toString() << '\n';
+});
 
 clang::format::FormatStyle Style =
 clang::format::getStyle("file", Filename, FallbackStyle);


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


r270079 - [X86][SSE2] Fixed shuffle of results in _mm_cmpnge_sd/_mm_cmpngt_sd tests

2016-05-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu May 19 11:48:59 2016
New Revision: 270079

URL: http://llvm.org/viewvc/llvm-project?rev=270079=rev
Log:
[X86][SSE2] Fixed shuffle of results in _mm_cmpnge_sd/_mm_cmpngt_sd tests

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

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=270079=270078=270079=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Thu May 19 11:48:59 2016
@@ -306,6 +306,10 @@ __m128d test_mm_cmpnge_pd(__m128d A, __m
 __m128d test_mm_cmpnge_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_cmpnge_sd
   // CHECK: call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, i8 6)
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_cmpnge_sd(A, B);
 }
 
@@ -318,6 +322,10 @@ __m128d test_mm_cmpngt_pd(__m128d A, __m
 __m128d test_mm_cmpngt_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_cmpngt_sd
   // CHECK: call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, i8 5)
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_cmpngt_sd(A, B);
 }
 


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


Re: [PATCH] D20420: [find-all-symbol] Add macro support.

2016-05-19 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

In the future I'd prefer to do renaming changes 
(ResultReporter->SymbolReporter) in a separate change, but this is fine now.



Comment at: include-fixer/find-all-symbols/SymbolReporter.h:1
@@ +1,2 @@
+//===-- SymbolReporter.h - find all symbols--*- C++ 
-*-===//
+//

find all symbols?


http://reviews.llvm.org/D20420



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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-05-19 Thread don hinton via cfe-commits
hintonda added a comment.

Btw, this version can successfully check libcxx.


http://reviews.llvm.org/D18575



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


Re: [PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 57810.
vsk added a comment.

- Fix explanation of the test case in test/CoverageMapping.


http://reviews.llvm.org/D20401

Files:
  lib/Lex/TokenLexer.cpp
  test/CoverageMapping/Inputs/macros.h
  test/CoverageMapping/include-macros.c
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -58,8 +58,7 @@
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  std::vector CheckLex(StringRef Source,
-  ArrayRef ExpectedTokens) {
+  std::vector Lex(StringRef Source) {
 std::unique_ptr Buf =
 llvm::MemoryBuffer::getMemBuffer(Source);
 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
@@ -82,6 +81,12 @@
   toks.push_back(tok);
 }
 
+return toks;
+  }
+
+  std::vector CheckLex(StringRef Source,
+  ArrayRef ExpectedTokens) {
+auto toks = Lex(Source);
 EXPECT_EQ(ExpectedTokens.size(), toks.size());
 for (unsigned i = 0, e = ExpectedTokens.size(); i != e; ++i) {
   EXPECT_EQ(ExpectedTokens[i], toks[i].getKind());
@@ -358,4 +363,21 @@
   EXPECT_EQ("N", Lexer::getImmediateMacroName(idLoc4, SourceMgr, LangOpts));
 }
 
+TEST_F(LexerTest, DontMergeMacroArgsFromDifferentMacroFiles) {
+  std::vector toks =
+  Lex("#define helper1 0\n"
+  "void helper2(const char *, ...);\n"
+  "#define M1(a, ...) helper2(a, ##__VA_ARGS__)\n"
+  "#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__)\n"
+  "void f1() { M2(\"a\", \"b\"); }");
+
+  // Check the file corresponding to the "helper1" macro arg in M2.
+  //
+  // The lexer used to report its size as 31, meaning that the end of the
+  // expansion would be on the *next line* (just past `M2("a", "b")`). Make
+  // sure that we get the correct end location (the comma after "helper1").
+  SourceLocation helper1ArgLoc = toks[20].getLocation();
+  EXPECT_EQ(SourceMgr.getFileIDSize(SourceMgr.getFileID(helper1ArgLoc)), 8U);
+}
+
 } // anonymous namespace
Index: test/CoverageMapping/include-macros.c
===
--- /dev/null
+++ test/CoverageMapping/include-macros.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name include-macros.c %s | FileCheck %s
+
+#include "Inputs/macros.h"
+
+void f1() {
+  M2("a", "b");
+}
+
+// CHECK-LABEL: f1:
+// CHECK-NEXT:   File 0, 5:11 -> 7:2 = #0
+// CHECK-NEXT:   Expansion,File 0, 6:3 -> 6:5 = #0 (Expanded file = 1)
+// CHECK-NEXT:   File 1, 13:20 -> 13:50 = #0
+// CHECK-NEXT:   Expansion,File 1, 13:20 -> 13:22 = #0 (Expanded file = 2)
+// CHECK-NEXT:   File 2, 7:20 -> 7:46 = #0
+// CHECK-NEXT:   Expansion,File 2, 7:33 -> 7:44 = #0 (Expanded file = 3)
+// CHECK-NEXT:   File 3, 13:26 -> 13:34 = #0
+// CHECK-NEXT:   Expansion,File 3, 13:26 -> 13:33 = #0 (Expanded file = 4)
+// CHECK-NEXT:   File 4, 3:17 -> 3:18 = #0
Index: test/CoverageMapping/Inputs/macros.h
===
--- /dev/null
+++ test/CoverageMapping/Inputs/macros.h
@@ -0,0 +1,13 @@
+// Assorted macros to help test #include behavior across file boundaries.
+
+#define helper1 0
+
+void helper2(const char *, ...);
+
+#define M1(a, ...) helper2(a, ##__VA_ARGS__);
+
+// Note: M2 stresses vararg macro functions with macro arguments. The spelling
+// locations of the args used to be set to the expansion site, leading to
+// crashes (region LineEnd < LineStart). The regression test requires M2's line
+// number to be greater than the line number containing the expansion.
+#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__);
Index: lib/Lex/TokenLexer.cpp
===
--- lib/Lex/TokenLexer.cpp
+++ lib/Lex/TokenLexer.cpp
@@ -787,6 +787,9 @@
 if (CurLoc.isFileID() != NextLoc.isFileID())
   break; // Token from different kind of FileID.
 
+if (CurLoc.isMacroID() && !SM.isWrittenInSameFile(CurLoc, NextLoc))
+  break; // Token from a different macro.
+
 int RelOffs;
 if (!SM.isInSameSLocAddrSpace(CurLoc, NextLoc, ))
   break; // Token from different local/loaded location.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-19 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: include/clang/Sema/DeclSpec.h:1152-1169
@@ -1153,19 +1151,20 @@
 
   struct ArrayTypeInfo : TypeInfoCommon {
-/// The type qualifiers for the array: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers for the array:
+/// const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 
 /// True if this dimension included the 'static' keyword.
 bool hasStatic : 1;
 
 /// True if this dimension was [*].  In this case, NumElts is null.
 bool isStar : 1;
 
 /// This is the size of the array, or null if [] or [*] was specified.
 /// Since the parser is multi-purpose, and we don't want to impose a root
 /// expression class on all clients, NumElts is untyped.
 Expr *NumElts;
 
 void destroy() {}
   };
 

Should `__unaligned` actually be carried here or does MSVC discard the 
qualifier here?


Comment at: include/clang/Sema/DeclSpec.h:1414-1418
@@ -1414,7 +1413,7 @@
 
   struct MemberPointerTypeInfo : TypeInfoCommon {
-/// The type qualifiers: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 union {

Ditto.  Do we need storage for this bit or should we make sure it got discarded 
earlier?


http://reviews.llvm.org/D20437



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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread don hinton via cfe-commits
hintonda added a comment.

I can already catch all of these cases, but I can't catch this one, will this 
catch it too?

  void g(void (*fp)(void) throw()) throw();
  ^^^


http://reviews.llvm.org/D20428



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


Re: r269220 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-19 Thread Andrey Bokhanko via cfe-commits
David,

All these cases are handled properly now.

Could you, please, review?

http://reviews.llvm.org/D20437

Yours,
Andrey


On Sat, May 14, 2016 at 6:11 AM, David Majnemer 
wrote:

> FYI, the following is a little shorter:
> using Ty = int () __unaligned;
>
> Also, this case (in C mode) is interesting:
> void f(int x[__unaligned 4]);
>
> DeclaratorChunk::getArray will truncate the TypeQuals
> because ArrayTypeInfo's TypeQuals doesn't have enough bits.
>
> similar issues arise with:
> struct A;
>
> void (A::*__unaligned vpa)();
>
> On Fri, May 13, 2016 at 4:03 PM,  wrote:
>
>> Hi David,
>>
>> Thanks for letting me know -- will investigate after the weekend.
>>
>> Yours,
>> Andrey
>>
>> Отправлено с iPad
>>
>> 13 мая 2016 г., в 20:33, David Majnemer 
>> написал(а):
>>
>> This seems to crash clang:
>> struct S {
>>   void f() __unaligned;
>> };
>> void S::f() __unaligned {
>> }
>>
>> clang/lib/Sema/DeclSpec.cpp:214: static clang::DeclaratorChunk
>> clang::DeclaratorChunk::getFunction(bool, bool, clang::SourceLocation,
>> clang::DeclaratorChunk::ParamInfo *, unsigned int, clang::SourceLocation,
>> clang::SourceLocation, unsigned int, bool, clang::SourceLocation,
>> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation,
>> clang::SourceLocation, clang::ExceptionSpecificationType,
>> clang::SourceRange, ParsedType *, clang::SourceRange *, unsigned int,
>> clang::Expr *, CachedTokens *, clang::SourceLocation,
>> clang::SourceLocation, clang::Declarator &, TypeResult): Assertion
>> `I.Fun.TypeQuals == TypeQuals && "bitfield overflow"' failed.
>>
>>
>> On Wed, May 11, 2016 at 11:38 AM, Andrey Bokhanko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: asbokhan
>>> Date: Wed May 11 13:38:21 2016
>>> New Revision: 269220
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269220=rev
>>> Log:
>>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>>
>>> This patch implements __unaligned (MS extension) as a proper type
>>> qualifier
>>> (before that, it was implemented as an ignored attribute).
>>>
>>> It also fixes PR27367 and PR27666.
>>>
>>> Differential Revision: http://reviews.llvm.org/D20103
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/include/clang/Sema/DeclSpec.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/ParseTentative.cpp
>>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>>> cfe/trunk/test/Sema/address_spaces.c
>>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Type.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220=269219=269220=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Type.h (original)
>>> +++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2016
>>> @@ -111,6 +111,7 @@ namespace clang {
>>>  /// The collection of all-type qualifiers we support.
>>>  /// Clang supports five independent qualifiers:
>>>  /// * C99: const, volatile, and restrict
>>> +/// * MS: __unaligned
>>>  /// * Embedded C (TR18037): address spaces
>>>  /// * Objective C: the GC attributes (none, weak, or strong)
>>>  class Qualifiers {
>>> @@ -152,8 +153,8 @@ public:
>>>
>>>enum {
>>>  /// The maximum supported address space number.
>>> -/// 24 bits should be enough for anyone.
>>> -MaxAddressSpace = 0xffu,
>>> +/// 23 bits should be enough for anyone.
>>> +MaxAddressSpace = 0x7fu,
>>>
>>>  /// The width of the "fast" qualifier mask.
>>>  FastWidth = 3,
>>> @@ -265,6 +266,13 @@ public:
>>>  Mask |= mask;
>>>}
>>>
>>> +  bool hasUnaligned() const { return Mask & UMask; }
>>> +  void setUnaligned(bool flag) {
>>> +Mask = (Mask & ~UMask) | (flag ? UMask : 0);
>>> +  }
>>> +  void removeUnaligned() { Mask &= ~UMask; }
>>> +  void addUnaligned() { Mask |= UMask; }
>>> +
>>>bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
>>>GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >>
>>> GCAttrShift); }
>>>void setObjCGCAttr(GC type) {
>>> @@ 

[PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-19 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer.
andreybokhanko added a subscriber: cfe-commits.

This adds support of MS-specific "__unaligned" qualifier for function types and 
fixes errors described by David Majnemer in this thread: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160509/thread.html#158098

Yours,
Andrey
=
Software Engineer
Intel Compiler Team

http://reviews.llvm.org/D20437

Files:
  include/clang/AST/Type.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclCXX.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1643,7 +1643,7 @@
 
   QualType ClassTy = C.getTypeDeclType(getParent());
   ClassTy = C.getQualifiedType(ClassTy,
-   Qualifiers::fromCVRMask(getTypeQualifiers()));
+   Qualifiers::fromCVRUMask(getTypeQualifiers()));
   return C.getPointerType(ClassTy);
 }
 
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1447,7 +1447,8 @@
   if (HasRestrict)
 Out << 'I';
 
-  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+  if (Quals.hasUnaligned() ||
+  (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned()))
 Out << 'F';
 }
 
@@ -1822,7 +1823,7 @@
   // If this is a C++ instance method, mangle the CVR qualifiers for the
   // this pointer.
   if (HasThisQuals) {
-Qualifiers Quals = Qualifiers::fromCVRMask(Proto->getTypeQuals());
+Qualifiers Quals = Qualifiers::fromCVRUMask(Proto->getTypeQuals());
 manglePointerExtQualifiers(Quals, /*PointeeType=*/QualType());
 mangleRefQualifier(Proto->getRefQualifier());
 mangleQualifiers(Quals, /*IsMember=*/false);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2668,8 +2668,8 @@
 { "const", DeclSpec::TQ_const, ConstQualLoc },
 { "volatile", DeclSpec::TQ_volatile, VolatileQualLoc },
 { "restrict", DeclSpec::TQ_restrict, RestrictQualLoc },
-{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc },
-{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc }
+{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc },
+{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc }
   };
 
   SmallString<32> QualStr;
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -796,8 +796,8 @@
   case TQ_const:TQ_constLoc = Loc; return false;
   case TQ_restrict: TQ_restrictLoc = Loc; return false;
   case TQ_volatile: TQ_volatileLoc = Loc; return false;
-  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
+  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   }
 
   llvm_unreachable("Unknown type qualifier!");
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -934,6 +934,7 @@
   else
 Record = cast(ContextDecl);
 
+  CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -215,6 +215,12 @@
 return Qs;
   }
 
+  static Qualifiers fromCVRUMask(unsigned CVRU) {
+Qualifiers Qs;
+Qs.addCVRUQualifiers(CVRU);
+return Qs;
+  }
+
   // Deserialize qualifiers from an opaque representation.
   static Qualifiers fromOpaqueValue(unsigned opaque) {
 Qualifiers Qs;
@@ -265,6 +271,10 @@
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask |= mask;
   }
+  void addCVRUQualifiers(unsigned mask) {
+assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits");
+Mask |= mask;
+  }
 
   bool hasUnaligned() const { return Mask & UMask; }
   void setUnaligned(bool flag) {
@@ -1372,7 +1382,7 @@
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// \brief The ref-qualifier associated with a \c FunctionProtoType.
 ///
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ 

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Martin Probst via cfe-commits
mprobst marked 2 inline comments as done.
mprobst added a comment.

Thanks for the review, appreciated!



Comment at: lib/Format/SortJavaScriptImports.cpp:160
@@ +159,3 @@
+  if (i + 1 < e) {
+// Insert breaks between imports.
+ReferencesText += "\n";

klimek wrote:
> Between categories of imports and imports and exports, right?
Added a comment.


Comment at: lib/Format/SortJavaScriptImports.cpp:170-171
@@ +169,4 @@
+// Separate references from the main code body of the file.
+if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
+  ReferencesText += "\n";
+

klimek wrote:
> Shouldn't we add 2 if NewlinesBefore is 0? Or is that syntactically 
> impossible?
The next token is on a new line, so it gets a wrap just from that already. I've 
added a test though.


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D20428#434270, @alexfh wrote:

> In http://reviews.llvm.org/D20428#434242, @aaron.ballman wrote:
>
> > In http://reviews.llvm.org/D20428#434238, @alexfh wrote:
> >
> > > Full context diff, please.
> >
> >
> > Pardon my complete ignorance, but how? I generated the diff from svn the 
> > usual way, so I assume I've missed some step.
>
>
> There are at least two ways to do this:
>
> 1. both `git diff` and `svn diff` can be convinced to produce diffs with full 
> context: 
> http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
> 2. I find arcanist a very useful alternative to using web-interface for 
> posting diffs: 
> http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line


Hmm, so (1) it's strange that I've yet to run into this before today, and (2) 
I'm on Windows using TortoiseSVN, so the command line help isn't overly helpful 
and it seems Tortoise doesn't have this functionality with its Create Patch 
menu item or related options. Sorry for the lack of context in my latest 
upload, but it does have two important changes:

1. noexcept now tracks its full source range, not just the start location of 
the noexcept token,
2. now, with actual tests.


http://reviews.llvm.org/D20428



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


r270067 - [driver][mips] Hardcode triple name in case of CodeSourcery toolchain. NFC

2016-05-19 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu May 19 10:05:22 2016
New Revision: 270067

URL: http://llvm.org/viewvc/llvm-project?rev=270067=rev
Log:
[driver][mips] Hardcode triple name in case of CodeSourcery toolchain. NFC

CodeSourcery toolchain is a standalone toolchain which always uses
the same triple name in its paths. It is independent from target
triple used by the driver.

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270067=270066=270067=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 10:05:22 2016
@@ -2011,7 +2011,7 @@ static bool findMIPSMultilibs(const Driv
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   std::string SysRootInc =
-  InstallDir.str() + "/../../../../" + TripleStr.str();
+  InstallDir.str() + "/../../../../mips-linux-gnu";
   if (StringRef(M.includeSuffix()).startswith("/uclibc"))
 Dirs.push_back(SysRootInc + "/libc/uclibc/usr/include");
   else


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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 57798.
aaron.ballman added a comment.

For noexcept specifications without an expression, now tracking the full source 
range. Also, added tests.


http://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -580,5 +580,44 @@
   Language::Lang_CXX11));
 }
 
+class ExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const TypeLoc ) override {
+auto T =
+  Node.getUnqualifiedLoc().castAs();
+assert(!T.isNull());
+return T.getExceptionSpecRange();
+  }
+};
+
+TEST(FunctionDecl, ExceptionSpecifications) {
+  ExceptionSpecRangeVerifier Verifier;
+
+  Verifier.expectRange(1, 10, 1, 16);
+  EXPECT_TRUE(Verifier.match("void f() throw();\n", loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 34);
+  EXPECT_TRUE(Verifier.match("void f() throw(void(void) throw());\n",
+ loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 19);
+  std::vector Args;
+  Args.push_back("-fms-extensions");
+  EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
+ Args, Language::Lang_CXX));
+
+  Verifier.expectRange(1, 10, 1, 17);
+  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 24);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 32);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
+ loc(functionType()), Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -572,6 +572,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5812,6 +5812,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+  TL.setExceptionSpecRange(SourceRange(ReadSourceLocation(Record, Idx),
+   ReadSourceLocation(Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, ReadDeclAs(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4919,6 +4919,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
 NewTL.setParam(i, ParamDecls[i]);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5065,7 +5065,7 @@
 ParmVarDecl *Param = cast(FTI.Params[i].Param);
 TL.setParam(tpi++, Param);
   }
-  // FIXME: exception specs
+  TL.setExceptionSpecRange(FTI.getExceptionSpecRange());
 }
 void VisitParenTypeLoc(ParenTypeLoc TL) {
   assert(Chunk.Kind == DeclaratorChunk::Paren);
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3400,7 +3400,8 @@
 
   // If we already had a dynamic specification, parse the noexcept for,
   // recovery, but emit a diagnostic and don't store the results.
-  SourceRange NoexceptRange;
+  SourceRange NoexceptRange(Tok.getLocation(),
+Tok.getEndLoc().getLocWithOffset(-1));
   ExceptionSpecificationType NoexceptType = EST_None;
 
   SourceLocation KeywordLoc 

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/SortJavaScriptImports.cpp:160
@@ +159,3 @@
+  if (i + 1 < e) {
+// Insert breaks between imports.
+ReferencesText += "\n";

Between categories of imports and imports and exports, right?


Comment at: lib/Format/SortJavaScriptImports.cpp:170-171
@@ +169,4 @@
+// Separate references from the main code body of the file.
+if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
+  ReferencesText += "\n";
+

Shouldn't we add 2 if NewlinesBefore is 0? Or is that syntactically impossible?


http://reviews.llvm.org/D20198



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


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-05-19 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 57796.
a.sidorin marked an inline comment as done.
a.sidorin added a comment.

Add some basic tests for ExpressionTraitExpr and ArrayTypeTraitExpr.


http://reviews.llvm.org/D14326

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/DeclFriend.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class3.cpp
  test/ASTMerge/Inputs/exprs3.cpp
  test/ASTMerge/class2.cpp
  test/ASTMerge/exprs.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -466,5 +466,48 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher vaArgExpr;
+
+/// \brief Matches the decayed type, whose original type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasOriginalType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+
+TEST(ImportExpr, ImportVAArgExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport(__builtin_va_list list, ...) {"
+  "  (void)__builtin_va_arg(list, int); }",
+  Lang_CXX, "", Lang_CXX, Verifier,
+  functionDecl(
+hasParameter(0,
+ varDecl(
+   hasName("list"),
+   hasType(
+ decayedType(
+   hasOriginalType(
+ typedefType(
+   hasDeclaration(
+ typedefDecl(
+   hasName("__builtin_va_list"),
+   hasType(
+ constantArrayType(
+   hasSize(1),
+   hasElementType(
+ qualType(
+   recordType(),
+   asString("struct __va_list_tag"
+  ),
+hasBody(
+  compoundStmt(
+has(
+  cStyleCastExpr(
+hasSourceExpression(
+  vaArgExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: test/ASTMerge/exprs.cpp
===
--- /dev/null
+++ test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 , S1 ) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: test/ASTMerge/class2.cpp
===
--- /dev/null
+++ test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: test/ASTMerge/Inputs/exprs3.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+const unsigned wchar_t Ch6 = L'f';
+
+const short C1 = 12;
+const unsigned short C2 = 13;
+
+const int C3 = 12;
+const unsigned int C4 = 13;
+
+const long C5 = 22;
+const unsigned long C6 = 23;
+
+const long long C7 = 66;
+const unsigned long long C8 = 67;
+
+
+// String literals
+const char str1[] = "ABCD";
+const char str2[] = "ABCD" "0123";
+
+const 

r270068 - [driver] Do not pass target triple to the MultilibSet include dirs callback

2016-05-19 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu May 19 10:07:00 2016
New Revision: 270068

URL: http://llvm.org/viewvc/llvm-project?rev=270068=rev
Log:
[driver] Do not pass target triple to the MultilibSet include dirs callback

No one callback uses target triple so we can escape passing the unused
argument.

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=270068=270067=270068=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Thu May 19 10:07:00 2016
@@ -99,9 +99,9 @@ public:
   typedef multilib_list::iterator iterator;
   typedef multilib_list::const_iterator const_iterator;
 
-  typedef std::function
-  IncludeDirsFunc;
+  typedef std::function
+  IncludeDirsFunc;
 
   typedef llvm::function_ref FilterCallback;
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270068=270067=270068=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 10:07:00 2016
@@ -1924,7 +1924,7 @@ static bool findMIPSMultilibs(const Driv
 .FilterOut(".*sof/nan2008")
 .FilterOut(NonExistent)
 .setIncludeDirsCallback([](StringRef InstallDir,
-   StringRef TripleStr, const Multilib ) 
{
+   const Multilib ) {
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   std::string SysRootInc =
@@ -1954,8 +1954,8 @@ static bool findMIPSMultilibs(const Driv
 MuslMipsMultilibs = MultilibSet().Either(MArchMipsR2, MArchMipselR2);
 
 // Specify the callback that computes the include directories.
-MuslMipsMultilibs.setIncludeDirsCallback([](
-StringRef InstallDir, StringRef TripleStr, const Multilib ) {
+MuslMipsMultilibs.setIncludeDirsCallback([](StringRef InstallDir,
+const Multilib ) {
   std::vector Dirs;
   Dirs.push_back(
   (InstallDir + "/../sysroot" + M.osSuffix() + "/usr/include").str());
@@ -2007,7 +2007,7 @@ static bool findMIPSMultilibs(const Driv
 .FilterOut("/micromips.*/64")
 .FilterOut(NonExistent)
 .setIncludeDirsCallback([](StringRef InstallDir,
-   StringRef TripleStr, const Multilib ) 
{
+   const Multilib ) {
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   std::string SysRootInc =
@@ -2060,7 +2060,7 @@ static bool findMIPSMultilibs(const Driv
 .Maybe(LittleEndian)
 .FilterOut(NonExistent)
 .setIncludeDirsCallback([](StringRef InstallDir,
-   StringRef TripleStr, const Multilib ) 
{
+   const Multilib ) {
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   Dirs.push_back(
@@ -2540,8 +2540,7 @@ void MipsLLVMToolChain::AddClangSystemIn
 
   const auto  = Multilibs.includeDirsCallback();
   if (Callback) {
-const auto IncludePaths =
-Callback(D.getInstalledDir(), getTripleString(), SelectedMultilib);
+const auto IncludePaths = Callback(D.getInstalledDir(), SelectedMultilib);
 for (const auto  : IncludePaths)
   addExternCSystemIncludeIfExists(DriverArgs, CC1Args, Path);
   }
@@ -2588,8 +2587,8 @@ void MipsLLVMToolChain::AddClangCXXStdli
 
   const auto  = Multilibs.includeDirsCallback();
   if (Callback) {
-const auto IncludePaths = Callback(getDriver().getInstalledDir(),
-   getTripleString(), SelectedMultilib);
+const auto IncludePaths =
+Callback(getDriver().getInstalledDir(), SelectedMultilib);
 for (const auto  : IncludePaths) {
   if (llvm::sys::fs::exists(Path + "/c++/v1")) {
 addSystemInclude(DriverArgs, CC1Args, Path + "/c++/v1");
@@ -3971,7 +3970,6 @@ void Linux::AddClangSystemIncludeArgs(co
 const auto  = Multilibs.includeDirsCallback();
 if (Callback) {
   const auto IncludePaths = Callback(GCCInstallation.getInstallPath(),
- GCCInstallation.getTriple().str(),
  GCCInstallation.getMultilib());
   for (const auto  : IncludePaths)
 

r270069 - [driver] Do not pass install dir to the MultilibSet include dirs callback

2016-05-19 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu May 19 10:07:21 2016
New Revision: 270069

URL: http://llvm.org/viewvc/llvm-project?rev=270069=rev
Log:
[driver] Do not pass install dir to the MultilibSet include dirs callback

All additional include directories are relative to the toolchain install
folder. So let's do not pass this folder to each callback to simplify
and slightly reduce the code.

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=270069=270068=270069=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Thu May 19 10:07:21 2016
@@ -99,8 +99,7 @@ public:
   typedef multilib_list::iterator iterator;
   typedef multilib_list::const_iterator const_iterator;
 
-  typedef std::function
+  typedef std::function
   IncludeDirsFunc;
 
   typedef llvm::function_ref FilterCallback;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270069=270068=270069=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 10:07:21 2016
@@ -1923,16 +1923,12 @@ static bool findMIPSMultilibs(const Driv
 .Maybe(Nan2008)
 .FilterOut(".*sof/nan2008")
 .FilterOut(NonExistent)
-.setIncludeDirsCallback([](StringRef InstallDir,
-   const Multilib ) {
-  std::vector Dirs;
-  Dirs.push_back((InstallDir + "/include").str());
-  std::string SysRootInc =
-  InstallDir.str() + "/../../../../sysroot";
+.setIncludeDirsCallback([](const Multilib ) {
+  std::vector Dirs({"/include"});
   if (StringRef(M.includeSuffix()).startswith("/uclibc"))
-Dirs.push_back(SysRootInc + "/uclibc/usr/include");
+Dirs.push_back("/../../../../sysroot/uclibc/usr/include");
   else
-Dirs.push_back(SysRootInc + "/usr/include");
+Dirs.push_back("/../../../../sysroot/usr/include");
   return Dirs;
 });
   }
@@ -1954,12 +1950,9 @@ static bool findMIPSMultilibs(const Driv
 MuslMipsMultilibs = MultilibSet().Either(MArchMipsR2, MArchMipselR2);
 
 // Specify the callback that computes the include directories.
-MuslMipsMultilibs.setIncludeDirsCallback([](StringRef InstallDir,
-const Multilib ) {
-  std::vector Dirs;
-  Dirs.push_back(
-  (InstallDir + "/../sysroot" + M.osSuffix() + "/usr/include").str());
-  return Dirs;
+MuslMipsMultilibs.setIncludeDirsCallback([](const Multilib ) {
+  return std::vector(
+  {"/../sysroot" + M.osSuffix() + "/usr/include"});
 });
   }
 
@@ -2006,16 +1999,13 @@ static bool findMIPSMultilibs(const Driv
 .FilterOut("/mips16.*/64")
 .FilterOut("/micromips.*/64")
 .FilterOut(NonExistent)
-.setIncludeDirsCallback([](StringRef InstallDir,
-   const Multilib ) {
-  std::vector Dirs;
-  Dirs.push_back((InstallDir + "/include").str());
-  std::string SysRootInc =
-  InstallDir.str() + "/../../../../mips-linux-gnu";
+.setIncludeDirsCallback([](const Multilib ) {
+  std::vector Dirs({"/include"});
   if (StringRef(M.includeSuffix()).startswith("/uclibc"))
-Dirs.push_back(SysRootInc + "/libc/uclibc/usr/include");
+Dirs.push_back(
+"/../../../../mips-linux-gnu/libc/uclibc/usr/include");
   else
-Dirs.push_back(SysRootInc + "/libc/usr/include");
+Dirs.push_back("/../../../../mips-linux-gnu/libc/usr/include");
   return Dirs;
 });
   }
@@ -2059,13 +2049,9 @@ static bool findMIPSMultilibs(const Driv
 .Maybe(MAbi64)
 .Maybe(LittleEndian)
 .FilterOut(NonExistent)
-.setIncludeDirsCallback([](StringRef InstallDir,
-   const Multilib ) {
-  std::vector Dirs;
-  Dirs.push_back((InstallDir + "/include").str());
-  Dirs.push_back(
-  (InstallDir + "/../../../../sysroot/usr/include").str());
-  return Dirs;
+.setIncludeDirsCallback([](const Multilib ) {
+  return std::vector(
+

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57795.
mprobst added a comment.

- ranges


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,194 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::string sort(StringRef Code, unsigned Offset = 0, unsigned Length = 0) {
+StringRef FileName = "input.js";
+if (Length == 0U)
+  Length = Code.size() - Offset;
+std::vector Ranges(1, tooling::Range(Offset, Length));
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code,
+  unsigned Offset = 0, unsigned Length = 0) {
+std::string Result = sort(Code, Offset, Length);
+EXPECT_EQ(Expected.str(), Result) << "Expected:\n"
+  << Expected << "\nActual:\n"
+  << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, AlreadySorted) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from 

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57794.
mprobst added a comment.

- correctly insert breaks after import block


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,180 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::string sort(StringRef Code, unsigned Offset = 0, unsigned Length = 0) {
+StringRef FileName = "input.js";
+if (Length == 0U)
+  Length = Code.size() - Offset;
+std::vector Ranges(1, tooling::Range(Offset, Length));
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code,
+  unsigned Offset = 0, unsigned Length = 0) {
+std::string Result = sort(Code, Offset, Length);
+EXPECT_EQ(Expected.str(), Result) << "Expected:\n"
+  << Expected << "\nActual:\n"
+  << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, AlreadySorted) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ 

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

2016-05-19 Thread Hans Wennborg via cfe-commits
+Tom who manages 3.8.1
+Alex who's owner of clang-tidy: is this ok for 3.8.1?

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=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=261990=261991=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 ) {
>>  const ClangTidyMessage  = 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  : 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(());
>>
>> +  auto WorkingDir = Compiler.getSourceManager()
>> +.getFileManager()
>> +.getVirtualFileSystem()
>> +->getCurrentWorkingDirectory();
>> +  if (WorkingDir)
>> +Context.setCurrentBuildDirectory(WorkingDir.get());
>> +
>>std::vector Checks;
>>CheckFactories->createChecks(, Checks);
>>
>> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr>  void handleErrors(const std::vector , bool Fix,
>>unsigned ) {
>>ErrorReporter Reporter(Fix);
>> -  for (const ClangTidyError  : Errors)
>> +  vfs::FileSystem  =
>> +  *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
>> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
>> +  if (!InitialWorkingDir)
>> +llvm::report_fatal_error("Cannot get current working path.");
>> +
>> +  for (const ClangTidyError  : Errors) {
>> +if (!Error.BuildDirectory.empty()) {
>> +  // By default, the working directory of file system is the current
>> +  // clang-tidy running directory.
>> +  //
>> +  // Change the directory to the one used during the analysis.
>> +  FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
>> +}
>>  Reporter.reportDiagnostic(Error);
>> +// Return to the initial directory to correctly resolve next Error.
>> +FileSystem.setCurrentWorkingDirectory(InitialWorkingDir.get());
>> +  }
>>Reporter.Finish();
>>WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
>>  }
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
>> URL: 
>> 

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:22
@@ +21,3 @@
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.

alexfh wrote:
> This method assumes a rather non-trivial definition of "valid". Please add a 
> comment what exactly this method does.
> 
> Also, static is preferred to anonymous namespaces for functions in LLVM style 
> (http://llvm.org/docs/CodingStandards.html#anonymous-namespaces):
> | ... make anonymous namespaces as small as possible, and only use them for 
> class declarations. ...
I have renamed to `IsCheckable`, but it doesn't make more sense here. Do you 
have better suggestion on the function name? 


Comment at: test/clang-tidy/misc-unused-using-decls.cpp:86
@@ +85,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is 
unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+

Will do it in a follow-up.


http://reviews.llvm.org/D20429



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


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57790.
hokein added a comment.

Forgot a comments.


http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+llvm::SmallPtrSet UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,25 @@
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool IsCheckable(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult ) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();
+  if (IsCheckable(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto  : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+  Context.IsUsed = 

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57785.
hokein marked 4 inline comments as done.
hokein added a comment.

Address comments.


http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+std::set UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,25 @@
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool IsCheckable(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult ) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();
+  if (IsCheckable(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto  : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+  

Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D20428#434242, @aaron.ballman wrote:

> In http://reviews.llvm.org/D20428#434238, @alexfh wrote:
>
> > Full context diff, please.
>
>
> Pardon my complete ignorance, but how? I generated the diff from svn the 
> usual way, so I assume I've missed some step.


There are at least two ways to do this:

1. both `git diff` and `svn diff` can be convinced to produce diffs with full 
context: 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
2. I find arcanist a very useful alternative to using web-interface for posting 
diffs: 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 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:22
@@ +21,3 @@
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.

This method assumes a rather non-trivial definition of "valid". Please add a 
comment what exactly this method does.

Also, static is preferred to anonymous namespaces for functions in LLVM style 
(http://llvm.org/docs/CodingStandards.html#anonymous-namespaces):
| ... make anonymous namespaces as small as possible, and only use them for 
class declarations. ...


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:29
@@ +28,3 @@
+  if (isa(TargetDecl->getDeclContext())) {
+llvm::errs() << "context\n";
+return false;

Debug output?


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:102
@@ +101,3 @@
+  for (auto  : Contexts) {
+if (Context.UsingTargetDecls.find(D->getCanonicalDecl()) !=
+Context.UsingTargetDecls.end()) {

.count() for sets is as effective, but results in clearer code.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.h:39
@@ +38,3 @@
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+std::set UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;

`SmallPtrSet` should be more efficient here.


Comment at: test/clang-tidy/misc-unused-using-decls.cpp:86
@@ +85,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is 
unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+

Not for this patch, but it makes sense to remove trailing comments on deleted 
lines.


http://reviews.llvm.org/D20429



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


[clang-tools-extra] r270059 - [include-fixer] Remove an unused local variable ExistingHeaders.

2016-05-19 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu May 19 08:23:27 2016
New Revision: 270059

URL: http://llvm.org/viewvc/llvm-project?rev=270059=rev
Log:
[include-fixer] Remove an unused local variable ExistingHeaders.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=270059=270058=270059=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu May 19 08:23:27 
2016
@@ -242,8 +242,6 @@ public:
   std::vector
   CreateReplacementsForHeaders(StringRef Code,
const std::set ) {
-std::set ExistingHeaders;
-
 // Create replacements for new headers.
 clang::tooling::Replacements Insertions;
 if (FirstIncludeOffset == -1U) {


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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Full context diff, please.

> I'm not certain of the best way to test this functionality in isolation;


Same way other locations/ranges are tested in 
unittests/AST/SourceLocationTest.cpp?


http://reviews.llvm.org/D20428



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


[PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added subscribers: djasper, cfe-commits.

http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+std::set UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,24 @@
 namespace tidy {
 namespace misc {
 
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext())) {
+llvm::errs() << "context\n";
+return false;
+  }
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+} // namespace
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +48,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult ) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();
+  if (IsValidDecl(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +98,24 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto  : Contexts) {
+if (Context.UsingTargetDecls.find(D->getCanonicalDecl()) !=
+Context.UsingTargetDecls.end()) {
+  Context.IsUsed = true;
+  break;
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
-  for (const auto  : FoundDecls) {
-if (FoundDecl.second == nullptr)
-  

Re: [PATCH] D20394: Fix cdp intrinsic

2016-05-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270058: [ARM] Fix cdp intrinsic (authored by rsingh).

Changed prior to commit:
  http://reviews.llvm.org/D20394?vs=57698=5#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20394

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

Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -52,8 +52,8 @@
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
 BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
 
Index: cfe/trunk/test/CodeGen/builtins-arm.c
===
--- cfe/trunk/test/CodeGen/builtins-arm.c
+++ cfe/trunk/test/CodeGen/builtins-arm.c
@@ -84,6 +84,20 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void cdp() {
+  // CHECK: define void @cdp()
+  // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp(1, 2, 3, 4, 5, 6);
+}
+
+void cdp2() {
+  // CHECK: define void @cdp2()
+  // CHECK: call void @llvm.arm.cdp2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, 6);
+}
+
 unsigned mrc() {
   // CHECK: define i32 @mrc()
   // CHECK: [[R:%.*]] = call i32 @llvm.arm.mrc(i32 15, i32 0, i32 13, i32 0, 
i32 3)
Index: cfe/trunk/test/Sema/builtins-arm.c
===
--- cfe/trunk/test/Sema/builtins-arm.c
+++ cfe/trunk/test/Sema/builtins-arm.c
@@ -48,6 +48,18 @@
 }
 
 void test6(int a, int b, int c) {
+  __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}}
+  __builtin_arm_cdp(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+
+  __builtin_arm_cdp2(a, 2, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, a, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, a, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+
   __builtin_arm_mrc( a, 0, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, a, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, 0,  a, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}


Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -52,8 +52,8 @@
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
 BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
 
Index: cfe/trunk/test/CodeGen/builtins-arm.c
===
--- cfe/trunk/test/CodeGen/builtins-arm.c
+++ cfe/trunk/test/CodeGen/builtins-arm.c
@@ -84,6 +84,20 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void cdp() {
+  // CHECK: define void @cdp()
+  // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp(1, 2, 3, 4, 5, 

r270058 - [ARM] Fix cdp intrinsic

2016-05-19 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Thu May 19 08:04:34 2016
New Revision: 270058

URL: http://llvm.org/viewvc/llvm-project?rev=270058=rev
Log:
[ARM] Fix cdp intrinsic

- Fixed cdp intrinsic to only accept compile time
  constant values previously you could pass in a
  variable to the builtin which would result in
  illegal llvm assembly output

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/test/CodeGen/builtins-arm.c
cfe/trunk/test/Sema/builtins-arm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=270058=270057=270058=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Thu May 19 08:04:34 2016
@@ -52,8 +52,8 @@ BUILTIN(__builtin_arm_mcr, "vUIiUIiUiUIi
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
 BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
 

Modified: cfe/trunk/test/CodeGen/builtins-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm.c?rev=270058=270057=270058=diff
==
--- cfe/trunk/test/CodeGen/builtins-arm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm.c Thu May 19 08:04:34 2016
@@ -84,6 +84,20 @@ void prefetch(int i) {
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void cdp() {
+  // CHECK: define void @cdp()
+  // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp(1, 2, 3, 4, 5, 6);
+}
+
+void cdp2() {
+  // CHECK: define void @cdp2()
+  // CHECK: call void @llvm.arm.cdp2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, 6);
+}
+
 unsigned mrc() {
   // CHECK: define i32 @mrc()
   // CHECK: [[R:%.*]] = call i32 @llvm.arm.mrc(i32 15, i32 0, i32 13, i32 0, 
i32 3)

Modified: cfe/trunk/test/Sema/builtins-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-arm.c?rev=270058=270057=270058=diff
==
--- cfe/trunk/test/Sema/builtins-arm.c (original)
+++ cfe/trunk/test/Sema/builtins-arm.c Thu May 19 08:04:34 2016
@@ -48,6 +48,18 @@ void test5() {
 }
 
 void test6(int a, int b, int c) {
+  __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}}
+  __builtin_arm_cdp(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+
+  __builtin_arm_cdp2(a, 2, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, a, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, a, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+
   __builtin_arm_mrc( a, 0, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, a, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, 0,  a, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}


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


[PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman added subscribers: cfe-commits, hintonda, alexfh.

We do not currently track the source locations for exception specifications 
such that their source range can be queried through the AST. This leads to 
trying to write more complex code to determine the source range for uses like 
FixItHints (see D18575 for an example). In addition to use within tools like 
clang-tidy, I think this information may become more important to track as 
exception specifications become more integrated into the type system.

One thing this patch is missing is a test case. I'm not certain of the best way 
to test this functionality in isolation; suggestions welcome.

http://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -572,6 +572,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5812,6 +5812,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+  TL.setExceptionSpecRange(SourceRange(ReadSourceLocation(Record, Idx),
+   ReadSourceLocation(Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, ReadDeclAs(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4919,6 +4919,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
 NewTL.setParam(i, ParamDecls[i]);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5065,7 +5065,7 @@
 ParmVarDecl *Param = cast(FTI.Params[i].Param);
 TL.setParam(tpi++, Param);
   }
-  // FIXME: exception specs
+  TL.setExceptionSpecRange(FTI.getExceptionSpecRange());
 }
 void VisitParenTypeLoc(ParenTypeLoc TL) {
   assert(Chunk.Kind == DeclaratorChunk::Paren);
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2935,6 +2935,18 @@
   return RTRange;
 }
 
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+  const TypeSourceInfo *TSI = getTypeSourceInfo();
+  if (!TSI)
+return SourceRange();
+  FunctionTypeLoc FTL =
+TSI->getTypeLoc().IgnoreParens().getAs();
+  if (!FTL)
+return SourceRange();
+
+  return FTL.getExceptionSpecRange();
+}
+
 const Attr *FunctionDecl::getUnusedResultAttr() const {
   QualType RetType = getReturnType();
   if (RetType->isRecordType()) {
Index: include/clang/AST/TypeLoc.h
===
--- include/clang/AST/TypeLoc.h
+++ include/clang/AST/TypeLoc.h
@@ -1248,6 +1248,7 @@
   SourceLocation LocalRangeBegin;
   SourceLocation LParenLoc;
   SourceLocation RParenLoc;
+  SourceRange ExceptionSpecRange;
   SourceLocation LocalRangeEnd;
 };
 
@@ -1289,6 +1290,13 @@
 return SourceRange(getLParenLoc(), getRParenLoc());
   }
 
+  SourceRange getExceptionSpecRange() const {
+return this->getLocalData()->ExceptionSpecRange;
+  }
+  void setExceptionSpecRange(SourceRange R) {
+this->getLocalData()->ExceptionSpecRange = R;
+  }
+
   ArrayRef getParams() const {
 return llvm::makeArrayRef(getParmArray(), getNumParams());
   }
@@ -1318,6 +1326,7 @@
 setLocalRangeBegin(Loc);
 setLParenLoc(Loc);
 setRParenLoc(Loc);
+setExceptionSpecRange(SourceRange(Loc));
 setLocalRangeEnd(Loc);
 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
   setParam(i, nullptr);
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ 

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.

lg


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20424: [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270055: [include-fixer] Make search handle fully qualified 
names correctly. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D20424?vs=57766=57772#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20424

Files:
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we 
evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= (SymbolContext == Symbol.getContexts().end());
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {


Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= (SymbolContext == Symbol.getContexts().end());
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r270055 - [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 07:41:56 2016
New Revision: 270055

URL: http://llvm.org/viewvc/llvm-project?rev=270055=rev
Log:
[include-fixer] Make search handle fully qualified names correctly.

If a search string starts with "::" we don't want to return any results
for suffixes of that string.

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

Modified:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=270055=270054=270055=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Thu May 19 
07:41:56 2016
@@ -24,6 +24,12 @@ SymbolIndexManager::search(llvm::StringR
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@ SymbolIndexManager::search(llvm::StringR
   }
 }
 
+// If the name was qualified we only want to add results if we 
evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= (SymbolContext == Symbol.getContexts().end());
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=270055=270054=270055=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Thu 
May 19 07:41:56 2016
@@ -103,6 +103,12 @@ TEST(IncludeFixer, Typo) {
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {


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


Re: [PATCH] D20424: [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.



Comment at: include-fixer/SymbolIndexManager.cpp:73
@@ +72,3 @@
+if (IsFullyQualified)
+  IsMatched &= SymbolContext == Symbol.getContexts().end();
+

Might be `IsMatched &= (SymbolContext == Symbol.getContexts().end());` for 
reading clearly?


http://reviews.llvm.org/D20424



___
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-19 Thread jojo.ma via cfe-commits
jojo added inline comments.


Comment at: lib/Support/TargetParser.cpp:441
@@ +440,3 @@
+  if (Extensions & AArch64::AEK_PROFILE)
+Features.push_back("+spe");
+

bsmith wrote:
> For ARM there is a table that defines these extensions and how they map to 
> backend features, it would be good to do this in a similar manner.
There is a similar one for aarch64.But only in the context of switch-case,they 
can be map to backend features by table look-up. eg,getArchExtName().
We need to judge the value of "Extensions" by means of bit operations here.It 
is not possible to use the table.


Comment at: lib/Support/TargetParser.cpp:770
@@ +769,3 @@
+  if (A.ID == ARM::AK_ARMV8_2A)
+Features.push_back("+v8.2a");
+  return A.ID;

bsmith wrote:
> Why do we need to add these features explicitly, can't we just pass through 
> the correct triple?
Sometimes people do not give a complete and standardized triple, which leads to 
the obtaining of these features by triple impossible.
It maybe safer to add these features by "-march".


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


[PATCH] D20424: [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added reviewers: hokein, ioeric.
bkramer added a subscriber: cfe-commits.

If a search string starts with "::" we don't want to return any results
for suffixes of that string.

http://reviews.llvm.org/D20424

Files:
  include-fixer/SymbolIndexManager.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we 
evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= SymbolContext == Symbol.getContexts().end();
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= SymbolContext == Symbol.getContexts().end();
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270047 - [Clang][AVX512][intrinsics] continue completing missing set intrinsics

2016-05-19 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu May 19 07:07:49 2016
New Revision: 270047

URL: http://llvm.org/viewvc/llvm-project?rev=270047=rev
Log:
[Clang][AVX512][intrinsics] continue completing missing set intrinsics

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


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=270047=270046=270047=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu May 19 07:07:49 2016
@@ -8983,6 +8983,21 @@ _mm512_mask_set1_epi64 (__m512i __O, __m
  __M);
 }
 
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_set_epi32 (int __A, int __B, int __C, int __D,
+ int __E, int __F, int __G, int __H,
+ int __I, int __J, int __K, int __L,
+ int __M, int __N, int __O, int __P)
+{
+  return __extension__ (__m512i)(__v16si)
+  { __P, __O, __N, __M, __L, __K, __J, __I,
+__H, __G, __F, __E, __D, __C, __B, __A };
+}
+
+#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7,   \
+   e8,e9,e10,e11,e12,e13,e14,e15)  \
+  _mm512_set_epi32(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
+  
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_set_epi64 (long long __A, long long __B, long long __C,
  long long __D, long long __E, long long __F,
@@ -8992,6 +9007,9 @@ _mm512_set_epi64 (long long __A, long lo
   { __H, __G, __F, __E, __D, __C, __B, __A };
 }
 
+#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7)   \
+  _mm512_set_epi64(e7,e6,e5,e4,e3,e2,e1,e0)
+
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_set_pd (double __A, double __B, double __C, double __D,
 double __E, double __F, double __G, double __H)
@@ -9000,6 +9018,9 @@ _mm512_set_pd (double __A, double __B, d
   { __H, __G, __F, __E, __D, __C, __B, __A };
 }
 
+#define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7)  \
+  _mm512_set_pd(e7,e6,e5,e4,e3,e2,e1,e0)
+
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_set_ps (float __A, float __B, float __C, float __D,
 float __E, float __F, float __G, float __H,
@@ -9011,6 +9032,9 @@ _mm512_set_ps (float __A, float __B, flo
 __H, __G, __F, __E, __D, __C, __B, __A };
 }
 
+#define _mm512_setr_ps(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) \
+  _mm512_set_ps(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif // __AVX512FINTRIN_H

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=270047=270046=270047=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 07:07:49 2016
@@ -6521,6 +6521,74 @@ __m512i test_mm512_mask_set1_epi32 (__m5
   return _mm512_mask_set1_epi32 ( __O, __M, __A);
 }
 
+__m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D,
+   int __E, int __F, int __G, int __H,
+   int __I, int __J, int __K, int __L,
+   int __M, int __N, int __O, int __P)
+{
+ //CHECK-LABLE: @test_mm512_set_epi32
+ //CHECK: insertelement{{.*}}i32 0
+//CHECK: insertelement{{.*}}i32 1
+//CHECK: insertelement{{.*}}i32 2
+//CHECK: insertelement{{.*}}i32 3
+//CHECK: insertelement{{.*}}i32 4
+//CHECK: insertelement{{.*}}i32 5
+//CHECK: insertelement{{.*}}i32 6
+//CHECK: insertelement{{.*}}i32 7
+//CHECK: insertelement{{.*}}i32 8
+//CHECK: insertelement{{.*}}i32 9
+//CHECK: insertelement{{.*}}i32 10
+//CHECK: insertelement{{.*}}i32 11
+//CHECK: insertelement{{.*}}i32 12
+//CHECK: insertelement{{.*}}i32 13
+//CHECK: insertelement{{.*}}i32 14
+//CHECK: insertelement{{.*}}i32 15
+ return _mm512_set_epi32( __A, __B, __C, __D,__E, __F, __G, __H,
+  __I, __J, __K, __L,__M, __N, __O, __P);
+}
+
+__m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D,
+   int __E, int __F, int __G, int __H,
+   int __I, int __J, int __K, int __L,
+   int __M, int __N, int __O, int __P)
+{
+//CHECK-LABLE: @test_mm512_setr_epi32
+ //CHECK: %0 = load{{.*}}%__P.addr, align 4
+ //CHECK: %1 = load{{.*}}%__O.addr, align 4
+ //CHECK: %2 = load{{.*}}%__N.addr, align 4
+ //CHECK: %3 = load{{.*}}%__M.addr, align 4
+ //CHECK: %4 = load{{.*}}%__L.addr, align 4
+ //CHECK: %5 = load{{.*}}%__K.addr, align 4
+ //CHECK: %6 = load{{.*}}%__J.addr, align 4
+ //CHECK: %7 = load{{.*}}%__I.addr, align 4
+ //CHECK: %8 = load{{.*}}%__H.addr, align 4
+ //CHECK: %9 = load{{.*}}%__G.addr, align 4
+ //CHECK: %10 = load{{.*}}%__F.addr, align 4
+ //CHECK: %11 = load{{.*}}%__E.addr, align 4
+ //CHECK: %12 = load{{.*}}%__D.addr, 

[PATCH] D20422: [MSVC2015] dllexport for defaulted special class members

2016-05-19 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.

Clang doesn't dllexport defaulted special member function defaulted inside 
class but does it if they defaulted outside class. MSVC doesn't make any 
distinction where they were defaulted. Also MSVC 2013 and 2015 export different 
set of members. MSVC2015 doesn't emit trivial defaulted x-tors but does emit 
copy assign operator.


http://reviews.llvm.org/D20422

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport-members.cpp
  test/CodeGenCXX/dllexport.cpp

Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 %s
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 -check-prefix=M32MSVC2015 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 -check-prefix=M32MSVC2013 %s
 
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 -check-prefix=M64MSVC2015 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 -check-prefix=M64MSVC2013 %s
 
 // RUN: %clang_cc1 -triple i686-windows-gnu-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G64 %s
@@ -561,7 +561,7 @@
 
   // Explicitly defaulted copy constructur:
   T(const T&) = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.T* @"\01??0T@@QAE@ABU0@@Z"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.T* @"\01??0T@@QAE@ABU0@@Z"
 
   void a() {}
   // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?a@T@@QAEXXZ"
@@ -647,9 +647,34 @@
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
   DefaultedCtorsDtors() = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.DefaultedCtorsDtors* @"\01??0DefaultedCtorsDtors@@QAE@XZ"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.DefaultedCtorsDtors* @"\01??0DefaultedCtorsDtors@@QAE@XZ"
   ~DefaultedCtorsDtors() = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1DefaultedCtorsDtors@@QAE@XZ"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1DefaultedCtorsDtors@@QAE@XZ"
+};
+
+// Export defaulted member function definitions declared inside class.
+struct __declspec(dllexport) ExportDefaultedInclassDefs {
+  ExportDefaultedInclassDefs() = default;
+  // M32VS2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QAE@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M64VS2013-DAG: define weak_odr dllexport%struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QEAA@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M32VS2015-NOT: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedInclassDefs* 

  1   2   >