r313446 - Remove comment accidentally committed with D36642. NFC.

2017-09-15 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Sep 15 23:26:51 2017
New Revision: 313446

URL: http://llvm.org/viewvc/llvm-project?rev=313446&view=rev
Log:
Remove comment accidentally committed with D36642. NFC.

Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=313446&r1=313445&r2=313446&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Sep 15 23:26:51 2017
@@ -79,8 +79,7 @@ Preprocessor::AllocateVisibilityMacroDir
 }
 
 /// \brief Read and discard all tokens remaining on the current line until
-/// the tok::eod token is found. If the discarded tokens are in a skipped 
range,
-/// complete the range and pass it to the \c SourceRangeSkipped callback.
+/// the tok::eod token is found.
 void Preprocessor::DiscardUntilEndOfDirective() {
   Token Tmp;
   do {


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


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-15 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 115528.
vlad.tsyrklevich added a comment.

Address @eugenis' comments


https://reviews.llvm.org/D37925

Files:
  include/clang/Basic/SanitizerBlacklist.h
  include/clang/Basic/SanitizerSpecialCaseList.h
  lib/AST/Decl.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/SanitizerBlacklist.cpp
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/XRayLists.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/Inputs/sanitizer-special-case-list.sanitized.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized1.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized2.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
  test/CodeGen/sanitizer-special-case-list.c
  test/CodeGenCXX/cfi-blacklist.cpp

Index: test/CodeGenCXX/cfi-blacklist.cpp
===
--- test/CodeGenCXX/cfi-blacklist.cpp
+++ test/CodeGenCXX/cfi-blacklist.cpp
@@ -1,6 +1,18 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
-// RUN: echo "type:std::*" > %t.txt
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting cfi and cfi-vcall work correctly
+// RUN: echo "[cfi-vcall]" > %t.vcall.txt
+// RUN: echo "type:std::*" >> %t.vcall.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+//
+// RUN: echo "[cfi]" > %t.cfi.txt
+// RUN: echo "type:std::*" >> %t.cfi.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting non-vcall modes does not affect vcalls
+// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
+// RUN: echo "type:std::*" >> %t.other.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
 
 struct S1 {
   virtual void f();
Index: test/CodeGen/sanitizer-special-case-list.c
===
--- /dev/null
+++ test/CodeGen/sanitizer-special-case-list.c
@@ -0,0 +1,26 @@
+// Verify that blacklist sections correctly select sanitizers to apply blacklist entries to.
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized1.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized2.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized3.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized4.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.sanitized.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=SANITIZED
+
+unsigned i;
+
+// SANITIZED: @overflow
+// UNSANITIZED: @overflow
+unsigned overflow() {
+  // SANITIZED: call {{.*}}void @__ubsan
+  // UNSANITIZED-NOT: call {{.*}}void @__ubsan
+  return i * 37;
+}
+
+// SANITIZED: @cfi
+// UNSANITIZED: @cfi
+void cfi(void (*fp)()) {
+  // SANITIZED: llvm.type.test
+  // UNSANITIZED-NOT: llvm.type.test
+  fp();
+}
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
===
--- /dev/null
+++ test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
@@ -0,0 +1,4 @@
+[c*]
+fun:*cfi*
+[u*]
+fun:*overflow*
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
===
--- /dev/null
+++ test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
@@ -0,0 +1,4 @@
+[cfi-icall]
+fun:*cfi*
+[unsigned-integer-overflow]
+fun:*overflow*
I

[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-15 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added inline comments.



Comment at: include/clang/Basic/SanitizerSpecialCaseList.h:33
+
+  bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
+ StringRef Category = StringRef()) const;

eugenis wrote:
> Please add  a comment on the meaning of Mask. I assume it's any-of?
Correct, I'll add a comment regarding this.



Comment at: lib/CodeGen/CGDeclCXX.cpp:322
+  if (getLangOpts().Sanitize.hasOneOf(ASanMask))
+if (!isInSanitizerBlacklist(ASanMask, Fn, Loc))
   Fn->addFnAttr(llvm::Attribute::SanitizeAddress);

This use of ASanMask could also confound address & kernel-address as @eugenis 
pointed out.



Comment at: lib/CodeGen/CodeGenModule.cpp:1569
   const auto &SanitizerBL = getContext().getSanitizerBlacklist();
-  if (SanitizerBL.isBlacklistedGlobal(GV->getName(), Category))
+  if (SanitizerBL.isBlacklistedGlobal(ASanMask, GV->getName(), Category))
 return true;

eugenis wrote:
> would this blacklist [address] when compiling for kernel-address, and vice 
> versa?
Yes, it would. We should pass the actual sanitizer option mask ANDed with the 
ASanMask here. Thanks!


https://reviews.llvm.org/D37925



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


[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-15 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:442
+SmallString<256> Name = llvm::sys::path::relative_path(II.getFilename());
+SmallString<256> FullPath = llvm::sys::path::root_path(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");

Naming this FullPath seems inaccurate. It's not the full path, it's the root 
path (which is just the root_name + root_directory, but not any directory after 
that).

In any case, I don't see why all of this is necessary. Can't you just have:

SmallString<256> Name = II.getFilename();
llvm::sys::path::replace_extension(Name, "cubin");

const char *CubinF =
C.addTempFile(C.getArgs().MakeArgString(Name));



https://reviews.llvm.org/D37912



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


[PATCH] D37913: [OpenMP] Enable the existing nocudalib flag for OpenMP offloading toolchain.

2017-09-15 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Please add a test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D37913



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


r313430 - [WebAssembly] Restore __builtin_wasm_rethrow builtin

2017-09-15 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Fri Sep 15 18:07:43 2017
New Revision: 313430

URL: http://llvm.org/viewvc/llvm-project?rev=313430&view=rev
Log:
[WebAssembly] Restore __builtin_wasm_rethrow builtin

Summary:
Restore the `__builtin_wasm_rethrow` builtin deleted in D37931. On second
thought, it appears it can be used to implement `__cxa_rethrow`.

Reviewers: dschuff, sunfish

Reviewed By: dschuff

Subscribers: jfb, sbc100, jgravelle-google

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=313430&r1=313429&r2=313430&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Sep 15 18:07:43 
2017
@@ -23,5 +23,6 @@ BUILTIN(__builtin_wasm_grow_memory, "zz"
 
 // Exception handling builtins.
 BUILTIN(__builtin_wasm_throw, "vUiv*", "r")
+BUILTIN(__builtin_wasm_rethrow, "v", "r")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=313430&r1=313429&r2=313430&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 15 18:07:43 2017
@@ -9613,6 +9613,10 @@ Value *CodeGenFunction::EmitWebAssemblyB
 Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_throw);
 return Builder.CreateCall(Callee, {Tag, Obj});
   }
+  case WebAssembly::BI__builtin_wasm_rethrow: {
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow);
+return Builder.CreateCall(Callee);
+  }
 
   default:
 return nullptr;

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=313430&r1=313429&r2=313430&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Fri Sep 15 18:07:43 2017
@@ -20,3 +20,9 @@ void f3(unsigned int tag, void *obj) {
 // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 }
+
+void f4() {
+  return __builtin_wasm_rethrow();
+// WEBASSEMBLY32: call void @llvm.wasm.rethrow()
+// WEBASSEMBLY64: call void @llvm.wasm.rethrow()
+}


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


[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:477
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-  assert((LangOpts.ShortWChar ||
-  llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) 
==

MatzeB wrote:
> rnk wrote:
> > @MatzeB ptal
> Can you find a new place for this assert()? Please do not just remove it!
> 
> For the backstory: Unfortunately I had to duplicate the wchar decision logic 
> inside llvm (TargetLibraryInfoImpl::getTargetWCharSize() for cases where we 
> just have the target triple available but need to know the size of wchar_t 
> using library function. This means the logic in LLVM needs to be updated when 
> support for new platforms is added but for people adding platform support it 
> will not be obvious that they have the change LLVM/TargetLibraryInfo as well 
> unless an assert() point them to there being a mismatch.
Sure, I'll try to see if I can find a suitable place or adjustment of it.  
However, one thing to note is that the frontend does actually embed that into 
the IR metadata ("wchar_size"). 


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


r313425 - [docs] add Windows examples to ThinLTO.rst

2017-09-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Fri Sep 15 17:16:13 2017
New Revision: 313425

URL: http://llvm.org/viewvc/llvm-project?rev=313425&view=rev
Log:
[docs] add Windows examples to ThinLTO.rst

Reviewers: pcc, ruiu

Reviewed By: ruiu

Subscribers: mehdi_amini, eraman, cfe-commits

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

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=313425&r1=313424&r2=313425&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Fri Sep 15 17:16:13 2017
@@ -63,7 +63,7 @@ ThinLTO is currently supported for the f
 - **ld64**:
   Starting with `Xcode 8 `_.
 - **lld**:
-  Starting with r284050 (ELF only).
+  Starting with r284050 for ELF, r298942 for COFF.
 
 Usage
 =
@@ -78,6 +78,13 @@ To utilize ThinLTO, simply add the -flto
   % clang -flto=thin -O2 file1.c file2.c -c
   % clang -flto=thin -O2 file1.o file2.o -o a.out
 
+When using lld-link, the -flto option need only be added to the compile step:
+
+.. code-block:: console
+
+  % clang-cl -flto=thin -O2 -c file1.c file2.c
+  % lld-link /out:a.exe file1.obj file2.obj
+
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
 linker for the final native link.  As such, the usage model the same as
@@ -111,6 +118,8 @@ be reduced to ``N`` via:
   ``-Wl,-mllvm,-threads=N``
 - lld:
   ``-Wl,--thinlto-jobs=N``
+- lld-link:
+  ``/opt:lldltojobs=N``
 
 Incremental
 ---
@@ -125,7 +134,7 @@ which currently must be enabled through
   ``-Wl,-cache_path_lto,/path/to/cache``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-dir=/path/to/cache``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocache:/path/to/cache``
 
 Cache Pruning
@@ -138,7 +147,7 @@ policy string. The cache policy must be
 
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocachepolicy:POLICY``
 
 A policy string is a series of key-value pairs separated by ``:`` characters.
@@ -187,13 +196,20 @@ To bootstrap clang/LLVM with ThinLTO, fo
when configuring the bootstrap compiler build:
 
   * ``-DLLVM_ENABLE_LTO=Thin``
-  * ``-DLLVM_PARALLEL_LINK_JOBS=1``
-(since the ThinLTO link invokes parallel backend jobs)
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
   * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
+  Or, on Windows:
+
+  * ``-DLLVM_ENABLE_LTO=Thin``
+  * ``-DCMAKE_C_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_LINKER=/path/to/host/lld-link.exe``
+  * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib.exe``
+  * ``-DCMAKE_AR=/path/to/host/llvm-ar.exe``
+
 #. To use additional linker arguments for controlling the backend
parallelism_ or enabling incremental_ builds of the bootstrap compiler,
after configuring the build, modify the resulting CMakeCache.txt file in the


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


[PATCH] D37943: [docs] add Windows examples to ThinLTO.rst

2017-09-15 Thread Bob Haarman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313425: [docs] add Windows examples to ThinLTO.rst (authored 
by inglorion).

Changed prior to commit:
  https://reviews.llvm.org/D37943?vs=115522&id=115524#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37943

Files:
  cfe/trunk/docs/ThinLTO.rst


Index: cfe/trunk/docs/ThinLTO.rst
===
--- cfe/trunk/docs/ThinLTO.rst
+++ cfe/trunk/docs/ThinLTO.rst
@@ -63,7 +63,7 @@
 - **ld64**:
   Starting with `Xcode 8 `_.
 - **lld**:
-  Starting with r284050 (ELF only).
+  Starting with r284050 for ELF, r298942 for COFF.
 
 Usage
 =
@@ -78,6 +78,13 @@
   % clang -flto=thin -O2 file1.c file2.c -c
   % clang -flto=thin -O2 file1.o file2.o -o a.out
 
+When using lld-link, the -flto option need only be added to the compile step:
+
+.. code-block:: console
+
+  % clang-cl -flto=thin -O2 -c file1.c file2.c
+  % lld-link /out:a.exe file1.obj file2.obj
+
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
 linker for the final native link.  As such, the usage model the same as
@@ -111,6 +118,8 @@
   ``-Wl,-mllvm,-threads=N``
 - lld:
   ``-Wl,--thinlto-jobs=N``
+- lld-link:
+  ``/opt:lldltojobs=N``
 
 Incremental
 ---
@@ -125,7 +134,7 @@
   ``-Wl,-cache_path_lto,/path/to/cache``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-dir=/path/to/cache``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocache:/path/to/cache``
 
 Cache Pruning
@@ -138,7 +147,7 @@
 
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocachepolicy:POLICY``
 
 A policy string is a series of key-value pairs separated by ``:`` characters.
@@ -187,13 +196,20 @@
when configuring the bootstrap compiler build:
 
   * ``-DLLVM_ENABLE_LTO=Thin``
-  * ``-DLLVM_PARALLEL_LINK_JOBS=1``
-(since the ThinLTO link invokes parallel backend jobs)
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
   * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
+  Or, on Windows:
+
+  * ``-DLLVM_ENABLE_LTO=Thin``
+  * ``-DCMAKE_C_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_LINKER=/path/to/host/lld-link.exe``
+  * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib.exe``
+  * ``-DCMAKE_AR=/path/to/host/llvm-ar.exe``
+
 #. To use additional linker arguments for controlling the backend
parallelism_ or enabling incremental_ builds of the bootstrap compiler,
after configuring the build, modify the resulting CMakeCache.txt file in the


Index: cfe/trunk/docs/ThinLTO.rst
===
--- cfe/trunk/docs/ThinLTO.rst
+++ cfe/trunk/docs/ThinLTO.rst
@@ -63,7 +63,7 @@
 - **ld64**:
   Starting with `Xcode 8 `_.
 - **lld**:
-  Starting with r284050 (ELF only).
+  Starting with r284050 for ELF, r298942 for COFF.
 
 Usage
 =
@@ -78,6 +78,13 @@
   % clang -flto=thin -O2 file1.c file2.c -c
   % clang -flto=thin -O2 file1.o file2.o -o a.out
 
+When using lld-link, the -flto option need only be added to the compile step:
+
+.. code-block:: console
+
+  % clang-cl -flto=thin -O2 -c file1.c file2.c
+  % lld-link /out:a.exe file1.obj file2.obj
+
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
 linker for the final native link.  As such, the usage model the same as
@@ -111,6 +118,8 @@
   ``-Wl,-mllvm,-threads=N``
 - lld:
   ``-Wl,--thinlto-jobs=N``
+- lld-link:
+  ``/opt:lldltojobs=N``
 
 Incremental
 ---
@@ -125,7 +134,7 @@
   ``-Wl,-cache_path_lto,/path/to/cache``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-dir=/path/to/cache``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocache:/path/to/cache``
 
 Cache Pruning
@@ -138,7 +147,7 @@
 
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocachepolicy:POLICY``
 
 A policy string is a series of key-value pairs separated by ``:`` characters.
@@ -187,13 +196,20 @@
when configuring the bootstrap compiler build:
 
   * ``-DLLVM_ENABLE_LTO=Thin``
-  * ``-DLLVM_PARALLEL_LINK_JOBS=1``
-(since the ThinLTO link invokes parallel backend jobs)
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
   * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
+  Or, on Windows:
+
+  * ``-DLLVM_ENABLE_LTO=Thin``
+  * ``-DCMAKE_C_COMPILER=/path/to/host/clang-cl.exe``

[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:477
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-  assert((LangOpts.ShortWChar ||
-  llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) 
==

rnk wrote:
> @MatzeB ptal
Can you find a new place for this assert()? Please do not just remove it!

For the backstory: Unfortunately I had to duplicate the wchar decision logic 
inside llvm (TargetLibraryInfoImpl::getTargetWCharSize() for cases where we 
just have the target triple available but need to know the size of wchar_t 
using library function. This means the logic in LLVM needs to be updated when 
support for new platforms is added but for people adding platform support it 
will not be obvious that they have the change LLVM/TargetLibraryInfo as well 
unless an assert() point them to there being a mismatch.


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


[PATCH] D37943: [docs] add Windows examples to ThinLTO.rst

2017-09-15 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D37943



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


[PATCH] D37943: [docs] add Windows examples to ThinLTO.rst

2017-09-15 Thread Bob Haarman via Phabricator via cfe-commits
inglorion created this revision.
Herald added subscribers: eraman, mehdi_amini.

https://reviews.llvm.org/D37943

Files:
  clang/docs/ThinLTO.rst


Index: clang/docs/ThinLTO.rst
===
--- clang/docs/ThinLTO.rst
+++ clang/docs/ThinLTO.rst
@@ -63,7 +63,7 @@
 - **ld64**:
   Starting with `Xcode 8 `_.
 - **lld**:
-  Starting with r284050 (ELF only).
+  Starting with r284050 for ELF, r298942 for COFF.
 
 Usage
 =
@@ -78,6 +78,13 @@
   % clang -flto=thin -O2 file1.c file2.c -c
   % clang -flto=thin -O2 file1.o file2.o -o a.out
 
+When using lld-link, the -flto option need only be added to the compile step:
+
+.. code-block:: console
+
+  % clang-cl -flto=thin -O2 -c file1.c file2.c
+  % lld-link /out:a.exe file1.obj file2.obj
+
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
 linker for the final native link.  As such, the usage model the same as
@@ -111,6 +118,8 @@
   ``-Wl,-mllvm,-threads=N``
 - lld:
   ``-Wl,--thinlto-jobs=N``
+- lld-link:
+  ``/opt:lldltojobs=N``
 
 Incremental
 ---
@@ -125,7 +134,7 @@
   ``-Wl,-cache_path_lto,/path/to/cache``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-dir=/path/to/cache``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocache:/path/to/cache``
 
 Cache Pruning
@@ -138,7 +147,7 @@
 
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocachepolicy:POLICY``
 
 A policy string is a series of key-value pairs separated by ``:`` characters.
@@ -187,13 +196,20 @@
when configuring the bootstrap compiler build:
 
   * ``-DLLVM_ENABLE_LTO=Thin``
-  * ``-DLLVM_PARALLEL_LINK_JOBS=1``
-(since the ThinLTO link invokes parallel backend jobs)
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
   * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
+  Or, on Windows:
+
+  * ``-DLLVM_ENABLE_LTO=Thin``
+  * ``-DCMAKE_C_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_LINKER=/path/to/host/lld-link.exe``
+  * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib.exe``
+  * ``-DCMAKE_AR=/path/to/host/llvm-ar.exe``
+
 #. To use additional linker arguments for controlling the backend
parallelism_ or enabling incremental_ builds of the bootstrap compiler,
after configuring the build, modify the resulting CMakeCache.txt file in the


Index: clang/docs/ThinLTO.rst
===
--- clang/docs/ThinLTO.rst
+++ clang/docs/ThinLTO.rst
@@ -63,7 +63,7 @@
 - **ld64**:
   Starting with `Xcode 8 `_.
 - **lld**:
-  Starting with r284050 (ELF only).
+  Starting with r284050 for ELF, r298942 for COFF.
 
 Usage
 =
@@ -78,6 +78,13 @@
   % clang -flto=thin -O2 file1.c file2.c -c
   % clang -flto=thin -O2 file1.o file2.o -o a.out
 
+When using lld-link, the -flto option need only be added to the compile step:
+
+.. code-block:: console
+
+  % clang-cl -flto=thin -O2 -c file1.c file2.c
+  % lld-link /out:a.exe file1.obj file2.obj
+
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
 linker for the final native link.  As such, the usage model the same as
@@ -111,6 +118,8 @@
   ``-Wl,-mllvm,-threads=N``
 - lld:
   ``-Wl,--thinlto-jobs=N``
+- lld-link:
+  ``/opt:lldltojobs=N``
 
 Incremental
 ---
@@ -125,7 +134,7 @@
   ``-Wl,-cache_path_lto,/path/to/cache``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-dir=/path/to/cache``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocache:/path/to/cache``
 
 Cache Pruning
@@ -138,7 +147,7 @@
 
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocachepolicy:POLICY``
 
 A policy string is a series of key-value pairs separated by ``:`` characters.
@@ -187,13 +196,20 @@
when configuring the bootstrap compiler build:
 
   * ``-DLLVM_ENABLE_LTO=Thin``
-  * ``-DLLVM_PARALLEL_LINK_JOBS=1``
-(since the ThinLTO link invokes parallel backend jobs)
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
   * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
+  Or, on Windows:
+
+  * ``-DLLVM_ENABLE_LTO=Thin``
+  * ``-DCMAKE_C_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_LINKER=/path/to/host/lld-link.exe``
+  * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib.exe``
+  * ``-DCMAKE_AR=/path/to/host/llvm-ar.exe``
+
 #. To use addi

[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-15 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: include/clang/Basic/SanitizerSpecialCaseList.h:33
+
+  bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
+ StringRef Category = StringRef()) const;

Please add  a comment on the meaning of Mask. I assume it's any-of?



Comment at: lib/CodeGen/CodeGenModule.cpp:1569
   const auto &SanitizerBL = getContext().getSanitizerBlacklist();
-  if (SanitizerBL.isBlacklistedGlobal(GV->getName(), Category))
+  if (SanitizerBL.isBlacklistedGlobal(ASanMask, GV->getName(), Category))
 return true;

would this blacklist [address] when compiling for kernel-address, and vice 
versa?



Comment at: test/CodeGen/sanitizer-special-case-list.c:4
+// RUN: echo "fun:*cfi*" > %t.unsanitized1
+// RUN: echo "fun:*overflow*" >> %t.unsanitized1
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall 
-fsanitize-blacklist=%t.unsanitized1 -emit-llvm %s -o - | FileCheck %s 
--check-prefix=UNSANITIZED

it is common to add such files as actual files under Inputs/


https://reviews.llvm.org/D37925



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


[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc

2017-09-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D37042



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


[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Frontend/PrintPreprocessedOutput.cpp:566
+  MoveToLine(Loc);
+  OS << "#pragma " << "clang assume_nonnull end";
+  setEmittedDirectiveOnThisLine();

Extra "<<"?



Comment at: test/Preprocessor/pragma_assume_nonnull.c:29
+   return bar(0) + foo(0); // expected-warning {{null passed to a callee that 
requires a non-null argument}}
+#endif
+}

This testcase is a little more complicated than it needs to be (the 
"#if"/"#ifndef" doesn't really add anything).


https://reviews.llvm.org/D37861



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


[PATCH] D32051: [Preprocessor] Improve MSVC comma-elision before an empty expansion.

2017-09-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

This has likely gone stale, and my employer has decided to tell customers to 
modify their code.


https://reviews.llvm.org/D32051



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


[PATCH] D37892: [X86] Use native shuffle vector for the perm2f128 intrinsics

2017-09-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313418: [X86] Use native shuffle vector for the perm2f128 
intrinsics (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D37892?vs=115427&id=115518#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37892

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/avx-builtins.c
  cfe/trunk/test/CodeGen/avx2-builtins.c


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -7923,6 +7923,45 @@
 return EmitX86Select(*this, Ops[4], Align, Ops[3]);
   }
 
+  case X86::BI__builtin_ia32_vperm2f128_pd256:
+  case X86::BI__builtin_ia32_vperm2f128_ps256:
+  case X86::BI__builtin_ia32_vperm2f128_si256:
+  case X86::BI__builtin_ia32_permti256: {
+unsigned Imm = cast(Ops[2])->getZExtValue();
+unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
+
+// This takes a very simple approach since there are two lanes and a
+// shuffle can have 2 inputs. So we reserve the first input for the first
+// lane and the second input for the second lane. This may result in
+// duplicate sources, but this can be dealt with in the backend.
+
+Value *OutOps[2];
+uint32_t Indices[8];
+for (unsigned l = 0; l != 2; ++l) {
+  // Determine the source for this lane.
+  if (Imm & (1 << ((l * 4) + 3)))
+OutOps[l] = llvm::ConstantAggregateZero::get(Ops[0]->getType());
+  else if (Imm & (1 << ((l * 4) + 1)))
+OutOps[l] = Ops[1];
+  else
+OutOps[l] = Ops[0];
+
+  for (unsigned i = 0; i != NumElts/2; ++i) {
+// Start with ith element of the source for this lane.
+unsigned Idx = (l * NumElts) + i;
+// If bit 0 of the immediate half is set, switch to the high half of
+// the source.
+if (Imm & (1 << (l * 4)))
+  Idx += NumElts/2;
+Indices[(l * (NumElts/2)) + i] = Idx;
+  }
+}
+
+return Builder.CreateShuffleVector(OutOps[0], OutOps[1],
+   makeArrayRef(Indices, NumElts),
+   "vperm");
+  }
+
   case X86::BI__builtin_ia32_movnti:
   case X86::BI__builtin_ia32_movnti64:
   case X86::BI__builtin_ia32_movntsd:
Index: cfe/trunk/test/CodeGen/avx-builtins.c
===
--- cfe/trunk/test/CodeGen/avx-builtins.c
+++ cfe/trunk/test/CodeGen/avx-builtins.c
@@ -678,19 +678,19 @@
 
 __m256d test_mm256_permute2f128_pd(__m256d A, __m256d B) {
   // CHECK-LABEL: test_mm256_permute2f128_pd
-  // CHECK: call <4 x double> @llvm.x86.avx.vperm2f128.pd.256(<4 x double> 
%{{.*}}, <4 x double> %{{.*}}, i8 49)
+  // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x 
i32> 
   return _mm256_permute2f128_pd(A, B, 0x31);
 }
 
 __m256 test_mm256_permute2f128_ps(__m256 A, __m256 B) {
   // CHECK-LABEL: test_mm256_permute2f128_ps
-  // CHECK: call <8 x float> @llvm.x86.avx.vperm2f128.ps.256(<8 x float> 
%{{.*}}, <8 x float> %{{.*}}, i8 19)
+  // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 

   return _mm256_permute2f128_ps(A, B, 0x13);
 }
 
 __m256i test_mm256_permute2f128_si256(__m256i A, __m256i B) {
   // CHECK-LABEL: test_mm256_permute2f128_si256
-  // CHECK: call <8 x i32> @llvm.x86.avx.vperm2f128.si.256(<8 x i32> %{{.*}}, 
<8 x i32> %{{.*}}, i8 32)
+  // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> 
   return _mm256_permute2f128_si256(A, B, 0x20);
 }
 
Index: cfe/trunk/test/CodeGen/avx2-builtins.c
===
--- cfe/trunk/test/CodeGen/avx2-builtins.c
+++ cfe/trunk/test/CodeGen/avx2-builtins.c
@@ -907,8 +907,8 @@
 
 __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_permute2x128_si256
-  // CHECK: call <4 x i64> @llvm.x86.avx2.vperm2i128(<4 x i64> %{{.*}}, <4 x 
i64> %{{.*}}, i8 49)
-  return _mm256_permute2x128_si256(a, b, 0x31);
+  // CHECK: shufflevector <4 x i64> zeroinitializer, <4 x i64> %{{.*}}, <4 x 
i32> 
+  return _mm256_permute2x128_si256(a, b, 0x38);
 }
 
 __m256i test_mm256_permute4x64_epi64(__m256i a) {


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -7923,6 +7923,45 @@
 return EmitX86Select(*this, Ops[4], Align, Ops[3]);
   }
 
+  case X86::BI__builtin_ia32_vperm2f128_pd256:
+  case X86::BI__builtin_ia32_vperm2f128_ps256:
+  case X86::BI__builtin_ia32_vperm2f128_si256:
+  case X86::BI__builtin_ia32_permti256: {
+unsigned Imm = cast(Ops[2])->getZExtValue();
+unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
+
+// This takes a very simple approach since there are two lanes a

r313418 - [X86] Use native shuffle vector for the perm2f128 intrinsics

2017-09-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Sep 15 16:00:59 2017
New Revision: 313418

URL: http://llvm.org/viewvc/llvm-project?rev=313418&view=rev
Log:
[X86] Use native shuffle vector for the perm2f128 intrinsics

This patch replaces the perm2f128 intrinsics with native shuffle vectors.

This uses a pretty simple approach to allocate source 0 to the lower half input 
and source 1 to the upper half input. Then its just a matter of filling in the 
indices to use either the lower or upper half of that specific source. This can 
result in the same source being used by both operands. InstCombine or 
SelectionDAGBuilder should be able to clean that up.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx2-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=313418&r1=313417&r2=313418&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 15 16:00:59 2017
@@ -7923,6 +7923,45 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 return EmitX86Select(*this, Ops[4], Align, Ops[3]);
   }
 
+  case X86::BI__builtin_ia32_vperm2f128_pd256:
+  case X86::BI__builtin_ia32_vperm2f128_ps256:
+  case X86::BI__builtin_ia32_vperm2f128_si256:
+  case X86::BI__builtin_ia32_permti256: {
+unsigned Imm = cast(Ops[2])->getZExtValue();
+unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
+
+// This takes a very simple approach since there are two lanes and a
+// shuffle can have 2 inputs. So we reserve the first input for the first
+// lane and the second input for the second lane. This may result in
+// duplicate sources, but this can be dealt with in the backend.
+
+Value *OutOps[2];
+uint32_t Indices[8];
+for (unsigned l = 0; l != 2; ++l) {
+  // Determine the source for this lane.
+  if (Imm & (1 << ((l * 4) + 3)))
+OutOps[l] = llvm::ConstantAggregateZero::get(Ops[0]->getType());
+  else if (Imm & (1 << ((l * 4) + 1)))
+OutOps[l] = Ops[1];
+  else
+OutOps[l] = Ops[0];
+
+  for (unsigned i = 0; i != NumElts/2; ++i) {
+// Start with ith element of the source for this lane.
+unsigned Idx = (l * NumElts) + i;
+// If bit 0 of the immediate half is set, switch to the high half of
+// the source.
+if (Imm & (1 << (l * 4)))
+  Idx += NumElts/2;
+Indices[(l * (NumElts/2)) + i] = Idx;
+  }
+}
+
+return Builder.CreateShuffleVector(OutOps[0], OutOps[1],
+   makeArrayRef(Indices, NumElts),
+   "vperm");
+  }
+
   case X86::BI__builtin_ia32_movnti:
   case X86::BI__builtin_ia32_movnti64:
   case X86::BI__builtin_ia32_movntsd:

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=313418&r1=313417&r2=313418&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Fri Sep 15 16:00:59 2017
@@ -678,19 +678,19 @@ __m256 test_mm256_permute_ps(__m256 A) {
 
 __m256d test_mm256_permute2f128_pd(__m256d A, __m256d B) {
   // CHECK-LABEL: test_mm256_permute2f128_pd
-  // CHECK: call <4 x double> @llvm.x86.avx.vperm2f128.pd.256(<4 x double> 
%{{.*}}, <4 x double> %{{.*}}, i8 49)
+  // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x 
i32> 
   return _mm256_permute2f128_pd(A, B, 0x31);
 }
 
 __m256 test_mm256_permute2f128_ps(__m256 A, __m256 B) {
   // CHECK-LABEL: test_mm256_permute2f128_ps
-  // CHECK: call <8 x float> @llvm.x86.avx.vperm2f128.ps.256(<8 x float> 
%{{.*}}, <8 x float> %{{.*}}, i8 19)
+  // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 

   return _mm256_permute2f128_ps(A, B, 0x13);
 }
 
 __m256i test_mm256_permute2f128_si256(__m256i A, __m256i B) {
   // CHECK-LABEL: test_mm256_permute2f128_si256
-  // CHECK: call <8 x i32> @llvm.x86.avx.vperm2f128.si.256(<8 x i32> %{{.*}}, 
<8 x i32> %{{.*}}, i8 32)
+  // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> 
   return _mm256_permute2f128_si256(A, B, 0x20);
 }
 

Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=313418&r1=313417&r2=313418&view=diff
==
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Fri Sep 15 16:00:59 2017
@@ -907,8 +907,8 @@ __m256i test_mm256_packs_epu32(__m256i a
 
 __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_

[PATCH] D37941: [X86] Move even more of our CPU to feature mapping switch to use fallthroughs

2017-09-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.

This arranges more of the Intel and AMD CPUs into fallthrough positions based 
on their features. We may be able to merge this new AMD set with the BTVER or 
BDVER sets but I didn't look that closely.


https://reviews.llvm.org/D37941

Files:
  lib/Basic/Targets/X86.cpp


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -140,23 +140,6 @@
 setFeatureEnabledImpl(Features, "sse2", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 break;
-  case CK_Yonah:
-  case CK_Prescott:
-  case CK_Nocona:
-setFeatureEnabledImpl(Features, "sse3", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "cx16", true);
-break;
-  case CK_Core2:
-setFeatureEnabledImpl(Features, "ssse3", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "cx16", true);
-break;
-  case CK_Penryn:
-setFeatureEnabledImpl(Features, "sse4.1", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "cx16", true);
-break;
   case CK_Cannonlake:
 setFeatureEnabledImpl(Features, "avx512ifma", true);
 setFeatureEnabledImpl(Features, "avx512vbmi", true);
@@ -207,6 +190,17 @@
 LLVM_FALLTHROUGH;
   case CK_Nehalem:
 setFeatureEnabledImpl(Features, "sse4.2", true);
+LLVM_FALLTHROUGH;
+  case CK_Penryn:
+setFeatureEnabledImpl(Features, "sse4.1", true);
+LLVM_FALLTHROUGH;
+  case CK_Core2:
+setFeatureEnabledImpl(Features, "ssse3", true);
+LLVM_FALLTHROUGH;
+  case CK_Yonah:
+  case CK_Prescott:
+  case CK_Nocona:
+setFeatureEnabledImpl(Features, "sse3", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
@@ -262,29 +256,24 @@
   case CK_C3:
 setFeatureEnabledImpl(Features, "3dnow", true);
 break;
-  case CK_Athlon:
-  case CK_Geode:
-setFeatureEnabledImpl(Features, "3dnowa", true);
-break;
-  case CK_AthlonXP:
-setFeatureEnabledImpl(Features, "sse", true);
-setFeatureEnabledImpl(Features, "3dnowa", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-break;
-  case CK_K8:
-setFeatureEnabledImpl(Features, "sse2", true);
-setFeatureEnabledImpl(Features, "3dnowa", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-break;
   case CK_AMDFAM10:
 setFeatureEnabledImpl(Features, "sse4a", true);
 setFeatureEnabledImpl(Features, "lzcnt", true);
 setFeatureEnabledImpl(Features, "popcnt", true);
 LLVM_FALLTHROUGH;
   case CK_K8SSE3:
 setFeatureEnabledImpl(Features, "sse3", true);
-setFeatureEnabledImpl(Features, "3dnowa", true);
+LLVM_FALLTHROUGH;
+  case CK_K8:
+setFeatureEnabledImpl(Features, "sse2", true);
+LLVM_FALLTHROUGH;
+  case CK_AthlonXP:
+setFeatureEnabledImpl(Features, "sse", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
+LLVM_FALLTHROUGH;
+  case CK_Athlon:
+  case CK_Geode:
+setFeatureEnabledImpl(Features, "3dnowa", true);
 break;
   case CK_BTVER2:
 setFeatureEnabledImpl(Features, "avx", true);


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -140,23 +140,6 @@
 setFeatureEnabledImpl(Features, "sse2", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 break;
-  case CK_Yonah:
-  case CK_Prescott:
-  case CK_Nocona:
-setFeatureEnabledImpl(Features, "sse3", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "cx16", true);
-break;
-  case CK_Core2:
-setFeatureEnabledImpl(Features, "ssse3", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "cx16", true);
-break;
-  case CK_Penryn:
-setFeatureEnabledImpl(Features, "sse4.1", true);
-setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "cx16", true);
-break;
   case CK_Cannonlake:
 setFeatureEnabledImpl(Features, "avx512ifma", true);
 setFeatureEnabledImpl(Features, "avx512vbmi", true);
@@ -207,6 +190,17 @@
 LLVM_FALLTHROUGH;
   case CK_Nehalem:
 setFeatureEnabledImpl(Features, "sse4.2", true);
+LLVM_FALLTHROUGH;
+  case CK_Penryn:
+setFeatureEnabledImpl(Features, "sse4.1", true);
+LLVM_FALLTHROUGH;
+  case CK_Core2:
+setFeatureEnabledImpl(Features, "ssse3", true);
+LLVM_FALLTHROUGH;
+  case CK_Yonah:
+  case CK_Prescott:
+  case CK_Nocona:
+setFeatureEnabledImpl(Features, "sse3", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
@@ -262,29 +256,24 @@
   case CK_C3:
 setFeatureEnabledImpl(Features, "3dnow", true);
 break;
-  case CK_Athlon:
-  case CK_Geode:
-setFeatur

[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I'm not particularly familiar with OpenMP internals. Could you elaborate on why 
libdevice would not be needed with -c for the OpenMP case?
Is that because it would only apply to the host compilation and that nothing 
will be compiled for the openmp targets?
Does openmp allow separate compilation for the target (i.e. something similar 
to what --cuda-device-only does?)




Comment at: test/Driver/openmp-offload-gpu.c:133
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s

I'd have separate runs -- one with -S and another one with -c.

That would cover openMP compilation changes. There should also be similar test 
to verify new behavior for CUDA compilation.


Repository:
  rL LLVM

https://reviews.llvm.org/D37914



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


[PATCH] D37938: [X86] Remove unnecessary extra encodings from the CPU name enum in clang

2017-09-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.

For a lot of older CPUs we have a 1:1 mapping between CPU name and enum name. 
But many of them are effectively aliases of each other and as a result are 
always repeated together at every usage

This patch removes most of the duplication. It also uses StringSwitch::Cases to 
make the many to one mapping in the StringSwitch more obvious.


https://reviews.llvm.org/D37938

Files:
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h

Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -126,7 +126,6 @@
 CK_PentiumPro,
 CK_Pentium2,
 CK_Pentium3,
-CK_Pentium3M,
 CK_PentiumM,
 CK_C3_2,
 
@@ -140,7 +139,6 @@
 /// Netburst microarchitecture based processors.
 //@{
 CK_Pentium4,
-CK_Pentium4M,
 CK_Prescott,
 CK_Nocona,
 //@}
@@ -221,22 +219,14 @@
 /// K7 architecture processors.
 //@{
 CK_Athlon,
-CK_AthlonThunderbird,
-CK_Athlon4,
 CK_AthlonXP,
-CK_AthlonMP,
 //@}
 
 /// \name K8
 /// K8 architecture processors.
 //@{
-CK_Athlon64,
-CK_Athlon64SSE3,
-CK_AthlonFX,
 CK_K8,
 CK_K8SSE3,
-CK_Opteron,
-CK_OpteronSSE3,
 CK_AMDFAM10,
 //@}
 
@@ -298,22 +288,17 @@
 case CK_PentiumPro:
 case CK_Pentium2:
 case CK_Pentium3:
-case CK_Pentium3M:
 case CK_PentiumM:
 case CK_Yonah:
 case CK_C3_2:
 case CK_Pentium4:
-case CK_Pentium4M:
 case CK_Lakemont:
 case CK_Prescott:
 case CK_K6:
 case CK_K6_2:
 case CK_K6_3:
 case CK_Athlon:
-case CK_AthlonThunderbird:
-case CK_Athlon4:
 case CK_AthlonXP:
-case CK_AthlonMP:
 case CK_Geode:
   // Only accept certain architectures when compiling in 32-bit mode.
   if (getTriple().getArch() != llvm::Triple::x86)
@@ -336,13 +321,8 @@
 case CK_SkylakeServer:
 case CK_Cannonlake:
 case CK_KNL:
-case CK_Athlon64:
-case CK_Athlon64SSE3:
-case CK_AthlonFX:
 case CK_K8:
 case CK_K8SSE3:
-case CK_Opteron:
-case CK_OpteronSSE3:
 case CK_AMDFAM10:
 case CK_BTVER1:
 case CK_BTVER2:
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -130,14 +130,12 @@
 setFeatureEnabledImpl(Features, "mmx", true);
 break;
   case CK_Pentium3:
-  case CK_Pentium3M:
   case CK_C3_2:
 setFeatureEnabledImpl(Features, "sse", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 break;
   case CK_PentiumM:
   case CK_Pentium4:
-  case CK_Pentium4M:
   case CK_x86_64:
 setFeatureEnabledImpl(Features, "sse2", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
@@ -265,21 +263,15 @@
 setFeatureEnabledImpl(Features, "3dnow", true);
 break;
   case CK_Athlon:
-  case CK_AthlonThunderbird:
   case CK_Geode:
 setFeatureEnabledImpl(Features, "3dnowa", true);
 break;
-  case CK_Athlon4:
   case CK_AthlonXP:
-  case CK_AthlonMP:
 setFeatureEnabledImpl(Features, "sse", true);
 setFeatureEnabledImpl(Features, "3dnowa", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 break;
   case CK_K8:
-  case CK_Opteron:
-  case CK_Athlon64:
-  case CK_AthlonFX:
 setFeatureEnabledImpl(Features, "sse2", true);
 setFeatureEnabledImpl(Features, "3dnowa", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
@@ -290,8 +282,6 @@
 setFeatureEnabledImpl(Features, "popcnt", true);
 LLVM_FALLTHROUGH;
   case CK_K8SSE3:
-  case CK_OpteronSSE3:
-  case CK_Athlon64SSE3:
 setFeatureEnabledImpl(Features, "sse3", true);
 setFeatureEnabledImpl(Features, "3dnowa", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
@@ -807,7 +797,6 @@
 defineCPUMacros(Builder, "pentium");
 break;
   case CK_Pentium3:
-  case CK_Pentium3M:
   case CK_PentiumM:
 Builder.defineMacro("__tune_pentium3__");
 LLVM_FALLTHROUGH;
@@ -827,7 +816,6 @@
 Builder.defineMacro("__pentiumpro__");
 break;
   case CK_Pentium4:
-  case CK_Pentium4M:
 defineCPUMacros(Builder, "pentium4");
 break;
   case CK_Yonah:
@@ -888,10 +876,7 @@
 defineCPUMacros(Builder, "k6");
 break;
   case CK_Athlon:
-  case CK_AthlonThunderbird:
-  case CK_Athlon4:
   case CK_AthlonXP:
-  case CK_AthlonMP:
 defineCPUMacros(Builder, "athlon");
 if (SSELevel != NoSSE) {
   Builder.defineMacro("__athlon_sse__");
@@ -901,11 +886,6 @@
   case CK_K8:
   case CK_K8SSE3:
   case CK_x86_64:
-  case CK_Opteron:
-  case CK_OpteronSSE3:
-  case CK_Athlon64:
-  case CK_Athlon64SSE3:
-  case CK_AthlonFX:
 defineCPUMacros(Builder, "k8");
 break;
   case CK_AMDFAM10:
@@ -1553,55 +1533,37 @@
   .Case("i686", CK_i686)
   .Case("pentiumpro", CK_PentiumPro)
   .Case("pentium2", CK_Pentium2)
-  .Case("pentium3", CK_Pentium3)
-  .Case("pentium3m"

[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 115510.
compnerd added a comment.

Try to clarify the logic for APCS ABI.


Repository:
  rL LLVM

https://reviews.llvm.org/D37891

Files:
  include/clang/Basic/DiagnosticFrontendKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/AVR.h
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/Basic/Targets/XCore.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CXX/conv/conv.prom/p2.cpp
  test/CodeGen/aarch64-type-sizes.c
  test/CodeGen/arm-metadata.c
  test/CodeGen/coff-aarch64-type-sizes.c
  test/CodeGen/ms-annotation.c
  test/CodeGen/pascal-wchar-string.c
  test/CodeGen/string-literal-short-wstring.c
  test/CodeGen/string-literal-unicode-conversion.c
  test/CodeGen/wchar-const.c
  test/CodeGen/wchar-size.c
  test/CodeGenCXX/mangle-ms-string-literals.cpp
  test/CodeGenCXX/ms_wide_predefined_expr.cpp
  test/Driver/clang_f_opts.c
  test/Driver/rewrite-legacy-objc.m
  test/Driver/rewrite-objc.m
  test/Driver/wchar_t.c
  test/Headers/wchar_limits.cpp
  test/Index/index-pch.cpp
  test/Lexer/wchar-signedness.c
  test/Lexer/wchar.c
  test/Preprocessor/init.c
  test/Preprocessor/pr19649-unsigned-wchar_t.c
  test/Preprocessor/stdint.c
  test/Preprocessor/wchar_t.c
  test/Preprocessor/woa-defaults.c
  test/Preprocessor/woa-wchar_t.c
  test/Sema/format-strings-ms.c
  test/Sema/wchar.c
  test/SemaCXX/no-wchar.cpp
  test/SemaCXX/short-wchar-sign.cpp

Index: test/SemaCXX/short-wchar-sign.cpp
===
--- test/SemaCXX/short-wchar-sign.cpp
+++ test/SemaCXX/short-wchar-sign.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fshort-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -verify %s
 // expected-no-diagnostics
 
Index: test/SemaCXX/no-wchar.cpp
===
--- test/SemaCXX/no-wchar.cpp
+++ test/SemaCXX/no-wchar.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify %s
-// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++98 %s
-// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fwchar-type=short -fno-signed-wchar -fno-wchar -verify %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fwchar-type=short -fno-signed-wchar -fno-wchar -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fwchar-type=short -fno-signed-wchar -fno-wchar -verify -std=c++11 %s
 wchar_t x; // expected-error {{unknown type name 'wchar_t'}}
 
 typedef unsigned short wchar_t;
Index: test/Sema/wchar.c
===
--- test/Sema/wchar.c
+++ test/Sema/wchar.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// RUN: %clang_cc1 %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR
+// RUN: %clang_cc1 %s -fsyntax-only -fwchar-type=short -fno-signed-wchar -verify -DSHORT_WCHAR
 
 typedef __WCHAR_TYPE__ wchar_t;
 
Index: test/Sema/format-strings-ms.c
===
--- test/Sema/format-strings-ms.c
+++ test/Sema/format-strings-ms.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -fwchar-type=short -fno-signed-wchar -triple=i386-pc-win32 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -fwchar-type=short -fno-signed-wchar -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
 
 int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
 int scanf(const char * restrict, ...) ;
Index: test/Preprocessor/woa-wchar_t.c
===
--- test/Preprocessor/woa-wchar_t.c
+++ test/Preprocessor/woa-wchar_t.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -dM -triple armv7-windows -E %s | FileCheck %s
-// RUN: %clang_cc1 -dM -fno-signed-char -triple armv7-windows -E %s | FileCheck %s
+// RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple armv7-windows -E %s | FileCheck %s
+// RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -fno-signed-char -triple armv7-windows -E %s | FileCheck %s
 
 // CHECK: #define __WCHAR_TYPE__ unsigned short
 
Index: test/Preprocessor/woa-defaults.c
=

[PATCH] D32049: [Preprocessor] Implement empty vs omitted __VA_ARGS__ string-expansion MSVC Extension

2017-09-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I don't know?  I don't have a really good way of repro'ing that.  Do you have 
any ability to grab me a preprocessed reproducer of that one?  Godbolt doesn't 
have Windows headers for this.


https://reviews.llvm.org/D32049



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


[PATCH] D32049: [Preprocessor] Implement empty vs omitted __VA_ARGS__ string-expansion MSVC Extension

2017-09-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Would this help with https://bugs.llvm.org/show_bug.cgi?id=32021 ?


https://reviews.llvm.org/D32049



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


[PATCH] D32050: [Preprocessor] Implement MSVC extension to expand arguments to ##

2017-09-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

This has likely gone stale, and my employer has decided to tell customers to 
modify their code.


https://reviews.llvm.org/D32050



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


[clang-tools-extra] r313407 - Resubmit "[lit] Force site configs to run before source-tree configs"

2017-09-15 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Fri Sep 15 15:10:46 2017
New Revision: 313407

URL: http://llvm.org/viewvc/llvm-project?rev=313407&view=rev
Log:
Resubmit "[lit] Force site configs to run before source-tree configs"

This is a resubmission of r313270.  It broke standalone builds of
compiler-rt because we were not correctly generating the llvm-lit
script in the standalone build directory.

The fixes incorporated here attempt to find llvm/utils/llvm-lit
from the source tree returned by llvm-config.  If present, it
will generate llvm-lit into the output directory.  Regardless,
the user can specify -DLLVM_EXTERNAL_LIT to point to a specific
lit.py on their file system.  This supports the use case of
someone installing lit via a package manager.  If it cannot find
a source tree, and -DLLVM_EXTERNAL_LIT is either unspecified or
invalid, then we print a warning that tests will not be able
to run.

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

Modified:
clang-tools-extra/trunk/test/Unit/lit.cfg
clang-tools-extra/trunk/test/lit.cfg

Modified: clang-tools-extra/trunk/test/Unit/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/Unit/lit.cfg?rev=313407&r1=313406&r2=313407&view=diff
==
--- clang-tools-extra/trunk/test/Unit/lit.cfg (original)
+++ clang-tools-extra/trunk/test/Unit/lit.cfg Fri Sep 15 15:10:46 2017
@@ -9,10 +9,9 @@ config.suffixes = [] # Seems not to matt
 
 # Test Source and Exec root dirs both point to the same directory where google
 # test binaries are built.
-extra_tools_obj_dir = getattr(config, 'extra_tools_obj_dir', None)
-if extra_tools_obj_dir is not None:
-  config.test_source_root = extra_tools_obj_dir
-  config.test_exec_root = config.test_source_root
+
+config.test_source_root = config.extra_tools_obj_dir
+config.test_exec_root = config.test_source_root
 
 # All GoogleTests are named to have 'Tests' as their suffix. The '.' option is
 # a special value for GoogleTest indicating that it should look through the
@@ -20,18 +19,6 @@ if extra_tools_obj_dir is not None:
 # ;-separated list of subdirectories).
 config.test_format = lit.formats.GoogleTest('.', 'Tests')
 
-# If the site-specific configuration wasn't loaded (e.g. the build system 
failed
-# to create it or the user is running a test file directly) try to come up with
-# sane config options.
-if config.test_exec_root is None:
-  # Look for a --param=extra_tools_unit_site_config option.
-  site_cfg = lit_config.params.get('extra_tools_unit_site_config', None)
-  if site_cfg and os.path.exists(site_cfg):
-  lit_config.load_config(config, site_cfg)
-  raise SystemExit
-
-  # FIXME: Support out-of-tree builds? See clang/test/Unit/lit.cfg if we care.
-
 shlibpath_var = ''
 if platform.system() == 'Linux':
 shlibpath_var = 'LD_LIBRARY_PATH'
@@ -41,17 +28,11 @@ elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
 # Point the dynamic loader at dynamic libraries in 'lib'.
-shlibdir = getattr(config, 'shlibdir', None)
-if not shlibdir:
-lit_config.fatal('No shlibdir set!')
-llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
-if not llvm_libs_dir:
-lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((shlibdir, llvm_libs_dir,
+shlibpath = os.path.pathsep.join((config.shlibdir, config.llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
 # Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(shlibdir):
-shlibpath = os.path.pathsep.join((shlibdir, shlibpath))
+if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
+shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
 
 config.environment[shlibpath_var] = shlibpath

Modified: clang-tools-extra/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=313407&r1=313406&r2=313407&view=diff
==
--- clang-tools-extra/trunk/test/lit.cfg (original)
+++ clang-tools-extra/trunk/test/lit.cfg Fri Sep 15 15:10:46 2017
@@ -54,9 +54,7 @@ config.excludes = ['Inputs']
 config.test_source_root = os.path.dirname(__file__)
 
 # test_exec_root: The root path where tests should be run.
-clang_tools_binary_dir = getattr(config, 'clang_tools_binary_dir', None)
-if clang_tools_binary_dir is not None:
-config.test_exec_root = os.path.join(clang_tools_binary_dir, 'test')
+config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
 
 # Clear some environment variables that might affect Clang.
 #
@@ -88,92 +86,19 @@ for name in possibly_dangerous_env_vars:
 del config.environment[name]
 
 # Tweak the PATH to include the tools dir and the scripts dir.
-if clang_tools_binary_dir is not None:
-clang_tools_dir = getattr(config, 'clang_tools_dir', None)
-if not clang_tools_dir:
-lit_config.fat

r313407 - Resubmit "[lit] Force site configs to run before source-tree configs"

2017-09-15 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Fri Sep 15 15:10:46 2017
New Revision: 313407

URL: http://llvm.org/viewvc/llvm-project?rev=313407&view=rev
Log:
Resubmit "[lit] Force site configs to run before source-tree configs"

This is a resubmission of r313270.  It broke standalone builds of
compiler-rt because we were not correctly generating the llvm-lit
script in the standalone build directory.

The fixes incorporated here attempt to find llvm/utils/llvm-lit
from the source tree returned by llvm-config.  If present, it
will generate llvm-lit into the output directory.  Regardless,
the user can specify -DLLVM_EXTERNAL_LIT to point to a specific
lit.py on their file system.  This supports the use case of
someone installing lit via a package manager.  If it cannot find
a source tree, and -DLLVM_EXTERNAL_LIT is either unspecified or
invalid, then we print a warning that tests will not be able
to run.

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

Modified:
cfe/trunk/runtime/CMakeLists.txt
cfe/trunk/test/Unit/lit.cfg
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=313407&r1=313406&r2=313407&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Fri Sep 15 15:10:46 2017
@@ -77,6 +77,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
${COMPILER_RT_PASSTHROUGH_VARIABLES}

Modified: cfe/trunk/test/Unit/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg?rev=313407&r1=313406&r2=313407&view=diff
==
--- cfe/trunk/test/Unit/lit.cfg (original)
+++ cfe/trunk/test/Unit/lit.cfg Fri Sep 15 15:10:46 2017
@@ -17,14 +17,11 @@ config.suffixes = []
 
 # test_source_root: The root path where tests are located.
 # test_exec_root: The root path where tests should be run.
-clang_obj_root = getattr(config, 'clang_obj_root', None)
-if clang_obj_root is not None:
-config.test_exec_root = os.path.join(clang_obj_root, 'unittests')
-config.test_source_root = config.test_exec_root
+config.test_exec_root = os.path.join(config.clang_obj_root, 'unittests')
+config.test_source_root = config.test_exec_root
 
 # testFormat: The test format to use to interpret tests.
-llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
-config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
+config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
 
 # Propagate the temp directory. Windows requires this because it uses \Windows\
 # if none of these are present.
@@ -38,55 +35,6 @@ for symbolizer in ['ASAN_SYMBOLIZER_PATH
 if symbolizer in os.environ:
 config.environment[symbolizer] = os.environ[symbolizer]
 
-###
-
-# Check that the object root is known.
-if config.test_exec_root is None:
-# Otherwise, we haven't loaded the site specific configuration (the user is
-# probably trying to run on a test file directly, and either the site
-# configuration hasn't been created by the build system, or we are in an
-# out-of-tree build situation).
-
-# Check for 'clang_unit_site_config' user parameter, and use that if 
available.
-site_cfg = lit_config.params.get('clang_unit_site_config', None)
-if site_cfg and os.path.exists(site_cfg):
-lit_config.load_config(config, site_cfg)
-raise SystemExit
-
-# Try to detect the situation where we are using an out-of-tree build by
-# looking for 'llvm-config'.
-#
-# FIXME: I debated (i.e., wrote and threw away) adding logic to
-# automagically generate the lit.site.cfg if we are in some kind of fresh
-# build situation. This means knowing how to invoke the build system
-# though, and I decided it was too much magic.
-
-llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
-if not llvm_config:
-lit_config.fatal('No site specific configuration available!')
-
-# Get the source and object roots.
-llvm_src_root = subprocess.check_output(['llvm-config', 
'--src-root']).strip()
-llvm_obj_root = subprocess.check_output(['llvm-config', 
'--obj-root']).strip()
-clang_src_root = os.path.join(llvm_src_root, "tools", "clang")
-clang_obj_root = os.path.join(llvm_obj_root, "tools", "clang")
-
-# Validate that we got a tree which points to here, using the standard
-# tools/clang layout.
-this_src_root = os.path.join(os.path.dirn

[PATCH] D32049: [Preprocessor] Implement empty vs omitted __VA_ARGS__ string-expansion MSVC Extension

2017-09-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

This has likely gone stale, and my employer has decided to tell customers to 
modify their code.


https://reviews.llvm.org/D32049



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


[PATCH] D32052: [Preprocessor] Dont omit comma after __VA_ARGS__ in MSVC mode if it is an argument to a macro function that takes only a single parameter.

2017-09-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

This has likely gone stale, and my employer has decided to tell customers to 
modify their code.


https://reviews.llvm.org/D32052



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


r313402 - Remove __builtin_wasm_rethrow builtin

2017-09-15 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Fri Sep 15 15:01:22 2017
New Revision: 313402

URL: http://llvm.org/viewvc/llvm-project?rev=313402&view=rev
Log:
Remove __builtin_wasm_rethrow builtin

Summary:
Remove `__builtin_wasm_rethrow` builtin. I thought it was required to implement
`__cxa_rethrow` function in libcxxabi, but it turned out it will be using
`__builtin_wasm_throw` instead.

Reviewers: dschuff, jgravelle-google

Reviewed By: jgravelle-google

Subscribers: jfb, sbc100, jgravelle-google

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=313402&r1=313401&r2=313402&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Sep 15 15:01:22 
2017
@@ -23,6 +23,5 @@ BUILTIN(__builtin_wasm_grow_memory, "zz"
 
 // Exception handling builtins.
 BUILTIN(__builtin_wasm_throw, "vUiv*", "r")
-BUILTIN(__builtin_wasm_rethrow, "v", "r")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=313402&r1=313401&r2=313402&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 15 15:01:22 2017
@@ -9574,10 +9574,6 @@ Value *CodeGenFunction::EmitWebAssemblyB
 Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_throw);
 return Builder.CreateCall(Callee, {Tag, Obj});
   }
-  case WebAssembly::BI__builtin_wasm_rethrow: {
-Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow);
-return Builder.CreateCall(Callee);
-  }
 
   default:
 return nullptr;

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=313402&r1=313401&r2=313402&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Fri Sep 15 15:01:22 2017
@@ -20,9 +20,3 @@ void f3(unsigned int tag, void *obj) {
 // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 }
-
-void f4() {
-  return __builtin_wasm_rethrow();
-// WEBASSEMBLY32: call void @llvm.wasm.rethrow()
-// WEBASSEMBLY64: call void @llvm.wasm.rethrow()
-}


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


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-15 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 115509.
vlad.tsyrklevich added a comment.

Run clang-format.


https://reviews.llvm.org/D37925

Files:
  include/clang/Basic/SanitizerBlacklist.h
  include/clang/Basic/SanitizerSpecialCaseList.h
  lib/AST/Decl.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/SanitizerBlacklist.cpp
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/XRayLists.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/sanitizer-special-case-list.c
  test/CodeGenCXX/cfi-blacklist.cpp

Index: test/CodeGenCXX/cfi-blacklist.cpp
===
--- test/CodeGenCXX/cfi-blacklist.cpp
+++ test/CodeGenCXX/cfi-blacklist.cpp
@@ -1,6 +1,18 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
-// RUN: echo "type:std::*" > %t.txt
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting cfi and cfi-vcall work correctly
+// RUN: echo "[cfi-vcall]" > %t.vcall.txt
+// RUN: echo "type:std::*" >> %t.vcall.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+//
+// RUN: echo "[cfi]" > %t.cfi.txt
+// RUN: echo "type:std::*" >> %t.cfi.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting non-vcall modes does not affect vcalls
+// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
+// RUN: echo "type:std::*" >> %t.other.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
 
 struct S1 {
   virtual void f();
Index: test/CodeGen/sanitizer-special-case-list.c
===
--- /dev/null
+++ test/CodeGen/sanitizer-special-case-list.c
@@ -0,0 +1,47 @@
+// Verify that blacklist sections correctly select sanitizers to apply blacklist entries to.
+//
+// RUN: echo "fun:*cfi*" > %t.unsanitized1
+// RUN: echo "fun:*overflow*" >> %t.unsanitized1
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized1 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[cfi]" > %t.unsanitized2
+// RUN: echo "fun:*cfi*" >> %t.unsanitized2
+// RUN: echo "[unsigned-integer-overflow]" >> %t.unsanitized2
+// RUN: echo "fun:*overflow*" >> %t.unsanitized2
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized2 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[cfi-icall]" > %t.unsanitized3
+// RUN: echo "fun:*cfi*" >> %t.unsanitized3
+// RUN: echo "[unsigned-integer-overflow]" >> %t.unsanitized3
+// RUN: echo "fun:*overflow*" >> %t.unsanitized3
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized3 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[c*]" > %t.unsanitized4
+// RUN: echo "fun:*cfi*" >> %t.unsanitized4
+// RUN: echo "[u*]" >> %t.unsanitized4
+// RUN: echo "fun:*overflow*" >> %t.unsanitized4
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized4 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[unsigned-integer-overflow]" > %t.sanitized
+// RUN: echo "fun:*cfi*" >> %t.sanitized
+// RUN: echo "[cfi]" >> %t.sanitized
+// RUN: echo "fun:*overflow*" >> %t.sanitized
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.sanitized -emit-llvm %s -o - | FileCheck %s --check-prefix=SANITIZED
+
+unsigned i;
+
+// SANITIZED: @overflow
+// UNSANITIZED: @overflow
+unsigned overflow() {
+  // SANITIZED: call {{.*}}void @__ubsan
+  // UNSANITIZED-NOT: call {{.*}}void @__ubsan
+  return i * 37;
+}
+
+// SANITIZED: @cfi
+// UNSANITIZED: @cfi
+void cfi(void (*fp)()) {
+  // SANITIZED: llvm.type.test
+  // UNSANITIZED-NOT: llvm.type.test
+  fp();
+}
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1106,7 +1106,8 @@
   /// annotations are emitted during finalization of the LLVM cod

[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115502.
gtbercea added a comment.

Fix diff.


Repository:
  rL LLVM

https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -125,3 +125,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib device is 
found when using -c -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,6 +502,11 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_c) &&
+DriverArgs.hasArg(options::OPT_S))
+  return;
+
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
 return;
   }


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -125,3 +125,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib device is found when using -c -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,6 +502,11 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_c) &&
+DriverArgs.hasArg(options::OPT_S))
+  return;
+
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37132: [clang-format] Add support for C++17 structured bindings.

2017-09-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Thanks for this change.
Could you take a look of https://reviews.llvm.org/D35743 too?

This outputs a space before and after "&" or "&&", like this

  "auto & [...",  "auto && [..."

Could we remove one of the space to a format like the following?

  "auto& [...",  "auto&& [..."


https://reviews.llvm.org/D37132



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


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115500.
gtbercea added a comment.

Add test.


https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -89,7 +89,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" 
"{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -99,7 +99,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
 
-// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" 
"{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -125,3 +125,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib device is 
found when using -c -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,9 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_c) &&
+DriverArgs.hasArg(options::OPT_S))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -89,7 +89,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -99,7 +99,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
 
-// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -125,3 +125,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib device is found when using -c -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,9 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_

[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115497.
gtbercea added a comment.

Fix tests.


https://reviews.llvm.org/D37912

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -89,7 +89,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" 
"{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -99,7 +99,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
 
-// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" 
"{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,11 +438,13 @@
 if (!II.isFilename())
   continue;
 
-SmallString<256> Name = llvm::sys::path::filename(II.getFilename());
+SmallString<256> Name = llvm::sys::path::relative_path(II.getFilename());
+SmallString<256> FullPath = llvm::sys::path::root_path(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");
+llvm::sys::path::append(FullPath, Name);
 
 const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+C.addTempFile(C.getArgs().MakeArgString(FullPath));
 
 CmdArgs.push_back(CubinF);
   }


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -89,7 +89,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -99,7 +99,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
 
-// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,11 +438,13 @@
 if (!II.isFilename())
   continue;
 
-SmallString<256> Name = llvm::sys::path::filename(II.getFilename());
+SmallString<256> Name = llvm::sys::path::relative_path(II.getFilename());
+SmallString<256> FullPath = llvm::sys::path::root_path(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");
+llvm::sys::path::append(FullPath, Name);
 
 const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+C.addTempFile(C.getArgs().MakeArgString(FullPath));
 
 CmdArgs.push_back(CubinF);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:2659
+
+  const bool IsAPCSABI =
+  IsARM && (IsGNUEnvironment || IsNetBSD ||

rnk wrote:
> This target detection logic is insanely complicated, and I'm not convinced 
> it's simpler than the Basic/Targets/ delegation strategy.
> 
> I can go either way on putting this info in the Driver or Basic, but this 
> code needs to be simpler. Surely a switch could help here?
I like the idea of the switch, I'll try to convert this.  In my defense, this 
was trying to be a translation of the original conditions in Basic.  Doesn't 
mean that I like this or don't want this to converted into something saner.

If we put this into Basic, we get back the 3-bits of information ({`char`, 
`short`, `int`} * {`signed`, `unsigned`}) into 1-bit :-p.  This was a pretty 
painful change, but I think that it does result in a simpler flow for the 
frontend.


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:62
+std::pair Process() const {
+  assert(C != Criteria::None && "invalid criteria");
+

JonasToth wrote:
> You acces `Critera` always scoped. I think you could declare `Criteria` to be 
> a `enum class`, not just a plain `enum`
Apparently it's not as simple as that...
Then i get:
```
1/8] Building CXX object 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/clangTidyReadabilityModule.dir/FunctionCognitiveComplexityCheck.cpp.o
FAILED: 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/clangTidyReadabilityModule.dir/FunctionCognitiveComplexityCheck.cpp.o
 
/usr/local/bin/clang++  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Itools/clang/tools/extra/clang-tidy/readability 
-I/build/clang-tools-extra/clang-tidy/readability -I/build/clang/include 
-Itools/clang/include -I/usr/include/libxml2 -Iinclude -I/build/llvm/include 
-fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fcolor-diagnostics 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG-fno-exceptions -fno-rtti -MD -MT 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/clangTidyReadabilityModule.dir/FunctionCognitiveComplexityCheck.cpp.o
 -MF 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/clangTidyReadabilityModule.dir/FunctionCognitiveComplexityCheck.cpp.o.d
 -o 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/clangTidyReadabilityModule.dir/FunctionCognitiveComplexityCheck.cpp.o
 -c 
/build/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
/build/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:100:44:
 error: invalid operands to binary expression 
('clang::tidy::readability::(anonymous 
namespace)::CognitiveComplexity::Criteria' and 
'clang::tidy::readability::(anonymous 
namespace)::CognitiveComplexity::Criteria')
  } else if (C == (Criteria::Increment | Criteria::IncrementNesting)) {
   ~~~ ^ ~~
/build/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:536:9:
 error: value of type 'CognitiveComplexity::Criteria' is not contextually 
convertible to 'bool'
if (Reasons & CognitiveComplexity::Criteria::All)
^~~~
2 errors generated.
ninja: build stopped: subcommand failed.

```

The first failure i could have explained as use-before-declaration. But not the 
second one
I'll keep it as is where it is for now.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:102-114
+const std::array CognitiveComplexity::Msgs = {{
+// B1 + B2 + B3
+"+%0, including nesting penalty of %1, nesting level increased to %2",
+
+// B1 + B2
+"+%0, nesting level increased to %2",
+

JonasToth wrote:
> could this initialization land in line 45? that would be directly close to 
> the criteria. 
It would be nice indeed, but if i do
```
  // All the possible messages that can be outputed. The choice of the message
  // to use is based of the combination of the Criterias
  static constexpr std::array Msgs = {{
  // B1 + B2 + B3
  "+%0, including nesting penalty of %1, nesting level increased to %2",

  // B1 + B2
  "+%0, nesting level increased to %2",

  // B1
  "+%0",

  // B2
  "nesting level increased to %2",
  }};
```
i get
```
$ ninja check-clang-tools -j1 
[1/5] Linking CXX executable bin/clang-tidy
FAILED: bin/clang-tidy 
: && /usr/local/bin/clang++  -fPIC -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fcolor-diagnostics 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG  -Wl,-allow-shlib-undefined-Wl,-O3 
-Wl,--gc-sections 
tools/clang/tools/extra/clang-tidy/tool/CMakeFiles/clang-tidy.dir/ClangTidyMain.cpp.o
  -o bin/clang-tidy  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a 
-lpthread lib/libclangAST.a lib/libclangASTMatchers.a lib/libclangBasic.a 
lib/libclangTidy.a lib/libclangTidyAndroidModule.a 
lib/libclangTidyBoostModule.a lib/libclangTidyBugproneModule.a 
lib/libclangTidyCERTModule.a lib/libclangTidyCppCoreGuidelinesModule.a 
lib/libclangTidyGoogleModule.a lib/libclangTidyHICPPModule.a 
lib/libclangTi

[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 115482.
lebedev.ri marked 13 inline comments as done.
lebedev.ri added a comment.

Address most of the @JonasToth's review notes.


Repository:
  rL LLVM

https://reviews.llvm.org/D36836

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  test/clang-tidy/readability-function-cognitive-complexity.cpp

Index: test/clang-tidy/readability-function-cognitive-complexity.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-function-cognitive-complexity.cpp
@@ -0,0 +1,839 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- -config='{CheckOptions: [{key: readability-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11
+
+// any function should be checked.
+
+extern int ext_func(int x = 0);
+
+int some_func(int x = 0);
+
+static int some_other_func(int x = 0) {}
+
+template void some_templ_func(T x = 0) {}
+
+class SomeClass {
+public:
+  int *begin(int x = 0);
+  int *end(int x = 0);
+  static int func(int x = 0);
+  template void some_templ_func(T x = 0) {}
+};
+
+// nothing ever decreases cognitive complexity, so we can check all the things
+// in one go. none of the following should increase cognitive complexity:
+void unittest_false() {
+  {};
+  ext_func();
+  some_func();
+  some_other_func();
+  some_templ_func();
+  some_templ_func();
+  SomeClass::func();
+  SomeClass C;
+  C.some_templ_func();
+  C.some_templ_func();
+  C.func();
+  C.end();
+  int i = some_func();
+  i = i;
+  i++;
+  --i;
+  i < 0;
+  int j = 0 ?: 1;
+  auto k = new int;
+  delete k;
+  throw i;
+  {
+throw i;
+  }
+end:
+  return;
+}
+
+#if 1
+#define CC100
+#else
+// this macro has cognitive complexity of 100.
+// it is needed to be able to compare the testcases with the
+// reference Sonar implementation. please place it right after the first
+// CHECK-NOTES in each function
+#define CC100 if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){}if(1){}
+#endif
+
+////
+//-- B1. Increments --//
+////
+// Check that every thing listed in B1 of the specification does indeed   //
+// recieve the base increment, and that not-body does not increase nesting//
+////
+
+// break does not increase cognitive complexity.
+// only  break LABEL  does, but it is unavaliable in C or C++
+
+// continue does not increase cognitive complexity.
+// only  continue LABEL  does, but it is unavaliable in C or C++
+
+void unittest_b1_00() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_00' has cognitive complexity of 5 (threshold 0) [readability-function-cognitive-complexity]
+  CC100;
+
+  if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:9: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+  } else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:16: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+  } else {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +1, nesting level increased to 1{{$}}
+  }
+}
+
+void unittest_b1_01() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_01' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  CC100;
+
+  int i = (1 ? 1 : 0) ? 1 : 0;
+// CHECK-NOTES: :[[@LINE-1]]:23: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:14: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+}
+
+void unittest_b1_02(int x) {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_02' has cognitive complexity of 5 (threshold 0) [readability-function-cognitive-complexity]
+  CC100;
+
+  switch (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:13: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+  case -1:
+return;
+  case 1 ? 1 : 0:
+// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+return;
+  case (1 ? 2 : 0) ... (1 ? 3 : 0):
+// CHECK-NOTES: :[[@LINE-1]]:11: note: +1, including nesting penalty of 

[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Now we just need a test case to make sure this works as intended.


https://reviews.llvm.org/D37914



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


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115481.
gtbercea added a comment.

Fix condition.


https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,9 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_c) &&
+DriverArgs.hasArg(options::OPT_S))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,9 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_c) &&
+DriverArgs.hasArg(options::OPT_S))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-15 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added a comment.

Not included in this change:

- Updating the sanitizer documentation to use section headers. It's worth doing 
for the CFI documentation to let people know they can break down blacklist 
entries by CFI mode, but is it worth pushing users to specify '[address]', 
'[memory]', etc. sections for the other sanitizers as well?
- Merging the various sanitizer blacklists into a single blacklist. I'd like to 
pursue this in a later change where I also plan to break down the cfi blacklist 
by the specific CFI mode they should be blacklisted by.


https://reviews.llvm.org/D37925



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


r313392 - [X86] Disable _mm512_maskz_set1_epi64 intrinsic on 32-bit targets to prevent a backend isel failure.

2017-09-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Sep 15 13:27:59 2017
New Revision: 313392

URL: http://llvm.org/viewvc/llvm-project?rev=313392&view=rev
Log:
[X86] Disable _mm512_maskz_set1_epi64 intrinsic on 32-bit targets to prevent a 
backend isel failure.

The __builtin_ia32_pbroadcastq512_mem_mask we were previously trying to use in 
32-bit mode is not implemented in the x86 backend and causes isel to fail in 
release builds. In debug builds it fails even earlier during legalization with 
an llvm_unreachable.

While there add the missing test case for this intrinsic for this for 64-bit 
mode.

This fixes PR34631. D37668 should be able to recover this for 32-bit mode soon. 
But I wanted to fix the crash ahead of that.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=313392&r1=313391&r2=313392&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Sep 15 13:27:59 2017
@@ -974,7 +974,6 @@ TARGET_BUILTIN(__builtin_ia32_pmuludq512
 TARGET_BUILTIN(__builtin_ia32_ptestmd512, "UsV16iV16iUs", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_ptestmq512, "UcV8LLiV8LLiUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastd512_gpr_mask, "V16iiV16iUs", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_pbroadcastq512_mem_mask, "V8LLiLLiV8LLiUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_loaddqusi512_mask, "V16iiC*V16iUs", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi512_mask, "V8LLiLLiC*V8LLiUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_loadups512_mask, "V16ffC*V16fUs", "", "avx512f")

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=313392&r1=313391&r2=313392&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Sep 15 13:27:59 2017
@@ -267,21 +267,16 @@ _mm512_maskz_set1_epi32(__mmask16 __M, i
  __M);
 }
 
+#ifdef __x86_64__
 static __inline __m512i __DEFAULT_FN_ATTRS
 _mm512_maskz_set1_epi64(__mmask8 __M, long long __A)
 {
-#ifdef __x86_64__
   return (__m512i) __builtin_ia32_pbroadcastq512_gpr_mask (__A,
  (__v8di)
  _mm512_setzero_si512 (),
  __M);
-#else
-  return (__m512i) __builtin_ia32_pbroadcastq512_mem_mask (__A,
- (__v8di)
- _mm512_setzero_si512 (),
- __M);
-#endif
 }
+#endif
 
 static __inline __m512 __DEFAULT_FN_ATTRS
 _mm512_setzero_ps(void)

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=313392&r1=313391&r2=313392&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Fri Sep 15 13:27:59 2017
@@ -7935,6 +7935,13 @@ __m512i test_mm512_mask_set1_epi64 (__m5
 //CHECK: @llvm.x86.avx512.mask.pbroadcast.q.gpr.512
   return _mm512_mask_set1_epi64 (__O, __M, __A);
 }
+
+__m512i test_mm512_maskz_set1_epi64 (__mmask8 __M, long long __A)
+{
+//CHECK-LABEL: @test_mm512_maskz_set1_epi64
+//CHECK: @llvm.x86.avx512.mask.pbroadcast.q.gpr.512
+  return _mm512_maskz_set1_epi64 (__M, __A);
+}
 #endif
 
 __m512i test_mm512_set_epi64 (long long __A, long long __B, long long __C,


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


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-15 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich created this revision.
Herald added a subscriber: mgorny.

This is the follow-up patch to https://reviews.llvm.org/D37924.

This change refactors clang to use the the newly added section headers
in SpecialCaseList to specify which sanitizers blacklists entries
should apply to, like so:

  [cfi-vcall]
  fun:*bad_vcall*
  [cfi-derived-cast|cfi-unrelated-cast]
  fun:*bad_cast*

The SanitizerSpecialCaseList class has been added to allow querying by
SanitizerMask, and SanitizerBlacklist and its downstream users have been
updated to provide that information. Old blacklists not using sections
will continue to function identically since the blacklist entries will
be placed into a '[*]' section by default matching against all
sanitizers.


https://reviews.llvm.org/D37925

Files:
  include/clang/Basic/SanitizerBlacklist.h
  include/clang/Basic/SanitizerSpecialCaseList.h
  lib/AST/Decl.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/SanitizerBlacklist.cpp
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/XRayLists.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/sanitizer-special-case-list.c
  test/CodeGenCXX/cfi-blacklist.cpp

Index: test/CodeGenCXX/cfi-blacklist.cpp
===
--- test/CodeGenCXX/cfi-blacklist.cpp
+++ test/CodeGenCXX/cfi-blacklist.cpp
@@ -1,6 +1,18 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
-// RUN: echo "type:std::*" > %t.txt
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting cfi and cfi-vcall work correctly
+// RUN: echo "[cfi-vcall]" > %t.vcall.txt
+// RUN: echo "type:std::*" >> %t.vcall.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+//
+// RUN: echo "[cfi]" > %t.cfi.txt
+// RUN: echo "type:std::*" >> %t.cfi.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting non-vcall modes does not affect vcalls
+// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
+// RUN: echo "type:std::*" >> %t.other.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
 
 struct S1 {
   virtual void f();
Index: test/CodeGen/sanitizer-special-case-list.c
===
--- /dev/null
+++ test/CodeGen/sanitizer-special-case-list.c
@@ -0,0 +1,47 @@
+// Verify that blacklist sections correctly select sanitizers to apply blacklist entries to.
+//
+// RUN: echo "fun:*cfi*" > %t.unsanitized1
+// RUN: echo "fun:*overflow*" >> %t.unsanitized1
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized1 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[cfi]" > %t.unsanitized2
+// RUN: echo "fun:*cfi*" >> %t.unsanitized2
+// RUN: echo "[unsigned-integer-overflow]" >> %t.unsanitized2
+// RUN: echo "fun:*overflow*" >> %t.unsanitized2
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized2 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[cfi-icall]" > %t.unsanitized3
+// RUN: echo "fun:*cfi*" >> %t.unsanitized3
+// RUN: echo "[unsigned-integer-overflow]" >> %t.unsanitized3
+// RUN: echo "fun:*overflow*" >> %t.unsanitized3
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized3 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[c*]" > %t.unsanitized4
+// RUN: echo "fun:*cfi*" >> %t.unsanitized4
+// RUN: echo "[u*]" >> %t.unsanitized4
+// RUN: echo "fun:*overflow*" >> %t.unsanitized4
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized4 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: echo "[unsigned-integer-overflow]" > %t.sanitized
+// RUN: echo "fun:*cfi*" >> %t.sanitized
+// RUN: echo "[cfi]" >> %t.sanitized
+// RUN: echo "fun:*overflow*" >> %t.sanitized
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.sanitized -emit-llvm %s -o - | 

r313389 - This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352 LLVM code change is as per https://reviews.llvm.org/D33514

2017-09-15 Thread Vivek Pandya via cfe-commits
Author: vivekvpandya
Date: Fri Sep 15 13:09:55 2017
New Revision: 313389

URL: http://llvm.org/viewvc/llvm-project?rev=313389&view=rev
Log:
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352 LLVM code change 
is as per https://reviews.llvm.org/D33514

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=313389&r1=313388&r2=313389&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Sep 15 13:09:55 2017
@@ -46,6 +46,31 @@ using namespace clang;
 using namespace llvm;
 
 namespace clang {
+  class BackendConsumer;
+  class ClangDiagnosticHandler final : public DiagnosticHandler {
+  public:
+ClangDiagnosticHandler(const CodeGenOptions &CGOpts, BackendConsumer *BCon)
+: CodeGenOpts(CGOpts), BackendCon(BCon) {}
+  
+bool handleDiagnostics(const DiagnosticInfo &DI) override;
+bool isAnalysisRemarkEnable(const std::string &PassName) {
+  return (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
+  CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName));
+}
+bool isMissedOptRemarkEnable(const std::string &PassName) {
+  return (CodeGenOpts.OptimizationRemarkMissedPattern &&
+  CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName));
+}
+bool isPassedOptRemarkEnable(const std::string &PassName) {
+  return (CodeGenOpts.OptimizationRemarkPattern &&
+  CodeGenOpts.OptimizationRemarkPattern->match(PassName));
+}
+  
+  private:
+const CodeGenOptions &CodeGenOpts;
+BackendConsumer *BackendCon;
+  };
+
   class BackendConsumer : public ASTConsumer {
 using LinkModule = CodeGenAction::LinkModule;
 
@@ -224,10 +249,10 @@ namespace clang {
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
   Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
 
-  LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+  std::unique_ptr OldDiagnosticHandler =
   Ctx.getDiagnosticHandler();
-  void *OldDiagnosticContext = Ctx.getDiagnosticContext();
-  Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+  Ctx.setDiagnosticHandler(llvm::make_unique(
+CodeGenOpts, this));
   Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
   if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
 Ctx.setDiagnosticsHotnessThreshold(
@@ -264,7 +289,7 @@ namespace clang {
 
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 
-  Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+  Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
 
   if (OptRecordFile)
 OptRecordFile->keep();
@@ -299,11 +324,6 @@ namespace clang {
   ((BackendConsumer*)Context)->InlineAsmDiagHandler2(SM, Loc);
 }
 
-static void DiagnosticHandler(const llvm::DiagnosticInfo &DI,
-  void *Context) {
-  ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
-}
-
 /// Get the best possible source location to represent a diagnostic that
 /// may have associated debug info.
 const FullSourceLoc
@@ -343,6 +363,11 @@ namespace clang {
   void BackendConsumer::anchor() {}
 }
 
+bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) {
+  BackendCon->DiagnosticHandlerImpl(DI);
+  return true;
+}
+
 /// ConvertBackendLocation - Convert a location in a temporary llvm::SourceMgr
 /// buffer to be a valid FullSourceLoc.
 static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D,


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


r313386 - [Sema] Error out early for tags defined inside an enumeration.

2017-09-15 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Sep 15 12:51:42 2017
New Revision: 313386

URL: http://llvm.org/viewvc/llvm-project?rev=313386&view=rev
Log:
[Sema] Error out early for tags defined inside an enumeration.

This fixes PR28903 by avoiding access check for inner enum constant. We
are performing access check because one enum constant references another
and because enum is defined in CXXRecordDecl. But access check doesn't
work because FindDeclaringClass doesn't expect more than one EnumDecl
and because inner enum has access AS_none due to not being an immediate
child of a record.

The change detects an enum is defined in wrong place and allows to skip
parsing its body. Access check is skipped together with body parsing.
There was no crash in C, added test case to cover the new error.

rdar://problem/28530809

Reviewers: rnk, doug.gregor, rsmith

Reviewed By: doug.gregor

Subscribers: cfe-commits

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


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/enum.c
cfe/trunk/test/SemaCXX/enum.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=313386&r1=313385&r2=313386&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 15 12:51:42 
2017
@@ -1335,6 +1335,8 @@ def err_type_defined_in_alias_template :
   "%0 cannot be defined in a type alias template">;
 def err_type_defined_in_condition : Error<
   "%0 cannot be defined in a condition">;
+def err_type_defined_in_enum : Error<
+  "%0 cannot be defined in an enumeration">;
 
 def note_pure_virtual_function : Note<
   "unimplemented pure virtual method %0 in %1">;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=313386&r1=313385&r2=313386&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 15 12:51:42 2017
@@ -13928,6 +13928,12 @@ CreateNewDecl:
 Invalid = true;
   }
 
+  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+Diag(New->getLocation(), diag::err_type_defined_in_enum)
+  << Context.getTagDeclType(New);
+Invalid = true;
+  }
+
   // Maybe add qualifier info.
   if (SS.isNotEmpty()) {
 if (SS.isSet()) {

Modified: cfe/trunk/test/Sema/enum.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=313386&r1=313385&r2=313386&view=diff
==
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Fri Sep 15 12:51:42 2017
@@ -123,3 +123,14 @@ int NegativeShortTest[NegativeShort == -
 // PR24610
 enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
+
+// PR28903
+struct PR28903 {
+  enum {
+PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at 
{{.*}})' cannot be defined in an enumeration}}
+  PR28903_B,
+  PR28903_C = PR28903_B
+})0
+  };
+  int makeStructNonEmpty;
+};

Modified: cfe/trunk/test/SemaCXX/enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=313386&r1=313385&r2=313386&view=diff
==
--- cfe/trunk/test/SemaCXX/enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum.cpp Fri Sep 15 12:51:42 2017
@@ -110,3 +110,13 @@ enum { overflow = 123456 * 234567 };
 // expected-warning@-2 {{not an integral constant expression}}
 // expected-note@-3 {{value 28958703552 is outside the range of representable 
values}}
 #endif
+
+// PR28903
+struct PR28903 {
+  enum {
+PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at 
{{.*}})' cannot be defined in an enumeration}}
+  PR28903_B,
+  PR28903_C = PR28903_B
+})
+  };
+};


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


[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
vsapsai marked an inline comment as done.
Closed by commit rL313386: [Sema] Error out early for tags defined inside an 
enumeration. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D37089?vs=115333&id=115466#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37089

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/enum.c
  cfe/trunk/test/SemaCXX/enum.cpp


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1335,6 +1335,8 @@
   "%0 cannot be defined in a type alias template">;
 def err_type_defined_in_condition : Error<
   "%0 cannot be defined in a condition">;
+def err_type_defined_in_enum : Error<
+  "%0 cannot be defined in an enumeration">;
 
 def note_pure_virtual_function : Note<
   "unimplemented pure virtual method %0 in %1">;
Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -123,3 +123,14 @@
 // PR24610
 enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
+
+// PR28903
+struct PR28903 {
+  enum {
+PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at 
{{.*}})' cannot be defined in an enumeration}}
+  PR28903_B,
+  PR28903_C = PR28903_B
+})0
+  };
+  int makeStructNonEmpty;
+};
Index: cfe/trunk/test/SemaCXX/enum.cpp
===
--- cfe/trunk/test/SemaCXX/enum.cpp
+++ cfe/trunk/test/SemaCXX/enum.cpp
@@ -110,3 +110,13 @@
 // expected-warning@-2 {{not an integral constant expression}}
 // expected-note@-3 {{value 28958703552 is outside the range of representable 
values}}
 #endif
+
+// PR28903
+struct PR28903 {
+  enum {
+PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at 
{{.*}})' cannot be defined in an enumeration}}
+  PR28903_B,
+  PR28903_C = PR28903_B
+})
+  };
+};
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13928,6 +13928,12 @@
 Invalid = true;
   }
 
+  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+Diag(New->getLocation(), diag::err_type_defined_in_enum)
+  << Context.getTagDeclType(New);
+Invalid = true;
+  }
+
   // Maybe add qualifier info.
   if (SS.isNotEmpty()) {
 if (SS.isSet()) {


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1335,6 +1335,8 @@
   "%0 cannot be defined in a type alias template">;
 def err_type_defined_in_condition : Error<
   "%0 cannot be defined in a condition">;
+def err_type_defined_in_enum : Error<
+  "%0 cannot be defined in an enumeration">;
 
 def note_pure_virtual_function : Note<
   "unimplemented pure virtual method %0 in %1">;
Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -123,3 +123,14 @@
 // PR24610
 enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
+
+// PR28903
+struct PR28903 {
+  enum {
+PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at {{.*}})' cannot be defined in an enumeration}}
+  PR28903_B,
+  PR28903_C = PR28903_B
+})0
+  };
+  int makeStructNonEmpty;
+};
Index: cfe/trunk/test/SemaCXX/enum.cpp
===
--- cfe/trunk/test/SemaCXX/enum.cpp
+++ cfe/trunk/test/SemaCXX/enum.cpp
@@ -110,3 +110,13 @@
 // expected-warning@-2 {{not an integral constant expression}}
 // expected-note@-3 {{value 28958703552 is outside the range of representable values}}
 #endif
+
+// PR28903
+struct PR28903 {
+  enum {
+PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in an enumeration}}
+  PR28903_B,
+  PR28903_C = PR28903_B
+})
+  };
+};
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13928,6 +13928,12 @@
 Invalid = true;
   }
 
+  if (!Invalid && TUK == TUK_Definition && DC->getDec

r313385 - [Analyzer] Check function name size before indexing.

2017-09-15 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Sep 15 12:51:26 2017
New Revision: 313385

URL: http://llvm.org/viewvc/llvm-project?rev=313385&view=rev
Log:
[Analyzer] Check function name size before indexing.

https://reviews.llvm.org/D37908

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=313385&r1=313384&r2=313385&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Fri Sep 15 
12:51:26 2017
@@ -1211,7 +1211,8 @@ RetainSummaryManager::getFunctionSummary
 
 // Check for release functions, the only kind of functions that we care
 // about that don't return a pointer type.
-if (FName[0] == 'C' && (FName[1] == 'F' || FName[1] == 'G')) {
+if (FName.size() >= 2 &&
+FName[0] == 'C' && (FName[1] == 'F' || FName[1] == 'G')) {
   // Test for 'CGCF'.
   FName = FName.substr(FName.startswith("CGCF") ? 4 : 2);
 

Modified: cfe/trunk/test/Analysis/retain-release.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.mm?rev=313385&r1=313384&r2=313385&view=diff
==
--- cfe/trunk/test/Analysis/retain-release.mm (original)
+++ cfe/trunk/test/Analysis/retain-release.mm Fri Sep 15 12:51:26 2017
@@ -461,3 +461,5 @@ voidradar13722286::PrepareBitmap() {
}
 }
 
+// rdar://34210609
+void _() { _(); }; // no-warning


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


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In https://reviews.llvm.org/D37822#872291, @Anastasia wrote:

> Could you please explain a bit more why the alignment have to be put 
> explicitly in the struct? I am just not very convinced this is general enough.


The captured variables are fields of the block literal struct. Due to alignment 
requirement of these fields, there is alignment requirement of
the block literal struct. The ISA of the block invoke function is generated 
with the assumption of these alignments. If the block literal is
allocated at a memory address not satisfying the alignment requirement, the 
kernel behavior is undefined.

Generally, __enqueue_kernel library function needs to prepare the kernel 
argument before launching the kernel. It usually does this by copying
the block literal to some buffer then pass the address of the buffer to the 
kernel. Then the address of the buffer has to satisfy the alignment
requirement.

If this block literal struct is not general enough, how about add another field 
as target reserved size, and leave the remaining space of header for
target specific use. And add a target hook to allow target fill the reserved 
space, e.g.

  struct __opencl_block_literal {
int total_size;
int align;
__generic void *invoke;
int target_reserved_size; /* round up to 4 bytes */
int target_reserved[];
/* captures */
  };




Comment at: lib/CodeGen/CGBlocks.cpp:314
 
   assert(elementTypes.empty());
-  elementTypes.push_back(CGM.VoidPtrTy);

Anastasia wrote:
> Why removing this?
It is not removed. It is moved to line 307.



Comment at: test/CodeGenOpenCL/blocks.cl:17
   int i;
-// Checking for null instead of @_NSConcreteStackBlock symbol
-// COMMON: store i8* null, i8** %block.isa
+  // COMMON-NOT: store i8* null, i8** %block.isa
+  // COMMON: %[[block_size:.*]] = getelementptr inbounds <{ i32, i32, i8 
addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %block, i32 0, 
i32 0

Anastasia wrote:
> We don't need to check other fields too?
will add checks.


https://reviews.llvm.org/D37822



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


[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-15 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 115462.
Nebiroth marked an inline comment as done.
Nebiroth added a comment.

Fixed a few comments.
Rebased on latest clangd version.


https://reviews.llvm.org/D37150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -11,16 +11,23 @@
 #include "JSONRPCDispatcher.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-
 #include 
 #include 
 #include 
 #include 
 
 using namespace clang;
 using namespace clang::clangd;
 
+static llvm::cl::opt CompileCommandsDir(
+"compile-commands-dir",
+llvm::cl::desc("Specify a path to look for compile_commands.json. If path "
+   "is invalid, clangd will look in the current directory and "
+   "parent paths of each source file."));
+
+
 static llvm::cl::opt
 WorkerThreadsCount("j",
llvm::cl::desc("Number of async workers used by clangd"),
@@ -59,15 +66,37 @@
   llvm::raw_ostream &Outs = llvm::outs();
   llvm::raw_ostream &Logs = llvm::errs();
   JSONOutput Out(Outs, Logs);
-
+  
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
 
+  // If --compile-commands-dir arg was invoked, check value and override default
+  // path.
+  namespace path = llvm::sys::path;
+
+  if (!llvm::sys::path::is_absolute(CompileCommandsDir)) {
+Out.log("Path specified by --compile-commands-dir must be an absolute "
+"path. The argument will be ignored.\n");
+CompileCommandsDir = "";
+  }
+
+  if (!llvm::sys::fs::exists(CompileCommandsDir)) {
+Out.log("Path specified by --compile-commands-dir does not exist. The argument will be "
+"ignored.\n");
+CompileCommandsDir = "";
+  }  
+  llvm::Optional CompileCommandsDirPath;
+
+  if (CompileCommandsDir.empty())
+CompileCommandsDirPath = llvm::None;
+  else
+CompileCommandsDirPath = CompileCommandsDir;
+
   llvm::Optional ResourceDirRef = None;
   if (!ResourceDir.empty())
 ResourceDirRef = ResourceDir;
 
   ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets,
-ResourceDirRef);
+ResourceDirRef, CompileCommandsDirPath);
   LSPServer.run(std::cin);
 }
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -45,14 +45,19 @@
 class DirectoryBasedGlobalCompilationDatabase
 : public GlobalCompilationDatabase {
 public:
+  DirectoryBasedGlobalCompilationDatabase(
+  llvm::Optional NewCompileCommandsDir)
+  : CompileCommandsDir(NewCompileCommandsDir) {}
   std::vector
   getCompileCommands(PathRef File) override;
 
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 
 private:
-  tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
+  tooling::CompilationDatabase *getCompilationDatabase(PathRef File);  
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File);
 
+  llvm::Optional CompileCommandsDir;
   std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
   /// directories).
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -62,43 +62,50 @@
 }
 
 tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
-  std::lock_guard Lock(Mutex);
-
+DirectoryBasedGlobalCompilationDatabase::tryLoadDatabaseFromPath(PathRef File) {
   namespace path = llvm::sys::path;
+  auto CachedIt = CompilationDatabases.find(File);
+  std::string Error = "";
 
   assert((path::is_absolute(File, path::Style::posix) ||
   path::is_absolute(File, path::Style::windows)) &&
  "path must be absolute");
 
-  for (auto Path = path::parent_path(File); !Path.empty();
-   Path = path::parent_path(Path)) {
-
-auto CachedIt = CompilationDatabases.find(Path);
-if (CachedIt != CompilationDatabases.end())
-  return CachedIt->second.get();
-std::string Error;
-auto CDB = tooling::CompilationDatabase::loadFromDirectory(Path, Error);
-if (!CDB) {
-  if (!Error.empty()) {
-// FIXME(ibiryukov): logging
-// Output.log("Error when trying to load compilation database from " +
-//Twine(Path) + ": " + Twine(Error) + "\n");
-  }
-  continue;
-}
+  if (CachedIt != CompilationDatabases.end())
+return CachedIt->second.get();
+  auto CDB = tooling::Compilatio

[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR

2017-09-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm going to go ahead and remove __builtin_ia32_pbroadcastq512_mem_mask from 
clang and change _mm512_maskz_set1_epi64 to be disabled in 32-bit mode. I want 
to nominate this for 5.0.1 because using it in 32-bit mode causes the compile 
to throw a cannot select error. So disabling it in the header at least gives a 
better user experience.

After that goes in you should rebase this patch and enable all of the 
set1_epi64 intrinsics to work in 32-bit mode like they should.




Comment at: lib/Headers/avx512fintrin.h:9742
 
 #ifdef __x86_64__
 static __inline__ __m512i __DEFAULT_FN_ATTRS

Please remove the #ifdef __x86_64__ from this. It should work in 32-bits as 
well.



Comment at: lib/Headers/avx512vlintrin.h:5759
 
 #ifdef __x86_64__
 static __inline__ __m128i __DEFAULT_FN_ATTRS

Please remove the __x86_64__ from these. They should work in 32-bit mode.


https://reviews.llvm.org/D37668



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:27
+  // Here are all the possible reasons:
+  enum Criteria : unsigned char {
+None = 0,

JonasToth wrote:
> i think clarifying which language constructs relative to what criteria would 
> help here.
> 
> with the document next to me here its clear, but i think we shouldn't expect 
> that. a link/refernce to the page would be nice, too.
*relate


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D37568: [AMDGPU] Allow flexible register names in inline asm constraints

2017-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Basic/Targets/AMDGPU.h:194
+Info.setAllowsRegister();
+Name = S.data() - 1;
+return true;

arsenm wrote:
> I'm not sure I understand these data() - 1s. 
The caller of this function expects Name is on the last parsed char and will 
increase it before check the next char.



Comment at: test/Sema/inline-asm-validate-amdgpu.cl:74
+__asm("v_add_f64_e64 v[1:2], v[3:4], v[5:6]" : "=v[1:2]"(ci) : 
"v[3:4]"(ai), "v[5:6]"(bi) : ); //expected-error {{invalid output constraint 
'=v[1:2]' in asm}}
+
+c[i] = ci;

arsenm wrote:
> While you're here can we add some tests for the immediate constraints? There 
> was a bug report recently when using s_trap with the i constraints for the 
> constant operand.
what's the syntax of the immediate constraints? And some examples? Thanks.


https://reviews.llvm.org/D37568



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


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

BTW, at least for CUDA compilation, '-c' would still needs libdevice as 
device-side will compile PTX to SASS and will need all the symbols PTX may 
refer to. 
Would that not be the case for OpenMP's compilation, too?


https://reviews.llvm.org/D37914



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


[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D37912#872318, @gtbercea wrote:

> In https://reviews.llvm.org/D37912#872294, @tra wrote:
>
> > Shouldn't this temp .cubin file go into the temporary directory, as opposed 
> > to the same directory as the input file?
>
>
> That is indeed the intention. The filename already contains the "/tmp/" I 
> just make sure that doesn't get dropped.


Is that guaranteed to always be the case? If not, you're just hiding the 
problem.
IMO, it would be better to construct a temporary path for the file, if that's 
the intention. All you need is TC.getDriver().GetTemporaryPath(...).


Repository:
  rL LLVM

https://reviews.llvm.org/D37912



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


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115447.
gtbercea added a comment.

Fix parantheses.


https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,8 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_S, options::OPT_c))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,8 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_S, options::OPT_c))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115444.
gtbercea added a comment.

Contract check.


https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,8 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_S, options::OPT_c)))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,10 +502,8 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
-if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_S)) ||
-(DeviceOffloadingKind == Action::OFK_OpenMP &&
- DriverArgs.hasArg(options::OPT_c)))
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_S, options::OPT_c)))
   return;
 
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r313377 - [libc++] Account for Microsoft CRT const overloads

2017-09-15 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Sep 15 11:49:34 2017
New Revision: 313377

URL: http://llvm.org/viewvc/llvm-project?rev=313377&view=rev
Log:
[libc++] Account for Microsoft CRT const overloads

Microsoft's CRT already provides the const overloads, and it defines the
`_CRT_CONST_CORRECT_OVERLOADS` macro to indicate their presence. Check
for this macro before attempting to define our own const-correct
overloads, to avoid compiler warnings about casts dropping const
qualifiers.

Modified:
libcxx/trunk/include/wchar.h

Modified: libcxx/trunk/include/wchar.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/wchar.h?rev=313377&r1=313376&r2=313377&view=diff
==
--- libcxx/trunk/include/wchar.h (original)
+++ libcxx/trunk/include/wchar.h Fri Sep 15 11:49:34 2017
@@ -125,6 +125,10 @@ size_t wcsrtombs(char* restrict dst, con
 #  if __GLIBC_PREREQ(2, 10)
 #define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
 #  endif
+#elif defined(_LIBCPP_MSVCRT)
+#  if defined(_CRT_CONST_CORRECT_OVERLOADS)
+#define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
+#  endif
 #endif
 
 #if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && 
defined(_LIBCPP_PREFERRED_OVERLOAD)


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


[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D37912#872294, @tra wrote:

> Shouldn't this temp .cubin file go into the temporary directory, as opposed 
> to the same directory as the input file?


That is indeed the intention. The filename already contains the "/tmp/" I just 
make sure that doesn't get dropped.


Repository:
  rL LLVM

https://reviews.llvm.org/D37912



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


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:505-508
+if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
+ DriverArgs.hasArg(options::OPT_S)) ||
+(DeviceOffloadingKind == Action::OFK_OpenMP &&
+ DriverArgs.hasArg(options::OPT_c)))

This could probably be rephrased as:
```
if (DeviceOffloadingKind == Action::OFK_OpenMP && 
DriverArgs.hasArg(options::OPT_S, options::OPT_c))) ...
```


Repository:
  rL LLVM

https://reviews.llvm.org/D37914



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


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

If we only use the compiler front-end, do not throw an error about the cuda 
device library not being found. This allows the front-end to be run on systems 
where no Cuda installation is found.


Repository:
  rL LLVM

https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,6 +502,12 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
+ DriverArgs.hasArg(options::OPT_S)) ||
+(DeviceOffloadingKind == Action::OFK_OpenMP &&
+ DriverArgs.hasArg(options::OPT_c)))
+  return;
+
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
 return;
   }


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -502,6 +502,12 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+if ((DeviceOffloadingKind == Action::OFK_OpenMP &&
+ DriverArgs.hasArg(options::OPT_S)) ||
+(DeviceOffloadingKind == Action::OFK_OpenMP &&
+ DriverArgs.hasArg(options::OPT_c)))
+  return;
+
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Shouldn't this temp .cubin file go into the temporary directory, as opposed to 
the same directory as the input file?


Repository:
  rL LLVM

https://reviews.llvm.org/D37912



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


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Could you please explain a bit more why the alignment have to be put explicitly 
in the struct? I am just not very convinced this is general enough.




Comment at: lib/CodeGen/CGBlocks.cpp:314
 
   assert(elementTypes.empty());
-  elementTypes.push_back(CGM.VoidPtrTy);

Why removing this?



Comment at: test/CodeGenOpenCL/blocks.cl:17
   int i;
-// Checking for null instead of @_NSConcreteStackBlock symbol
-// COMMON: store i8* null, i8** %block.isa
+  // COMMON-NOT: store i8* null, i8** %block.isa
+  // COMMON: %[[block_size:.*]] = getelementptr inbounds <{ i32, i32, i8 
addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %block, i32 0, 
i32 0

We don't need to check other fields too?


https://reviews.llvm.org/D37822



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


[PATCH] D37913: [OpenMP] Enable the existing nocudalib flag for OpenMP offloading toolchain.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

Enable the -nocudalib flag for the OpenMP device offloading toolchain as well. 
Currently it can only be used for the CUDA toolchain.


Repository:
  rL LLVM

https://reviews.llvm.org/D37913

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -494,11 +494,11 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
-
-if (DriverArgs.hasArg(options::OPT_nocudalib))
-  return;
   }
 
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -494,11 +494,11 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
-
-if (DriverArgs.hasArg(options::OPT_nocudalib))
-  return;
   }
 
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

When composing the output file name, the path to the file is being dropped. The 
full path is required.


Repository:
  rL LLVM

https://reviews.llvm.org/D37912

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,11 +438,13 @@
 if (!II.isFilename())
   continue;
 
-SmallString<256> Name = llvm::sys::path::filename(II.getFilename());
+SmallString<256> Name = llvm::sys::path::relative_path(II.getFilename());
+SmallString<256> FullPath = llvm::sys::path::root_path(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");
+llvm::sys::path::append(FullPath, Name);
 
 const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+C.addTempFile(C.getArgs().MakeArgString(FullPath));
 
 CmdArgs.push_back(CubinF);
   }


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,11 +438,13 @@
 if (!II.isFilename())
   continue;
 
-SmallString<256> Name = llvm::sys::path::filename(II.getFilename());
+SmallString<256> Name = llvm::sys::path::relative_path(II.getFilename());
+SmallString<256> FullPath = llvm::sys::path::root_path(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");
+llvm::sys::path::append(FullPath, Name);
 
 const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+C.addTempFile(C.getArgs().MakeArgString(FullPath));
 
 CmdArgs.push_back(CubinF);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:7251
+if (const auto *rhproto = dyn_cast(rhptee))
+  rhptee = S.removeNoEscapeFromFunctionProto(lhproto, rhproto);
+

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > I think the right place to do this is probably mergeFunctionTypes.
> > When we have the following conditional operator expression, what is the 
> > type of the expression?
> > 
> > ```
> > void func0(__attribute__((noescape)) int *a, int *b);
> > void func1(int *a, __attribute__((noescape)) int *b);
> > 
> > c ? func0 : func1;
> > ```
> > 
> > The standard says the type of each parameter in the composite parameter 
> > type list is the composite type of the corresponding parameters of both 
> > functions, so I guess mergeFunctionType should drop noescape from both 
> > parameters?
> Yes, that sounds right.
I defined a new function (mergeExtParameterInfo) that checks the compatibility 
of two functions and creates the composite type and used it for C's 
compatibility checking and C++'s conversion rules. Also, I added new test cases 
in test/Sema/noescape.c.


https://reviews.llvm.org/D32210



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


[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 115432.
ahatanak added a comment.

Address review comments.

The new patch defines a new function "mergeExtParameterInfo" that merges two 
functions' ExtParameterInfo lists and uses it where previously 
doFunctionTypesMatchOnExtParameterInfos was used.


https://reviews.llvm.org/D32210

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/Analysis/retain-release.m
  test/CodeGenCXX/noescape.cpp
  test/CodeGenObjC/noescape.m
  test/Misc/ast-dump-attr.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/noescape.c
  test/SemaObjC/arc-nsconsumed-errors.m
  test/SemaObjCXX/noescape.mm

Index: test/SemaObjCXX/noescape.mm
===
--- /dev/null
+++ test/SemaObjCXX/noescape.mm
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++1z %s
+
+typedef void (^BlockTy)();
+
+struct S {
+  int i;
+  void m();
+};
+
+void noescapeFunc0(id, __attribute__((noescape)) BlockTy);
+void noescapeFunc1(id, [[clang::noescape]] BlockTy);
+void noescapeFunc2(__attribute__((noescape)) int *); // expected-note {{previous declaration is here}}
+void noescapeFunc3(__attribute__((noescape)) id);
+void noescapeFunc4(__attribute__((noescape)) int &);
+void noescapeFunc2(int *); // expected-error {{conflicting types for 'noescapeFunc2'}}
+
+void invalidFunc0(int __attribute__((noescape))); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+void invalidFunc1(int __attribute__((noescape(0; // expected-error {{'noescape' attribute takes no arguments}}
+void invalidFunc2(int0 *__attribute__((noescape))); // expected-error {{use of undeclared identifier 'int0'; did you mean 'int'?}}
+void invalidFunc3(__attribute__((noescape)) int (S::*Ty)); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+void invalidFunc4(__attribute__((noescape)) void (S::*Ty)()); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+int __attribute__((noescape)) g; // expected-warning {{'noescape' attribute only applies to parameters}}
+
+struct S1 {
+  virtual void m0(int *__attribute__((noescape))); // expected-note {{parameter of overridden method is annotated with __attribute__((noescape))}}
+};
+
+struct S2 : S1 {
+  void m0(int *__attribute__((noescape))) override;
+};
+
+struct S3 : S1 {
+  void m0(int *) override; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}}
+};
+
+__attribute__((objc_root_class))
+@interface C0
+-(void) m0:(int*)__attribute__((noescape)) p; // expected-note {{parameter of overridden method is annotated with __attribute__((noescape))}}
+@end
+
+@implementation C0
+-(void) m0:(int*)__attribute__((noescape)) p {}
+@end
+
+@interface C1 : C0
+-(void) m0:(int*)__attribute__((noescape)) p;
+@end
+
+@implementation C1 : C0
+-(void) m0:(int*)__attribute__((noescape)) p {}
+@end
+
+@interface C2 : C0
+-(void) m0:(int*) p; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}}
+@end
+
+@implementation C2 : C0
+-(void) m0:(int*) p {}
+@end
+
+void func0(int *);
+void (*fnptr0)(int *);
+void (*fnptr1)(__attribute__((noescape)) int *);
+template struct S4 {};
+template struct S5 {};
+
+#if __cplusplus < 201406
+  // expected-note@-4 {{template parameter is declared here}}
+  // expected-note@-4 {{template parameter is declared here}}
+#endif
+
+void test0() {
+  fnptr0 = &func0;
+  fnptr0 = &noescapeFunc2;
+  fnptr1 = &func0; // expected-error {{assigning to 'void (*)(__attribute__((noescape)) int *)' from incompatible type 'void (*)(int *)'}}
+  fnptr1 = &noescapeFunc2;
+  S4<&func0> e0;
+  S4<&noescapeFunc2> e1;
+  S5<&func0> ne0;
+
+#if __cplusplus < 201406
+  // expected-error@-4 {{non-type template argument of type 'void (*)(__attribute__((noescape)) int *)' cannot be converted to a value of type 'void (*)(int *)'}}
+  // expected-error@-4 {{non-type template argument of type 'void (*)(int *)' cannot be converted to a value of type 'void (*)(__attribute__((noescape)) int *)'}}
+#else
+  // expected-error@-6 {{value of type 'void (*)(int *)' is not implicitly convertible to 'void (*)(__attribute__((noescape)) int *)'}}
+#endif
+
+  S5<&noescapeFunc2> ne1;
+}
Index: test/SemaObjC/arc-nsconsumed-errors.m
===
--- test/SemaObjC/arc-nsconsumed-errors.m
+++ test/SemaObjC/arc-nsconsumed-errors.m
@

[PATCH] D37892: [X86] Use native shuffle vector for the perm2f128 intrinsics

2017-09-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - please can you update the 
avx-intrinsics-fast-isel.ll/avxs-intrinsics-fast-isel.ll cases to match the 
*-builtins.c as well (either now or if/when you add the intrinsics to 
autoupgrade).


https://reviews.llvm.org/D37892



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


[PATCH] D37892: [X86] Use native shuffle vector for the perm2f128 intrinsics

2017-09-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 115427.
craig.topper added a comment.

Convert the AVX2 integer intrinsic as well.


https://reviews.llvm.org/D37892

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx-builtins.c
  test/CodeGen/avx2-builtins.c


Index: test/CodeGen/avx2-builtins.c
===
--- test/CodeGen/avx2-builtins.c
+++ test/CodeGen/avx2-builtins.c
@@ -907,8 +907,8 @@
 
 __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_permute2x128_si256
-  // CHECK: call <4 x i64> @llvm.x86.avx2.vperm2i128(<4 x i64> %{{.*}}, <4 x 
i64> %{{.*}}, i8 49)
-  return _mm256_permute2x128_si256(a, b, 0x31);
+  // CHECK: shufflevector <4 x i64> zeroinitializer, <4 x i64> %{{.*}}, <4 x 
i32> 
+  return _mm256_permute2x128_si256(a, b, 0x38);
 }
 
 __m256i test_mm256_permute4x64_epi64(__m256i a) {
Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -678,19 +678,19 @@
 
 __m256d test_mm256_permute2f128_pd(__m256d A, __m256d B) {
   // CHECK-LABEL: test_mm256_permute2f128_pd
-  // CHECK: call <4 x double> @llvm.x86.avx.vperm2f128.pd.256(<4 x double> 
%{{.*}}, <4 x double> %{{.*}}, i8 49)
+  // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x 
i32> 
   return _mm256_permute2f128_pd(A, B, 0x31);
 }
 
 __m256 test_mm256_permute2f128_ps(__m256 A, __m256 B) {
   // CHECK-LABEL: test_mm256_permute2f128_ps
-  // CHECK: call <8 x float> @llvm.x86.avx.vperm2f128.ps.256(<8 x float> 
%{{.*}}, <8 x float> %{{.*}}, i8 19)
+  // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 

   return _mm256_permute2f128_ps(A, B, 0x13);
 }
 
 __m256i test_mm256_permute2f128_si256(__m256i A, __m256i B) {
   // CHECK-LABEL: test_mm256_permute2f128_si256
-  // CHECK: call <8 x i32> @llvm.x86.avx.vperm2f128.si.256(<8 x i32> %{{.*}}, 
<8 x i32> %{{.*}}, i8 32)
+  // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> 
   return _mm256_permute2f128_si256(A, B, 0x20);
 }
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7923,6 +7923,45 @@
 return EmitX86Select(*this, Ops[4], Align, Ops[3]);
   }
 
+  case X86::BI__builtin_ia32_vperm2f128_pd256:
+  case X86::BI__builtin_ia32_vperm2f128_ps256:
+  case X86::BI__builtin_ia32_vperm2f128_si256:
+  case X86::BI__builtin_ia32_permti256: {
+unsigned Imm = cast(Ops[2])->getZExtValue();
+unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
+
+// This takes a very simple approach since there are two lanes and a
+// shuffle can have 2 inputs. So we reserve the first input for the first
+// lane and the second input for the second lane. This may result in
+// duplicate sources, but this can be dealt with in the backend.
+
+Value *OutOps[2];
+uint32_t Indices[8];
+for (unsigned l = 0; l != 2; ++l) {
+  // Determine the source for this lane.
+  if (Imm & (1 << ((l * 4) + 3)))
+OutOps[l] = llvm::ConstantAggregateZero::get(Ops[0]->getType());
+  else if (Imm & (1 << ((l * 4) + 1)))
+OutOps[l] = Ops[1];
+  else
+OutOps[l] = Ops[0];
+
+  for (unsigned i = 0; i != NumElts/2; ++i) {
+// Start with ith element of the source for this lane.
+unsigned Idx = (l * NumElts) + i;
+// If bit 0 of the immediate half is set, switch to the high half of
+// the source.
+if (Imm & (1 << (l * 4)))
+  Idx += NumElts/2;
+Indices[(l * (NumElts/2)) + i] = Idx;
+  }
+}
+
+return Builder.CreateShuffleVector(OutOps[0], OutOps[1],
+   makeArrayRef(Indices, NumElts),
+   "vperm");
+  }
+
   case X86::BI__builtin_ia32_movnti:
   case X86::BI__builtin_ia32_movnti64:
   case X86::BI__builtin_ia32_movntsd:


Index: test/CodeGen/avx2-builtins.c
===
--- test/CodeGen/avx2-builtins.c
+++ test/CodeGen/avx2-builtins.c
@@ -907,8 +907,8 @@
 
 __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_permute2x128_si256
-  // CHECK: call <4 x i64> @llvm.x86.avx2.vperm2i128(<4 x i64> %{{.*}}, <4 x i64> %{{.*}}, i8 49)
-  return _mm256_permute2x128_si256(a, b, 0x31);
+  // CHECK: shufflevector <4 x i64> zeroinitializer, <4 x i64> %{{.*}}, <4 x i32> 
+  return _mm256_permute2x128_si256(a, b, 0x38);
 }
 
 __m256i test_mm256_permute4x64_epi64(__m256i a) {
Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -678,19 +678,19 @@
 
 __m256d test_mm256_permute2f128_pd(__m256d A, __m256d B) {
   // CHECK-LABEL: test_mm256_permute2f128_pd
-

[PATCH] D37568: [AMDGPU] Allow flexible register names in inline asm constraints

2017-09-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/Basic/Targets/AMDGPU.h:124
+  /// {sn}, {s[n]}
+  /// {S} , wheere S is a special register name
+  {v[n:m]}

Typo wheere



Comment at: lib/Basic/Targets/AMDGPU.h:194
+Info.setAllowsRegister();
+Name = S.data() - 1;
+return true;

I'm not sure I understand these data() - 1s. 



Comment at: test/Sema/inline-asm-validate-amdgpu.cl:74
+__asm("v_add_f64_e64 v[1:2], v[3:4], v[5:6]" : "=v[1:2]"(ci) : 
"v[3:4]"(ai), "v[5:6]"(bi) : ); //expected-error {{invalid output constraint 
'=v[1:2]' in asm}}
+
+c[i] = ci;

While you're here can we add some tests for the immediate constraints? There 
was a bug report recently when using s_trap with the i constraints for the 
constant operand.


https://reviews.llvm.org/D37568



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


r313369 - [CUDA] Work around a new quirk in CUDA9 headers.

2017-09-15 Thread Artem Belevich via cfe-commits
Author: tra
Date: Fri Sep 15 10:30:53 2017
New Revision: 313369

URL: http://llvm.org/viewvc/llvm-project?rev=313369&view=rev
Log:
[CUDA] Work around a new quirk in CUDA9 headers.

In CUDA-9 some of device-side math functions that we need are conditionally
defined within '#if _GLIBCXX_MATH_H'. We need to temporarily undo the guard
around inclusion of math_functions.hpp.

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=313369&r1=313368&r2=313369&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Fri Sep 15 10:30:53 
2017
@@ -254,7 +254,17 @@ static inline __device__ void __brkpt(in
 #pragma push_macro("__GNUC__")
 #undef __GNUC__
 #define signbit __ignored_cuda_signbit
+
+// CUDA-9 omits device-side definitions of some math functions if it sees
+// include guard from math.h wrapper from libstdc++. We have to undo the header
+// guard temporarily to get the definitions we need.
+#pragma push_macro("_GLIBCXX_MATH_H")
+#if CUDA_VERSION >= 9000
+#undef _GLIBCXX_MATH_H
+#endif
+
 #include "math_functions.hpp"
+#pragma pop_macro("_GLIBCXX_MATH_H")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


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


[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313369: [CUDA] Work around a new quirk in CUDA9 headers. 
(authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D37906?vs=115415&id=115422#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37906

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -254,7 +254,17 @@
 #pragma push_macro("__GNUC__")
 #undef __GNUC__
 #define signbit __ignored_cuda_signbit
+
+// CUDA-9 omits device-side definitions of some math functions if it sees
+// include guard from math.h wrapper from libstdc++. We have to undo the header
+// guard temporarily to get the definitions we need.
+#pragma push_macro("_GLIBCXX_MATH_H")
+#if CUDA_VERSION >= 9000
+#undef _GLIBCXX_MATH_H
+#endif
+
 #include "math_functions.hpp"
+#pragma pop_macro("_GLIBCXX_MATH_H")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -254,7 +254,17 @@
 #pragma push_macro("__GNUC__")
 #undef __GNUC__
 #define signbit __ignored_cuda_signbit
+
+// CUDA-9 omits device-side definitions of some math functions if it sees
+// include guard from math.h wrapper from libstdc++. We have to undo the header
+// guard temporarily to get the definitions we need.
+#pragma push_macro("_GLIBCXX_MATH_H")
+#if CUDA_VERSION >= 9000
+#undef _GLIBCXX_MATH_H
+#endif
+
 #include "math_functions.hpp"
+#pragma pop_macro("_GLIBCXX_MATH_H")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-09-15 Thread enh via cfe-commits
It's supposed to tell you whether the target arch supports it. So it's
definitely something the compiler knows better than the C library, which is
why I didn't just work around this myself 😀

Clang may not be correct right now, but if that's true, (a) it's already
lying to us through the other macro and (b) it's still in a better position
to know the truth.

On Sep 15, 2017 10:12, "Pirama Arumuga Nainar via Phabricator" <
revi...@reviews.llvm.org> wrote:

pirama added a comment.

In https://reviews.llvm.org/D37302#871794, @joerg wrote:

> So what about targets that don't support subnormals? I'm moderately sure
ARM falls into this category given the right phase of the moon.


Clang defines `__FLT_HAS_DENORM__` and friends unconditionally, so I
thought we could do this for `FLT_HAS_SUBNORM` as well, considering that
gcc did the same.  But that might be misleading because gcc's float.h was
just for the target of that particular gcc build.

Am I right to understand that `__FLT_HAS_DENORM__` signifies *compiler*
support for denorms as opposed to support on the *platforms* supported?  If
so, it might support our alternative consideration of defining these macros
in the bionic/libc headers for Android (and rely on the include_next
similar to Windows and Darwin).


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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-09-15 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D37302#871794, @joerg wrote:

> So what about targets that don't support subnormals? I'm moderately sure ARM 
> falls into this category given the right phase of the moon.


Clang defines `__FLT_HAS_DENORM__` and friends unconditionally, so I thought we 
could do this for `FLT_HAS_SUBNORM` as well, considering that gcc did the same. 
 But that might be misleading because gcc's float.h was just for the target of 
that particular gcc build.

Am I right to understand that `__FLT_HAS_DENORM__` signifies *compiler* support 
for denorms as opposed to support on the *platforms* supported?  If so, it 
might support our alternative consideration of defining these macros in the 
bionic/libc headers for Android (and rely on the include_next similar to 
Windows and Darwin).


https://reviews.llvm.org/D37302



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


[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.

2017-09-15 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

> BTW, this change essentially augments the job that the "#undef GNUC" above 
> used to do in older CUDA versions. CUDA9 replaced GNUC with _GLIBCXX_MATH_H 
> in CUDA-9 in some places.

Ah, that's right.  Okay then.  :)


https://reviews.llvm.org/D37906



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


[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I don't think we really care why they do it for nvcc. 
My understanding is that nvcc needs to avoid name clashes between their 
implementation of functions and the ones that come from the host headers and 
that's why they have to tread really carefully around host includes.

We just need to get those definitions of the device-side functions and we don't 
care whether host-side functions with the same name are visible at the same 
time. I wish CUDA would just put all device-side function definitions into a 
separate file/namespace and let us cherry-pick them at will. Alas, we have to 
work around nvcc's work arounds...

BTW, this change essentially augments the job that the "#undef __GNUC__" above 
used to do in older CUDA versions.  CUDA9 replaced __GNUC__ with 
_GLIBCXX_MATH_H in CUDA-9 in some places.


https://reviews.llvm.org/D37906



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


[PATCH] D35743: [clang-format] Handle Structured binding declaration in C++17

2017-09-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

ping.


https://reviews.llvm.org/D35743



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


[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:477
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-  assert((LangOpts.ShortWChar ||
-  llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) 
==

@MatzeB ptal



Comment at: lib/Driver/ToolChains/Clang.cpp:2659
+
+  const bool IsAPCSABI =
+  IsARM && (IsGNUEnvironment || IsNetBSD ||

This target detection logic is insanely complicated, and I'm not convinced it's 
simpler than the Basic/Targets/ delegation strategy.

I can go either way on putting this info in the Driver or Basic, but this code 
needs to be simpler. Surely a switch could help here?


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.

2017-09-15 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

This is a bit of a Chesterton's Fence -- do we know why they're doing this?

I guess it's probably going to be OK because our overriding semantics will make 
it OK, and our test-suite tests (should) exercise all of math.h.  But I'm still 
a little worried about it.


https://reviews.llvm.org/D37906



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


[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.

2017-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added a subscriber: sanjoy.

In CUDA-9 some of device-side math functions that we need are conditionally
defined within '#if _GLIBCXX_MATH_H'. We need to temporarily undo the guard 
around inclusion of math_functions.hpp


https://reviews.llvm.org/D37906

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -254,7 +254,17 @@
 #pragma push_macro("__GNUC__")
 #undef __GNUC__
 #define signbit __ignored_cuda_signbit
+
+// CUDA-9 omits device-side definitions of some math functions if it sees
+// include guard from math.h wrapper from libstdc++. We have to undo the header
+// guard temporarily to get the definitions we need.
+#pragma push_macro("_GLIBCXX_MATH_H")
+#if CUDA_VERSION >= 9000
+#undef _GLIBCXX_MATH_H
+#endif
+
 #include "math_functions.hpp"
+#pragma pop_macro("_GLIBCXX_MATH_H")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -254,7 +254,17 @@
 #pragma push_macro("__GNUC__")
 #undef __GNUC__
 #define signbit __ignored_cuda_signbit
+
+// CUDA-9 omits device-side definitions of some math functions if it sees
+// include guard from math.h wrapper from libstdc++. We have to undo the header
+// guard temporarily to get the definitions we need.
+#pragma push_macro("_GLIBCXX_MATH_H")
+#if CUDA_VERSION >= 9000
+#undef _GLIBCXX_MATH_H
+#endif
+
 #include "math_functions.hpp"
+#pragma pop_macro("_GLIBCXX_MATH_H")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

We could leave the defaults there as they stand, and only have the new flags 
alter the default.  However, it seems that just paying the cost of adjusting 
the tests once isn't too bad.  To me, it seems that having one instance of the 
horrible logic for determining the type of `wchar_t` is better than having two 
copies which can diverge slightly.  My understanding was that we determined 
that it was better to just pay this test adjustment cost, since it would treat 
all the targets the same.


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I do remember recommending this approach over IRC, but I thought we concluded 
that we should leave all the defaults in lib/Basic/Targets/ and make the -cc1 
-fwchar-type= and -f[no-]signed-wchar overrides that affected all targets 
equally. That would avoid the need for these test updates, anyway.


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


[PATCH] D37308: Fix the __interface inheritence rules to work better with IUnknown and IDispatch

2017-09-15 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313364: Fix the __interface inheritence rules to work better 
with IUnknown and IDispatch (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D37308?vs=115272&id=115414#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37308

Files:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp
  cfe/trunk/test/SemaCXX/ms-iunknown-outofline-def.cpp
  cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -1831,6 +1831,10 @@
 return getLambdaData().MethodTyInfo;
   }
 
+  // \brief Determine whether this type is an Interface Like type for
+  // __interface inheritence purposes.
+  bool isInterfaceLike() const;
+
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;
Index: cfe/trunk/test/SemaCXX/ms-iunknown-outofline-def.cpp
===
--- cfe/trunk/test/SemaCXX/ms-iunknown-outofline-def.cpp
+++ cfe/trunk/test/SemaCXX/ms-iunknown-outofline-def.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+
+struct __declspec(uuid("---C000-0046")) IUnknown {
+  void foo();
+};
+
+__interface NoError : public IUnknown {};
+void IUnknown::foo() {}
+// expected-error@+1{{interface type cannot inherit from}}
+__interface HasError : public IUnknown {}; 
Index: cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp
===
--- cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp
+++ cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+
+struct __declspec(uuid("---C000-0046")) IUnknown {
+  void foo() {}
+};
+
+// expected-error@+1{{interface type cannot inherit from}}
+__interface HasError : public IUnknown {}; 
Index: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
===
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+
+struct __declspec(uuid("---C000-0046")) IUnknown {
+  void foo();
+};
+struct IPropertyPageBase : public IUnknown {};
+struct IPropertyPage : public IPropertyPageBase {};
+__interface ISfFileIOPropertyPage : public IPropertyPage {};
+
+
+namespace NS {
+  struct __declspec(uuid("---C000-0046")) IUnknown {};
+  // expected-error@+1 {{interface type cannot inherit from}}
+  __interface IPropertyPageBase : public IUnknown {}; 
+}
+// expected-error@+1 {{interface type cannot inherit from}}
+__interface IPropertyPageBase2 : public NS::IUnknown {}; 
+
+__interface temp_iface {};
+struct bad_base : temp_iface {};
+// expected-error@+1 {{interface type cannot inherit from}}
+__interface bad_inherit : public bad_base{};
+
+struct mult_inher_base : temp_iface, IUnknown {};
+// expected-error@+1 {{interface type cannot inherit from}}
+__interface bad_inherit2 : public mult_inher_base{};
+
+struct PageBase : public IUnknown {};
+struct Page3 : public PageBase {};
+struct Page4 : public PageBase {};
+__interface PropertyPage : public Page4 {};
+
+struct Page5 : public Page3, Page4{};
+// expected-error@+1 {{interface type cannot inherit from}}
+__interface PropertyPage2 : public Page5 {}; 
+
+__interface IF1 {};
+__interface PP : IUnknown, IF1{}; 
+__interface PP2 : PP, Page3, Page4{};
Index: cfe/trunk/lib/AST/DeclCXX.cpp
===
--- cfe/trunk/lib/AST/DeclCXX.cpp
+++ cfe/trunk/lib/AST/DeclCXX.cpp
@@ -1470,6 +1470,53 @@
   return false;
 }
 
+bool CXXRecordDecl::isInterfaceLike() const {
+  assert(hasDefinition() && "checking for interface-like without a definition");
+  // All __interfaces are inheritently interface-like.
+  if (isInterface())
+return true;
+
+  // Interface-like types cannot have a user declared constructor, destructor,
+  // friends, VBases, conversion functions, or fields.  Additionally, lambdas
+  // cannot be interface types.
+  if (isLambda() || hasUserDeclaredConstructor() ||
+  hasUserDeclaredDestructor() || !field_empty() || hasFriends() ||
+  getNumVBases() > 0 || conversion_end() - conversion_begin() > 0)
+return false;
+
+  // No interface-like type can have a method with a definition.
+  for (const auto *const Method : methods())
+if (Method->isDefined())
+  return false;
+
+  // Check "Special" types.
+  const auto *Uu

r313364 - Fix the __interface inheritence rules to work better with IUnknown and IDispatch

2017-09-15 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Sep 15 09:03:35 2017
New Revision: 313364

URL: http://llvm.org/viewvc/llvm-project?rev=313364&view=rev
Log:
Fix the __interface inheritence rules to work better with IUnknown and IDispatch

__interface objects in MSVC are permitted to inherit from __interface types, 
and interface-like types.

Additionally, there are two default interface-like types 
(IUnknown and IDispatch) that all interface-like
types must inherit from.

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

Added:
cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp   (with props)
cfe/trunk/test/SemaCXX/ms-iunknown-outofline-def.cpp   (with props)
cfe/trunk/test/SemaCXX/ms-iunknown.cpp   (with props)
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=313364&r1=313363&r2=313364&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Sep 15 09:03:35 2017
@@ -1831,6 +1831,10 @@ public:
 return getLambdaData().MethodTyInfo;
   }
 
+  // \brief Determine whether this type is an Interface Like type for
+  // __interface inheritence purposes.
+  bool isInterfaceLike() const;
+
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=313364&r1=313363&r2=313364&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Sep 15 09:03:35 2017
@@ -1470,6 +1470,53 @@ bool CXXRecordDecl::isAnyDestructorNoRet
   return false;
 }
 
+bool CXXRecordDecl::isInterfaceLike() const {
+  assert(hasDefinition() && "checking for interface-like without a 
definition");
+  // All __interfaces are inheritently interface-like.
+  if (isInterface())
+return true;
+
+  // Interface-like types cannot have a user declared constructor, destructor,
+  // friends, VBases, conversion functions, or fields.  Additionally, lambdas
+  // cannot be interface types.
+  if (isLambda() || hasUserDeclaredConstructor() ||
+  hasUserDeclaredDestructor() || !field_empty() || hasFriends() ||
+  getNumVBases() > 0 || conversion_end() - conversion_begin() > 0)
+return false;
+
+  // No interface-like type can have a method with a definition.
+  for (const auto *const Method : methods())
+if (Method->isDefined())
+  return false;
+
+  // Check "Special" types.
+  const auto *Uuid = getAttr();
+  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
+  ((getName() == "IUnknown" &&
+Uuid->getGuid() == "---C000-0046") ||
+   (getName() == "IDispatch" &&
+Uuid->getGuid() == "00020400---C000-0046"))) {
+if (getNumBases() > 0)
+  return false;
+return true;
+  }
+
+  // FIXME: Any access specifiers is supposed to make this no longer interface
+  // like.
+
+  // If this isn't a 'special' type, it must have a single interface-like base.
+  if (getNumBases() != 1)
+return false;
+
+  const auto BaseSpec = *bases_begin();
+  if (BaseSpec.isVirtual() || BaseSpec.getAccessSpecifier() != AS_public)
+return false;
+  const auto *Base = BaseSpec.getType()->getAsCXXRecordDecl();
+  if (Base->isInterface() || !Base->isInterfaceLike())
+return false;
+  return true;
+}
+
 void CXXRecordDecl::completeDefinition() {
   completeDefinition(nullptr);
 }

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=313364&r1=313363&r2=313364&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Sep 15 09:03:35 2017
@@ -2388,7 +2388,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecor
   if (const RecordType *Record = NewBaseType->getAs()) {
 const CXXRecordDecl *RD = cast(Record->getDecl());
 if (Class->isInterface() &&
-  (!RD->isInterface() ||
+  (!RD->isInterfaceLike() ||
KnownBase->getAccessSpecifier() != AS_public)) {
   // The Microsoft extension __interface does not permit bases that
   // are not themselves public interfaces.

Added: cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown-inline-def.cpp?rev=313364&view=auto
==
--- cfe/trunk/test/SemaCXX/ms-iunknown-inli

[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I did read through it now. In general, the code is sound with my understanding 
of the complexity metric and there is a almost one to one wording to the 
document, which is nice.
Since we chatted in IRC directly, i would give a short summary to avoid 
forgetting what we talked about :)

- the enum is specially optimized for size. the bitfield representation does 
not directly give a benefit, but will force maintainers to think about the enum 
size
- `Increment; Traverse; Decrement;` is for checking the newly created nesting 
level -> this was unclear to me, but after clarification pretty easy to 
understand
- maybe add additional diagnostics on to deep nesting, sidetalk
- class traversal not necessary, since the methods are done directly. Maybe 
later addition to find complex classes
- some testcases for templatefunctions to demonstrate basic functionality
- one testcase for a standalone class, that is not defined within a function 
body.




Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:228-234
+// if   increases nesting level
+++CurrentNestingLevel;
+ShouldContinue = TraverseStmt(Node->getThen());
+--CurrentNestingLevel;
+
+if (!ShouldContinue || !Node->getElse())
+  return ShouldContinue;

line 228-234 are a pattern, existing in all traversals. i think it could be 
refactored into its own function with a descriptive name. Especially the 
increment, traverse, decrement isn't obvious immediatly, but when noting its 
blockyness it is.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:507
+
+  bool TraverseDecl(Decl *Node, bool MainAnalyzedFunction = false) {
+if (!Node || MainAnalyzedFunction)

I assume this is the part applicable to class complexity? Maybe a short comment 
would clarify.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:584
+  for (const auto &Detail : Visitor.CC.Details) {
+const std::pair Reasoning(Detail.Process());
+diag(Detail.Loc, Reasoning.first, DiagnosticIDs::Note)

What would you think about the following:
```
const char *IncreaseMessage = nullptr;
unsigned short Increase = 0;
std::tie(IncreaseMessage, Increase) = Reasoning(Detail.Process());
```

Would be applicable elsewhere too. It's more going to the C++17 structured 
bindings and good potential target for futurue `modernize-` checks ;)
And i think it would be more readable.



Comment at: docs/ReleaseNotes.rst:138
+
+  Checks function Cognitive Complexity metric, and flags the functions with
+  Cognitive Complexity exceeding the configured limit.

How about
'Applies the Cognitive Complexity metric to functions (classes?), flagging 
those exceeding the configured limit/threshold'



Comment at: 
docs/clang-tidy/checks/readability-function-cognitive-complexity.rst:10
+`_ specification
+version 1.2 (19 April 2017), with two notable exceptions:
+   * `preprocessor conditionals` (`#ifdef`, `#if`, `#elif`, `#else`, `#endif`)

One or two sentences for the general thought would be nice for the quick 
reader, who doesn't like pdfs.

Noting, that the metric adds additional penalties for nesting and that switch 
cases are not the same complexity as if/else-if chains would be enough.



Comment at: 
docs/clang-tidy/checks/readability-function-cognitive-complexity.rst:11
+version 1.2 (19 April 2017), with two notable exceptions:
+   * `preprocessor conditionals` (`#ifdef`, `#if`, `#elif`, `#else`, `#endif`)
+ are not accounted for. Could be done.

This should land in a sperate `Limitations` section, similar to other checks.



Comment at: test/clang-tidy/readability-function-cognitive-complexity.cpp:23
+// in one go. none of the following should increase cognitive complexity:
+void unittest_false() {
+  {};

What happens in a codeblock like this:

```
void f() {
  { // nesting is increased, but not complexity, right? There is no occurence 
of a 'count' event
throw i;
  }
}
```



Comment at: test/clang-tidy/readability-function-cognitive-complexity.cpp:227
+// CHECK-NOTES: :[[@LINE-3]]:14: note: +1{{$}}
+  }
+}

what happens if you mix the unary operator in?

`if(1 || (1 && !1) || !boolean)`



Comment at: test/clang-tidy/readability-function-cognitive-complexity.cpp:481
+// CHECK-NOTES: :[[@LINE-1]]:13: note: +2, including nesting penalty of 1, 
nesting level increased to 2{{$}}
+// FIXME: would be nice to point at the '?' symbol. does not seem to be 
possible
+  }

did you try to get `getTrueExpr`/`getFalseExpr` and point to their respective 
end/beginning?


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



__

[PATCH] D37905: [libclang, bindings]: add spelling location

2017-09-15 Thread Masud Rahman via Phabricator via cfe-commits
frutiger added a comment.

**Please note**:

- this change means that versions of `libclang` built prior to the introduction 
of `clang_getExpansionLocation` will not work.
- this change alters the behavior of `clang_getSpellingLocation` to return the 
spelling location

I would appreciate advice on if either of these changes are acceptable.  Thank 
you.


https://reviews.llvm.org/D37905



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


[PATCH] D37905: [libclang, bindings]: add spelling location

2017-09-15 Thread Masud Rahman via Phabricator via cfe-commits
frutiger created this revision.

o) Enhance 'CursorLocation' with four additional properties that can

  retrieve spelling location information.

o) Update the implementation to use 'clang_getExpansionLocation'

  instead of the deprecated 'clang_getInstantiationLocation', which
  has been present since 2011.

o) Update the implementation of 'clang_getSpellingLocation' to actually

  obtain spelling location instead of file location.


https://reviews.llvm.org/D37905

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_location.py
  tools/libclang/CXSourceLocation.cpp

Index: tools/libclang/CXSourceLocation.cpp
===
--- tools/libclang/CXSourceLocation.cpp
+++ tools/libclang/CXSourceLocation.cpp
@@ -319,7 +319,7 @@
   const SourceManager &SM =
   *static_cast(location.ptr_data[0]);
   // FIXME: This should call SourceManager::getSpellingLoc().
-  SourceLocation SpellLoc = SM.getFileLoc(Loc);
+  SourceLocation SpellLoc = SM.getSpellingLoc(Loc);
   std::pair LocInfo = SM.getDecomposedLoc(SpellLoc);
   FileID FID = LocInfo.first;
   unsigned FileOffset = LocInfo.second;
Index: bindings/python/tests/cindex/test_location.py
===
--- bindings/python/tests/cindex/test_location.py
+++ bindings/python/tests/cindex/test_location.py
@@ -93,3 +93,10 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 assert range1 != range3
+
+def test_spelling_location():
+tu = get_tu('''#define ONE int one
+ONE;''')
+one = get_cursor(tu, 'one')
+assert one.location.spelling_line == 1
+assert one.location.line == 2
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -217,19 +217,48 @@
 A SourceLocation represents a particular location within a source file.
 """
 _fields_ = [("ptr_data", c_void_p * 2), ("int_data", c_uint)]
-_data = None
-
-def _get_instantiation(self):
-if self._data is None:
-f, l, c, o = c_object_p(), c_uint(), c_uint(), c_uint()
-conf.lib.clang_getInstantiationLocation(self, byref(f), byref(l),
-byref(c), byref(o))
-if f:
-f = File(f)
-else:
-f = None
-self._data = (f, int(l.value), int(c.value), int(o.value))
-return self._data
+_expansion_data = None
+_spelling_data  = None
+
+def _get_expansion(self):
+if self._expansion_data is None:
+expansion_file   = c_object_p()
+expansion_line   = c_uint()
+expansion_column = c_uint()
+expansion_offset = c_uint()
+conf.lib.clang_getExpansionLocation(self,
+byref(expansion_file),
+byref(expansion_line),
+byref(expansion_column),
+byref(expansion_offset))
+
+self._expansion_data = {
+'file':   File(expansion_file) if expansion_file else None,
+'line':   int(expansion_line.value),
+'column': int(expansion_column.value),
+'offset': int(expansion_offset.value),
+}
+return self._expansion_data
+
+def _get_spelling(self):
+if self._spelling_data is None:
+spelling_file   = c_object_p()
+spelling_line   = c_uint()
+spelling_column = c_uint()
+spelling_offset = c_uint()
+conf.lib.clang_getSpellingLocation(self,
+   byref(spelling_file),
+   byref(spelling_line),
+   byref(spelling_column),
+   byref(spelling_offset))
+
+self._spelling_data = {
+'file':   File(spelling_file) if spelling_file else None,
+'line':   int(spelling_line.value),
+'column': int(spelling_column.value),
+'offset': int(spelling_offset.value),
+}
+return self._spelling_data
 
 @staticmethod
 def from_position(tu, file, line, column):
@@ -252,22 +281,42 @@
 @property
 def file(self):
 """Get the file represented by this source location."""
-return self._get_instantiation()[0]
+return self._get_expansion()['file']
 
 @property
 def line(self):
 """Get the line represented by this source location."""
-return self._get_instantiation()[1]
+return self._get_expansion()['line']
 
 @property
 def column(self):
 """Get 

[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
Herald added a subscriber: klimek.

NamespaceEndCommentsFixer did not fix namespace comments when the brace opening 
the namespace was not on the same line as the "namespace" keyword.
It occurs in Allman, GNU and Linux styles and whenever 
BraceWrapping.AfterNamespace is true.

Before:

  namespace a
  {
  void f();
  void g();
  }

After:

  namespace a
  {
  void f();
  void g();
  } // namespace a


https://reviews.llvm.org/D37904

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1413,7 +1413,7 @@
   verifyFormat("typedef enum {} EmptyEnum;");
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum {\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -1425,7 +1425,7 @@
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum\n"
"{\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -9323,7 +9323,7 @@
"struct B {\n"
"  int x;\n"
"};\n"
-   "}\n",
+   "} // namespace a\n",
LinuxBraceStyle);
   verifyFormat("enum X {\n"
"  Y = 0,\n"
@@ -9453,6 +9453,19 @@
 TEST_F(FormatTest, AllmanBraceBreaking) {
   FormatStyle AllmanBraceStyle = getLLVMStyle();
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+
+  EXPECT_EQ("namespace a\n"
+"{\n"
+"void f();\n"
+"void g();\n"
+"} // namespace a\n",
+format("namespace a\n"
+   "{\n"
+   "void f();\n"
+   "void g();\n"
+   "}\n",
+   AllmanBraceStyle));
+
   verifyFormat("namespace a\n"
"{\n"
"class A\n"
@@ -9471,7 +9484,7 @@
"{\n"
"  int x;\n"
"};\n"
-   "}",
+   "} // namespace a",
AllmanBraceStyle);
 
   verifyFormat("void f()\n"
@@ -9677,7 +9690,7 @@
"  }\n"
"  void g() { return; }\n"
"}\n"
-   "}",
+   "} // namespace a",
GNUBraceStyle);
 
   verifyFormat("void f()\n"
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -118,6 +118,12 @@
 return nullptr;
   assert(StartLineIndex < AnnotatedLines.size());
   const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First;
+  if (NamespaceTok->is(tok::l_brace)) {
+// "namespace" keyword can be on the line preceding '{', e.g. in styles
+// where BraceWrapping.AfterNamespace is true.
+if (StartLineIndex > 0)
+  NamespaceTok = AnnotatedLines[StartLineIndex - 1]->First;
+  }
   // Detect "(inline)? namespace" in the beginning of a line.
   if (NamespaceTok->is(tok::kw_inline))
 NamespaceTok = NamespaceTok->getNextNonComment();


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1413,7 +1413,7 @@
   verifyFormat("typedef enum {} EmptyEnum;");
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum {\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -1425,7 +1425,7 @@
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum\n"
"{\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -9323,7 +9323,7 @@
"struct B {\n"
"  int x;\n"
"};\n"
-   "}\n",
+   "} // namespace a\n",
LinuxBraceStyle);
   verifyFormat("enum X {\n"
"  Y = 0,\n"
@@ -9453,6 +9453,19 @@
 TEST_F(FormatTest, AllmanBraceBreaking) {
   FormatStyle AllmanBraceStyle = getLLVMStyle();
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+
+  EXPECT_EQ("namespace a\n"
+"{\n"
+"void f();\n"
+"void g();\n"
+"} // namespace a\n",
+format("namespace a\n"
+   "{\n"
+   "void f();\n"
+   "void g(

[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-15 Thread Micah Werbitt via Phabricator via cfe-commits
werbitt created this revision.

When 'buffer-file-name' is nil 'call-process-region' returned a segmentation 
fault error.

This was a problem when using clang-format-buffer on an orgmode source code 
editing buffer.

I fixed this problem by excluding the '-assume-filename' argument when 
'buffer-file-name' is nil.

To make it a bit more flexible I also added an optional argument, 
'assume-file', to specify an assume-filename that overrides 'buffer-file-name'.


https://reviews.llvm.org/D37903

Files:
  tools/clang-format/clang-format.el


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,7 +119,7 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file)
   "Use clang-format to format the code between START and END according to 
STYLE.
 If called interactively uses the region or the current statement if there
 is no active region.  If no style is given uses `clang-format-style'."
@@ -131,6 +131,9 @@
   (unless style
 (setq style clang-format-style))
 
+  (unless assume-file
+(setq assume-file buffer-file-name))
+
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
 'utf-8-unix))
 (file-end (clang-format--bufferpos-to-filepos end 'approximate
@@ -144,16 +147,16 @@
 ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
 (default-process-coding-system '(utf-8-unix . utf-8-unix)))
 (unwind-protect
-(let ((status (call-process-region
-   nil nil clang-format-executable
-   nil `(,temp-buffer ,temp-file) nil
-
-   "-output-replacements-xml"
-   "-assume-filename" (or (buffer-file-name) "")
-   "-style" style
-   "-offset" (number-to-string file-start)
-   "-length" (number-to-string (- file-end file-start))
-   "-cursor" (number-to-string cursor)))
+(let ((status (apply 'call-process-region
+ (append `(nil nil ,clang-format-executable
+   nil (,temp-buffer ,temp-file) nil)
+ '("-output-replacements-xml")
+ (if assume-file
+ `("-assume-filename" ,assume-file) 
nil)
+ `("-style" ,style
+   "-offset" ,(number-to-string file-start)
+   "-length" ,(number-to-string (- 
file-end file-start))
+   "-cursor" ,(number-to-string cursor)
   (stderr (with-temp-buffer
 (unless (zerop (cadr (insert-file-contents temp-file)))
   (insert ": "))
@@ -181,10 +184,10 @@
   (when (buffer-name temp-buffer) (kill-buffer temp-buffer)
 
 ;;;###autoload
-(defun clang-format-buffer (&optional style)
+(defun clang-format-buffer (&optional style assume-file)
   "Use clang-format to format the current buffer according to STYLE."
   (interactive)
-  (clang-format-region (point-min) (point-max) style))
+  (clang-format-region (point-min) (point-max) style assume-file))
 
 ;;;###autoload
 (defalias 'clang-format 'clang-format-region)


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,7 +119,7 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file)
   "Use clang-format to format the code between START and END according to STYLE.
 If called interactively uses the region or the current statement if there
 is no active region.  If no style is given uses `clang-format-style'."
@@ -131,6 +131,9 @@
   (unless style
 (setq style clang-format-style))
 
+  (unless assume-file
+(setq assume-file buffer-file-name))
+
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
 'utf-8-unix))
 (file-end (clang-format--bufferpos-to-filepos end 'approximate
@@ -144,16 +147,16 @@
 ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
 (default-process-coding-system '(utf-8-unix . utf-8-unix)))
 (unwind-protect
-(let ((status (call-process-region
-   nil nil clang-format-executable
-   nil `(,temp-buffer ,temp-file) nil
-
-   "-output-replacements-xml"
-  

[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Looking up to the Visitor, i will do this next.




Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:27
+  // Here are all the possible reasons:
+  enum Criteria : unsigned char {
+None = 0,

i think clarifying which language constructs relative to what criteria would 
help here.

with the document next to me here its clear, but i think we shouldn't expect 
that. a link/refernce to the page would be nice, too.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:51
+const SourceLocation Loc; // what caused the increment?
+const unsigned short Nesting; // how deeply nestedly is Loc located?
+const Criteria C : 3; // the criteria of the increment

s/nestedly/nested/

and make the trailing comments doxygen style? might help, but not so important 
i think.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:52
+const unsigned short Nesting; // how deeply nestedly is Loc located?
+const Criteria C : 3; // the criteria of the increment
+

is this a bitfield? How does it help here? A byte should already be started 
anyway, so leaving 5 bits empty wouldn't have an impact on the size of `Detail`



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:57
+
+// To minimize the the sizeof(Detail), we only store the minimal info 
there.
+// This function is used to convert from the stored info into the usable

duplicated 'the'



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:62
+std::pair Process() const {
+  assert(C != Criteria::None && "invalid criteria");
+

You acces `Critera` always scoped. I think you could declare `Criteria` to be a 
`enum class`, not just a plain `enum`



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:102-114
+const std::array CognitiveComplexity::Msgs = {{
+// B1 + B2 + B3
+"+%0, including nesting penalty of %1, nesting level increased to %2",
+
+// B1 + B2
+"+%0, nesting level increased to %2",
+

could this initialization land in line 45? that would be directly close to the 
criteria. 



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:116-146
+// Criteria is a bitset, thus a few helpers are needed
+static CognitiveComplexity::Criteria
+operator|(CognitiveComplexity::Criteria lhs,
+  CognitiveComplexity::Criteria rhs) {
+  return static_cast(
+  static_cast::type>(
+  lhs) |

`Criteria` could be moved out of the `Detail` struct. That would allow closer 
definiton of the helper code to the `enum`.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:154
+  Details.emplace_back(Loc, Nesting, C);
+  const Detail &d(Details.back());
+

s/d/D/ naming convention



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:168
+  // Used to efficiently know the last type of binary sequence operator that
+  // was encoutered. It would make sense for the function call to start the
+  // new sequence, thus it is a stack.

s/encoutered/encountered/


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D20689: [clang-tidy] Suspicious Call Argument checker

2017-09-15 Thread Barancsuk Lilla via Phabricator via cfe-commits
barancsuk added a comment.

@alexfh, would you mind taking a look at the changes that have been introduced 
in the new patch?

The main improvements are:

- The checker has been shifted to the module `readability`.
- It is checked, whether implicit type conversion is possible from the argument 
to the parameter.

I have run the modified checker on some large code bases with the following 
results:
 (The errors were categorized subjectively.)

- **PostgreSQL:** 32 renaming opportunities of 39 warnings
- **Cpython:** 10 renaming opportunities of 15 warnings
- **Xerces:** 6 renaming opportunities of 8 warnings
- **FFmpeg**:  5 renaming opportunities of 9 warnings
- **OpenSSL:** 3 renaming opportunities of 4 warnings
- **LLVM:** 20 renaming opportunities of 44 warnings

This article provides some evidence to support the feasibility of the checker 
as well. 
F5358417: icse2016-names.pdf  
The authors have proven that argument names are generally very similar to the 
corresponding parameters' names. 
The presented empirical evidence also shows, that argument and parameter name 
dissimilarities are strong indicators of incorrect argument usages, or they 
identify renaming opportunities to improve code readability. 
Moreover the authors have even found 3 existing bugs in open source projects.


https://reviews.llvm.org/D20689



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: sbenza, JonasToth.
aaron.ballman added a comment.

Adding a few reviewers to hopefully help Roman get some feedback.


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-09-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Any further reviews?
What are the criteria to accept this patch? Who or how many people should 
accept this?


https://reviews.llvm.org/D34512



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


[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file

2017-09-15 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D37299



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


[PATCH] D37846: [clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets

2017-09-15 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313355: [clang-tidy] Fixed misc-unused-parameters omitting 
parameters square brackets (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D37846?vs=115369&id=115395#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37846

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
@@ -138,8 +138,7 @@
   if (Function->isExternallyVisible() ||
   !Result.SourceManager->isInMainFile(Function->getLocation()) ||
   !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) {
-SourceRange RemovalRange(Param->getLocation(),
- Param->DeclaratorDecl::getSourceRange().getEnd());
+SourceRange RemovalRange(Param->getLocation());
 // Note: We always add a space before the '/*' to not accidentally create a
 // '*/*' for pointer types, which doesn't start a comment. clang-format will
 // clean this up afterwards.
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
@@ -20,11 +20,26 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused [misc-unused-parameters]
 // CHECK-FIXES: {{^}}void c(int * /*i*/) {}{{$}}
 
+void d(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
+// CHECK-FIXES: {{^}}void d(int  /*i*/[]) {}{{$}}
+
+void e(int i[1]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
+// CHECK-FIXES: {{^}}void e(int  /*i*/[1]) {}{{$}}
+
+void f(void (*fn)()) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: parameter 'fn' is unused [misc-unused-parameters]
+// CHECK-FIXES: {{^}}void f(void (* /*fn*/)()) {}{{$}}
+
 // Unchanged cases
 // ===
 void f(int i); // Don't remove stuff in declarations
 void g(int i = 1);
-void h(int i) { (void)i; } // Don't remove used parameters
+void h(int i[]);
+void s(int i[1]);
+void u(void (*fn)());
+void w(int i) { (void)i; } // Don't remove used parameters
 
 bool useLambda(int (*fn)(int));
 static bool static_var = useLambda([] (int a) { return a; });
@@ -59,6 +74,18 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning
 // CHECK-FIXES: {{^}}static void staticFunctionF()
 
+static void staticFunctionG(int i[]);
+// CHECK-FIXES: {{^}}static void staticFunctionG();
+static void staticFunctionG(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
+// CHECK-FIXES: {{^}}static void staticFunctionG()
+
+static void staticFunctionH(void (*fn)());
+// CHECK-FIXES: {{^}}static void staticFunctionH();
+static void staticFunctionH(void (*fn)()) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:36: warning
+// CHECK-FIXES: {{^}}static void staticFunctionH()
+
 static void someCallSites() {
   staticFunctionA(1);
 // CHECK-FIXES: staticFunctionA();
@@ -74,6 +101,12 @@
 // CHECK-FIXES: staticFunctionF();
   staticFunctionF();
 // CHECK-FIXES: staticFunctionF();
+  int t[] = {1};
+  staticFunctionG(t);
+// CHECK-FIXES: staticFunctionG();
+  void func();
+  staticFunctionH(&func);
+// CHECK-FIXES: staticFunctionH();
 }
 
 /*
@@ -109,6 +142,12 @@
   static void g(int i = 1) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning
 // CHECK-FIXES: static void g(int  /*i*/ = 1) {}
+  static void h(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning
+// CHECK-FIXES: static void h(int  /*i*/[]) {}
+  static void s(void (*fn)()) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning
+// CHECK-FIXES: static void s(void (* /*fn*/)()) {}
 };
 
 namespace {
@@ -125,6 +164,12 @@
   void s(int i = 1) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning
 // CHECK-FIXES: void s(int  /*i*/ = 1) {}
+  void u(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
+// CHECK-FIXES: void u(int  /*i*/[]) {}
+  void w(void (*fn)()) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning
+// CHECK-FIXES: void w(void (* /*fn*/)()) {}
 };
 
 void C::f(int i) {}
@@ -142,7 +187,9 @@
 // CHECK-FIXES: c.g();
 
   useFunction(&C::h);
-  useFunction(&C::s);;
+  useFunction(&C::s);
+  useFunction(&C::u);
+  useFunction(&C::w);
 }
 
 class Base {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r313355 - [clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets

2017-09-15 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Sep 15 04:28:28 2017
New Revision: 313355

URL: http://llvm.org/viewvc/llvm-project?rev=313355&view=rev
Log:
[clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets

Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34449

**Problem:**

Clang-tidy check misc-unused-parameters comments out parameter name omitting 
following characters (e.g. square brackets) what results in its complete 
removal. Compilation errors might occur after clang-tidy fix as well.

**Patch description:**

Changed removal range. The range should end after parameter name, not after 
whole parameter declarator (which might be followed by e.g. square brackets).

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Patch by Pawel Maciocha!

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp?rev=313355&r1=313354&r2=313355&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp Fri Sep 
15 04:28:28 2017
@@ -138,8 +138,7 @@ void UnusedParametersCheck::warnOnUnused
   if (Function->isExternallyVisible() ||
   !Result.SourceManager->isInMainFile(Function->getLocation()) ||
   !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) {
-SourceRange RemovalRange(Param->getLocation(),
- Param->DeclaratorDecl::getSourceRange().getEnd());
+SourceRange RemovalRange(Param->getLocation());
 // Note: We always add a space before the '/*' to not accidentally create a
 // '*/*' for pointer types, which doesn't start a comment. clang-format 
will
 // clean this up afterwards.

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp?rev=313355&r1=313354&r2=313355&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Fri Sep 
15 04:28:28 2017
@@ -20,11 +20,26 @@ void c(int *i) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused 
[misc-unused-parameters]
 // CHECK-FIXES: {{^}}void c(int * /*i*/) {}{{$}}
 
+void d(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused 
[misc-unused-parameters]
+// CHECK-FIXES: {{^}}void d(int  /*i*/[]) {}{{$}}
+
+void e(int i[1]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused 
[misc-unused-parameters]
+// CHECK-FIXES: {{^}}void e(int  /*i*/[1]) {}{{$}}
+
+void f(void (*fn)()) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: parameter 'fn' is unused 
[misc-unused-parameters]
+// CHECK-FIXES: {{^}}void f(void (* /*fn*/)()) {}{{$}}
+
 // Unchanged cases
 // ===
 void f(int i); // Don't remove stuff in declarations
 void g(int i = 1);
-void h(int i) { (void)i; } // Don't remove used parameters
+void h(int i[]);
+void s(int i[1]);
+void u(void (*fn)());
+void w(int i) { (void)i; } // Don't remove used parameters
 
 bool useLambda(int (*fn)(int));
 static bool static_var = useLambda([] (int a) { return a; });
@@ -59,6 +74,18 @@ static void staticFunctionF(int i) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning
 // CHECK-FIXES: {{^}}static void staticFunctionF()
 
+static void staticFunctionG(int i[]);
+// CHECK-FIXES: {{^}}static void staticFunctionG();
+static void staticFunctionG(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
+// CHECK-FIXES: {{^}}static void staticFunctionG()
+
+static void staticFunctionH(void (*fn)());
+// CHECK-FIXES: {{^}}static void staticFunctionH();
+static void staticFunctionH(void (*fn)()) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:36: warning
+// CHECK-FIXES: {{^}}static void staticFunctionH()
+
 static void someCallSites() {
   staticFunctionA(1);
 // CHECK-FIXES: staticFunctionA();
@@ -74,6 +101,12 @@ static void someCallSites() {
 // CHECK-FIXES: staticFunctionF();
   staticFunctionF();
 // CHECK-FIXES: staticFunctionF();
+  int t[] = {1};
+  staticFunctionG(t);
+// CHECK-FIXES: staticFunctionG();
+  void func();
+  staticFunctionH(&func);
+// CHECK-FIXES: staticFunctionH();
 }
 
 /*
@@ -109,6 +142,12 @@ class SomeClass {
   static void g(int i = 1) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning
 // CHECK-FIXES: static void g(int  /*i*/ = 1) {}
+  static void h(int i[]) {}
+// CHECK-MESSAGES: :[[@LINE-1]

[PATCH] D37845: [clang-format] New flag - BraceWrapping.AfterExternBlock

2017-09-15 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313354: [clang-format] New flag - 
BraceWrapping.AfterExternBlock (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D37845?vs=115240&id=115394#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37845

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/docs/ClangFormatStyleOptions.rst
===
--- cfe/trunk/docs/ClangFormatStyleOptions.rst
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst
@@ -661,6 +661,21 @@
 int x;
   }
 
+  * ``bool AfterExternBlock`` Wrap extern blocks.
+
+.. code-block:: c++
+
+  true:
+  extern "C"
+  {
+int foo();
+  }
+
+  false:
+  extern "C" {
+  int foo();
+  }
+
   * ``bool BeforeCatch`` Wrap before ``catch``.
 
 .. code-block:: c++
Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -681,6 +681,20 @@
 ///   }
 /// \endcode
 bool AfterUnion;
+/// \brief Wrap extern blocks.
+/// \code
+///   true:
+///   extern "C"
+///   {
+/// int foo();
+///   }
+///
+///   false:
+///   extern "C" {
+///   int foo();
+///   }
+/// \endcode
+bool AfterExternBlock;
 /// \brief Wrap before ``catch``.
 /// \code
 ///   true:
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -233,9 +233,10 @@
   if (Tok && Tok->is(tok::kw_typedef))
 Tok = Tok->getNextNonComment();
   if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union,
-  Keywords.kw_interface))
+  tok::kw_extern, Keywords.kw_interface))
 return !Style.BraceWrapping.SplitEmptyRecord && EmptyBlock
-? tryMergeSimpleBlock(I, E, Limit) : 0;
+   ? tryMergeSimpleBlock(I, E, Limit)
+   : 0;
 }
 
 // FIXME: TheLine->Level != 0 might or might not be the right check to do.
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1039,7 +1039,12 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+if (Style.BraceWrapping.AfterExternBlock) {
+  addUnwrappedLine();
+  parseBlock(/*MustBeDeclaration=*/true);
+} else {
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+}
 addUnwrappedLine();
 return;
   }
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -420,6 +420,7 @@
 IO.mapOptional("AfterObjCDeclaration", Wrapping.AfterObjCDeclaration);
 IO.mapOptional("AfterStruct", Wrapping.AfterStruct);
 IO.mapOptional("AfterUnion", Wrapping.AfterUnion);
+IO.mapOptional("AfterExternBlock", Wrapping.AfterExternBlock);
 IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
 IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
 IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
@@ -500,9 +501,9 @@
   if (Style.BreakBeforeBraces == FormatStyle::BS_Custom)
 return Style;
   FormatStyle Expanded = Style;
-  Expanded.BraceWrapping = {false, false, false, false, false, false,
-false, false, false, false, false, true,
-true,  true};
+  Expanded.BraceWrapping = {false, false, false, false, false, false, 
+false, false, false, false, false, false, 
+true,  true,  true};
   switch (Style.BreakBeforeBraces) {
   case FormatStyle::BS_Linux:
 Expanded.BraceWrapping.AfterClass = true;
@@ -515,6 +516,7 @@
 Expanded.BraceWrapping.AfterFunction = true;
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
+Expanded.BraceWrapping.AfterExternBlock = true;
 Expanded.BraceWrapping.SplitEmptyFunction = true;
 Expanded.BraceWrapping.SplitEmptyRecord = false;
 break;
@@ -531,13 +533,14 @@
 Expanded.BraceWrapping.AfterNamespace = true;
 Expanded.BraceWrappi

[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

2017-09-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I have some comments and questions but maybe you do not want to address those 
until Devin, NoQ, or Anna approved the general directions.




Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:107
+/** Recursively check if variable is changed in code. */
+static bool isChanged(const Stmt *S, const VarDecl *VD, bool Write) {
+  if (!S)

Usually, we do not like bug recursions since it might eat up the stack. 
Also, do you consider the case when the variable is passed by reference to a 
function in another translation unit? 



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:169
+  SVal Constraint_untested =
+  evalBinOp(State, BO_EQ, V, svalBuilder.makeIntVal(InitVal),
+svalBuilder.getConditionType());

Does this work for non-integer typed e.g. structs? 


Repository:
  rL LLVM

https://reviews.llvm.org/D37897



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


r313354 - [clang-format] New flag - BraceWrapping.AfterExternBlock

2017-09-15 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Sep 15 04:23:50 2017
New Revision: 313354

URL: http://llvm.org/viewvc/llvm-project?rev=313354&view=rev
Log:
[clang-format] New flag - BraceWrapping.AfterExternBlock

Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - **"extern C part"**

**Problem:**

Due to the lack of "brace wrapping extern" flag, clang format does parse the 
block after **extern** keyword moving the opening bracket to the header line 
always!

**Patch description:**

A new style added, new configuration flag - **BraceWrapping.AfterExternBlock** 
that allows us to decide whether we want a break before brace or not.

Reviewers: djasper, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

Contributed by @PriMee!

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=313354&r1=313353&r2=313354&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Fri Sep 15 04:23:50 2017
@@ -661,6 +661,21 @@ the configuration (without a prefix: ``A
 int x;
   }
 
+  * ``bool AfterExternBlock`` Wrap extern blocks.
+
+.. code-block:: c++
+
+  true:
+  extern "C"
+  {
+int foo();
+  }
+
+  false:
+  extern "C" {
+  int foo();
+  }
+
   * ``bool BeforeCatch`` Wrap before ``catch``.
 
 .. code-block:: c++

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=313354&r1=313353&r2=313354&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri Sep 15 04:23:50 2017
@@ -681,6 +681,20 @@ struct FormatStyle {
 ///   }
 /// \endcode
 bool AfterUnion;
+/// \brief Wrap extern blocks.
+/// \code
+///   true:
+///   extern "C"
+///   {
+/// int foo();
+///   }
+///
+///   false:
+///   extern "C" {
+///   int foo();
+///   }
+/// \endcode
+bool AfterExternBlock;
 /// \brief Wrap before ``catch``.
 /// \code
 ///   true:

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=313354&r1=313353&r2=313354&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Sep 15 04:23:50 2017
@@ -420,6 +420,7 @@ template <> struct MappingTraitshttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=313354&r1=313353&r2=313354&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Fri Sep 15 04:23:50 2017
@@ -233,9 +233,10 @@ private:
   if (Tok && Tok->is(tok::kw_typedef))
 Tok = Tok->getNextNonComment();
   if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union,
-  Keywords.kw_interface))
+  tok::kw_extern, Keywords.kw_interface))
 return !Style.BraceWrapping.SplitEmptyRecord && EmptyBlock
-? tryMergeSimpleBlock(I, E, Limit) : 0;
+   ? tryMergeSimpleBlock(I, E, Limit)
+   : 0;
 }
 
 // FIXME: TheLine->Level != 0 might or might not be the right check to do.

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=313354&r1=313353&r2=313354&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Sep 15 04:23:50 2017
@@ -1039,7 +1039,12 @@ void UnwrappedLineParser::parseStructura
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+if (Style.BraceWrapping.AfterExternBlock) {
+  addUnwrappedLine();
+  parseBlock(/*MustBeDeclaration=*/true);
+} else {
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+}
 addUnwrappedLine();
 return;
   }

Modified: cfe/trunk/unittests/Format/FormatTest.

[PATCH] D37846: [clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets

2017-09-15 Thread Pawel Maciocha via Phabricator via cfe-commits
PriMee added a comment.

Thank you!


https://reviews.llvm.org/D37846



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


[PATCH] D37846: [clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets

2017-09-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. I'll commit the patch for you.


https://reviews.llvm.org/D37846



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


  1   2   >