[PATCH] D36567: [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes

2017-08-09 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi created this revision.

I thought we should add this information to release notes, because we
added a new flag to clang driver.


https://reviews.llvm.org/D36567

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -61,7 +61,7 @@
 New Compiler Flags
 --
 
-The option 
+- --autocomplete was implemented to obtain a list of flags and its arguments. 
This is used for shell autocompletion.
 
 Deprecated Compiler Flags
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -61,7 +61,7 @@
 New Compiler Flags
 --
 
-The option 
+- --autocomplete was implemented to obtain a list of flags and its arguments. This is used for shell autocompletion.
 
 Deprecated Compiler Flags
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-08-09 Thread Wei Mi via Phabricator via cfe-commits
wmi added a comment.

In https://reviews.llvm.org/D36562#837594, @chandlerc wrote:

> This has been discussed before and I still pretty strongly disagree with it.
>
> This cripples the ability of TSan to find race conditions between accesses to 
> consecutive bitfields -- and these bugs have actually come up.


I guess you mean accessing different bitfields in a consecutive run 
simultaneously can cause data race. Because bitfields order in a consecutive 
run is implementation defined. With the change, Tsan may miss reporting that, 
but such data race can be exposed in a different compiler.

This can be solved by detecting tsan mode in the code. If tsan is enabled, we 
can stop splitting the bitfields.

> We also have had cases in the past where LLVM missed significant bitfield 
> combines and optimizations due to loading them as separate integers. Those 
> would become problems again, and I think they would be even harder to solve 
> than narrowing the access is going to be because we will have strictly less 
> information to work with.

how about only separating legal integer width bitfields at the beginning of a 
consecutive run? Then it won't hinder bitfields combines. This way, it can 
still help for some cases, including the important case we saw.

> Ultimately, while I understand the appeal of this approach, I don't think it 
> is correct and I think we should instead figure out how to optimize these 
> memory accesses well in LLVM. That approach will have the added benefit of 
> optimizing cases where the user has manually used a large integer to simulate 
> bitfields, and making combining and canonicalization substantially easier.




Repository:
  rL LLVM

https://reviews.llvm.org/D36562



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-08-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> What do you suggest? Should we widen the type of the difference, or abandon 
> this patch and revert back to the local solution I originally used in the 
> iterator checker?

Does the local solution you used in the iterator checker not have the same 
problem?


https://reviews.llvm.org/D35109



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

310549 should solve this problem by using a default architecture that is 
supported by the current device version.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D35820: [Driver] Search compiler-rt paths in -print-file-name=

2017-08-09 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310548: [Driver] Search compiler-rt paths in 
-print-file-name= (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D35820?vs=109485=110515#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35820

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


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -3682,7 +3682,12 @@
   return P.str();
   }
 
-  SmallString<128> P(ResourceDir);
+  SmallString<128> R(ResourceDir);
+  llvm::sys::path::append(R, Name);
+  if (llvm::sys::fs::exists(Twine(R)))
+return R.str();
+
+  SmallString<128> P(TC.getCompilerRTPath());
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -308,6 +308,13 @@
   return TC.getArchName();
 }
 
+std::string ToolChain::getCompilerRTPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName);
+  return Path.str();
+}
+
 std::string ToolChain::getCompilerRT(const ArgList , StringRef Component,
  bool Shared) const {
   const llvm::Triple  = getTriple();
@@ -320,9 +327,7 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -309,6 +309,8 @@
 return ToolChain::CST_Libstdcxx;
   }
 
+  virtual std::string getCompilerRTPath() const;
+
   virtual std::string getCompilerRT(const llvm::opt::ArgList ,
 StringRef Component,
 bool Shared = false) const;


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -3682,7 +3682,12 @@
   return P.str();
   }
 
-  SmallString<128> P(ResourceDir);
+  SmallString<128> R(ResourceDir);
+  llvm::sys::path::append(R, Name);
+  if (llvm::sys::fs::exists(Twine(R)))
+return R.str();
+
+  SmallString<128> P(TC.getCompilerRTPath());
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -308,6 +308,13 @@
   return TC.getArchName();
 }
 
+std::string ToolChain::getCompilerRTPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName);
+  return Path.str();
+}
+
 std::string ToolChain::getCompilerRT(const ArgList , StringRef Component,
  bool Shared) const {
   const llvm::Triple  = getTriple();
@@ -320,9 +327,7 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -309,6 +309,8 @@
 return ToolChain::CST_Libstdcxx;
   }
 
+  virtual std::string getCompilerRTPath() const;
+
   virtual std::string getCompilerRT(const llvm::opt::ArgList ,
 StringRef Component,
 bool Shared = false) const;

r310548 - [Driver] Search compiler-rt paths in -print-file-name=

2017-08-09 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug  9 21:16:38 2017
New Revision: 310548

URL: http://llvm.org/viewvc/llvm-project?rev=310548=rev
Log:
[Driver] Search compiler-rt paths in -print-file-name=

This makes it possible to print the name of compiler-rt libraries
by using simply clang -print-file-name=libclang_rt.${runtime}-${arch}.so
same as other libraries, without having to know the details of the
resource directory organization.

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

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

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=310548=310547=310548=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Aug  9 21:16:38 2017
@@ -309,6 +309,8 @@ public:
 return ToolChain::CST_Libstdcxx;
   }
 
+  virtual std::string getCompilerRTPath() const;
+
   virtual std::string getCompilerRT(const llvm::opt::ArgList ,
 StringRef Component,
 bool Shared = false) const;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=310548=310547=310548=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Aug  9 21:16:38 2017
@@ -3682,7 +3682,12 @@ std::string Driver::GetFilePath(StringRe
   return P.str();
   }
 
-  SmallString<128> P(ResourceDir);
+  SmallString<128> R(ResourceDir);
+  llvm::sys::path::append(R, Name);
+  if (llvm::sys::fs::exists(Twine(R)))
+return R.str();
+
+  SmallString<128> P(TC.getCompilerRTPath());
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=310548=310547=310548=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Aug  9 21:16:38 2017
@@ -308,6 +308,13 @@ static StringRef getArchNameForCompilerR
   return TC.getArchName();
 }
 
+std::string ToolChain::getCompilerRTPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName);
+  return Path.str();
+}
+
 std::string ToolChain::getCompilerRT(const ArgList , StringRef Component,
  bool Shared) const {
   const llvm::Triple  = getTriple();
@@ -320,9 +327,7 @@ std::string ToolChain::getCompilerRT(con
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();


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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-09 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

FWIW, I'm able to reproduce the failure using Docker:

Dockerfile:

  FROM ubuntu:xenial
  RUN apt-get update
  RUN apt-get install -y build-essential ca-certificates subversion python 
cmake --no-install-recommends
  
  WORKDIR /
  RUN svn co -q -r 310537 http://llvm.org/svn/llvm-project/llvm/trunk llvm
  RUN svn co -q -r 310537 http://llvm.org/svn/llvm-project/cfe/trunk 
llvm/tools/clang
  
  RUN mkdir /build
  WORKDIR /build
  
  RUN cmake ../llvm -DCMAKE_BUILD_TYPE="Release"



  $ docker build -t D29660-test . && docker run -it D29660-test /bin/bash

then inside the container: `make check-clang-driver -j8`


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

Thanks for running the test on your machine! This is very useful.

I see what the problem is now:

"clang: error: cannot find libdevice for sm_20. Provide path to different CUDA 
installation via --cuda-path, or pass -nocudalib to build without linking with 
libdevice."

Looking into it now.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-09 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 110514.
malhar1995 marked 7 inline comments as done.
malhar1995 added a comment.

Addressed comments.

P.S: I'm yet to test this callee-side parameter checking functionality on the 
actual ISL codebase. I'll do that ASAP.


Repository:
  rL LLVM

https://reviews.llvm.org/D36441

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-inline.m

Index: test/Analysis/retain-release-inline.m
===
--- test/Analysis/retain-release-inline.m
+++ test/Analysis/retain-release-inline.m
@@ -302,6 +302,9 @@
 __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
 void free(void *);
 
+void callee_side_parameter_checking_leak(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) { // expected-warning {{Potential leak of an object}}
+}
+
 // As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
 // implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
 // a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
@@ -348,6 +351,26 @@
   isl_basic_map_free(bmap);
 }
 
+void callee_side_parameter_checking_incorrect_rc_decrement(isl_basic_map *bmap) {
+  isl_basic_map_free(bmap); // expected-warning {{Incorrect decrement of the reference count}}
+}
+
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *callee_side_parameter_checking_return_notowned_object(isl_basic_map *bmap) {
+  return bmap; // expected-warning {{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
+
+ __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *callee_side_parameter_checking_assign_consumed_parameter_leak_return(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap1, __attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap2) { // expected-warning {{Potential leak of an object}}
+  bmap1 = bmap2;
+  isl_basic_map_free(bmap2);
+  return bmap1;
+}
+
+ __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *callee_side_parameter_checking_assign_consumed_parameter_leak(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap1, __attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap2) { // expected-warning {{Potential leak of an object}}
+  bmap1 = bmap2;
+  isl_basic_map_free(bmap1);
+  return bmap2;
+}
+
 //===--===//
 // Test returning retained and not-retained values.
 //===--===//
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -462,6 +462,7 @@
   ArgEffect getDefaultArgEffect() const { return DefaultArgEffect; }
 
   friend class RetainSummaryManager;
+  friend class RetainCountChecker;
 };
 } // end anonymous namespace
 
@@ -1848,6 +1849,15 @@
 
   class CFRefLeakReport : public CFRefReport {
 const MemRegion* AllocBinding;
+const Stmt *AllocStmt;
+
+// Finds the function declaration where a leak warning for the parameter 'sym' should be raised.
+void deriveParamLocation(CheckerContext , SymbolRef sym);
+// Finds the location where a leak warning for 'sym' should be raised.
+void deriveAllocLocation(CheckerContext , SymbolRef sym);
+// Produces description of a leak warning which is printed on the console.
+void createDescription(CheckerContext , bool GCEnabled, bool IncludeAllocationLine);
+
   public:
 CFRefLeakReport(CFRefBug , const LangOptions , bool GCEnabled,
 const SummaryLogTy , ExplodedNode *n, SymbolRef sym,
@@ -2427,13 +2437,25 @@
   return llvm::make_unique(L, os.str());
 }
 
-CFRefLeakReport::CFRefLeakReport(CFRefBug , const LangOptions ,
- bool GCEnabled, const SummaryLogTy ,
- ExplodedNode *n, SymbolRef sym,
- CheckerContext ,
- bool IncludeAllocationLine)
-  : CFRefReport(D, LOpts, GCEnabled, Log, n, sym, false) {
+void CFRefLeakReport::deriveParamLocation(CheckerContext , SymbolRef sym) {
+  const SourceManager& SMgr = Ctx.getSourceManager();
+
+  if (!sym->getOriginRegion())
+return;
 
+  auto *Region = dyn_cast(sym->getOriginRegion());
+  if (Region) {
+const Decl *PDecl = Region->getDecl();
+if (PDecl && isa(PDecl)) {
+  PathDiagnosticLocation ParamLocation = PathDiagnosticLocation::create(PDecl, SMgr);
+  

[libcxxabi] r310546 - [demangler] Fix some more -Wshadow warnings I missed in r310535

2017-08-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Aug  9 19:48:13 2017
New Revision: 310546

URL: http://llvm.org/viewvc/llvm-project?rev=310546=rev
Log:
[demangler] Fix some more -Wshadow warnings I missed in r310535

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=310546=310545=310546=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Aug  9 19:48:13 2017
@@ -48,7 +48,7 @@ class StringView {
 public:
   template 
   StringView(const char ()[N]) : First(Str), Last(Str + N - 1) {}
-  StringView(const char *First, const char *Last) : First(First), Last(Last) {}
+  StringView(const char *First_, const char *Last_) : First(First_), 
Last(Last_) {}
   StringView() : First(nullptr), Last(nullptr) {}
 
   StringView substr(size_t From, size_t To) {
@@ -132,8 +132,8 @@ public:
   public:
 StreamStringView() : First(0), Last(0) {}
 
-StreamStringView(StreamPosition First, StreamPosition Last)
-: First(First), Last(Last) {}
+StreamStringView(StreamPosition First_, StreamPosition Last_)
+: First(First_), Last(Last_) {}
 
 bool empty() const { return First == Last; }
   };


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


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper resigned from this revision.
craig.topper added a comment.

Guessing I'm only on here because I did the bulk of the 0->nullptr changes to 
clang a few years back.


https://reviews.llvm.org/D36530



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-09 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi, we are seeing this test fail on our internal linux build bot. I built/ran 
your latest change r310537 and here is the test result:

  
/home/dyung/src/upstream/llvm_clean/tools/clang/test/Driver/openmp-offload.c:722:23:
 error: expected string not found in input  
  
  // CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
   
^   
   
  :1:1: note: scanning from here 
   
  clang version 6.0.0 (trunk 310537)
   
  ^ 
   
  :9:114: note: possible intended match here 
   
   "nvlink" "-o" "/tmp/lit_tmp_FMSP4Q/openmp-offload-bb8c5f.out" "-arch" 
"sm_20" "-L/home/dyung/src/upstream/310537-linux/./lib" "-lomptarget-nvptx" 
"openmp-offload-74c18d.cubin"   
   

Executing the run line from line 719 of the file at r310537 produces the 
following output:

  dyung@Spica:~/src/upstream/llvm_clean/tools/clang/test/Driver$ 
/home/dyung/src/upstream/310537-linux/./bin/clang  -### -no-canonical-prefixes 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 
~/src/upstream/llvm_clean/tools/clang/test/Driver/openmp-offload.c 2>&1 
   
  clang version 6.0.0 (trunk 310537)
   
  Target: x86_64-unknown-linux-gnu  
   
  Thread model: posix   
   
  InstalledDir: /home/dyung/src/upstream/310537-linux/./bin 
   
  clang: error: cannot find libdevice for sm_20. Provide path to different CUDA 
installation via --cuda-path, or pass -nocudalib to build without linking with 
libdevice.   
  
   "/home/dyung/src/upstream/310537-linux/./bin/clang" "-cc1" "-triple" 
"x86_64-unknown-linux-gnu" "-emit-llvm-bc" "-emit-llvm-uselists" 
"-disable-free" "-main-file-name" "openmp-offload.c" "-mrelocation-model" 
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" 
"-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" 
"-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" 
"-resource-dir" "/home/dyung/src/upstream/310537-linux/./lib/clang/6.0.0" 
"-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/home/dyung/src/upstream/310537-linux/./lib/clang/6.0.0/include" 
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/home/dyung/src/upstream/310537-linux/./lib/clang/6.0.0/include" 
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-fdebug-compilation-dir" 
"/home/dyung/src/upstream/llvm_clean/tools/clang/test/Driver" "-ferror-limit" 
"19" "-fmessage-length" "117" "-fopenmp" "-fobjc-runtime=gcc" 
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" 
"/tmp/openmp-offload-e58520.bc" "-x" "c" 
"/home/dyung/src/upstream/llvm_clean/tools/clang/test/Driver/openmp-offload.c" 
"-fopenmp-targets=nvptx64-nvidia-cuda"  
  
  
   "/home/dyung/src/upstream/310537-linux/./bin/clang" "-cc1" "-triple" 
"nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu" "-S" 
"-disable-free" "-main-file-name" "openmp-offload.c" "-mrelocation-model" "pic" 
"-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-fuse-init-array" "-target-cpu" "sm_20" 
"-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" 
"/home/dyung/src/upstream/310537-linux/./lib/clang/6.0.0" "-internal-isystem" 
"/usr/local/include" "-internal-isystem" 
"/home/dyung/src/upstream/310537-linux/./lib/clang/6.0.0/include" 
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/home/dyung/src/upstream/310537-linux/./lib/clang/6.0.0/include" 
"-internal-externc-isystem" 

r310539 - clang-format: Fix bug with ENAS_DontAlign and empty lines

2017-08-09 Thread Jacob Bandes-Storch via cfe-commits
Author: jtbandes
Date: Wed Aug  9 17:15:31 2017
New Revision: 310539

URL: http://llvm.org/viewvc/llvm-project?rev=310539=rev
Log:
clang-format: Fix bug with ENAS_DontAlign and empty lines

This fixes a bug in `ENAS_DontAlign` (introduced in D32733) where blank lines 
had an EscapedNewlineColumn of 0, causing a subtraction to overflow when 
converted back to unsigned and leading to runaway memory allocation.

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


Modified:
cfe/trunk/lib/Format/WhitespaceManager.cpp
cfe/trunk/lib/Format/WhitespaceManager.h
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=310539=310538=310539=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Wed Aug  9 17:15:31 2017
@@ -603,8 +603,9 @@ void WhitespaceManager::generateChanges(
 if (C.CreateReplacement) {
   std::string ReplacementText = C.PreviousLinePostfix;
   if (C.ContinuesPPDirective)
-appendNewlineText(ReplacementText, C.NewlinesBefore,
-  C.PreviousEndOfTokenColumn, C.EscapedNewlineColumn);
+appendEscapedNewlineText(ReplacementText, C.NewlinesBefore,
+ C.PreviousEndOfTokenColumn,
+ C.EscapedNewlineColumn);
   else
 appendNewlineText(ReplacementText, C.NewlinesBefore);
   appendIndentText(ReplacementText, C.Tok->IndentLevel,
@@ -640,16 +641,17 @@ void WhitespaceManager::appendNewlineTex
 Text.append(UseCRLF ? "\r\n" : "\n");
 }
 
-void WhitespaceManager::appendNewlineText(std::string , unsigned Newlines,
-  unsigned PreviousEndOfTokenColumn,
-  unsigned EscapedNewlineColumn) {
+void WhitespaceManager::appendEscapedNewlineText(std::string ,
+ unsigned Newlines,
+ unsigned 
PreviousEndOfTokenColumn,
+ unsigned 
EscapedNewlineColumn) {
   if (Newlines > 0) {
-unsigned Offset =
-std::min(EscapedNewlineColumn - 2, PreviousEndOfTokenColumn);
+unsigned Spaces =
+std::max(1, EscapedNewlineColumn - PreviousEndOfTokenColumn - 1);
 for (unsigned i = 0; i < Newlines; ++i) {
-  Text.append(EscapedNewlineColumn - Offset - 1, ' ');
+  Text.append(Spaces, ' ');
   Text.append(UseCRLF ? "\\\r\n" : "\\\n");
-  Offset = 0;
+  Spaces = std::max(0, EscapedNewlineColumn - 1);
 }
   }
 }

Modified: cfe/trunk/lib/Format/WhitespaceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.h?rev=310539=310538=310539=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.h (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.h Wed Aug  9 17:15:31 2017
@@ -195,9 +195,9 @@ private:
   /// \brief Stores \p Text as the replacement for the whitespace in \p Range.
   void storeReplacement(SourceRange Range, StringRef Text);
   void appendNewlineText(std::string , unsigned Newlines);
-  void appendNewlineText(std::string , unsigned Newlines,
- unsigned PreviousEndOfTokenColumn,
- unsigned EscapedNewlineColumn);
+  void appendEscapedNewlineText(std::string , unsigned Newlines,
+unsigned PreviousEndOfTokenColumn,
+unsigned EscapedNewlineColumn);
   void appendIndentText(std::string , unsigned IndentLevel,
 unsigned Spaces, unsigned WhitespaceStartColumn);
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=310539=310538=310539=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Aug  9 17:15:31 2017
@@ -2309,6 +2309,30 @@ TEST_F(FormatTest, EscapedNewlines) {
   EXPECT_EQ("template  f();", format("\\\ntemplate  f();"));
   EXPECT_EQ("/* \\  \\  \\\n */", format("\\\n/* \\  \\  \\\n */"));
   EXPECT_EQ("", format(""));
+
+  FormatStyle DontAlign = getLLVMStyle();
+  DontAlign.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
+  DontAlign.MaxEmptyLinesToKeep = 3;
+  // FIXME: can't use verifyFormat here because the newline before
+  // "public:" is not inserted the first time it's reformatted
+  EXPECT_EQ("#define A \\\n"
+"  class Foo { \\\n"
+"void bar(); \\\n"
+"\\\n"
+"\\\n"
+"\\\n"
+"  public: \\\n"
+ 

[PATCH] D36564: [analyzer] Fix SimpleSValBuilder::simplifySVal

2017-08-09 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
Herald added a subscriber: xazax.hun.

This diff attempts to address a crash (triggered assert) on the newly-added 
test case.
The assert being discussed is inside SValBuilder::evalBinOp

  if (Optional RV = rhs.getAs()) {
 // Support pointer arithmetic where the addend is on the left
 // and the pointer on the right.
 assert(op == BO_Add);

but the root cause seems to be in a different place (if I'm not missing smth).

The method simplifySVal appears to be doing the wrong thing for SVal "(char*)E 
- (char*)B".
Call stack: evalIntegralCast -> evalBinOpNN -> simplifySVal -> ... -> 
simplifySVal -> Simplifier::VisitSymSymExpr -> ...

Inside Simplifier::VisitSymSymExpr the call Visit(S->getLHS()) returns a NonLoc 
(where S->getLHS() represents char* E) while the call Visit(S->getRHS()) 
returns a Loc.

For Visit(S->getRHS()) this happens because in VisitSymbolData(const SymbolData 
*S) the "if" condition

  if (const llvm::APSInt *I =
 SVB.getKnownValue(State, nonloc::SymbolVal(S)))

is satisfied and Loc is correctly chosen.
For Visit(S->getLHS()) nonloc::SymbolVal(S) is used instead.
Next those values will passed to SValBuilder::evalBinOp and the code path

  if (Optional RV = rhs.getAs()) {
 // Support pointer arithmetic where the addend is on the left
 // and the pointer on the right.
assert(op == BO_Add);
 // Commute the operands.
return evalBinOpLN(state, op, *RV, lhs.castAs(), type);
  }

is executed instead of

  if (Optional LV = lhs.getAs()) {
if (Optional RV = rhs.getAs())
  return evalBinOpLL(state, op, *LV, *RV, type);
  
return evalBinOpLN(state, op, *LV, rhs.castAs(), type);
  }

Test plan: make check-all (green)


Repository:
  rL LLVM

https://reviews.llvm.org/D36564

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/ptr-arith.cpp


Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -98,3 +98,10 @@
   int a[5][5];
*(*(a+1)+2) = 2;
 }
+
+unsigned ptrSubtractionNoCrash(char *Begin, char *End) {
+  auto N = End - Begin;
+  if (Begin)
+return 0;
+  return N;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1016,7 +1016,8 @@
   SVB.getKnownValue(State, nonloc::SymbolVal(S)))
 return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I)
 : (SVal)SVB.makeIntVal(*I);
-  return nonloc::SymbolVal(S);
+  return Loc::isLocType(S->getType()) ? (SVal)SVB.makeLoc(S) 
+  : nonloc::SymbolVal(S);
 }
 
 // TODO: Support SymbolCast. Support IntSymExpr when/if we actually


Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -98,3 +98,10 @@
   int a[5][5];
*(*(a+1)+2) = 2;
 }
+
+unsigned ptrSubtractionNoCrash(char *Begin, char *End) {
+  auto N = End - Begin;
+  if (Begin)
+return 0;
+  return N;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1016,7 +1016,8 @@
   SVB.getKnownValue(State, nonloc::SymbolVal(S)))
 return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I)
 : (SVal)SVB.makeIntVal(*I);
-  return nonloc::SymbolVal(S);
+  return Loc::isLocType(S->getType()) ? (SVal)SVB.makeLoc(S) 
+  : nonloc::SymbolVal(S);
 }
 
 // TODO: Support SymbolCast. Support IntSymExpr when/if we actually
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36563: Add a getName accessor for ModuleMacros

2017-08-09 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson created this revision.
Herald added a subscriber: mcrosier.

Swift would like to be able to access the name of a ModuleMacro. There was some 
discussion of this in https://github.com/apple/swift-clang/pull/93, suggesting 
that it makes sense to have this accessor in Clang.


https://reviews.llvm.org/D36563

Files:
  clang/Lex/MacroInfo.h


Index: clang/Lex/MacroInfo.h
===
--- clang/Lex/MacroInfo.h
+++ clang/Lex/MacroInfo.h
@@ -510,6 +510,9 @@
 ID.AddPointer(II);
   }
 
+  /// Get the name of the macro.
+  IdentifierInfo *getName() const { return II; }
+
   /// Get the ID of the module that exports this macro.
   Module *getOwningModule() const { return OwningModule; }
 


Index: clang/Lex/MacroInfo.h
===
--- clang/Lex/MacroInfo.h
+++ clang/Lex/MacroInfo.h
@@ -510,6 +510,9 @@
 ID.AddPointer(II);
   }
 
+  /// Get the name of the macro.
+  IdentifierInfo *getName() const { return II; }
+
   /// Get the ID of the module that exports this macro.
   Module *getOwningModule() const { return OwningModule; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310540 - Remove unused function

2017-08-09 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Wed Aug  9 17:19:43 2017
New Revision: 310540

URL: http://llvm.org/viewvc/llvm-project?rev=310540=rev
Log:
Remove unused function

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=310540=310539=310540=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Aug  9 17:19:43 2017
@@ -7381,8 +7381,6 @@ class AMDGPUABIInfo final : public Defau
 private:
   static const unsigned MaxNumRegsForArgsRet = 16;
 
-  bool shouldReturnTypeInRegister(QualType Ty,
-  ASTContext ) const;
   unsigned numRegsForType(QualType Ty) const;
 
   bool isHomogeneousAggregateBaseType(QualType Ty) const override;
@@ -7412,13 +7410,6 @@ bool AMDGPUABIInfo::isHomogeneousAggrega
   return Members * NumRegs <= MaxNumRegsForArgsRet;
 }
 
-/// Check whether the type is small enough to consider passing directly in
-/// registers.
-bool AMDGPUABIInfo::shouldReturnTypeInRegister(QualType Ty,
-   ASTContext ) const {
-  return ((Ctx.getTypeSize(Ty) + 31) / 32) <= MaxNumRegsForArgsRet;
-}
-
 /// Estimate number of registers the type will use when passed in registers.
 unsigned AMDGPUABIInfo::numRegsForType(QualType Ty) const {
   unsigned NumRegs = 0;


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


[PATCH] D36019: [clang-format] Fix bug with ENAS_DontAlign and empty lines

2017-08-09 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310539: clang-format: Fix bug with ENAS_DontAlign and empty 
lines (authored by jtbandes).

Repository:
  rL LLVM

https://reviews.llvm.org/D36019

Files:
  cfe/trunk/lib/Format/WhitespaceManager.cpp
  cfe/trunk/lib/Format/WhitespaceManager.h
  cfe/trunk/unittests/Format/FormatTest.cpp


Index: cfe/trunk/lib/Format/WhitespaceManager.h
===
--- cfe/trunk/lib/Format/WhitespaceManager.h
+++ cfe/trunk/lib/Format/WhitespaceManager.h
@@ -195,9 +195,9 @@
   /// \brief Stores \p Text as the replacement for the whitespace in \p Range.
   void storeReplacement(SourceRange Range, StringRef Text);
   void appendNewlineText(std::string , unsigned Newlines);
-  void appendNewlineText(std::string , unsigned Newlines,
- unsigned PreviousEndOfTokenColumn,
- unsigned EscapedNewlineColumn);
+  void appendEscapedNewlineText(std::string , unsigned Newlines,
+unsigned PreviousEndOfTokenColumn,
+unsigned EscapedNewlineColumn);
   void appendIndentText(std::string , unsigned IndentLevel,
 unsigned Spaces, unsigned WhitespaceStartColumn);
 
Index: cfe/trunk/lib/Format/WhitespaceManager.cpp
===
--- cfe/trunk/lib/Format/WhitespaceManager.cpp
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp
@@ -603,8 +603,9 @@
 if (C.CreateReplacement) {
   std::string ReplacementText = C.PreviousLinePostfix;
   if (C.ContinuesPPDirective)
-appendNewlineText(ReplacementText, C.NewlinesBefore,
-  C.PreviousEndOfTokenColumn, C.EscapedNewlineColumn);
+appendEscapedNewlineText(ReplacementText, C.NewlinesBefore,
+ C.PreviousEndOfTokenColumn,
+ C.EscapedNewlineColumn);
   else
 appendNewlineText(ReplacementText, C.NewlinesBefore);
   appendIndentText(ReplacementText, C.Tok->IndentLevel,
@@ -640,16 +641,17 @@
 Text.append(UseCRLF ? "\r\n" : "\n");
 }
 
-void WhitespaceManager::appendNewlineText(std::string , unsigned Newlines,
-  unsigned PreviousEndOfTokenColumn,
-  unsigned EscapedNewlineColumn) {
+void WhitespaceManager::appendEscapedNewlineText(std::string ,
+ unsigned Newlines,
+ unsigned 
PreviousEndOfTokenColumn,
+ unsigned 
EscapedNewlineColumn) {
   if (Newlines > 0) {
-unsigned Offset =
-std::min(EscapedNewlineColumn - 2, PreviousEndOfTokenColumn);
+unsigned Spaces =
+std::max(1, EscapedNewlineColumn - PreviousEndOfTokenColumn - 1);
 for (unsigned i = 0; i < Newlines; ++i) {
-  Text.append(EscapedNewlineColumn - Offset - 1, ' ');
+  Text.append(Spaces, ' ');
   Text.append(UseCRLF ? "\\\r\n" : "\\\n");
-  Offset = 0;
+  Spaces = std::max(0, EscapedNewlineColumn - 1);
 }
   }
 }
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -2309,6 +2309,30 @@
   EXPECT_EQ("template  f();", format("\\\ntemplate  f();"));
   EXPECT_EQ("/* \\  \\  \\\n */", format("\\\n/* \\  \\  \\\n */"));
   EXPECT_EQ("", format(""));
+
+  FormatStyle DontAlign = getLLVMStyle();
+  DontAlign.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
+  DontAlign.MaxEmptyLinesToKeep = 3;
+  // FIXME: can't use verifyFormat here because the newline before
+  // "public:" is not inserted the first time it's reformatted
+  EXPECT_EQ("#define A \\\n"
+"  class Foo { \\\n"
+"void bar(); \\\n"
+"\\\n"
+"\\\n"
+"\\\n"
+"  public: \\\n"
+"void baz(); \\\n"
+"  };",
+format("#define A \\\n"
+   "  class Foo { \\\n"
+   "void bar(); \\\n"
+   "\\\n"
+   "\\\n"
+   "\\\n"
+   "  public: \\\n"
+   "void baz(); \\\n"
+   "  };", DontAlign));
 }
 
 TEST_F(FormatTest, CalculateSpaceOnConsecutiveLinesInMacro) {


Index: cfe/trunk/lib/Format/WhitespaceManager.h
===
--- cfe/trunk/lib/Format/WhitespaceManager.h
+++ cfe/trunk/lib/Format/WhitespaceManager.h
@@ -195,9 +195,9 @@
   /// \brief Stores \p Text as the replacement for the whitespace in \p Range.
   void storeReplacement(SourceRange Range, StringRef Text);
   void appendNewlineText(std::string , unsigned 

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

I've removed that test. Let's see if the other two tests pass or not.

I can't reproduce the error locally so it's hard to figure out what's failing.

If you have a machine with that configuration and can run the command I would 
appreciate seeing the output of the failing command. That way I know what the 
driver is doing on your machine.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-09 Thread Hans Wennborg via cfe-commits
Marshall: ping?

On Thu, Aug 3, 2017 at 10:20 AM, Hans Wennborg  wrote:
> Sounds good to me, but Eric or Marshall need to sign off.
>
> On Thu, Aug 3, 2017 at 10:15 AM, Shoaib Meenai  wrote:
>> Ping.
>>
>> On 7/28/17, 7:57 PM, "Shoaib Meenai"  wrote:
>>
>> Marshall, Eric, Hans,
>>
>> Any objections to backporting this to 5.0? It fixes a potential 
>> visibility
>> issue for clients of the header.
>>
>> On 7/28/17, 7:54 PM, "cfe-commits on behalf of Shoaib Meenai via 
>> cfe-commits" > cfe-commits@lists.llvm.org> wrote:
>>
>> Author: smeenai
>> Date: Fri Jul 28 19:54:41 2017
>> New Revision: 309474
>>
>> URL: 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D309474-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=EcGbIxegCOTbSLMJelp_vOaeGiS_iQ1eciM_oeX41-E=5q7TS5mhaUsf-1jQBqX62RvjcqAiy2whh8RO7yFhPyA=
>> Log:
>> [libc++] Hoist extern template above first use
>>
>> This function template is referenced inside class basic_string as a
>> friend function. The extern template declaration needs to be above 
>> that
>> friend declaration to actually take effect.
>>
>> This is important because this function was marked as exported in
>> r307966, so without the extern template taking effect, it can leak 
>> into
>> other DSOs as a visible symbol.
>>
>> Modified:
>> libcxx/trunk/include/string
>>
>> Modified: libcxx/trunk/include/string
>> URL: 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_string-3Frev-3D309474-26r1-3D309473-26r2-3D309474-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=EcGbIxegCOTbSLMJelp_vOaeGiS_iQ1eciM_oeX41-E=zFJXc9CA6Sgyh25kGeAh4Qo36gpNQX_zo2qRlRFJoL8=
>> 
>> ==
>> --- libcxx/trunk/include/string (original)
>> +++ libcxx/trunk/include/string Fri Jul 28 19:54:41 2017
>> @@ -556,6 +556,8 @@ template>  basic_string<_CharT, _Traits, _Allocator>
>>  operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, 
>> _CharT __y);
>>
>> +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+> char_traits, allocator >(char const*, string const&))
>> +
>>  template 
>>  class _LIBCPP_TEMPLATE_VIS __basic_string_common
>>  {
>> @@ -3999,7 +4001,6 @@ basic_string<_CharT, _Traits, _Allocator
>>
>>  _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
>> basic_string)
>>  _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
>> basic_string)
>> -_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+> char_traits, allocator >(char const*, string const&))
>>
>>  #if _LIBCPP_STD_VER > 11
>>  // Literal suffixes for basic_string [basic.string.literals]
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=EcGbIxegCOTbSLMJelp_vOaeGiS_iQ1eciM_oeX41-E=95GYNfQT_kBVjYvYRYnF3mje6PEyF4EDl4MCBQKCu88=
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-09 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

r310519 did not fix the problem, see 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7062. I 
would suggest to revert and fix it properly, our bots are broken for a few days 
already.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[libcxxabi] r310535 - [demangler] Fix a bunch of -Wshadow warnings

2017-08-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Aug  9 15:45:35 2017
New Revision: 310535

URL: http://llvm.org/viewvc/llvm-project?rev=310535=rev
Log:
[demangler] Fix a bunch of -Wshadow warnings

These were causing failures in -Werror builds.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=310535=310534=310535=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Aug  9 15:45:35 2017
@@ -216,10 +216,10 @@ private:
   const unsigned HasArray : 1;
 
 public:
-  Node(Kind K, bool HasRHS = false, bool HasFunction = false,
-   bool HasArray = false)
-  : K(K), HasRHSComponent(HasRHS), HasFunction(HasFunction),
-HasArray(HasArray) {}
+  Node(Kind K_, bool HasRHS_ = false, bool HasFunction_ = false,
+   bool HasArray_ = false)
+  : K(K_), HasRHSComponent(HasRHS_), HasFunction(HasFunction_),
+HasArray(HasArray_) {}
 
   bool hasRHSComponent() const { return HasRHSComponent; }
   bool hasArray() const { return HasArray; }
@@ -252,8 +252,8 @@ class NodeArray {
 
 public:
   NodeArray() : NumElements(0) {}
-  NodeArray(Node **Elements, size_t NumElements)
-  : Elements(Elements), NumElements(NumElements) {}
+  NodeArray(Node **Elements_, size_t NumElements_)
+  : Elements(Elements_), NumElements(NumElements_) {}
 
   bool empty() const { return NumElements == 0; }
   size_t size() const { return NumElements; }
@@ -272,8 +272,8 @@ class DotSuffix final : public Node {
   const StringView Suffix;
 
 public:
-  DotSuffix(Node *Prefix, StringView Suffix)
-  : Node(KDotSuffix), Prefix(Prefix), Suffix(Suffix) {}
+  DotSuffix(Node *Prefix_, StringView Suffix_)
+  : Node(KDotSuffix), Prefix(Prefix_), Suffix(Suffix_) {}
 
   void printLeft(OutputStream ) const override {
 Prefix->print(s);
@@ -288,8 +288,8 @@ class VendorExtQualType final : public N
   const Node *Ty;
 
 public:
-  VendorExtQualType(Node *Ext, Node *Ty)
-  : Node(KVendorExtQualType), Ext(Ext), Ty(Ty) {}
+  VendorExtQualType(Node *Ext_, Node *Ty_)
+  : Node(KVendorExtQualType), Ext(Ext_), Ty(Ty_) {}
 
   void printLeft(OutputStream ) const override {
 Ext->print(S);
@@ -326,15 +326,15 @@ protected:
   }
 
 public:
-  QualType(Node *Child, Qualifiers Quals)
-  : Node(KQualType, Child->hasRHSComponent(), Child->hasFunction(),
- Child->hasArray()),
-Quals(Quals), Child(Child) {}
-
-  QualType(Node::Kind ChildKind, Node *Child, Qualifiers Quals)
-  : Node(ChildKind, Child->hasRHSComponent(), Child->hasFunction(),
- Child->hasArray()),
-Quals(Quals), Child(Child) {}
+  QualType(Node *Child_, Qualifiers Quals_)
+  : Node(KQualType, Child_->hasRHSComponent(), Child_->hasFunction(),
+ Child_->hasArray()),
+Quals(Quals_), Child(Child_) {}
+
+  QualType(Node::Kind ChildKind_, Node *Child_, Qualifiers Quals_)
+  : Node(ChildKind_, Child_->hasRHSComponent(), Child_->hasFunction(),
+ Child_->hasArray()),
+Quals(Quals_), Child(Child_) {}
 
   void printLeft(OutputStream ) const override {
 Child->printLeft(S);
@@ -348,7 +348,7 @@ class ConversionOperatorType final : pub
   const Node *Ty;
 
 public:
-  ConversionOperatorType(Node *Ty) : Node(KConversionOperatorType), Ty(Ty) {}
+  ConversionOperatorType(Node *Ty_) : Node(KConversionOperatorType), Ty(Ty_) {}
 
   void printLeft(OutputStream ) const override {
 S += "operator ";
@@ -361,8 +361,8 @@ class PostfixQualifiedType final : publi
   const StringView Postfix;
 
 public:
-  PostfixQualifiedType(Node *Ty, StringView Postfix)
-  : Node(KPostfixQualifiedType), Ty(Ty), Postfix(Postfix) {}
+  PostfixQualifiedType(Node *Ty_, StringView Postfix_)
+  : Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {}
 
   void printLeft(OutputStream ) const override {
 Ty->printLeft(s);
@@ -376,7 +376,7 @@ class NameType final : public Node {
   const StringView Name;
 
 public:
-  NameType(StringView Name) : Node(KNameType), Name(Name) {}
+  NameType(StringView Name_) : Node(KNameType), Name(Name_) {}
 
   StringView getName() const { return Name; }
   StringView getBaseName() const override { return Name; }
@@ -391,8 +391,8 @@ class ObjCProtoName : public Node {
   friend class PointerType;
 
 public:
-  ObjCProtoName(Node *Ty, Node *Protocol)
-  : Node(KObjCProtoName), Ty(Ty), Protocol(Protocol) {}
+  ObjCProtoName(Node *Ty_, Node *Protocol_)
+  : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {}
 
   bool isObjCObject() const {
 return Ty->K == KNameType &&
@@ -411,8 +411,8 @@ class PointerType final : public Node {
   const Node *Pointee;
 
 public:
-  PointerType(Node *Pointee)
-  : Node(KPointerType, Pointee->hasRHSComponent()), Pointee(Pointee) {}
+  PointerType(Node *Pointee_)
+  : 

[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-09 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Just to restate: the ideal outcome of this discussion for me would be to 
resolve things such that _ALL_ libc implementations will feel comfortable using 
this technique to provide the C11-required predefined macros.

I'd love for linux, freebsd, macos, solaris, etc etc libc to all conform to the 
C standard in this regards, and do so in a common way, without the need to 
encode information about each libc version into the compiler. I _really_ don't 
think that scales well.

So I take your comments from FreeBSD's point of view seriously, and would very 
much like to understand and hopefully resolve them.

In https://reviews.llvm.org/D34158#837130, @joerg wrote:

> In https://reviews.llvm.org/D34158#836026, @jyknight wrote:
>
> > In https://reviews.llvm.org/D34158#827178, @joerg wrote:
> >
> > > (2) It adds magic behavior that can make debugging more difficult. 
> > > Partially preprocessed sources for example could be compiled with plain 
> > > -c before, now they need a different command line.
> >
> >
> > If this is a problem, making it be Linux-only does _nothing_ to solve it. 
> > But I don't actually see how this is a substantively new problem? Compiling 
> > with plain -c before
> >  would get #defines for those predefined macros that the compiler sets, 
> > even though you may not have wanted those. Is this fundamentally different?
>
>
> It makes it a linux-only problem. As such, it is something *I* only care 
> about secondary. A typical use case I care about a lot is pulling the crash 
> report sources from my (NetBSD) build machine,
>  extracting the original command line to rerun the normal compilation with 
> -save-temps. I don't necessarily have the (same) system headers on the 
> machine I use for debugging and that's exactly
>  the kind of use case this change breaks. All other predefined macros are 
> driven by the target triple and remain stable.


"it's Linux only so I don't care if it's broken." is still not very helpful. :)

But I do think understand what you're saying now, so thanks for the elaboration.

Firstly, let's consider a "clang foo.i" or "clang -x cpp-output foo.c" 
compilation. In that case, it *clearly* should not be including the predef 
file. I think the patch as it stands may not do this properly. A test needs to 
be added for this to this patch, and perhaps the behavior needs to be fixed as 
well.

(Sidenote: clang doesn't support preprocessed input properly, but that's 
another bug, and we certainly ought not make it worse. Check out e.g. "int 
main() { return __GNUC__; }". it should report that __GNUC__ is undeclared, but 
instead compiles a program that returns 4.)

But, that's not the case you're talking about above -- you're not talking about 
compiling preprocessed output, you're talking about taking output that comes 
from -frewrite-includes.

Let me recap the scenario:

1. Start with a source file foo.c, with this content:

#include 
#pragma clang __debug parser_crash

2. Run "clang foo.c". It crashes, and dumps a /tmp/foo-XXX.c and a 
/tmp/foo-XXX.sh script.

The .c file is generated via -frewrite-includes, so it's _not_ already 
preprocessed, it simply has all includes pulled into a single file. It also 
_doesn't_ insert the compiler-predefined macros at the top, but it _will_ 
include the content of this stdc-predef.h file.

OK, so then...
The generated script invokes a -cc1 command line, with all the include 
arguments stripped out of the command. (TO FIX: We should be stripping the new 
arg as well: add "-fsystem-include-if-exists" argument to the list of include 
things in the skipArgs() function in lib/Driver/Job.cpp). Even without that 
change, it's actually already fine, as there is no include path specified in 
which to find the file -- but it's cleaner to strip it, so let's do that. The 
reproducer script will thus run correctly, and not include the file.

Now, the "/tmp/foo-XXX.sh" also has a line labeled "Driver args: " with the 
original command-line on it. If I understand correctly, you then like to take 
this simpler Driver command-line, and edit it manually: add -save-temps, and 
change the input filename  to the "/tmp/foo-XXX.c" file, and run that, instead 
of actually invoking the reproducer foo-XXX.sh.

Since stdc-predef.h is included automatically, it will now be present twice -- 
first, it will read the one from your system's /usr/include, and then the copy 
inlined into the /tmp/foo-XXX.c file. That's not what you desired. You wanted 
nothing from your /usr/include to be used.

The fix for the end-user here is easy: you can add -nostdinc which will 
suppress all the default include paths, and thus it will not find this predef 
file from your system include dir.

I'll note that you'd also have had an issue if the original driver command-line 
had a "-include" option in it, which you would have needed to edit out manually 
as well. (But I understand that is less common.)

Have I correctly described the situation? I 

[clang-tools-extra] r310532 - [clang-tidy] Don't compute the edit distance if it's over the threshold.

2017-08-09 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Aug  9 15:09:29 2017
New Revision: 310532

URL: http://llvm.org/viewvc/llvm-project?rev=310532=rev
Log:
[clang-tidy] Don't compute the edit distance if it's over the threshold.

No functional change intended.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp?rev=310532=310531=310532=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp Wed Aug  9 
15:09:29 2017
@@ -244,8 +244,8 @@ void VirtualNearMissCheck::check(const M
 if (isOverriddenByDerivedClass(BaseMD, DerivedRD))
   continue;
 
-unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+unsigned EditDistance = BaseMD->getName().edit_distance(
+DerivedMD->getName(), EditDistanceThreshold);
 if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
   if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
 // A "virtual near miss" is found.


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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-08-09 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

yaxunl wrote:
> bader wrote:
> > yaxunl wrote:
> > > bader wrote:
> > > > yaxunl wrote:
> > > > > bader wrote:
> > > > > > yaxunl wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > bader wrote:
> > > > > > > > > yaxunl wrote:
> > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > echuraev wrote:
> > > > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > > > > > Looks good from my side.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > @yaxunl , since you originally committed this. 
> > > > > > > > > > > > > > > > Could you please verify that changing from 
> > > > > > > > > > > > > > > > `SIZE_MAX` to `0` would be fine.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > Btw, we have a similar definition for 
> > > > > > > > > > > > > > > > `CLK_NULL_EVENT`.
> > > > > > > > > > > > > > > `__PIPE_RESERVE_ID_VALID_BIT` is implementation 
> > > > > > > > > > > > > > > detail and not part of the spec. I would suggest 
> > > > > > > > > > > > > > > to remove it from this header file.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > The spec only requires CLK_NULL_RESERVE_ID to be 
> > > > > > > > > > > > > > > defined but does not define its value. Naturally 
> > > > > > > > > > > > > > > a valid id starts from 0 and increases. I don't 
> > > > > > > > > > > > > > > see significant advantage to change 
> > > > > > > > > > > > > > > CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Is there any reason that this change is needed?
> > > > > > > > > > > > > > I don't see issues to commit things outside of spec 
> > > > > > > > > > > > > > as soon as they prefixed properly with "__".  But I 
> > > > > > > > > > > > > > agree it would be nice to see if it's any useful 
> > > > > > > > > > > > > > and what the motivation is for having different 
> > > > > > > > > > > > > > implementation.
> > > > > > > > > > > > > For `__PIPE_RESERVE_ID_VALID_BIT`, it assumes that 
> > > > > > > > > > > > > the implementation uses one specific bit of a reserve 
> > > > > > > > > > > > > id to indicate that the reserve id is valid. Not all 
> > > > > > > > > > > > > implementations assume that. Actually I am curious 
> > > > > > > > > > > > > why that is needed too.
> > > > > > > > > > > > About `CLK_NULL_RESERVE_ID`: we check that reserve id 
> > > > > > > > > > > > is valid if significant bit equal to one. 
> > > > > > > > > > > > `CLK_NULL_RESERVE_ID refers to an invalid reservation, 
> > > > > > > > > > > > so if `CLK_NULL_RESERVE_ID equal to 0, we can be sure 
> > > > > > > > > > > > that significant bit doesn't equal to 1 and it is 
> > > > > > > > > > > > invalid reserve id. Also it is more obviously if 
> > > > > > > > > > > > CLK_**NULL**_RESERVE_ID is equal to 0.
> > > > > > > > > > > > 
> > > > > > > > > > > > What about `__PIPE_RESERVE_ID_VALID_BIT`: As I 
> > > > > > > > > > > > understand previous implementation also assumes that 
> > > > > > > > > > > > one specific bit was of a reverse id was used to 
> > > > > > > > > > > > indicate that the reserve id is valid. So, we just 
> > > > > > > > > > > > increased reserve id size by one bit on 32-bit 
> > > > > > > > > > > > platforms and by 33 bits on 64-bit platforms. 
> > > > > > > > > > > It is more logical to me that `CLK_NULL_RESERVE_ID` is 0, 
> > > > > > > > > > > but spec doesn't define it of course.
> > > > > > > > > > In our implementation, valid reserve id starts at 0 and 
> > > > > > > > > > increasing linearly until `__SIZE_MAX-1`. This change will 
> > > > > > > > > > break our implementation.
> > > > > > > > > > 
> > > > > > > > > > However, we can modify our implementation to adopt this 
> > > > > > > > > > change since it brings about benefits overall.
> > > > > > > > > Ideally it would be great to have unified implementation, but 
> > > > > > > > > we can define device specific value for CLK_NULL_RESERVE_ID 
> > > > > > > > > by using ifdef directive.
> > > > > > > > How about
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > __attribute__((const)) size_t __clk_null_reserve_id();
> > > > > > > > #define CLK_NULL_RESERVE_ID __clk_null_reserve_id()
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > I think the spec does not require it to be compile time 
> > > > > > > > constant. Then each library can implement its own 
> > > > > > > > __clk_null_reserve_id() whereas the IR is target independent.
> > > > > > > Or we only do this for SPIR and define it as target specific 
> > > > > > > value for other targets.
> > > > > 

[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r310527


https://reviews.llvm.org/D36171



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


[PATCH] D36555: Move x86-specific sources to x86-specific source lists.

2017-08-09 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine created this revision.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D36555

Files:
  compiler-rt/lib/builtins/CMakeLists.txt


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -51,7 +51,6 @@
   cmpti2.c
   comparedf2.c
   comparesf2.c
-  cpu_model.c
   ctzdi2.c
   ctzsi2.c
   ctzti2.c
@@ -66,7 +65,6 @@
   divtc3.c
   divti3.c
   divtf3.c
-  divxc3.c
   extendsfdf2.c
   extendhfsf2.c
   ffsdi2.c
@@ -84,22 +82,17 @@
   fixunssfdi.c
   fixunssfsi.c
   fixunssfti.c
-  fixunsxfdi.c
-  fixunsxfsi.c
   fixunsxfti.c
-  fixxfdi.c
   fixxfti.c
   floatdidf.c
   floatdisf.c
-  floatdixf.c
   floatsidf.c
   floatsisf.c
   floattidf.c
   floattisf.c
   floattixf.c
   floatundidf.c
   floatundisf.c
-  floatundixf.c
   floatunsidf.c
   floatunsisf.c
   floatuntidf.c
@@ -124,7 +117,6 @@
   mulvdi3.c
   mulvsi3.c
   mulvti3.c
-  mulxc3.c
   negdf2.c
   negdi2.c
   negsf2.c
@@ -142,7 +134,6 @@
   powidf2.c
   powisf2.c
   powitf2.c
-  powixf2.c
   subdf3.c
   subsf3.c
   subvdi3.c
@@ -226,6 +217,18 @@
 clear_cache.c)
 endif()
 
+# These sources work on all x86 variants, but only x86 variants.
+set(x86_ARCH_SOURCES
+  cpu_model.c
+  divxc3.c
+  fixxfdi.c
+  fixunsxfdi.c
+  fixunsxfsi.c
+  floatdixf.c
+  floatundixf.c
+  mulxc3.c
+  powixf2.c)
+
 if (NOT MSVC)
   set(x86_64_SOURCES
   x86_64/chkstk.S
@@ -288,6 +291,11 @@
   set(i686_SOURCES ${i386_SOURCES})
 endif () # if (NOT MSVC)
 
+set(x86_64h_SOURCES ${x86_64h_SOURCES} ${x86_ARCH_SOURCES})
+set(x86_64_SOURCES ${x86_64_SOURCES} ${x86_ARCH_SOURCES})
+set(i386_SOURCES ${i386_SOURCES} ${x86_ARCH_SOURCES})
+set(i686_SOURCES ${i686_SOURCES} ${x86_ARCH_SOURCES})
+
 set(arm_SOURCES
   arm/bswapdi2.S
   arm/bswapsi2.S


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -51,7 +51,6 @@
   cmpti2.c
   comparedf2.c
   comparesf2.c
-  cpu_model.c
   ctzdi2.c
   ctzsi2.c
   ctzti2.c
@@ -66,7 +65,6 @@
   divtc3.c
   divti3.c
   divtf3.c
-  divxc3.c
   extendsfdf2.c
   extendhfsf2.c
   ffsdi2.c
@@ -84,22 +82,17 @@
   fixunssfdi.c
   fixunssfsi.c
   fixunssfti.c
-  fixunsxfdi.c
-  fixunsxfsi.c
   fixunsxfti.c
-  fixxfdi.c
   fixxfti.c
   floatdidf.c
   floatdisf.c
-  floatdixf.c
   floatsidf.c
   floatsisf.c
   floattidf.c
   floattisf.c
   floattixf.c
   floatundidf.c
   floatundisf.c
-  floatundixf.c
   floatunsidf.c
   floatunsisf.c
   floatuntidf.c
@@ -124,7 +117,6 @@
   mulvdi3.c
   mulvsi3.c
   mulvti3.c
-  mulxc3.c
   negdf2.c
   negdi2.c
   negsf2.c
@@ -142,7 +134,6 @@
   powidf2.c
   powisf2.c
   powitf2.c
-  powixf2.c
   subdf3.c
   subsf3.c
   subvdi3.c
@@ -226,6 +217,18 @@
 clear_cache.c)
 endif()
 
+# These sources work on all x86 variants, but only x86 variants.
+set(x86_ARCH_SOURCES
+  cpu_model.c
+  divxc3.c
+  fixxfdi.c
+  fixunsxfdi.c
+  fixunsxfsi.c
+  floatdixf.c
+  floatundixf.c
+  mulxc3.c
+  powixf2.c)
+
 if (NOT MSVC)
   set(x86_64_SOURCES
   x86_64/chkstk.S
@@ -288,6 +291,11 @@
   set(i686_SOURCES ${i386_SOURCES})
 endif () # if (NOT MSVC)
 
+set(x86_64h_SOURCES ${x86_64h_SOURCES} ${x86_ARCH_SOURCES})
+set(x86_64_SOURCES ${x86_64_SOURCES} ${x86_ARCH_SOURCES})
+set(i386_SOURCES ${i386_SOURCES} ${x86_ARCH_SOURCES})
+set(i686_SOURCES ${i686_SOURCES} ${x86_ARCH_SOURCES})
+
 set(arm_SOURCES
   arm/bswapdi2.S
   arm/bswapsi2.S
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36230: [X86][Asm] Allow negative immediate to appear before bracketed expression

2017-08-09 Thread coby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310529: [X86][Asm] Allow negative immediate to appear before 
bracketed expression (authored by coby).

Changed prior to commit:
  https://reviews.llvm.org/D36230?vs=109374=110485#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36230

Files:
  cfe/trunk/test/CodeGen/ms-inline-asm.c


Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -484,13 +484,13 @@
   __asm mov eax, (4 + 4) * 16
 // CHECK: mov eax, $$128
   __asm mov eax, 4 + 8 * -16
-// CHECK: mov eax, $$4294967172
+// CHECK: mov eax, $$-124
   __asm mov eax, 4 + 16 / -8
 // CHECK: mov eax, $$2
   __asm mov eax, (16 + 16) / -8
-// CHECK: mov eax, $$4294967292
+// CHECK: mov eax, $$-4
   __asm mov eax, ~15
-// CHECK: mov eax, $$4294967280
+// CHECK: mov eax, $$-16
   __asm mov eax, 6 ^ 3
 // CHECK: mov eax, $$5
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
@@ -655,6 +655,12 @@
   // CHECK: call void asm sideeffect inteldialect "mov dr0, eax\0A\09mov dr1, 
ebx\0A\09mov dr2, ebx\0A\09mov dr3, ecx\0A\09mov dr6, edx\0A\09mov dr7, ecx", 
"~{dr0},~{dr1},~{dr2},~{dr3},~{dr6},~{dr7},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t46() {
+  // CHECK-LABEL: define void @t46
+  __asm add eax, -128[eax]
+  // CHECK: call void asm sideeffect inteldialect "add eax, $$-128[eax]", 
"~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
__asm { mov eax, 3[ebx]A.b}


Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -484,13 +484,13 @@
   __asm mov eax, (4 + 4) * 16
 // CHECK: mov eax, $$128
   __asm mov eax, 4 + 8 * -16
-// CHECK: mov eax, $$4294967172
+// CHECK: mov eax, $$-124
   __asm mov eax, 4 + 16 / -8
 // CHECK: mov eax, $$2
   __asm mov eax, (16 + 16) / -8
-// CHECK: mov eax, $$4294967292
+// CHECK: mov eax, $$-4
   __asm mov eax, ~15
-// CHECK: mov eax, $$4294967280
+// CHECK: mov eax, $$-16
   __asm mov eax, 6 ^ 3
 // CHECK: mov eax, $$5
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
@@ -655,6 +655,12 @@
   // CHECK: call void asm sideeffect inteldialect "mov dr0, eax\0A\09mov dr1, ebx\0A\09mov dr2, ebx\0A\09mov dr3, ecx\0A\09mov dr6, edx\0A\09mov dr7, ecx", "~{dr0},~{dr1},~{dr2},~{dr3},~{dr6},~{dr7},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t46() {
+  // CHECK-LABEL: define void @t46
+  __asm add eax, -128[eax]
+  // CHECK: call void asm sideeffect inteldialect "add eax, $$-128[eax]", "~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
 	__asm { mov eax, 3[ebx]A.b}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r310530 - Mark test as unsupported c++98/03 to fix buildbots

2017-08-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Aug  9 14:51:56 2017
New Revision: 310530

URL: http://llvm.org/viewvc/llvm-project?rev=310530=rev
Log:
Mark test as unsupported c++98/03 to fix buildbots

Modified:
libcxxabi/trunk/test/unittest_demangle.pass.cpp

Modified: libcxxabi/trunk/test/unittest_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unittest_demangle.pass.cpp?rev=310530=310529=310530=diff
==
--- libcxxabi/trunk/test/unittest_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/unittest_demangle.pass.cpp Wed Aug  9 14:51:56 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 #include "../src/cxa_demangle.cpp"
 
 using namespace __cxxabiv1;


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


r310529 - [X86][Asm] Allow negative immediate to appear before bracketed expression

2017-08-09 Thread Coby Tayree via cfe-commits
Author: coby
Date: Wed Aug  9 14:50:22 2017
New Revision: 310529

URL: http://llvm.org/viewvc/llvm-project?rev=310529=rev
Log:
[X86][Asm] Allow negative immediate to appear before bracketed expression

Currently, only non-negative immediate is allowed prior to a brac expression 
(memory reference).
MASM / GAS does not have any problem cope with the left side of the real line, 
so we should be able to as well.

llvm: D36229

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

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

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=310529=310528=310529=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Wed Aug  9 14:50:22 2017
@@ -484,13 +484,13 @@ void t37() {
   __asm mov eax, (4 + 4) * 16
 // CHECK: mov eax, $$128
   __asm mov eax, 4 + 8 * -16
-// CHECK: mov eax, $$4294967172
+// CHECK: mov eax, $$-124
   __asm mov eax, 4 + 16 / -8
 // CHECK: mov eax, $$2
   __asm mov eax, (16 + 16) / -8
-// CHECK: mov eax, $$4294967292
+// CHECK: mov eax, $$-4
   __asm mov eax, ~15
-// CHECK: mov eax, $$4294967280
+// CHECK: mov eax, $$-16
   __asm mov eax, 6 ^ 3
 // CHECK: mov eax, $$5
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
@@ -655,6 +655,12 @@ void t45() {
   // CHECK: call void asm sideeffect inteldialect "mov dr0, eax\0A\09mov dr1, 
ebx\0A\09mov dr2, ebx\0A\09mov dr3, ecx\0A\09mov dr6, edx\0A\09mov dr7, ecx", 
"~{dr0},~{dr1},~{dr2},~{dr3},~{dr6},~{dr7},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void t46() {
+  // CHECK-LABEL: define void @t46
+  __asm add eax, -128[eax]
+  // CHECK: call void asm sideeffect inteldialect "add eax, $$-128[eax]", 
"~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"()
+}
+
 void dot_operator(){
 // CHECK-LABEL: define void @dot_operator
__asm { mov eax, 3[ebx]A.b}


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


r310527 - AMDGPU: Use direct struct returns and arguments

2017-08-09 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Wed Aug  9 14:44:58 2017
New Revision: 310527

URL: http://llvm.org/viewvc/llvm-project?rev=310527=rev
Log:
AMDGPU: Use direct struct returns and arguments

This is an improvement over always using byval for
structs.

This will use registers until ~16 are used, and then
switch back to byval. This needs more work, since I'm
not sure it ever really makes sense to use byval. If
the register limit is exceeded, the arguments still
end up passed on the stack, but with a different ABI.
It also may make sense to base this on number of
registers used for non-struct arguments, rather than
just arguments that appear first in the argument list.

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=310527=310526=310527=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Aug  9 14:44:58 2017
@@ -7378,38 +7378,147 @@ public:
 namespace {
 
 class AMDGPUABIInfo final : public DefaultABIInfo {
+private:
+  static const unsigned MaxNumRegsForArgsRet = 16;
+
+  bool shouldReturnTypeInRegister(QualType Ty,
+  ASTContext ) const;
+  unsigned numRegsForType(QualType Ty) const;
+
+  bool isHomogeneousAggregateBaseType(QualType Ty) const override;
+  bool isHomogeneousAggregateSmallEnough(const Type *Base,
+ uint64_t Members) const override;
+
 public:
-  explicit AMDGPUABIInfo(CodeGen::CodeGenTypes ) : DefaultABIInfo(CGT) {}
+  explicit AMDGPUABIInfo(CodeGen::CodeGenTypes ) :
+DefaultABIInfo(CGT) {}
 
-private:
-  ABIArgInfo classifyArgumentType(QualType Ty) const;
+  ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyKernelArgumentType(QualType Ty) const;
+  ABIArgInfo classifyArgumentType(QualType Ty, unsigned ) const;
 
   void computeInfo(CGFunctionInfo ) const override;
 };
 
+bool AMDGPUABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
+  return true;
+}
+
+bool AMDGPUABIInfo::isHomogeneousAggregateSmallEnough(
+  const Type *Base, uint64_t Members) const {
+  uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
+
+  // Homogeneous Aggregates may occupy at most 16 registers.
+  return Members * NumRegs <= MaxNumRegsForArgsRet;
+}
+
+/// Check whether the type is small enough to consider passing directly in
+/// registers.
+bool AMDGPUABIInfo::shouldReturnTypeInRegister(QualType Ty,
+   ASTContext ) const {
+  return ((Ctx.getTypeSize(Ty) + 31) / 32) <= MaxNumRegsForArgsRet;
+}
+
+/// Estimate number of registers the type will use when passed in registers.
+unsigned AMDGPUABIInfo::numRegsForType(QualType Ty) const {
+  unsigned NumRegs = 0;
+
+  if (const VectorType *VT = Ty->getAs()) {
+// Compute from the number of elements. The reported size is based on the
+// in-memory size, which includes the padding 4th element for 3-vectors.
+QualType EltTy = VT->getElementType();
+unsigned EltSize = getContext().getTypeSize(EltTy);
+
+// 16-bit element vectors should be passed as packed.
+if (EltSize == 16)
+  return (VT->getNumElements() + 1) / 2;
+
+unsigned EltNumRegs = (EltSize + 31) / 32;
+return EltNumRegs * VT->getNumElements();
+  }
+
+  if (const RecordType *RT = Ty->getAs()) {
+const RecordDecl *RD = RT->getDecl();
+assert(!RD->hasFlexibleArrayMember());
+
+for (const FieldDecl *Field : RD->fields()) {
+  QualType FieldTy = Field->getType();
+  NumRegs += numRegsForType(FieldTy);
+}
+
+return NumRegs;
+  }
+
+  return (getContext().getTypeSize(Ty) + 31) / 32;
+}
+
 void AMDGPUABIInfo::computeInfo(CGFunctionInfo ) const {
+  llvm::CallingConv::ID CC = FI.getCallingConvention();
+
   if (!getCXXABI().classifyReturnType(FI))
 FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
 
-  unsigned CC = FI.getCallingConvention();
-  for (auto  : FI.arguments())
-if (CC == llvm::CallingConv::AMDGPU_KERNEL)
-  Arg.info = classifyArgumentType(Arg.type);
-else
-  Arg.info = DefaultABIInfo::classifyArgumentType(Arg.type);
+  unsigned NumRegsLeft = MaxNumRegsForArgsRet;
+  for (auto  : FI.arguments()) {
+if (CC == llvm::CallingConv::AMDGPU_KERNEL) {
+  Arg.info = classifyKernelArgumentType(Arg.type);
+} else {
+  Arg.info = classifyArgumentType(Arg.type, NumRegsLeft);
+}
+  }
 }
 
-/// \brief Classify argument of given type \p Ty.
-ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty) const {
-  llvm::StructType *StrTy = dyn_cast(CGT.ConvertType(Ty));
-  if (!StrTy) {
-return 

[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310525: [demangler] Improve representation of 
substitutions/templates (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D36427?vs=110281=110480#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36427

Files:
  libcxxabi/trunk/src/cxa_demangle.cpp
  libcxxabi/trunk/test/unittest_demangle.pass.cpp

Index: libcxxabi/trunk/src/cxa_demangle.cpp
===
--- libcxxabi/trunk/src/cxa_demangle.cpp
+++ libcxxabi/trunk/src/cxa_demangle.cpp
@@ -1407,117 +1407,6 @@
   }
 };
 
-template 
-class arena
-{
-static const std::size_t alignment = 16;
-alignas(alignment) char buf_[N];
-char* ptr_;
-
-std::size_t 
-align_up(std::size_t n) noexcept
-{return (n + (alignment-1)) & ~(alignment-1);}
-
-bool
-pointer_in_buffer(char* p) noexcept
-{return buf_ <= p && p <= buf_ + N;}
-
-public:
-arena() noexcept : ptr_(buf_) {}
-~arena() {ptr_ = nullptr;}
-arena(const arena&) = delete;
-arena& operator=(const arena&) = delete;
-
-char* allocate(std::size_t n);
-void deallocate(char* p, std::size_t n) noexcept;
-
-static constexpr std::size_t size() {return N;}
-std::size_t used() const {return static_cast(ptr_ - buf_);}
-void reset() {ptr_ = buf_;}
-};
-
-template 
-char*
-arena::allocate(std::size_t n)
-{
-n = align_up(n);
-if (static_cast(buf_ + N - ptr_) >= n)
-{
-char* r = ptr_;
-ptr_ += n;
-return r;
-}
-return static_cast(std::malloc(n));
-}
-
-template 
-void
-arena::deallocate(char* p, std::size_t n) noexcept
-{
-if (pointer_in_buffer(p))
-{
-n = align_up(n);
-if (p + n == ptr_)
-ptr_ = p;
-}
-else
-std::free(p);
-}
-
-template 
-class short_alloc
-{
-arena& a_;
-public:
-typedef T value_type;
-
-public:
-template  struct rebind {typedef short_alloc<_Up, N> other;};
-
-short_alloc(arena& a) noexcept : a_(a) {}
-template 
-short_alloc(const short_alloc& a) noexcept
-: a_(a.a_) {}
-short_alloc(const short_alloc&) = default;
-short_alloc& operator=(const short_alloc&) = delete;
-
-T* allocate(std::size_t n)
-{
-return reinterpret_cast(a_.allocate(n*sizeof(T)));
-}
-void deallocate(T* p, std::size_t n) noexcept
-{
-a_.deallocate(reinterpret_cast(p), n*sizeof(T));
-}
-
-template 
-friend
-bool
-operator==(const short_alloc& x, const short_alloc& y) noexcept;
-
-template  friend class short_alloc;
-};
-
-template 
-inline
-bool
-operator==(const short_alloc& x, const short_alloc& y) noexcept
-{
-return N == M && _ == _;
-}
-
-template 
-inline
-bool
-operator!=(const short_alloc& x, const short_alloc& y) noexcept
-{
-return !(x == y);
-}
-
-const size_t bs = 4 * 1024;
-template  using Alloc = short_alloc;
-template  using Vector = std::vector;
-
 class BumpPointerAllocator {
   struct BlockMeta {
 BlockMeta* Next;
@@ -1568,13 +1457,209 @@
   }
 };
 
+template 
+class PODSmallVector {
+  static_assert(std::is_pod::value,
+"T is required to be a plain old data type");
+
+  T* First;
+  T* Last;
+  T* Cap;
+  T Inline[N];
+
+  bool isInline() const { return First == Inline; }
+
+  void clearInline() {
+First = Inline;
+Last = Inline;
+Cap = Inline + N;
+  }
+
+  void reserve(size_t NewCap) {
+size_t S = size();
+if (isInline()) {
+  auto* Tmp = static_cast(std::malloc(NewCap * sizeof(T)));
+  std::copy(First, Last, Tmp);
+  First = Tmp;
+} else
+  First = static_cast(std::realloc(First, NewCap * sizeof(T)));
+Last = First + S;
+Cap = First + NewCap;
+  }
+
+public:
+  PODSmallVector() : First(Inline), Last(First), Cap(Inline + N) {}
+
+  PODSmallVector(const PODSmallVector&) = delete;
+  PODSmallVector& operator=(const PODSmallVector&) = delete;
+
+  PODSmallVector(PODSmallVector&& Other) : PODSmallVector() {
+if (Other.isInline()) {
+  std::copy(Other.begin(), Other.end(), First);
+  Last = First + Other.size();
+  Other.clear();
+  return;
+}
+
+First = Other.First;
+Last = Other.Last;
+Cap = Other.Cap;
+Other.clearInline();
+  }
+
+  PODSmallVector& operator=(PODSmallVector&& Other) {
+if (Other.isInline()) {
+  if (!isInline()) {
+std::free(First);
+clearInline();
+  }
+  std::copy(Other.begin(), Other.end(), First);
+  Last = First + Other.size();
+  Other.clear();
+  return *this;
+}
+
+if (isInline()) {
+  First = Other.First;
+  Last = Other.Last;
+  Cap = Other.Cap;
+  Other.clearInline();
+  return *this;
+}
+
+std::swap(First, Other.First);
+std::swap(Last, Other.Last);
+

[libcxxabi] r310525 - [demangler] Improve representation of substitutions/templates

2017-08-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Aug  9 14:30:57 2017
New Revision: 310525

URL: http://llvm.org/viewvc/llvm-project?rev=310525=rev
Log:
[demangler] Improve representation of substitutions/templates

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

Added:
libcxxabi/trunk/test/unittest_demangle.pass.cpp
Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=310525=310524=310525=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Aug  9 14:30:57 2017
@@ -1407,117 +1407,6 @@ public:
   }
 };
 
-template 
-class arena
-{
-static const std::size_t alignment = 16;
-alignas(alignment) char buf_[N];
-char* ptr_;
-
-std::size_t 
-align_up(std::size_t n) noexcept
-{return (n + (alignment-1)) & ~(alignment-1);}
-
-bool
-pointer_in_buffer(char* p) noexcept
-{return buf_ <= p && p <= buf_ + N;}
-
-public:
-arena() noexcept : ptr_(buf_) {}
-~arena() {ptr_ = nullptr;}
-arena(const arena&) = delete;
-arena& operator=(const arena&) = delete;
-
-char* allocate(std::size_t n);
-void deallocate(char* p, std::size_t n) noexcept;
-
-static constexpr std::size_t size() {return N;}
-std::size_t used() const {return static_cast(ptr_ - buf_);}
-void reset() {ptr_ = buf_;}
-};
-
-template 
-char*
-arena::allocate(std::size_t n)
-{
-n = align_up(n);
-if (static_cast(buf_ + N - ptr_) >= n)
-{
-char* r = ptr_;
-ptr_ += n;
-return r;
-}
-return static_cast(std::malloc(n));
-}
-
-template 
-void
-arena::deallocate(char* p, std::size_t n) noexcept
-{
-if (pointer_in_buffer(p))
-{
-n = align_up(n);
-if (p + n == ptr_)
-ptr_ = p;
-}
-else
-std::free(p);
-}
-
-template 
-class short_alloc
-{
-arena& a_;
-public:
-typedef T value_type;
-
-public:
-template  struct rebind {typedef short_alloc<_Up, N> other;};
-
-short_alloc(arena& a) noexcept : a_(a) {}
-template 
-short_alloc(const short_alloc& a) noexcept
-: a_(a.a_) {}
-short_alloc(const short_alloc&) = default;
-short_alloc& operator=(const short_alloc&) = delete;
-
-T* allocate(std::size_t n)
-{
-return reinterpret_cast(a_.allocate(n*sizeof(T)));
-}
-void deallocate(T* p, std::size_t n) noexcept
-{
-a_.deallocate(reinterpret_cast(p), n*sizeof(T));
-}
-
-template 
-friend
-bool
-operator==(const short_alloc& x, const short_alloc& y) 
noexcept;
-
-template  friend class short_alloc;
-};
-
-template 
-inline
-bool
-operator==(const short_alloc& x, const short_alloc& y) noexcept
-{
-return N == M && _ == _;
-}
-
-template 
-inline
-bool
-operator!=(const short_alloc& x, const short_alloc& y) noexcept
-{
-return !(x == y);
-}
-
-const size_t bs = 4 * 1024;
-template  using Alloc = short_alloc;
-template  using Vector = std::vector;
-
 class BumpPointerAllocator {
   struct BlockMeta {
 BlockMeta* Next;
@@ -1568,13 +1457,209 @@ public:
   }
 };
 
+template 
+class PODSmallVector {
+  static_assert(std::is_pod::value,
+"T is required to be a plain old data type");
+
+  T* First;
+  T* Last;
+  T* Cap;
+  T Inline[N];
+
+  bool isInline() const { return First == Inline; }
+
+  void clearInline() {
+First = Inline;
+Last = Inline;
+Cap = Inline + N;
+  }
+
+  void reserve(size_t NewCap) {
+size_t S = size();
+if (isInline()) {
+  auto* Tmp = static_cast(std::malloc(NewCap * sizeof(T)));
+  std::copy(First, Last, Tmp);
+  First = Tmp;
+} else
+  First = static_cast(std::realloc(First, NewCap * sizeof(T)));
+Last = First + S;
+Cap = First + NewCap;
+  }
+
+public:
+  PODSmallVector() : First(Inline), Last(First), Cap(Inline + N) {}
+
+  PODSmallVector(const PODSmallVector&) = delete;
+  PODSmallVector& operator=(const PODSmallVector&) = delete;
+
+  PODSmallVector(PODSmallVector&& Other) : PODSmallVector() {
+if (Other.isInline()) {
+  std::copy(Other.begin(), Other.end(), First);
+  Last = First + Other.size();
+  Other.clear();
+  return;
+}
+
+First = Other.First;
+Last = Other.Last;
+Cap = Other.Cap;
+Other.clearInline();
+  }
+
+  PODSmallVector& operator=(PODSmallVector&& Other) {
+if (Other.isInline()) {
+  if (!isInline()) {
+std::free(First);
+clearInline();
+  }
+  std::copy(Other.begin(), Other.end(), First);
+  Last = First + Other.size();
+  Other.clear();
+  return *this;
+}
+
+if (isInline()) {
+  First = Other.First;
+  Last = Other.Last;
+  Cap = Other.Cap;
+  Other.clearInline();
+   

Re: r310436 - [AST] Move visibility computations into a class; NFC

2017-08-09 Thread George Burgess IV via cfe-commits
Sorry about that!

Attempted fix is r310523. I'll keep an eye on the bot to make sure it
turns green.

On Wed, Aug 9, 2017 at 1:23 PM, Juergen Ributzka  wrote:
> This seems to cause UBSAN issues:
>
> runtime error: load of value 4294967295, which is not a valid value for type
> 'clang::LVComputationKind'
>
> See ASAN+UBSAN bot on Green Dragon:
> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/4065/console
>
> On Tue, Aug 8, 2017 at 9:02 PM, George Burgess IV via cfe-commits
>  wrote:
>>
>> Author: gbiv
>> Date: Tue Aug  8 21:02:49 2017
>> New Revision: 310436
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310436=rev
>> Log:
>> [AST] Move visibility computations into a class; NFC
>>
>> This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal
>> is to cache decl visibility/linkage for the duration of each
>> visibility+linkage query.
>>
>> The simplest way I can see to do this is to put the visibility
>> calculation code that needs to (transitively) access this cache into a
>> class, which is what this patch does. Actual caching will come in patch
>> 2. (Another way would be to keep the cache in ASTContext + manually
>> invalidate it or something, but that felt way too subtle to me.)
>>
>> Caching visibility results across multiple queries seems a bit tricky,
>> since the user can add visibility attributes ~whenever they want, and
>> these attributes can apparently have far-reaching effects (e.g. class
>> visibility extends to its members, ...). Because a cache that's dropped
>> at the end of each top-level query seems to work nearly as well and
>> doesn't require any eviction logic, I opted for that design.
>>
>> Added:
>> cfe/trunk/lib/AST/Linkage.h
>> Modified:
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/Type.cpp
>>
>> Modified: cfe/trunk/lib/AST/Decl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=310436=310435=310436=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/Decl.cpp (original)
>> +++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 21:02:49 2017
>> @@ -12,6 +12,7 @@
>>
>> //===--===//
>>
>>  #include "clang/AST/Decl.h"
>> +#include "Linkage.h"
>>  #include "clang/AST/ASTContext.h"
>>  #include "clang/AST/ASTLambda.h"
>>  #include "clang/AST/ASTMutationListener.h"
>> @@ -99,38 +100,6 @@ TranslationUnitDecl::TranslationUnitDecl
>>  // and 'matcher' is a type only matters when looking for attributes
>>  // and settings from the immediate context.
>>
>> -const static unsigned IgnoreExplicitVisibilityBit = 2;
>> -const static unsigned IgnoreAllVisibilityBit = 4;
>> -
>> -/// Kinds of LV computation.  The linkage side of the computation is
>> -/// always the same, but different things can change how visibility is
>> -/// computed.
>> -enum LVComputationKind {
>> -  /// Do an LV computation for, ultimately, a type.
>> -  /// Visibility may be restricted by type visibility settings and
>> -  /// the visibility of template arguments.
>> -  LVForType = NamedDecl::VisibilityForType,
>> -
>> -  /// Do an LV computation for, ultimately, a non-type declaration.
>> -  /// Visibility may be restricted by value visibility settings and
>> -  /// the visibility of template arguments.
>> -  LVForValue = NamedDecl::VisibilityForValue,
>> -
>> -  /// Do an LV computation for, ultimately, a type that already has
>> -  /// some sort of explicit visibility.  Visibility may only be
>> -  /// restricted by the visibility of template arguments.
>> -  LVForExplicitType = (LVForType | IgnoreExplicitVisibilityBit),
>> -
>> -  /// Do an LV computation for, ultimately, a non-type declaration
>> -  /// that already has some sort of explicit visibility.  Visibility
>> -  /// may only be restricted by the visibility of template arguments.
>> -  LVForExplicitValue = (LVForValue | IgnoreExplicitVisibilityBit),
>> -
>> -  /// Do an LV computation when we only care about the linkage.
>> -  LVForLinkageOnly =
>> -  LVForValue | IgnoreExplicitVisibilityBit | IgnoreAllVisibilityBit
>> -};
>> -
>>  /// Does this computation kind permit us to consider additional
>>  /// visibility settings from attributes and the like?
>>  static bool hasExplicitVisibilityAlready(LVComputationKind computation) {
>> @@ -219,8 +188,8 @@ static Optional getVisibilit
>>return None;
>>  }
>>
>> -static LinkageInfo
>> -getLVForType(const Type , LVComputationKind computation) {
>> +LinkageInfo LinkageComputer::getLVForType(const Type ,
>> +  LVComputationKind computation)
>> {
>>if (computation == LVForLinkageOnly)
>>  return LinkageInfo(T.getLinkage(), DefaultVisibility, true);
>>return T.getLinkageAndVisibility();
>> @@ -229,9 +198,8 @@ getLVForType(const Type , LVComputatio
>>  /// \brief Get the most restrictive linkage for the types in the 

r310523 - Use unsigned instead of an enum for map keys

2017-08-09 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Aug  9 14:20:41 2017
New Revision: 310523

URL: http://llvm.org/viewvc/llvm-project?rev=310523=rev
Log:
Use unsigned instead of an enum for map keys

ubsan's enum sanitizer doesn't like the latter, and we had to have
out-of-bounds values for DenseMapInfo's tombstone/empty keys.

Modified:
cfe/trunk/lib/AST/Linkage.h

Modified: cfe/trunk/lib/AST/Linkage.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Linkage.h?rev=310523=310522=310523=diff
==
--- cfe/trunk/lib/AST/Linkage.h (original)
+++ cfe/trunk/lib/AST/Linkage.h Wed Aug  9 14:20:41 2017
@@ -55,27 +55,7 @@ enum LVComputationKind {
   LVForLinkageOnly =
   LVForValue | IgnoreExplicitVisibilityBit | IgnoreAllVisibilityBit
 };
-} // namespace clang
 
-namespace llvm {
-template <> struct DenseMapInfo {
-  static inline clang::LVComputationKind getEmptyKey() {
-return static_cast(-1);
-  }
-  static inline clang::LVComputationKind getTombstoneKey() {
-return static_cast(-2);
-  }
-  static unsigned getHashValue(const clang::LVComputationKind ) {
-return Val;
-  }
-  static bool isEqual(const clang::LVComputationKind ,
-  const clang::LVComputationKind ) {
-return LHS == RHS;
-  }
-};
-} // namespace llvm
-
-namespace clang {
 class LinkageComputer {
   // We have a cache for repeated linkage/visibility computations. This saves 
us
   // from exponential behavior in heavily templated code, such as:
@@ -85,18 +65,27 @@ class LinkageComputer {
   // using B = Foo;
   // using C = Foo;
   // using D = Foo;
-  using QueryType = std::pair;
+  //
+  // Note that the unsigned is actually a LVComputationKind; ubsan's enum
+  // sanitizer doesn't like tombstone/empty markers outside of
+  // LVComputationKind's range.
+  using QueryType = std::pair;
   llvm::SmallDenseMap CachedLinkageInfo;
+
+  static QueryType makeCacheKey(const NamedDecl *ND, LVComputationKind Kind) {
+return std::make_pair(ND, static_cast(Kind));
+  }
+
   llvm::Optional lookup(const NamedDecl *ND,
  LVComputationKind Kind) const {
-auto Iter = CachedLinkageInfo.find(std::make_pair(ND, Kind));
+auto Iter = CachedLinkageInfo.find(makeCacheKey(ND, Kind));
 if (Iter == CachedLinkageInfo.end())
   return None;
 return Iter->second;
   }
 
   void cache(const NamedDecl *ND, LVComputationKind Kind, LinkageInfo Info) {
-CachedLinkageInfo[std::make_pair(ND, Kind)] = Info;
+CachedLinkageInfo[makeCacheKey(ND, Kind)] = Info;
   }
 
   LinkageInfo getLVForTemplateArgumentList(ArrayRef Args,


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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-09 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
atanasyan added a project: clang.
Herald added a subscriber: arichardson.

While we do not support `-mshared / -mno-shared` properly, show warning and 
ignore `-mlong-calls` option in case of implicitly or explicitly provided 
`-mabicalls` option.

The patch depends on https://reviews.llvm.org/D36550.


Repository:
  rL LLVM

https://reviews.llvm.org/D36551

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/mips-features.c
  test/Driver/mips-longcalls-warning.c


Index: test/Driver/mips-longcalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-longcalls-warning.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mlong-calls' option as it cannot be used with 
the implicit usage of -mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | 
FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mlong-calls' option as it cannot be used with 
-mabicalls
Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -336,12 +336,16 @@
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx"
 
 // -mlong-call
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mlong-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-ON %s
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mno-long-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mno-long-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-OFF %s
 // RUN: %clang -target mips-img-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
+// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -252,6 +252,16 @@
   else
 Features.push_back("-noabicalls");
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
+   options::OPT_mno_long_calls)) {
+if (A->getOption().matches(options::OPT_mno_long_calls))
+  Features.push_back("-long-calls");
+else if (NeedNoAbiCalls)
+  Features.push_back("+long-calls");
+else
+  D.Diag(diag::warn_drv_unsupported_longcalls) << (ABICallsArg ? 0 : 1);
+  }
+
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
 // FIXME: Note, this is a hack. We need to pass the selected float
@@ -316,8 +326,6 @@
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
-  AddTargetFeature(Args, Features, options::OPT_mlong_calls,
-   options::OPT_mno_long_calls, "long-calls");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, 
"mt");
 }
 
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_longcalls : Warning<
+  "ignoring '-mlong-calls' option as it cannot be used with "
+  "%select{|the implicit usage of }0-mabicalls">,
+  InGroup;
 def warn_drv_unsupported_abicalls : Warning<
   "ignoring '-mabicalls' option as it cannot be used with "
   "non position-independent code and N64 ABI">,


Index: test/Driver/mips-longcalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-longcalls-warning.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck -check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mlong-calls' option as it cannot be used with the implicit usage of -mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mlong-calls' option as it cannot be used with -mabicalls
Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c

[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

2017-08-09 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
atanasyan added a project: clang.
Herald added a subscriber: arichardson.

The `-mabicalls` option does not have a sense in case of non position 
independent code on N64 ABI. After this change driver starts to show a warning 
that `-mabicalls` is ignored in that case.


Repository:
  rL LLVM

https://reviews.llvm.org/D36550

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/mips-abicalls-warning.c
  test/Driver/mips-features.c


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -10,6 +10,11 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 
-Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
Index: test/Driver/mips-abicalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-abicalls-warning.c
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | 
FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non 
position-independent code and N64 ABI
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -227,11 +227,30 @@
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool DefNoAbiCalls = IsN64 && NonPIC;
+  bool NeedNoAbiCalls = false;
+
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  if (!ABICallsArg)
+NeedNoAbiCalls = DefNoAbiCalls;
+  else {
+if (ABICallsArg->getOption().matches(options::OPT_mno_abicalls))
+  NeedNoAbiCalls = true;
+else {
+  if (DefNoAbiCalls) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+NeedNoAbiCalls = true;
+  } else {
+NeedNoAbiCalls = false;
+  }
+}
+  }
+
+  if (NeedNoAbiCalls)
 Features.push_back("+noabicalls");
   else
-AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
- options::OPT_mabicalls, "noabicalls");
+Features.push_back("-noabicalls");
 
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and N64 ABI">,
+  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -10,6 +10,11 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt -Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
Index: test/Driver/mips-abicalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-abicalls-warning.c
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non position-independent code and N64 ABI
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -227,11 +227,30 @@
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool 

[PATCH] D36526: [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310521: [Sema] Assign new flag -Wenum-compare-switch to 
switch-related parts of -Wenum… (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D36526?vs=110407=110473#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36526

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/test/Sema/switch.c
  cfe/trunk/test/SemaCXX/warn-enum-compare.cpp


Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -762,7 +762,7 @@
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
 return;
 
-  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
   << CondType << CaseType << Cond->getSourceRange()
   << Case->getSourceRange();
 }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5918,7 +5918,11 @@
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,
-  InGroup>;
+  InGroup;
+def warn_comparison_of_mixed_enum_types_switch : Warning<
+  "comparison of two values with different enumeration types in switch 
statement"
+  "%diff{ ($ and $)|}0,1">,
+  InGroup;
 def warn_null_in_arithmetic_operation : Warning<
   "use of NULL in arithmetic operation">,
   InGroup;
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -454,6 +454,8 @@
 def SwitchBool : DiagGroup<"switch-bool">;
 def SwitchEnum : DiagGroup<"switch-enum">;
 def Switch : DiagGroup<"switch">;
+def EnumCompareSwitch : DiagGroup<"enum-compare-switch">;
+def EnumCompare   : DiagGroup<"enum-compare", [EnumCompareSwitch]>;
 def ImplicitFallthroughPerFunction :
   DiagGroup<"implicit-fallthrough-per-function">;
 def ImplicitFallthrough  : DiagGroup<"implicit-fallthrough",
Index: cfe/trunk/test/Sema/switch.c
===
--- cfe/trunk/test/Sema/switch.c
+++ cfe/trunk/test/Sema/switch.c
@@ -372,7 +372,7 @@
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
-  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types in switch statement ('enum ExtendedEnum1' and 'const enum 
ExtendedEnum1_unrelated')}}
   }
 }
 
Index: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
===
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
@@ -212,19 +212,19 @@
   switch (a) {
 case name1::F1: break;
 case name1::F3: break;
-case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('name1::Foo' and 
'name2::Baz')}}
   }
 
   switch (x) {
 case FooB: break;
 case FooC: break;
-case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types ('Foo' and 'Bar')}}
+case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('Foo' and 'Bar')}}
   }
 
   switch(getBar()) {
 case BarE: break;
 case BarF: break;
-case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
+case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('Bar' and 'Foo')}}
   }
 
   switch(x) {


Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -762,7 +762,7 @@
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
 return;
 
-  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
   << CondType << CaseType << 

r310521 - [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Aug  9 13:56:43 2017
New Revision: 310521

URL: http://llvm.org/viewvc/llvm-project?rev=310521=rev
Log:
[Sema] Assign new flag -Wenum-compare-switch to switch-related parts of 
-Wenum-compare

Patch by: Reka Nikolett Kovacs

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/switch.c
cfe/trunk/test/SemaCXX/warn-enum-compare.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=310521=310520=310521=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Aug  9 13:56:43 2017
@@ -454,6 +454,8 @@ def CoveredSwitchDefault : DiagGroup<"co
 def SwitchBool : DiagGroup<"switch-bool">;
 def SwitchEnum : DiagGroup<"switch-enum">;
 def Switch : DiagGroup<"switch">;
+def EnumCompareSwitch : DiagGroup<"enum-compare-switch">;
+def EnumCompare   : DiagGroup<"enum-compare", [EnumCompareSwitch]>;
 def ImplicitFallthroughPerFunction :
   DiagGroup<"implicit-fallthrough-per-function">;
 def ImplicitFallthrough  : DiagGroup<"implicit-fallthrough",

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310521=310520=310521=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug  9 13:56:43 
2017
@@ -5918,7 +5918,11 @@ def warn_runsigned_always_true_compariso
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,
-  InGroup>;
+  InGroup;
+def warn_comparison_of_mixed_enum_types_switch : Warning<
+  "comparison of two values with different enumeration types in switch 
statement"
+  "%diff{ ($ and $)|}0,1">,
+  InGroup;
 def warn_null_in_arithmetic_operation : Warning<
   "use of NULL in arithmetic operation">,
   InGroup;

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=310521=310520=310521=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 13:56:43 2017
@@ -762,7 +762,7 @@ static void checkEnumTypesInSwitchStmt(S
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
 return;
 
-  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
   << CondType << CaseType << Cond->getSourceRange()
   << Case->getSourceRange();
 }

Modified: cfe/trunk/test/Sema/switch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch.c?rev=310521=310520=310521=diff
==
--- cfe/trunk/test/Sema/switch.c (original)
+++ cfe/trunk/test/Sema/switch.c Wed Aug  9 13:56:43 2017
@@ -372,7 +372,7 @@ void switch_on_ExtendedEnum1(enum Extend
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
-  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types in switch statement ('enum ExtendedEnum1' and 'const enum 
ExtendedEnum1_unrelated')}}
   }
 }
 

Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-enum-compare.cpp?rev=310521=310520=310521=diff
==
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp Wed Aug  9 13:56:43 2017
@@ -212,19 +212,19 @@ void test () {
   switch (a) {
 case name1::F1: break;
 case name1::F3: break;
-case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('name1::Foo' and 
'name2::Baz')}}
   }
 
   switch (x) {
 case FooB: break;
 case FooC: break;
-case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types ('Foo' and 'Bar')}}
+

[PATCH] D36526: [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.

Thanks!


https://reviews.llvm.org/D36526



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

In https://reviews.llvm.org/D29660#837298, @alekseyshl wrote:

> Even after r310505, openmp-offload.c continues to haunt our bots, for example 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2012.
>  Can you please fix this test?


Preparing a fix now.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-09 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

Even after r310505, openmp-offload.c continues to haunt our bots, for example 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2012. 
Can you please fix this test?


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: r310436 - [AST] Move visibility computations into a class; NFC

2017-08-09 Thread Juergen Ributzka via cfe-commits
This seems to cause UBSAN issues:

runtime error: load of value 4294967295, which is not a valid value for
type 'clang::LVComputationKind'

See ASAN+UBSAN bot on Green Dragon:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/4065/console

On Tue, Aug 8, 2017 at 9:02 PM, George Burgess IV via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Tue Aug  8 21:02:49 2017
> New Revision: 310436
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310436=rev
> Log:
> [AST] Move visibility computations into a class; NFC
>
> This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal
> is to cache decl visibility/linkage for the duration of each
> visibility+linkage query.
>
> The simplest way I can see to do this is to put the visibility
> calculation code that needs to (transitively) access this cache into a
> class, which is what this patch does. Actual caching will come in patch
> 2. (Another way would be to keep the cache in ASTContext + manually
> invalidate it or something, but that felt way too subtle to me.)
>
> Caching visibility results across multiple queries seems a bit tricky,
> since the user can add visibility attributes ~whenever they want, and
> these attributes can apparently have far-reaching effects (e.g. class
> visibility extends to its members, ...). Because a cache that's dropped
> at the end of each top-level query seems to work nearly as well and
> doesn't require any eviction logic, I opted for that design.
>
> Added:
> cfe/trunk/lib/AST/Linkage.h
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/Type.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> Decl.cpp?rev=310436=310435=310436=diff
> 
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 21:02:49 2017
> @@ -12,6 +12,7 @@
>  //===---
> ---===//
>
>  #include "clang/AST/Decl.h"
> +#include "Linkage.h"
>  #include "clang/AST/ASTContext.h"
>  #include "clang/AST/ASTLambda.h"
>  #include "clang/AST/ASTMutationListener.h"
> @@ -99,38 +100,6 @@ TranslationUnitDecl::TranslationUnitDecl
>  // and 'matcher' is a type only matters when looking for attributes
>  // and settings from the immediate context.
>
> -const static unsigned IgnoreExplicitVisibilityBit = 2;
> -const static unsigned IgnoreAllVisibilityBit = 4;
> -
> -/// Kinds of LV computation.  The linkage side of the computation is
> -/// always the same, but different things can change how visibility is
> -/// computed.
> -enum LVComputationKind {
> -  /// Do an LV computation for, ultimately, a type.
> -  /// Visibility may be restricted by type visibility settings and
> -  /// the visibility of template arguments.
> -  LVForType = NamedDecl::VisibilityForType,
> -
> -  /// Do an LV computation for, ultimately, a non-type declaration.
> -  /// Visibility may be restricted by value visibility settings and
> -  /// the visibility of template arguments.
> -  LVForValue = NamedDecl::VisibilityForValue,
> -
> -  /// Do an LV computation for, ultimately, a type that already has
> -  /// some sort of explicit visibility.  Visibility may only be
> -  /// restricted by the visibility of template arguments.
> -  LVForExplicitType = (LVForType | IgnoreExplicitVisibilityBit),
> -
> -  /// Do an LV computation for, ultimately, a non-type declaration
> -  /// that already has some sort of explicit visibility.  Visibility
> -  /// may only be restricted by the visibility of template arguments.
> -  LVForExplicitValue = (LVForValue | IgnoreExplicitVisibilityBit),
> -
> -  /// Do an LV computation when we only care about the linkage.
> -  LVForLinkageOnly =
> -  LVForValue | IgnoreExplicitVisibilityBit | IgnoreAllVisibilityBit
> -};
> -
>  /// Does this computation kind permit us to consider additional
>  /// visibility settings from attributes and the like?
>  static bool hasExplicitVisibilityAlready(LVComputationKind computation) {
> @@ -219,8 +188,8 @@ static Optional getVisibilit
>return None;
>  }
>
> -static LinkageInfo
> -getLVForType(const Type , LVComputationKind computation) {
> +LinkageInfo LinkageComputer::getLVForType(const Type ,
> +  LVComputationKind computation) {
>if (computation == LVForLinkageOnly)
>  return LinkageInfo(T.getLinkage(), DefaultVisibility, true);
>return T.getLinkageAndVisibility();
> @@ -229,9 +198,8 @@ getLVForType(const Type , LVComputatio
>  /// \brief Get the most restrictive linkage for the types in the given
>  /// template parameter list.  For visibility purposes, template
>  /// parameters are part of the signature of a template.
> -static LinkageInfo
> -getLVForTemplateParameterList(const TemplateParameterList *Params,
> -  LVComputationKind computation) {
> 

[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

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

In https://reviews.llvm.org/D34158#837130, @joerg wrote:

> In https://reviews.llvm.org/D34158#836026, @jyknight wrote:
>
> > In https://reviews.llvm.org/D34158#827178, @joerg wrote:
> >
> > > (2) It adds magic behavior that can make debugging more difficult. 
> > > Partially preprocessed sources for example could be compiled with plain 
> > > -c before, now they need a different command line.
> >
> >
> > If this is a problem, making it be Linux-only does _nothing_ to solve it. 
> > But I don't actually see how this is a substantively new problem? Compiling 
> > with plain -c before
> >  would get #defines for those predefined macros that the compiler sets, 
> > even though you may not have wanted those. Is this fundamentally different?
>
>
> It makes it a linux-only problem. As such, it is something *I* only care 
> about secondary. A typical use case I care about a lot is pulling the crash 
> report sources from my (NetBSD) build machine,
>  extracting the original command line to rerun the normal compilation with 
> -save-temps. I don't necessarily have the (same) system headers on the 
> machine I use for debugging and that's exactly
>  the kind of use case this change breaks. All other predefined macros are 
> driven by the target triple and remain stable.


Don't you use preprocessed source files from a crash?


https://reviews.llvm.org/D34158



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-09 Thread DIVYA SHANMUGHAN via Phabricator via cfe-commits
DIVYA added a comment.

Link to algorithm.bench.cpp benchmark 
https://github.com/hiraditya/std-benchmark/blob/master/cxx/algorithm.bench.cpp




Comment at: include/algorithm:4208
+
+  // Threshold(or depth limit) for introsort is taken to be 2*log2(size)
+  typedef typename iterator_traits<_RandomAccessIterator>::difference_type 
difference_type;

bcraig wrote:
> This comment says basically the same thing as the code.  The comment would be 
> more useful if it said why 2*log2(size) is used.
We tested the code with depth limit from log2(size) to 4*log2(size).It was 
giving good performance around 2*log2(size).So the depth limit was fixed a this 
value.


https://reviews.llvm.org/D36423



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


[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310516: Make -std=c++17 an alias of -std=c++1z (authored by 
hans).

Changed prior to commit:
  https://reviews.llvm.org/D36532?vs=110430=110462#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36532

Files:
  cfe/trunk/include/clang/Frontend/LangStandards.def
  cfe/trunk/test/Driver/unknown-std.cpp
  cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp


Index: cfe/trunk/include/clang/Frontend/LangStandards.def
===
--- cfe/trunk/include/clang/Frontend/LangStandards.def
+++ cfe/trunk/include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017 with amendments",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with amendments and GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",
Index: cfe/trunk/test/Driver/unknown-std.cpp
===
--- cfe/trunk/test/Driver/unknown-std.cpp
+++ cfe/trunk/test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU 
extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with 
GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with 
GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
Index: cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
===
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;


Index: cfe/trunk/include/clang/Frontend/LangStandards.def
===
--- cfe/trunk/include/clang/Frontend/LangStandards.def
+++ cfe/trunk/include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017 with amendments",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z |
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with amendments and GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z |
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",
Index: cfe/trunk/test/Driver/unknown-std.cpp
===
--- cfe/trunk/test/Driver/unknown-std.cpp
+++ cfe/trunk/test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU 

r310516 - Make -std=c++17 an alias of -std=c++1z

2017-08-09 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Aug  9 13:12:53 2017
New Revision: 310516

URL: http://llvm.org/viewvc/llvm-project?rev=310516=rev
Log:
Make -std=c++17 an alias of -std=c++1z

As suggested on PR33912.

Trying to keep this small to make it easy to merge to the 5.0 branch. We
can do a follow-up with more thorough renaming (diagnostic text,
options, ids, etc.) later.

(For C++14 this was done in r215982, and I think a smaller patch for the
3.5 branch:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140818/113013.html)

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

Modified:
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/test/Driver/unknown-std.cpp
cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=310516=310515=310516=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Wed Aug  9 13:12:53 2017
@@ -109,15 +109,17 @@ LANGSTANDARD(gnucxx14, "gnu++14",
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017 with amendments",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with amendments and GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",

Modified: cfe/trunk/test/Driver/unknown-std.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-std.cpp?rev=310516=310515=310516=diff
==
--- cfe/trunk/test/Driver/unknown-std.cpp (original)
+++ cfe/trunk/test/Driver/unknown-std.cpp Wed Aug  9 13:12:53 2017
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU 
extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with 
GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with 
GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard

Modified: cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp?rev=310516=310515=310516=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp Wed Aug  9 13:12:53 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;


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


[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: include/clang/Frontend/LangStandards.def:113
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|

rsmith wrote:
> Missing "with amendments" compared to the other languages. We already 
> implement some DRs against c++17.
Thanks! I wasn't sure about that part.


https://reviews.llvm.org/D36532



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


[PATCH] D36526: [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36526



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-09 Thread Vassil Vassilev via cfe-commits

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.
Not helpful indeed :) Do you have access to the machine and would you be 
willing to build in debug mode and send us some stack traces. I do not 
have any arm machines :(


On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev  wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

   * Previously, Clang ignored the move constructor when making this
 determination. It now takes the move constructor into account, per
 https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
 seem recent, but the ABI change was agreed on the Itanium C++ ABI
 list a long time ago).

   * Previously, Clang's behavior when the copy constructor was deleted
 was unstable -- depending on whether the lazy declaration of the
 copy constructor had been triggered, you might get different
behavior.
 We now eagerly declare the copy constructor whenever its deletedness
 is unclear, and ignore deleted copy/move constructors when looking
for
 a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

   * If the copy constructor would be implicitly deleted (but has not
been
 lazily declared yet), for instance because the class has an rvalue
 reference member, we would pass it directly. We now pass such a
class
 indirectly, matching MSVC.

Modified:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401=310400=310401=diff


==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if a defaulted corresponding
special
   /// member can't be fully analyzed without performing overload
resolution.
   /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
   unsigned NeedOverloadResolutionForMoveConstructor : 1;
   unsigned NeedOverloadResolutionForMoveAssignment : 1;
   unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if an implicit defaulted
corresponding
   /// special member would be defined as deleted.
   /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
   unsigned DefaultedMoveConstructorIsDeleted : 1;
   unsigned DefaultedMoveAssignmentIsDeleted : 1;
   unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
   /// constructor.
   unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-09 Thread Diana Picus via cfe-commits
Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus  wrote:
> Hi,
>
> See attached. FWIW, when I ran this on a very similar machine, I got
> 194 failures, all of which went away after reverting. So there might
> be something fishy going on.
>
> Regards,
> Diana
>
> On 9 August 2017 at 15:02, Vassil Vassilev  wrote:
>> Hi Diana,
>>
>>   It seems the service is down. Could you send us the details of the
>> failures (incl stack traces if any)
>>
>> Many thanks,
>> Vassil
>>
>> On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
>>>
>>> Hi Richard,
>>>
>>> I'm sorry but I've reverted this in r310464 because it was breaking
>>> some ASAN tests on this bot:
>>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
>>>
>>> Please let me know if I can help debug this.
>>>
>>> Cheers,
>>> Diana
>>>
>>> On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>>>  wrote:

 I forgot to say:

 Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
 Schmidt, which was based on a patch by Reid Kleckner.

 On 8 August 2017 at 12:12, Richard Smith via cfe-commits
  wrote:
>
> Author: rsmith
> Date: Tue Aug  8 12:12:28 2017
> New Revision: 310401
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310401=rev
> Log:
> PR19668, PR23034: Fix handling of move constructors and deleted copy
> constructors when deciding whether classes should be passed indirectly.
>
> This fixes ABI differences between Clang and GCC:
>
>   * Previously, Clang ignored the move constructor when making this
> determination. It now takes the move constructor into account, per
> https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
> seem recent, but the ABI change was agreed on the Itanium C++ ABI
> list a long time ago).
>
>   * Previously, Clang's behavior when the copy constructor was deleted
> was unstable -- depending on whether the lazy declaration of the
> copy constructor had been triggered, you might get different
> behavior.
> We now eagerly declare the copy constructor whenever its deletedness
> is unclear, and ignore deleted copy/move constructors when looking
> for
> a trivial such constructor.
>
> This also fixes an ABI difference between Clang and MSVC:
>
>   * If the copy constructor would be implicitly deleted (but has not
> been
> lazily declared yet), for instance because the class has an rvalue
> reference member, we would pass it directly. We now pass such a
> class
> indirectly, matching MSVC.
>
> Modified:
>  cfe/trunk/include/clang/AST/DeclCXX.h
>  cfe/trunk/lib/AST/ASTImporter.cpp
>  cfe/trunk/lib/AST/DeclCXX.cpp
>  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
>  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>  cfe/trunk/lib/Serialization/ASTWriter.cpp
>  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
>  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL:
>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401=310400=310401=diff
>
>
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
> @@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
>   /// \brief These flags are \c true if a defaulted corresponding
> special
>   /// member can't be fully analyzed without performing overload
> resolution.
>   /// @{
> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>   unsigned NeedOverloadResolutionForMoveConstructor : 1;
>   unsigned NeedOverloadResolutionForMoveAssignment : 1;
>   unsigned NeedOverloadResolutionForDestructor : 1;
> @@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
>   /// \brief These flags are \c true if an implicit defaulted
> corresponding
>   /// special member would be defined as deleted.
>   /// @{
> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>   unsigned 

[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Frontend/LangStandards.def:113
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|

Missing "with amendments" compared to the other languages. We already implement 
some DRs against c++17.


https://reviews.llvm.org/D36532



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


r310511 - [OPENMP] Emit non-debug version of outlined functions with original

2017-08-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug  9 12:38:53 2017
New Revision: 310511

URL: http://llvm.org/viewvc/llvm-project?rev=310511=rev
Log:
[OPENMP] Emit non-debug version of outlined functions with original
name.

If the host code is compiled with the debug info, while the target
without, there is a problem that the compiler is unable to find the
debug wrapper. Patch fixes this problem by emitting special name for the
debug version of the code.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_codegen.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=310511=310510=310511=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Aug  9 12:38:53 2017
@@ -247,7 +247,7 @@ namespace {
 /// true if cast to/from  UIntPtr is required for variables captured by
 /// value.
 const bool UIntPtrCastRequired = true;
-/// true if only casted argumefnts must be registered as local args or VLA
+/// true if only casted arguments must be registered as local args or VLA
 /// sizes.
 const bool RegisterCastedArgsOnly = false;
 /// Name of the generated function.
@@ -261,7 +261,7 @@ namespace {
   };
 }
 
-static std::pair emitOutlinedFunctionPrologue(
+static llvm::Function *emitOutlinedFunctionPrologue(
 CodeGenFunction , FunctionArgList ,
 llvm::MapVector>
 ,
@@ -277,7 +277,6 @@ static std::pair
   CodeGenModule  = CGF.CGM;
   ASTContext  = CGM.getContext();
   FunctionArgList TargetArgs;
-  bool HasUIntPtrArgs = false;
   Args.append(CD->param_begin(),
   std::next(CD->param_begin(), CD->getContextParamPosition()));
   TargetArgs.append(
@@ -296,7 +295,6 @@ static std::pair
 // outlined function.
 if ((I->capturesVariableByCopy() && !ArgType->isAnyPointerType()) ||
 I->capturesVariableArrayType()) {
-  HasUIntPtrArgs = true;
   if (FO.UIntPtrCastRequired)
 ArgType = Ctx.getUIntPtrType();
 }
@@ -432,7 +430,7 @@ static std::pair
 ++I;
   }
 
-  return {F, HasUIntPtrArgs};
+  return F;
 }
 
 llvm::Function *
@@ -448,12 +446,15 @@ CodeGenFunction::GenerateOpenMPCapturedS
   FunctionArgList Args;
   llvm::MapVector> 
LocalAddrs;
   llvm::DenseMap> 
VLASizes;
+  SmallString<256> Buffer;
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << CapturedStmtInfo->getHelperName();
+  if (NeedWrapperFunction)
+Out << "_debug__";
   FunctionOptions FO(, !NeedWrapperFunction, 
/*RegisterCastedArgsOnly=*/false,
- CapturedStmtInfo->getHelperName());
-  llvm::Function *F;
-  bool HasUIntPtrArgs;
-  std::tie(F, HasUIntPtrArgs) = emitOutlinedFunctionPrologue(
-  *this, Args, LocalAddrs, VLASizes, CXXThisValue, FO);
+ Out.str());
+  llvm::Function *F = emitOutlinedFunctionPrologue(*this, Args, LocalAddrs,
+   VLASizes, CXXThisValue, FO);
   for (const auto  : LocalAddrs) {
 if (LocalAddrPair.second.first) {
   setAddrOfLocalVar(LocalAddrPair.second.first,
@@ -465,14 +466,12 @@ CodeGenFunction::GenerateOpenMPCapturedS
   PGO.assignRegionCounters(GlobalDecl(CD), F);
   CapturedStmtInfo->EmitBody(*this, CD->getBody());
   FinishFunction(CD->getBodyRBrace());
-  if (!NeedWrapperFunction || !HasUIntPtrArgs)
+  if (!NeedWrapperFunction)
 return F;
 
-  SmallString<256> Buffer;
-  llvm::raw_svector_ostream Out(Buffer);
-  Out << "__nondebug_wrapper_" << CapturedStmtInfo->getHelperName();
   FunctionOptions WrapperFO(, /*UIntPtrCastRequired=*/true,
-/*RegisterCastedArgsOnly=*/true, Out.str());
+/*RegisterCastedArgsOnly=*/true,
+CapturedStmtInfo->getHelperName());
   CodeGenFunction WrapperCGF(CGM, /*suppressNewContext=*/true);
   WrapperCGF.disableDebugInfo();
   Args.clear();
@@ -480,7 +479,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
   VLASizes.clear();
   llvm::Function *WrapperF =
   emitOutlinedFunctionPrologue(WrapperCGF, Args, LocalAddrs, VLASizes,
-   WrapperCGF.CXXThisValue, WrapperFO).first;
+   WrapperCGF.CXXThisValue, WrapperFO);
   LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
   llvm::SmallVector CallArgs;
   for (const auto *Arg : Args) {

Modified: cfe/trunk/test/OpenMP/distribute_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_codegen.cpp?rev=310511=310510=310511=diff
==
--- cfe/trunk/test/OpenMP/distribute_codegen.cpp (original)
+++ 

Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread David Blaikie via cfe-commits
OK - go ahead and remove the tests then, if the functionality is now
covered by the buildbot+existing tests.

On Wed, Aug 9, 2017 at 12:04 PM Grang, Mandeep Singh 
wrote:

> > Ah, OK. I'm still curious about whether this results in a loss of test
> coverage. Without this test, would the bug it was testing still be caught
> by some test failure in at least one of the forward or reverse iteration
> modes?
>
> Sorry ... I missed that. Yes, the reverse iteration buildbot
> http://lab.llvm.org:8011/builders/reverse-iteration would test these.
> These tests were a stopgap solution anyway while the reverse builtbot was
> being setup.
>
> > I'll just do that (r310506 & r310508) - done! :)
> Thanks!
>
>
> --Mandeep
>
> On 8/9/2017 11:35 AM, David Blaikie wrote:
>
>
>
> On Wed, Aug 9, 2017 at 1:44 AM Grang, Mandeep Singh 
> wrote:
>
>> In D35043 I have removed the llvm tests which use -reverse-iterate. This
>> patch removes the clang tests.
>>
>
> Ah, OK. I'm still curious about whether this results in a loss of test
> coverage. Without this test, would the bug it was testing still be caught
> by some test failure in at least one of the forward or reverse iteration
> modes?
>
>
>> Should I post a later patch to change all "class PointerLikeTypeTraits"
>> to "struct PointerLikeTypeTraits"?
>>
>
> I'll just do that (r310506 & r310508) - done! :)
>
>
>>
>>
>> On 8/7/2017 2:50 PM, David Blaikie wrote:
>>
>>
>>
>> On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> mgrang added a comment.
>>>
>>> This patch does 3 things:
>>>
>>> 1. Get rid of the unit test objc-modern-metadata-visibility2.mm because
>>> this test check uses flag -reverse-iterate. This flag will be removed in
>>> https://reviews.llvm.org/D35043.
>>>
>>
>> Sure - please commit that separately (probably once D35043 is approved -
>> probably best to include that removal in D35043, or a separate patch that
>> /only/ removes the -reverse-iterate flag (& any tests that use it) as a
>> standalone change?).
>>
>> Does this test need a replacement? If this test is removed and the
>> underlying issue it was testing regresses, will one of the buildbots
>> (reverse or normal) catch the problem?
>>
>>
>>> 2. https://reviews.llvm.org/D35043 gets rid of the empty base
>>> definition for PointerLikeTypeTraits. This results in a compiler warning
>>> because PointerLikeTypeTrait has been defined as struct here while in the
>>> header it is a class. So I have changed struct to class.
>>>
>>
>> I'd probably go the other way - traits classes like this make more sense
>> as structs, I think - it only has public members & no implementation really
>> has any need for supporting private members.
>>
>>
>>> 3. Since I changed struct PointerLikeTypeTrait to class
>>> PointerLikeTypeTrait here, the member functions are no longer public now.
>>> This results in a compiler error. So I explicitly marked them as public
>>> here.
>>>
>>>
>>> https://reviews.llvm.org/D36386
>>>
>>>
>>>
>>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-09 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

In https://reviews.llvm.org/D34158#836026, @jyknight wrote:

> In https://reviews.llvm.org/D34158#827178, @joerg wrote:
>
> > (2) It adds magic behavior that can make debugging more difficult. 
> > Partially preprocessed sources for example could be compiled with plain -c 
> > before, now they need a different command line.
>
>
> If this is a problem, making it be Linux-only does _nothing_ to solve it. But 
> I don't actually see how this is a substantively new problem? Compiling with 
> plain -c before
>  would get #defines for those predefined macros that the compiler sets, even 
> though you may not have wanted those. Is this fundamentally different?


It makes it a linux-only problem. As such, it is something *I* only care about 
secondary. A typical use case I care about a lot is pulling the crash report 
sources from my (NetBSD) build machine,
extracting the original command line to rerun the normal compilation with 
-save-temps. I don't necessarily have the (same) system headers on the machine 
I use for debugging and that's exactly
the kind of use case this change breaks. All other predefined macros are driven 
by the target triple and remain stable.

>> (3) It seems to me that the GNU userland (and maybe Windows) is the 
>> exception to a well integrated tool chain. Most other platforms have a 
>> single canonical
>>  libc, libm and libpthread implementation and can as such directly define 
>> all the relevant macros directly in the driver.
> 
> I don't think this is accurate. There's many platforms out there, and for 
> almost none of them do we have exact knowledge of the features of the libc 
> encoded
>  into the compiler. I'd note that not only do you need this for every (OS, 
> libc) combination, you'd need it for every (OS, libc-VERSION) combination.

Not really. The feature set is rarely changing and generally will have only a 
cut-off version.

>> Given that many of the macros involved are already reflected by the compiler 
>> behavior anyway, they can't be decoupled. I.e. the questionable
>>  concept of locale-independent wchar_t is already hard-coded in the front 
>> end as soon as any long character literals are used.
> 
> AFAICT, this example is not actually the case. The frontend only needs to 
> know *a* valid encoding for wide-character literals in some
>  implementation-defined locale (for example, it might always emit them as 
> unicode codepoints, as clang does).  Standard says:
>  "the array elements [...] are initialized with the sequence of wide 
> characters corresponding to the multibyte character sequence, as
>  defined by the mbstowcs function with an implementation defined current 
> locale."

I know what the standard says. It doesn't make much sense if you do not have a 
fixed wchar_t encoding.

> On the other hand, I believe the intent of this macro is to guarantee that 
> _no matter what_ the locale is,
>  that a U+0100 character (say, translated with mbrtowc from the locale 
> encoding) gets represented as 0x100.

Yes, so it is essentially "we have screwed up by creating a language mechanism 
that adds a major constraint, so let's go all the way".

> Thus, it's "fine" for the frontend to always emit wchar_t literals as 
> unicode, yet, the libc may sometimes use an arbitrary different
>  internal encoding, depending on the locale used at runtime. (Obviously using 
> wide character literals with such a libc would be a poor 
>  user experience, and such a libc probably ought to reconsider its choices, 
> but that's a different discussion.)

One of the biggest opponents of that was Itojun. It's not a decision that 
should be made here as it is only indirectly related to this discussion.

>> As such, please move the command line additions back into the 
>> target-specific files for targets that actually want to get this behavior.
> 
> Without even a suggestion of a better solution to use for other targets, I 
> find it is to be a real shame to push for this to be linux-only,
>  and leave everyone else hanging. I find that that _most_ of these defines 
> are effectively library decisions. I further would claim that these
>  are likely to vary over the lifetime of even a single libc, and that as such 
> we would be better served by allowing the libc to set them directly, rather 
> than encoding it into the compiler.
> 
> TTBOMK, no targets except linux/glibc/gcc actually comply with this part of 
> the C99/C11 standard today, and so this feature would be useful to have 
> available across all targets.
> 
> (I very much dislike that the C standard has started adding all these new 
> predefined macros, instead of exposing them from a header, but there's not 
> much to be done about that...)

Exactly. It's not like this is a lot of target logic. It should be a single 
call for targets that want to get this functionality. But that's my point -- it 
should be opt-in, not opt-out.


https://reviews.llvm.org/D34158




Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread Grang, Mandeep Singh via cfe-commits
> Ah, OK. I'm still curious about whether this results in a loss of 
test coverage. Without this test, would the bug it was testing still be 
caught by some test failure in at least one of the forward or reverse 
iteration modes?


Sorry ... I missed that. Yes, the reverse iteration buildbot 
http://lab.llvm.org:8011/builders/reverse-iteration would test these. 
These tests were a stopgap solution anyway while the reverse builtbot 
was being setup.



> I'll just do that (r310506 & r310508) - done! :)
Thanks!


--Mandeep


On 8/9/2017 11:35 AM, David Blaikie wrote:



On Wed, Aug 9, 2017 at 1:44 AM Grang, Mandeep Singh 
> wrote:


In D35043 I have removed the llvm tests which use
-reverse-iterate. This patch removes the clang tests.


Ah, OK. I'm still curious about whether this results in a loss of test 
coverage. Without this test, would the bug it was testing still be 
caught by some test failure in at least one of the forward or reverse 
iteration modes?


Should I post a later patch to change all "class
PointerLikeTypeTraits" to "struct PointerLikeTypeTraits"?


I'll just do that (r310506 & r310508) - done! :)



On 8/7/2017 2:50 PM, David Blaikie wrote:



On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via
Phabricator > wrote:

mgrang added a comment.

This patch does 3 things:

1. Get rid of the unit test
objc-modern-metadata-visibility2.mm
 because this
test check uses flag -reverse-iterate. This flag will be
removed in https://reviews.llvm.org/D35043.


Sure - please commit that separately (probably once D35043 is
approved - probably best to include that removal in D35043, or a
separate patch that /only/ removes the -reverse-iterate flag (&
any tests that use it) as a standalone change?).

Does this test need a replacement? If this test is removed and
the underlying issue it was testing regresses, will one of the
buildbots (reverse or normal) catch the problem?

2. https://reviews.llvm.org/D35043 gets rid of the empty base
definition for PointerLikeTypeTraits. This results in a
compiler warning because PointerLikeTypeTrait has been
defined as struct here while in the header it is a class. So
I have changed struct to class.


I'd probably go the other way - traits classes like this make
more sense as structs, I think - it only has public members & no
implementation really has any need for supporting private members.

3. Since I changed struct PointerLikeTypeTrait to class
PointerLikeTypeTrait here, the member functions are no longer
public now. This results in a compiler error. So I explicitly
marked them as public here.


https://reviews.llvm.org/D36386







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


[PATCH] D36537: [OpenMP] Enable executable lookup into driver directory.

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

Add comment.


https://reviews.llvm.org/D36537

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,9 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  // Lookup binaries into the driver directory, this is used to
+  // discover the clang-offload-bundler executable.
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,9 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  // Lookup binaries into the driver directory, this is used to
+  // discover the clang-offload-bundler executable.
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36537: [OpenMP] Enable executable lookup into driver directory.

2017-08-09 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

I think this is fine, but please add a comment explaining that you're doing 
this to find (e.g., to find the offload bundler, etc.).


Repository:
  rL LLVM

https://reviews.llvm.org/D36537



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

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

Ping


https://reviews.llvm.org/D35449



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


[PATCH] D36537: [OpenMP] Enable executable lookup into driver directory.

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

Invoking the compiler inside a script causes the clang-offload-bundler 
executable to not be found. This patch fixes this error.


Repository:
  rL LLVM

https://reviews.llvm.org/D36537

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,7 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,7 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread David Blaikie via cfe-commits
On Wed, Aug 9, 2017 at 1:44 AM Grang, Mandeep Singh 
wrote:

> In D35043 I have removed the llvm tests which use -reverse-iterate. This
> patch removes the clang tests.
>

Ah, OK. I'm still curious about whether this results in a loss of test
coverage. Without this test, would the bug it was testing still be caught
by some test failure in at least one of the forward or reverse iteration
modes?


> Should I post a later patch to change all "class PointerLikeTypeTraits" to
> "struct PointerLikeTypeTraits"?
>

I'll just do that (r310506 & r310508) - done! :)


>
>
> On 8/7/2017 2:50 PM, David Blaikie wrote:
>
>
>
> On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> mgrang added a comment.
>>
>> This patch does 3 things:
>>
>> 1. Get rid of the unit test objc-modern-metadata-visibility2.mm because
>> this test check uses flag -reverse-iterate. This flag will be removed in
>> https://reviews.llvm.org/D35043.
>>
>
> Sure - please commit that separately (probably once D35043 is approved -
> probably best to include that removal in D35043, or a separate patch that
> /only/ removes the -reverse-iterate flag (& any tests that use it) as a
> standalone change?).
>
> Does this test need a replacement? If this test is removed and the
> underlying issue it was testing regresses, will one of the buildbots
> (reverse or normal) catch the problem?
>
>
>> 2. https://reviews.llvm.org/D35043 gets rid of the empty base definition
>> for PointerLikeTypeTraits. This results in a compiler warning because
>> PointerLikeTypeTrait has been defined as struct here while in the header it
>> is a class. So I have changed struct to class.
>>
>
> I'd probably go the other way - traits classes like this make more sense
> as structs, I think - it only has public members & no implementation really
> has any need for supporting private members.
>
>
>> 3. Since I changed struct PointerLikeTypeTrait to class
>> PointerLikeTypeTrait here, the member functions are no longer public now.
>> This results in a compiler error. So I explicitly marked them as public
>> here.
>>
>>
>> https://reviews.llvm.org/D36386
>>
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310508 - PointerLikeTypeTraits: class->struct to match LLVM change

2017-08-09 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Aug  9 11:34:22 2017
New Revision: 310508

URL: http://llvm.org/viewvc/llvm-project?rev=310508=rev
Log:
PointerLikeTypeTraits: class->struct to match LLVM change

Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclGroup.h
cfe/trunk/include/clang/AST/TemplateName.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/CodeGen/ConstantInitFuture.h
cfe/trunk/include/clang/Sema/Ownership.h

Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=310508=310507=310508=diff
==
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Wed Aug  9 11:34:22 2017
@@ -359,8 +359,7 @@ struct simplify_type< ::clang::CanQual is "basically a pointer".
 template
-class PointerLikeTypeTraits {
-public:
+struct PointerLikeTypeTraits {
   static inline void *getAsVoidPointer(clang::CanQual P) {
 return P.getAsOpaquePtr();
   }

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310508=310507=310508=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug  9 11:34:22 2017
@@ -73,8 +73,7 @@ public:
 namespace llvm {
   // Provide PointerLikeTypeTraits for non-cvr pointers.
   template<>
-  class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
-  public:
+  struct PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
 static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
   return F.get();
 }

Modified: cfe/trunk/include/clang/AST/DeclGroup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclGroup.h?rev=310508=310507=310508=diff
==
--- cfe/trunk/include/clang/AST/DeclGroup.h (original)
+++ cfe/trunk/include/clang/AST/DeclGroup.h Wed Aug  9 11:34:22 2017
@@ -138,10 +138,9 @@ public:
 namespace llvm {
   // DeclGroupRef is "like a pointer", implement PointerLikeTypeTraits.
   template 
-  class PointerLikeTypeTraits;
+  struct PointerLikeTypeTraits;
   template <>
-  class PointerLikeTypeTraits {
-  public:
+  struct PointerLikeTypeTraits {
 static inline void *getAsVoidPointer(clang::DeclGroupRef P) {
   return P.getAsOpaquePtr();
 }

Modified: cfe/trunk/include/clang/AST/TemplateName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=310508=310507=310508=diff
==
--- cfe/trunk/include/clang/AST/TemplateName.h (original)
+++ cfe/trunk/include/clang/AST/TemplateName.h Wed Aug  9 11:34:22 2017
@@ -515,8 +515,7 @@ namespace llvm {
 
 /// \brief The clang::TemplateName class is effectively a pointer.
 template<>
-class PointerLikeTypeTraits {
-public:
+struct PointerLikeTypeTraits {
   static inline void *getAsVoidPointer(clang::TemplateName TN) {
 return TN.getAsVoidPointer();
   }

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=310508=310507=310508=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Aug  9 11:34:22 2017
@@ -48,10 +48,9 @@ namespace clang {
 
 namespace llvm {
   template 
-  class PointerLikeTypeTraits;
+  struct PointerLikeTypeTraits;
   template<>
-  class PointerLikeTypeTraits< ::clang::Type*> {
-  public:
+  struct PointerLikeTypeTraits< ::clang::Type*> {
 static inline void *getAsVoidPointer(::clang::Type *P) { return P; }
 static inline ::clang::Type *getFromVoidPointer(void *P) {
   return static_cast< ::clang::Type*>(P);
@@ -59,8 +58,7 @@ namespace llvm {
 enum { NumLowBitsAvailable = clang::TypeAlignmentInBits };
   };
   template<>
-  class PointerLikeTypeTraits< ::clang::ExtQuals*> {
-  public:
+  struct PointerLikeTypeTraits< ::clang::ExtQuals*> {
 static inline void *getAsVoidPointer(::clang::ExtQuals *P) { return P; }
 static inline ::clang::ExtQuals *getFromVoidPointer(void *P) {
   return static_cast< ::clang::ExtQuals*>(P);
@@ -1143,8 +1141,7 @@ template<> struct simplify_type< ::clang
 
 // Teach SmallPtrSet that QualType is "basically a pointer".
 template<>
-class PointerLikeTypeTraits {
-public:
+struct PointerLikeTypeTraits {
   static inline void *getAsVoidPointer(clang::QualType P) {
 return P.getAsOpaquePtr();
   }


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-09 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110443.
yawanng marked 5 inline comments as done.

https://reviews.llvm.org/D35372

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/android/CloexecCheck.h
  clang-tidy/android/CloexecMemfdCreateCheck.cpp
  clang-tidy/android/CloexecMemfdCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-memfd-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-memfd-create.cpp

Index: test/clang-tidy/android-cloexec-memfd-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-memfd-create.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s android-cloexec-memfd-create %t
+
+#define MFD_ALLOW_SEALING 1
+#define __O_CLOEXEC 3
+#define MFD_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int memfd_create(const char *name, unsigned int flags);
+
+void a() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'memfd_create' should use MFD_CLOEXEC where possible [android-cloexec-memfd-create]
+  // CHECK-FIXES: memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC))
+}
+
+void f() {
+  memfd_create(NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'memfd_create'
+  // CHECK-FIXES: memfd_create(NULL, 3 | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, 3 | MFD_CLOEXEC))
+
+  int flag = 3;
+  memfd_create(NULL, flag);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, flag));
+}
+
+namespace i {
+int memfd_create(const char *name, unsigned int flags);
+
+void d() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+}
+
+} // namespace i
+
+void e() {
+  memfd_create(NULL, MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_CLOEXEC));
+  memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC));
+}
+
+class G {
+public:
+  int memfd_create(const char *name, unsigned int flags);
+  void d() {
+memfd_create(NULL, MFD_ALLOW_SEALING);
+TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-memfd-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-memfd-create.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-memfd-create
+
+android-cloexec-memfd-create
+
+
+``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
+the file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  memfd_create(name, MFD_ALLOW_SEALING);
+
+  // becomes
+
+  memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-memfd_create
+  `_ check
+
+  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument of
+  ``memfd_create()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecMemfdCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecMemfdCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecMemfdCreateCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

Revision 310505 fixes the tests for this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D35937: [clang-tidy] Add new readability non-idiomatic static access

2017-08-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

A few late comments.




Comment at: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst:28-29
+
+  C::foo();
+  C::x;
+

This may be confusing as to whether the check removes the struct definition 
(and the definition of c1) or not.



Comment at: 
docs/clang-tidy/checks/readability-static-accessed-through-instance.rst:11
+
+Thefollowing code:
+

typo: "Thefollowing"



Comment at: test/clang-tidy/readability-static-accessed-through-instance.cpp:55
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through
+  // instance  [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  C::x;{{$}}

Line wrapping gone bad. I guess you can just remove the second line. Same below.


Repository:
  rL LLVM

https://reviews.llvm.org/D35937



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


[PATCH] D36482: Enable bunch of sanitizers on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski updated this revision to Diff 110442.
krytarowski edited the summary of this revision.
krytarowski added a comment.

Fix lsan entry.
Add tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482

Files:
  lib/Driver/ToolChains/NetBSD.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -516,6 +516,29 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
+// ADDRESS-NETBSD: "-fsanitize=address"
+
+// RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
+// VPTR-NETBSD: "-fsanitize=vptr"
+
+// RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// SAFESTACK-NETBSD: "-fsanitize=safe-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4
 // CHECK-FSAN-UBSAN-PS4: unsupported option '-fsanitize=function' for target 
'x86_64-scei-ps4'
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FSAN-PS4
Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,13 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Function;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Vptr;
+  }
+  if (IsX86_64) {
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -516,6 +516,29 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | FileCheck %s -check-prefix=ADDRESS-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | FileCheck %s -check-prefix=ADDRESS-NETBSD
+// ADDRESS-NETBSD: "-fsanitize=address"
+
+// RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck %s -check-prefix=VPTR-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck %s -check-prefix=VPTR-NETBSD
+// VPTR-NETBSD: "-fsanitize=vptr"
+
+// RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// SAFESTACK-NETBSD: "-fsanitize=safe-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck %s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck %s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function -fsanitize=undefined %s 

[PATCH] D36492: [RFC][time-report] Add preprocessor timer

2017-08-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added subscribers: mzolotukhin, vsk.
vsk added a comment.

Thanks for working on this. Collecting better timing information in the 
frontend sgtm. It's cheap to do, and we can use the information to guide our 
efforts re: attacking the compile-time problem. Feel free to add me to future 
timing-related reviews. Regarding this specific patch:

Could you add a short test (perhaps in test/Misc?) that checks that 
-ftime-report prints out an entry for 'Preprocessing'?

It'd be nice to dump this timer from Preprocessor::PrintStats(), too.




Comment at: lib/Lex/Preprocessor.cpp:660
 
+  llvm::TimeRegion(PPOpts->ShowTimers ?  : nullptr);
+

I wonder whether this is too fine-grained. I think setting up a timer in 
Preprocessor::Lex() might capture more information. Would you mind 
experimenting with that?



Comment at: lib/Lex/Preprocessor.cpp:660
 
+  llvm::TimeRegion(PPOpts->ShowTimers ?  : nullptr);
+

vsk wrote:
> I wonder whether this is too fine-grained. I think setting up a timer in 
> Preprocessor::Lex() might capture more information. Would you mind 
> experimenting with that?
Nitpick: it may be useful to add PPOpts::getTimer(), in case we find more sites 
where we need to either get back the PP timer or nullptr.


https://reviews.llvm.org/D36492



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

In https://reviews.llvm.org/D29660#836927, @arphaman wrote:

> Looks like this test is failing on macOS again after this change:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/39231/testReport/Clang/Driver/openmp_offload_c/
>
> Can you please take a look?


Looking into it now.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

I have a few more nitpicks; LGTM after you fix those.




Comment at: src/cxa_demangle.cpp:1621-1631
+// Name stack, this is used by the parser to hold temporary names that were
+// parsed. The parser colapses multiple names into new nodes to construct
+// the AST. Once the parser is finished, names.size() == 1.
+PODSmallVector names;
+
+// Substitution table. Itanium supports name substitutions as a means of
+// compression. The string "S42_" refers to the 42nd entry in this table.

erik.pilkington wrote:
> dexonsmith wrote:
> > How much have you thought about these sizes (32, 32, and 4)?  Any evidence 
> > to back up these specific choices?
> Yep, 32 is enough for the Subs table/names to never overflow when demangling 
> the symbols in LLVM, and 4 seldom overflows TemplateParams. TemplateParams is 
> temporary held on the stack in parse_template_args(), so I wanted it to be 
> smaller.
Sounds great.  Please add comments to that effect.



Comment at: src/cxa_demangle.cpp:1626-1630
+Node **Begin = Substitutions.begin() + PackIndices[N];
+Node **End = (N + 1 == PackIndices.size())
+ ? Substitutions.end()
+ : Substitutions.begin() + PackIndices[N + 1];
+assert(End <= Substitutions.end() && Begin <= End);

This assertion won't be meaningful in the case that matters: when 
`PackIndices[N + 1]` is larger than `Substitutions.size()`.  In that case, 
`End` is in the middle of nowhere, and the result of `End <= 
Substitutions.end()` is undefined.  A smart optimizer would fold that to `true`.

You should assert `PackIndices[N + 1] <= Substitutions.size()`.



Comment at: src/cxa_demangle.cpp:5195-5199
+auto TmpParams = std::move(db.TemplateParams);
+size_t k0 = db.Names.size();
+const char* t1 = parse_template_arg(t, last, db);
+size_t k1 = db.Names.size();
+db.TemplateParams = std::move(TmpParams);

This looks really hairy.  This is the only (non-recursive) caller of 
`parse_template_arg`... it doesn't seem reasonable for `parse_template_arg` to 
modify template params, if we're just going to reset them after without looking.

Please add a FIXME to sort this out (at least to document the logic, if not to 
refactor it somehow).



Comment at: src/cxa_demangle.cpp:5207-5209
+}
+else
+{

Early `continue` instead of `else`, if you leave the logic like this.

I'm a little skeptical that this structure is better than before, though, since 
there's some non-trivial duplicated code.  I'll let you decide.


https://reviews.llvm.org/D36427



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-09 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110429.
euhlmann edited the summary of this revision.
euhlmann added a comment.

This addresses Daniel's previous concerns. The option is now an enum, the 
heuristic for detecting include guards is expanded and has corresponding unit 
tests, and style issues are resolved.
This does not yet use `PPBranchLevel` to track indent; I'm updating this review 
with my current work before addressing that point.


https://reviews.llvm.org/D35955

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2286,8 +2286,158 @@
getLLVMStyleWithColumns(11));
 }
 
-TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
-  EXPECT_EQ("{\n  {\n#define A\n  }\n}", format("{{\n#define A\n}}"));
+TEST_F(FormatTest, IndentPreprocessorDirectives) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef _WIN32\n"
+   "#define A 0\n"
+   "#ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#endif\n"
+   "#else\n"
+   "#define A 1\n"
+   "#endif",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef _WIN32\n"
+   "#  define A 0\n"
+   "#  ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#  endif\n"
+   "#else\n"
+   "#  define A 1\n"
+   "#endif",
+   Style);
+  // Test with include guards.
+  EXPECT_EQ("#ifndef _SOMEFILE_H\n"
+"#define _SOMEFILE_H\n"
+"code();\n"
+"#endif",
+format("#ifndef _SOMEFILE_H\n"
+   "#define _SOMEFILE_H\n"
+   "code();\n"
+   "#endif",
+   Style));
+  // Include guards must have a #define with the same variable immediately
+  // after #ifndef.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define FOO\n"
+"code();\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define FOO\n"
+   "code();\n"
+   "#endif",
+   Style));
+
+  // Include guards must cover the entire file.
+  EXPECT_EQ("code();\n"
+"#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif",
+format("code();\n"
+   "#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif\n"
+"code();",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif\n"
+   "code();",
+   Style));
+  // Include guards don't have #else.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#else\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#else\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#elif FOO\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#elif FOO\n"
+   "#endif",
+   Style));
+  // Defect: We currently do not deal with the case where there's code between
+  // the #ifndef and #define but all other conditions hold. This is because when
+  // the #define line is parsed, UnwrappedLineParser::Lines doesn't hold the
+  // previous code line yet, so we can't detect it.
+  EXPECT_NE("#ifndef NOT_GUARD\n"
+ 

[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.

As suggested on PR33912.

Trying to keep this small to make it easy to merge to the 5.0 branch. We can do 
a follow-up with more thorough renaming (diagnostic text, options, ids, etc.) 
later.

(For c++14 this was done in r215982, and I think a smaller patch for the 3.5 
branch: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140818/113013.html)


https://reviews.llvm.org/D36532

Files:
  include/clang/Frontend/LangStandards.def
  test/Driver/unknown-std.cpp
  test/SemaCXX/cxx1z-init-statement.cpp


Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;
Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU 
extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with 
GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with GNU extensions' 
standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with 
GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",


Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;
Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with GNU extensions' standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z |
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
-   

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

Looks like this test is failing on macOS again after this change:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/39231/testReport/Clang/Driver/openmp_offload_c/

Can you please take a look?


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D35932: [clang-tidy] Add integer division check

2017-08-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

A few more nits.




Comment at: clang-tidy/bugprone/IntegerDivisionCheck.cpp:40-44
+  hasAncestor(
+  castExpr(hasCastKind(CK_IntegralToFloating)).bind("FloatCast")),
+  unless(hasAncestor(
+  expr(Exceptions,
+   hasAncestor(castExpr(equalsBoundNode("FloatCast")))

The way `hasAncestor` is used in this code makes me uneasy. Each nested 
ancestor traversal can potentially slow down matching by a factor of the depth 
of the AST tree, which may lead to poor performance on certain types of code 
(nested descendant traversal is much worse though). Some of the overhead may be 
compensated by memoization, but it's hard to predict where it will actually 
work.

It's usually better to avoid nested ancestor traversals, if there are good 
alternatives. Here I don't see a better possibility with matchers, but it's to 
go one level lower and use RecursiveASTVisitor directly. Without constructing / 
discovering a problematic case it's hard to tell whether the performance win of 
switching to RAV is worth the added complexity, so I'm not suggesting to do 
that yet. Just mentioning a possible issue to be aware of.



Comment at: clang-tidy/bugprone/IntegerDivisionCheck.cpp:51
+  const auto *IntDiv = Result.Nodes.getNodeAs("IntDiv");
+  diag(IntDiv->getLocStart(), "integer division; possible precision loss");
+}

Maybe expand the message to describe the pattern the check matches more 
precisely? E.g. "result of an integer division is used in a floating point 
context; possible loss of precision"?



Comment at: docs/ReleaseNotes.rst:63-64
+
+  Finds cases of integer divisions that seem to alter the meaning of the
+  surrounding code.
 

The description is somewhat vague. How about "Finds cases where integer 
division in floating point context is likely to cause unintended loss of 
precision."? Same in the docs below.



Comment at: test/clang-tidy/bugprone-integer-division.cpp:14
+  return x / y - 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: integer division; possible 
precision loss [bugprone-integer-division]
+}

It's better to truncate repeated fragments of the messages, especially when 
they exceed 80 characters (better on a word boundary ;).


https://reviews.llvm.org/D35932



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


[PATCH] D36531: [Parse] Document Parser::SkipFunctionBodies

2017-08-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

https://reviews.llvm.org/D36531

Files:
  include/clang/Parse/Parser.h


Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -253,6 +253,10 @@
   /// be NULL.
   bool ParsingInObjCContainer;
 
+  /// Whether to skip parsing of function bodies.
+  ///
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   bool SkipFunctionBodies;
 
   /// The location of the expression statement that is being parsed right now.


Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -253,6 +253,10 @@
   /// be NULL.
   bool ParsingInObjCContainer;
 
+  /// Whether to skip parsing of function bodies.
+  ///
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   bool SkipFunctionBodies;
 
   /// The location of the expression statement that is being parsed right now.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

check-safestack

  -- Testing: 8 tests, 8 threads --
  Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  Testing Time: 0.56s
Expected Passes: 7
Unsupported Tests  : 1

I will research how to add the requested tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482



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


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

Add documentation for `clang::ParseAST` parameters `PrintStats` and
`SkipFunctionBodies`. Also, remove a tiny bit of trailing whitespace.


https://reviews.llvm.org/D36530

Files:
  include/clang/Parse/ParseAST.h


Index: include/clang/Parse/ParseAST.h
===
--- include/clang/Parse/ParseAST.h
+++ include/clang/Parse/ParseAST.h
@@ -29,10 +29,13 @@
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor , ASTConsumer *C,
 ASTContext , bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@
   /// abstract syntax tree.
   void ParseAST(Sema , bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif


Index: include/clang/Parse/ParseAST.h
===
--- include/clang/Parse/ParseAST.h
+++ include/clang/Parse/ParseAST.h
@@ -29,10 +29,13 @@
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor , ASTConsumer *C,
 ASTContext , bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@
   /// abstract syntax tree.
   void ParseAST(Sema , bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36452: [clang-tidy] Fix another crash in make-unique check.

2017-08-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310496: [clang-tidy] Fix another crash in make-unique check. 
(authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D36452

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -199,6 +199,13 @@
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -415,3 +415,16 @@
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};


Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -199,6 +199,13 @@
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -415,3 +415,16 @@
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r310496 - [clang-tidy] Fix another crash in make-unique check.

2017-08-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Aug  9 10:03:42 2017
New Revision: 310496

URL: http://llvm.org/viewvc/llvm-project?rev=310496=rev
Log:
[clang-tidy] Fix another crash in make-unique check.

Summary:
The crash happens when calling `reset` method without any preceding
operation like "->" or ".", this could happen in a subclass of the
"std::unique_ptr".

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=310496=310495=310496=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Wed Aug  
9 10:03:42 2017
@@ -199,6 +199,13 @@ void MakeSmartPtrCheck::checkReset(Sourc
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=310496=310495=310496=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Wed Aug  
9 10:03:42 2017
@@ -415,3 +415,16 @@ void macro() {
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};


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


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski updated this revision to Diff 110420.
krytarowski edited the summary of this revision.
krytarowski added a comment.

Enable more sanitizers.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482

Files:
  lib/Driver/ToolChains/NetBSD.cpp


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,14 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Function;
+  }
+  if (IsX86_64) {
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,14 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Function;
+  }
+  if (IsX86_64) {
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36452: [clang-tidy] Fix another crash in make-unique check.

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

Thank you for the fix!
Looks good!




Comment at: test/clang-tidy/modernize-make-unique.cpp:419
+
+class UniqueFoo : public std::unique_ptr {
+ public:

I suspected folks were doing weird stuff to cause this crash ;]


https://reviews.llvm.org/D36452



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


[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

Two PrecompiledPreambles, used in parallel on separate threads,
could be writing preamble to the same temporary file.


https://reviews.llvm.org/D36529

Files:
  lib/Frontend/PrecompiledPreamble.cpp


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@
 PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine ,
 StringRef Suffix) {
   llvm::SmallString<64> File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting 
(i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@
 PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine ,
 StringRef Suffix) {
   llvm::SmallString<64> File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting (i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Catched by a test from https://reviews.llvm.org/D36261.


https://reviews.llvm.org/D36529



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I'm not sure this approach is the best to deal with the boilerplate, but it 
seems like an improvement compared to repeating code. See a few comments inline.




Comment at: clang-tidy/android/CloexecCheck.cpp:66
+
+StringRef CloexecCheck::getSpellingArg(const MatchFinder::MatchResult ,
+   int N) const {

1. Should this be a class method?
2. Is this ever used? (if it is going to be used in a different check, let's 
postpone its addition to that moment)



Comment at: clang-tidy/android/CloexecCheck.h:43
+ast_matchers::callExpr(
+ast_matchers::callee(FuncDecl().bind(FuncDeclBindingStr)))
+.bind(FuncBindingStr),

Can we make this method non-template and put its implementation to the .cpp 
file? It could accept a Matcher or something like that and just 
apply it:

void registerForCall(MatchFinder *Finder, Matcher Function) {
  Finder->addMatcher(calExpr(callee(functionDecl(isExternC(), 
Function).bind(...))).bind(...), this);
}

Then you could make `FuncDeclBindingStr` and `FuncBindingStr` local to the file.



Comment at: clang-tidy/android/CloexecCheck.h:47
+  }
+  /// Currently, we has three types of fixes.
+  ///

s/we has/we have/



Comment at: clang-tidy/android/CloexecCheck.h:102-137
+  ast_matchers::internal::Matcher hasIntegerParameter(int N) {
+return ast_matchers::hasParameter(
+N, ast_matchers::hasType(ast_matchers::isInteger()));
+  }
+
+  ast_matchers::internal::Matcher
+  hasCharPointerTypeParameter(int N) {

These methods don't add much value: `hasParameter(N, hasType(isInteger()))` is 
not much longer or harder to read than `hasIntegerParameter(N)`, etc. Also 
having these utilities as non-static methods doesn't make much sense. If you 
want a shorter way to describe function signatures, I would suggest a single 
utility function `hasParameters()` that would take a list of type matchers and 
apply them to the corresponding parameters. That one could be useful more 
broadly than in this specific check, so it could be placed in utils/ (and later 
in ASTMatchers.h, if we find enough potential users).



Comment at: clang-tidy/android/CloexecCheck.h:140
+private:
+  const static char *FuncDeclBindingStr;
+  const static char *FuncBindingStr;

You're missing one more const: `static const char * const FuncDeclBindingStr;`


https://reviews.llvm.org/D35372



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


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

2017-08-09 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Apart from those in the in-line comments, I have a question: how safe is this 
library to `Release` builds? I know this is only a submodule dependency for the 
"real deal" in https://reviews.llvm.org/D30691, but I have seen some asserts 
that "imported function should already have a body" and such.

Will the static analyzer handle these errors gracefully and fall back to 
"function is unknown, let's throw my presumptions out of the window" or will it 
bail away? I'm explicitly thinking of the assert-lacking `Release` build.




Comment at: include/clang/Basic/AllDiagnostics.h:20
 #include "clang/AST/CommentDiagnostic.h"
+#include "clang/CrossTU/CrossTUDiagnostic.h"
 #include "clang/Analysis/AnalysisDiagnostic.h"

Import file order?



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:42
+/// Note that this class also implements caching.
+class CrossTranslationUnit {
+public:

Does the name of this class make sense? If I say


```
CrossTranslationUnit *ctuptr = new CrossTranslationUnit(...);
```

did I construct a new //CrossTranslationUnit//? What even **is** a 
//CrossTranslationUnit//? Other class names, such as `ASTImporter`, `DiagOpts`, 
and `FrontendAction`, etc. somehow feel better at ~~transmitting~~ reflecting 
upon their meaning in their name.





Comment at: lib/CrossTU/CrossTranslationUnit.cpp:45
+
+/// Recursively visit the funtion decls of a DeclContext, and looks up a
+/// function based on mangled name.

"visit**s** (...) and looks up" or "visit (...) and look up"



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:46
+/// Recursively visit the funtion decls of a DeclContext, and looks up a
+/// function based on mangled name.
+const FunctionDecl *

If we are using //USR// for lookup, then why does this look up "based on 
mangled name"?



Comment at: tools/CMakeLists.txt:25
   add_clang_subdirectory(scan-view)
+  add_clang_subdirectory(clang-func-mapping)
 endif()

The other "blocks" in this file look //somewhat// in alphabetic order, perhaps 
this should be added a few lines above?


https://reviews.llvm.org/D34512



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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea closed this revision.
gtbercea added a comment.

Already covered by https://reviews.llvm.org/D34888


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

check-ubsan

  -- Testing: 172 tests, 8 threads --
  Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  Testing Time: 20.19s
Expected Passes: 156
Unsupported Tests  : 16

I will enable more options and extend this commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482



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


[clang-tools-extra] r310491 - [clang-tidy] Ignore newlines in checks list

2017-08-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Aug  9 09:00:31 2017
New Revision: 310491

URL: http://llvm.org/viewvc/llvm-project?rev=310491=rev
Log:
[clang-tidy] Ignore newlines in checks list

This is a follow up to https://reviews.llvm.org/D30567 where I overlooked that
LLVM YAML parser doesn't support multiline literal folding.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp

clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=310491=310490=310491=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed Aug  
9 09:00:31 2017
@@ -115,7 +115,7 @@ ClangTidyError::ClangTidyError(StringRef
 // Returns true if GlobList starts with the negative indicator ('-'), removes 
it
 // from the GlobList.
 static bool ConsumeNegativeIndicator(StringRef ) {
-  GlobList = GlobList.trim(' ');
+  GlobList = GlobList.trim(" \r\n");
   if (GlobList.startswith("-")) {
 GlobList = GlobList.substr(1);
 return true;

Modified: 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp?rev=310491=310490=310491=diff
==
--- 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 Wed Aug  9 09:00:31 2017
@@ -74,7 +74,7 @@ TEST(GlobList, WhitespacesAtBegin) {
 }
 
 TEST(GlobList, Complex) {
-  GlobList Filter("*,-a.*, -b.*,   a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, -*qwe* 
");
+  GlobList Filter("*,-a.*, -b.*, \r  \n  a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, 
-*qwe* ");
 
   EXPECT_TRUE(Filter.contains("aaa"));
   EXPECT_TRUE(Filter.contains("qqq"));


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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-09 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch provides an implementation for P0428R2 .


https://reviews.llvm.org/D36527

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -823,7 +822,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2;>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: test/SemaCXX/cxx2a-template-lambdas.cpp
===
--- test/SemaCXX/cxx2a-template-lambdas.cpp
+++ test/SemaCXX/cxx2a-template-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+template
+constexpr bool is_same = false;
+
+template
+constexpr bool is_same = true;
+
+template
+struct DummyTemplate { };
+
+void func() {
+  auto L0 = [](T arg) {
+static_assert(is_same);
+  };
+  L0(0);
+
+  auto L1 = [] {
+static_assert(I == 5);
+  };
+  L1.operator()<5>();
+
+  auto L2 = []