Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo abandoned this revision.
mstorsjo added a comment.

This test isn't strictly necessary, thus abandoning


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/diagnostics/Inputs/include/Something.h:1
@@ +1,2 @@
+void clang_analyzer_warnIfReached();
+

Please, choose better file names. Every test that adds something cannot add a 
header called something:) It won't scale.


Comment at: test/Analysis/diagnostics/plist-diagnostics-include-check.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection 
-analyzer-output=plist-multi-file -o plist.xml %s
+

Please, check that output is produced. Search for other tests with 
-analyzer-poutput=plist-multi-file for examples.


https://reviews.llvm.org/D22090



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

We'd definitely want the same routine in both: printing the name in 
-analyzer-display-progress and be accepted by -analyze-function.

Looks like what ND->getQualifiedNameAsString() returns is not proper ObjC 
syntax, but maybe it's fine for the debug feature? Even though it is not very 
readable...


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

I am not sure it's the right way of fixing this problem and it introduces a 
regression. The bug is probably specific to "&&".

+ Devin as we might have seen something similar.



Comment at: test/Analysis/misc-ps-region-store.m:332
@@ -330,3 +331,3 @@
   if (p < q) {
 // If we reach here, 'p' cannot be null.  If 'p' is null, then 'n' must
 // be '0', meaning that this branch is not feasible.

Try substituting 'p' with null and you will se that n must be zero in that case 
because, otherwise, we would take the early return branch. Since p is not null, 
we should not warn here. 

This is a regression.


https://reviews.llvm.org/D22862



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


[libcxx] r276955 - Add a bunch of noexcepts to char_traits and string_view.

2016-07-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jul 27 23:52:02 2016
New Revision: 276955

URL: http://llvm.org/viewvc/llvm-project?rev=276955=rev
Log:
Add a bunch of noexcepts to char_traits and string_view.

Modified:
libcxx/trunk/include/__string
libcxx/trunk/include/string_view

Modified: libcxx/trunk/include/__string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__string?rev=276955=276954=276955=diff
==
--- libcxx/trunk/include/__string (original)
+++ libcxx/trunk/include/__string Wed Jul 27 23:52:02 2016
@@ -207,19 +207,19 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) 
_NOEXCEPT
 {return (unsigned char)__c1 < (unsigned char)__c2;}
 
-static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
-static inline size_t length(const char_type* __s) {return strlen(__s);}
-static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a)
+static inline size_t length(const char_type* __s)  _NOEXCEPT {return 
strlen(__s);}
+static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a) _NOEXCEPT
 {return __n == 0 ? NULL : (const char_type*) memchr(__s, 
to_int_type(__a), __n);}
-static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
-static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
 }
-static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
+static inline char_type* assign(char_type* __s, size_t __n, char_type __a) 
_NOEXCEPT
 {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), 
__n);}
 
 static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -252,20 +252,20 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) 
_NOEXCEPT
 {return __c1 < __c2;}
 
-static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);}
-static inline size_t length(const char_type* __s)
+static inline size_t length(const char_type* __s) _NOEXCEPT
 {return wcslen(__s);}
-static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a)
+static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a) _NOEXCEPT
 {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);}
-static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
-static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
 }
-static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
+static inline char_type* assign(char_type* __s, size_t __n, char_type __a) 
_NOEXCEPT
 {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
 
 static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -299,17 +299,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
 {return __c1 < __c2;}
 
 _LIBCPP_INLINE_VISIBILITY
-static int  compare(const char_type* __s1, const char_type* 
__s2, size_t __n);
+static int  compare(const char_type* __s1, const char_type* 
__s2, size_t __n) _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY
-static size_t   length(const char_type* __s);
+static size_t   length(const char_type* __s) _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY
-static const char_type* find(const char_type* __s, size_t __n, const 
char_type& __a);
+static const char_type* find(const 

Re: [PATCH] D22810: scan-build: Add an option to show the description in the list of defect

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

The report you are referencing does not seem to have "Description" as a column 
name. Also, the titles row is not gray all the way to the right...


https://reviews.llvm.org/D22810



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


Re: [PATCH] D22494: [analyzer] Explain why analyzer report is not generated (fix for PR12421).

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/PR12421.c:11
@@ +10,2 @@
+
+// CHECK: warning: Path diagnostic report is not generated. HTMLDiagnostics 
does not support diagnostics that cross file boundaries.

ayartsev wrote:
> zaks.anna wrote:
> > We should use the name of the diagnostic consumer here - that will only be 
> > legible for the developers working on the attic analyzer core. 
> Done. As for me the name of the diagnostic consumer also makes the warning 
> more clear and helpful for an ordinary user. From the consumer name he can 
> see what report format is talked about and maybe change the scan-build (which 
> setups the '-analyzer-output' frontend option internally) options. Do you 
> still want to remove the consumer name from the warning?
"HTMLDiagnostics" is not a name a user would be familiar with. You should use 
only familiar terms in diagnostics.


Comment at: test/Analysis/PR12421.h:1
@@ +1,2 @@
+static void f() {
+  int *p = 0;

zaks.anna wrote:
> Please. do not use the PR as a file name. Use the purpose of the test instead,
this does not seem to be done.


https://reviews.llvm.org/D22494



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread David Majnemer via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D22900#498793, @Gerolf wrote:

> Nope, I don't see the tail call. Anyway, I'll simplify my test case. Don't 
> worry about it.
>
> clang++ -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.cpp
>
> cat t.ll:
>
> ; ModuleID = 't.cpp'
>  source_filename = "t.cpp"
>  target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
>  target triple = "i386-apple-darwin9"
>
> %struct.C = type { %struct.CBase, %struct.I }
>  %struct.CBase = type { i32 (...)** }
>  %struct.I = type { i32 (...)** }
>  %struct.LARGE = type { %union.anon }
>  %union.anon = type { i32 }
>
> ; Function Attrs: nounwind
>  define void @_ZN1C4SeekE5LARGE(%struct.C* %this, %struct.LARGE* byval align 
> 4) #0 align 2 {
> entry:
>
>   %this.addr = alloca %struct.C*, align 4
>   store %struct.C* %this, %struct.C** %this.addr, align 4
>   %this1 = load %struct.C*, %struct.C** %this.addr, align 4
>   ret void
>
> }
>
> attributes #0 = { nounwind "disable-tail-calls"="false" 
> "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" 
> "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "stack-protector-buffer-size"="8" "target-features"="+x87" 
> "unsafe-fp-math"="false" "use-soft-float"="false" }


D'oh, that m_fn1 should have been Seek :/

$ cat t.ii

  struct LARGE {
union {
  int i;
};
  };
  struct I {
virtual void m_fn1(LARGE);
  };
  struct CBase {
virtual ~CBase();
  };
  struct C : CBase, I {
void m_fn1(LARGE);
  };
  void C::m_fn1(LARGE) {}

$ ~/llvm/Debug+Asserts/bin/clang -cc1 -x c++ -emit-llvm -triple 
i386-apple-darwin9 t.ii && grep tail t.ll

  tail call void @_ZN1C5m_fn1E5LARGE(%struct.C* %3, %struct.LARGE* byval align 
4 %0)


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread Gerolf Hoflehner via cfe-commits
Gerolf added a comment.

Nope, I don't see the tail call. Anyway, I'll simplify my test case. Don't 
worry about it.

clang++ -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.cpp

cat t.ll:

; ModuleID = 't.cpp'
source_filename = "t.cpp"
target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
target triple = "i386-apple-darwin9"

%struct.C = type { %struct.CBase, %struct.I }
%struct.CBase = type { i32 (...)** }
%struct.I = type { i32 (...)** }
%struct.LARGE = type { %union.anon }
%union.anon = type { i32 }

; Function Attrs: nounwind
define void @_ZN1C4SeekE5LARGE(%struct.C* %this, %struct.LARGE* byval align 4) 
#0 align 2 {
entry:

  %this.addr = alloca %struct.C*, align 4
  store %struct.C* %this, %struct.C** %this.addr, align 4
  %this1 = load %struct.C*, %struct.C** %this.addr, align 4
  ret void

}

attributes #0 = { nounwind "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"stack-protector-buffer-size"="8" "target-features"="+x87" 
"unsafe-fp-math"="false" "use-soft-float"="false" }


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread David Majnemer via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D22900#498781, @Gerolf wrote:

> Please add the options you used to compile? I can certainly shrink the test 
> case a bit before I commit.


clang -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.ii -o -


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread Gerolf Hoflehner via cfe-commits
Gerolf added a comment.

Please add the options you used to compile? I can certainly shrink the test 
case a bit before I commit.


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer added a comment.

The test seems a little large, the following shows that we emit a tail call 
with a byval argument on trunk.

  struct LARGE {
union {
  int i;
};
  };
  struct I {
virtual void m_fn1(LARGE);
  };
  struct CBase {
virtual ~CBase();
  };
  struct C : CBase, I {
void Seek(LARGE);
  };
  void C::Seek(LARGE) {}


https://reviews.llvm.org/D22900



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


Re: [PATCH] D20168: [CodeGen] Handle structs directly in AMDGPUABIInfo

2016-07-27 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D20168



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


Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-27 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D22691



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


Re: [PATCH] D22895: [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-27 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D22895



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


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-27 Thread Raphael Isemann via cfe-commits
teemperor added a comment.

Is there a specific situation/bug we want to test against with these tests? I 
looks to me as if they would mainly test against non-determinism (i.e. same 
statements have different data due to non-determinism).



Comment at: lib/Analysis/CloneDetection.cpp:113
@@ +112,3 @@
+
+  void addData(std::string const ) {
+D.AddString(String);

v.g.vassilev wrote:
> Same here, `const std::string `. Is this caught by clang-format?
It hasn't complained so far or I'm missing a flag. But it's also accepting many 
non-LLVM like naming schemes, so I assume it's quite forgiving in this regard.


https://reviews.llvm.org/D22514



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


[PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread Gerolf Hoflehner via cfe-commits
Gerolf created this revision.
Gerolf added reviewers: eli.friedman, mkuper.
Gerolf added a subscriber: cfe-commits.

This is just closing the loop for
https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg28837.html with a
test case and fixes PR28748 which had been introduced by r244207.

https://reviews.llvm.org/D22900

Files:
  lib/CodeGen/CGVTables.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/tail-byval.cpp

Index: test/CodeGenCXX/tail-byval.cpp
===
--- /dev/null
+++ test/CodeGenCXX/tail-byval.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 %s -I%S -isystem %S/Inputs -emit-llvm -triple i386-apple-darwin9 -Wno-incompatible-ms-struct -o - -Os | opt - -dse -S -o - | FileCheck %s
+#pragma ms_struct on
+
+#include 
+#include 
+
+extern "C" int rand();
+
+struct
+IByteStream
+{
+public:
+};
+
+
+class IEmpty {};
+
+class CRepro
+{
+protected:
+	CRepro( IEmpty* p) : mp(p) {};
+	virtual ~CRepro()  {}
+	
+	IEmpty* mp;
+};
+
+class BStream : public CRepro, public IByteStream
+{
+protected:
+	BStream( IEmpty *p);
+	virtual ~BStream(){} ;
+	
+protected:
+	int32_t Ref;
+};
+
+class CStream : public BStream
+{
+public:
+static uint32_t Create(uint32_t m, IByteStream **ppS, IEmpty *p);
+private:
+	CStream(bool fD, bool fZero,  IEmpty *p) ;
+};
+
+typedef union _LARGE {
+	struct {
+		uint32_t Low;
+		int32_t High;
+	} DUMMYSTRUCTNAME;
+	struct {
+		uint32_t Low;
+		int32_t High;
+	} u;
+	int64_t Quad;
+} LARGE;
+
+class I
+{
+public:
+	virtual uint32_t Seek(LARGE dlibMove, uint32_t Origin, LARGE *plibNP) = 0;
+	
+};
+
+class CBase : public CRepro
+{
+protected:
+	CBase(IByteStream *ps,  IEmpty *p);
+	virtual ~CBase() {};
+	
+protected:
+	uint64_t Offset;
+	uint32_t ThreadId;
+};
+
+class C : public CBase, public I
+{
+public:
+static uint32_t Create(IByteStream *ps,  wchar_t *w,  I **ppi,  IEmpty *p);
+	uint32_t Seek(LARGE dlibMove, uint32_t Origin, LARGE *plibNP);
+	
+private:
+	C(IByteStream *ps,  IEmpty *p) ;
+	~C() {};
+	
+};
+
+uint32_t C::Seek(LARGE dlibMove, uint32_t Origin, LARGE *plibNP)
+{
+	uint32_t hr = 1;
+	
+	if (Origin != 1 || dlibMove.Quad != 0)
+	{
+		if (ThreadId != 0 && ThreadId != (uint32_t)rand())
+		{
+			hr = 3;
+			goto LError;
+		}
+		
+		if (Origin == 0)
+		{
+			Offset = (uint64_t) dlibMove.Quad;
+		}
+	}
+	
+LError:
+	if (plibNP != NULL)
+		(*plibNP).Quad = Offset;
+	return hr;
+}
+// CHECK: define i32 @_ZThn20_N1C4SeekE6_LARGEjPS0_
+// CHECK: store i64
+// CHECK: ret
Index: test/CodeGenCXX/microsoft-abi-structors.cpp
===
--- test/CodeGenCXX/microsoft-abi-structors.cpp
+++ test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -177,7 +177,7 @@
 //  Do an adjustment from B* to C*.
 // DTORS2:   getelementptr i8, i8* %{{.*}}, i32 -4
 // DTORS2:   bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::C"*
-// DTORS2:   %[[CALL:.*]] = tail call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
+// DTORS2:   %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
 // DTORS2:   ret i8* %[[CALL]]
 
 }
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -322,8 +322,6 @@
   // Consider return adjustment if we have ThunkInfo.
   if (Thunk && !Thunk->Return.isEmpty())
 RV = PerformReturnAdjustment(*this, ResultType, RV, *Thunk);
-  else if (llvm::CallInst* Call = dyn_cast(CallOrInvoke))
-Call->setTailCallKind(llvm::CallInst::TCK_Tail);
 
   // Emit return.
   if (!ResultType->isVoidType() && Slot.isNull())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-27 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65857.
teemperor marked 5 inline comments as done.
teemperor added a comment.

- Removed duplicate test case.


https://reviews.llvm.org/D22514

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/test-asm.cpp
  test/Analysis/copypaste/test-attributes.cpp
  test/Analysis/copypaste/test-call.cpp
  test/Analysis/copypaste/test-catch.cpp
  test/Analysis/copypaste/test-delete.cpp
  test/Analysis/copypaste/test-dependent-exist.cpp
  test/Analysis/copypaste/test-expr-types.cpp
  test/Analysis/copypaste/test-fold.cpp
  test/Analysis/copypaste/test-function-try-block.cpp
  test/Analysis/copypaste/test-generic.c
  test/Analysis/copypaste/test-labels.cpp
  test/Analysis/copypaste/test-lambda.cpp
  test/Analysis/copypaste/test-try-body.cpp

Index: test/Analysis/copypaste/test-try-body.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-try-body.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if function try blocks are correctly handled.
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-lambda.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-lambda.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+void foo1(int a, long b) {
+  auto l = [a, b](){};
+}
+
+void foo2(int a, long b) {
+  auto l = [, b](){};
+}
+
+void foo3(int a, long b) {
+  auto l = [a](){};
+}
+
+void foo4(int a, long b) {
+  auto l = [=](){};
+}
+
+void foo5(int a, long b) {
+  auto l = [&](){};
+}
+
Index: test/Analysis/copypaste/test-labels.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-labels.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+
+bool foo1(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Targeting a different label with the address-of-label operator.
+bool foo2(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Different target label in goto
+bool foo3(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto end;
+  }
+  end:
+  return false;
+}
+
+// FIXME: Can't detect same algorithm as in foo1 but with different label names.
+bool foo4(int x) {
+  foo:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto foo;
+  }
+  end:
+  return false;
+}
Index: test/Analysis/copypaste/test-generic.c
===
--- /dev/null
+++ test/Analysis/copypaste/test-generic.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -analyze -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global;
+
+int foo1() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, float: 2, default: 3);
+  return 1;
+}
+
+// Different associated type (int instead of float)
+int foo2() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, int: 2, default: 4);
+  return 1;
+}
+
+// Different number of associated types.
+int foo3() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, default: 4);
+  return 1;
+}
Index: test/Analysis/copypaste/test-function-try-block.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-function-try-block.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if the special case of a try
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-fold.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-fold.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global = 0;
+
+template
+int foo1(Args&&... args) {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return 

Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-27 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65854.
teemperor added a comment.

- Rebased patch.
- Fixed code style (`const type` instead of `type const`).
- Fixed missing const on some variables in StmtDataCollector.
- Rewrote a few comments/variable names.


https://reviews.llvm.org/D22514

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/test-asm.cpp
  test/Analysis/copypaste/test-attributes.cpp
  test/Analysis/copypaste/test-call.cpp
  test/Analysis/copypaste/test-catch.cpp
  test/Analysis/copypaste/test-delete.cpp
  test/Analysis/copypaste/test-dependent-exist.cpp
  test/Analysis/copypaste/test-expr-types.cpp
  test/Analysis/copypaste/test-fold.cpp
  test/Analysis/copypaste/test-function-try-block.cpp
  test/Analysis/copypaste/test-generic.c
  test/Analysis/copypaste/test-labels.cpp
  test/Analysis/copypaste/test-lambda.cpp
  test/Analysis/copypaste/test-try-body.cpp

Index: test/Analysis/copypaste/test-try-body.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-try-body.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if function try blocks are correctly handled.
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-lambda.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-lambda.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+void foo1(int a, long b) {
+  auto l = [a, b](){};
+}
+
+void foo2(int a, long b) {
+  auto l = [, b](){};
+}
+
+void foo3(int a, long b) {
+  auto l = [a](){};
+}
+
+void foo4(int a, long b) {
+  auto l = [=](){};
+}
+
+void foo5(int a, long b) {
+  auto l = [&](){};
+}
+
Index: test/Analysis/copypaste/test-labels.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-labels.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+
+bool foo1(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Targeting a different label with the address-of-label operator.
+bool foo2(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Different target label in goto
+bool foo3(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto end;
+  }
+  end:
+  return false;
+}
+
+// FIXME: Can't detect same algorithm as in foo1 but with different label names.
+bool foo4(int x) {
+  foo:
+  if (x != 3) {
+++x;
+void *ptr = &
+goto foo;
+  }
+  end:
+  return false;
+}
Index: test/Analysis/copypaste/test-generic.c
===
--- /dev/null
+++ test/Analysis/copypaste/test-generic.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -analyze -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global;
+
+int foo1() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, float: 2, default: 3);
+  return 1;
+}
+
+// Different associated type (int instead of float)
+int foo2() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, int: 2, default: 4);
+  return 1;
+}
+
+// Different number of associated types.
+int foo3() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, default: 4);
+  return 1;
+}
Index: test/Analysis/copypaste/test-function-try-block.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-function-try-block.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if the special case of a try
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-fold.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-fold.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global = 0;
+

Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect

2016-07-27 Thread comicfans44 via cfe-commits
comicfans44 added a comment.

In https://reviews.llvm.org/D21946#473071, @zturner wrote:

> In https://reviews.llvm.org/D21946#473070, @comicfans44 wrote:
>
> > I've not commited to cfe before, so I think I havn't commit access 
> > permission.
>
>
> If you've committed anywhere in LLVM, you should have commit access to cfe.  
> Feel free to give it a try, as I won't be able to commit until Wednesday of 
> next week at the earliest anyway due to the upcoming holiday.


ping ?


https://reviews.llvm.org/D21946



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


r276950 - [analyzer] Add check::BeginFunction to CheckerDocumentation checks. NFC.

2016-07-27 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Jul 27 19:52:10 2016
New Revision: 276950

URL: http://llvm.org/viewvc/llvm-project?rev=276950=rev
Log:
[analyzer] Add check::BeginFunction to CheckerDocumentation checks. NFC.

This was an oversight from when I added BeginFunction support in r261293.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp?rev=276950=276949=276950=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp Wed Jul 27 
19:52:10 2016
@@ -45,6 +45,7 @@ class CheckerDocumentation : public Chec
check::Location,
check::Bind,
check::DeadSymbols,
+   check::BeginFunction,
check::EndFunction,
check::EndAnalysis,
check::EndOfTranslationUnit,


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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r276948


https://reviews.llvm.org/D22881



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


[clang-tools-extra] r276949 - test: fix typo in file name (NFC)

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Jul 27 19:43:14 2016
New Revision: 276949

URL: http://llvm.org/viewvc/llvm-project?rev=276949=rev
Log:
test: fix typo in file name (NFC)

Added:
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp
  - copied, changed from r276948, 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp
Removed:
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp

Removed: 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp?rev=276948=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp 
(removed)
@@ -1,8 +0,0 @@
-// RUN: clang-rename -offset=74 -new-name=Bar %s -- | FileCheck %s
-
-class Foo { // CHECK: class Bar {
-public:
-  void foo(int x);
-};
-
-void Foo::foo(int x) {} // CHECK: void Bar::foo(int x) {}

Copied: 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp 
(from r276948, 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp?p2=clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp=clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp=276948=276949=276949=diff
==
(empty)


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


[clang-tools-extra] r276948 - clang-rename: adjust NamedDeclFindingASTVisitor for RecordDecls

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Jul 27 19:42:01 2016
New Revision: 276948

URL: http://llvm.org/viewvc/llvm-project?rev=276948=rev
Log:
clang-rename: adjust NamedDeclFindingASTVisitor for RecordDecls

Ensure that Context is always properly initialised in the constructor.  It is
used for querying the LangOpts in VisitTypeLoc.  Prevent a null pointer
dereference in setResult by ensuring that a RecordDecl is being handled.

Patch by Alexander Shaposhnikov!

Added:
clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=276948=276947=276948=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Wed Jul 27 19:42:01 2016
@@ -42,8 +42,9 @@ public:
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager ,
-  const std::string )
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string ,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -75,9 +76,10 @@ public:
   bool VisitTypeLoc(const TypeLoc Loc) {
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-   TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@ const NamedDecl *getNamedDeclAt(const AS
 const NamedDecl *getNamedDeclFor(const ASTContext ,
  const std::string ) {
   const auto  = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, );
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();

Added: clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp?rev=276948=auto
==
--- clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp 
Wed Jul 27 19:42:01 2016
@@ -0,0 +1,13 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
+


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


r276947 - Replace preserve-as-comments CodeGen test with driver test

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 19:36:34 2016
New Revision: 276947

URL: http://llvm.org/viewvc/llvm-project?rev=276947=rev
Log:
Replace preserve-as-comments CodeGen test with driver test

Added:
cfe/trunk/test/Driver/preserve-as-comments.c
Removed:
cfe/trunk/test/CodeGen/preserve-as-comments.c

Removed: cfe/trunk/test/CodeGen/preserve-as-comments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/preserve-as-comments.c?rev=276946=auto
==
--- cfe/trunk/test/CodeGen/preserve-as-comments.c (original)
+++ cfe/trunk/test/CodeGen/preserve-as-comments.c (removed)
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -S -triple=x86_64-unknown-unknown -fno-preserve-as-comments 
%s -o - | FileCheck %s --check-prefix=NOASM --check-prefix=CHECK
-// RUN: %clang_cc1 -S %s -triple=x86_64-unknown-unknown -o - | FileCheck %s 
--check-prefix=ASM --check-prefix=CHECK
-
-// CHECK-LABEL: main
-// CHECK: #APP
-// ASM: #comment
-// NOASM-NOT: #comment
-// CHECK: #NO_APP
-int main() {
-  __asm__("/*comment*/");
-  return 0;
-}

Added: cfe/trunk/test/Driver/preserve-as-comments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/preserve-as-comments.c?rev=276947=auto
==
--- cfe/trunk/test/Driver/preserve-as-comments.c (added)
+++ cfe/trunk/test/Driver/preserve-as-comments.c Wed Jul 27 19:36:34 2016
@@ -0,0 +1,2 @@
+// RUN: %clang -S -fno-preserve-as-comments %s -### 2>&1 | FileCheck %s
+// CHECK: "-fno-preserve-as-comments"


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


[PATCH] D22895: [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, 
kkwli0, tra.
sfantao added subscribers: cfe-commits, caomhin.

This patch prevents OpenMP flags from being forwarded to CUDA device commands. 
That was causing the CUDA frontend to attempt to emit OpenMP code which is not 
supported.

https://reviews.llvm.org/D22895

Files:
  lib/Driver/Tools.cpp
  test/Driver/offloading-interoperability.c

Index: test/Driver/offloading-interoperability.c
===
--- /dev/null
+++ test/Driver/offloading-interoperability.c
@@ -0,0 +1,17 @@
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Verify that CUDA device commands do not get OpenMP flags.
+//
+// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 
--cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
+//
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le--linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" 
"--eh-frame-hdr" "-m" "elf64lppc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5049,9 +5049,13 @@
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 
-  // Forward flags for OpenMP
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action.
+  //
+  // TODO: Allow OpenMP offload actions when they become available.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
-   options::OPT_fno_openmp, false)) {
+   options::OPT_fno_openmp, false) &&
+  JA.isDeviceOffloading(Action::OFK_None)) {
 switch (getOpenMPRuntime(getToolChain(), Args)) {
 case OMPRT_OMP:
 case OMPRT_IOMP5:


Index: test/Driver/offloading-interoperability.c
===
--- /dev/null
+++ test/Driver/offloading-interoperability.c
@@ -0,0 +1,17 @@
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Verify that CUDA device commands do not get OpenMP flags.
+//
+// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
+//
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5049,9 +5049,13 @@
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 
-  // Forward flags for OpenMP
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action.
+  //
+  // TODO: Allow OpenMP offload actions when they become available.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
-   options::OPT_fno_openmp, false)) {
+   options::OPT_fno_openmp, false) &&
+  JA.isDeviceOffloading(Action::OFK_None)) {
 switch (getOpenMPRuntime(getToolChain(), Args)) {
 case OMPRT_OMP:
 case OMPRT_IOMP5:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


only correct delayed typos for conditional expressions when needed.

2016-07-27 Thread David Tarditi via cfe-commits
r272587 (http://reviews.llvm.org/D20490) fixed an issue where typo correction 
could cause a crash when compiling C programs.The problem was that a typo 
expression could be inadvertently processed twice.r272587 fixed this for 
BinOp expressions.   Conditional expressions can hit the same problem too.  
This change adds the two line fix for them, as well as a small test case 
illustrating the crash.   This is my first time proposing a patch for clang.  I 
don't have commit privileges, so if someone could review/commit this for me, 
I'd appreciate it.   If Phrabicator is the preferred way or there's another 
preferred process for submitting patches, let me know.

I see from the prior review that the consensus was that "typo correction is in 
a messy state, we should fix this". I agree.  There are other problematic 
places in the code where double-processing might or might not occur for C code. 
 An example is the processing of subscript expressions in 
Parser::ParsePostfixExpressionSuffix.  Without clear invariants, it is hard to 
know what to do.

Testing: clang fails on the test case without this change, passes with it.   
The clang test suite results were otherwise the same before and after this 
change.

Thanks,
David


c-typo-crash.patch
Description: c-typo-crash.patch
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r276350 - [CodeGen] Fix a crash when constant folding switch statement

2016-07-27 Thread David Majnemer via cfe-commits
I hear that he is on vacation.

On Wednesday, July 27, 2016, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Richard: ping?
>
> On Fri, Jul 22, 2016 at 7:00 AM, Hans Wennborg  > wrote:
> > Richard: should we merge this to 3.9?
> >
> > On Thu, Jul 21, 2016 at 6:31 PM, Erik Pilkington via cfe-commits
> > > wrote:
> >> Author: epilk
> >> Date: Thu Jul 21 17:31:40 2016
> >> New Revision: 276350
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=276350=rev
> >> Log:
> >> [CodeGen] Fix a crash when constant folding switch statement
> >>
> >> Differential revision: https://reviews.llvm.org/D22542
> >>
> >> Modified:
> >> cfe/trunk/lib/CodeGen/CGStmt.cpp
> >> cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276350=276349=276350=diff
> >>
> ==
> >> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 17:31:40 2016
> >> @@ -1264,6 +1264,14 @@ void CodeGenFunction::EmitCaseStmt(const
> >>  }
> >>
> >>  void CodeGenFunction::EmitDefaultStmt(const DefaultStmt ) {
> >> +  // If there is no enclosing switch instance that we're aware of,
> then this
> >> +  // default statement can be elided. This situation only happens when
> we've
> >> +  // constant-folded the switch.
> >> +  if (!SwitchInsn) {
> >> +EmitStmt(S.getSubStmt());
> >> +return;
> >> +  }
> >> +
> >>llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
> >>assert(DefaultBlock->empty() &&
> >>   "EmitDefaultStmt: Default block already defined?");
> >>
> >> Modified: cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp?rev=276350=276349=276350=diff
> >>
> ==
> >> --- cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp (original)
> >> +++ cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp Thu Jul 21
> 17:31:40 2016
> >> @@ -18,4 +18,13 @@ int main(void) {
> >>   return test(5);
> >>  }
> >>
> >> +void other_test() {
> >> +  switch(0) {
> >> +  case 0:
> >> +do {
> >> +default:;
> >> +} while(0);
> >> +  }
> >> +}
> >> +
> >>  // CHECK: call i32 (i8*, ...) @_Z6printfPKcz
> >>
> >>
> >> ___
> >> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r276350 - [CodeGen] Fix a crash when constant folding switch statement

2016-07-27 Thread Hans Wennborg via cfe-commits
Richard: ping?

On Fri, Jul 22, 2016 at 7:00 AM, Hans Wennborg  wrote:
> Richard: should we merge this to 3.9?
>
> On Thu, Jul 21, 2016 at 6:31 PM, Erik Pilkington via cfe-commits
>  wrote:
>> Author: epilk
>> Date: Thu Jul 21 17:31:40 2016
>> New Revision: 276350
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276350=rev
>> Log:
>> [CodeGen] Fix a crash when constant folding switch statement
>>
>> Differential revision: https://reviews.llvm.org/D22542
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGStmt.cpp
>> cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276350=276349=276350=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 17:31:40 2016
>> @@ -1264,6 +1264,14 @@ void CodeGenFunction::EmitCaseStmt(const
>>  }
>>
>>  void CodeGenFunction::EmitDefaultStmt(const DefaultStmt ) {
>> +  // If there is no enclosing switch instance that we're aware of, then this
>> +  // default statement can be elided. This situation only happens when we've
>> +  // constant-folded the switch.
>> +  if (!SwitchInsn) {
>> +EmitStmt(S.getSubStmt());
>> +return;
>> +  }
>> +
>>llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
>>assert(DefaultBlock->empty() &&
>>   "EmitDefaultStmt: Default block already defined?");
>>
>> Modified: cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp?rev=276350=276349=276350=diff
>> ==
>> --- cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp Thu Jul 21 17:31:40 
>> 2016
>> @@ -18,4 +18,13 @@ int main(void) {
>>   return test(5);
>>  }
>>
>> +void other_test() {
>> +  switch(0) {
>> +  case 0:
>> +do {
>> +default:;
>> +} while(0);
>> +  }
>> +}
>> +
>>  // CHECK: call i32 (i8*, ...) @_Z6printfPKcz
>>
>>
>> ___
>> 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: r276900 - [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

2016-07-27 Thread Hans Wennborg via cfe-commits
Should this be merged to 3.9?

Thanks,
Hans

On Wed, Jul 27, 2016 at 11:25 AM, Erik Pilkington via cfe-commits
 wrote:
> Author: epilk
> Date: Wed Jul 27 13:25:10 2016
> New Revision: 276900
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276900=rev
> Log:
> [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer
>
> Fixes PR27994, a crash on valid.
>
> Differential revision: https://reviews.llvm.org/D21145
>
> Modified:
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=276900=276899=276900=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 27 13:25:10 2016
> @@ -961,32 +961,26 @@ static QualType adjustCVQualifiersForCXX
>  QualType Sema::getCurrentThisType() {
>DeclContext *DC = getFunctionLevelDeclContext();
>QualType ThisTy = CXXThisTypeOverride;
> +
>if (CXXMethodDecl *method = dyn_cast(DC)) {
>  if (method && method->isInstance())
>ThisTy = method->getThisType(Context);
>}
> -  if (ThisTy.isNull()) {
> -if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
> -CurContext->getParent()->getParent()->isRecord()) {
> -  // This is a generic lambda call operator that is being instantiated
> -  // within a default initializer - so use the enclosing class as 'this'.
> -  // There is no enclosing member function to retrieve the 'this' pointer
> -  // from.
> -
> -  // FIXME: This looks wrong. If we're in a lambda within a lambda 
> within a
> -  // default member initializer, we need to recurse up more parents to 
> find
> -  // the right context. Looks like we should be walking up to the parent 
> of
> -  // the closure type, checking whether that is itself a lambda, and if 
> so,
> -  // recursing, until we reach a class or a function that isn't a lambda
> -  // call operator. And we should accumulate the constness of *this on 
> the
> -  // way.
> -
> -  QualType ClassTy = Context.getTypeDeclType(
> -  cast(CurContext->getParent()->getParent()));
> -  // There are no cv-qualifiers for 'this' within default initializers,
> -  // per [expr.prim.general]p4.
> -  ThisTy = Context.getPointerType(ClassTy);
> -}
> +
> +  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
> +  !ActiveTemplateInstantiations.empty()) {
> +
> +assert(isa(DC) &&
> +   "Trying to get 'this' type from static method?");
> +
> +// This is a lambda call operator that is being instantiated as a default
> +// initializer. DC must point to the enclosing class type, so we can 
> recover
> +// the 'this' type from it.
> +
> +QualType ClassTy = Context.getTypeDeclType(cast(DC));
> +// There are no cv-qualifiers for 'this' within default initializers,
> +// per [expr.prim.general]p4.
> +ThisTy = Context.getPointerType(ClassTy);
>}
>
>// If we are within a lambda's call operator, the cv-qualifiers of 'this'
>
> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=276900=276899=276900=diff
> ==
> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Wed Jul 27 13:25:10 2016
> @@ -1,5 +1,4 @@
> -// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify 
> -fblocks %s
> -// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify 
> -fblocks %s
> +// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
> -fblocks %s
>
>  namespace std { class type_info; };
>
> @@ -499,3 +498,30 @@ void foo() {
>};
>  }
>  }
> +
> +namespace PR27994 {
> +struct A { template  A(T); };
> +
> +template 
> +struct B {
> +  int x;
> +  A a = [&] { int y = x; };
> +  A b = [&] { [&] { [&] { int y = x; }; }; };
> +  A d = [&](auto param) { int y = x; };
> +  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
> +};
> +
> +B b;
> +
> +template  struct C {
> +  struct D {
> +int x;
> +A f = [&] { int y = x; };
> +  };
> +};
> +
> +int func() {
> +  C a;
> +  decltype(a)::D b;
> +}
> +}
>
>
> ___
> 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: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Renato Golin via cfe-commits
On 27 July 2016 at 21:57, Nirav Davé  wrote:
> Looks like I missed the target triple. Should work now.

Still failing on *all* ARM targets.

'No available targets are compatible with this triple.'

Please move the test to an x86 directory.

http://llvm.org/docs/TestingGuide.html#platform-specific-tests

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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276937: Retry: [Driver] Compute effective target triples 
once per job (NFCI) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D22596?vs=64792=65829#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22596

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -40,6 +40,7 @@
   class Compilation;
   class Driver;
   class JobAction;
+  class RegisterEffectiveTriple;
   class SanitizerArgs;
   class Tool;
 
@@ -91,6 +92,14 @@
 
   mutable std::unique_ptr SanitizerArguments;
 
+  /// The effective clang triple for the current Job.
+  mutable llvm::Triple EffectiveTriple;
+
+  /// Set the toolchain's effective clang triple.
+  void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; }
+
+  friend class RegisterEffectiveTriple;
+
 protected:
   MultilibSet Multilibs;
   const char *DefaultLinker = "ld";
@@ -141,6 +150,12 @@
 return Triple.getTriple();
   }
 
+  /// Get the toolchain's effective clang triple.
+  const llvm::Triple () const {
+assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
+return EffectiveTriple;
+  }
+
   path_list () { return FilePaths; }
   const path_list () const { return FilePaths; }
 
@@ -432,6 +447,19 @@
   virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); }
 };
 
+/// Set a ToolChain's effective triple. Reset it when the registration object
+/// is destroyed.
+class RegisterEffectiveTriple {
+  const ToolChain 
+
+public:
+  RegisterEffectiveTriple(const ToolChain , llvm::Triple T) : TC(TC) {
+TC.setEffectiveTriple(T);
+  }
+
+  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
+};
+
 } // end namespace driver
 } // end namespace clang
 
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -312,9 +312,6 @@
   /// @name ToolChain Implementation
   /// {
 
-  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList ,
-  types::ID InputType) const override;
-
   types::ID LookupTypeForExtension(const char *Ext) const override;
 
   bool HasNativeLLVMSupport() const override;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -176,13 +176,6 @@
 
 MachO::~MachO() {}
 
-std::string MachO::ComputeEffectiveClangTriple(const ArgList ,
-   types::ID InputType) const {
-  llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
-
-  return Triple.getTriple();
-}
-
 std::string Darwin::ComputeEffectiveClangTriple(const ArgList ,
 types::ID InputType) const {
   llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -764,7 +764,7 @@
 // -mfloat-abi=.
 arm::FloatABI arm::getARMFloatABI(const ToolChain , const ArgList ) {
   const Driver  = TC.getDriver();
-  const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(Args));
+  const llvm::Triple  = TC.getEffectiveTriple();
   auto SubArch = getARMSubArchVersionNumber(Triple);
   arm::FloatABI ABI = FloatABI::Invalid;
   if (Arg *A =
@@ -1165,8 +1165,7 @@
 
 void Clang::AddAArch64TargetArgs(const ArgList ,
  ArgStringList ) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple(TripleStr);
+  const llvm::Triple  = getToolChain().getEffectiveTriple();
 
   if (!Args.hasFlag(options::OPT_mred_zone, options::OPT_mno_red_zone, true) ||
   Args.hasArg(options::OPT_mkernel) ||
@@ -3838,8 +3837,8 @@
 void Clang::ConstructJob(Compilation , const JobAction ,
  const InputInfo , const InputInfoList ,
  const ArgList , const char *LinkingOutput) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  const llvm::Triple Triple(TripleStr);
+  const llvm::Triple  = getToolChain().getEffectiveTriple();
+  const std::string  = Triple.getTriple();
 
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
@@ -6500,9 +6499,8 @@
   assert(Inputs.size() == 1 && "Unexpected number 

r276937 - Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jul 27 18:02:20 2016
New Revision: 276937

URL: http://llvm.org/viewvc/llvm-project?rev=276937=rev
Log:
Retry: [Driver] Compute effective target triples once per job (NFCI)

Compute an effective triple once per job. Cache the triple in the
prevailing ToolChain for the duration of the job.

Clients which need effective triples now look them up in the ToolChain.
This eliminates wasteful re-computation of effective triples (e.g in
getARMFloatABI()).

While we're at it, delete MachO::ComputeEffectiveClangTriple. It was a
no-op override.

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

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

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=276937=276936=276937=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Jul 27 18:02:20 2016
@@ -40,6 +40,7 @@ namespace driver {
   class Compilation;
   class Driver;
   class JobAction;
+  class RegisterEffectiveTriple;
   class SanitizerArgs;
   class Tool;
 
@@ -91,6 +92,14 @@ private:
 
   mutable std::unique_ptr SanitizerArguments;
 
+  /// The effective clang triple for the current Job.
+  mutable llvm::Triple EffectiveTriple;
+
+  /// Set the toolchain's effective clang triple.
+  void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; }
+
+  friend class RegisterEffectiveTriple;
+
 protected:
   MultilibSet Multilibs;
   const char *DefaultLinker = "ld";
@@ -141,6 +150,12 @@ public:
 return Triple.getTriple();
   }
 
+  /// Get the toolchain's effective clang triple.
+  const llvm::Triple () const {
+assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
+return EffectiveTriple;
+  }
+
   path_list () { return FilePaths; }
   const path_list () const { return FilePaths; }
 
@@ -432,6 +447,19 @@ public:
   virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); }
 };
 
+/// Set a ToolChain's effective triple. Reset it when the registration object
+/// is destroyed.
+class RegisterEffectiveTriple {
+  const ToolChain 
+
+public:
+  RegisterEffectiveTriple(const ToolChain , llvm::Triple T) : TC(TC) {
+TC.setEffectiveTriple(T);
+  }
+
+  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
+};
+
 } // end namespace driver
 } // end namespace clang
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=276937=276936=276937=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jul 27 18:02:20 2016
@@ -2247,6 +2247,19 @@ InputInfo Driver::BuildJobsForActionNoCa
 InputInfos.append(OffloadDependencesInputInfo.begin(),
   OffloadDependencesInputInfo.end());
 
+  // Set the effective triple of the toolchain for the duration of this job.
+  llvm::Triple EffectiveTriple;
+  const ToolChain  = T->getToolChain();
+  const ArgList  = C.getArgsForToolChain(TC, BoundArch);
+  if (InputInfos.size() != 1) {
+EffectiveTriple = llvm::Triple(ToolTC.ComputeEffectiveClangTriple(Args));
+  } else {
+// Pass along the input type if it can be unambiguously determined.
+EffectiveTriple = llvm::Triple(
+ToolTC.ComputeEffectiveClangTriple(Args, InputInfos[0].getType()));
+  }
+  RegisterEffectiveTriple TripleRAII(ToolTC, EffectiveTriple);
+
   // Determine the place to write output to, if any.
   InputInfo Result;
   if (JA->getType() == types::TY_Nothing)

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=276937=276936=276937=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Jul 27 18:02:20 2016
@@ -68,7 +68,8 @@ static ToolChain::RTTIMode CalculateRTTI
 ToolChain::ToolChain(const Driver , const llvm::Triple ,
  const ArgList )
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
-  CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
+  CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
+  EffectiveTriple() {
   if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
 if (!isThreadModelSupported(A->getValue()))
   D.Diag(diag::err_drv_invalid_thread_model_for_target)

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

r276936 - Revert "[Driver] Compute effective target triples once per job (NFCI)"

2016-07-27 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jul 27 18:01:55 2016
New Revision: 276936

URL: http://llvm.org/viewvc/llvm-project?rev=276936=rev
Log:
Revert "[Driver] Compute effective target triples once per job (NFCI)"

This reverts commit r275895 in order to address some post-commit review
feedback from Eric Christopher (see: the list thread for r275895).

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Driver/Tool.h
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=276936=276935=276936=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jul 27 18:01:55 2016
@@ -121,8 +121,7 @@ These are major API changes that have ha
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
-- Classes which inherit from ``driver::Tool`` must be updated to use effective
-  target triples when constructing jobs.
+-  ...
 
 AST Matchers
 

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=276936=276935=276936=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Wed Jul 27 18:01:55 2016
@@ -16,10 +16,6 @@
 #include 
 #include 
 
-namespace llvm {
-class Triple;
-}
-
 namespace clang {
 namespace driver {
 
@@ -70,8 +66,7 @@ class SanitizerArgs {
   bool requiresPIE() const;
   bool needsUnwindTables() const;
   bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
-  void addArgs(const ToolChain , const llvm::Triple ,
-   const llvm::opt::ArgList ,
+  void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
 };
 

Modified: cfe/trunk/include/clang/Driver/Tool.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Tool.h?rev=276936=276935=276936=diff
==
--- cfe/trunk/include/clang/Driver/Tool.h (original)
+++ cfe/trunk/include/clang/Driver/Tool.h Wed Jul 27 18:01:55 2016
@@ -14,7 +14,6 @@
 #include "llvm/Support/Program.h"
 
 namespace llvm {
-class Triple;
 namespace opt {
   class ArgList;
 }
@@ -128,7 +127,6 @@ public:
   virtual void ConstructJob(Compilation , const JobAction ,
 const InputInfo ,
 const InputInfoList ,
-const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const = 0;
 };

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=276936=276935=276936=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Jul 27 18:01:55 2016
@@ -260,13 +260,11 @@ public:
 return ToolChain::CST_Libstdcxx;
   }
 
-  virtual std::string getCompilerRT(const llvm::Triple ,
-const llvm::opt::ArgList ,
+  virtual std::string getCompilerRT(const llvm::opt::ArgList ,
 StringRef Component,
 bool Shared = false) const;
 
-  const char *getCompilerRTArgString(const llvm::Triple ,
- const llvm::opt::ArgList ,
+  const char *getCompilerRTArgString(const llvm::opt::ArgList ,
  StringRef Component,
  bool Shared = false) const;
   /// needsProfileRT - returns true if instrumentation profile is on.
@@ -412,8 +410,7 @@ public:
   const llvm::opt::ArgList , llvm::opt::ArgStringList ) const;
   /// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
   /// a suitable profile runtime library to the linker.
-  virtual void addProfileRTLibs(const llvm::Triple ,
-const llvm::opt::ArgList ,
+  virtual void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
 
   /// \brief Add arguments to use system-specific CUDA includes.

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

r276934 - [OpenMP] Add support to map member expressions with references to pointers.

2016-07-27 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Wed Jul 27 17:52:16 2016
New Revision: 276934

URL: http://llvm.org/viewvc/llvm-project?rev=276934=rev
Log:
[OpenMP] Add support to map member expressions with references to pointers.

Summary: This patch add support to map pointers through references in class 
members. Although a reference does not have storage that a user can access, it 
still has to be mapped in order to get the deep copy right and the 
dereferencing code work properly.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=276934=276933=276934=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jul 27 17:52:16 2016
@@ -5320,14 +5320,34 @@ private:
 isa(Next->getAssociatedExpression())) &&
"Unexpected expression");
 
-// Save the base we are currently using.
-BasePointers.push_back(BP);
-
 auto *LB = CGF.EmitLValue(I->getAssociatedExpression()).getPointer();
 auto *Size = getExprTypeSize(I->getAssociatedExpression());
 
+// If we have a member expression and the current component is a
+// reference, we have to map the reference too. Whenever we have a
+// reference, the section that reference refers to is going to be a
+// load instruction from the storage assigned to the reference.
+if (isa(I->getAssociatedExpression()) &&
+I->getAssociatedDeclaration()->getType()->isReferenceType()) {
+  auto *LI = cast(LB);
+  auto *RefAddr = LI->getPointerOperand();
+
+  BasePointers.push_back(BP);
+  Pointers.push_back(RefAddr);
+  Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
+  Types.push_back(getMapTypeBits(
+  /*MapType*/ OMPC_MAP_alloc, /*MapTypeModifier=*/OMPC_MAP_unknown,
+  !IsExpressionFirstInfo, IsCaptureFirstInfo));
+  IsExpressionFirstInfo = false;
+  IsCaptureFirstInfo = false;
+  // The reference will be the next base address.
+  BP = RefAddr;
+}
+
+BasePointers.push_back(BP);
 Pointers.push_back(LB);
 Sizes.push_back(Size);
+
 // We need to add a pointer flag for each map that comes from the
 // same expression except for the first one. We also need to signal
 // this map is the first one that relates with the current capture

Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=276934=276933=276934=diff
==
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Wed Jul 27 17:52:16 2016
@@ -4564,4 +4564,193 @@ void explicit_maps_pointer_references (i
   }
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK29 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK29 --check-prefix CK29-64
+// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK29 --check-prefix CK29-64
+// RUN: %clang_cc1 -DCK29 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK29 --check-prefix CK29-32
+// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK29 --check-prefix CK29-32
+#ifdef CK29
+
+// CK29: [[SSA:%.+]] = type { double*, double** }
+// CK29: [[SSB:%.+]]  = type { [[SSA]]*, [[SSA]]** }
+
+// CK29: [[SIZE00:@.+]] = private {{.*}}constant [4 x i[[Z:64|32]]] 
[i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] 
80]
+// CK29: [[MTYPE00:@.+]] = private {{.*}}constant [4 x i32] [i32 35, i32 16, 
i32 19, i32 19]
+
+// CK29: [[SIZE01:@.+]] = private {{.*}}constant [4 x i[[Z]]] [i[[Z]] {{8|4}}, 
i[[Z]] {{8|4}}, 

r276933 - [OpenMP] Add support for mapping array sections through pointer references.

2016-07-27 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Wed Jul 27 17:49:49 2016
New Revision: 276933

URL: http://llvm.org/viewvc/llvm-project?rev=276933=rev
Log:
[OpenMP] Add support for mapping array sections through pointer references.

Summary:
This patch fixes a bug in the map of array sections whose base is a reference 
to a pointer. The existing mapping support was not prepared to deal with it, 
causing the compiler to crash.

Mapping a reference to a pointer enjoys the same characteristics of a regular 
pointer, i.e., it is passed by value. Therefore, the reference has to be 
materialized in the target region.

Reviewers: hfinkel, carlo.bertolli, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=276933=276932=276933=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jul 27 17:49:49 2016
@@ -5271,15 +5271,13 @@ private:
 
   // If the variable is a pointer and is being dereferenced (i.e. is not
   // the last component), the base has to be the pointer itself, not its
-  // reference.
-  if (I->getAssociatedDeclaration()->getType()->isAnyPointerType() &&
-  std::next(I) != CE) {
-auto PtrAddr = CGF.MakeNaturalAlignAddrLValue(
-BP, I->getAssociatedDeclaration()->getType());
+  // reference. References are ignored for mapping purposes.
+  QualType Ty =
+  I->getAssociatedDeclaration()->getType().getNonReferenceType();
+  if (Ty->isAnyPointerType() && std::next(I) != CE) {
+auto PtrAddr = CGF.MakeNaturalAlignAddrLValue(BP, Ty);
 BP = CGF.EmitLoadOfPointerLValue(PtrAddr.getAddress(),
- I->getAssociatedDeclaration()
- ->getType()
- ->getAs())
+ Ty->castAs())
  .getPointer();
 
 // We do not need to generate individual map information for the

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=276933=276932=276933=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Jul 27 17:49:49 2016
@@ -264,7 +264,17 @@ CodeGenFunction::GenerateOpenMPCapturedS
 // If we are capturing a pointer by copy we don't need to do anything, just
 // use the value that we get from the arguments.
 if (I->capturesVariableByCopy() && FD->getType()->isAnyPointerType()) {
-  setAddrOfLocalVar(I->getCapturedVar(), GetAddrOfLocalVar(Args[Cnt]));
+  const VarDecl *CurVD = I->getCapturedVar();
+  Address LocalAddr = GetAddrOfLocalVar(Args[Cnt]);
+  // If the variable is a reference we need to materialize it here.
+  if (CurVD->getType()->isReferenceType()) {
+Address RefAddr = CreateMemTemp(CurVD->getType(), getPointerAlign(),
+".materialized_ref");
+EmitStoreOfScalar(LocalAddr.getPointer(), RefAddr, /*Volatile=*/false,
+  CurVD->getType());
+LocalAddr = RefAddr;
+  }
+  setAddrOfLocalVar(CurVD, LocalAddr);
   ++Cnt;
   ++I;
   continue;

Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=276933=276932=276933=diff
==
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Wed Jul 27 17:49:49 2016
@@ -60,12 +60,15 @@ void implicit_maps_integer (int a){
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK2 --check-prefix CK2-32
 #ifdef CK2
 
-// CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
-// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i[[sz]]] zeroinitializer
+// Map types: OMP_MAP_IS_PTR = 32
+// CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i32] [i32 32]
 
-// CK2-LABEL: implicit_maps_integer_reference
-void implicit_maps_integer_reference (int 

Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-07-27 Thread Martin Probst via cfe-commits
mprobst added a comment.

Friendly ping :-)


https://reviews.llvm.org/D22431



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


r276930 - test/Frontend: Add a test for aarch64 target CPU names.

2016-07-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Wed Jul 27 17:47:07 2016
New Revision: 276930

URL: http://llvm.org/viewvc/llvm-project?rev=276930=rev
Log:
test/Frontend: Add a test for aarch64 target CPU names.

Nothing else checked the target cpu names for aarch64 yet.
Add a test in the spirit of x86-target-cpu.c.

Added:
cfe/trunk/test/Frontend/aarch64-target-cpu.c

Added: cfe/trunk/test/Frontend/aarch64-target-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/aarch64-target-cpu.c?rev=276930=auto
==
--- cfe/trunk/test/Frontend/aarch64-target-cpu.c (added)
+++ cfe/trunk/test/Frontend/aarch64-target-cpu.c Wed Jul 27 17:47:07 2016
@@ -0,0 +1,14 @@
+// Ensure we support the various CPU names.
+//
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a35 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a53 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a57 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a72 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a73 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cyclone -verify 
%s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu exynos-m1 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu generic -verify 
%s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu kryo -verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu vulcan -verify 
%s
+//
+// expected-no-diagnostics


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


r276931 - Basic/Targets.cpp: Reformat aarch64 CPU list.

2016-07-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Wed Jul 27 17:47:09 2016
New Revision: 276931

URL: http://llvm.org/viewvc/llvm-project?rev=276931=rev
Log:
Basic/Targets.cpp: Reformat aarch64 CPU list.

Having 1 entry per line and an alphabetical order is clearer and reduces
the risk of invalid merges.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=276931=276930=276931=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 27 17:47:09 2016
@@ -5727,14 +5727,17 @@ public:
 
   bool setCPU(const std::string ) override {
 bool CPUKnown = llvm::StringSwitch(Name)
-.Case("generic", true)
-.Cases("cortex-a53", "cortex-a57", "cortex-a72",
-   "cortex-a35", "exynos-m1", true)
-.Case("cortex-a73", true)
-.Case("cyclone", true)
-.Case("kryo", true)
-.Case("vulcan", true)
-.Default(false);
+  .Case("cortex-a35", true)
+  .Case("cortex-a53", true)
+  .Case("cortex-a57", true)
+  .Case("cortex-a72", true)
+  .Case("cortex-a73", true)
+  .Case("cyclone", true)
+  .Case("exynos-m1", true)
+  .Case("generic", true)
+  .Case("kryo", true)
+  .Case("vulcan", true)
+  .Default(false);
 return CPUKnown;
   }
 


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


r276929 - Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Wed Jul 27 17:46:31 2016
New Revision: 276929

URL: http://llvm.org/viewvc/llvm-project?rev=276929=rev
Log:
Refactor how include paths are appended to the command arguments.

Summary:
This patch aims at removing redundancy in the way include paths for the regular 
and offloading toolchains are appended to the arguments list in the clang tool.

This was suggested by @rsmith in response to r275931.

Reviewers: rsmith, tra

Subscribers: rsmith, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cuda-version-check.cu

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276929=276928=276929=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 17:46:31 2016
@@ -296,56 +296,25 @@ static bool forwardToGCC(const Option 
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
-/// Add the C++ include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadCXXStdlibIncludeArgs(Compilation ,
-const JobAction ,
-const ArgList ,
-ArgStringList ) {
+/// Apply \a Work on the current tool chain \a RegularToolChain and any other
+/// offloading tool chain that is associated with the current action \a JA.
+static void
+forAllAssociatedToolChains(Compilation , const JobAction ,
+   const ToolChain ,
+   llvm::function_ref Work) {
+  // Apply Work on the current/regular tool chain.
+  Work(RegularToolChain);
 
+  // Apply Work on all the offloading tool chains associated with the current
+  // action.
   if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
 
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the C include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadClangSystemIncludeArgs(Compilation ,
-  const JobAction ,
-  const ArgList ,
-  ArgStringList ) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the include args that are specific of each offloading programming 
model.
-static void addExtraOffloadSpecificIncludeArgs(Compilation ,
-   const JobAction ,
-   const ArgList ,
-   ArgStringList ) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
+  //
+  // TODO: Add support for other offloading programming models here.
+  //
 }
 
 void Clang::AddPreprocessingOptions(Compilation , const JobAction ,
@@ -622,22 +591,26 @@ void Clang::AddPreprocessingOptions(Comp
   // of an offloading programming model.
 
   // Add C++ include arguments, if needed.
-  if (types::isCXX(Inputs[0].getType())) {
-getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-addExtraOffloadCXXStdlibIncludeArgs(C, JA, Args, CmdArgs);
-  }
+  if (types::isCXX(Inputs[0].getType()))
+forAllAssociatedToolChains(C, JA, getToolChain(),
+   [, ](const ToolChain ) {
+ TC.AddClangCXXStdlibIncludeArgs(Args, 
CmdArgs);
+   });
 
   // Add system include arguments for all targets but IAMCU.
-  if (!IsIAMCU) {
-getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
-addExtraOffloadClangSystemIncludeArgs(C, JA, Args, CmdArgs);
-  } else {
+  if (!IsIAMCU)
+

Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-27 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:509
@@ +508,3 @@
+  //}
+  //  }
+  //}

I disagree about compactness being valuable here. I think it is more important 
to intrinsically document the spec. These will be written once and read 
frequently. When they are written, they will copied from a previous example -- 
probably by someone who is not familiar with the code or the spec format.

Another possibility (not sure if it is the right one here) is to use macro 
tricks to define a simple DSL like Kulpreet did in the LocalizationChecker.cpp.


https://reviews.llvm.org/D20811



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276927: [CUDA] Align kernel launch args correctly when the 
LLVM type's alignment is… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D22879?vs=65800=65824#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22879

Files:
  cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu

Index: cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
===
--- cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
+++ cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
   ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+
+// Using llvm::StructType is correct only because printf doesn't accept
+// aggregates.  If we had to handle aggregates here, we'd have to manually
+// compute the offsets within the alloca -- we wouldn't be able to assume
+// that the alignment of the llvm type was the same as the alignment of the
+// clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");
 llvm::Value *Alloca = CreateTempAlloca(AllocaTy);
 
Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction ,
  FunctionArgList ) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = 

r276927 - [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul 27 17:36:21 2016
New Revision: 276927

URL: http://llvm.org/viewvc/llvm-project?rev=276927=rev
Log:
[CUDA] Align kernel launch args correctly when the LLVM type's alignment is 
different from the clang type's alignment.

Summary:
Before this patch, we computed the offsets in memory of args passed to
GPU kernel functions by throwing all of the args into an LLVM struct.

clang emits packed llvm structs basically whenever it feels like it, and
packed structs have alignment 1.  So we cannot rely on the llvm type's
alignment matching the C++ type's alignment.

This patch fixes our codegen so we always respect the clang types'
alignments.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Added:
cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
Modified:
cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp

Modified: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp?rev=276927=276926=276927=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp Wed Jul 27 17:36:21 2016
@@ -99,6 +99,12 @@ CodeGenFunction::EmitCUDADevicePrintfCal
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
   ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+
+// Using llvm::StructType is correct only because printf doesn't accept
+// aggregates.  If we had to handle aggregates here, we'd have to manually
+// compute the offsets within the alloca -- we wouldn't be able to assume
+// that the alignment of the llvm type was the same as the alignment of the
+// clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");
 llvm::Value *Alloca = CreateTempAlloca(AllocaTy);
 

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=276927=276926=276927=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Wed Jul 27 17:36:21 2016
@@ -118,37 +118,28 @@ void CGNVCUDARuntime::emitDeviceStub(Cod
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction ,
  FunctionArgList ) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-
ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch

Added: cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu?rev=276927=auto

Re: [PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

2016-07-27 Thread Manman Ren via cfe-commits
manmanren abandoned this revision.
manmanren added a comment.

Abandon this change for now.


https://reviews.llvm.org/D22636



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

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

lgtm


https://reviews.llvm.org/D22879



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a comment.

Ok, sounds good. Feel free to abandon this one as well.

cheers,
--renato


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D22856#497796, @NoQ wrote:

> > I think it would be better for fully-qualified Objective-C methods to be 
> > specified with their Objective-C-style names. For example: "-[Test1 
> > myMethodWithY:withX:]".
>
>
> Uhm, need to know more about those. So i just print "`-[`", then 
> fully-qualified class name, then selector identifier, then "`]`"?


Instance methods get "-" and class methods (which are similar to static methods 
in Java) get the "+" prefix. See CGDebugInfo::getObjCMethodName() in 
CGDebugInfo.cpp for the gory details.


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22874: [analyzer] Fixes to the checker developer manual.

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

A couple of nits. Otherwise, LGTM. Thanks!



Comment at: www/analyzer/checker_dev_manual.html:534
@@ +533,3 @@
+itself to the child process (for example, in gcc you can
+set follow-fork-mode=child), or use the -###
+flag for obtaining the command line of the child process:

I suggest to just tell about -### and drop the explanation about attaching to 
the child process. Sounds good?


Comment at: www/analyzer/checker_dev_manual.html:645
@@ +644,3 @@
+
+The bug reporter mechanism removes path diagnostics inside intermediate
+function calls that have returned by the time the bug was found and contain

I'd move this up after the description of "-analyze-function=foo".


https://reviews.llvm.org/D22874



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


r276925 - Don't crash when generating code for __attribute__((naked)) member functions.

2016-07-27 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul 27 17:04:24 2016
New Revision: 276925

URL: http://llvm.org/viewvc/llvm-project?rev=276925=rev
Log:
Don't crash when generating code for __attribute__((naked)) member functions.

Summary:
Previously this crashed inside EmitThisParam().  There should be no
prelude for naked functions, so just skip the whole thing.

Reviewers: majnemer

Subscribers: llvm-commits

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

Added:
cfe/trunk/test/CodeGenCXX/naked.cpp
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=276925=276924=276925=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Jul 27 17:04:24 2016
@@ -1390,6 +1390,10 @@ void ItaniumCXXABI::addImplicitStructorP
 }
 
 void ItaniumCXXABI::EmitInstanceFunctionProlog(CodeGenFunction ) {
+  // Naked functions have no prolog.
+  if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr())
+return;
+
   /// Initialize the 'this' slot.
   EmitThisParam(CGF);
 

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=276925=276924=276925=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Jul 27 17:04:24 2016
@@ -1417,6 +1417,10 @@ llvm::Value *MicrosoftCXXABI::adjustThis
 }
 
 void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction ) {
+  // Naked functions have no prolog.
+  if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr())
+return;
+
   EmitThisParam(CGF);
 
   /// If this is a function that the ABI specifies returns 'this', initialize

Added: cfe/trunk/test/CodeGenCXX/naked.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/naked.cpp?rev=276925=auto
==
--- cfe/trunk/test/CodeGenCXX/naked.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/naked.cpp Wed Jul 27 17:04:24 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows -emit-llvm %s -o - | FileCheck %s
+
+class TestNaked {
+public:
+  void NakedFunction();
+};
+
+__attribute__((naked)) void TestNaked::NakedFunction() {
+  // CHECK-LABEL: define void @
+  // CHECK: call void asm sideeffect
+  asm("");
+}


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


Re: [PATCH] D22788: [OpenMP] Code generation for the is_device_ptr clause

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65813.
sfantao updated the summary for this revision.
sfantao added a comment.

- Remove unecessary brief directives from comments.


https://reviews.llvm.org/D22788

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/OpenMPClause.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_is_device_ptr_codegen.cpp
  test/OpenMP/target_is_device_ptr_messages.cpp

Index: test/OpenMP/target_is_device_ptr_messages.cpp
===
--- test/OpenMP/target_is_device_ptr_messages.cpp
+++ test/OpenMP/target_is_device_ptr_messages.cpp
@@ -142,6 +142,7 @@
   T * = k;
   T aa[10];
   auto  = aa;
+  S6 *ps;
 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
   {}
 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
@@ -178,6 +179,22 @@
   {}
 #pragma omp target is_device_ptr(da) // OK
   {}
+#pragma omp target map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as firstprivate}}
+  {}
+#pragma omp target is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as private}}
+  {}
   return 0;
 }
 
@@ -194,6 +211,7 @@
   int * = k;
   int aa[10];
   auto  = aa;
+  S6 *ps;
 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
   {}
 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
@@ -230,5 +248,21 @@
   {}
 #pragma omp target is_device_ptr(da) // OK
   {}
+#pragma omp target map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as firstprivate}}
+  {}
+#pragma omp target is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as private}}
+  {}
   return tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -0,0 +1,293 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck 

Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/CodeGen/CGStmtOpenMP.cpp:3410-3411
@@ +3409,4 @@
+  llvm::DenseSet EmittedAsFirstprivate;
+  CGCapturedStmtInfo CapturesInfo(cast(*D.getAssociatedStmt()));
+  for (const auto *C : D.getClausesOfKind()) {
+auto OrigVarIt = C->varlist_begin();

ABataev wrote:
> EmitOMPUseDevicePtrClause() should emit the code for single clause. The outer 
> loop must be used in directive emission function.
Ok ,makes sense, Doing as you say.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:3477-3495
@@ +3476,21 @@
+  // Codegen with device pointer privatization.
+  auto & = [, ](CodeGenFunction , PrePostActionTy &) {
+auto & = [, ](CodeGenFunction , PrePostActionTy &) {
+  OMPPrivateScope PrivateScope(CGF);
+  CGF.EmitOMPUseDevicePtrClause(S, PrivateScope, 
Info.CaptureDeviceAddrMap);
+  (void)PrivateScope.Privatize();
+  CGF.EmitStmt(
+  cast(S.getAssociatedStmt())->getCapturedStmt());
+};
+// Notwithstanding the body of the region is emitted as inlined directive,
+// we don't use an inline scope as changes in the references inside the
+// region are expected to be visible outside, so we do not privative them.
+OMPLexicalScope Scope(CGF, S);
+CGF.CGM.getOpenMPRuntime().emitInlinedDirective(CGF, OMPD_target_data,
+CodeGen);
+  };
+
+  // Codegen with no device pointer privatization.
+  auto & = [, ](CodeGenFunction , PrePostActionTy &) {
+auto & = [, ](CodeGenFunction , PrePostActionTy &) {
+  CGF.EmitStmt(

ABataev wrote:
> PvtCodeGen and NoPvtCodeGen are pretty similar. Could you merge them somehow 
> into the one? Maybe some custom PrePostAction could be used here?
I replaced this code by a single region codegen controlling the privatization 
with a flag and a pre-action. Let me know if this what you had in mind.


Comment at: lib/Sema/SemaOpenMP.cpp:11858
@@ +11857,3 @@
+// similar properties of a first private variable.
+DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_firstprivate, Ref);
+

ABataev wrote:
> Are the restrictions for firstprivates applied also? What if inner directive 
> has some clauses that cannot be used with variables previously marked as 
> firstprivates, but can be used with variables, used in use_device_ptr?
I was revisiting the spec and I couldn't find any conflict with the 
`firstprivate` restrictions. There are conflicts for variables used in a 
firstprivate clause that are also used in clauses of enclosing worksharing 
constructs but not the other way around. Note that we are using the 
firstprivate attribute but do not do all the firstprivate checks, so the 
conflicts would only arise from other enclosed constructs, not other enclosing 
constructs. Let me know if you have any specific case in mind or if you'd like 
me to do this differently.  


https://reviews.llvm.org/D22691



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


Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65810.
sfantao marked 8 inline comments as done.
sfantao added a comment.

- Remove unnecessary brief directives and refactor target data privatization 
code genenration.


https://reviews.llvm.org/D22691

Files:
  include/clang/AST/OpenMPClause.h
  lib/AST/OpenMPClause.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_codegen.cpp

Index: test/OpenMP/target_data_use_device_ptr_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_codegen.cpp
@@ -0,0 +1,464 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+double *g;
+
+// CK1: @g = global double*
+// CK1: [[MTYPE00:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE03:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE04:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE05:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE06:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE07:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE08:@.+]] = {{.*}}constant [2 x i32] [{{i32 35, i32 99|i32 99, i32 35}}]
+// CK1: [[MTYPE09:@.+]] = {{.*}}constant [2 x i32] [i32 99, i32 99]
+// CK1: [[MTYPE10:@.+]] = {{.*}}constant [2 x i32] [i32 99, i32 99]
+// CK1: [[MTYPE11:@.+]] = {{.*}}constant [2 x i32] [i32 96, i32 35]
+// CK1: [[MTYPE12:@.+]] = {{.*}}constant [2 x i32] [i32 96, i32 35]
+
+// CK1-LABEL: @_Z3foo
+template
+void foo(float *, T *) {
+  float *l;
+  T *t;
+
+  // CK1-DAG: [[RVAL:%.+]] = bitcast double* [[T:%.+]] to i8*
+  // CK1-DAG: [[T]] = load double*, double** [[DECL:@g]],
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: store i8* [[RVAL]], i8** [[BP]],
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to double**
+  // CK1: [[VAL:%.+]] = load double*, double** [[CBP]],
+  // CK1-NOT: store double* [[VAL]], double** [[DECL]],
+  // CK1: store double* [[VAL]], double** [[PVT:%.+]],
+  // CK1: [[TT:%.+]] = load double*, double** [[PVT]],
+  // CK1: getelementptr inbounds double, double* [[TT]], i32 1
+  #pragma omp target data map(g[:10]) use_device_ptr(g)
+  {
+++g;
+  }
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+  // CK1: [[TTT:%.+]] = load double*, double** [[DECL]],
+  // CK1: getelementptr inbounds double, double* [[TTT]], i32 1
+  ++g;
+
+  // CK1-DAG: [[RVAL:%.+]] = bitcast float* [[T1:%.+]] to i8*
+  // CK1-DAG: [[T1]] = load float*, float** [[DECL:%.+]],
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: store i8* [[RVAL]], i8** [[BP]],
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE01]]
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+  // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
+  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1: store float* [[VAL]], float** [[PVT:%.+]],
+  // CK1: [[TT1:%.+]] = load float*, float** [[PVT]],
+  // CK1: getelementptr inbounds float, float* [[TT1]], i32 1
+  #pragma omp target data map(l[:10]) use_device_ptr(l)
+  {
+++l;
+  }
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE01]]
+  // CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
+  // CK1: getelementptr inbounds float, float* [[TTT]], i32 1
+  ++l;
+
+  // CK1-NOT: call void @__tgt_target
+  

Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-07-27 Thread Eric Christopher via cfe-commits
echristo added a comment.

Go ahead and split out your cleanups into another patch and remove the custom 
handling in the hexagon target then.

Thanks!

-eric


Repository:
  rL LLVM

https://reviews.llvm.org/D22766



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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Not a huge fan of the registration/etc. That said, this is cleaner than a lot 
of the alternatives at the moment without making you do a lot of toolchain 
evisceration.

LGTM.

-eric


https://reviews.llvm.org/D22596



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: test/CodeGenCUDA/kernel-args-alignment.cu:1-2
@@ +1,3 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+

rnk wrote:
> Typically clang doesn't need a registered backend for a target to generate IR 
> for that target. It "knows" a whole bunch of stuff about all target calling 
> conventions and data layout. Unless CUDA goes out of its way to query LLVM 
> backend information, we shouldn't need these REQUIRES lines.
> 
> You should probably test this theory, though, by configuring an ARM-only 
> clang and running the tests. :)
Yeah, I don't think we actually need this, as we have a bunch of other codegen 
tests that don't have these REQUIRES lines.


https://reviews.llvm.org/D22879



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 65800.
jlebar added a comment.

Remove REQUIRES lines.


https://reviews.llvm.org/D22879

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/kernel-args-alignment.cu

Index: test/CodeGenCUDA/kernel-args-alignment.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction ,
  FunctionArgList ) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
   ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+
+// Using llvm::StructType is correct only because printf doesn't accept
+// aggregates.  If we had to handle aggregates here, we'd have to manually
+// compute the offsets within the alloca -- we wouldn't be able to assume
+// that the alignment of the llvm type was the same as the alignment of the
+// clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");

Re: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Nirav Davé via cfe-commits
Looks like I missed the target triple. Should work now.

Thanks,

-Nirav

On Wed, Jul 27, 2016 at 4:41 PM, Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

> Hi Nirav,
>
> This test is failing on darwin:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26574
>
> Can you take a look?
>
> On Wed, Jul 27, 2016 at 12:57 PM, Nirav Dave via cfe-commits
>  wrote:
> > Author: niravd
> > Date: Wed Jul 27 14:57:40 2016
> > New Revision: 276907
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276907=rev
> > Log:
> > Add flags to toggle preservation of assembly comments
> >
> > Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.
> >
> > Reviewers: echristo, rnk
> >
> > Subscribers: mehdi_amini, llvm-commits
> >
> > Differential Revision: https://reviews.llvm.org/D22883
> >
> > Added:
> > cfe/trunk/test/CodeGen/preserve-as-comments.c
> > Modified:
> > cfe/trunk/include/clang/Driver/Options.td
> > cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > cfe/trunk/lib/Driver/Tools.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> >
> > Modified: cfe/trunk/include/clang/Driver/Options.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907=276906=276907=diff
> >
> ==
> > --- cfe/trunk/include/clang/Driver/Options.td (original)
> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
> > @@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group >  def fno_pie : Flag<["-"], "fno-pie">, Group;
> >  def fplugin_EQ : Joined<["-"], "fplugin=">, Group,
> Flags<[DriverOption]>, MetaVarName<"">,
> >HelpText<"Load the named plugin (dynamic shared object)">;
> > +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">,
> Group;
> > +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">,
> Group, Flags<[CC1Option]>,
> > +  HelpText<"Do not preserve comments in inline assembly">;
> >  def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
> >  def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
> >  def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
> >
> > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907=276906=276907=diff
> >
> ==
> > --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> > +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27
> 14:57:40 2016
> > @@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
> >  CODEGENOPT(CompressDebugSections, 1, 0) ///<
> -Wa,-compress-debug-sections
> >  CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
> >  CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
> > +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA,
> -fno-preserve-as-comments.
> >  CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit
> __attribute__((malloc)) operator new
> >  CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
> >  CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should
> be EH-safe.
> >
> > Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907=276906=276907=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
> > @@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
> >CodeGenOpts.IncrementalLinkerCompatible;
> >Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
> >Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
> > +  Options.MCOptions.PreserveAsmComments =
> CodeGenOpts.PreserveAsmComments;
> >Options.MCOptions.ABIName = TargetOpts.ABI;
> >
> >TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
> FeaturesStr,
> >
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907=276906=276907=diff
> >
> ==
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
> > @@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation ,
> >  true))
> >  CmdArgs.push_back("-fno-jump-tables");
> >
> > +  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
> > +options::OPT_fno_preserve_as_comments, true))
> > +CmdArgs.push_back("-fno-preserve-as-comments");
> > +
> >if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
> > 

r276915 - Add target triple in test

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 15:48:39 2016
New Revision: 276915

URL: http://llvm.org/viewvc/llvm-project?rev=276915=rev
Log:
Add target triple in test

Modified:
cfe/trunk/test/CodeGen/preserve-as-comments.c

Modified: cfe/trunk/test/CodeGen/preserve-as-comments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/preserve-as-comments.c?rev=276915=276914=276915=diff
==
--- cfe/trunk/test/CodeGen/preserve-as-comments.c (original)
+++ cfe/trunk/test/CodeGen/preserve-as-comments.c Wed Jul 27 15:48:39 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -S -fno-preserve-as-comments %s -o - | FileCheck %s 
--check-prefix=NOASM --check-prefix=CHECK
-// RUN: %clang_cc1 -S %s -o - | FileCheck %s --check-prefix=ASM 
--check-prefix=CHECK
+// RUN: %clang_cc1 -S -triple=x86_64-unknown-unknown -fno-preserve-as-comments 
%s -o - | FileCheck %s --check-prefix=NOASM --check-prefix=CHECK
+// RUN: %clang_cc1 -S %s -triple=x86_64-unknown-unknown -o - | FileCheck %s 
--check-prefix=ASM --check-prefix=CHECK
 
 // CHECK-LABEL: main
 // CHECK: #APP


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


Re: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Bruno Cardoso Lopes via cfe-commits
Hi Nirav,

This test is failing on darwin:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26574

Can you take a look?

On Wed, Jul 27, 2016 at 12:57 PM, Nirav Dave via cfe-commits
 wrote:
> Author: niravd
> Date: Wed Jul 27 14:57:40 2016
> New Revision: 276907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276907=rev
> Log:
> Add flags to toggle preservation of assembly comments
>
> Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.
>
> Reviewers: echristo, rnk
>
> Subscribers: mehdi_amini, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D22883
>
> Added:
> cfe/trunk/test/CodeGen/preserve-as-comments.c
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907=276906=276907=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
> @@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group  def fno_pie : Flag<["-"], "fno-pie">, Group;
>  def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
> Flags<[DriverOption]>, MetaVarName<"">,
>HelpText<"Load the named plugin (dynamic shared object)">;
> +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
> Group;
> +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
> Group, Flags<[CC1Option]>,
> +  HelpText<"Do not preserve comments in inline assembly">;
>  def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
>  def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
>  def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907=276906=276907=diff
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27 14:57:40 
> 2016
> @@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
>  CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
>  CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
>  CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
> +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
>  CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit 
> __attribute__((malloc)) operator new
>  CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
>  CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
> EH-safe.
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907=276906=276907=diff
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
> @@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
>CodeGenOpts.IncrementalLinkerCompatible;
>Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
>Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
> +  Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
>Options.MCOptions.ABIName = TargetOpts.ABI;
>
>TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, 
> FeaturesStr,
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907=276906=276907=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
> @@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation ,
>  true))
>  CmdArgs.push_back("-fno-jump-tables");
>
> +  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
> +options::OPT_fno_preserve_as_comments, true))
> +CmdArgs.push_back("-fno-preserve-as-comments");
> +
>if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
>  CmdArgs.push_back("-mregparm");
>  CmdArgs.push_back(A->getValue());
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=276907=276906=276907=diff
> ==
> --- 

r276912 - test commit

2016-07-27 Thread Matt Masten via cfe-commits
Author: mmasten
Date: Wed Jul 27 15:23:32 2016
New Revision: 276912

URL: http://llvm.org/viewvc/llvm-project?rev=276912=rev
Log:
test commit

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

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=276912=276911=276912=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Jul 27 15:23:32 2016
@@ -55,6 +55,7 @@ public:
 Accelerate // Use the Accelerate framework.
   };
 
+
   enum ObjCDispatchMethodKind {
 Legacy = 0,
 NonLegacy = 1,


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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits

Fixed in r276889 by Simon Pilgrim!
On 27/07/16 22:03, Vassil Vassilev wrote:

Looking into it.
On 27/07/16 18:34, Jun Bum Lim wrote:

junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: 
default label in switch which covers all enumeration values 
[-Werror,-Wcovered-switch-default]


   default: llvm_unreachable("Unknown code completion result Kind.");
   ^


Repository:
   rL LLVM

https://reviews.llvm.org/D17820







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


Re: r276889 - Fix unnecessary default switch warning

2016-07-27 Thread Vassil Vassilev via cfe-commits

Thanks a lot!
On 27/07/16 18:41, Simon Pilgrim via cfe-commits wrote:

Author: rksimon
Date: Wed Jul 27 11:41:56 2016
New Revision: 276889

URL: http://llvm.org/viewvc/llvm-project?rev=276889=rev
Log:
Fix unnecessary default switch warning

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

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=276889=276888=276889=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Jul 27 11:41:56 2016
@@ -445,8 +445,8 @@ bool PrintingCodeCompleteConsumer::isRes
case CodeCompletionResult::RK_Pattern: {
  return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
}
-  default: llvm_unreachable("Unknown code completion result Kind.");
}
+  llvm_unreachable("Unknown code completion result Kind.");
  }
  
  void



___
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] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 65796.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments. Added missing codegen test.


https://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,31 +1,85 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+constant sampler_t glb_smp6 = glb_smp; // expected-error{{initializer element is not a compile-time constant}}
+
+int f(void);
+constant sampler_t glb_smp7 = f(); // expected-error{{initializer element is not a compile-time constant}}
+
+constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant sampler_t' with an expression of incompatible type 'float'}}
+
+constant sampler_t glb_smp9 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
 
 void foo(sampler_t);
 
 constant struct sampler_s {
   sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
 } sampler_str = {0};
 
+sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
-  const sampler_t const_smp = 7;
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  const sampler_t const_smp2;
+  const sampler_t const_smp3 = const_smp;
+  const sampler_t const_smp4 = f();
+  const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const sampler_t' with an expression of incompatible type 'float'}}
+  const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
+
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);
+  foo(glb_smp4);
+  foo(glb_smp5);
+  foo(glb_smp6);
+  foo(glb_smp7);
+  foo(glb_smp8);
+  foo(glb_smp9);
+  foo(smp);
+  foo(sampler_str.smp);
   foo(const_smp);
+  foo(const_smp2);
+  foo(const_smp3);
+  foo(const_smp4);
+  foo(const_smp5);
+  foo(const_smp6);
+  foo(argsmp);
   foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
+  foo(sa[0]);
+  foo(bad());
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
 
 void bar() {
-  sampler_t smp1 = 7;
-  sampler_t smp2 = 2;
+  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
   smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
   smp1+1; //expected-error{{invalid operands to binary expression 

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Yaxun Liu via cfe-commits
yaxunl marked 9 inline comments as done.


Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:84
@@ +83,3 @@
+SamplerTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "__opencl_sampler_t"),
+  CGM.getContext().getTargetAddressSpace(

Anastasia wrote:
> Related to this thread: 
> http://lists.llvm.org/pipermail/cfe-dev/2016-July/050126.html.
> 
> I am guessing leaving the old naming scheme should be fine.
I have some more comments about that. I think we should use 
`struct.__opencl_sampler` as the name of sampler type in LLVM IR.


Comment at: lib/Sema/SemaInit.cpp:6949
@@ +6948,3 @@
+  // declaration.
+  if (!Var->getInit() || !isa(Var->getInit()))
+break;

Anastasia wrote:
> Do we accept declaring global sampler_t variable without an initializer?
no. Since in file scope sampler variable is only allowed in constant addr 
space, it has to be initialized. There is a test for it.


Comment at: lib/Sema/SemaInit.cpp:6956
@@ +6955,3 @@
+}
+  }
+

Anastasia wrote:
> Could you use else here instead of adding TakeLiteral variable to avoid going 
> to the next compound statement?
Good catch. Will do.


Comment at: lib/Sema/SemaInit.cpp:6965
@@ +6964,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Anastasia wrote:
> Should this generate an error?
This has already been diagnosed when parsing the intializer of the variable 
declaration.


Comment at: test/SemaOpenCL/sampler_t.cl:51
@@ -14,1 +50,3 @@
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);

Anastasia wrote:
> Are these extra calls below adding any extra testing?
Add the function calls to test

1. No additional error msgs since the error msgs should be emitted for the 
variable declarations.
2. no crashes when parsing them


Comment at: test/SemaOpenCL/sampler_t.cl:83
@@ -28,2 +82,3 @@
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary 
expression}}
+  foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }

Anastasia wrote:
> Does this line add extra testing?
Test no crashes when an invalid sampler expression is passed as a sampler 
argument.


https://reviews.llvm.org/D21567



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


r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 14:57:40 2016
New Revision: 276907

URL: http://llvm.org/viewvc/llvm-project?rev=276907=rev
Log:
Add flags to toggle preservation of assembly comments

Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.

Reviewers: echristo, rnk

Subscribers: mehdi_amini, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/preserve-as-comments.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907=276906=276907=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
@@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
Group;
+def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Do not preserve comments in inline assembly">;
 def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
 def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
 def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907=276906=276907=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27 14:57:40 2016
@@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
 CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
 CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907=276906=276907=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
@@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
   CodeGenOpts.IncrementalLinkerCompatible;
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+  Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
 
   TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907=276906=276907=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
@@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation ,
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
+options::OPT_fno_preserve_as_comments, true))
+CmdArgs.push_back("-fno-preserve-as-comments");
+
   if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
 CmdArgs.push_back("-mregparm");
 CmdArgs.push_back(A->getValue());

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=276907=276906=276907=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jul 27 14:57:40 2016
@@ -544,6 +544,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
   Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
+  Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
   

Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits

Looking into it.
On 27/07/16 18:34, Jun Bum Lim wrote:

junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: default label 
in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

   default: llvm_unreachable("Unknown code completion result Kind.");
   ^


Repository:
   rL LLVM

https://reviews.llvm.org/D17820





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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D22857#497719, @rengolin wrote:

> I'll just echo @compnerd comments, since Phab didn't get it.
>
> - Change the syntax to __asm__, to be more portable
> - Add Microsoft asm block syntax


MSVC doesn't support inline assembly on ARM at all (they only support that on 
32 bit x86), so there's none of their syntax to support or test.

In https://reviews.llvm.org/D22857#497808, @rengolin wrote:

> As I read it, this is just making sure "inline asm" works on Windows, which 
> apparently hasn't been working so far. In a way, unrelated to the commit in 
> question.


No, inline assembly has been working, but only for assembly that didn't contain 
any immediate values.

> I agree we shouldn't be adding clang tests to assembler bugs.


Ok, we can skip this test if you prefer - the assembler test added for llvm-mc 
should be fine and enough as well.


https://reviews.llvm.org/D22857



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


r276904 - Adjust coercion of aggregates on RenderScript

2016-07-27 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Wed Jul 27 14:01:51 2016
New Revision: 276904

URL: http://llvm.org/viewvc/llvm-project?rev=276904=rev
Log:
Adjust coercion of aggregates on RenderScript

Summary:
In RenderScript, the size of the argument or return value emitted in the
IR is expected to be the same as the size of corresponding qualified
type.  For ARM and AArch64, the coercion performed by Clang can
change the parameter or return value to a type whose size is different
(usually larger) than the original aggregate type.  Specifically, this
can happen in the following cases:
- Aggregate parameters of size <= 64 bytes and return values smaller
  than 4 bytes on ARM
- Aggregate parameters and return values smaller than bytes on
  AArch64

This patch coerces the cases above to an integer array that is the same
size and alignment as the original aggregate.  A new field is added to
TargetInfo to detect a RenderScript target and limit this coercion just
to that case.

Tests added to test/CodeGen/renderscript.c

Reviewers: rsmith

Subscribers: aemerson, srhines, llvm-commits

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/renderscript.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=276904=276903=276904=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Jul 27 14:01:51 2016
@@ -92,6 +92,8 @@ protected:
 
   unsigned HasBuiltinMSVaList : 1;
 
+  unsigned IsRenderScriptTarget : 1;
+
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple );
 
@@ -565,6 +567,9 @@ public:
   /// available on this target.
   bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; }
 
+  /// Returns true for RenderScript.
+  bool isRenderScriptTarget() const { return IsRenderScriptTarget; }
+
   /// \brief Returns whether the passed in string is a valid clobber in an
   /// inline asm statement.
   ///

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=276904=276903=276904=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Wed Jul 27 14:01:51 2016
@@ -80,6 +80,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   SSERegParmMax = 0;
   HasAlignMac68kSupport = false;
   HasBuiltinMSVaList = false;
+  IsRenderScriptTarget = false;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=276904=276903=276904=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 27 14:01:51 2016
@@ -8113,6 +8113,7 @@ public:
  Triple.getOSName(),
  Triple.getEnvironmentName()),
 Opts) {
+IsRenderScriptTarget = true;
 LongWidth = LongAlign = 64;
   }
   void getTargetDefines(const LangOptions ,
@@ -8130,7 +8131,9 @@ public:
   : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(),
  Triple.getOSName(),
  Triple.getEnvironmentName()),
-Opts) {}
+Opts) {
+IsRenderScriptTarget = true;
+  }
 
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=276904=276903=276904=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 27 14:01:51 2016
@@ -31,6 +31,31 @@
 using namespace clang;
 using namespace CodeGen;
 
+// Helper for coercing an aggregate argument or return value into an integer
+// array of the same size (including padding) and alignment.  This alternate
+// coercion happens only for the RenderScript ABI and can be removed after
+// runtimes that rely on it are no longer supported.
+//
+// RenderScript assumes that the size of the argument / return value in the IR
+// is the same as the size of the corresponding qualified type. This helper
+// coerces the aggregate type into an array of the same size (including
+// padding).  This coercion is used in lieu of expansion of 

[PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-27 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added reviewers: klimek, omtcyfz.
alexshap added subscribers: compnerd, cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

Properly initialize the field Context in NamedDeclFindingASTVisitor 
constructor: 
it is dereferenced in VisitTypeLoc Context->getLangOpts(). 
Fix passing nullptr to setResult in VisitTypeLoc: 
it is dereferenced in setResult Decl->getQualifiedNameAsString().
Add a test case: 
clang-rename crashes on it without this patch, works correctly with this patch. 
All the other tests are green.

https://reviews.llvm.org/D22881

Files:
  clang-rename/USRFinder.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp

Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -42,8 +42,9 @@
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager ,
-  const std::string )
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string ,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -76,8 +77,9 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@
 const NamedDecl *getNamedDeclFor(const ASTContext ,
  const std::string ) {
   const auto  = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, );
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();


Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -42,8 +42,9 @@
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager ,
-  const std::string )
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string ,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -76,8 +77,9 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@
 const NamedDecl *getNamedDeclFor(const ASTContext ,
  const std::string ) {
   const auto  = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, );
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21145: [Sema] Fix crash on valid where instantiation of lambda cannot access type of 'this'

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276900: [Sema] Teach getCurrentThisType to reconize lambda 
in in-class initializer (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D21145?vs=60622=65779#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21145

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Index: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
===
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -961,32 +961,26 @@
 QualType Sema::getCurrentThisType() {
   DeclContext *DC = getFunctionLevelDeclContext();
   QualType ThisTy = CXXThisTypeOverride;
+
   if (CXXMethodDecl *method = dyn_cast(DC)) {
 if (method && method->isInstance())
   ThisTy = method->getThisType(Context);
   }
-  if (ThisTy.isNull()) {
-if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
-CurContext->getParent()->getParent()->isRecord()) {
-  // This is a generic lambda call operator that is being instantiated
-  // within a default initializer - so use the enclosing class as 'this'.
-  // There is no enclosing member function to retrieve the 'this' pointer
-  // from.
-
-  // FIXME: This looks wrong. If we're in a lambda within a lambda within a
-  // default member initializer, we need to recurse up more parents to find
-  // the right context. Looks like we should be walking up to the parent of
-  // the closure type, checking whether that is itself a lambda, and if so,
-  // recursing, until we reach a class or a function that isn't a lambda
-  // call operator. And we should accumulate the constness of *this on the
-  // way.
-
-  QualType ClassTy = Context.getTypeDeclType(
-  cast(CurContext->getParent()->getParent()));
-  // There are no cv-qualifiers for 'this' within default initializers, 
-  // per [expr.prim.general]p4.
-  ThisTy = Context.getPointerType(ClassTy);
-}
+
+  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
+  !ActiveTemplateInstantiations.empty()) {
+
+assert(isa(DC) &&
+   "Trying to get 'this' type from static method?");
+
+// This is a lambda call operator that is being instantiated as a default
+// initializer. DC must point to the enclosing class type, so we can 
recover
+// the 'this' type from it.
+
+QualType ClassTy = Context.getTypeDeclType(cast(DC));
+// There are no cv-qualifiers for 'this' within default initializers,
+// per [expr.prim.general]p4.
+ThisTy = Context.getPointerType(ClassTy);
   }
 
   // If we are within a lambda's call operator, the cv-qualifiers of 'this'


Index: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
===
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks %s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks %s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -961,32 +961,26 @@
 

r276900 - [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

2016-07-27 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Jul 27 13:25:10 2016
New Revision: 276900

URL: http://llvm.org/viewvc/llvm-project?rev=276900=rev
Log:
[Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

Fixes PR27994, a crash on valid.

Differential revision: https://reviews.llvm.org/D21145

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=276900=276899=276900=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 27 13:25:10 2016
@@ -961,32 +961,26 @@ static QualType adjustCVQualifiersForCXX
 QualType Sema::getCurrentThisType() {
   DeclContext *DC = getFunctionLevelDeclContext();
   QualType ThisTy = CXXThisTypeOverride;
+
   if (CXXMethodDecl *method = dyn_cast(DC)) {
 if (method && method->isInstance())
   ThisTy = method->getThisType(Context);
   }
-  if (ThisTy.isNull()) {
-if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
-CurContext->getParent()->getParent()->isRecord()) {
-  // This is a generic lambda call operator that is being instantiated
-  // within a default initializer - so use the enclosing class as 'this'.
-  // There is no enclosing member function to retrieve the 'this' pointer
-  // from.
-
-  // FIXME: This looks wrong. If we're in a lambda within a lambda within a
-  // default member initializer, we need to recurse up more parents to find
-  // the right context. Looks like we should be walking up to the parent of
-  // the closure type, checking whether that is itself a lambda, and if so,
-  // recursing, until we reach a class or a function that isn't a lambda
-  // call operator. And we should accumulate the constness of *this on the
-  // way.
-
-  QualType ClassTy = Context.getTypeDeclType(
-  cast(CurContext->getParent()->getParent()));
-  // There are no cv-qualifiers for 'this' within default initializers, 
-  // per [expr.prim.general]p4.
-  ThisTy = Context.getPointerType(ClassTy);
-}
+
+  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
+  !ActiveTemplateInstantiations.empty()) {
+
+assert(isa(DC) &&
+   "Trying to get 'this' type from static method?");
+
+// This is a lambda call operator that is being instantiated as a default
+// initializer. DC must point to the enclosing class type, so we can 
recover
+// the 'this' type from it.
+
+QualType ClassTy = Context.getTypeDeclType(cast(DC));
+// There are no cv-qualifiers for 'this' within default initializers,
+// per [expr.prim.general]p4.
+ThisTy = Context.getPointerType(ClassTy);
   }
 
   // If we are within a lambda's call operator, the cv-qualifiers of 'this'

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=276900=276899=276900=diff
==
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Wed Jul 27 13:25:10 2016
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@ void foo() {
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}


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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: test/CodeGenCUDA/kernel-args-alignment.cu:1-2
@@ +1,3 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+

Typically clang doesn't need a registered backend for a target to generate IR 
for that target. It "knows" a whole bunch of stuff about all target calling 
conventions and data layout. Unless CUDA goes out of its way to query LLVM 
backend information, we shouldn't need these REQUIRES lines.

You should probably test this theory, though, by configuring an ARM-only clang 
and running the tests. :)


https://reviews.llvm.org/D22879



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Btw, I am missing tests for generated __translate_sampler_initializer which I 
think we had at some point.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:84
@@ +83,3 @@
+SamplerTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "__opencl_sampler_t"),
+  CGM.getContext().getTargetAddressSpace(

Related to this thread: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050126.html.

I am guessing leaving the old naming scheme should be fine.


Comment at: lib/Sema/SemaInit.cpp:6907
@@ -6905,2 +6906,3 @@
 case SK_OCLSamplerInit: {
-  assert(Step->Type->isSamplerT() && 
+  // Sampler initialzation have 6 cases:
+  //   1. function argument passing

There are 5 cases it seems :)


Comment at: lib/Sema/SemaInit.cpp:6947
@@ +6946,3 @@
+  // Do not diagnose if the file-scope variable does not have 
initializer
+  // since this has already beend diagnosed when parsing the variable
+  // declaration.

beend -> been


Comment at: lib/Sema/SemaInit.cpp:6949
@@ +6948,3 @@
+  // declaration.
+  if (!Var->getInit() || !isa(Var->getInit()))
+break;

Do we accept declaring global sampler_t variable without an initializer?


Comment at: lib/Sema/SemaInit.cpp:6956
@@ +6955,3 @@
+}
+  }
+

Could you use else here instead of adding TakeLiteral variable to avoid going 
to the next compound statement?


Comment at: lib/Sema/SemaInit.cpp:6965
@@ +6964,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Should this generate an error?


Comment at: test/SemaOpenCL/sampler_t.cl:51
@@ -14,1 +50,3 @@
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);

Are these extra calls below adding any extra testing?


Comment at: test/SemaOpenCL/sampler_t.cl:83
@@ -28,2 +82,3 @@
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary 
expression}}
+  foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }

Does this line add extra testing?


https://reviews.llvm.org/D21567



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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-27 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 65773.
ashi1 marked an inline comment as done.
ashi1 added a comment.

Removed indentation as per Anastasia's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D22637

Files:
  include/clang/Basic/OpenCLExtensions.def
  lib/Basic/Targets.cpp
  test/Misc/amdgcn.languageOptsOpenCL.cl
  test/SemaOpenCL/extension-version.cl

Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -222,6 +222,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 
 #if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
+#if (__OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -181,6 +181,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_egl_image' - 
ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
 #ifdef cl_khr_srgb_image_writes
 #error "Incorrect cl_khr_srgb_image_writes define"
 #endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2115,6 +2115,7 @@
   Opts.cl_khr_fp16 = 1;
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
Index: include/clang/Basic/OpenCLExtensions.def
===
--- include/clang/Basic/OpenCLExtensions.def
+++ include/clang/Basic/OpenCLExtensions.def
@@ -67,6 +67,7 @@
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -222,6 +222,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 
 #if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
+#if (__OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -181,6 +181,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_egl_image' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
 #ifdef cl_khr_srgb_image_writes
 #error "Incorrect cl_khr_srgb_image_writes define"
 #endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2115,6 +2115,7 @@
   Opts.cl_khr_fp16 = 1;
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
Index: include/clang/Basic/OpenCLExtensions.def
===
--- include/clang/Basic/OpenCLExtensions.def
+++ 

r276896 - Update Clang Parser test error message to match new parser errors

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 12:39:47 2016
New Revision: 276896

URL: http://llvm.org/viewvc/llvm-project?rev=276896=rev
Log:
Update Clang Parser test error message to match new parser errors

Modified:
cfe/trunk/test/Parser/ms-inline-asm.c

Modified: cfe/trunk/test/Parser/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=276896=276895=276896=diff
==
--- cfe/trunk/test/Parser/ms-inline-asm.c (original)
+++ cfe/trunk/test/Parser/ms-inline-asm.c Wed Jul 27 12:39:47 2016
@@ -54,7 +54,7 @@ void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
 void t13() {
-  __asm m{o}v eax, ebx // expected-error {{expected identifier}} 
expected-error {{use of undeclared label '{o}v eax, ebx'}}
+  __asm m{o}v eax, ebx // expected-error {{unknown token in expression}}
 }
 
 int t_fail() { // expected-note {{to match this}}


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


[PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: tra, cfe-commits.

Before this patch, we computed the offsets in memory of args passed to
GPU kernel functions by throwing all of the args into an LLVM struct.

clang emits packed llvm structs basically whenever it feels like it, and
packed structs have alignment 1.  So we cannot rely on the llvm type's
alignment matching the C++ type's alignment.

This patch fixes our codegen so we always respect the clang types'
alignments.

https://reviews.llvm.org/D22879

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/kernel-args-alignment.cu

Index: test/CodeGenCUDA/kernel-args-alignment.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction ,
  FunctionArgList ) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < 

Re: [PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi updated this revision to Diff 65765.
ibadawi added a comment.

Restore the test lost in patch #2. Really sorry for the noise...


https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext , QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext , QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi updated this revision to Diff 65763.
ibadawi added a comment.

Remove extra blank line added by accident


https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext , QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext , QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22874: [analyzer] Fixes to the checker developer manual.

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added a reviewer: zaks.anna.
NoQ added subscribers: dcoughlin, xazax.hun, a.sidorin, cfe-commits.

1. Fix the explanation of how to run tests after migration from autotools to 
cmake.

2. Expand the "debugging" section with more interesting stuff, as accidentally 
discussed in D22622 and D22856.

Any other things to fix there?

Also, does anybody think it's a good idea to mention my unofficial guide 
(https://github.com/haoNoQ/clang-analyzer-guide/releases) in the "additional 
sources" section?

https://reviews.llvm.org/D22874

Files:
  www/analyzer/checker_dev_manual.html

Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -511,75 +511,143 @@
   live in clang/test/Analysis folder. To run all of the analyzer tests, 
   execute the following from the clang build directory:
 
-$ TESTDIRS=Analysis make test
+$ bin/llvm-lit -sv ../llvm/tools/clang/test/Analysis
 
 
 Useful Commands/Debugging Hints
-
-
-While investigating a checker-related issue, instruct the analyzer to only 
+
+Attaching the debugger
+
+When your command contains the -cc1 flag, you can attach the
+debugger to it directly:
+
+
+$ gdb --args clang -cc1 -analyze -analyzer-checker=core test.c
+$ lldb -- clang -cc1 -analyze -analyzer-checker=core test.c
+
+
+
+Otherwise, if your command line contains --analyze,
+the actual clang instance would be run in a separate process. In
+order to debug it, you'd have to either instruct your debugger to attach
+itself to the child process (for example, in gcc you can
+set follow-fork-mode=child), or use the -###
+flag for obtaining the command line of the child process:
+
+
+
+$ clang --analyze test.c -\#\#\#
+
+
+
+Below we describe a few useful command line arguments, all of which assume that
+you are running clang -cc1.
+
+
+Narrowing down the problem
+
+While investigating a checker-related issue, instruct the analyzer to only
 execute a single checker:
-
-$ clang -cc1 -analyze -analyzer-checker=osx.KeychainAPI test.c
-
-
-
-To dump AST:
-
-$ clang -cc1 -ast-dump test.c
-
-
-
-To view/dump CFG use debug.ViewCFG or debug.DumpCFG checkers:
-
-$ clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.c
- 
-
-
-To see all available debug checkers:
-
-$ clang -cc1 -analyzer-checker-help | grep "debug"
-
-
-
-To see which function is failing while processing a large file use 
--analyzer-display-progress option.
-
-
-While debugging execute clang -cc1 -analyze -analyzer-checker=core 
-instead of clang --analyze, as the later would call the compiler 
-in a separate process.
-
-
-To view ExplodedGraph (the state graph explored by the analyzer) while 
-debugging, goto a frame that has clang::ento::ExprEngine object and 
-execute:
- 
-(gdb) p ViewGraph(0)
-
-
-
-To see the ProgramState while debugging use the following command. 
-
-(gdb) p State->dump()
- 
-
-
-To see clang::Expr while debugging use the following command. If you 
-pass in a SourceManager object, it will also dump the corresponding line in the 
-source code.
-
-(gdb) p E->dump()
- 
-
-
-To dump AST of a method that the current ExplodedNode belongs to:
-
-(gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump()
-(gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump(getContext().getSourceManager())
-
-
-
+
+
+$ clang -cc1 -analyze -analyzer-checker=osx.KeychainAPI test.c
+
+
+If you are experiencing a crash, to see which function is failing while
+processing a large file use the  -analyzer-display-progress
+option.
+
+You can analyze a particular function within the file, which is often useful
+because the problem is always in a certain function:
+
+$ clang -cc1 -analyze -analyzer-checker=core test.c -analyzer-display-progress
+ANALYZE (Syntax): test.c foo
+ANALYZE (Syntax): test.c bar
+ANALYZE (Path,  Inline_Regular): test.c bar
+ANALYZE (Path,  Inline_Regular): test.c foo
+$ clang -cc1 -analyze -analyzer-checker=core test.c -analyzer-display-progress -analyze-function=foo
+ANALYZE (Syntax): test.c foo
+ANALYZE (Path,  Inline_Regular): test.c foo
+
+
+Visualizing the analysis
+
+To dump the AST, which often helps understanding how the program should
+behave:
+
+$ clang -cc1 -ast-dump test.c
+
+
+To view/dump CFG use debug.ViewCFG or debug.DumpCFG
+checkers:
+
+$ clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.c
+
+
+ExplodedGraph (the state graph explored by the analyzer) can be
+visualized with another debug checker:
+
+$ clang -cc1 -analyze -analyzer-checker=debug.ViewExplodedGraph test.c
+
+Or, equivalently, with -analyzer-viz-egraph-graphviz
+option, which does the same thing - dumps the exploded graph in graphviz
+.dot format.
+
+You can convert .dot files into other formats - in
+particular, converting to .svg and viewing in your web
+browser might be more comfortable than using 

r276891 - UsersManual.rst: update clang-cl option list

2016-07-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 27 11:56:03 2016
New Revision: 276891

URL: http://llvm.org/viewvc/llvm-project?rev=276891=rev
Log:
UsersManual.rst: update clang-cl option list

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=276891=276890=276891=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Jul 27 11:56:03 2016
@@ -2118,16 +2118,26 @@ Execute ``clang-cl /?`` to see a list of
   /fp:fast
   /fp:precise
   /fp:strict
+  /Fp  Set pch filename (with /Yc and /Yu)
   /GAAssume thread-local variables are defined in the 
executable
+  /GdSet __cdecl as a default calling convention
   /GF-   Disable string pooling
   /GR-   Disable emission of RTTI data
   /GREnable emission of RTTI data
+  /GrSet __fastcall as a default calling convention
+  /GS-   Disable buffer security check
+  /GSEnable buffer security check
   /Gs Set stack probe size
+  /GvSet __vectorcall as a default calling convention
   /Gw-   Don't put each data item in its own section
   /GwPut each data item in its own section
+  /GX-   Enable exception handling
+  /GXEnable exception handling
   /Gy-   Don't put each function in its own section
   /GyPut each function in its own section
+  /GzSet __stdcall as a default calling convention
   /help  Display available options
+  /imsvcAdd directory to system include search path, as 
if part of %INCLUDE%
   /IAdd directory to include search path
   /J Make char type unsigned
   /LDd   Create debug DLL
@@ -2137,7 +2147,6 @@ Execute ``clang-cl /?`` to see a list of
   /MDUse DLL run-time
   /MTd   Use static debug run-time
   /MTUse static run-time
-  /Ob0   Disable inlining
   /OdDisable optimization
   /Oi-   Disable use of builtin functions
   /OiEnable use of builtin functions
@@ -2149,6 +2158,7 @@ Execute ``clang-cl /?`` to see a list of
   /Qvec- Disable the loop vectorization passes
   /Qvec  Enable the loop vectorization passes
   /showIncludes  Print info about included files to stderr
+  /std:   Language standard to compile for
   /TCTreat all source files as C
   /Tc  Specify a C source file
   /TPTreat all source files as C++
@@ -2171,6 +2181,9 @@ Execute ``clang-cl /?`` to see a list of
   /WX-   Do not treat warnings as errors
   /WXTreat warnings as errors
   /w Disable all warnings
+  /Y-Disable precompiled headers, overrides /Yc and /Yu
+  /Yc  Generate a pch file for all code up to and 
including 
+  /Yu  Load a pch file and use it instead of all code up 
to and including 
   /Z7Enable CodeView debug information in object files
   /Zc:sizedDealloc-  Disable C++14 sized global deallocation functions
   /Zc:sizedDealloc   Enable C++14 sized global deallocation functions
@@ -2179,6 +2192,7 @@ Execute ``clang-cl /?`` to see a list of
   /Zc:threadSafeInit Enable thread-safe initialization of static 
variables
   /Zc:trigraphs- Disable trigraphs (default)
   /Zc:trigraphs  Enable trigraphs
+  /ZdEmit debug line number tables only
   /ZiAlias for /Z7. Does not produce PDBs.
   /ZlDon't mention any default libraries in the object 
file
   /ZpSet the default maximum struct packing alignment 
to 1
@@ -2215,6 +2229,8 @@ Execute ``clang-cl /?`` to see a list of
   -fsanitize=  Turn on runtime checks for various forms of 
undefined or suspicious
   behavior. See user manual for available checks
   -gcodeview  Generate CodeView debug information
+  -gline-tables-only  Emit debug line number tables only
+  -miamcu Use Intel MCU ABI
   -mllvm   Additional arguments to forward to LLVM's option 
processing
   -Qunused-arguments  Don't emit warning for unused driver arguments
   -R  Enable the specified remark



Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-27 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Misc/amdgcn.languageOptsOpenCL.cl:188
@@ +187,3 @@
+  #endif
+#else
+  #ifdef cl_khr_mipmap_image

Looks good! Could you just remove indentation please as it's not common for C 
macros?

The same for the test below!


Repository:
  rL LLVM

https://reviews.llvm.org/D22637



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


Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Artem Belevich via cfe-commits
tra added a comment.

Looks good.


https://reviews.llvm.org/D22518



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


r276889 - Fix unnecessary default switch warning

2016-07-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jul 27 11:41:56 2016
New Revision: 276889

URL: http://llvm.org/viewvc/llvm-project?rev=276889=rev
Log:
Fix unnecessary default switch warning

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

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=276889=276888=276889=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Jul 27 11:41:56 2016
@@ -445,8 +445,8 @@ bool PrintingCodeCompleteConsumer::isRes
   case CodeCompletionResult::RK_Pattern: {
 return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
   }
-  default: llvm_unreachable("Unknown code completion result Kind.");
   }
+  llvm_unreachable("Unknown code completion result Kind.");
 }
 
 void 


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


r276887 - Update cxx_dr_Status after 3.9 branch

2016-07-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 27 11:39:45 2016
New Revision: 276887

URL: http://llvm.org/viewvc/llvm-project?rev=276887=rev
Log:
Update cxx_dr_Status after 3.9 branch

Modified:
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=276887=276886=276887=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Jul 27 11:39:45 2016
@@ -7315,7 +7315,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1250;>1250
 CD3
 Cv-qualification of incomplete virtual function return types
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1251;>1251
@@ -9253,7 +9253,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1573;>1573
 DRWP
 Inherited constructor characteristics
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1574;>1574
@@ -9289,7 +9289,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579;>1579
 C++14
 Return by converting move constructor
-Unknown
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1580;>1580
@@ -9685,7 +9685,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1645;>1645
 DR
 Identical inheriting constructors via default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1646;>1646
@@ -10105,7 +10105,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1715;>1715
 DR
 Access and inherited constructor templates
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1716;>1716
@@ -10231,7 +10231,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1736;>1736
 DR
 Inheriting constructor templates in a local class
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1737;>1737
@@ -11461,7 +11461,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1941;>1941
 DR
 SFINAE and inherited constructor default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1942;>1942
@@ -11569,7 +11569,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1959;>1959
 DR
 Inadvertently inherited copy constructor
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1960;>1960
@@ -11761,7 +11761,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1991;>1991
 DR
 Inheriting constructors vs default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1992;>1992

Modified: cfe/trunk/www/make_cxx_dr_status
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/make_cxx_dr_status?rev=276887=276886=276887=diff
==
--- cfe/trunk/www/make_cxx_dr_status (original)
+++ cfe/trunk/www/make_cxx_dr_status Wed Jul 27 11:39:45 2016
@@ -102,10 +102,10 @@ def availability(issue):
   if status == 'unknown':
 avail = 'Unknown'
 avail_style = ' class="none"'
-  elif status == '3.9':
+  elif status == '4.0':
 avail = 'SVN'
 avail_style = ' class="svn"'
-  elif status.startswith('3.'):
+  elif re.match('^[0-9]+\.', status):
 avail = 'Clang %s' % status
 avail_style = ' class="full"'
   elif status == 'yes':


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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Ping.


https://reviews.llvm.org/D22596



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


[PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi created this revision.
ibadawi added reviewers: majnemer, rjmccall.
ibadawi added a subscriber: cfe-commits.

This is a proposed fix for bug 16154 
(https://llvm.org/bugs/show_bug.cgi?id=16154) -- it was tentatively fixed in 
r183084 but had the fix was backed out in r183575 because the approach taken 
wrongly affected the behavior or other warnings.

https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext , QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,10 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
+
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext , QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,10 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
+
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Jun Bum Lim via cfe-commits
junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: default label 
in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

  default: llvm_unreachable("Unknown code completion result Kind.");
  ^


Repository:
  rL LLVM

https://reviews.llvm.org/D17820



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a comment.

In https://reviews.llvm.org/D22857#497805, @ahatanak wrote:

> Is r276859 fixing a bug in the assembler?


Sort of. It was just adding a comment character to ; instead of #.

> I'm trying to understand why we have to add a clang test in this particular 
> case because I don't think we normally add a test in clang every time we fix 
> a bug in the backend or assembler.


As I read it, this is just making sure "inline asm" works on Windows, which 
apparently hasn't been working so far. In a way, unrelated to the commit in 
question.

I agree we shouldn't be adding clang tests to assembler bugs.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Akira Hatanaka via cfe-commits
ahatanak added a subscriber: ahatanak.
ahatanak added a comment.

Is r276859 fixing a bug in the assembler?

I'm trying to understand why we have to add a clang test in this particular 
case because I don't think we normally add a test in clang every time we fix a 
bug in the backend or assembler.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22690: [OpenMP] Add support for mapping array sections through pointer references.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65751.
sfantao marked an inline comment as done.
sfantao added a comment.

- Use castAs instead of getAs in pointer type.


https://reviews.llvm.org/D22690

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp

Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -60,12 +60,15 @@
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK2 --check-prefix CK2-32
 #ifdef CK2
 
-// CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
-// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i[[sz]]] zeroinitializer
+// Map types: OMP_MAP_IS_PTR = 32
+// CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i32] [i32 32]
 
-// CK2-LABEL: implicit_maps_integer_reference
-void implicit_maps_integer_reference (int a){
+// CK2-LABEL: implicit_maps_reference
+void implicit_maps_reference (int a, int *b){
   int  = a;
   // CK2-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}})
   // CK2-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
@@ -85,6 +88,25 @@
   {
++i;
   }
+
+  int * = b;
+  // CK2-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES2]]{{.+}}, {{.+}}[[TYPES2]]{{.+}})
+  // CK2-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
+  // CK2-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
+  // CK2-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK2-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK2-DAG: store i8* [[VALBP:%.+]], i8** [[BP1]],
+  // CK2-DAG: store i8* [[VALP:%.+]], i8** [[P1]],
+  // CK2-DAG: [[VALBP]] = bitcast i32* [[VAL:%.+]] to i8*
+  // CK2-DAG: [[VALP]] = bitcast i32* [[VAL]] to i8*
+  // CK2-DAG: [[VAL]] = load i32*, i32** [[ADDR:%.+]],
+  // CK2-DAG: [[ADDR]] = load i32**, i32*** [[ADDR2:%.+]],
+
+  // CK2: call void [[KERNEL2:@.+]](i32* [[VAL]])
+  #pragma omp target
+  {
+   ++p;
+  }
 }
 
 // CK2: define internal void [[KERNEL]](i[[sz]] [[ARG:%.+]])
@@ -99,6 +121,14 @@
 // CK2-32: [[RVAL:%.+]] = load i32*, i32** [[REF]],
 // CK2-32: {{.+}} = load i32, i32* [[RVAL]],
 
+// CK2: define internal void [[KERNEL2]](i32* [[ARG:%.+]])
+// CK2: [[ADDR:%.+]] = alloca i32*,
+// CK2: [[REF:%.+]] = alloca i32**,
+// CK2: store i32* [[ARG]], i32** [[ADDR]],
+// CK2: store i32** [[ADDR]], i32*** [[REF]],
+// CK2: [[T:%.+]] = load i32**, i32*** [[REF]],
+// CK2: [[TT:%.+]] = load i32*, i32** [[T]],
+// CK2: getelementptr inbounds i32, i32* [[TT]], i32 1
 #endif
 ///==///
 // RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-64
@@ -4471,4 +4501,67 @@
 // CK27: define {{.+}}[[CALL06]]
 // CK27: define {{.+}}[[CALL07]]
 #endif
+///==///
+// RUN: %clang_cc1 -DCK28 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK28 --check-prefix CK28-64
+// RUN: %clang_cc1 -DCK28 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-64
+// RUN: %clang_cc1 -DCK28 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-32
+// RUN: %clang_cc1 -DCK28 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-32
+#ifdef CK28
+
+// CK28: [[SIZE00:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] [i[[Z:64|32]] {{8|4}}]
+// CK28: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i32] 

Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

> I think it would be better for fully-qualified Objective-C methods to be 
> specified with their Objective-C-style names. For example: "-[Test1 
> myMethodWithY:withX:]".


Uhm, need to know more about those. So i just print "`-[`", then 
fully-qualified class name, then selector identifier, then "`]`"?

> Does this approach work for C++ when there are multiple overloads of methods 
> with the same name?


Nope, unfortunately not. I'm open to suggestions on how to make this work. We 
may either dump types of arguments, or do something like "`foo~1`", "`foo~2`", 
etc.


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

I think it would be better for fully-qualified Objective-C methods to be 
specified with their Objective-C-style names. For example:  "-[Test1 
myMethodWithY:withX:]". This would also remove the ambiguity when there are 
class and instance methods with the same selector.

Does this approach work for C++ when there are multiple overloads of methods 
with the same name?


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Art, Richard,

Thanks for looking at this patch. I tried to address Richard concerns in the 
last diff.

Let me know your thoughts,

Thanks again,
Samuel



Comment at: lib/Driver/Tools.cpp:308-335
@@ -349,1 +307,30 @@
+Action::OffloadKind ActiveOffloadingKind = Action::OFK_None) {
+  SmallVector RelevantToolChains;
+  // Add the current tool chain to the relevant tool chain list if it is
+  // defined.
+  if (RegularToolChain)
+RelevantToolChains.push_back(RegularToolChain);
+
+  // Add all the offloading tool chains associated with the current action to
+  // the relevant tool chain list. If we don't have a specific active offload
+  // kind, consider all available, otherwise consider only the active kind.
+  if (ActiveOffloadingKind == Action::OFK_None ||
+  ActiveOffloadingKind == Action::OFK_Cuda) {
+if (JA.isHostOffloading(Action::OFK_Cuda))
+  RelevantToolChains.push_back(
+  C.getSingleOffloadToolChain());
+else if (JA.isDeviceOffloading(Action::OFK_Cuda))
+  RelevantToolChains.push_back(
+  C.getSingleOffloadToolChain());
+  }
+
+  //
+  // TODO: Add support for other offloading programming models here.
+  //
+
+  // Apply Work on all the relevant tool chains.
+  for (const auto *TC : RelevantToolChains) {
+assert(TC && "Undefined tool chain??");
+Work(TC);
+  }
 }

rsmith wrote:
> There's no point in building a `SmallVector` here, just directly call `Work` 
> when you find a toolchain that should be used.
Ok, I'm doing as you suggest.


Comment at: lib/Driver/Tools.cpp:317-318
@@ +316,4 @@
+  // kind, consider all available, otherwise consider only the active kind.
+  if (ActiveOffloadingKind == Action::OFK_None ||
+  ActiveOffloadingKind == Action::OFK_Cuda) {
+if (JA.isHostOffloading(Action::OFK_Cuda))

rsmith wrote:
> What is this `ActiveOffloadingKind` parameter for? Both values that we 
> actually pass in here do the exact same thing.
`ActiveOffloadingKind` was meant to signal the offloading model in use. Its 
true right now we only have CUDA kind. We are proposing the OpenMP kind in 
https://reviews.llvm.org/D21843 (one of the depending patches of the patch that 
inserted this modification), so the goal was to pave the way for that.

In any case, I'm removing the `ActiveOffloadingKind` check, as I am calling 
`AddCudaIncludeArgs` directly in the caller of this function. Let me know if 
you'd like to fix this in a different way.


Comment at: lib/Driver/Tools.cpp:341-346
@@ -340,8 @@
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-

rsmith wrote:
> The OFK_Host / OFK_Cuda arguments here are reversed from the other two cases. 
> Is that a bug that's fixed by this change, or a bug that's introduced by this 
> change? :)
> 
> Either way it seems that we're missing test coverage.
As per the implementation before my change, `AddCudaIncludeArgs` should be 
called on the current toolchain. The outcome of using one toolchain or the 
other is similar except that for a CUDA toolchain there is an extra check. So, 
we'd always get the check if producing commands for both toolchains except if 
compiling with host/device-only mode. I fixed the issue here and added 
regression tests for host/device only . 


https://reviews.llvm.org/D22518



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


Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65747.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Remove of use of SmallVector and include CUDA args only for the regular 
toolchain.


https://reviews.llvm.org/D22518

Files:
  lib/Driver/Tools.cpp
  test/Driver/cuda-version-check.cu

Index: test/Driver/cuda-version-check.cu
===
--- test/Driver/cuda-version-check.cu
+++ test/Driver/cuda-version-check.cu
@@ -39,6 +39,15 @@
 // RUN:--no-cuda-version-check %s | \
 // RUN:FileCheck %s --check-prefix=OK
 
+// We need to make sure the version check is done only for the device toolchain,
+// therefore we should not get an error in host-only mode. We use the -S here
+// to avoid the error being produced in case by the assembler tool, which does
+// the same check.
+// RUN: %clang -v -### --cuda-gpu-arch=sm_60 --cuda-host-only --sysroot=%S/Inputs/CUDA -S 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=OK
+// RUN: %clang -v -### --cuda-gpu-arch=sm_60 --cuda-device-only --sysroot=%S/Inputs/CUDA -S 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=ERR_SM60
+
 // OK-NOT: error: GPU arch
 
 // OK_SM35-NOT: error: GPU arch sm_35
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -296,56 +296,25 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
-/// Add the C++ include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadCXXStdlibIncludeArgs(Compilation ,
-const JobAction ,
-const ArgList ,
-ArgStringList ) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the C include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadClangSystemIncludeArgs(Compilation ,
-  const JobAction ,
-  const ArgList ,
-  ArgStringList ) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the include args that are specific of each offloading programming model.
-static void addExtraOffloadSpecificIncludeArgs(Compilation ,
-   const JobAction ,
-   const ArgList ,
-   ArgStringList ) {
-
+/// Apply \a Work on the current tool chain \a RegularToolChain and any other
+/// offloading tool chain that is associated with the current action \a JA.
+static void
+forAllAssociatedToolChains(Compilation , const JobAction ,
+   const ToolChain ,
+   llvm::function_ref Work) {
+  // Apply Work on the current/regular tool chain.
+  Work(RegularToolChain);
+
+  // Apply Work on all the offloading tool chains associated with the current
+  // action.
   if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
 
-  // TODO: Add support for other programming models here.
+  //
+  // TODO: Add support for other offloading programming models here.
+  //
 }
 
 void Clang::AddPreprocessingOptions(Compilation , const JobAction ,
@@ -622,22 +591,26 @@
   // of an offloading programming model.
 
   // Add C++ include arguments, if needed.
-  if (types::isCXX(Inputs[0].getType())) {
-getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-addExtraOffloadCXXStdlibIncludeArgs(C, JA, Args, CmdArgs);
-  }
+  if (types::isCXX(Inputs[0].getType()))
+forAllAssociatedToolChains(C, JA, getToolChain(),
+   [, ](const ToolChain ) {
+ 

RE: r276361 - Reverting r275115 which caused PR28634.

2016-07-27 Thread Daniel Sanders via cfe-commits
Thanks for reverting this, our internal buildbots have gone green again.

> Can you add a non-regression test case?
> (It seems the test-suite didn’t catch this bug right?)

Do we have any upstream buildbots using -O0? I haven't investigated very far* 
but -O0 seems to be the common factor between our internal builders that 
failed. Also, adding -O1 to the failing command causes the compilation failure 
to disappear on MultiSource/Applications/JM/ldecod/loopFilter.c. I haven't 
tested the other failing tests yet but they were:
MultiSource/Applications/SPASS/SPASS
MultiSource/Benchmarks/Olden/bh/bh
MultiSource/Applications/viterbi/viterbi
MultiSource/Applications/sqlite3/sqlite3
MultiSource/Applications/JM/lencod/lencod
MultiSource/Applications/hbd/hbd
MultiSource/Benchmarks/MallocBench/gs/gs
MultiSource/Benchmarks/ASC_Sequoia/AMGmk/AMGmk
MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset

* We've had higher priority buildbot issues over the last couple weeks and I'm 
still tracking down a particularly unpleasant one where failing 'ninja 
check-all' somehow manages to kill all _future_ python processes as they're 
being created. I'm having to reboot the machine after each attempt at bisecting 
it.

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Mehdi Amini via cfe-commits
> Sent: 22 July 2016 01:31
> To: Wolfgang Pieb
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: r276361 - Reverting r275115 which caused PR28634.
> 
> 
> > On Jul 21, 2016, at 4:28 PM, Wolfgang Pieb via cfe-commits  comm...@lists.llvm.org> wrote:
> >
> > Author: wolfgangp
> > Date: Thu Jul 21 18:28:18 2016
> > New Revision: 276361
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276361=rev
> > Log:
> > Reverting r275115 which caused PR28634.
> > When empty (forwarding) basic blocks that are referenced by user labels
> > are removed, incorrect code may be generated.
> 
> Can you add a non-regression test case?
> (It seems the test-suite didn’t catch this bug right?)
> 
> Thanks,
> 
> —
> Mehdi
> 
> 
> >
> >
> > Removed:
> >cfe/trunk/test/CodeGen/forwarding-blocks-if.c
> > Modified:
> >cfe/trunk/lib/CodeGen/CGStmt.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
> > URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276361=276360=27
> 6361=diff
> >
> ==
> 
> > --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 18:28:18 2016
> > @@ -623,14 +623,7 @@ void CodeGenFunction::EmitIfStmt(const I
> > RunCleanupsScope ThenScope(*this);
> > EmitStmt(S.getThen());
> >   }
> > -  {
> > -auto CurBlock = Builder.GetInsertBlock();
> > -EmitBranch(ContBlock);
> > -// Eliminate any empty blocks that may have been created by nested
> > -// control flow statements in the 'then' clause.
> > -if (CurBlock)
> > -  SimplifyForwardingBlocks(CurBlock);
> > -  }
> > +  EmitBranch(ContBlock);
> >
> >   // Emit the 'else' code if present.
> >   if (const Stmt *Else = S.getElse()) {
> > @@ -646,12 +639,7 @@ void CodeGenFunction::EmitIfStmt(const I
> > {
> >   // There is no need to emit line number for an unconditional branch.
> >   auto NL = ApplyDebugLocation::CreateEmpty(*this);
> > -  auto CurBlock = Builder.GetInsertBlock();
> >   EmitBranch(ContBlock);
> > -  // Eliminate any empty blocks that may have been created by nested
> > -  // control flow statements emitted in the 'else' clause.
> > -  if (CurBlock)
> > -SimplifyForwardingBlocks(CurBlock);
> > }
> >   }
> >
> >
> > Removed: cfe/trunk/test/CodeGen/forwarding-blocks-if.c
> > URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/CodeGen/forwarding-blocks-
> if.c?rev=276360=auto
> >
> ==
> 
> > --- cfe/trunk/test/CodeGen/forwarding-blocks-if.c (original)
> > +++ cfe/trunk/test/CodeGen/forwarding-blocks-if.c (removed)
> > @@ -1,36 +0,0 @@
> > -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
> > -// Check that no empty blocks are generated for nested ifs.
> > -
> > -extern void func();
> > -
> > -int f0(int val) {
> > -  if (val == 0) {
> > -func();
> > -  } else if (val == 1) {
> > -func();
> > -  }
> > -  return 0;
> > -}
> > -
> > -// CHECK-LABEL: define {{.*}}i32 @f0
> > -// CHECK: call void {{.*}} @func
> > -// CHECK: call void {{.*}} @func
> > -// CHECK: br label %[[RETBLOCK1:[^ ]*]]
> > -// CHECK: [[RETBLOCK1]]:
> > -// CHECK-NOT: br label
> > -// CHECK: ret i32
> > -
> > -int f1(int val, int g) {
> > -  if (val == 0)
> > -if (g == 1) {
> > -  func();
> > -}
> > -  return 0;
> > -}
> > -
> > -// CHECK-LABEL: define {{.*}}i32 @f1
> > -// CHECK: call void {{.*}} @func
> > -// CHECK: br label %[[RETBLOCK2:[^ ]*]]
> 

Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r276878.


Repository:
  rL LLVM

https://reviews.llvm.org/D17820



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


r276878 - Implement filtering for code completion of identifiers.

2016-07-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Jul 27 09:56:59 2016
New Revision: 276878

URL: http://llvm.org/viewvc/llvm-project?rev=276878=rev
Log:
Implement filtering for code completion of identifiers.

Patch by Cristina Cristescu and Axel Naumann!

Agreed on post commit review (D17820).

Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/test/CodeCompletion/objc-message.mm
cfe/trunk/test/Index/complete-method-decls.m
cfe/trunk/test/Index/complete-objc-message-id.m
cfe/trunk/test/Index/complete-objc-message.m
cfe/trunk/test/Index/complete-recovery.m
cfe/trunk/test/Index/complete-super.m

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=276878=276877=276878=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 27 09:56:59 2016
@@ -265,6 +265,10 @@ class Preprocessor : public RefCountedBa
   /// \brief True if we hit the code-completion point.
   bool CodeCompletionReached;
 
+  /// \brief The code completion token containing the information
+  /// on the stem that is to be code completed.
+  IdentifierInfo *CodeCompletionII;
+
   /// \brief The directory that the main file should be considered to occupy,
   /// if it does not correspond to a real file (as happens when building a
   /// module).
@@ -984,6 +988,18 @@ public:
   /// completion point.
   void CodeCompleteNaturalLanguage();
 
+  /// \brief Set the code completion token for filtering purposes.
+  void setCodeCompletionIdentifierInfo(IdentifierInfo *Filter) {
+CodeCompletionII = Filter;
+  }
+
+  /// \brief Get the code completion token for filtering purposes.
+  StringRef getCodeCompletionFilter() {
+if (CodeCompletionII)
+  return CodeCompletionII->getName();
+return {};
+  }
+
   /// \brief Retrieve the preprocessing record, or NULL if there is no
   /// preprocessing record.
   PreprocessingRecord *getPreprocessingRecord() const { return Record; }

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=276878=276877=276878=diff
==
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Wed Jul 27 09:56:59 2016
@@ -913,6 +913,13 @@ public:
   /// \brief Deregisters and destroys this code-completion consumer.
   virtual ~CodeCompleteConsumer();
 
+  /// \name Code-completion filtering
+  /// \brief Check if the result should be filtered out.
+  virtual bool isResultFilteredOut(StringRef Filter,
+   CodeCompletionResult Results) {
+return false;
+  }
+
   /// \name Code-completion callbacks
   //@{
   /// \brief Process the finalized code-completion results.
@@ -966,6 +973,8 @@ public:
  OverloadCandidate *Candidates,
  unsigned NumCandidates) override;
 
+  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) 
override;
+
   CodeCompletionAllocator () override {
 return CCTUInfo.getAllocator();
   }

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=276878=276877=276878=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Jul 27 09:56:59 2016
@@ -1533,7 +1533,15 @@ FinishIdentifier:
 // preprocessor, which may macro expand it or something.
 if (II->isHandleIdentifierCase())
   return PP->HandleIdentifier(Result);
-
+
+if (II->getTokenID() == tok::identifier && isCodeCompletionPoint(CurPtr)
+&& II->getPPKeywordID() == tok::pp_not_keyword
+&& II->getObjCKeywordID() == tok::objc_not_keyword) {
+  // Return the code-completion token.
+  Result.setKind(tok::code_completion);
+  cutOffLexing();
+  return true;
+}
 return true;
   }
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=276878=276877=276878=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Jul 27 09:56:59 2016
@@ -74,7 +74,7 @@ Preprocessor::Preprocessor(IntrusiveRefC
   IncrementalProcessing(false), TUKind(TUKind), CodeComplete(nullptr),
   CodeCompletionFile(nullptr), CodeCompletionOffset(0),
   LastTokenWasAt(false), 

Re: [llvm-dev] [PATCH] Add support for the 'unless' matcher in the dynamic layer.

2016-07-27 Thread Piotr Padlewski via cfe-commits
Is, but it is still a lot of typing and we are talking about debuging.

2016-07-27 3:40 GMT-07:00 Manuel Klimek :

> On Wed, Jul 27, 2016 at 1:06 AM Piotr Padlewski via llvm-dev <
> llvm-...@lists.llvm.org> wrote:
>
>> We could also just add nothing() matcher, so debugging would be much
>> easier, just add anything() or nothing() matcher as extra argument.
>>
>> The other pros of it is that new developers won't send the patches that
>> uses those variadic matchers with only one argument.
>>
>
> We already have anything() and unless(anything()).
>
>
>>
>> 2016-07-26 16:02 GMT-07:00 Zac Hansen via llvm-dev <
>> llvm-...@lists.llvm.org>:
>>
>>> Even if it still did add overhead, it seems perfectly reasonable, from a
>>> user's perspective (namely mine), that if I introduce unnecessary narrowing
>>> matchers to my chain that there may be a performance penalty.
>>>
>>> The ability to do the following easily outweighs any performance issues
>>> for me:
>>>
>>>
>>> anyOf (
>>> /*hasName("..."), */
>>> hasName("...")
>>>
>>> )
>>>
>>> though C++ not allowing trailing commas makes this not quite as great.
>>>
>>>
>>> *However, without help, I would not be able to put forward a patch with
>>> anything more than simply removing the minimums.*
>>>
>>> Would this be acceptable or would someone be able to point me at what it
>>> would take to do it the "smart way" in less time than it would take them to
>>> make the change themselves?
>>>
>>> On Tue, Jul 26, 2016 at 3:29 PM, Samuel Benzaquen 
>>> wrote:
>>>
 One of the reasons we added the minimum was because these nodes added
 overhead to the matching that was not unnecessary when they only had a
 single node.
 On the current implementation we could actually get rid of the node
 completely for the one argument calls.
 I would be ok with removing the lower bound.


 On Tue, Jul 26, 2016 at 6:20 PM, Zac Hansen  wrote:

> I was wondering if there is any objection to removing the 2-element
> minimum on the eachOf, anyOf and allOf matchers.
>
> It is frustrating when playing with matchers to have to edit
> significant amounts of code to be able to temporarily go from 2 to 1
> matcher inside an any- or allOf matcher.
>
> And overall it feels very "un-set-theory"-like.
>
> The change was made here:
> https://github.com/llvm-mirror/clang/commit/674e54c167eab0be7a54bca7082c07d2f1d0c8cc
>
>
> Thank you and apologies if I sent this to the wrong lists/people.
>
> --Zac
>


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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin requested changes to this revision.
This revision now requires changes to proceed.


Comment at: test/CodeGen/arm-inline-asm-windows.c:2
@@ +1,3 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target armv7-windows -c -o - %s
+

Also, I just noticed, this outputs the binary to stdout. Maybe better 

-o /dev/null

or whatever is the practice on Windows that also work on Linux. :)


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a subscriber: compnerd.
rengolin added a comment.

I'll just echo @compnerd comments, since Phab didn't get it.

- Change the syntax to __asm__, to be more portable
- Add Microsoft asm block syntax

cheers,
--renato


https://reviews.llvm.org/D22857



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


  1   2   >