[PATCH] D39543: [analyzer] Document the issue hash debugging facility

2017-11-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

> these kinds of tasks should have the same level of attention as others

Dunno really. I'm not sure anybody actually reads that doc instead of 
accidentally finding the checker code by debugging how the tests work.


https://reviews.llvm.org/D39543



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


[PATCH] D39834: [clangd] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-09 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk updated this revision to Diff 122395.
Quolyk retitled this revision from "[clangd][WIP] -foptimization-record-file= 
should imply -fsave-optimization-record" to "[clangd] 
-foptimization-record-file= should imply -fsave-optimization-record".
Quolyk added a comment.

Added 1 test, I guess it's sufficient


https://reviews.llvm.org/D39834

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/opt-record.c


Index: test/Driver/opt-record.c
===
--- test/Driver/opt-record.c
+++ test/Driver/opt-record.c
@@ -9,6 +9,7 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc 
-nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O 
-check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib 
%s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record 
-foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-EQ
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4376,6 +4376,11 @@
   llvm::sys::path::replace_extension(F, "opt.yaml");
   CmdArgs.push_back(Args.MakeArgString(F));
 }
+  } else {
+if (const Arg *A = 
Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
+  CmdArgs.push_back("-opt-record-file");
+  CmdArgs.push_back(A->getValue());
+}
   }
 
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,


Index: test/Driver/opt-record.c
===
--- test/Driver/opt-record.c
+++ test/Driver/opt-record.c
@@ -9,6 +9,7 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record -foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4376,6 +4376,11 @@
   llvm::sys::path::replace_extension(F, "opt.yaml");
   CmdArgs.push_back(Args.MakeArgString(F));
 }
+  } else {
+if (const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
+  CmdArgs.push_back("-opt-record-file");
+  CmdArgs.push_back(A->getValue());
+}
   }
 
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D39862#921075, @george.karpenkov wrote:

> Of course I'm new, but I disagree with this statement: in order to have a 
> robust API, the function should not crash, unless the caller violates an 
> explicit precondition.
>  `getSVal` is just a function for getting a symbolic value for a particular 
> statement, it seems totally valid to query it for an expression which type is 
> `void`.


Not for an expression - this overload retrieves a value stored in the memory 
region. I think that we should inform the checker's author when he tries to 
interpret the value in memory as a void value, because i believe that in pretty 
much all cases he has a better type to provide.




Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:265
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {

george.karpenkov wrote:
> NoQ wrote:
> > If a type is an integral or enumeration type or a Loc type, then it is 
> > definitely not null.
> But the check itself will crash if the type is null.
Whoops right sry.


Repository:
  rL LLVM

https://reviews.llvm.org/D39862



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


[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

Reverted in https://reviews.llvm.org/rL317877 -- I'm going to try again next 
week instead.


Repository:
  rL LLVM

https://reviews.llvm.org/D39114



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


r317877 - Revert "[XRay][darwin] Initial XRay in Darwin Support"

2017-11-09 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Nov  9 23:00:55 2017
New Revision: 317877

URL: http://llvm.org/viewvc/llvm-project?rev=317877=rev
Log:
Revert "[XRay][darwin] Initial XRay in Darwin Support"

This reverts r317875.

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

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=317877=317876=317877=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Nov  9 23:00:55 2017
@@ -30,7 +30,6 @@ public:
   XRayArgs(const ToolChain , const llvm::opt::ArgList );
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
-  bool needsXRayRt() const { return XRayInstrument; }
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=317877=317876=317877=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Nov  9 23:00:55 2017
@@ -18,7 +18,6 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
-#include "clang/Driver/XRayArgs.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
@@ -1099,11 +1098,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   if (Sanitize.needsEsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
 
-  const XRayArgs& XRay = getXRayArgs();
-  if (XRay.needsXRayRt() && isTargetMacOS()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.xray_osx.a", RLO_AlwaysLink);
-  }
-
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
   CmdArgs.push_back("-lSystem");

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=317877=317876=317877=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Nov  9 23:00:55 2017
@@ -51,15 +51,6 @@ XRayArgs::XRayArgs(const ToolChain ,
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
-else if (Triple.getOS() == llvm::Triple::Darwin)
-  // Experimental support for macos.
-  switch (Triple.getArch()) {
-  case llvm::Triple::x86_64:
-break;
-  default:
-D.Diag(diag::err_drv_clang_unsupported)
-<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
-  }
 else
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on non-Linux target OS");


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


[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

Landing now, will deal with the test and dynamic/




Comment at: compiler-rt/trunk/lib/xray/xray_trampoline_x86_64.S:75
 
-   .globl __xray_FunctionEntry
+   .globl ASM_TSAN_SYMBOL(__xray_FunctionEntry)
.align 16, 0x90

kubamracek wrote:
> Since we want to use `ASM_TSAN_SYMBOL` outside of TSan, can we rename it to 
> just `ASM_SYMBOL` (or something like that)?
Probably. I was thinking about doing that, but then ended up deciding against 
it.

I can make a change later to migrate all uses in compiler-rt (if someone 
doesn't beat me to it). :)


Repository:
  rL LLVM

https://reviews.llvm.org/D39114



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


[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added inline comments.



Comment at: compiler-rt/trunk/lib/xray/xray_trampoline_x86_64.S:75
 
-   .globl __xray_FunctionEntry
+   .globl ASM_TSAN_SYMBOL(__xray_FunctionEntry)
.align 16, 0x90

Since we want to use `ASM_TSAN_SYMBOL` outside of TSan, can we rename it to 
just `ASM_SYMBOL` (or something like that)?


Repository:
  rL LLVM

https://reviews.llvm.org/D39114



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


[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317875: [XRay][darwin] Initial XRay in Darwin Support 
(authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D39114?vs=122352=122391#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39114

Files:
  cfe/trunk/include/clang/Driver/XRayArgs.h
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/lib/Driver/XRayArgs.cpp
  compiler-rt/trunk/cmake/config-ix.cmake
  compiler-rt/trunk/lib/xray/CMakeLists.txt
  compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
  compiler-rt/trunk/lib/xray/weak_symbols.txt
  compiler-rt/trunk/lib/xray/xray_init.cc
  compiler-rt/trunk/lib/xray/xray_trampoline_x86_64.S
  compiler-rt/trunk/test/xray/TestCases/Darwin/always-never-instrument.cc
  compiler-rt/trunk/test/xray/TestCases/Darwin/lit.local.cfg
  compiler-rt/trunk/test/xray/TestCases/Linux/lit.local.cfg
  compiler-rt/trunk/test/xray/lit.cfg

Index: cfe/trunk/include/clang/Driver/XRayArgs.h
===
--- cfe/trunk/include/clang/Driver/XRayArgs.h
+++ cfe/trunk/include/clang/Driver/XRayArgs.h
@@ -30,6 +30,7 @@
   XRayArgs(const ToolChain , const llvm::opt::ArgList );
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
+  bool needsXRayRt() const { return XRayInstrument; }
 };
 
 } // namespace driver
Index: cfe/trunk/lib/Driver/XRayArgs.cpp
===
--- cfe/trunk/lib/Driver/XRayArgs.cpp
+++ cfe/trunk/lib/Driver/XRayArgs.cpp
@@ -51,6 +51,15 @@
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
+else if (Triple.getOS() == llvm::Triple::Darwin)
+  // Experimental support for macos.
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
 else
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on non-Linux target OS");
Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -18,6 +18,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
+#include "clang/Driver/XRayArgs.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
@@ -1098,6 +1099,11 @@
   if (Sanitize.needsEsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
 
+  const XRayArgs& XRay = getXRayArgs();
+  if (XRay.needsXRayRt() && isTargetMacOS()) {
+AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.xray_osx.a", RLO_AlwaysLink);
+  }
+
   // Otherwise link libSystem, then the dynamic runtime library, and finally any
   // target specific static runtime library.
   CmdArgs.push_back("-lSystem");
Index: compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
@@ -12,21 +12,50 @@
   -I${COMPILER_RT_SOURCE_DIR}/lib)
 
 set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})
+set(XRAY_LINK_FLAGS)
+append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_LINK_FLAGS)
+append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_LINK_FLAGS)
+append_list_if(COMPILER_RT_HAS_LIBPTHREAD -lpthread XRAY_LINK_FLAGS)
+
+if (APPLE)
+  list(APPEND XRAY_LINK_FLAGS -lc++)
+  list(APPEND XRAY_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
+  set(XRAY_TEST_RUNTIME_OBJECTS
+$
+$
+$)
+  set(XRAY_TEST_RUNTIME RTXRayTest)
+  add_library(${XRAY_TEST_RUNTIME} STATIC ${XRAY_TEST_RUNTIME_OBJECTS})
+  set_target_properties(${XRAY_TEST_RUNTIME} PROPERTIES
+ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+FOLDER "Compiler-RT Runtime tests")
+
+  darwin_filter_host_archs(XRAY_SUPPORTED_ARCH XRAY_TEST_ARCH)
+  list(APPEND XRAY_UNITTEST_CFLAGS ${DARWIN_osx_CFLAGS})
+  list(APPEND XRAY_LINK_FLAGS "-lc++")
+  list(APPEND XRAY_LINK_FLAGS "-fxray-instrument")
+  add_weak_symbols("sanitizer_common" XRAY_LINK_FLAGS)
+  add_weak_symbols("xray" XRAY_LINK_FLAGS)
+else()
+  append_list_if(COMPILER_RT_HAS_LIBSTDCXX lstdc++ XRAY_LINK_FLAGS)
+endif()
+
 macro(add_xray_unittest testname)
   cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})
-  if(UNIX AND NOT APPLE)
+  if(UNIX)
 foreach(arch ${XRAY_TEST_ARCH})
   set(TEST_OBJECTS)
   generate_compiler_rt_tests(TEST_OBJECTS
 XRayUnitTests "${testname}-${arch}-Test" "${arch}"
 SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
+RUNTIME ${XRAY_TEST_RUNTIME}
+

r317875 - [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Nov  9 21:50:13 2017
New Revision: 317875

URL: http://llvm.org/viewvc/llvm-project?rev=317875=rev
Log:
[XRay][darwin] Initial XRay in Darwin Support

Summary:
This change implements the changes required in both clang and
compiler-rt to allow building XRay-instrumented binaries in Darwin. For
now we limit this to x86_64. We also start building the XRay runtime
library in compiler-rt for osx.

A caveat to this is that we don't have the tests set up and running
yet, which we'll do in a set of follow-on changes.

This patch uses the monorepo layout for the coordinated change across
multiple projects.

Reviewers: kubamracek

Subscribers: mgorny, cfe-commits, llvm-commits

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

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

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=317875=317874=317875=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Nov  9 21:50:13 2017
@@ -30,6 +30,7 @@ public:
   XRayArgs(const ToolChain , const llvm::opt::ArgList );
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
+  bool needsXRayRt() const { return XRayInstrument; }
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=317875=317874=317875=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Nov  9 21:50:13 2017
@@ -18,6 +18,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
+#include "clang/Driver/XRayArgs.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
@@ -1098,6 +1099,11 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   if (Sanitize.needsEsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
 
+  const XRayArgs& XRay = getXRayArgs();
+  if (XRay.needsXRayRt() && isTargetMacOS()) {
+AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.xray_osx.a", RLO_AlwaysLink);
+  }
+
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
   CmdArgs.push_back("-lSystem");

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=317875=317874=317875=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Nov  9 21:50:13 2017
@@ -51,6 +51,15 @@ XRayArgs::XRayArgs(const ToolChain ,
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
+else if (Triple.getOS() == llvm::Triple::Darwin)
+  // Experimental support for macos.
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
 else
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on non-Linux target OS");


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


[PATCH] D39877: AMDGPU/NFC: Move getAMDGPUTargetFeatures to AMDGPU toolchain

2017-11-09 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D39877



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


r317873 - [X86] Reduce the number of FMA builtins needed by the frontend by adding negates to operands of the fmadd and fmaddsub builtins.

2017-11-09 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Nov  9 21:20:32 2017
New Revision: 317873

URL: http://llvm.org/viewvc/llvm-project?rev=317873=rev
Log:
[X86] Reduce the number of FMA builtins needed by the frontend by adding 
negates to operands of the fmadd and fmaddsub builtins.

The backend should be able to combine the negates to create fmsub, fnmadd, and 
fnmsub. faddsub converting to fsubadd still needs work I think, but should be 
very doable.

This matches what we already do for the masked builtins.

This only covers the packed builtins. Scalar builtins will be done after FMA4 
is fixed.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/fma4intrin.h
cfe/trunk/lib/Headers/fmaintrin.h
cfe/trunk/test/CodeGen/fma-builtins.c
cfe/trunk/test/CodeGen/fma4-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=317873=317872=317873=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Nov  9 21:20:32 2017
@@ -684,34 +684,20 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddps,
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddss3, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsd3, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubps, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubpd, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmsubss3, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmsubsd3, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmaddps, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmaddpd, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfnmaddss3, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfnmaddsd3, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmsubps, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmsubpd, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfnmsubss3, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfnmsubsd3, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubps, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubaddps, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubaddpd, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddps256, "V8fV8fV8fV8f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd256, "V4dV4dV4dV4d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubps256, "V8fV8fV8fV8f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubpd256, "V4dV4dV4dV4d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfnmaddps256, "V8fV8fV8fV8f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfnmaddpd256, "V4dV4dV4dV4d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmsubps256, "V8fV8fV8fV8f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmsubpd256, "V4dV4dV4dV4d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubps256, "V8fV8fV8fV8f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd256, "V4dV4dV4dV4d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubaddps256, "V8fV8fV8fV8f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubaddpd256, "V4dV4dV4dV4d", "", "fma|fma4")
 
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_mask3, "V2dV2dV2dV2dUc", "", 
"avx512vl")

Modified: cfe/trunk/lib/Headers/fma4intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/fma4intrin.h?rev=317873=317872=317873=diff
==
--- cfe/trunk/lib/Headers/fma4intrin.h (original)
+++ cfe/trunk/lib/Headers/fma4intrin.h Thu Nov  9 21:20:32 2017
@@ -60,13 +60,13 @@ _mm_macc_sd(__m128d __A, __m128d __B, __
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_msub_ps(__m128 __A, __m128 __B, __m128 __C)
 {
-  return (__m128)__builtin_ia32_vfmsubps((__v4sf)__A, (__v4sf)__B, 
(__v4sf)__C);
+  return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, 
-(__v4sf)__C);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_msub_pd(__m128d __A, __m128d __B, __m128d __C)
 {
-  return (__m128d)__builtin_ia32_vfmsubpd((__v2df)__A, (__v2df)__B, 
(__v2df)__C);
+  return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, 
-(__v2df)__C);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -84,13 +84,13 @@ _mm_msub_sd(__m128d __A, __m128d __B, __
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_nmacc_ps(__m128 __A, __m128 __B, __m128 __C)
 {
-  return (__m128)__builtin_ia32_vfnmaddps((__v4sf)__A, (__v4sf)__B, 

[PATCH] D39886: [ASTImporter] Fix wrong conflict detections for unnamed structures

2017-11-09 Thread Takafumi Kubota via Phabricator via cfe-commits
tk1012 created this revision.

This patch fixes wrong conflict detections for unnamed structures.
Current ASTImporter mistakenly identifies two different unnamed structs as the 
same one.
This is because ASTImporter checks the name of each RecordDecl for the conflict 
identification and the both of them have the same "unnamed" name.
To avoid this, this patch skips the confliction check if SearchName is the null 
string and also adds a tase case.


https://reviews.llvm.org/D39886

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -485,6 +485,36 @@
has(atomicType()));
 }
 
+TEST(ImportDecl, ImportUnnamedRecordDecl) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport() {"
+  "  struct Root {"
+  "struct { int a; } A;"
+  "struct { float b; } B;"
+  "  } root;"
+  "}",
+  Lang_C, "", Lang_C, Verifier,
+  functionDecl(
+hasBody(
+  compoundStmt(
+has(
+declStmt(
+  has(
+recordDecl(
+  has(
+recordDecl(
+  has(
+fieldDecl(
+  hasType(asString("int")),
+  has(
+recordDecl(
+  has(
+fieldDecl(
+  hasType(asString("float"))
+  );
+}
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1631,7 +1631,7 @@
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *AdoptDecl = nullptr;
   RecordDecl *PrevDecl = nullptr;
-  if (!DC->isFunctionOrMethod()) {
+  if (!DC->isFunctionOrMethod() && SearchName.getAsString() != "") {
 SmallVector ConflictingDecls;
 SmallVector FoundDecls;
 DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -485,6 +485,36 @@
has(atomicType()));
 }
 
+TEST(ImportDecl, ImportUnnamedRecordDecl) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport() {"
+  "  struct Root {"
+  "struct { int a; } A;"
+  "struct { float b; } B;"
+  "  } root;"
+  "}",
+  Lang_C, "", Lang_C, Verifier,
+  functionDecl(
+hasBody(
+  compoundStmt(
+has(
+declStmt(
+  has(
+recordDecl(
+  has(
+recordDecl(
+  has(
+fieldDecl(
+  hasType(asString("int")),
+  has(
+recordDecl(
+  has(
+fieldDecl(
+  hasType(asString("float"))
+  );
+}
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1631,7 +1631,7 @@
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *AdoptDecl = nullptr;
   RecordDecl *PrevDecl = nullptr;
-  if (!DC->isFunctionOrMethod()) {
+  if (!DC->isFunctionOrMethod() && SearchName.getAsString() != "") {
 SmallVector ConflictingDecls;
 SmallVector FoundDecls;
 DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:69
+  (Ctor->getAccess() == AS_private || Ctor->isDeleted())) {
+NonCopyableBase = true;
+break;

xazax.hun wrote:
> aaron.ballman wrote:
> > What if the base class is inherited privately? e.g.,
> > ```
> > struct Base {
> >   Base(const Base&) {}
> > };
> > 
> > struct Derived : private Base {
> >   Derived(const Derived &) {}
> > };
> > ```
> We warn in that case too. I added a test to demonstrate this. I think we 
> still want to copy private bases in copy ctors if they are not empty and 
> copyable. 
Good, thank you for adding the test (and I agree, we want to warn in that case).


https://reviews.llvm.org/D33722



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


[PATCH] D39878: AMDGPU: Add -mxnack/-mno-xnack options that set +/-xnack feature

2017-11-09 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D39878



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1502-1503
+evaluated at compile-time;
+  - A dependent integral value which depends on one or more template arguments,
+be they type or non-type e.g. ``sizeof(T)`` within the scope of
+``template struct S;``.

Slight wording tweak:

"A type or non-type dependent integral value..."

drop the "be they type or non-type"

Same comment applies below.



Comment at: lib/CodeGen/TargetInfo.cpp:7665
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+{
+  assert(E);

The curly brace should bind to the end of the function parameter list. I'd just 
run the whole patch through clang-format and then fix up anything that goes 
wrong in the .td files.



Comment at: lib/CodeGen/TargetInfo.cpp:7669
+  llvm::APSInt Tmp{32, 0};
+  E->EvaluateAsInt(Tmp, Ctx);
+

Are you expecting this to always succeed, or are you relying on the initialized 
value in the case where this fails?



Comment at: lib/Sema/SemaDeclAttr.cpp:5473
+static bool checkAllAreIntegral(Sema , const AttributeList ) {
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);

Don't use `auto` here either, just use `unsigned`. Also `i` doesn't match our 
coding standard.



Comment at: lib/Sema/SemaDeclAttr.cpp:5474
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);
+if (E && !E->getType()->isIntegralOrEnumerationType()) {

* binds to `E` not to `Expr`



Comment at: lib/Sema/SemaDeclAttr.cpp:5484
+
+  return true;
+}

This still returns `true` even if `E` is null; is that intended?


https://reviews.llvm.org/D39857



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


[PATCH] D39821: Add CLANG_DEFAULT_OBJCOPY to allow Clang to use llvm-objcopy for dwarf fission

2017-11-09 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich updated this revision to Diff 122382.
jakehehrlich added a comment.

fixed typo


Repository:
  rL LLVM

https://reviews.llvm.org/D39821

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  lib/Driver/ToolChains/CommonArgs.cpp


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -725,7 +725,8 @@
   ExtractArgs.push_back(Output.getFilename());
   ExtractArgs.push_back(OutFile);
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("objcopy"));
+  const char *Exec =
+  Args.MakeArgString(TC.GetProgramPath(CLANG_DEFAULT_OBJCOPY));
   InputInfo II(types::TY_Object, Output.getFilename(), Output.getFilename());
 
   // First extract the dwo sections.
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -17,6 +17,9 @@
 /* Default runtime library to use. */
 #define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
 
+/* Default objcopy to use */
+#define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}"
+
 /* Default OpenMP runtime used by -fopenmp. */
 #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -232,6 +232,9 @@
 "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for 
platform default)" FORCE)
 endif()
 
+set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
+  "Default objcopy executable to use.")
+
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -725,7 +725,8 @@
   ExtractArgs.push_back(Output.getFilename());
   ExtractArgs.push_back(OutFile);
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("objcopy"));
+  const char *Exec =
+  Args.MakeArgString(TC.GetProgramPath(CLANG_DEFAULT_OBJCOPY));
   InputInfo II(types::TY_Object, Output.getFilename(), Output.getFilename());
 
   // First extract the dwo sections.
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -17,6 +17,9 @@
 /* Default runtime library to use. */
 #define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
 
+/* Default objcopy to use */
+#define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}"
+
 /* Default OpenMP runtime used by -fopenmp. */
 #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -232,6 +232,9 @@
 "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE)
 endif()
 
+set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
+  "Default objcopy executable to use.")
+
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-09 Thread Volodymyr Sapsai via cfe-commits
On Nov 9, 2017, at 12:13, Reimar Döffinger  wrote:
> 
> Hello!
> 
> On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote:
>> Thanks for the patch, Reimar. Can you please add tests to ensure this 
>> functionality doesn’t regress? As null character is required by the standard 
>> (27.7.2.3p21), a good starting point seems to be
>> test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
>> test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
> 
> New patch attached, though I went the lazy way of just adding one case.
> Not sure that's "good enough" - in principle I think it should be.
I think it makes sense to cover wchar_t as well. And I think it would be useful 
to test the case with specified delimiter too. Most likely implementation 
should be reused for the case with explicit delimiter and default new line 
delimiter. But I prefer not to rely on this assumption and test explicitly.

> More tricky would be to add a test for the _LIBCPP_NO_EXCEPTIONS case,
> is there any code testing that at all?
According to tests, exceptions are tested in various ways. Let me find how to 
configure the build to run tests in these modes.

>> And what about free function std::getline that takes a stream and a string? 
>> The standard (21.4.8.9p7) specifies 
> [...]
>> 
>> Technically, string is not a character array of non-zero size. But according 
>> to the spirit of the standard, I would expect string to be empty after 
>> reading into it from a stream that reached EOF. What do you think?
> 
> Starting with the useful answer instead of what I think:
> 
> I'd try what other implementations do and align with that.
> At least libstdc++ does not clear the string, so tentatively
> I'd suggest not changing behaviour, for simple interoperability.
> Testing at least Microsoft C++ in addition might be a good idea
> though…
OK, let’s drop this case.

> Test code:
> 
> #include 
> #include 
> #include 
> 
> int main()
> {
>std::istringstream in;
>std::string dummy;
>in >> dummy;
>char test[20] = "oldstring";
>in.getline(test, sizeof(test));
>std::cout << "std::istream::getline result: " << test << std::endl;
>dummy = "oldstring";
>std::getline(in, dummy);
>std::cout << "std::getline result: " << dummy << std::endl;
>return test[0];
> }
> 
> 
> As to what I really think, for anyone who isn't tired of unfair rants
> (anyone else please just skip):
> 
> I don't really care much about that case, because at least unlike
> not 0-terminating a char buffer it is not in the "things you never EVER
> do" list.
> But this rather needs to be put to the standard authors and it needs to be
> clarified.
> Along with the suggestion to not only spend time on new features but
> also on improving the spec quality.
> Large parts of the spec read like when a second-semester maths student
> tries to write a proof: the language lacks the precision to actually
> write a solid proof, and excessive verbosity is used to try to make
> up for it (to no effect besides annoying the reader).
> The lack of specified pre- and post-conditions (specified formally
> or in natural language) for at least parts easy to specify in such a way
> to allow at least partial formal verification or proof of correctness
> isn't exactly state-of-the-art either.
> 
> Kind regards,
> Reimar Döffinger
> 
>>> On Oct 4, 2017, at 12:07, Reimar Döffinger via cfe-commits 
>>>  wrote:
>>> 
>>> If the sentinel failed (e.g. due to having reached
>>> EOF before) or an exception was caught it failed to
>>> do that.
>>> The C++14 standard says:
>>> "In any case, if n is greater than zero, it then stores
>>> a null character (using charT()) into the next
>>> successive location of the array."
>>> Other implementations like libstdc++ do 0-terminate and
>>> not doing so may lead security issues in applications.
>>> ---
>>> include/istream | 6 --
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/include/istream b/include/istream
>>> index 0b8e05d95..5c73df38f 100644
>>> --- a/include/istream
>>> +++ b/include/istream
>>> @@ -1069,16 +1069,18 @@ basic_istream<_CharT, _Traits>::getline(char_type* 
>>> __s, streamsize __n, char_typ
>>>this->rdbuf()->sbumpc();
>>>++__gc_;
>>>}
>>> -if (__n > 0)
>>> -*__s = char_type();
>>>if (__gc_ == 0)
>>>   __err |= ios_base::failbit;
>>>this->setstate(__err);
>>>}
>>> +if (__n > 0)
>>> +*__s = char_type();
>>> #ifndef _LIBCPP_NO_EXCEPTIONS
>>>}
>>>catch (...)
>>>{
>>> +if (__n > 0)
>>> +*__s = char_type();
>>>this->__set_badbit_and_consider_rethrow();
>>>}
>>> #endif  // _LIBCPP_NO_EXCEPTIONS
>>> -- 
>>> 2.14.2
>>> 
>>> 

[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

2017-11-09 Thread Steven Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317860: [Driver] Make clang/cc conforms to UNIX standard 
(authored by steven_wu).

Repository:
  rL LLVM

https://reviews.llvm.org/D39502

Files:
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/test/Driver/cuda-bail-out.cu
  cfe/trunk/test/Driver/output-file-cleanup.c
  cfe/trunk/test/Driver/unix-conformance.c

Index: cfe/trunk/test/Driver/cuda-bail-out.cu
===
--- cfe/trunk/test/Driver/cuda-bail-out.cu
+++ cfe/trunk/test/Driver/cuda-bail-out.cu
@@ -0,0 +1,54 @@
+// Test clang driver bails out after one error during CUDA compilation.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifdef FORCE_ERROR
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+#if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM60) && (__CUDA_ARCH__ == 600)
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM60 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST -DERROR_SM35 --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-gpu-arch=sm_60 %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST -DERROR_SM60 --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-gpu-arch=sm_60 %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM35 -DERROR_SM60 --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-gpu-arch=sm_60 %s 2>&1 | FileCheck %s
+
+
+// CHECK: error: compilation failed
+// CHECK-NOT: error: compilation failed
Index: cfe/trunk/test/Driver/unix-conformance.c
===
--- cfe/trunk/test/Driver/unix-conformance.c
+++ cfe/trunk/test/Driver/unix-conformance.c
@@ -0,0 +1,24 @@
+// Check UNIX conformance for cc/c89/c99
+// When c99 encounters a compilation error that causes an object file not to be
+// created, it shall write a diagnostic to standard error and continue to
+// compile other source code operands, but it shall not perform the link phase
+// and it shall return a non-zero exit status.
+
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
+// RUN: rm -rf %t-dir
+// RUN: mkdir -p %t-dir
+// RUN: cd %t-dir
+//
+// RUN: touch %t-dir/1.c
+// RUN: echo "invalid C code" > %t-dir/2.c
+// RUN: touch %t-dir/3.c
+// RUN: echo "invalid C code" > %t-dir/4.c
+// RUN: touch %t-dir/5.c
+// RUN: not %clang -S %t-dir/1.c %t-dir/2.c %t-dir/3.c %t-dir/4.c %t-dir/5.c
+// RUN: test -f %t-dir/1.s
+// RUN: test ! -f %t-dir/2.s
+// RUN: test -f %t-dir/3.s
+// RUN: test ! -f %t-dir/4.s
+// RUN: test -f %t-dir/5.s
Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -41,18 +41,3 @@
 // RUN: not %clang -S %t-dir/1.c %t-dir/2.c
 // RUN: test -f %t-dir/1.s
 // RUN: test ! -f %t-dir/2.s
-
-// When given multiple .c files to compile, clang compiles them in order until
-// it hits an error, at which point it stops.
-//
-// RUN: touch %t-dir/1.c
-// RUN: echo "invalid C code" > %t-dir/2.c
-// RUN: touch %t-dir/3.c
-// RUN: echo "invalid C code" > %t-dir/4.c
-// RUN: touch %t-dir/5.c
-// RUN: not %clang -S %t-dir/1.c %t-dir/2.c %t-dir/3.c %t-dir/4.c %t-dir/5.c
-// RUN: test -f %t-dir/1.s
-// RUN: test ! -f %t-dir/2.s
-// RUN: test ! -f %t-dir/3.s
-// RUN: test ! -f %t-dir/4.s

r317860 - [Driver] Make clang/cc conforms to UNIX standard

2017-11-09 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Thu Nov  9 17:32:47 2017
New Revision: 317860

URL: http://llvm.org/viewvc/llvm-project?rev=317860=rev
Log:
[Driver] Make clang/cc conforms to UNIX standard

Summary:
This is basically reverting r261774 with a tweak for clang-cl. UNIX
standard states:
When c99 encounters a compilation error that causes an object file not
to be created, it shall write a diagnostic to standard error and
continue to compile other source code operands, but it shall not perform
the link phase and it shall return a non-zero exit status

The same goes for c89 or cc. And they are all alias or shims pointing to
clang on Darwin.

The original commit was intended for CUDA so the error message doesn't
get emit twice for both host and device. It seems that the clang driver
has been changed to model the CUDA dependency differently. Now the
driver behaves the same without this commit.

rdar://problem/32223263

Reviewers: thakis, dexonsmith, tra

Reviewed By: tra

Subscribers: jlebar, cfe-commits

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

Added:
cfe/trunk/test/Driver/cuda-bail-out.cu
cfe/trunk/test/Driver/unix-conformance.c
Modified:
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/test/Driver/output-file-cleanup.c

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=317860=317859=317860=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Thu Nov  9 17:32:47 2017
@@ -182,16 +182,51 @@ int Compilation::ExecuteCommand(const Co
   return ExecutionFailed ? 1 : Res;
 }
 
-void Compilation::ExecuteJobs(
-const JobList ,
-SmallVectorImpl> ) const {
+using FailingCommandList = SmallVectorImpl>;
+
+static bool ActionFailed(const Action *A,
+ const FailingCommandList ) {
+
+  if (FailingCommands.empty())
+return false;
+
+  // CUDA can have the same input source code compiled multiple times so do not
+  // compiled again if there are already failures. It is OK to abort the CUDA
+  // pipeline on errors.
+  if (A->isOffloading(Action::OFK_Cuda))
+return true;
+
+  for (const auto  : FailingCommands)
+if (A == &(CI.second->getSource()))
+  return true;
+
+  for (const Action *AI : A->inputs())
+if (ActionFailed(AI, FailingCommands))
+  return true;
+
+  return false;
+}
+
+static bool InputsOk(const Command ,
+ const FailingCommandList ) {
+  return !ActionFailed((), FailingCommands);
+}
+
+void Compilation::ExecuteJobs(const JobList ,
+  FailingCommandList ) const {
+  // According to UNIX standard, driver need to continue compiling all the
+  // inputs on the command line even one of them failed.
+  // In all but CLMode, execute all the jobs unless the necessary inputs for 
the
+  // job is missing due to previous failures.
   for (const auto  : Jobs) {
+if (!InputsOk(Job, FailingCommands))
+  continue;
 const Command *FailingCommand = nullptr;
 if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
-  // Bail as soon as one command fails, so we don't output duplicate error
-  // messages if we die on e.g. the same file.
-  return;
+  // Bail as soon as one command fails in cl driver mode.
+  if (TheDriver.IsCLMode())
+return;
 }
   }
 }

Added: cfe/trunk/test/Driver/cuda-bail-out.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-bail-out.cu?rev=317860=auto
==
--- cfe/trunk/test/Driver/cuda-bail-out.cu (added)
+++ cfe/trunk/test/Driver/cuda-bail-out.cu Thu Nov  9 17:32:47 2017
@@ -0,0 +1,54 @@
+// Test clang driver bails out after one error during CUDA compilation.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifdef FORCE_ERROR
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 
\
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 
\
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+#if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM60) && (__CUDA_ARCH__ == 600)
+#error compilation 

[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

2017-11-09 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM for CUDA-related functionality & tests. Thank you for the patch!


https://reviews.llvm.org/D39502



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


[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

2017-11-09 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 122376.
steven_wu added a comment.

Add more tests! The new tests can trigger two errors during the compilation
but only one should be emitted.


https://reviews.llvm.org/D39502

Files:
  lib/Driver/Compilation.cpp
  test/Driver/cuda-bail-out.cu
  test/Driver/output-file-cleanup.c
  test/Driver/unix-conformance.c

Index: test/Driver/unix-conformance.c
===
--- /dev/null
+++ test/Driver/unix-conformance.c
@@ -0,0 +1,24 @@
+// Check UNIX conformance for cc/c89/c99
+// When c99 encounters a compilation error that causes an object file not to be
+// created, it shall write a diagnostic to standard error and continue to
+// compile other source code operands, but it shall not perform the link phase
+// and it shall return a non-zero exit status.
+
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
+// RUN: rm -rf %t-dir
+// RUN: mkdir -p %t-dir
+// RUN: cd %t-dir
+//
+// RUN: touch %t-dir/1.c
+// RUN: echo "invalid C code" > %t-dir/2.c
+// RUN: touch %t-dir/3.c
+// RUN: echo "invalid C code" > %t-dir/4.c
+// RUN: touch %t-dir/5.c
+// RUN: not %clang -S %t-dir/1.c %t-dir/2.c %t-dir/3.c %t-dir/4.c %t-dir/5.c
+// RUN: test -f %t-dir/1.s
+// RUN: test ! -f %t-dir/2.s
+// RUN: test -f %t-dir/3.s
+// RUN: test ! -f %t-dir/4.s
+// RUN: test -f %t-dir/5.s
Index: test/Driver/output-file-cleanup.c
===
--- test/Driver/output-file-cleanup.c
+++ test/Driver/output-file-cleanup.c
@@ -41,18 +41,3 @@
 // RUN: not %clang -S %t-dir/1.c %t-dir/2.c
 // RUN: test -f %t-dir/1.s
 // RUN: test ! -f %t-dir/2.s
-
-// When given multiple .c files to compile, clang compiles them in order until
-// it hits an error, at which point it stops.
-//
-// RUN: touch %t-dir/1.c
-// RUN: echo "invalid C code" > %t-dir/2.c
-// RUN: touch %t-dir/3.c
-// RUN: echo "invalid C code" > %t-dir/4.c
-// RUN: touch %t-dir/5.c
-// RUN: not %clang -S %t-dir/1.c %t-dir/2.c %t-dir/3.c %t-dir/4.c %t-dir/5.c
-// RUN: test -f %t-dir/1.s
-// RUN: test ! -f %t-dir/2.s
-// RUN: test ! -f %t-dir/3.s
-// RUN: test ! -f %t-dir/4.s
-// RUN: test ! -f %t-dir/5.s
Index: test/Driver/cuda-bail-out.cu
===
--- /dev/null
+++ test/Driver/cuda-bail-out.cu
@@ -0,0 +1,54 @@
+// Test clang driver bails out after one error during CUDA compilation.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifdef FORCE_ERROR
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+#if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM60) && (__CUDA_ARCH__ == 600)
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM60 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST -DERROR_SM35 --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-gpu-arch=sm_60 %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST -DERROR_SM60 --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-gpu-arch=sm_60 %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM35 -DERROR_SM60 --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-gpu-arch=sm_60 %s 2>&1 | FileCheck %s
+
+
+// CHECK: error: compilation failed
+// CHECK-NOT: error: compilation failed
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ 

r317854 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-09 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Nov  9 16:59:22 2017
New Revision: 317854

URL: http://llvm.org/viewvc/llvm-project?rev=317854=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/ASTUnresolvedSet.h
cfe/trunk/include/clang/AST/ASTVector.h
cfe/trunk/include/clang/AST/AttrIterator.h
cfe/trunk/include/clang/AST/BaseSubobject.h
cfe/trunk/include/clang/AST/CommentVisitor.h
cfe/trunk/include/clang/AST/DeclFriend.h
cfe/trunk/include/clang/AST/DeclGroup.h
cfe/trunk/include/clang/AST/DeclVisitor.h
cfe/trunk/include/clang/AST/DependentDiagnostic.h
cfe/trunk/include/clang/AST/RecordLayout.h
cfe/trunk/include/clang/AST/Redeclarable.h
cfe/trunk/include/clang/AST/StmtGraphTraits.h
cfe/trunk/include/clang/AST/StmtVisitor.h
cfe/trunk/lib/AST/DeclFriend.cpp
cfe/trunk/lib/AST/DeclGroup.cpp
cfe/trunk/lib/AST/RecordLayout.cpp

Modified: cfe/trunk/include/clang/AST/ASTUnresolvedSet.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTUnresolvedSet.h?rev=317854=317853=317854=diff
==
--- cfe/trunk/include/clang/AST/ASTUnresolvedSet.h (original)
+++ cfe/trunk/include/clang/AST/ASTUnresolvedSet.h Thu Nov  9 16:59:22 2017
@@ -1,4 +1,4 @@
-//===-- ASTUnresolvedSet.h - Unresolved sets of declarations  ---*- C++ 
-*-===//
+//===- ASTUnresolvedSet.h - Unresolved sets of declarations -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -16,14 +16,22 @@
 #define LLVM_CLANG_AST_ASTUNRESOLVEDSET_H
 
 #include "clang/AST/ASTVector.h"
+#include "clang/AST/DeclAccessPair.h"
 #include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/Specifiers.h"
+#include 
+#include 
 
 namespace clang {
 
+class NamedDecl;
+
 /// \brief An UnresolvedSet-like class which uses the ASTContext's allocator.
 class ASTUnresolvedSet {
+  friend class LazyASTUnresolvedSet;
+
   struct DeclsTy : ASTVector {
-DeclsTy() {}
+DeclsTy() = default;
 DeclsTy(ASTContext , unsigned N) : ASTVector(C, N) {}
 
 bool isLazy() const { return getTag(); }
@@ -32,14 +40,12 @@ class ASTUnresolvedSet {
 
   DeclsTy Decls;
 
-  friend class LazyASTUnresolvedSet;
-
 public:
-  ASTUnresolvedSet() {}
+  ASTUnresolvedSet() = default;
   ASTUnresolvedSet(ASTContext , unsigned N) : Decls(C, N) {}
 
-  typedef UnresolvedSetIterator iterator;
-  typedef UnresolvedSetIterator const_iterator;
+  using iterator = UnresolvedSetIterator;
+  using const_iterator = UnresolvedSetIterator;
 
   iterator begin() { return iterator(Decls.begin()); }
   iterator end() { return iterator(Decls.end()); }
@@ -98,13 +104,14 @@ public:
   }
 
   void reserve(ASTContext , unsigned N) { Impl.reserve(C, N); }
+
   void addLazyDecl(ASTContext , uintptr_t ID, AccessSpecifier AS) {
 assert(Impl.empty() || Impl.Decls.isLazy());
 Impl.Decls.setLazy(true);
-Impl.addDecl(C, reinterpret_cast(ID << 2), AS);
+Impl.addDecl(C, reinterpret_cast(ID << 2), AS);
   }
 };
 
 } // namespace clang
 
-#endif
+#endif // LLVM_CLANG_AST_ASTUNRESOLVEDSET_H

Modified: cfe/trunk/include/clang/AST/ASTVector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTVector.h?rev=317854=317853=317854=diff
==
--- cfe/trunk/include/clang/AST/ASTVector.h (original)
+++ cfe/trunk/include/clang/AST/ASTVector.h Thu Nov  9 16:59:22 2017
@@ -1,4 +1,4 @@
-//===- ASTVector.h - Vector that uses ASTContext for allocation  --*- C++ 
-*-=//
+//===- ASTVector.h - Vector that uses ASTContext for allocation ---*- C++ 
-*-=//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -18,22 +18,26 @@
 #ifndef LLVM_CLANG_AST_ASTVECTOR_H
 #define LLVM_CLANG_AST_ASTVECTOR_H
 
-#include "clang/AST/AttrIterator.h"
 #include "llvm/ADT/PointerIntPair.h"
-#include "llvm/Support/type_traits.h"
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
 
 namespace clang {
-  class ASTContext;
+
+class ASTContext;
 
 template
 class ASTVector {
 private:
-  T *Begin, *End;
-  llvm::PointerIntPair Capacity;
+  T *Begin = nullptr;
+  T *End = nullptr;
+  llvm::PointerIntPair Capacity;
 
   void setEnd(T *P) { this->End = P; }
 
@@ -45,7 +49,7 @@ protected:
 
 public:
   // Default ctor - Initialize to empty.
-  ASTVector() : Begin(nullptr), End(nullptr), Capacity(nullptr, false) {}
+  ASTVector() : Capacity(nullptr, false) {}
 
   ASTVector(ASTVector &) : Begin(O.Begin), End(O.End), Capacity(O.Capacity) {
 O.Begin = O.End = nullptr;
@@ -53,14 +57,15 @@ public:
 O.Capacity.setInt(false);
   }
 
-  ASTVector(const ASTContext , unsigned N)
-  : Begin(nullptr), End(nullptr), Capacity(nullptr, false) {
+  ASTVector(const ASTContext , unsigned N) : Capacity(nullptr, false) {
 reserve(C, N);
  

[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

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



Comment at: test/Driver/cuda-bail-out.cu:47
+// CHECK-HOST-ERROR: Error during compilation for host
+// CHECK-HOST-ERROR-NOT: Error during compilation for sm_35

steven_wu wrote:
> tra wrote:
> > steven_wu wrote:
> > > tra wrote:
> > > > steven_wu wrote:
> > > > > tra wrote:
> > > > > > To make it more robust, I'd add another copy of the last line 
> > > > > > before CHECK-HOST-ERROR: so it would catch device-side errors if 
> > > > > > they were to happen ahead of the host.
> > > > > > 
> > > > > > Generally speaking, expected behavior is "I want to see an error 
> > > > > > from one compilation only". We don't really care which CUDA 
> > > > > > compilation phase produces it. Perhaps all we need in all test 
> > > > > > cases is:
> > > > > > 
> > > > > > ```
> > > > > > CHECK: Error during compilation
> > > > > > CHECK-NOT:  Error during compilation
> > > > > > ```
> > > > > > 
> > > > > > This way we don't need to depend on specific phase order.
> > > > > That will be a design choice for CUDA driver. I have no preference 
> > > > > going either direction. Just let me know so I will update the test 
> > > > > case.
> > > > > 
> > > > > Speaking of "-fsyntax-only", this is another interesting behavior of 
> > > > > clang cuda driver:
> > > > > ```
> > > > > $ clang -x cuda /dev/null -x c /dev/null -ccc-print-phases
> > > > > 14: input, "/dev/null", c, (host-cuda)
> > > > > $ clang -fsyntax-only -x cuda /dev/null -x c /dev/null 
> > > > > -ccc-print-phases
> > > > > 9: input, "/dev/null", c
> > > > > ```
> > > > > So depending on if -fsyntax-only is used or not, the c language part 
> > > > > can be either offloading or not offloading.
> > > > > This is a corner case that the driver behavior will change after this 
> > > > > patch.
> > > > OK. Let's just check for one error only. 
> > > > 
> > > > As for the second, it is, IMO a problem. The file after ```-x c```  
> > > > should have been treated as plain C input, regardless of -fsyntax-only. 
> > > >  It's reproducible in clean clang tree, so it's not due to this patch. 
> > > The corner case I am talking about is after this patch, "-x c" will be 
> > > syntax checked even if "-x cuda" failed the syntax check (which sounds 
> > > good) but only when using "-fsyntax-only"
> > > 
> > > I am updating the test case.
> > Sorry, I should've phrased my suggestion better. I didn't mean to remove 
> > multiple sources of errors. Quite the opposite. There should be multiple 
> > test runs with errors produced by combination of phases. E.g. host, 
> > host+sm_35, host+sm_60, sm_35+sm+60, host+sm_35+sm_60.
> > 
> > The check itself is fine, you just need multiple runs that trigger errors 
> > during particular phase.
> > 
> > ```
> > #if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
> > #error Host error
> > #endif
> > 
> > #if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
> > #error sm_35 error
> > #endif
> > ...
> > 
> > ```
> > 
> > and then do multiple runs with various combinations of -DERROR_xxx
> > 
> Hmm, I might still understand you incorrectly. If the error message is 
> different for host and different devices, checking the error message requires 
> the compilation being executed in a certain order. Otherwise, you won't know 
> which error is going to be emitted.
> On the other hand, if you don't care about the order and don't want to check 
> for any ordering, the best we can do is run all the combinations and check 
> the error only happens once. In my current test, I have host + default_sm, 
> host + sm_35 + sim_60. I can add --cude-device-only but is there anything 
> else I need to do?
That would be implementation details. You could use regex in the error check to 
match any of them.
All I want to know, that I only see errors from one phase only, even when more 
than one phase is broken.

We're almost there. Now we just need few tests with an error from more than one 
phase. E.g. a few test runs with more than one `-DERROR_xxx`



https://reviews.llvm.org/D39502



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


[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

This allows us to limit the number of results we return and still allow them
to be surfaced by refining a query (https://reviews.llvm.org/D39852).

The initial algorithm is very conservative - it accepts a completion if the
filter is any case-insensitive sub-sequence. It does not attempt to rank items
based on match quality.


https://reviews.llvm.org/D39882

Files:
  clangd/ClangdUnit.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -694,6 +694,61 @@
   }
 }
 
+TEST_F(ClangdCompletionTest, Filter) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  Opts, EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+
+  const char *Body = R"cpp(
+int Abracadabra;
+int Alakazam;
+struct S {
+  int FooBar;
+  int FooBaz;
+  int Qux;
+};
+  )cpp";
+  auto Complete = [&](StringRef Query) {
+StringWithPos Completion = parseTextMarker(
+formatv("{0} int main() { {1}{{complete}} }", Body, Query).str(),
+"complete");
+Server.addDocument(FooCpp, Completion.Text);
+return Server
+.codeComplete(FooCpp, Completion.MarkerPos, StringRef(Completion.Text))
+.get()
+.Value;
+  };
+
+  auto Foba = Complete("S().Foba");
+  EXPECT_TRUE(ContainsItem(Foba, "FooBar"));
+  EXPECT_TRUE(ContainsItem(Foba, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(Foba, "Qux"));
+
+  auto FR = Complete("S().FR");
+  EXPECT_TRUE(ContainsItem(FR, "FooBar"));
+  EXPECT_FALSE(ContainsItem(FR, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(FR, "Qux"));
+
+  auto Op = Complete("S().opr");
+  EXPECT_TRUE(ContainsItem(Op, "operator="));
+
+  auto Aaa = Complete("aaa");
+  EXPECT_TRUE(ContainsItem(Aaa, "Abracadabra"));
+  EXPECT_TRUE(ContainsItem(Aaa, "Alakazam"));
+
+  auto UA = Complete("_a");
+  EXPECT_TRUE(ContainsItem(UA, "static_cast"));
+  EXPECT_FALSE(ContainsItem(UA, "Abracadabra"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -380,9 +380,12 @@
   void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override final {
+StringRef Filter = S.getPreprocessor().getCodeCompletionFilter();
 Items.reserve(NumResults);
 for (unsigned I = 0; I < NumResults; ++I) {
   auto  = Results[I];
+  if (!Filter.empty() && !fuzzyMatch(S, Context, Filter, Result))
+continue;
   const auto *CCS = Result.CreateCodeCompletionString(
   S, Context, *Allocator, CCTUInfo,
   CodeCompleteOpts.IncludeBriefComments);
@@ -397,6 +400,41 @@
   CodeCompletionTUInfo () override { return CCTUInfo; }
 
 private:
+  bool fuzzyMatch(Sema , const CodeCompletionContext , StringRef Filter,
+  CodeCompletionResult Result) {
+switch (Result.Kind) {
+case CodeCompletionResult::RK_Declaration:
+  if (auto *ID = Result.Declaration->getIdentifier())
+return fuzzyMatch(Filter, ID->getName());
+  break;
+case CodeCompletionResult::RK_Keyword:
+  return fuzzyMatch(Filter, Result.Keyword);
+case CodeCompletionResult::RK_Macro:
+  return fuzzyMatch(Filter, Result.Macro->getName());
+case CodeCompletionResult::RK_Pattern:
+  return fuzzyMatch(Filter, Result.Pattern->getTypedText());
+}
+auto *CCS = Result.CreateCodeCompletionString(
+S, CCCtx, *Allocator, CCTUInfo, /*IncludeBriefComments=*/false);
+return fuzzyMatch(Filter, CCS->getTypedText());
+  }
+
+  // Checks whether Target matches the Filter.
+  // Currently just requires a case-insensitive subsequence match.
+  // FIXME: make stricter and word-based: 'unique_ptr' should not match 'que'.
+  // FIXME: return a score to be incorporated into ranking.
+  static bool fuzzyMatch(StringRef Filter, StringRef Target) {
+llvm::errs() << "match " << Target << " against " << Filter << "\n";
+size_t TPos = 0;
+for (char C : Filter) {
+  TPos = Target.find_lower(C, TPos);
+  if (TPos == StringRef::npos)
+return false;
+}
+llvm::errs() << "yeah\n";
+return true;
+  }
+
   CompletionItem
   ProcessCodeCompleteResult(const CodeCompletionResult ,
 const CodeCompletionString ) const {

[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

2017-11-09 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 122372.
steven_wu added a comment.

I think I understand what you mean now. You want some cases when the
compilation doesn't failed on the first source it process.

I add a testcase which compiles for host + sm_35 + sim_60. I run the test
3 times and each time I trigger an error in different source. This should cover
the case.


https://reviews.llvm.org/D39502

Files:
  lib/Driver/Compilation.cpp
  test/Driver/cuda-bail-out.cu
  test/Driver/output-file-cleanup.c
  test/Driver/unix-conformance.c

Index: test/Driver/unix-conformance.c
===
--- /dev/null
+++ test/Driver/unix-conformance.c
@@ -0,0 +1,24 @@
+// Check UNIX conformance for cc/c89/c99
+// When c99 encounters a compilation error that causes an object file not to be
+// created, it shall write a diagnostic to standard error and continue to
+// compile other source code operands, but it shall not perform the link phase
+// and it shall return a non-zero exit status.
+
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
+// RUN: rm -rf %t-dir
+// RUN: mkdir -p %t-dir
+// RUN: cd %t-dir
+//
+// RUN: touch %t-dir/1.c
+// RUN: echo "invalid C code" > %t-dir/2.c
+// RUN: touch %t-dir/3.c
+// RUN: echo "invalid C code" > %t-dir/4.c
+// RUN: touch %t-dir/5.c
+// RUN: not %clang -S %t-dir/1.c %t-dir/2.c %t-dir/3.c %t-dir/4.c %t-dir/5.c
+// RUN: test -f %t-dir/1.s
+// RUN: test ! -f %t-dir/2.s
+// RUN: test -f %t-dir/3.s
+// RUN: test ! -f %t-dir/4.s
+// RUN: test -f %t-dir/5.s
Index: test/Driver/output-file-cleanup.c
===
--- test/Driver/output-file-cleanup.c
+++ test/Driver/output-file-cleanup.c
@@ -41,18 +41,3 @@
 // RUN: not %clang -S %t-dir/1.c %t-dir/2.c
 // RUN: test -f %t-dir/1.s
 // RUN: test ! -f %t-dir/2.s
-
-// When given multiple .c files to compile, clang compiles them in order until
-// it hits an error, at which point it stops.
-//
-// RUN: touch %t-dir/1.c
-// RUN: echo "invalid C code" > %t-dir/2.c
-// RUN: touch %t-dir/3.c
-// RUN: echo "invalid C code" > %t-dir/4.c
-// RUN: touch %t-dir/5.c
-// RUN: not %clang -S %t-dir/1.c %t-dir/2.c %t-dir/3.c %t-dir/4.c %t-dir/5.c
-// RUN: test -f %t-dir/1.s
-// RUN: test ! -f %t-dir/2.s
-// RUN: test ! -f %t-dir/3.s
-// RUN: test ! -f %t-dir/4.s
-// RUN: test ! -f %t-dir/5.s
Index: test/Driver/cuda-bail-out.cu
===
--- /dev/null
+++ test/Driver/cuda-bail-out.cu
@@ -0,0 +1,44 @@
+// Test clang driver bails out after one error during CUDA compilation.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifdef FORCE_ERROR
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DFORCE_ERROR --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+#if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
+#error compilation failed
+#endif
+
+#if defined(ERROR_SM60) && (__CUDA_ARCH__ == 600)
+#error compilation failed
+#endif
+
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_HOST --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-ibm-linux-gnu -fsyntax-only -nocudalib \
+// RUN:   -nocudainc -DERROR_SM60 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_60 \
+// RUN:   --cuda-device-only %s 2>&1 | FileCheck %s
+
+
+// CHECK: error: compilation failed
+// CHECK-NOT: error: compilation failed
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -182,16 +182,51 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-void Compilation::ExecuteJobs(
-const JobList ,
-SmallVectorImpl> ) const {
+using FailingCommandList = SmallVectorImpl>;
+
+static bool ActionFailed(const Action *A,
+ const FailingCommandList ) {
+
+  if (FailingCommands.empty())
+return false;
+
+  // CUDA can have 

[PATCH] D39446: [PGO] Detect more structural changes with the stable hash

2017-11-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 122368.
vsk edited the summary of this revision.
vsk added a comment.

- Consider logical nots and some binary comparison operators in the hash, per 
an offline conversation with @bogner


https://reviews.llvm.org/D39446

Files:
  lib/CodeGen/CodeGenPGO.cpp
  test/Frontend/Inputs/optimization-remark-with-hotness.proftext
  test/Profile/Inputs/c-captured.proftext
  test/Profile/Inputs/c-counter-overflows.proftext
  test/Profile/Inputs/c-general.proftext
  test/Profile/Inputs/c-unprofiled-blocks.proftext
  test/Profile/Inputs/cxx-class.proftext
  test/Profile/Inputs/cxx-hash-v2.profdata.v5
  test/Profile/Inputs/cxx-hash-v2.proftext
  test/Profile/Inputs/cxx-lambda.proftext
  test/Profile/Inputs/cxx-rangefor.proftext
  test/Profile/Inputs/cxx-templates.proftext
  test/Profile/Inputs/cxx-throws.proftext
  test/Profile/Inputs/func-entry.proftext
  test/Profile/Inputs/gcc-flag-compatibility.proftext
  test/Profile/Inputs/objc-general.proftext
  test/Profile/c-outdated-data.c
  test/Profile/cxx-hash-v2.cpp
  test/Profile/objc-general.m

Index: test/Profile/objc-general.m
===
--- test/Profile/objc-general.m
+++ test/Profile/objc-general.m
@@ -3,7 +3,9 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-use-path=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck -check-prefix=PGOUSE %s
+
+// PGOUSE-NOT: warning: profile data may be out of date
 
 #ifdef HAVE_FOUNDATION
 
@@ -63,6 +65,20 @@
 }
 @end
 
+void nested_objc_for_ranges(NSArray *arr) {
+  int x = 0;
+  for (id a in arr)
+for (id b in arr)
+  ++x;
+}
+
+void consecutive_objc_for_ranges(NSArray *arr) {
+  int x = 0;
+  for (id a in arr) {}
+  for (id b in arr)
+++x;
+}
+
 // PGOUSE-DAG: ![[FR1]] = !{!"branch_weights", i32 2, i32 3}
 // PGOUSE-DAG: ![[FR2]] = !{!"branch_weights", i32 3, i32 2}
 // PGOUSE-DAG: ![[BL1]] = !{!"branch_weights", i32 2, i32 2}
Index: test/Profile/cxx-hash-v2.cpp
===
--- /dev/null
+++ test/Profile/cxx-hash-v2.cpp
@@ -0,0 +1,177 @@
+// REQUIRES: shell
+
+// Check that all of the hashes in this file are unique (i.e, that none of the
+// profiles for these functions are mutually interchangeable).
+//
+// RUN: llvm-profdata show -all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes
+// RUN: uniq %t.hashes > %t.hashes.unique
+// RUN: diff %t.hashes %t.hashes.unique
+
+// RUN: llvm-profdata merge %S/Inputs/cxx-hash-v2.proftext -o %t.profdata
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -allow-empty
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%S/Inputs/cxx-hash-v2.profdata.v5 2>&1 | FileCheck %s -allow-empty
+
+// CHECK-NOT: warning: profile data may be out of date
+
+int x;
+int arr[1] = {0};
+
+void loop_after_if_else() {
+  if (1)
+x = 1;
+  else
+x = 2;
+  while (0)
+++x;
+}
+
+void loop_in_then_block() {
+  if (1) {
+while (0)
+  ++x;
+  } else {
+x = 2;
+  }
+}
+
+void loop_in_else_block() {
+  if (1) {
+x = 1;
+  } else {
+while (0)
+  ++x;
+  }
+}
+
+void if_inside_of_for() {
+  for (x = 0; x < 0; ++x) {
+x = 1;
+if (1)
+  x = 2;
+  }
+}
+
+void if_outside_of_for() {
+  for (x = 0; x < 0; ++x)
+x = 1;
+  if (1)
+x = 2;
+}
+
+void if_inside_of_while() {
+  while (0) {
+x = 1;
+if (1)
+  x = 2;
+  }
+}
+
+void if_outside_of_while() {
+  while (0)
+x = 1;
+  if (1)
+x = 2;
+}
+
+void nested_dos() {
+  do {
+do {
+  ++x;
+} while (0);
+  } while (0);
+}
+
+void consecutive_dos() {
+  do {
+  } while (0);
+  do {
+++x;
+  } while (0);
+}
+
+void loop_empty() {
+  for (x = 0; x < 5; ++x) {}
+}
+
+void loop_return() {
+  for (x = 0; x < 5; ++x)
+return;
+}
+
+void loop_continue() {
+  for (x = 0; x < 5; ++x)
+continue;
+}
+
+void loop_break() {
+  for (x = 0; x < 5; ++x)
+break;
+}
+
+void no_gotos() {
+  static void *dispatch[] = {&};
+  x = 0;
+done:
+  ++x;
+}
+
+void direct_goto() {
+  static void *dispatch[] = {&};
+  x = 0;
+  goto done;
+done:
+  ++x;
+}
+
+void indirect_goto() {
+  static void *dispatch[] = {&};
+  x = 0;
+  goto 

[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

2017-11-09 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added inline comments.



Comment at: test/Driver/cuda-bail-out.cu:47
+// CHECK-HOST-ERROR: Error during compilation for host
+// CHECK-HOST-ERROR-NOT: Error during compilation for sm_35

tra wrote:
> steven_wu wrote:
> > tra wrote:
> > > steven_wu wrote:
> > > > tra wrote:
> > > > > To make it more robust, I'd add another copy of the last line before 
> > > > > CHECK-HOST-ERROR: so it would catch device-side errors if they were 
> > > > > to happen ahead of the host.
> > > > > 
> > > > > Generally speaking, expected behavior is "I want to see an error from 
> > > > > one compilation only". We don't really care which CUDA compilation 
> > > > > phase produces it. Perhaps all we need in all test cases is:
> > > > > 
> > > > > ```
> > > > > CHECK: Error during compilation
> > > > > CHECK-NOT:  Error during compilation
> > > > > ```
> > > > > 
> > > > > This way we don't need to depend on specific phase order.
> > > > That will be a design choice for CUDA driver. I have no preference 
> > > > going either direction. Just let me know so I will update the test case.
> > > > 
> > > > Speaking of "-fsyntax-only", this is another interesting behavior of 
> > > > clang cuda driver:
> > > > ```
> > > > $ clang -x cuda /dev/null -x c /dev/null -ccc-print-phases
> > > > 14: input, "/dev/null", c, (host-cuda)
> > > > $ clang -fsyntax-only -x cuda /dev/null -x c /dev/null -ccc-print-phases
> > > > 9: input, "/dev/null", c
> > > > ```
> > > > So depending on if -fsyntax-only is used or not, the c language part 
> > > > can be either offloading or not offloading.
> > > > This is a corner case that the driver behavior will change after this 
> > > > patch.
> > > OK. Let's just check for one error only. 
> > > 
> > > As for the second, it is, IMO a problem. The file after ```-x c```  
> > > should have been treated as plain C input, regardless of -fsyntax-only.  
> > > It's reproducible in clean clang tree, so it's not due to this patch. 
> > The corner case I am talking about is after this patch, "-x c" will be 
> > syntax checked even if "-x cuda" failed the syntax check (which sounds 
> > good) but only when using "-fsyntax-only"
> > 
> > I am updating the test case.
> Sorry, I should've phrased my suggestion better. I didn't mean to remove 
> multiple sources of errors. Quite the opposite. There should be multiple test 
> runs with errors produced by combination of phases. E.g. host, host+sm_35, 
> host+sm_60, sm_35+sm+60, host+sm_35+sm_60.
> 
> The check itself is fine, you just need multiple runs that trigger errors 
> during particular phase.
> 
> ```
> #if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
> #error Host error
> #endif
> 
> #if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
> #error sm_35 error
> #endif
> ...
> 
> ```
> 
> and then do multiple runs with various combinations of -DERROR_xxx
> 
Hmm, I might still understand you incorrectly. If the error message is 
different for host and different devices, checking the error message requires 
the compilation being executed in a certain order. Otherwise, you won't know 
which error is going to be emitted.
On the other hand, if you don't care about the order and don't want to check 
for any ordering, the best we can do is run all the combinations and check the 
error only happens once. In my current test, I have host + default_sm, host + 
sm_35 + sim_60. I can add --cude-device-only but is there anything else I need 
to do?


https://reviews.llvm.org/D39502



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


[PATCH] D39611: [CodeGen] change const-ness of complex calls

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

In https://reviews.llvm.org/D39611#918654, @hfinkel wrote:

> In https://reviews.llvm.org/D39611#918275, @spatel wrote:
>
> > Patch updated:
> >  I don't know if we have agreement on the behavior that we want yet,
>
>
> I just sent a note to the Austin group mailing list to see if the POSIX folks 
> agree with my reading. I'll follow up.


They don't, so here's a summary...

1. It is not the intent of POSIX to restrict implementation choices here made 
available by the C specification. Oversights aside, places where POSIX 
intentionally restricts implementation choices allowed by C are given CX or XSI 
shading.

Moreover, 2.3 Error Numbers, says, "Implementations may... contain extensions 
or limitations that prevent some errors from occurring. The ERRORS section on 
each reference page specifies whether an error shall be returned, or whether it 
may be returned. Implementations shall not generate a different error number 
from the ones described here for error conditions described in this volume of 
IEEE Std 1003.1-2001, but may generate additional errors unless explicitly 
disallowed for a particular function." Because no errors are defined, and POSIX 
contains no specific prohibition on the complex.h functions returning errors 
via errno, no restriction on these functions setting errno is implied.

Thus, if C says that an implementation can set errno for functions in 
complex.h, POSIX does not restrict that.

2. 7.12 in C99 says that setting ERANGE on overflow is implementation-defined 
(same as in C90), but C99 TC3 and POSIX.1-2001 have math_errhandling, and 
there, when (math_errhandling & MATH_ERRNO) != 0, all overflows for functions 
in  set errno to ERANGE.

3. We can assume, for consistency, that the intent of the C standard is to 
allow math_errhandling, and thus associated requirements (e.g., the overflow 
requirements), to also apply to function in complex.h. G6p4 does say that there 
is an equivalence for floating-point exceptions (e.g., when (math_errhandling & 
MATH_ERREXCEPT) != 0), and so while errno is not explicitly discussed in this 
context, it is not unreasonable to assume this to be an oversight. It is also 
noted that in C99 Annex G was informative, not normative. So anything derived 
from Annex G is not a requirement until C11.

3. C11 DR#442 clarifies that, when Annex F is relevant, the definition of 
floating-point overflow in Annex F takes precedence over it being  generically 
undefined in the absence of Annex F. Moreover, as clarified by C90 DR#025, 
where the type as infinities, all values are within the represented range, and 
so just the fact that an infinity is generated as a result implies that an 
overflow had occurred. Overflow only occurs for cases where a value is 
generated outside of the represented range for its type, such as when doing 
floating-point-to-integer conversions.

But, C99 has an updated definition of overflow, and it says, 7.12.1p4, "A 
floating result overflows if the magnitude of the mathematical result is finite 
but so large that the mathematical result cannot be represented without 
extraordinary roundoff error in an object of the specified type." Moreover, 
C99's Annex F says, "The ‘‘overflow’’ floating-point exception is raised 
whenever an infinity - or, because of
rounding direction, a maximal-magnitude finite number - is returned in lieu of 
a value whose magnitude is too large." While the Annex F text replaces the 
overflow definition, and does not mention errno explicitly, it is reasonable to 
assume it does not eliminate the errno-associated requirements from 7.12.1p4 
intentionally.

Thus, cabs is fine to set errno, as can essentially all of the other complex.h 
functions.

> 
> 
>> but I'm updating the patch/description/title to only deal with  in 
>> this patch and taking a shot at one interpretation, so we can see what that 
>> might look like.
>> 
>> There are really 2 changes here:
>> 
>> 1. We had all of  marked constant all the time ('c'). I think 
>> there's agreement that can't be true by default (a platform could set errno 
>> on any of these calls based on the language in the C standard).
>> 2. We make an exception for a GNU environment - here, the calls are always 
>> constant because the standard allows - and POSIX constrains - the errno 
>> setting behavior. This is despite the fact that glibc is known to set errno 
>> in some cases.




https://reviews.llvm.org/D39611



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


[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

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



Comment at: test/Driver/cuda-bail-out.cu:47
+// CHECK-HOST-ERROR: Error during compilation for host
+// CHECK-HOST-ERROR-NOT: Error during compilation for sm_35

steven_wu wrote:
> tra wrote:
> > steven_wu wrote:
> > > tra wrote:
> > > > To make it more robust, I'd add another copy of the last line before 
> > > > CHECK-HOST-ERROR: so it would catch device-side errors if they were to 
> > > > happen ahead of the host.
> > > > 
> > > > Generally speaking, expected behavior is "I want to see an error from 
> > > > one compilation only". We don't really care which CUDA compilation 
> > > > phase produces it. Perhaps all we need in all test cases is:
> > > > 
> > > > ```
> > > > CHECK: Error during compilation
> > > > CHECK-NOT:  Error during compilation
> > > > ```
> > > > 
> > > > This way we don't need to depend on specific phase order.
> > > That will be a design choice for CUDA driver. I have no preference going 
> > > either direction. Just let me know so I will update the test case.
> > > 
> > > Speaking of "-fsyntax-only", this is another interesting behavior of 
> > > clang cuda driver:
> > > ```
> > > $ clang -x cuda /dev/null -x c /dev/null -ccc-print-phases
> > > 14: input, "/dev/null", c, (host-cuda)
> > > $ clang -fsyntax-only -x cuda /dev/null -x c /dev/null -ccc-print-phases
> > > 9: input, "/dev/null", c
> > > ```
> > > So depending on if -fsyntax-only is used or not, the c language part can 
> > > be either offloading or not offloading.
> > > This is a corner case that the driver behavior will change after this 
> > > patch.
> > OK. Let's just check for one error only. 
> > 
> > As for the second, it is, IMO a problem. The file after ```-x c```  should 
> > have been treated as plain C input, regardless of -fsyntax-only.  It's 
> > reproducible in clean clang tree, so it's not due to this patch. 
> The corner case I am talking about is after this patch, "-x c" will be syntax 
> checked even if "-x cuda" failed the syntax check (which sounds good) but 
> only when using "-fsyntax-only"
> 
> I am updating the test case.
Sorry, I should've phrased my suggestion better. I didn't mean to remove 
multiple sources of errors. Quite the opposite. There should be multiple test 
runs with errors produced by combination of phases. E.g. host, host+sm_35, 
host+sm_60, sm_35+sm+60, host+sm_35+sm_60.

The check itself is fine, you just need multiple runs that trigger errors 
during particular phase.

```
#if defined(ERROR_HOST) && !defined(__CUDA_ARCH__)
#error Host error
#endif

#if defined(ERROR_SM35) && (__CUDA_ARCH__ == 350)
#error sm_35 error
#endif
...

```

and then do multiple runs with various combinations of -DERROR_xxx



https://reviews.llvm.org/D39502



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


[PATCH] D39879: AMDGPU: Remove -mamdgpu-debugger-abi option

2017-11-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
Herald added subscribers: tpr, dstuttard, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D39879

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/AMDGPU.cpp
  test/Driver/amdgpu-features.c


Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -1,11 +1,3 @@
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=0.0 %s -o - 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-0-0: the clang compiler does not support 
'-mamdgpu-debugger-abi=0.0'
-
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o - 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-regs" "-target-feature" 
"+amdgpu-debugger-emit-prologue"
-
 // RUN: %clang -### -target amdgcn -mcpu=gfx700 -mxnack %s 2>&1 | FileCheck 
--check-prefix=XNACK %s
 // XNACK: "-target-feature" "+xnack"
 
Index: lib/Driver/ToolChains/AMDGPU.cpp
===
--- lib/Driver/ToolChains/AMDGPU.cpp
+++ lib/Driver/ToolChains/AMDGPU.cpp
@@ -39,17 +39,6 @@
 void amdgpu::getAMDGPUTargetFeatures(const Driver ,
  const llvm::opt::ArgList ,
  std::vector ) {
-  if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) {
-StringRef value = dAbi->getValue();
-if (value == "1.0") {
-  Features.push_back("+amdgpu-debugger-insert-nops");
-  Features.push_back("+amdgpu-debugger-reserve-regs");
-  Features.push_back("+amdgpu-debugger-emit-prologue");
-} else {
-  D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
-}
-  }
-
   handleTargetFeaturesGroup(
 Args, Features, options::OPT_m_amdgpu_Features_Group);
 }
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1834,11 +1834,6 @@
 def msimd128 : Flag<["-"], "msimd128">, Group;
 def mno_simd128 : Flag<["-"], "mno-simd128">, Group;
 
-def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
-  Flags<[HelpHidden]>,
-  Group,
-  HelpText<"Generate additional code for specified  of debugger ABI 
(AMDGPU only)">,
-  MetaVarName<"">;
 def mxnack : Flag<["-"], "mxnack">, Group,
   HelpText<"Enable XNACK (AMDGPU only)">;
 def mno_xnack : Flag<["-"], "mno-xnack">, Group,


Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -1,11 +1,3 @@
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=0.0 %s -o - 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-0-0: the clang compiler does not support '-mamdgpu-debugger-abi=0.0'
-
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=1.0 %s -o - 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-regs" "-target-feature" "+amdgpu-debugger-emit-prologue"
-
 // RUN: %clang -### -target amdgcn -mcpu=gfx700 -mxnack %s 2>&1 | FileCheck --check-prefix=XNACK %s
 // XNACK: "-target-feature" "+xnack"
 
Index: lib/Driver/ToolChains/AMDGPU.cpp
===
--- lib/Driver/ToolChains/AMDGPU.cpp
+++ lib/Driver/ToolChains/AMDGPU.cpp
@@ -39,17 +39,6 @@
 void amdgpu::getAMDGPUTargetFeatures(const Driver ,
  const llvm::opt::ArgList ,
  std::vector ) {
-  if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) {
-StringRef value = dAbi->getValue();
-if (value == "1.0") {
-  Features.push_back("+amdgpu-debugger-insert-nops");
-  Features.push_back("+amdgpu-debugger-reserve-regs");
-  Features.push_back("+amdgpu-debugger-emit-prologue");
-} else {
-  D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
-}
-  }
-
   handleTargetFeaturesGroup(
 Args, Features, options::OPT_m_amdgpu_Features_Group);
 }
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1834,11 +1834,6 @@
 def msimd128 : Flag<["-"], "msimd128">, Group;
 def mno_simd128 : Flag<["-"], "mno-simd128">, Group;
 
-def mamdgpu_debugger_abi : 

[PATCH] D39878: AMDGPU: Add -mxnack/-mno-xnack options that set +/-xnack feature

2017-11-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
Herald added subscribers: tpr, dstuttard, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D39878

Files:
  include/clang/Driver/Options.td
  test/Driver/amdgpu-features.c


Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -5,3 +5,9 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o - 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
 // CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-regs" "-target-feature" 
"+amdgpu-debugger-emit-prologue"
+
+// RUN: %clang -### -target amdgcn -mcpu=gfx700 -mxnack %s 2>&1 | FileCheck 
--check-prefix=XNACK %s
+// XNACK: "-target-feature" "+xnack"
+
+// RUN: %clang -### -target amdgcn -mcpu=gfx700 -mno-xnack %s 2>&1 | FileCheck 
--check-prefix=NO-XNACK %s
+// NO-XNACK: "-target-feature" "-xnack"
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1822,7 +1822,6 @@
 
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, 
Group,
   HelpText<"Generate code which only uses the general purpose registers 
(AArch64 only)">;
-
 def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">,
   Group,
   HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">;
@@ -1840,6 +1839,10 @@
   Group,
   HelpText<"Generate additional code for specified  of debugger ABI 
(AMDGPU only)">,
   MetaVarName<"">;
+def mxnack : Flag<["-"], "mxnack">, Group,
+  HelpText<"Enable XNACK (AMDGPU only)">;
+def mno_xnack : Flag<["-"], "mno-xnack">, Group,
+  HelpText<"Disable XNACK (AMDGPU only)">;
 
 def faltivec : Flag<["-"], "faltivec">, Group, Flags<[DriverOption]>;
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, 
Flags<[DriverOption]>;


Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -5,3 +5,9 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=1.0 %s -o - 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
 // CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-regs" "-target-feature" "+amdgpu-debugger-emit-prologue"
+
+// RUN: %clang -### -target amdgcn -mcpu=gfx700 -mxnack %s 2>&1 | FileCheck --check-prefix=XNACK %s
+// XNACK: "-target-feature" "+xnack"
+
+// RUN: %clang -### -target amdgcn -mcpu=gfx700 -mno-xnack %s 2>&1 | FileCheck --check-prefix=NO-XNACK %s
+// NO-XNACK: "-target-feature" "-xnack"
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1822,7 +1822,6 @@
 
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group,
   HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">;
-
 def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">,
   Group,
   HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">;
@@ -1840,6 +1839,10 @@
   Group,
   HelpText<"Generate additional code for specified  of debugger ABI (AMDGPU only)">,
   MetaVarName<"">;
+def mxnack : Flag<["-"], "mxnack">, Group,
+  HelpText<"Enable XNACK (AMDGPU only)">;
+def mno_xnack : Flag<["-"], "mno-xnack">, Group,
+  HelpText<"Disable XNACK (AMDGPU only)">;
 
 def faltivec : Flag<["-"], "faltivec">, Group, Flags<[DriverOption]>;
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, Flags<[DriverOption]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39877: AMDGPU/NFC: Move getAMDGPUTargetFeatures to AMDGPU toolchain

2017-11-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
Herald added subscribers: tpr, dstuttard, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D39877

Files:
  lib/Driver/ToolChains/AMDGPU.cpp
  lib/Driver/ToolChains/AMDGPU.h
  lib/Driver/ToolChains/Clang.cpp

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -15,6 +15,7 @@
 #include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "Arch/X86.h"
+#include "AMDGPU.h"
 #include "CommonArgs.h"
 #include "Hexagon.h"
 #include "InputInfo.h"
@@ -278,23 +279,6 @@
   handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group);
 }
 
-static void getAMDGPUTargetFeatures(const Driver , const ArgList ,
-std::vector ) {
-  if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) {
-StringRef value = dAbi->getValue();
-if (value == "1.0") {
-  Features.push_back("+amdgpu-debugger-insert-nops");
-  Features.push_back("+amdgpu-debugger-reserve-regs");
-  Features.push_back("+amdgpu-debugger-emit-prologue");
-} else {
-  D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
-}
-  }
-
-  handleTargetFeaturesGroup(
-Args, Features, options::OPT_m_amdgpu_Features_Group);
-}
-
 static void getTargetFeatures(const ToolChain , const llvm::Triple ,
   const ArgList , ArgStringList ,
   bool ForAS) {
@@ -347,7 +331,7 @@
 break;
   case llvm::Triple::r600:
   case llvm::Triple::amdgcn:
-getAMDGPUTargetFeatures(D, Args, Features);
+amdgpu::getAMDGPUTargetFeatures(D, Args, Features);
 break;
   }
 
Index: lib/Driver/ToolChains/AMDGPU.h
===
--- lib/Driver/ToolChains/AMDGPU.h
+++ lib/Driver/ToolChains/AMDGPU.h
@@ -19,7 +19,6 @@
 namespace clang {
 namespace driver {
 namespace tools {
-
 namespace amdgpu {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
@@ -33,6 +32,9 @@
 const char *LinkingOutput) const override;
 };
 
+void getAMDGPUTargetFeatures(const Driver , const llvm::opt::ArgList ,
+ std::vector );
+
 } // end namespace amdgpu
 } // end namespace tools
 
Index: lib/Driver/ToolChains/AMDGPU.cpp
===
--- lib/Driver/ToolChains/AMDGPU.cpp
+++ lib/Driver/ToolChains/AMDGPU.cpp
@@ -11,6 +11,7 @@
 #include "CommonArgs.h"
 #include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -35,6 +36,24 @@
   CmdArgs, Inputs));
 }
 
+void amdgpu::getAMDGPUTargetFeatures(const Driver ,
+ const llvm::opt::ArgList ,
+ std::vector ) {
+  if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) {
+StringRef value = dAbi->getValue();
+if (value == "1.0") {
+  Features.push_back("+amdgpu-debugger-insert-nops");
+  Features.push_back("+amdgpu-debugger-reserve-regs");
+  Features.push_back("+amdgpu-debugger-emit-prologue");
+} else {
+  D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
+}
+  }
+
+  handleTargetFeaturesGroup(
+Args, Features, options::OPT_m_amdgpu_Features_Group);
+}
+
 /// AMDGPU Toolchain
 AMDGPUToolChain::AMDGPUToolChain(const Driver , const llvm::Triple ,
  const ArgList )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 122352.
dberris retitled this revision from "[XRay] Initial XRay in Darwin Support" to 
"[XRay][darwin] Initial XRay in Darwin Support".
dberris edited the summary of this revision.
dberris removed subscribers: echristo, pelikan.
dberris added a comment.
This revision is now accepted and ready to land.

Re-title, back out test changes to a different patch.


https://reviews.llvm.org/D39114

Files:
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/XRayArgs.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/xray/CMakeLists.txt
  compiler-rt/lib/xray/tests/CMakeLists.txt
  compiler-rt/lib/xray/weak_symbols.txt
  compiler-rt/lib/xray/xray_init.cc
  compiler-rt/lib/xray/xray_trampoline_x86_64.S
  compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
  compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
  compiler-rt/test/xray/TestCases/Linux/lit.local.cfg
  compiler-rt/test/xray/lit.cfg

Index: compiler-rt/test/xray/lit.cfg
===
--- compiler-rt/test/xray/lit.cfg
+++ compiler-rt/test/xray/lit.cfg
@@ -40,7 +40,7 @@
 # Default test suffixes.
 config.suffixes = ['.c', '.cc', '.cpp']
 
-if config.host_os not in ['Linux']:
+if config.host_os not in ['Linux', 'Darwin']:
   config.unsupported = True
 elif '64' not in config.host_arch:
   if 'arm' in config.host_arch:
Index: compiler-rt/test/xray/TestCases/Linux/lit.local.cfg
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Linux/lit.local.cfg
@@ -0,0 +1,9 @@
+def getRoot(config):
+  if not config.parent:
+return config
+  return getRoot(config.parent)
+
+root = getRoot(config)
+
+if root.host_os not in ['Linux']:
+  config.unsupported = True
Index: compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
@@ -0,0 +1,9 @@
+def getRoot(config):
+  if not config.parent:
+return config
+  return getRoot(config.parent)
+
+root = getRoot(config)
+
+if root.host_os not in ['Darwin']:
+  config.unsupported = True
Index: compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
@@ -0,0 +1,23 @@
+// Test that the always/never instrument lists apply.
+// RUN: echo "fun:main" > %tmp-always.txt
+// RUN: echo "fun:__xray*" > %tmp-never.txt
+// RUN: %clangxx_xray \
+// RUN: -fxray-never-instrument=%tmp-never.txt \
+// RUN: -fxray-always-instrument=%tmp-always.txt \
+// RUN: %s -o %t
+// RUN: %llvm_xray extract -symbolize %t | \
+// RUN:FileCheck %s --check-prefix NOINSTR
+// RUN: %llvm_xray extract -symbolize %t | \
+// RUN:FileCheck %s --check-prefix ALWAYSINSTR
+// REQUIRES: x86_64-linux
+// REQUIRES: built-in-llvm-tree
+
+// NOINSTR-NOT: {{.*__xray_NeverInstrumented.*}}
+int __xray_NeverInstrumented() {
+  return 0;
+}
+
+// ALWAYSINSTR: {{.*function-name:.*main.*}}
+int main(int argc, char *argv[]) {
+  return __xray_NeverInstrumented();
+}
Index: compiler-rt/lib/xray/xray_trampoline_x86_64.S
===
--- compiler-rt/lib/xray/xray_trampoline_x86_64.S
+++ compiler-rt/lib/xray/xray_trampoline_x86_64.S
@@ -14,10 +14,13 @@
 //===--===//
 
 #include "../builtins/assembly.h"
+#include "../sanitizer_common/sanitizer_asm.h"
+
+
 
 .macro SAVE_REGISTERS
 	subq $192, %rsp
-	.cfi_def_cfa_offset 200
+	CFI_DEF_CFA_OFFSET(200)
 	// At this point, the stack pointer should be aligned to an 8-byte boundary,
 	// because any call instructions that come after this will add another 8
 	// bytes and therefore align it to 16-bytes.
@@ -57,25 +60,28 @@
 	movq	8(%rsp), %r8
 	movq	0(%rsp), %r9
 	addq	$192, %rsp
-	.cfi_def_cfa_offset 8
+	CFI_DEF_CFA_OFFSET(8)
 .endm
 
-	.text
+#if !defined(__APPLE__)
+	.section .text
+#else
+	.section __TEXT,__text
+#endif
 	.file "xray_trampoline_x86.S"
 
 //===--===//
 
-	.globl __xray_FunctionEntry
+	.globl ASM_TSAN_SYMBOL(__xray_FunctionEntry)
 	.align 16, 0x90
-	.type __xray_FunctionEntry,@function
-
-__xray_FunctionEntry:
-	.cfi_startproc
+	ASM_TYPE_FUNCTION(__xray_FunctionEntry)
+ASM_TSAN_SYMBOL(__xray_FunctionEntry):
+	CFI_STARTPROC
 	SAVE_REGISTERS
 
 	// This load has to be atomic, it's concurrent with __xray_patch().
 	// On x86/amd64, a simple (type-aligned) MOV instruction is enough.
-	movq	_ZN6__xray19XRayPatchedFunctionE(%rip), %rax
+	movq	ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
 	testq	%rax, %rax
 	je	.Ltmp0
 
@@ -86,28 +92,27 @@
 .Ltmp0:
 	RESTORE_REGISTERS
 	retq
-.Ltmp1:
-	.size 

[PATCH] D39502: [Driver] Make clang/cc conforms to UNIX standard

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

I abdicate as a reviewer in favor of tra -- if he's happy, I'm happy.


https://reviews.llvm.org/D39502



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


r317849 - [analyzer] [NFC] Minor ExprEngineC refactoring

2017-11-09 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Nov  9 15:33:37 2017
New Revision: 317849

URL: http://llvm.org/viewvc/llvm-project?rev=317849=rev
Log:
[analyzer] [NFC] Minor ExprEngineC refactoring

Move a repeated block of code into a function.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=317849=317848=317849=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Thu Nov  9 15:33:37 2017
@@ -20,6 +20,24 @@ using namespace clang;
 using namespace ento;
 using llvm::APSInt;
 
+/// \brief Optionally conjure and return a symbol for offset when processing
+/// an expression \p Expression.
+/// If \p Other is a location, conjure a symbol for \p Symbol
+/// (offset) if it is unknown so that memory arithmetic always
+/// results in an ElementRegion.
+/// \p Count The number of times the current basic block was visited.
+static SVal conjureOffsetSymbolOnLocation(
+SVal Symbol, SVal Other, Expr* Expression, SValBuilder ,
+unsigned Count, const LocationContext *LCtx) {
+  QualType Ty = Expression->getType();
+  if (Other.getAs() &&
+  Ty->isIntegralOrEnumerationType() &&
+  Symbol.isUnknown()) {
+return svalBuilder.conjureSymbolVal(Expression, LCtx, Ty, Count);
+  }
+  return Symbol;
+}
+
 void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
  ExplodedNode *Pred,
  ExplodedNodeSet ) {
@@ -63,24 +81,13 @@ void ExprEngine::VisitBinaryOperator(con
   StmtNodeBuilder Bldr(*it, Tmp2, *currBldrCtx);
 
   if (B->isAdditiveOp()) {
-// If one of the operands is a location, conjure a symbol for the other
-// one (offset) if it's unknown so that memory arithmetic always
-// results in an ElementRegion.
 // TODO: This can be removed after we enable history tracking with
 // SymSymExpr.
 unsigned Count = currBldrCtx->blockCount();
-if (LeftV.getAs() &&
-RHS->getType()->isIntegralOrEnumerationType() &&
-RightV.isUnknown()) {
-  RightV = svalBuilder.conjureSymbolVal(RHS, LCtx, RHS->getType(),
-Count);
-}
-if (RightV.getAs() &&
-LHS->getType()->isIntegralOrEnumerationType() &&
-LeftV.isUnknown()) {
-  LeftV = svalBuilder.conjureSymbolVal(LHS, LCtx, LHS->getType(),
-   Count);
-}
+RightV = conjureOffsetSymbolOnLocation(
+RightV, LeftV, RHS, svalBuilder, Count, LCtx);
+LeftV = conjureOffsetSymbolOnLocation(
+LeftV, RightV, LHS, svalBuilder, Count, LCtx);
   }
 
   // Although we don't yet model pointers-to-members, we do need to make


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


[PATCH] D39584: [analyzer] [NFC] another very minor ExprEngineC refactoring

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317849: [analyzer] [NFC] Minor ExprEngineC refactoring 
(authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D39584?vs=121814=122345#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39584

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -20,6 +20,24 @@
 using namespace ento;
 using llvm::APSInt;
 
+/// \brief Optionally conjure and return a symbol for offset when processing
+/// an expression \p Expression.
+/// If \p Other is a location, conjure a symbol for \p Symbol
+/// (offset) if it is unknown so that memory arithmetic always
+/// results in an ElementRegion.
+/// \p Count The number of times the current basic block was visited.
+static SVal conjureOffsetSymbolOnLocation(
+SVal Symbol, SVal Other, Expr* Expression, SValBuilder ,
+unsigned Count, const LocationContext *LCtx) {
+  QualType Ty = Expression->getType();
+  if (Other.getAs() &&
+  Ty->isIntegralOrEnumerationType() &&
+  Symbol.isUnknown()) {
+return svalBuilder.conjureSymbolVal(Expression, LCtx, Ty, Count);
+  }
+  return Symbol;
+}
+
 void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
  ExplodedNode *Pred,
  ExplodedNodeSet ) {
@@ -63,24 +81,13 @@
   StmtNodeBuilder Bldr(*it, Tmp2, *currBldrCtx);
 
   if (B->isAdditiveOp()) {
-// If one of the operands is a location, conjure a symbol for the other
-// one (offset) if it's unknown so that memory arithmetic always
-// results in an ElementRegion.
 // TODO: This can be removed after we enable history tracking with
 // SymSymExpr.
 unsigned Count = currBldrCtx->blockCount();
-if (LeftV.getAs() &&
-RHS->getType()->isIntegralOrEnumerationType() &&
-RightV.isUnknown()) {
-  RightV = svalBuilder.conjureSymbolVal(RHS, LCtx, RHS->getType(),
-Count);
-}
-if (RightV.getAs() &&
-LHS->getType()->isIntegralOrEnumerationType() &&
-LeftV.isUnknown()) {
-  LeftV = svalBuilder.conjureSymbolVal(LHS, LCtx, LHS->getType(),
-   Count);
-}
+RightV = conjureOffsetSymbolOnLocation(
+RightV, LeftV, RHS, svalBuilder, Count, LCtx);
+LeftV = conjureOffsetSymbolOnLocation(
+LeftV, RightV, LHS, svalBuilder, Count, LCtx);
   }
 
   // Although we don't yet model pointers-to-members, we do need to make


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -20,6 +20,24 @@
 using namespace ento;
 using llvm::APSInt;
 
+/// \brief Optionally conjure and return a symbol for offset when processing
+/// an expression \p Expression.
+/// If \p Other is a location, conjure a symbol for \p Symbol
+/// (offset) if it is unknown so that memory arithmetic always
+/// results in an ElementRegion.
+/// \p Count The number of times the current basic block was visited.
+static SVal conjureOffsetSymbolOnLocation(
+SVal Symbol, SVal Other, Expr* Expression, SValBuilder ,
+unsigned Count, const LocationContext *LCtx) {
+  QualType Ty = Expression->getType();
+  if (Other.getAs() &&
+  Ty->isIntegralOrEnumerationType() &&
+  Symbol.isUnknown()) {
+return svalBuilder.conjureSymbolVal(Expression, LCtx, Ty, Count);
+  }
+  return Symbol;
+}
+
 void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
  ExplodedNode *Pred,
  ExplodedNodeSet ) {
@@ -63,24 +81,13 @@
   StmtNodeBuilder Bldr(*it, Tmp2, *currBldrCtx);
 
   if (B->isAdditiveOp()) {
-// If one of the operands is a location, conjure a symbol for the other
-// one (offset) if it's unknown so that memory arithmetic always
-// results in an ElementRegion.
 // TODO: This can be removed after we enable history tracking with
 // SymSymExpr.
 unsigned Count = currBldrCtx->blockCount();
-if (LeftV.getAs() &&
-RHS->getType()->isIntegralOrEnumerationType() &&
-RightV.isUnknown()) {
-  RightV = svalBuilder.conjureSymbolVal(RHS, LCtx, RHS->getType(),
-Count);
-}
-if (RightV.getAs() &&
-LHS->getType()->isIntegralOrEnumerationType() &&
-LeftV.isUnknown()) {
-  LeftV = 

[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris planned changes to this revision.
dberris added a comment.

In https://reviews.llvm.org/D39114#920591, @kubamracek wrote:

> > When linking the final binary, the XRay runtime can't seem to find the 
> > `__{start,stop}_xray_{fn_idx,instr_map}` symbols. I've marked them weak, 
> > but they seem to either not be resolved when statically linking the binary. 
> > The dynamic lib version of the XRay runtime isn't quite ready yet, but I'm 
> > willing to try some things there.
> >  There are also missing symbols from the sanitizer_common library that's 
> > linked to from the `libclang_rt.xray_osx.a` produced by the compiler-rt 
> > XRay build configuration.
> >  Any further hints/thoughts on this would be great, @kubamracek (cc 
> > @pelikan and @echristo)
>
> This is one of the reasons why a dynamic shared library works better. Using a 
> dynamic library should solve this. What are the problems with that?


Nothing fundamentally wrong with doing that, except for the clang changes to 
link correctly (which I still need to experiment with). Let me go that route 
and report back.

I'll also split the patch up into smaller bits. The changes to the tests can be 
a separate change. I'll back those out and re-upload.

Thanks!


https://reviews.llvm.org/D39114



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


[PATCH] D39852: [clangd] Support returning a limited number of completion results.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 122342.
sammccall added a comment.

Oops, sorting was backwards (test caught it, but I forgot to run it)


https://reviews.llvm.org/D39852

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/authority-less-uri.test
  test/clangd/completion-items-kinds.test
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -619,16 +619,15 @@
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
   template 
-  bool ContainsItemPred(std::vector const ,
-Predicate Pred) {
-for (const auto  : Items) {
+  bool ContainsItemPred(CompletionList const , Predicate Pred) {
+for (const auto  : Items.items) {
   if (Pred(Item))
 return true;
 }
 return false;
   }
 
-  bool ContainsItem(std::vector const , StringRef Name) {
+  bool ContainsItem(CompletionList const , StringRef Name) {
 return ContainsItemPred(Items, [Name](clangd::CompletionItem Item) {
   return Item.insertText == Name;
 });
@@ -694,6 +693,44 @@
   }
 }
 
+TEST_F(ClangdCompletionTest, Limit) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  Opts.Limit = 2;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  Opts, EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  StringWithPos Completion = parseTextMarker(R"cpp(
+struct ClassWithMembers {
+  int AAA();
+  int BBB();
+  int CCC();
+}
+int main() { ClassWithMembers().{complete} }
+  )cpp",
+ "complete");
+  Server.addDocument(FooCpp, Completion.Text);
+
+  /// For after-dot completion we must always get consistent results.
+  auto Results = Server
+ .codeComplete(FooCpp, Completion.MarkerPos,
+   StringRef(Completion.Text))
+ .get()
+ .Value;
+
+  EXPECT_TRUE(Results.isIncomplete);
+  EXPECT_EQ(Opts.Limit, Results.items.size());
+  EXPECT_TRUE(ContainsItem(Results, "AAA"));
+  EXPECT_TRUE(ContainsItem(Results, "BBB"));
+  EXPECT_FALSE(ContainsItem(Results, "CCC"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -31,14 +31,17 @@
 #
 #  CHECK:  "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 
 X-Test: Testing
 Content-Type: application/vscode-jsonrpc; charset-utf-8
@@ -57,14 +60,17 @@
 #
 #  CHECK:  "id": 3,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
 
 Content-Type: application/vscode-jsonrpc; charset-utf-8
@@ -83,14 +89,17 @@
 #
 #  CHECK:  "id": 5,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  

[PATCH] D39584: [analyzer] [NFC] another very minor ExprEngineC refactoring

2017-11-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Yes, looks great. Thanks!


https://reviews.llvm.org/D39584



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


[PATCH] D39050: Add index-while-building support to Clang

2017-11-09 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes planned changes to this revision.
nathawes added a comment.

In https://reviews.llvm.org/D39050#920451, @ioeric wrote:

> In https://reviews.llvm.org/D39050#900830, @arphaman wrote:
>
> > I think this patch should be split into a number of smaller patches to help 
> > the review process.
> >
> > Things like `tools/IndexStore`, `DirectoryWatcher` and other components 
> > that are not directly needed right now should definitely be in their own 
> > patches.
> >  It would be nice to find some way to split the implementation into 
> > multiple patches as well.
>
>
> +1.
>
> This is a lot of work (but great work!) for one patch. Smaller/incremental 
> patches help reviewers understand and (hopefully) capture potential 
> improvement of the design. I would really appreciate it if you could further 
> split the patch.


Thanks for taking a look @ioeric! I'll have a go at splitting it further.

> Some comments/ideas:
> 
> - The lack of tests is a bit concerning.

I moved all the code for reading the index store data into a separate patch (to 
come after this one) in order to slim this one down for review, and most of the 
tests went with it because they're based around reading and dumping the stored 
data for FileCheck. The original version of this patch has them all 
(https://reviews.llvm.org/D39050?id=118854). The ones that remain here are just 
those checking that the unit/record files are written out and that the hashing 
mechanism is producing distinct record files when the symbolic content of the 
source file changes.

> - I think the implementation of the index output logic (e.g. 
> `IndexUnitWriter` and bit format file) can be abstracted away (and split into 
> separate patches) so that you can unit-test the action with a custom/mock 
> unit writer; this would also make the action reusable with (potentially) 
> other storage formats.

The added IndexRecordAction and existing IndexAction use the same functionality 
from libIndex to collect the indexing data, so I'm not sure mocking the unit 
writer to unit test IndexRecordAction would add very much value – writing the 
index data out is the new behavior. The existing tests for IndexAction (under 
test/Index/Core) are already covering the correctness of the majority of the 
collected indexing info and the tests coming in the follow-up patch (seen in 
the original version of this patch) test it's still correct after the 
write/read round trip.

> - I would suggest that you start with a patch that implement the index action 
> and just enough components so that you could test the action.
> 
>   Thanks!


https://reviews.llvm.org/D39050



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


[PATCH] D39738: [clangd] Sort completion results.

2017-11-09 Thread Francisco Lopes da Silva via Phabricator via cfe-commits
francisco.lopes added a comment.

OK. I do agree serialization, etc, is a stumbling block on delivering large 
results fast. I just wanted to warn on this because I've just seen ycmd devs 
went through this, where sorting was one of the bottlenecks, like, to 
`std::sort` 43k results instead of simply partial sorting them just over a 30 
results window, which is orders of magnitude faster.

If LSP completion ends up only feasible when there's filtering server side, 
with its own hard-coded sorting/filtering/ranking mechanisms, it's really sad, 
because it completely reduce flexibility of consumers wishing to apply their 
own (custom/configurable/uniform) sorting mechanisms.


Repository:
  rL LLVM

https://reviews.llvm.org/D39738



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


[PATCH] D39738: [clangd] Sort completion results.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D39738#921103, @francisco.lopes wrote:

> I'm still in the process of construction of a general jsonrpc/LSP client and 
> didn't start consuming clangd yet.


If you concerns about clangd's responsiveness, I recommend testing using 
VSCode, which has a high-quality LSP client. The clangd plugin can be installed 
from the extension browser.

> But, I do have previous experience with libclang, and I don't know whether 
> clangd will be able to return completion results at global scope (not 
> necessarily on member access solely), like libclang does.

Yes, this works today. On my usage in the LLVM codebase it's fast (~0.5 ms) but 
VSCode takes ~200ms to process the results, and other clients (e.g. an 
experimental YCMd integration) are much slower. Based on this, I'm not 
concerned about the server-side sorting overhead.

> This is my main concern, because global scope completion is one of the most 
> useful use cases, even more in languages like C, but the results can be large 
> and can go at the order of 43k results by simply including a header like 
> windows.h . As I still 
> didn't start consuming clangd, I don't know whether it even supports 
> returning all the results from libclang to let the client do its filtering 
> and sorting.

This will work, but it's not really possible to make it fast. Fully populating, 
serializing and deserializing 43k results so the client can see them is a lot 
of work.
The only way to make this fast is to score and filter results before seralizing 
them. https://reviews.llvm.org/D39852 goes down this path. (It can be disabled 
if you're set on filtering client-side).


Repository:
  rL LLVM

https://reviews.llvm.org/D39738



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


[PATCH] D39738: [clangd] Sort completion results.

2017-11-09 Thread Francisco Lopes da Silva via Phabricator via cfe-commits
francisco.lopes added a comment.

I'm still in the process of construction a general jsonrpc client and didn't 
start consuming clangd yet. But, I do have previous experience with libclang, 
and I don't know whether clangd will be able to return completion results at 
global scope (not necessarily on member access solely), like libclang does. 
This is my main concern, because global scope completion is one of the most 
useful use cases, even more in languages like C, but the results can be large 
and can go at the order of 43k results by simply including a header like 
windows.h . As I still 
didn't start consuming clangd, I don't know whether it even supports returns 
all the results from libclang to let the client do its filtering and sorting.


Repository:
  rL LLVM

https://reviews.llvm.org/D39738



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


[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

2017-11-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 122329.
jdenny added a comment.

Hi Alexey.  Thanks for your comments.  This update should address them all.


https://reviews.llvm.org/D39859

Files:
  lib/Sema/SemaExpr.cpp
  test/OpenMP/parallel_firstprivate_messages.cpp


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,8 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not 
refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}}
+  #pragma omp parallel firstprivate (d)
+d = 5; // expected-error {{cannot assign to variable 'd' with 
const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected 
variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool HasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (HasConst)
+DeclRefType.addConst();
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,8 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+  #pragma omp parallel firstprivate (d)
+d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool HasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (HasConst)
+DeclRefType.addConst();
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 122327.

https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,33 @@
   }
 }
 
+static bool checkAllAreIntegral(Sema , const AttributeList ) {
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);
+if (E && !E->getType()->isIntegralOrEnumerationType()) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+<< getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+<< E->getSourceRange();
+
+  return false;
+}
+  }
+
+  return true;
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema , Decl *D,
   const AttributeList ) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5510,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema , Decl *D,
const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
-Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+MaxExpr = Attr.getArgAsExpr(1);
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5547,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
+ AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7661,6 +7661,16 @@
 };
 }
 
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+{
+  assert(E);
+
+  llvm::APSInt Tmp{32, 0};
+  E->EvaluateAsInt(Tmp, Ctx);
+
+  return Tmp;
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ,
 ForDefinition_t IsForDefinition) const {
@@ -7676,8 +7686,11 @@
 FD->getAttr() : nullptr;
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+llvm::APSInt KMin 

[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317839: [analyzer] do not crash when trying to convert an 
APSInt to an unexpected type (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D39862?vs=122306=122328#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39862

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
  cfe/trunk/test/Analysis/taint-tester.c


Index: cfe/trunk/test/Analysis/taint-tester.c
===
--- cfe/trunk/test/Analysis/taint-tester.c
+++ cfe/trunk/test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()


Index: cfe/trunk/test/Analysis/taint-tester.c
===
--- cfe/trunk/test/Analysis/taint-tester.c
+++ cfe/trunk/test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317839 - [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Nov  9 13:49:38 2017
New Revision: 317839

URL: http://llvm.org/viewvc/llvm-project?rev=317839=rev
Log:
[analyzer] do not crash when trying to convert an APSInt to an unexpected type

This is the issue breaking the postgresql bot, purely by chance exposed
through taint checker, somehow appearing after
https://reviews.llvm.org/D38358 got committed.

The backstory is that the taint checker requests SVal for the value of
the pointer, and analyzer has a "fast path" in the getter to return a
constant when we know that the value is constant.
Unfortunately, the getter requires a cast to get signedness correctly,
and for the pointer `void *` the cast crashes.

This is more of a band-aid patch, as I am not sure what could be done
here "correctly", but it should be applied in any case to avoid the
crash.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/test/Analysis/taint-tester.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=317839=317838=317839=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Thu Nov  9 13:49:38 2017
@@ -260,7 +260,9 @@ SVal ProgramState::getSVal(Loc location,
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()

Modified: cfe/trunk/test/Analysis/taint-tester.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/taint-tester.c?rev=317839=317838=317839=diff
==
--- cfe/trunk/test/Analysis/taint-tester.c (original)
+++ cfe/trunk/test/Analysis/taint-tester.c Thu Nov  9 13:49:38 2017
@@ -189,3 +189,10 @@ void atoiTest() {
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}


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


[clang-tools-extra] r317838 - [clangd] Fix compilation database detection

2017-11-09 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov  9 13:45:27 2017
New Revision: 317838

URL: http://llvm.org/viewvc/llvm-project?rev=317838=rev
Log:
[clangd] Fix compilation database detection

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=317838=317837=317838=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Thu Nov  9 
13:45:27 2017
@@ -81,7 +81,7 @@ DirectoryBasedGlobalCompilationDatabase:
 return CachedIt->second.get();
   std::string Error = "";
   auto CDB = tooling::CompilationDatabase::loadFromDirectory(File, Error);
-  if (CDB && Error.empty()) {
+  if (CDB) {
 auto Result = CDB.get();
 CompilationDatabases.insert(std::make_pair(File, std::move(CDB)));
 return Result;


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


[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 added a comment.

In https://reviews.llvm.org/D5767#920085, @rsmith wrote:

> I'm not entirely sure what's happening with this and 
> https://reviews.llvm.org/D38818, but the direction looks good to me, and I 
> left a couple of comments on the other review thread.


This was the original pull request. I created https://reviews.llvm.org/D38818 
when I didn't know how to update this one (it was originally created by Mikael, 
not me). I have updated https://reviews.llvm.org/D38818 and this one as well 
based on the comments, so both pull requests have the same code now (and I'll 
cancel the one that does not get merged).


https://reviews.llvm.org/D5767



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx marked an inline comment as done.
AlexVlx added a comment.

In https://reviews.llvm.org/D39857#920814, @kzhuravl wrote:

> Hi Alex, can you rebase on top of trunk (I think you brought in some extra 
> changes from hcc branch) and upload a full diff?


Hello Konstantine - apologies about that, hopefully it's correct now. Thank you.


https://reviews.llvm.org/D39857



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


[PATCH] D38818: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 marked an inline comment as done.
sabel83 added a comment.

The last update of the patch also contains the changes to this pull request 
based on comments from https://reviews.llvm.org/D5767.


https://reviews.llvm.org/D38818



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


[PATCH] D38818: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 marked an inline comment as done.
sabel83 added a comment.

I have moved the tests into their own directory in the last update.




Comment at: tools/CMakeLists.txt:37
 add_clang_subdirectory(libclang)
+add_subdirectory(templight)

rsmith wrote:
> Did you mean to include this in this patch? There's no such directory added 
> here. (Should this be an `add_llvm_external_project`, to pick up some 
> external project if it's checked out here?)
It is a reference to a utility based on this patch. The utility has not been 
finished yet, so I have removed that line.


https://reviews.llvm.org/D38818



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


[PATCH] D38818: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 updated this revision to Diff 122324.

https://reviews.llvm.org/D38818

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/FrontendOptions.h
  include/clang/FrontendTool/Utils.h
  include/clang/Sema/Sema.h
  include/clang/Sema/TemplateInstCallback.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/Parse/ParseAST.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  test/Templight/templight-deduced-func.cpp
  test/Templight/templight-default-arg-inst.cpp
  test/Templight/templight-default-func-arg.cpp
  test/Templight/templight-default-template-arg.cpp
  test/Templight/templight-exception-spec-func.cpp
  test/Templight/templight-explicit-template-arg.cpp
  test/Templight/templight-memoization.cpp
  test/Templight/templight-nested-memoization.cpp
  test/Templight/templight-nested-template-instantiation.cpp
  test/Templight/templight-one-instantiation.cpp
  test/Templight/templight-prior-template-arg.cpp

Index: test/Templight/templight-prior-template-arg.cpp
===
--- test/Templight/templight-prior-template-arg.cpp
+++ test/Templight/templight-prior-template-arg.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+template
+class A {};
+
+template  class Outer>
+class B {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B::Outer'$}}
+// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+50]]{{:1'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B::Outer'$}}
+// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+45]]{{:1'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+39]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+34]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+28]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+23]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+17]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+12]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+6]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+1]]{{:6'$}}
+B b;
Index: test/Templight/templight-one-instantiation.cpp
===
--- test/Templight/templight-one-instantiation.cpp
+++ test/Templight/templight-one-instantiation.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+
+template 
+struct foo {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:}}[[@LINE+6]]{{:10'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:}}[[@LINE+1]]{{:10'$}}
+foo x;
Index: test/Templight/templight-nested-template-instantiation.cpp
===
--- test/Templight/templight-nested-template-instantiation.cpp
+++ test/Templight/templight-nested-template-instantiation.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+
+template 
+struct foo : foo {};
+
+template <>
+struct foo<0> {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo<2>'$}}
+// CHECK: {{^kind:[ 

[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 122323.
AlexVlx marked 7 inline comments as done.

https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,33 @@
   }
 }
 
+static bool checkAllAreIntegral(Sema , const AttributeList ) {
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);
+if (E && !E->getType()->isIntegralOrEnumerationType()) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+<< getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+<< E->getSourceRange();
+
+  return false;
+}
+  }
+
+  return true;
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema , Decl *D,
   const AttributeList ) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5510,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema , Decl *D,
const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
-Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+MaxExpr = Attr.getArgAsExpr(1);
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5547,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
+ AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7661,6 +7661,16 @@
 };
 }
 
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+{
+  assert(E);
+
+  llvm::APSInt Tmp{32, 0};
+  E->EvaluateAsInt(Tmp, Ctx);
+
+  return Tmp;
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ,
 ForDefinition_t IsForDefinition) const {
@@ -7676,8 +7686,11 @@
 FD->getAttr() : nullptr;
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+

[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D39836#920977, @arphaman wrote:

> In https://reviews.llvm.org/D39836#920587, @sammccall wrote:
>
> > So I probably should have started from the other end, here :-)
> >
> > I'd really like to make the completion retrieval and ranking more flexible. 
> > In particular
> >
> > - incorporating results from other sources (indexes: both in-memory and 
> > external services).
> > - combining more quality signals like usage count and fuzzy-match-strength 
> > in a non-lexicographic-sort way The biggest difficulty in *supporting* 
> > unusable functions is maintaining the invariant that all unusable functions 
> > are ranked lower than usable ones - all code that deals with ranking has to 
> > deal with this special case, e.g. by making score a tuple instead of a 
> > single number.
>
>
> That sounds good to me. Please keep in mind that not all clients might want 
> to take advantage of these things as they might have their own fuzz-match 
> logic


Yup! My understanding of the protocol is clients will generally trigger 
completion after the dot, and then filter client-side *unless* the result set 
is incomplete.
So fuzzy-match filtering/scoring would only be triggered if we limit the number 
of results (proposed as optional in https://reviews.llvm.org/D39852) or if 
completion is explicitly triggered mid-identifier (maybe we should allow 
turning this off too).

> and external result injection.

Absolutely. To be concrete, i'm thinking about three overlaid:

1. a static generated index that clangd consumes (e.g. generated by 
index-while-building and located on disk, or a hosted index of google's 
monorepo)
2. a dynamically generated index of symbols in files that clangd has seen. 
(Likely to be dirty with respect to 1)
3. context-sensitive completion results as today

1 would definitely be optional.
2 isn't really external... we might want to handle global symbols with 2 and 
not 3 as now, but that's an implementation detail.

>> If the current approach of "give them a penalty" is enough, knowing that in 
>> the future it may lead to e.g. a very widely used but inaccessible protected 
>> function being ranked highly, then that seems fine to me too. A wider 
>> configuration space means testing is more work, but happy to live with it. 
>> What do you think?
>> 
>> (With my user-hat on, configurable is fine, though I do strongly feel they 
>> should be off by default, and it seems unlikely many users will change the 
>> defaults.)
> 
> I'd be ok with off by default, as long as it's possible to turn it on :)

Sure, I'll update the patch.

For these things that are (I assume) more "user preference" than project- or 
integration-specific, I wonder whether command-line flags are the right thing. 
Configuration in `~/.clangd` is a can of worms, but might be the right thing in 
the long-run.


https://reviews.llvm.org/D39836



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


[PATCH] D39738: [clangd] Sort completion results.

2017-11-09 Thread Francisco Lopes da Silva via Phabricator via cfe-commits
francisco.lopes added a comment.

Sorting got hardcoded? libclang has it optional. If hardcoded it becomes a 
performance problem, since some clients may wish to order it themselves with 
private heuristics.


Repository:
  rL LLVM

https://reviews.llvm.org/D39738



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


[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

2017-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:14356
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool hasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();

`hasConst` must start from capital letter `HasConst`.



Comment at: lib/Sema/SemaExpr.cpp:14360
+  if (hasConst)
+DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+}

Better to make it this way:
```
DeclRefType.addConst();
```



Comment at: test/OpenMP/parallel_firstprivate_messages.cpp:75
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}}
+d = 5; // expected-error {{cannot assign to variable 'd' with 
const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected 
variable name}}

Please, add a separate directive with this assignment


https://reviews.llvm.org/D39859



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


[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'm curious if the crash would turn into an assertion failure during 
`getRawSVal()` after https://reviews.llvm.org/D38801 is committed.

The problem with this checker producing void symbols is known since 
https://reviews.llvm.org/D26837. If this problem is fixed on the checker side 
(it probably should be - the checker , we can probably put stronger asserts 
onto types suitable for symbols.




Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:265
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {

If a type is an integral or enumeration type or a Loc type, then it is 
definitely not null.


https://reviews.llvm.org/D39862



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


[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This seems reasonable to me. Please commit it. @NoQ can do a post-commit review 
and fix it up if he would rather address the issue differently.


https://reviews.llvm.org/D39862



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added inline comments.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:25
+/// we will do best effort to generate a fix, however, if the
+/// case can not be solved with a simple fix (e.g. remove prefix or change 
first
+/// character), we will leave the fix to the user.

benhamilton wrote:
> hokein wrote:
> > I might miss some background context. 
> > 
> > The fix of the check seems to me that it does more things it should. It 
> > removes all the non-alphabetical prefix characters, I'd be conservative of 
> > the fix here (just fix the case "CamelCase", and only give a warning for 
> > other cases).
> I agree, removing a prefix is not a good idea. Warning is fine.
> 
> We could probably also change `snake_case` variables to `CamelCase` 
> automatically. Not sure if it's worth doing in this review, but @Wizard can 
> file a bug to follow up and add a TODO comment here mentioning the bug.
Will do


https://reviews.llvm.org/D39829



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 122319.
Wizard marked 6 inline comments as done.
Wizard added a comment.

address comments


https://reviews.llvm.org/D39829

Files:
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tidy/objc/PropertyDeclarationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-property-declaration.rst
  test/clang-tidy/objc-property-declaration.m

Index: test/clang-tidy/objc-property-declaration.m
===
--- /dev/null
+++ test/clang-tidy/objc-property-declaration.m
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s objc-property-declaration %t
+
+@interface Foo
+@property(assign, nonatomic) int NotCamelCase;
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property 'NotCamelCase' is not in proper format according to property naming convention [objc-property-declaration]
+// CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
+@property(assign, nonatomic) int camelCase;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:34: warning: property 'camelCase' is not in proper format according to property naming convention [objc-property-declaration]
+@end
Index: docs/clang-tidy/checks/objc-property-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-property-declaration.rst
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - objc-property-declaration
+
+objc-property-declaration
+=
+
+Finds property declarations in Objective-C files that do not follow the pattern
+of property names in Apple's programming guide. The property name should be
+in the format of Lower Camel Case.
+
+For code:
+
+.. code-block:: objc
+
+@property(nonatomic, assign) int LowerCamelCase;
+
+The fix will be:
+
+.. code-block:: objc
+
+@property(nonatomic, assign) int lowerCamelCase;
+
+The check will do best effort to give a fix, however, in some cases it is
+difficult to give a proper fix since the property name could be complicated.
+Users will need to come up with a proper name by their own.
+
+The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -173,15 +173,16 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-forbidden-subclassing
+   objc-property-declaration
performance-faster-string-find
performance-for-range-copy
performance-implicit-conversion-in-loop
performance-inefficient-string-concatenation
performance-inefficient-vector-operation
performance-type-promotion-in-math-fn
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
-   objc-forbidden-subclassing
readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
Index: docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
===
--- docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
+++ docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
@@ -3,7 +3,7 @@
 google-objc-global-variable-declaration
 ===
 
-Finds global variable declarations in Objective-C files that are not follow the pattern
+Finds global variable declarations in Objective-C files that do not follow the pattern
 of variable names in Google's Objective-C Style Guide.
 
 The corresponding style guide rule:
@@ -16,26 +16,31 @@
 For code:
 
 .. code-block:: objc
+
   static NSString* myString = @"hello";
 
 The fix will be:
 
 .. code-block:: objc
+
   static NSString* gMyString = @"hello";
 
 Another example of constant:
 
 .. code-block:: objc
+
   static NSString* const myConstString = @"hello";
 
 The fix will be:
 
 .. code-block:: objc
+
   static NSString* const kMyConstString = @"hello";
 
 However for code that prefixed with non-alphabetical characters like:
 
 .. code-block:: objc
+
   static NSString* __anotherString = @"world";
 
 The check will give a warning message but will not be able to suggest a fix. The user
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-property-declaration
+  `_ check
+
+  FIXME: add release notes.
+
 - New `google-objc-global-variable-declaration
   

[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 122318.

https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,36 @@
   }
 }
 
+namespace
+{
+  bool checkAllAreIntegral(const AttributeList , Sema ) {
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+  auto e = Attr.getArgAsExpr(i);
+  if (e && !e->getType()->isIntegralOrEnumerationType()) {
+S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+  << getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+  << e->getSourceRange();
+
+return false;
+  }
+}
+
+return true;
+  }
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema , Decl *D,
   const AttributeList ) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5513,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema , Decl *D,
const AttributeList ) {
+  if (!checkAllAreIntegral(Attr, S))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
-Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+MaxExpr = Attr.getArgAsExpr(1);
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5550,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(Attr, S))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(Attr, S))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
+ AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7661,6 +7661,18 @@
 };
 }
 
+namespace
+{
+  inline
+  llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+  {
+llvm::APSInt r{32, 0};
+if (E) E->EvaluateAsInt(r, Ctx);
+
+return r;
+  }
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ,
 ForDefinition_t IsForDefinition) const {
@@ -7676,8 +7688,11 @@
 FD->getAttr() : nullptr;
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+

[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D39836#920587, @sammccall wrote:

> So I probably should have started from the other end, here :-)
>
> I'd really like to make the completion retrieval and ranking more flexible. 
> In particular
>
> - incorporating results from other sources (indexes: both in-memory and 
> external services).
> - combining more quality signals like usage count and fuzzy-match-strength in 
> a non-lexicographic-sort way The biggest difficulty in *supporting* unusable 
> functions is maintaining the invariant that all unusable functions are ranked 
> lower than usable ones - all code that deals with ranking has to deal with 
> this special case, e.g. by making score a tuple instead of a single number.


That sounds good to me. Please keep in mind that not all clients might want to 
take advantage of these things as they might have their own fuzz-match logic 
and external result injection.

> If the current approach of "give them a penalty" is enough, knowing that in 
> the future it may lead to e.g. a very widely used but inaccessible protected 
> function being ranked highly, then that seems fine to me too. A wider 
> configuration space means testing is more work, but happy to live with it. 
> What do you think?
> 
> (With my user-hat on, configurable is fine, though I do strongly feel they 
> should be off by default, and it seems unlikely many users will change the 
> defaults.)

I'd be ok with off by default, as long as it's possible to turn it on :)


https://reviews.llvm.org/D39836



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


[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D39799#920780, @JVApen wrote:

> How does this new file know if it should handle it's flags as  it does in 
> clang.exe or clang-cl.exe?


It doesn't set argv[0], so it's treated like `clang` by default.

I believe the flag `--driver-mode={gcc,g++,cpp,cl}` can be used to change this.
(I should add this to the brief doc)


Repository:
  rL LLVM

https://reviews.llvm.org/D39799



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


r317832 - [index] tag declarations should use the decl role instead of ref

2017-11-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Nov  9 12:50:59 2017
New Revision: 317832

URL: http://llvm.org/viewvc/llvm-project?rev=317832=rev
Log:
[index] tag declarations should use the decl role instead of ref

The 'decl' role is more canonical than the 'ref'. This helps us establish the
'specialization-of' relation just by looking at decls or defs.

rdar://31884960

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=317832=317831=317832=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Nov  9 12:50:59 2017
@@ -354,12 +354,10 @@ public:
 gatherTemplatePseudoOverrides(D, Relations);
 IndexCtx.indexTagDecl(D, Relations);
   } else {
-auto *Parent = dyn_cast(D->getDeclContext());
 SmallVector Relations;
 gatherTemplatePseudoOverrides(D, Relations);
-return IndexCtx.handleReference(D, D->getLocation(), Parent,
-D->getLexicalDeclContext(),
-SymbolRoleSet(), Relations);
+return IndexCtx.handleDecl(D, D->getLocation(), SymbolRoleSet(),
+   Relations, D->getLexicalDeclContext());
   }
 }
 return true;

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=317832=317831=317832=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu Nov  9 12:50:59 2017
@@ -201,8 +201,8 @@ class PseudoOverridesInSpecializations
   class InnerClass;
-// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | 
c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass |  | 
Ref,RelCont,RelSpecialization | rel: 2
-// CHECK-NEXT: RelCont
+// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | 
c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass |  | 
Decl,RelChild,RelSpecialization | rel: 2
+// CHECK-NEXT: RelChild
 // CHECK-NEXT: RelSpecialization | InnerClass | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerClass
 };
 
@@ -274,7 +274,7 @@ void ContainsSpecializedMemberFunction::
 
 template
 class SpecializationDecl;
-// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Decl | rel: 0
 
 template
 class SpecializationDecl { };


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


[PATCH] D39161: [bindings] remove unique_external test failure

2017-11-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny added reviewers: jbcoe, aaron.ballman.
mgorny added a comment.

Let's try some more reviewers.


https://reviews.llvm.org/D39161



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


[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun.

This is the issue breaking the postgresql bot, purely by chance exposed through 
taint checker, somehow appearing after https://reviews.llvm.org/D38358 got 
committed.

The backstory is that the taint checker requests `SVal` for the value of the 
pointer, and analyzer has a "fast path" in the getter to return a constant when 
we know that the value is constant.
Unfortunately, the getter requires a cast to get signedness correctly, and for 
the pointer `void *` the cast crashes.

This is more of a band-aid patch, as I am not sure what could be done here 
"correctly", but it should be applied in any case to avoid the crash.

@dcoughlin faster review here would be appreciated to get the bot back to green.


https://reviews.llvm.org/D39862

Files:
  lib/StaticAnalyzer/Core/ProgramState.cpp
  test/Analysis/taint-tester.c


Index: test/Analysis/taint-tester.c
===
--- test/Analysis/taint-tester.c
+++ test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()


Index: test/Analysis/taint-tester.c
===
--- test/Analysis/taint-tester.c
+++ test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39838: [clang] [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317828: [python] [tests] Update priority values in code 
completion test (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D39838?vs=17=122304#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39838

Files:
  cfe/trunk/bindings/python/tests/cindex/test_code_completion.py


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -68,8 +68,8 @@
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: 
Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: 
Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || 
Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -68,8 +68,8 @@
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317828 - [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Nov  9 12:17:41 2017
New Revision: 317828

URL: http://llvm.org/viewvc/llvm-project?rev=317828=rev
Log:
[python] [tests] Update priority values in code completion test

The priority for destructors and operators was reduced in r314019.
Adjust the values used in the test appropriately to fix the test
failure.

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

Modified:
cfe/trunk/bindings/python/tests/cindex/test_code_completion.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=317828=317827=317828=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Thu Nov  9 
12:17:41 2017
@@ -68,8 +68,8 @@ void f(P x, Q y) {
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: 
Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: 
Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || 
Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)


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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-09 Thread Reimar Döffinger via cfe-commits
Hello!

On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote:
> Thanks for the patch, Reimar. Can you please add tests to ensure this 
> functionality doesn’t regress? As null character is required by the standard 
> (27.7.2.3p21), a good starting point seems to be
> test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
> test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp

New patch attached, though I went the lazy way of just adding one case.
Not sure that's "good enough" - in principle I think it should be.
More tricky would be to add a test for the _LIBCPP_NO_EXCEPTIONS case,
is there any code testing that at all?

> And what about free function std::getline that takes a stream and a string? 
> The standard (21.4.8.9p7) specifies 
[...]
> 
> Technically, string is not a character array of non-zero size. But according 
> to the spirit of the standard, I would expect string to be empty after 
> reading into it from a stream that reached EOF. What do you think?

Starting with the useful answer instead of what I think:

I'd try what other implementations do and align with that.
At least libstdc++ does not clear the string, so tentatively
I'd suggest not changing behaviour, for simple interoperability.
Testing at least Microsoft C++ in addition might be a good idea
though...
Test code:

#include 
#include 
#include 

int main()
{
std::istringstream in;
std::string dummy;
in >> dummy;
char test[20] = "oldstring";
in.getline(test, sizeof(test));
std::cout << "std::istream::getline result: " << test << std::endl;
dummy = "oldstring";
std::getline(in, dummy);
std::cout << "std::getline result: " << dummy << std::endl;
return test[0];
}


As to what I really think, for anyone who isn't tired of unfair rants
(anyone else please just skip):

I don't really care much about that case, because at least unlike
not 0-terminating a char buffer it is not in the "things you never EVER
do" list.
But this rather needs to be put to the standard authors and it needs to be
clarified.
Along with the suggestion to not only spend time on new features but
also on improving the spec quality.
Large parts of the spec read like when a second-semester maths student
tries to write a proof: the language lacks the precision to actually
write a solid proof, and excessive verbosity is used to try to make
up for it (to no effect besides annoying the reader).
The lack of specified pre- and post-conditions (specified formally
or in natural language) for at least parts easy to specify in such a way
to allow at least partial formal verification or proof of correctness
isn't exactly state-of-the-art either.

Kind regards,
Reimar Döffinger

> > On Oct 4, 2017, at 12:07, Reimar Döffinger via cfe-commits 
> >  wrote:
> > 
> > If the sentinel failed (e.g. due to having reached
> > EOF before) or an exception was caught it failed to
> > do that.
> > The C++14 standard says:
> > "In any case, if n is greater than zero, it then stores
> > a null character (using charT()) into the next
> > successive location of the array."
> > Other implementations like libstdc++ do 0-terminate and
> > not doing so may lead security issues in applications.
> > ---
> > include/istream | 6 --
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/istream b/include/istream
> > index 0b8e05d95..5c73df38f 100644
> > --- a/include/istream
> > +++ b/include/istream
> > @@ -1069,16 +1069,18 @@ basic_istream<_CharT, _Traits>::getline(char_type* 
> > __s, streamsize __n, char_typ
> > this->rdbuf()->sbumpc();
> > ++__gc_;
> > }
> > -if (__n > 0)
> > -*__s = char_type();
> > if (__gc_ == 0)
> >__err |= ios_base::failbit;
> > this->setstate(__err);
> > }
> > +if (__n > 0)
> > +*__s = char_type();
> > #ifndef _LIBCPP_NO_EXCEPTIONS
> > }
> > catch (...)
> > {
> > +if (__n > 0)
> > +*__s = char_type();
> > this->__set_badbit_and_consider_rethrow();
> > }
> > #endif  // _LIBCPP_NO_EXCEPTIONS
> > -- 
> > 2.14.2
> > 
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
>From 67ecbad84c70a611cb933b90bb10a10e5f32d4a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= 
Date: Thu, 7 Sep 2017 08:42:10 +0200
Subject: [PATCH] Ensure std::istream::getline always 0-terminates string.

If the sentinel failed (e.g. due to having reached
EOF before) or an exception was caught it failed to
do that.
The C++14 standard says:
"In any case, if n is greater than zero, it then stores
a null character (using charT()) into the next
successive location 

[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:1329
   StringArgument<"ISA", 1>];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;

Please ensure that the attribute documentation properly reflects the changes 
you've made here. At the very least, I would expect the docs to mention that 
these can now be in dependent contexts. 

The same applies for the other attributes.



Comment at: include/clang/Basic/Attr.td:1368
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
+  let TemplateDependent = 1;

Since you're changing the definition of the attribute, it would also be nice to 
add some documentation to AttrDocs.td for this.



Comment at: lib/CodeGen/TargetInfo.cpp:7665-7666
 
+namespace
+{
+  inline

This should be a static function rather than in an inline namespace.



Comment at: lib/CodeGen/TargetInfo.cpp:7671
+llvm::APSInt r{32, 0};
+if (E) E->EvaluateAsInt(r, Ctx);
+

If there is no expression given, why should this return an `APSInt` for 0? This 
seems more like something you would assert.



Comment at: lib/Sema/SemaDeclAttr.cpp:5583-5584
 
+namespace
+{
+  inline

static function instead, please.



Comment at: lib/Sema/SemaDeclAttr.cpp:5586
+  inline
+  bool checkAllAreIntegral(const AttributeList , Sema ) {
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {

We usually put the `Sema` object first in the parameter list in this file, 
don't we?



Comment at: lib/Sema/SemaDeclAttr.cpp:5587-5588
+  bool checkAllAreIntegral(const AttributeList , Sema ) {
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+  auto e = Attr.getArgAsExpr(i);
+  if (e && !e->getType()->isIntegralOrEnumerationType()) {

These variables should not be lower-case per our usual coding conventions.



Comment at: lib/Sema/SemaDeclAttr.cpp:5588
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+  auto e = Attr.getArgAsExpr(i);
+  if (e && !e->getType()->isIntegralOrEnumerationType()) {

Please spell the type out explicitly.


https://reviews.llvm.org/D39857



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


[PATCH] D39838: [clang] [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D39838#920399, @ilya-biryukov wrote:

> LGTM.
>
> Can we run those tests as part of `check-all` cmake target or setup a 
> buildbot that runs those? Seems surprising it went unnoticed for so long.


I was thinking of that but I think it'd be nice to find someone who knows them 
better. I know they're loading `libclang.so` dynamically somehow, and I'm not 
really sure how to make sure that they're going to test the right library. On 
Gentoo we run the tests after installing clang to the system.


Repository:
  rL LLVM

https://reviews.llvm.org/D39838



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


[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

2017-11-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.

[OpenMP] diagnose assign to firstprivate const

Clang does not diagnose assignments to const variables declared
firstprivate.  Furthermore, codegen is broken such that, at run time,
such assignments simply have no effect.  For example, the following
prints 0 not 1:

int main() {

  const int i = 0;
  #pragma omp parallel firstprivate(i)
  { i=1; printf("%d\n", i); }
  return 0;

}

This commit makes these assignments a compile error, which is
consistent with other OpenMP compilers I've tried (pgcc 17.4-0, gcc 
6.3.0).


https://reviews.llvm.org/D39859

Files:
  lib/Sema/SemaExpr.cpp
  test/OpenMP/parallel_firstprivate_messages.cpp


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,7 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not 
refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}}
+d = 5; // expected-error {{cannot assign to variable 'd' with 
const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected 
variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool hasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (hasConst)
+DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,7 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool hasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (hasConst)
+DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a subscriber: cfe-commits.
kzhuravl added a reviewer: aaron.ballman.
kzhuravl added a comment.

Hi Alex, can you rebase on top of trunk (I think you brought in some extra 
changes from hcc branch) and upload a full diff?




Comment at: include/clang/Basic/Attr.td:1328
+  ExprArgument<"Max", 1>,
   StringArgument<"ISA", 1>];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];

Not in trunk.



Comment at: include/clang/Basic/Attr.td:1339
+  ExprArgument<"Max", 1>,
   StringArgument<"ISA", 1>];
   let Documentation = [AMDGPUWavesPerEUDocs];

Not in trunk.



Comment at: include/clang/Basic/Attr.td:1361-1370
+def AMDGPUMaxWorkGroupDim : InheritableAttr {
   let Spellings = [CXX11<"","hc_max_workgroup_dim", 201511>];
-  let Args = [IntArgument<"X">,
-  IntArgument<"Y", 1>,
-  IntArgument<"Z", 1>,
+  let Args = [ExprArgument<"X">,
+  ExprArgument<"Y">,
+  ExprArgument<"Z">,
   StringArgument<"ISA", 1>];
   let Subjects = SubjectList<[Function], ErrorDiag>;

Not in trunk.


https://reviews.llvm.org/D39857



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


[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread JVApen via Phabricator via cfe-commits
JVApen added a comment.

How does this new file know if it should handle it's flags as  it does in 
clang.exe or clang-cl.exe?


Repository:
  rL LLVM

https://reviews.llvm.org/D39799



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


r317820 - [analyzer] assume bitwise arithmetic axioms

2017-11-09 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Nov  9 11:06:22 2017
New Revision: 317820

URL: http://llvm.org/viewvc/llvm-project?rev=317820=rev
Log:
[analyzer] assume bitwise arithmetic axioms

Patches the solver to assume that bitwise OR of an unsigned value with a
constant always produces a value larger-or-equal than the constant, and
bitwise AND with a constant always produces a value less-or-equal than
the constant.

This patch is especially useful in the context of using bitwise
arithmetic for error code encoding: the analyzer would be able to state
that the error code produced using a bitwise OR is non-zero.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
cfe/trunk/test/Analysis/constant-folding.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=317820=317819=317820=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Thu Nov  9 
11:06:22 2017
@@ -460,6 +460,53 @@ RangeConstraintManager::removeDeadBindin
   return Changed ? State->set(CR) : State;
 }
 
+/// Return a range set subtracting zero from \p Domain.
+static RangeSet assumeNonZero(
+BasicValueFactory ,
+RangeSet::Factory ,
+SymbolRef Sym,
+RangeSet Domain) {
+  APSIntType IntType = BV.getAPSIntType(Sym->getType());
+  return Domain.Intersect(BV, F, ++IntType.getZeroValue(),
+  --IntType.getZeroValue());
+}
+
+/// \brief Apply implicit constraints for bitwise OR- and AND-.
+/// For unsigned types, bitwise OR with a constant always returns
+/// a value greater-or-equal than the constant, and bitwise AND
+/// returns a value less-or-equal then the constant.
+///
+/// Pattern matches the expression \p Sym against those rule,
+/// and applies the required constraints.
+/// \p Input Previously established expression range set
+static RangeSet applyBitwiseConstraints(
+BasicValueFactory ,
+RangeSet::Factory ,
+RangeSet Input,
+const SymIntExpr* SIE) {
+  QualType T = SIE->getType();
+  bool IsUnsigned = T->isUnsignedIntegerType();
+  const llvm::APSInt  = SIE->getRHS();
+  const llvm::APSInt  = BV.getAPSIntType(T).getZeroValue();
+  BinaryOperator::Opcode Operator = SIE->getOpcode();
+
+  // For unsigned types, the output of bitwise-or is bigger-or-equal than RHS.
+  if (Operator == BO_Or && IsUnsigned)
+return Input.Intersect(BV, F, RHS, BV.getMaxValue(T));
+
+  // Bitwise-or with a non-zero constant is always non-zero.
+  if (Operator == BO_Or && RHS != Zero)
+return assumeNonZero(BV, F, SIE, Input);
+
+  // For unsigned types, or positive RHS,
+  // bitwise-and output is always smaller-or-equal than RHS (assuming two's
+  // complement representation of signed types).
+  if (Operator == BO_And && (IsUnsigned || RHS >= Zero))
+return Input.Intersect(BV, F, BV.getMinValue(T), RHS);
+
+  return Input;
+}
+
 RangeSet RangeConstraintManager::getRange(ProgramStateRef State,
   SymbolRef Sym) {
   if (ConstraintRangeTy::data_type *V = State->get(Sym))
@@ -472,12 +519,13 @@ RangeSet RangeConstraintManager::getRang
 
   RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T));
 
-  // Special case: references are known to be non-zero.
-  if (T->isReferenceType()) {
-APSIntType IntType = BV.getAPSIntType(T);
-Result = Result.Intersect(BV, F, ++IntType.getZeroValue(),
-  --IntType.getZeroValue());
-  }
+  // References are known to be non-zero.
+  if (T->isReferenceType())
+return assumeNonZero(BV, F, Sym, Result);
+
+  // Known constraints on ranges of bitwise expressions.
+  if (const SymIntExpr* SIE = dyn_cast(Sym))
+return applyBitwiseConstraints(BV, F, Result, SIE);
 
   return Result;
 }

Modified: cfe/trunk/test/Analysis/constant-folding.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/constant-folding.c?rev=317820=317819=317820=diff
==
--- cfe/trunk/test/Analysis/constant-folding.c (original)
+++ cfe/trunk/test/Analysis/constant-folding.c Thu Nov  9 11:06:22 2017
@@ -76,3 +76,42 @@ void testMixedTypeComparisons (char a, u
   clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
   clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
 }
+
+void testBitwiseRules(unsigned int a, int b) {
+  clang_analyzer_eval((a | 1) >= 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | -1) >= -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 2) >= 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 5) >= 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 10) >= 10); // expected-warning{{TRUE}}
+
+  // Argument order should not 

[PATCH] D39707: [analyzer] assume bitwise arithmetic axioms

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317820: [analyzer] assume bitwise arithmetic axioms 
(authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D39707?vs=122170=122278#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39707

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  cfe/trunk/test/Analysis/constant-folding.c

Index: cfe/trunk/test/Analysis/constant-folding.c
===
--- cfe/trunk/test/Analysis/constant-folding.c
+++ cfe/trunk/test/Analysis/constant-folding.c
@@ -76,3 +76,42 @@
   clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
   clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
 }
+
+void testBitwiseRules(unsigned int a, int b) {
+  clang_analyzer_eval((a | 1) >= 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | -1) >= -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 2) >= 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 5) >= 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 10) >= 10); // expected-warning{{TRUE}}
+
+  // Argument order should not influence this
+  clang_analyzer_eval((1 | a) >= 1); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval((a & 1) <= 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & 2) <= 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & 5) <= 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & 10) <= 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & -10) <= 10); // expected-warning{{UNKNOWN}}
+
+  // Again, check for different argument order.
+  clang_analyzer_eval((1 & a) <= 1); // expected-warning{{TRUE}}
+
+  unsigned int c = a;
+  c |= 1;
+  clang_analyzer_eval((c | 0) == 0); // expected-warning{{FALSE}}
+
+  // Rules don't apply to signed typed, as the values might be negative.
+  clang_analyzer_eval((b | 1) > 0); // expected-warning{{UNKNOWN}}
+
+  // Even for signed values, bitwise OR with a non-zero is always non-zero.
+  clang_analyzer_eval((b | 1) == 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((b | -2) == 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((b | 10) == 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((b | 0) == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval((b | -2) >= 0); // expected-warning{{UNKNOWN}}
+
+  // Check that dynamically computed constants also work.
+  int constant = 1 << 3;
+  unsigned int d = a | constant;
+  clang_analyzer_eval(constant > 0); // expected-warning{{TRUE}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -460,6 +460,53 @@
   return Changed ? State->set(CR) : State;
 }
 
+/// Return a range set subtracting zero from \p Domain.
+static RangeSet assumeNonZero(
+BasicValueFactory ,
+RangeSet::Factory ,
+SymbolRef Sym,
+RangeSet Domain) {
+  APSIntType IntType = BV.getAPSIntType(Sym->getType());
+  return Domain.Intersect(BV, F, ++IntType.getZeroValue(),
+  --IntType.getZeroValue());
+}
+
+/// \brief Apply implicit constraints for bitwise OR- and AND-.
+/// For unsigned types, bitwise OR with a constant always returns
+/// a value greater-or-equal than the constant, and bitwise AND
+/// returns a value less-or-equal then the constant.
+///
+/// Pattern matches the expression \p Sym against those rule,
+/// and applies the required constraints.
+/// \p Input Previously established expression range set
+static RangeSet applyBitwiseConstraints(
+BasicValueFactory ,
+RangeSet::Factory ,
+RangeSet Input,
+const SymIntExpr* SIE) {
+  QualType T = SIE->getType();
+  bool IsUnsigned = T->isUnsignedIntegerType();
+  const llvm::APSInt  = SIE->getRHS();
+  const llvm::APSInt  = BV.getAPSIntType(T).getZeroValue();
+  BinaryOperator::Opcode Operator = SIE->getOpcode();
+
+  // For unsigned types, the output of bitwise-or is bigger-or-equal than RHS.
+  if (Operator == BO_Or && IsUnsigned)
+return Input.Intersect(BV, F, RHS, BV.getMaxValue(T));
+
+  // Bitwise-or with a non-zero constant is always non-zero.
+  if (Operator == BO_Or && RHS != Zero)
+return assumeNonZero(BV, F, SIE, Input);
+
+  // For unsigned types, or positive RHS,
+  // bitwise-and output is always smaller-or-equal than RHS (assuming two's
+  // complement representation of signed types).
+  if (Operator == BO_And && (IsUnsigned || RHS >= Zero))
+return Input.Intersect(BV, F, BV.getMinValue(T), RHS);
+
+  return Input;
+}
+
 RangeSet RangeConstraintManager::getRange(ProgramStateRef State,
   SymbolRef Sym) {
   if (ConstraintRangeTy::data_type *V = State->get(Sym))
@@ -472,12 +519,13 @@
 
   RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T));
 
-  

[PATCH] D39707: [analyzer] assume bitwise arithmetic axioms

2017-11-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks good to me. It is very clean! But please add a comment in the places 
where you are assuming a two's complement value representation for signed 
integers.


https://reviews.llvm.org/D39707



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


[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2017-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 122273.
ABataev added a comment.

Fixed version of OpenMP standard


https://reviews.llvm.org/D39457

Files:
  docs/OpenMPSupport.rst
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework 
is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full 
codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target simd: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp target teams: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams distribute [simd]: :partial:`Partial`.  No full codegen 
support.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No full 
codegen support.
+
+* #pragma omp teams distribute parallel for [simd]: :partial:`Partial`.  No 
full codegen support.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task`-based directives.
+


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* 

[PATCH] D39852: [clangd] Support returning a limited number of completion results.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

All results are scored, we only process CodeCompletionStrings for the winners.
We now return CompletionList rather than CompletionItem[] (both are valid).
sortText is now based on CodeCompletionResult::orderedName (mostly the same).

This is the first clangd-only completion option, so plumbing changed.
It requires a small clangd patch (exposing CodeCompletionResult::orderedName).

(This can't usefully be enabled yet: we don't support server-side filtering)


https://reviews.llvm.org/D39852

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/authority-less-uri.test
  test/clangd/completion-items-kinds.test
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -619,16 +619,15 @@
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
   template 
-  bool ContainsItemPred(std::vector const ,
-Predicate Pred) {
-for (const auto  : Items) {
+  bool ContainsItemPred(CompletionList const , Predicate Pred) {
+for (const auto  : Items.items) {
   if (Pred(Item))
 return true;
 }
 return false;
   }
 
-  bool ContainsItem(std::vector const , StringRef Name) {
+  bool ContainsItem(CompletionList const , StringRef Name) {
 return ContainsItemPred(Items, [Name](clangd::CompletionItem Item) {
   return Item.insertText == Name;
 });
@@ -694,6 +693,44 @@
   }
 }
 
+TEST_F(ClangdCompletionTest, Limit) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  Opts.Limit = 2;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  Opts, EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  StringWithPos Completion = parseTextMarker(R"cpp(
+struct ClassWithMembers {
+  int AAA();
+  int BBB();
+  int CCC();
+}
+int main() { ClassWithMembers().{complete} }
+  )cpp",
+ "complete");
+  Server.addDocument(FooCpp, Completion.Text);
+
+  /// For after-dot completion we must always get consistent results.
+  auto Results = Server
+ .codeComplete(FooCpp, Completion.MarkerPos,
+   StringRef(Completion.Text))
+ .get()
+ .Value;
+
+  EXPECT_TRUE(Results.isIncomplete);
+  EXPECT_EQ(Opts.Limit, Results.items.size());
+  EXPECT_TRUE(ContainsItem(Results, "AAA"));
+  EXPECT_TRUE(ContainsItem(Results, "BBB"));
+  EXPECT_FALSE(ContainsItem(Results, "CCC"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -31,14 +31,17 @@
 #
 #  CHECK:  "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 
 X-Test: Testing
 Content-Type: application/vscode-jsonrpc; charset-utf-8
@@ -57,14 +60,17 @@
 #
 #  CHECK:  "id": 3,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:

[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2017-11-09 Thread Aaron En Ye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 122271.
ashi1 added subscribers: scchan, yaxunl, ashi1.
ashi1 added a comment.
Herald added a subscriber: eraman.

I've added the lit tests for this change, and also showing full context.

My lit test import_weak_type.ll follows similar format to import_opaque_type.ll.


Repository:
  rL LLVM

https://reviews.llvm.org/D39739

Files:
  include/llvm/Transforms/Utils/FunctionImportUtils.h
  lib/Transforms/IPO/FunctionImport.cpp
  lib/Transforms/Utils/FunctionImportUtils.cpp
  test/ThinLTO/X86/Inputs/import_weak_type.ll
  test/ThinLTO/X86/import_weak_type.ll


Index: test/ThinLTO/X86/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/import_weak_type.ll
@@ -0,0 +1,19 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: opt -module-summary %p/Inputs/import_weak_type.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Check that we import correctly the imported weak type to replace declaration 
here
+; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc 
-force-import-weak -o - | llvm-dis -o - | FileCheck %s
+; CHECK: define weak void @foo()
+
+
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target triple = "amdgcn--amdhsa-hcc"
+
+declare extern_weak void @foo()
+define weak_odr amdgpu_kernel void @main() {
+call void @foo()
+  ret void
+}
+
Index: test/ThinLTO/X86/Inputs/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/Inputs/import_weak_type.ll
@@ -0,0 +1,7 @@
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target triple = "amdgcn--amdhsa-hcc"
+
+define weak void @foo() {
+  ret void
+}
+
Index: lib/Transforms/Utils/FunctionImportUtils.cpp
===
--- lib/Transforms/Utils/FunctionImportUtils.cpp
+++ lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -151,7 +151,8 @@
 // program semantics, since the linker will pick the first weak_any
 // definition and importing would change the order they are seen by the
 // linker. The module linking caller needs to enforce this.
-assert(!doImportAsDefinition(SGV));
+if(!ForceImportWeakFlag)
+  assert(!doImportAsDefinition(SGV));
 // If imported as a declaration, it becomes external_weak.
 return SGV->getLinkage();
 
Index: lib/Transforms/IPO/FunctionImport.cpp
===
--- lib/Transforms/IPO/FunctionImport.cpp
+++ lib/Transforms/IPO/FunctionImport.cpp
@@ -102,6 +102,12 @@
 static cl::opt ComputeDead("compute-dead", cl::init(true), cl::Hidden,
  cl::desc("Compute dead symbols"));
 
+bool llvm::ForceImportWeakFlag;
+static cl::opt
+ForceImportWeak("force-import-weak", cl::Hidden,
+cl::desc("Allow weak functions to be imported"),
+cl::location(ForceImportWeakFlag), cl::init(false));
+
 static cl::opt EnableImportMetadata(
 "enable-import-metadata", cl::init(
 #if !defined(NDEBUG)
@@ -169,7 +175,7 @@
 // filtered out.
 if (GVSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind)
   return false;
-if (GlobalValue::isInterposableLinkage(GVSummary->linkage()))
+if (!ForceImportWeakFlag && 
GlobalValue::isInterposableLinkage(GVSummary->linkage()))
   // There is no point in importing these, we can't inline them
   return false;
 if (isa(GVSummary))
Index: include/llvm/Transforms/Utils/FunctionImportUtils.h
===
--- include/llvm/Transforms/Utils/FunctionImportUtils.h
+++ include/llvm/Transforms/Utils/FunctionImportUtils.h
@@ -21,6 +21,9 @@
 namespace llvm {
 class Module;
 
+// Set to true depending on option -force-import-weak
+extern bool ForceImportWeakFlag;
+
 /// Class to handle necessary GlobalValue changes required by ThinLTO
 /// function importing, including linkage changes and any necessary renaming.
 class FunctionImportGlobalProcessing {


Index: test/ThinLTO/X86/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/import_weak_type.ll
@@ -0,0 +1,19 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: opt -module-summary %p/Inputs/import_weak_type.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Check that we import correctly the imported weak type to replace declaration here
+; 

[PATCH] D39706: [refactor][extract] Initial implementation of variable captures

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 122270.
arphaman marked 5 inline comments as done.
arphaman added a comment.

Address review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D39706

Files:
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/Extract/CaptureVariables.cpp
  lib/Tooling/Refactoring/Extract/CaptureVariables.h
  lib/Tooling/Refactoring/Extract/Extract.cpp
  test/Refactor/Extract/CaptureSimpleVariables.cpp
  test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
  test/Refactor/Extract/ExtractionSemicolonPolicy.m

Index: test/Refactor/Extract/ExtractionSemicolonPolicy.m
===
--- test/Refactor/Extract/ExtractionSemicolonPolicy.m
+++ test/Refactor/Extract/ExtractionSemicolonPolicy.m
@@ -10,7 +10,7 @@
   }
 }
 // CHECK: 1 'astmt' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(NSArray *array) {
 // CHECK-NEXT: for (id i in array) {
 // CHECK-NEXT: int x = 0;
 // CHECK-NEXT: }{{$}}
@@ -23,7 +23,7 @@
   }
 }
 // CHECK: 1 'bstmt' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(id lock) {
 // CHECK-NEXT: @synchronized(lock) {
 // CHECK-NEXT: int x = 0;
 // CHECK-NEXT: }{{$}}
Index: test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
===
--- test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
+++ test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
@@ -6,41 +6,41 @@
   /*range adeclstmt=->+0:59*/int area = r.width * r.height;
 }
 // CHECK: 1 'adeclstmt' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(const Rectangle ) {
 // CHECK-NEXT: int area = r.width * r.height;{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatement(const Rectangle ) {
-// CHECK-NEXT:   /*range adeclstmt=->+0:59*/extracted();{{$}}
+// CHECK-NEXT:   /*range adeclstmt=->+0:59*/extracted(r);{{$}}
 // CHECK-NEXT: }
 
 void extractStatementNoSemiIf(const Rectangle ) {
   /*range bextractif=->+2:4*/if (r.width) {
 int x = r.height;
   }
 }
 // CHECK: 1 'bextractif' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(const Rectangle ) {
 // CHECK-NEXT: if (r.width) {
 // CHECK-NEXT: int x = r.height;
 // CHECK-NEXT: }{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatementNoSemiIf(const Rectangle ) {
-// CHECK-NEXT:   /*range bextractif=->+2:4*/extracted();{{$}}
+// CHECK-NEXT:   /*range bextractif=->+2:4*/extracted(r);{{$}}
 // CHECK-NEXT: }
 
 void extractStatementDontExtraneousSemi(const Rectangle ) {
   /*range cextractif=->+2:4*/if (r.width) {
 int x = r.height;
   } ;
 } //^ This semicolon shouldn't be extracted.
 // CHECK: 1 'cextractif' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(const Rectangle ) {
 // CHECK-NEXT: if (r.width) {
 // CHECK-NEXT: int x = r.height;
 // CHECK-NEXT: }{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatementDontExtraneousSemi(const Rectangle ) {
-// CHECK-NEXT: extracted(); ;{{$}}
+// CHECK-NEXT: extracted(r); ;{{$}}
 // CHECK-NEXT: }
 
 void extractStatementNotSemiSwitch() {
@@ -102,12 +102,12 @@
   }
 }
 // CHECK: 1 'gextract' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(XS xs) {
 // CHECK-NEXT: for (int i : xs) {
 // CHECK-NEXT: }{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatementNotSemiRangedFor(XS xs) {
-// CHECK-NEXT: extracted();{{$}}
+// CHECK-NEXT: extracted(xs);{{$}}
 // CHECK-NEXT: }
 
 void extractStatementNotSemiRangedTryCatch() {
Index: test/Refactor/Extract/CaptureSimpleVariables.cpp
===
--- /dev/null
+++ test/Refactor/Extract/CaptureSimpleVariables.cpp
@@ -0,0 +1,40 @@
+// RUN: clang-refactor extract -selection=test:%s %s -- 2>&1 | grep -v CHECK | FileCheck %s
+
+void captureStaticVars() {
+  static int x;
+  /*range astaticvar=->+0:39*/int y = x;
+  x += 1;
+}
+// CHECK: 1 'astaticvar' results:
+// CHECK:  static void extracted(int x) {
+// CHECK-NEXT: int y = x;{{$}}
+// CHECK-NEXT: }{{[[:space:]].*}}
+// CHECK-NEXT: void captureStaticVars() {
+// CHECK-NEXT: static int x;
+// CHECK-NEXT: extracted(x);{{$}}
+
+typedef struct {
+  int width, height;
+} Rectangle;
+
+void basicTypes(int i, float f, char c, const int *ip, float *fp, const Rectangle *structPointer) {
+  /*range basictypes=->+0:73*/basicTypes(i, f, c, ip, fp, structPointer);
+}
+// CHECK: 1 'basictypes' results:
+// CHECK:  static void extracted(char c, float f, float *fp, int i, const int *ip, const Rectangle *structPointer) {
+// CHECK-NEXT: basicTypes(i, f, c, ip, fp, structPointer);{{$}}
+// CHECK-NEXT: }{{[[:space:]].*}}
+// CHECK-NEXT: void basicTypes(int i, float f, char c, const int *ip, float *fp, const Rectangle *structPointer) {
+// CHECK-NEXT: 

[PATCH] D39706: [refactor][extract] Initial implementation of variable captures

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/Refactoring/Extract/CaptureVariables.cpp:36
+  return true;
+// FIXME: Capture 'self'.
+if (!VD->isLocalVarDeclOrParm())

ioeric wrote:
> and `this`?
This is a different kind of expression that won't be handled in this method, 
and there's a fixit for 'this' further down already.



Comment at: lib/Tooling/Refactoring/Extract/CaptureVariables.h:36
+  explicit CapturedExtractedEntity(const VarDecl *VD)
+  : Kind(CapturedVarDecl), VD(VD) {}
+

ioeric wrote:
> Maybe a `FIXME` here for `Kind`?
I think this constructor will always set the same kind.


Repository:
  rL LLVM

https://reviews.llvm.org/D39706



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


[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2017-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 122268.
ABataev added a comment.

Update status.


https://reviews.llvm.org/D39457

Files:
  docs/OpenMPSupport.rst
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.5 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework 
is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full 
codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target simd: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp target teams: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams distribute [simd]: :partial:`Partial`.  No full codegen 
support.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No full 
codegen support.
+
+* #pragma omp teams distribute parallel for [simd]: :partial:`Partial`.  No 
full codegen support.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task`-based directives.
+


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.5 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target 

[PATCH] D39751: [libc++] Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317816: Add _LIBCPP_INLINE_VISIBILITY to 
__compressed_pair_elem members (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D39751?vs=121939=122261#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39751

Files:
  libcxx/trunk/include/memory


Index: libcxx/trunk/include/memory
===
--- libcxx/trunk/include/memory
+++ libcxx/trunk/include/memory
@@ -2040,11 +2040,12 @@
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 


Index: libcxx/trunk/include/memory
===
--- libcxx/trunk/include/memory
+++ libcxx/trunk/include/memory
@@ -2040,11 +2040,12 @@
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r317816 - Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

2017-11-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Nov  9 09:54:49 2017
New Revision: 317816

URL: http://llvm.org/viewvc/llvm-project?rev=317816=rev
Log:
Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

The commit r300140 changed the implementation of compressed_pair, but didn't add
_LIBCPP_INLINE_VISIBILITY to the constructors and get members of the
compressed_pair_elem class. This patch adds the visibility annotation.

I didn't find a way to test this change with libc++ regression tests.

rdar://35352579

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

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=317816=317815=317816=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Thu Nov  9 09:54:49 2017
@@ -2040,11 +2040,12 @@ struct __compressed_pair_elem {
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@ struct __compressed_pair_elem {
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@ struct __compressed_pair_elem<_Tp, _Idx,
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@ struct __compressed_pair_elem<_Tp, _Idx,
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 


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


r317813 - [OPENMP] Codegen for `#pragma omp target parallel for simd`.

2017-11-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov  9 09:32:15 2017
New Revision: 317813

URL: http://llvm.org/viewvc/llvm-project?rev=317813=rev
Log:
[OPENMP] Codegen for `#pragma omp target parallel for simd`.

Added codegen for `#pragma omp target parallel for simd` and clauses.

Added:
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen_registration.cpp

cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen_registration_naming.cpp
Modified:
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Nov  9 09:32:15 2017
@@ -793,7 +793,7 @@ bool clang::isOpenMPParallelDirective(Op
 
 bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
   return DKind == OMPD_target || DKind == OMPD_target_parallel ||
- DKind == OMPD_target_parallel_for || 
+ DKind == OMPD_target_parallel_for ||
  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
  DKind == OMPD_target_teams_distribute_parallel_for ||
@@ -909,7 +909,6 @@ void clang::getOpenMPCaptureRegions(
   case OMPD_atomic:
   case OMPD_target_data:
   case OMPD_target:
-  case OMPD_target_parallel_for_simd:
   case OMPD_target_simd:
   case OMPD_task:
   case OMPD_taskloop:
@@ -927,6 +926,7 @@ void clang::getOpenMPCaptureRegions(
 break;
   case OMPD_target_parallel:
   case OMPD_target_parallel_for:
+  case OMPD_target_parallel_for_simd:
 CaptureRegions.push_back(OMPD_target);
 CaptureRegions.push_back(OMPD_parallel);
 break;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Nov  9 09:32:15 2017
@@ -7125,6 +7125,10 @@ void CGOpenMPRuntime::scanForTargetRegio
   CodeGenFunction::EmitOMPTargetParallelForDeviceFunction(
   CGM, ParentName, cast(*S));
   break;
+case Stmt::OMPTargetParallelForSimdDirectiveClass:
+  CodeGenFunction::EmitOMPTargetParallelForSimdDeviceFunction(
+  CGM, ParentName, cast(*S));
+  break;
 default:
   llvm_unreachable("Unknown target directive for OpenMP device codegen.");
 }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Nov  9 09:32:15 2017
@@ -277,6 +277,7 @@ getExecutionModeForDirective(CodeGenModu
 return CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
   case OMPD_target_parallel:
   case OMPD_target_parallel_for:
+  case OMPD_target_parallel_for_simd:
 return CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
   default:
 llvm_unreachable("Unsupported directive on NVPTX device.");

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Nov  9 09:32:15 2017
@@ -2027,18 +2027,6 @@ void CodeGenFunction::EmitOMPDistributeS
   });
 }
 
-void CodeGenFunction::EmitOMPTargetParallelForSimdDirective(
-const OMPTargetParallelForSimdDirective ) {
-  OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
-  CGM.getOpenMPRuntime().emitInlinedDirective(
-  *this, OMPD_target_parallel_for_simd,
-  [](CodeGenFunction , PrePostActionTy &) {
-OMPLoopScope PreInitScope(CGF, S);
-CGF.EmitStmt(
-cast(S.getAssociatedStmt())->getCapturedStmt());
-  });
-}
-
 void CodeGenFunction::EmitOMPTargetSimdDirective(
 const OMPTargetSimdDirective ) {
   OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
@@ -4169,6 +4157,44 @@ void CodeGenFunction::EmitOMPTargetParal
   };
   emitCommonOMPTargetDirective(*this, S, CodeGen);
 }
+
+static void
+emitTargetParallelForSimdRegion(CodeGenFunction ,
+const 

[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

> When linking the final binary, the XRay runtime can't seem to find the 
> `__{start,stop}_xray_{fn_idx,instr_map}` symbols. I've marked them weak, but 
> they seem to either not be resolved when statically linking the binary. The 
> dynamic lib version of the XRay runtime isn't quite ready yet, but I'm 
> willing to try some things there.
>  There are also missing symbols from the sanitizer_common library that's 
> linked to from the `libclang_rt.xray_osx.a` produced by the compiler-rt XRay 
> build configuration.
>  Any further hints/thoughts on this would be great, @kubamracek (cc @pelikan 
> and @echristo)

This is one of the reasons why a dynamic shared library works better. Using a 
dynamic library should solve this. What are the problems with that?


https://reviews.llvm.org/D39114



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


[PATCH] D39800: [analyzer] pr34404: Fix a crash on pointers to members in nested anonymous structures.

2017-11-09 Thread Kirill Romanenkov via Phabricator via cfe-commits
kromanenkov added a comment.

@NoQ  Do we need to change a `DeclaratorDecl` field in PointerToMember SVal to 
something more common, like `ValueDecl`, to support `IndirectFieldDecl` as well?


https://reviews.llvm.org/D39800



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


r317811 - [OPENMP] Treat '#pragma omp target parallel for simd' as simd directive.

2017-11-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov  9 09:01:35 2017
New Revision: 317811

URL: http://llvm.org/viewvc/llvm-project?rev=317811=rev
Log:
[OPENMP] Treat '#pragma omp target parallel for simd' as simd directive.

`#pragma omp target parallel for simd` mistakenly was not treated as a
simd directive, fixed this problem.

Modified:
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/target_parallel_for_simd_ordered_messages.cpp

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=317811=317810=317811=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Nov  9 09:01:35 2017
@@ -829,7 +829,8 @@ bool clang::isOpenMPSimdDirective(OpenMP
  DKind == OMPD_teams_distribute_simd ||
  DKind == OMPD_teams_distribute_parallel_for_simd ||
  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd;
+ DKind == OMPD_target_teams_distribute_simd ||
+ DKind == OMPD_target_parallel_for_simd;
 }
 
 bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {

Modified: cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp?rev=317811=317810=317811=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp Thu Nov  9 
09:01:35 2017
@@ -77,14 +77,14 @@ T tmain(T argc, T *argv) {
 a = 2;
 // CHECK-NEXT: for (T i = 0; i < 2; ++i)
 // CHECK-NEXT: a = 2;
-#pragma omp target parallel for simd private(argc, b), firstprivate(c, d), 
lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) if (parallel 
:argc) num_threads(N) default(shared) shared(e) reduction(+ : h)
+#pragma omp target parallel for simd private(argc, b), firstprivate(c, d), 
lastprivate(d, f) collapse(N) schedule(static, N) ordered if (parallel :argc) 
num_threads(N) default(shared) shared(e) reduction(+ : h)
   for (int i = 0; i < 2; ++i)
 for (int j = 0; j < 2; ++j)
   for (int j = 0; j < 2; ++j)
 for (int j = 0; j < 2; ++j)
   for (int j = 0; j < 2; ++j)
 foo();
-  // CHECK-NEXT: #pragma omp target parallel for simd private(argc,b) 
firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) 
if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h)
+  // CHECK-NEXT: #pragma omp target parallel for simd private(argc,b) 
firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered 
if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h)
   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)

Modified: 
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp?rev=317811=317810=317811=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp 
Thu Nov  9 09:01:35 2017
@@ -125,11 +125,11 @@ int foomain(int argc, char **argv) {
 foo();
 #pragma omp parallel private(i)
 #pragma omp target parallel for simd firstprivate(i) // expected-note 
{{defined as firstprivate}}
-  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may not be 
firstprivate, predetermined as private}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may not be 
firstprivate, predetermined as linear}}
 foo();
 #pragma omp parallel reduction(+ : i)
 #pragma omp target parallel for simd firstprivate(i) // expected-note 
{{defined as firstprivate}}
-  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may not be 
firstprivate, predetermined as private}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may 

[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

Thanks for working on this! Can we split the patch and land parts that are 
LGTM? It's getting a bit crowded here. I think the ASM changes should be a 
separate patch, and the test changes as well, probably.


https://reviews.llvm.org/D39114



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


[PATCH] D38639: [clangd] #include statements support for Open definition

2017-11-09 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D38639#920487, @ilya-biryukov wrote:

> I think we should never iterate through `SourceManager`, as it's much easier 
> to get wrong than using the callbacks. I agree that all that fiddling with 
> callbacks is unfortunate, but it's well worth the fact that it'd be much 
> easier to tell that the implementation is correct by simply looking at the 
> implementation and not knowing how `SourceManager` works. `PPCallbacks` is a 
> much more direct API that was designed to handle our purposes.
>
> Note that we don't need to use `SourceManager` to find non-preamble includes, 
> we should implement proper `PPCallbacks` and use them when building the AST.


Sounds good!


https://reviews.llvm.org/D38639



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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

So I probably should have started from the other end, here :-)

I'd really like to make the completion retrieval and ranking more flexible. In 
particular

- incorporating results from other sources (indexes: both in-memory and 
external services).
- combining more quality signals like usage count and fuzzy-match-strength in a 
non-lexicographic-sort way

The biggest difficulty in *supporting* unusable functions is maintaining the 
invariant that all unusable functions are ranked lower than usable ones - all 
code that deals with ranking has to deal with this special case, e.g. by making 
score a tuple instead of a single number.

If the current approach of "give them a penalty" is enough, knowing that in the 
future it may lead to e.g. a very widely used but inaccessible protected 
function being ranked highly, then that seems fine to me too. A wider 
configuration space means testing is more work, but happy to live with it. What 
do you think?

(With my user-hat on, configurable is fine, though I do strongly feel they 
should be off by default, and it seems unlikely many users will change the 
defaults.)


https://reviews.llvm.org/D39836



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:25
+/// we will do best effort to generate a fix, however, if the
+/// case can not be solved with a simple fix (e.g. remove prefix or change 
first
+/// character), we will leave the fix to the user.

hokein wrote:
> I might miss some background context. 
> 
> The fix of the check seems to me that it does more things it should. It 
> removes all the non-alphabetical prefix characters, I'd be conservative of 
> the fix here (just fix the case "CamelCase", and only give a warning for 
> other cases).
I agree, removing a prefix is not a good idea. Warning is fine.

We could probably also change `snake_case` variables to `CamelCase` 
automatically. Not sure if it's worth doing in this review, but @Wizard can 
file a bug to follow up and add a TODO comment here mentioning the bug.


https://reviews.llvm.org/D39829



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: docs/clang-tidy/checks/objc-property-declaration.rst:7
+Finds property declarations in Objective-C files that do not follow the pattern
+of property names in Google's Objective-C Style Guide. The property name should
+be in the format of Lower Camel Case.

hokein wrote:
> Google style? but the link you provided is Apple.
Google's Objective-C style guide is a list of additions on top of Apple's 
Objective-C style guide.

Property naming standards are defined in Apple's style guide, and not changed 
by Google's.


https://reviews.llvm.org/D39829



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


[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm really happy you've made this work! I don't understand it enough to do a 
meaningful review (keen to learn if you have time for a walkthrough when back 
in the office).


https://reviews.llvm.org/D39842



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


[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Heh, I was just going to ask :-)

As a very first step, can we make this configurable but off-by-default? That 
will address the pressing diskless-servers need.

In a typical workstation scenario, disk is plentiful (if slow) and RAM is 
scarce - very likely we're running browser + editor (VSCode is another browser 
really) + clangd + build system, and clangd is likely the least important of 
these...
So if we're going to increase mem usage by a significant amount I think we want 
to measure it carefully first.


https://reviews.llvm.org/D39843



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


r317800 - [VirtualFileSystem] InMemoryFileSystem::addFile(): Type and Perms

2017-11-09 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Thu Nov  9 08:01:16 2017
New Revision: 317800

URL: http://llvm.org/viewvc/llvm-project?rev=317800=rev
Log:
[VirtualFileSystem] InMemoryFileSystem::addFile(): Type and Perms

Summary:
This implements a FIXME in InMemoryFileSystem::addFile(), allowing
clients to specify User, Group, Type, and/or Perms when creating a
file in an in-memory filesystem.

New tests included. Ran tests with:

% ninja BasicTests && ./tools/clang/unittests/Basic/BasicTests

Fixes PR#35172 (https://bugs.llvm.org/show_bug.cgi?id=35172)

Reviewers: bkramer, hokein

Reviewed By: bkramer, hokein

Subscribers: alexfh

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

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=317800=317799=317800=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Thu Nov  9 08:01:16 2017
@@ -320,15 +320,25 @@ public:
   ~InMemoryFileSystem() override;
 
   /// Add a buffer to the VFS with a path. The VFS owns the buffer.
+  /// If present, User, Group, Type and Perms apply to the newly-created file.
   /// \return true if the file was successfully added, false if the file 
already
   /// exists in the file system with different contents.
   bool addFile(const Twine , time_t ModificationTime,
-   std::unique_ptr Buffer);
+   std::unique_ptr Buffer,
+   Optional User = None, Optional Group = None,
+   Optional Type = None,
+   Optional Perms = None);
   /// Add a buffer to the VFS with a path. The VFS does not own the buffer.
+  /// If present, User, Group, Type and Perms apply to the newly-created file.
   /// \return true if the file was successfully added, false if the file 
already
   /// exists in the file system with different contents.
   bool addFileNoOwn(const Twine , time_t ModificationTime,
-llvm::MemoryBuffer *Buffer);
+llvm::MemoryBuffer *Buffer,
+Optional User = None,
+Optional Group = None,
+Optional Type = None,
+Optional Perms = None);
+
   std::string toString() const;
   /// Return true if this file system normalizes . and .. in paths.
   bool useNormalizedPaths() const { return UseNormalizedPaths; }

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=317800=317799=317800=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Nov  9 08:01:16 2017
@@ -493,7 +493,11 @@ std::string InMemoryFileSystem::toString
 }
 
 bool InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
- std::unique_ptr Buffer) {
+ std::unique_ptr Buffer,
+ Optional User,
+ Optional Group,
+ Optional Type,
+ Optional Perms) {
   SmallString<128> Path;
   P.toVector(Path);
 
@@ -509,7 +513,14 @@ bool InMemoryFileSystem::addFile(const T
 return false;
 
   detail::InMemoryDirectory *Dir = Root.get();
-  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
+  auto I = llvm::sys::path::begin(Path), E = sys::path::end(Path);
+  const auto ResolvedUser = User.getValueOr(0);
+  const auto ResolvedGroup = Group.getValueOr(0);
+  const auto ResolvedType = Type.getValueOr(sys::fs::file_type::regular_file);
+  const auto ResolvedPerms = Perms.getValueOr(sys::fs::all_all);
+  // Any intermediate directories we create should be accessible by
+  // the owner, even if Perms says otherwise for the final path.
+  const auto NewDirectoryPerms = ResolvedPerms | sys::fs::owner_all;
   while (true) {
 StringRef Name = *I;
 detail::InMemoryNode *Node = Dir->getChild(Name);
@@ -517,24 +528,21 @@ bool InMemoryFileSystem::addFile(const T
 if (!Node) {
   if (I == E) {
 // End of the path, create a new file.
-// FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::toTimePoint(ModificationTime), 0, 0,
-Buffer->getBufferSize(),
-llvm::sys::fs::file_type::regular_file,
-llvm::sys::fs::all_all);
+llvm::sys::toTimePoint(ModificationTime), ResolvedUser,
+ResolvedGroup, 

[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I would prefer to make this behaviour configurable.


https://reviews.llvm.org/D39836



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


r317799 - [clang-format] Keep Sphinx happy after r317794

2017-11-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Nov  9 07:54:59 2017
New Revision: 317799

URL: http://llvm.org/viewvc/llvm-project?rev=317799=rev
Log:
[clang-format] Keep Sphinx happy after r317794

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=317799=317798=317799=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Nov  9 07:54:59 2017
@@ -1584,11 +1584,6 @@ the configuration (without a prefix: ``A
 **SortUsingDeclarations** (``bool``)
   If ``true``, clang-format will sort using declarations.
 
-  .. code-block:: c++
-
- false: true:
- using std::cout;   vs. using std::cin;
- using std::cin;using std::cout;
   The order of using declarations is defined as follows:
   Split the strings by "::" and discard any initial empty strings. The last
   element of each list is a non-namespace name; all others are namespace
@@ -1597,6 +1592,12 @@ the configuration (without a prefix: ``A
   names, and within those groups, names are in case-insensitive
   lexicographic order.
 
+  .. code-block:: c++
+
+ false: true:
+ using std::cout;   vs. using std::cin;
+ using std::cin;using std::cout;
+
 **SpaceAfterCStyleCast** (``bool``)
   If ``true``, a space is inserted after C style casts.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=317799=317798=317799=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Nov  9 07:54:59 2017
@@ -1385,11 +1385,7 @@ struct FormatStyle {
   bool SortIncludes;
 
   /// \brief If ``true``, clang-format will sort using declarations.
-  /// \code
-  ///false: true:
-  ///using std::cout;   vs. using std::cin;
-  ///using std::cin;using std::cout;
-  /// \endcode
+  ///
   /// The order of using declarations is defined as follows:
   /// Split the strings by "::" and discard any initial empty strings. The last
   /// element of each list is a non-namespace name; all others are namespace
@@ -1397,6 +1393,11 @@ struct FormatStyle {
   /// individual names is that all non-namespace names come before all 
namespace
   /// names, and within those groups, names are in case-insensitive
   /// lexicographic order.
+  /// \code
+  ///false: true:
+  ///using std::cout;   vs. using std::cin;
+  ///using std::cin;using std::cout;
+  /// \endcode
   bool SortUsingDeclarations;
 
   /// \brief If ``true``, a space is inserted after C style casts.


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


  1   2   >