[PATCH] D52259: [CUDA] Fix two failed test cases using --cuda-path-ignore-env

2018-09-24 Thread Jiading Gai via Phabricator via cfe-commits
gaijiading updated this revision to Diff 166811.
gaijiading retitled this revision from "[CUDA] Rearrange search path ordering 
to fix two test case failures" to "[CUDA] Fix two failed test cases using 
--cuda-path-ignore-env".
gaijiading edited the summary of this revision.
gaijiading added a comment.

Thanks for the comments. Revised the patch to fix them using 
--cuda-path-ignore-env.


Repository:
  rC Clang

https://reviews.llvm.org/D52259

Files:
  test/Driver/cuda-detect.cu
  test/Driver/cuda-macosx.cu


Index: test/Driver/cuda-macosx.cu
===
--- test/Driver/cuda-macosx.cu
+++ test/Driver/cuda-macosx.cu
@@ -3,6 +3,6 @@
 // REQUIRES: nvptx-registered-target
 //
 // RUN: %clang -v --target=i386-apple-macosx \
-// RUN:   --sysroot=%S/Inputs/CUDA-macosx 2>&1 | FileCheck %s
+// RUN:   --sysroot=%S/Inputs/CUDA-macosx --cuda-path-ignore-env 2>&1 | 
FileCheck %s
 
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA-macosx/usr/local/cuda
Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -14,9 +14,9 @@
 
 
 // RUN: %clang -v --target=i386-unknown-linux \
-// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
+// RUN:   --sysroot=%S/Inputs/CUDA --cuda-path-ignore-env 2>&1 | FileCheck %s
 // RUN: %clang -v --target=i386-apple-macosx \
-// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
+// RUN:   --sysroot=%S/Inputs/CUDA --cuda-path-ignore-env 2>&1 | FileCheck %s
 
 // RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s


Index: test/Driver/cuda-macosx.cu
===
--- test/Driver/cuda-macosx.cu
+++ test/Driver/cuda-macosx.cu
@@ -3,6 +3,6 @@
 // REQUIRES: nvptx-registered-target
 //
 // RUN: %clang -v --target=i386-apple-macosx \
-// RUN:   --sysroot=%S/Inputs/CUDA-macosx 2>&1 | FileCheck %s
+// RUN:   --sysroot=%S/Inputs/CUDA-macosx --cuda-path-ignore-env 2>&1 | FileCheck %s
 
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA-macosx/usr/local/cuda
Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -14,9 +14,9 @@
 
 
 // RUN: %clang -v --target=i386-unknown-linux \
-// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
+// RUN:   --sysroot=%S/Inputs/CUDA --cuda-path-ignore-env 2>&1 | FileCheck %s
 // RUN: %clang -v --target=i386-apple-macosx \
-// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
+// RUN:   --sysroot=%S/Inputs/CUDA --cuda-path-ignore-env 2>&1 | FileCheck %s
 
 // RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52252: Driver: render arguments for the embedded bitcode correctly

2018-09-24 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r342929 (with tests)


Repository:
  rC Clang

https://reviews.llvm.org/D52252



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


[PATCH] D52446: Annotate LookupResult::clear() as LLVM_ATTRIBUTE_REINITIALIZES to silence bugprone-use-after-move after rC342925

2018-09-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 166806.
MaskRay retitled this revision from "Remove Found.clear() to silent 
bugprone-use-after-move after rC342925" to "Annotate LookupResult::clear() as 
LLVM_ATTRIBUTE_REINITIALIZES to silence bugprone-use-after-move after rC342925".
MaskRay removed a reviewer: clang.
MaskRay added a comment.

Update title with arc diff --edit --verbatim


Repository:
  rC Clang

https://reviews.llvm.org/D52446

Files:
  include/clang/Sema/Lookup.h


Index: include/clang/Sema/Lookup.h
===
--- include/clang/Sema/Lookup.h
+++ include/clang/Sema/Lookup.h
@@ -540,7 +540,7 @@
   }
 
   /// Clears out any current state.
-  void clear() {
+  LLVM_ATTRIBUTE_REINITIALIZES void clear() {
 ResultKind = NotFound;
 Decls.clear();
 if (Paths) deletePaths(Paths);


Index: include/clang/Sema/Lookup.h
===
--- include/clang/Sema/Lookup.h
+++ include/clang/Sema/Lookup.h
@@ -540,7 +540,7 @@
   }
 
   /// Clears out any current state.
-  void clear() {
+  LLVM_ATTRIBUTE_REINITIALIZES void clear() {
 ResultKind = NotFound;
 Decls.clear();
 if (Paths) deletePaths(Paths);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52446: Annotate LookupResult::clear() as LLVM_ATTRIBUTE_REINITIALIZES to silence bugprone-use-after-move after rC342925

2018-09-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 166805.
MaskRay added a comment.

Depends on https://reviews.llvm.org/D52451 (adding LLVM_ATTRIBUTE_REINITIALIZES)


Repository:
  rC Clang

https://reviews.llvm.org/D52446

Files:
  include/clang/Sema/Lookup.h


Index: include/clang/Sema/Lookup.h
===
--- include/clang/Sema/Lookup.h
+++ include/clang/Sema/Lookup.h
@@ -540,7 +540,7 @@
   }
 
   /// Clears out any current state.
-  void clear() {
+  LLVM_ATTRIBUTE_REINITIALIZES void clear() {
 ResultKind = NotFound;
 Decls.clear();
 if (Paths) deletePaths(Paths);


Index: include/clang/Sema/Lookup.h
===
--- include/clang/Sema/Lookup.h
+++ include/clang/Sema/Lookup.h
@@ -540,7 +540,7 @@
   }
 
   /// Clears out any current state.
-  void clear() {
+  LLVM_ATTRIBUTE_REINITIALIZES void clear() {
 ResultKind = NotFound;
 Decls.clear();
 if (Paths) deletePaths(Paths);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.cpp:119
 
+/// Collect and cache all file status from the underlying file system.
+class CollectStatCacheVFS : public vfs::FileSystem {

ioeric wrote:
> Would it make sense to add a `clang::vfs::ProxyFS` that proxies calls to 
> underlying FS by default and allows to override some methods?
This makes sense, we seem to have a recurring pattern of forwarding all methods 
by default in this commit. 
+1 to the suggestion



Comment at: clangd/ClangdUnit.cpp:128
+std::error_code &EC) override {
+return FS->dir_begin(Dir, EC);
+  }

One can obtain file stats from the returned iterator.
I believe this is exactly what will start happening after Sam's patch to list 
dirs when processing include dirs.

We should probably also wrap iterators that we return and cache stats from 
those.



Comment at: clangd/ClangdUnit.cpp:149
+if (auto S = File->get()->status())
+  cacheStatus(std::move(*S));
+return File;

If we cache the stats, we should probably cache the file contents too.
Not sure how much of an extra memory this will require.

Though maybe we could get away with returning the old stat, but new file 
contents. It would look as if the file was between calls to `stat()` and 
`openForRead`.



Comment at: clangd/ClangdUnit.cpp:339
+llvm::ErrorOr status(const Twine &Path) override {
+  auto I = StatCache.find(Path.str());
+  return (I != StatCache.end()) ? I->getValue() : FS->status(Path);

We store absolute paths, but Path can be relative here.



Comment at: clangd/ClangdUnit.cpp:340
+  auto I = StatCache.find(Path.str());
+  return (I != StatCache.end()) ? I->getValue() : FS->status(Path);
+}

Maybe remove parens? 
Comparisons associate properly with ternary op and it's common enough to not 
cause any confusion with the reader.



Comment at: clangd/CodeComplete.cpp:1003
   const tooling::CompileCommand &Command;
-  PrecompiledPreamble const *Preamble;
+  const PrecompiledPreamble *Preamble;
+  const PreambleFileStatusCache *PreambleStatCache;

Maybe pass a single pointer to `PreambleData` here?



Comment at: clangd/CodeComplete.cpp:1028
 
+  IntrusiveRefCntPtr VFS = Input.VFS;
+  if (Input.PreambleStatCache)

It feels like we could apply this caching one level higher, on the TUScheduler 
level when creating the filesystem. It makes sense not only for code 
completion, but also for all other features, including rebuilds of ASTs that 
were washed out of the cache.
WDYT?



Comment at: clangd/CodeComplete.cpp:1627
   Options,
-  {FileName, Command, Preamble, Contents, Pos, std::move(VFS),
-   std::move(PCHs)});
+  {FileName, Command, Preamble, /*PreambleStatCache=*/nullptr, Contents,
+   Pos, std::move(VFS), std::move(PCHs)});

`signatureHelp` could also benefit from the cached fs, maybe pass it too?
See the other comments about applying this caching one level higher (on 
TUScheduler level) too.



Comment at: clangd/CodeComplete.h:217
+CodeCompleteResult codeComplete(PathRef FileName, Position Pos,
+const InputsAndPreamble &Input,
 IntrusiveRefCntPtr VFS,

We should not be depending `TUScheduler.h`, I suggest to pass 
`PreambleData`instead of `PrecompiledPreamble` instead.

Depending on `TUScheduler.h` our layering  in clangd: low-level implementation 
of features should not depend on higher-level building blocks like TUScheduler.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419



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


Re: [clang-tools-extra] r342730 - [clangd] Remember to serialize symbol origin in YAML.

2018-09-24 Thread Ilya Biryukov via cfe-commits
Why would we want to serialize the origin?
We only serialize and deserialize for the static index, it does not seem to
be useful to serialize origin in that scenario.

Am I missing something?

On Fri, Sep 21, 2018 at 3:06 PM Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Fri Sep 21 06:04:57 2018
> New Revision: 342730
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342730&view=rev
> Log:
> [clangd] Remember to serialize symbol origin in YAML.
>
> Modified:
> clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
> clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp?rev=342730&r1=342729&r2=342730&view=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp (original)
> +++ clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp Fri Sep 21
> 06:04:57 2018
> @@ -27,6 +27,7 @@ namespace yaml {
>
>  using clang::clangd::Symbol;
>  using clang::clangd::SymbolID;
> +using clang::clangd::SymbolOrigin;
>  using clang::clangd::SymbolLocation;
>  using clang::index::SymbolInfo;
>  using clang::index::SymbolKind;
> @@ -65,6 +66,17 @@ struct NormalizedSymbolFlag {
>uint8_t Flag = 0;
>  };
>
> +struct NormalizedSymbolOrigin {
> +  NormalizedSymbolOrigin(IO &) {}
> +  NormalizedSymbolOrigin(IO &, SymbolOrigin O) {
> +Origin = static_cast(O);
> +  }
> +
> +  SymbolOrigin denormalize(IO &) { return
> static_cast(Origin); }
> +
> +  uint8_t Origin = 0;
> +};
> +
>  template <> struct MappingTraits {
>static void mapping(IO &IO, SymbolLocation::Position &Value) {
>  IO.mapRequired("Line", Value.Line);
> @@ -102,6 +114,8 @@ template <> struct MappingTraits
>  MappingNormalization NSymbolID(IO,
> Sym.ID);
>  MappingNormalization
> NSymbolFlag(
>  IO, Sym.Flags);
> +MappingNormalization
> NSymbolOrigin(
> +IO, Sym.Origin);
>  IO.mapRequired("ID", NSymbolID->HexString);
>  IO.mapRequired("Name", Sym.Name);
>  IO.mapRequired("Scope", Sym.Scope);
> @@ -110,6 +124,7 @@ template <> struct MappingTraits
> SymbolLocation());
>  IO.mapOptional("Definition", Sym.Definition, SymbolLocation());
>  IO.mapOptional("References", Sym.References, 0u);
> +IO.mapOptional("Origin", NSymbolOrigin->Origin);
>  IO.mapOptional("Flags", NSymbolFlag->Flag);
>  IO.mapOptional("Signature", Sym.Signature);
>  IO.mapOptional("CompletionSnippetSuffix",
> Sym.CompletionSnippetSuffix);
>
> Modified: clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp?rev=342730&r1=342729&r2=342730&view=diff
>
> ==
> --- clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
> (original)
> +++ clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp Fri
> Sep 21 06:04:57 2018
> @@ -7,6 +7,7 @@
>  //
>
>  
> //===--===//
>
> +#include "index/Index.h"
>  #include "index/Serialization.h"
>  #include "index/SymbolYAML.h"
>  #include "llvm/Support/ScopedPrinter.h"
> @@ -35,6 +36,7 @@ CanonicalDeclaration:
>End:
>  Line: 1
>  Column: 1
> +Origin:4
>  Flags:1
>  Documentation:'Foo doc'
>  ReturnType:'int'
> @@ -82,6 +84,7 @@ TEST(SerializationTest, YAMLConversions)
>EXPECT_EQ(Sym1.Documentation, "Foo doc");
>EXPECT_EQ(Sym1.ReturnType, "int");
>EXPECT_EQ(Sym1.CanonicalDeclaration.FileURI, "file:///path/foo.h");
> +  EXPECT_EQ(Sym1.Origin, SymbolOrigin::Static);
>EXPECT_TRUE(Sym1.Flags & Symbol::IndexedForCodeCompletion);
>EXPECT_FALSE(Sym1.Flags & Symbol::Deprecated);
>EXPECT_THAT(Sym1.IncludeHeaders,
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length

2018-09-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

The results are accessible trough the `index.html` in each folder:
F7303310: results.rar 

@aaron.ballman a friendly reminder.


https://reviews.llvm.org/D45050



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


[PATCH] D52401: Remove redundant null pointer check in operator delete

2018-09-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

You did not get a thumbs up from any of the code owners for libc++. Reverted in 
r342938.


Repository:
  rL LLVM

https://reviews.llvm.org/D52401



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


[PATCH] D52446: Remove Found.clear() to silent bugprone-use-after-move after rC342925

2018-09-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I think the check is wrong here. We need this `clear` call to reinitialize the 
object after moving from it. Maybe that function should be annotated as 
reinitializing the object instead?


Repository:
  rC Clang

https://reviews.llvm.org/D52446



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length

2018-09-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 166802.
Charusso marked 28 inline comments as done.
Charusso added a comment.

- Refactor and better English thanks for @whisperity!

- Removed `InjectUL` option so the checker handles the special case if the 
capacity of a buffer is `int.Max()`


https://reviews.llvm.org/D45050

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tidy/bugprone/NotNullTerminatedResultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-not-null-terminated-result-in-initialization-strlen.c
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-cxx.cpp
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-other.c
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen.cpp
  test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp

Index: test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp
@@ -0,0 +1,135 @@
+// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \
+// RUN: -- -std=c++11
+
+#define __STDC_WANT_LIB_EXT1__ 1
+
+typedef unsigned int size_t;
+typedef int errno_t;
+size_t wcslen(const wchar_t *);
+void *malloc(size_t);
+void *realloc(void *, size_t);
+
+template 
+errno_t wcsncpy_s(wchar_t (&dest)[size], const wchar_t *src, size_t length);
+errno_t wcsncpy_s(wchar_t *, size_t, const wchar_t *, size_t);
+
+template 
+wchar_t *wcsncpy(wchar_t (&dest)[size], const wchar_t *src, size_t length);
+wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
+
+template 
+errno_t wcscpy_s(wchar_t (&dest)[size], const wchar_t *);
+errno_t wcscpy_s(wchar_t *, size_t, const wchar_t *);
+
+template 
+wchar_t *wcscpy(wchar_t (&dest)[size], const wchar_t *);
+wchar_t *wcscpy(wchar_t *, const wchar_t *);
+
+errno_t wmemcpy_s(wchar_t *, size_t, const wchar_t *, size_t);
+wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t);
+
+
+//===--===//
+// wmemcpy() - destination array tests
+//===--===//
+
+void bad_wmemcpy_known_dest(const wchar_t *src) {
+  wchar_t dest01[13];
+  wmemcpy(dest01, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wchar_t dest01[14];
+  // CHECK-FIXES-NEXT: wcscpy_s(dest01, src);
+}
+
+void good_wmemcpy_known_dest(const wchar_t *src) {
+  wchar_t dst01[14];
+  wcscpy_s(dst01, src);
+}
+
+//===--===//
+// wmemcpy() - length tests
+//===--===//
+
+void bad_wmemcpy_full_source_length(const wchar_t *src) {
+  wchar_t dest20[13];
+  wmemcpy(dest20, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wchar_t dest20[14];
+  // CHECK-FIXES-NEXT: wcscpy_s(dest20, src);
+}
+
+void good_wmemcpy_full_source_length(const wchar_t *src) {
+  wchar_t dst20[14];
+  wcscpy_s(dst20, src);
+}
+
+void bad_wmemcpy_partial_source_length(const wchar_t *src) {
+  wchar_t dest21[13];
+  wmemcpy(dest21, src, wcslen(src) - 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wchar_t dest21[14];
+  // CHECK-FIXES-NEXT: wcsncpy_s(dest21, src, wcslen(src) - 1);
+}
+
+void good_wmemcpy_partial_source_length(const wchar_t *src) {
+  wchar_t dst21[14];
+  wcsncpy_s(dst21, src, wcslen(src) - 1);
+}
+
+//===--===//
+// wmemcpy_s() - destination array tests
+//===--===//
+
+void bad_wmemcpy_s_unknown_dest(wchar_t *dest40, const wchar_t *src) {
+  wmemcpy_s(dest40, 13, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcscpy_s(dest40, 13, src);
+}
+
+void good_wmemcpy_s_unknown_dest(wchar_t *dst40, const wchar_t *src) {
+  wcscpy_s(dst40, 13, src);
+}
+
+void bad_wmemcpy_s_known_dest(const wchar_t *src) {
+  wchar_t dest41[13];
+  wmemcpy_s(dest41, 13, src, wcslen(src));
+  // CHECK

[PATCH] D52401: Remove redundant null pointer check in operator delete

2018-09-24 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342936: Remove redundant null pointer check in operator 
delete (authored by MaskRay, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52401

Files:
  libcxx/trunk/src/new.cpp


Index: libcxx/trunk/src/new.cpp
===
--- libcxx/trunk/src/new.cpp
+++ libcxx/trunk/src/new.cpp
@@ -135,8 +135,7 @@
 void
 operator delete(void* ptr) _NOEXCEPT
 {
-if (ptr)
-::free(ptr);
+::free(ptr);
 }
 
 _LIBCPP_WEAK
@@ -257,11 +256,10 @@
 void
 operator delete(void* ptr, std::align_val_t) _NOEXCEPT
 {
-if (ptr)
 #if defined(_LIBCPP_MSVCRT_LIKE)
-::_aligned_free(ptr);
+::_aligned_free(ptr);
 #else
-::free(ptr);
+::free(ptr);
 #endif
 }
 


Index: libcxx/trunk/src/new.cpp
===
--- libcxx/trunk/src/new.cpp
+++ libcxx/trunk/src/new.cpp
@@ -135,8 +135,7 @@
 void
 operator delete(void* ptr) _NOEXCEPT
 {
-if (ptr)
-::free(ptr);
+::free(ptr);
 }
 
 _LIBCPP_WEAK
@@ -257,11 +256,10 @@
 void
 operator delete(void* ptr, std::align_val_t) _NOEXCEPT
 {
-if (ptr)
 #if defined(_LIBCPP_MSVCRT_LIKE)
-::_aligned_free(ptr);
+::_aligned_free(ptr);
 #else
-::free(ptr);
+::free(ptr);
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-24 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

In https://reviews.llvm.org/D51340#1243453, @hans wrote:

> In https://reviews.llvm.org/D51340#1243331, @takuto.ikuta wrote:
>
> > Ping?
> >
> > This patch reduced obj size largely, and I expect this makes distributed 
> > build (like goma) faster by reducing data transferred on network.
>
>
> I'll try to look at it this week.
>
> Have you confirmed on some Chromium file, e.g. stroke_opacity_custom.cc 
> (go/stroke-opactity-custom) that the number of functions that we codegen 
> decreases as expected? I'd expect this to save a lot of compile time.


Yes, stroke_opacity_custom.obj export 18 symbols, reduced from 781 in PCH 
build, compile time is reduced from 8.2 seconds to 6.7 seconds.


https://reviews.llvm.org/D51340



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


[PATCH] D52401: Remove redundant null pointer check in operator delete

2018-09-24 Thread Yutian Li via Phabricator via cfe-commits
hotpxl accepted this revision.
hotpxl added a comment.

LGTM


Repository:
  rCXX libc++

https://reviews.llvm.org/D52401



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


[PATCH] D52401: Remove redundant null pointer check in operator delete

2018-09-24 Thread Ka Ho Ng via Phabricator via cfe-commits
khng300 accepted this revision.
khng300 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCXX libc++

https://reviews.llvm.org/D52401



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


[PATCH] D52448: [clang-format] Break before next parameter after a formatted multiline raw string parameter

2018-09-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: cfe-commits.

TODO: in progress


Repository:
  rC Clang

https://reviews.llvm.org/D52448

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  unittests/Format/FormatTestRawStrings.cpp

Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -889,6 +889,22 @@
Style));
 }
 
+TEST_F(FormatTestRawStrings, TODOBreaksBeforeParametersWithMultilineRawStrings) {
+  FormatStyle Style = getRawStringPbStyleWithColumns(60);
+  expect_eq(R"test(
+
+)test",
+format(R"test(
+int f() {
+  int a = g(x, R"pb(
+  key: 1 #
+  key: 2
+)pb", 3, 4);
+}
+)test",
+   Style));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -108,11 +108,12 @@
 
   /// Reformats a raw string literal.
   ///
-  /// \returns An extra penalty induced by reformatting the token.
-  unsigned reformatRawStringLiteral(const FormatToken &Current,
-LineState &State,
-const FormatStyle &RawStringStyle,
-bool DryRun);
+  /// \returns A pair (Penalty, IsMultiline) where Penalty is the extra penalty
+  /// induced by reformatting the token and IsMultiline is true if the formatted
+  /// token is multiline.
+  std::pair
+  reformatRawStringLiteral(const FormatToken &Current, LineState &State,
+   const FormatStyle &RawStringStyle, bool DryRun);
 
   /// If the current token is at the end of the current line, handle
   /// the transition to the next line.
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -22,6 +22,11 @@
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "format-indenter"
+#define DBG(A) \
+  LLVM_DEBUG({ \
+llvm::errs() << __func__ << ":" << __LINE__ << "::" << #A << " = " << A\
+ << "\n";  \
+  });
 
 namespace clang {
 namespace format {
@@ -1461,7 +1466,7 @@
   }
 }
 
-unsigned ContinuationIndenter::reformatRawStringLiteral(
+std::pair ContinuationIndenter::reformatRawStringLiteral(
 const FormatToken &Current, LineState &State,
 const FormatStyle &RawStringStyle, bool DryRun) {
   unsigned StartColumn = State.Column - Current.ColumnWidth;
@@ -1502,10 +1507,15 @@
   // violate the rectangle rule and visually flows within the surrounding
   // source.
   bool ContentStartsOnNewline = Current.TokenText[OldPrefixSize] == '\n';
-  unsigned NextStartColumn =
-  ContentStartsOnNewline
-  ? State.Stack.back().NestedBlockIndent + Style.IndentWidth
-  : FirstStartColumn;
+  DBG(State.Stack.back().NestedBlockIndent);
+  DBG(State.Stack.back().Indent);
+  DBG(Current.Next->TokenText);
+  unsigned CurrentIndent = (Current.Next && Current.Next->is(tok::r_paren))
+   ? State.Stack.back().NestedBlockIndent
+   : State.Stack.back().Indent;
+  unsigned NextStartColumn = ContentStartsOnNewline
+ ? CurrentIndent + Style.IndentWidth
+ : FirstStartColumn;
 
   // The last start column is the column the raw string suffix starts if it is
   // put on a newline.
@@ -1517,7 +1527,7 @@
   // indent.
   unsigned LastStartColumn = Current.NewlinesBefore
  ? FirstStartColumn - NewPrefixSize
- : State.Stack.back().NestedBlockIndent;
+ : CurrentIndent;
 
   std::pair Fixes = internal::reformat(
   RawStringStyle, RawText, {tooling::Range(0, RawText.size())},
@@ -1528,7 +1538,7 @@
   tooling::Replacements NoFixes;
   if (!NewCode) {
 State.Column += Current.ColumnWidth;
-return 0;
+return {0, Current.IsMultiline};
   }
   if (!DryRun) {
 if (NewDelimiter != OldDelimiter) {
@@ -1577,7 +1587,11 @@
   unsigned PrefixExcessCharacters =
   StartColumn + NewPrefixSize > Style.ColumnLimit ?
   StartColumn + NewPrefixSize - Style.ColumnLimit : 0;
-  return Fixes.second + PrefixExcessCharacters * Style.PenaltyExcessCharacter;
+  unsigned Penalty =
+  Fixes.second + PrefixExcessCharacters * Style.PenaltyExcessCharacter;
+  bool IsMultiline =
+  ContentStartsOnNewline || (NewCode->find('\n') != st

[PATCH] D50147: clang-format: support external styles

2018-09-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I don't understand the use-case this patch is realizing. Suppose I have a bunch 
of projects that have to share a format style. Then I can checkout them under a 
common root directory and put an appropriate .clang-format file there.


Repository:
  rC Clang

https://reviews.llvm.org/D50147



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


[PATCH] D52395: Thread safety analysis: Require exclusive lock for passing by non-const reference

2018-09-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

While most people probably just use ordinary mutexes, hence won't be affected, 
those that use read/write locks need to know when to use a shared and when to 
use an exclusive lock. What makes things hard in C++ is that through passing by 
non-const reference, an object can actually be modified although it looks like 
it's only passed as a parameter. That makes it really hard to decide whether a 
shared lock is sufficient just by reading the code, which was a major pain 
point in our project. We had to do very careful reviews to make sure we had the 
right kind of lock in every function. I'd like to offload some of that work to 
the compiler.

That's the main reason for this change: it's pretty easy to find out where a 
variable is used, but it's hard to say which uses are reads and which are 
writes in modern C++, if it weren't for const.

In https://reviews.llvm.org/D52395#1244021, @aaron.ballman wrote:

> > Unlike checking const qualifiers on member functions, there are probably 
> > not many false positives here: if a function takes a non-const reference, 
> > it will in almost all cases modify the object that we passed it.
>
> I'm not certain I agree with the predicate here. We can make that inference 
> when there *is* a const qualifier on the parameter, but I don't I think we 
> can make any assumptions about whether it will or won't modify the object 
> passed in in the absence of a const qualifier. This has come up in the past 
> for things like `C(C&)` being a valid copy constructor despite the parameter 
> being non-const.


For const qualifiers on member functions, the concern is that I might have a 
shared lock on a data structure like a std::vector and then I read stuff from 
that vector. But unless I'm reading the vector from a const member function, or 
through a const reference, I'm going to use the non-const `operator[]`. That 
operator doesn't actually modify anything, but it returns a reference that 
allows me to modify stuff. However, I'm not doing any of that, so why should 
there be a warning. I think that's a valid concern.

Effectively we have two overloads that are both not actually modifying 
anything, but the non-const variant returns a reference that does allow us to 
modify something. My thinking was that this pattern is not so common with 
function parameters. The function(s) will return a reference to a part of an 
object, and such references will typically come from member functions for which 
we don't enforce this. So even if I use a non-modifying `` like 
`std::find`, there'll be no warning because the iterators come from container 
members `begin` and `end`. (By the way, that would be easy to fix by using 
`cbegin` and `cend`.)

The way I see it, there are basically three cases of false positives:

- The function doesn't actually modify the object, but takes it as non-const 
reference nevertheless. That can be easily fixed though and I think it's a fix 
that doesn't hurt.
- The function modifies the object sometimes, but here the user is very certain 
that it won't. That might be indication of a poor design, in any event it's 
very fragile. As a developer, I would feel very anxious about this, especially 
in a larger code base.
- We have two overloads of a function, both don't modify the object, but the 
non-const variant returns a non-const reference to some part of the object. 
This isn't backed up by data, but I think this doesn't happen nearly as often 
as with member functions. There are several fixes available as well: one could 
make sure that we only have a const reference there, or make the function a 
const member, or if all else fails, by taking a const reference to the object 
we don't want to modify and then call the function with that as argument. 
That's an additional line of code like `const auto &cref = obj;` which I think 
will rarely be needed.

So basically my argument is that this can catch really nasty bugs, and false 
positives should be rare. If they occur, they can be fixed by making the code 
more const-correct. Such fixes should be easy to sell, because everybody loves 
const-correctness, and it doesn't require any annotations.

> We might need some data to back this assertion up.

Makes sense to me, but I don't have access to the largest code base in terms of 
thread safety analysis. Maybe @delesley can help here? Or I need to apply for a 
job at Google. On our own code, we're still in the very early stages of 
annotating, so I can't provide reliable data from there. I've seen thread 
safety analysis in flutter  and Chromium, 
but both don't seem to use read/write locks.




Comment at: lib/Analysis/ThreadSafety.cpp:2023
   QualType Qt = Pvd->getType();
-  if (Qt->isReferenceType())
-checkAccess(Arg, AK_Read, POK_PassByRef);
+  if (const auto* RT = dyn_cast(&*Qt)) {
+if (RT->getPointeeType().isConstQualified())

[PATCH] D52446: Remove Found.clear() to silent bugprone-use-after-move after rC342925

2018-09-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.
MaskRay added a reviewer: clang.

Repository:
  rC Clang

https://reviews.llvm.org/D52446

Files:
  lib/Sema/SemaStmt.cpp


Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2223,7 +2223,6 @@
   llvm::function_ref BuildFound,
   llvm::function_ref BuildNotFound) {
 LookupResult OldFound = std::move(Found);
-Found.clear();
 
 if (Sema::ForRangeStatus Result = BuildNotFound())
   return Result;


Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2223,7 +2223,6 @@
   llvm::function_ref BuildFound,
   llvm::function_ref BuildNotFound) {
 LookupResult OldFound = std::move(Found);
-Found.clear();
 
 if (Sema::ForRangeStatus Result = BuildNotFound())
   return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342929 - Driver: render arguments for the embedded bitcode correctly

2018-09-24 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Sep 24 16:50:02 2018
New Revision: 342929

URL: http://llvm.org/viewvc/llvm-project?rev=342929&view=rev
Log:
Driver: render arguments for the embedded bitcode correctly

When embedding bitcode, only a subset of the arguments should be recorded into
the bitcode compilation commandline.  The frontend job is split into two jobs,
one which will generate the bitcode.  Ensure that the arguments for the
compilation to bitcode is properly stripped so that the embedded arguments are
the permitted subset.

Added:
cfe/trunk/test/Driver/fembed-bitcode.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=342929&r1=342928&r2=342929&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Sep 24 16:50:02 
2018
@@ -210,6 +210,8 @@ def warn_drv_omp_offload_target_duplicat
 def warn_drv_omp_offload_target_missingbcruntime : Warning<
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
   InGroup;
+def err_drv_unsupported_embed_bitcode
+: Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=342929&r1=342928&r2=342929&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Sep 24 16:50:02 2018
@@ -1297,21 +1297,28 @@ static bool isNoCommonDefault(const llvm
   }
 }
 
-void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
- ArgStringList &CmdArgs, bool KernelOrKext) const {
+namespace {
+void RenderARMABI(const llvm::Triple &Triple, const ArgList &Args,
+  ArgStringList &CmdArgs) {
   // Select the ABI to use.
   // FIXME: Support -meabi.
   // FIXME: Parts of this are duplicated in the backend, unify this somehow.
   const char *ABIName = nullptr;
-  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
+  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
 ABIName = A->getValue();
-  else {
+  } else {
 std::string CPU = getCPUName(Args, Triple, /*FromAs*/ false);
 ABIName = llvm::ARM::computeDefaultTargetABI(Triple, CPU).data();
   }
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName);
+}
+}
+
+void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
+ ArgStringList &CmdArgs, bool KernelOrKext) const {
+  RenderARMABI(Triple, Args, CmdArgs);
 
   // Determine floating point ABI from the options & target defaults.
   arm::FloatABI ABI = arm::getARMFloatABI(getToolChain(), Args);
@@ -1423,6 +1430,22 @@ void Clang::RenderTargetOptions(const ll
   }
 }
 
+namespace {
+void RenderAArch64ABI(const llvm::Triple &Triple, const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  const char *ABIName = nullptr;
+  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
+ABIName = A->getValue();
+  else if (Triple.isOSDarwin())
+ABIName = "darwinpcs";
+  else
+ABIName = "aapcs";
+
+  CmdArgs.push_back("-target-abi");
+  CmdArgs.push_back(ABIName);
+}
+}
+
 void Clang::AddAArch64TargetArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
@@ -1436,16 +1459,7 @@ void Clang::AddAArch64TargetArgs(const A
 options::OPT_mno_implicit_float, true))
 CmdArgs.push_back("-no-implicit-float");
 
-  const char *ABIName = nullptr;
-  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
-ABIName = A->getValue();
-  else if (Triple.isOSDarwin())
-ABIName = "darwinpcs";
-  else
-ABIName = "aapcs";
-
-  CmdArgs.push_back("-target-abi");
-  CmdArgs.push_back(ABIName);
+  RenderAArch64ABI(Triple, Args, CmdArgs);
 
   if (Arg *A = Args.getLastArg(options::OPT_mfix_cortex_a53_835769,
options::OPT_mno_fix_cortex_a53_835769)) {
@@ -3378,13 +3392,116 @@ void Clang::ConstructJob(Compilation &C,
 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
 
   // Embed-bitcode option.
+  // Only white-listed flags below are allowed to be embedded.
   if (C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO() &&
   (isa(JA) || isa(JA))) {
 // Add flags implied by -fem

[PATCH] D52401: Remove redundant null pointer check in operator delete

2018-09-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping :)


Repository:
  rCXX libc++

https://reviews.llvm.org/D52401



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


r342927 - [www] Change 'Clang 7' items from yellow to green now Clang 7 is

2018-09-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Sep 24 16:21:09 2018
New Revision: 342927

URL: http://llvm.org/viewvc/llvm-project?rev=342927&view=rev
Log:
[www] Change 'Clang 7' items from yellow to green now Clang 7 is
released.

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

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=342927&r1=342926&r2=342927&view=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Mon Sep 24 16:21:09 2018
@@ -2021,7 +2021,7 @@ of class templates
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#330";>330
 CD4
 Qualification conversions and pointers to arrays of pointers
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#331";>331
@@ -7093,7 +7093,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1213";>1213
 CD3
 Array subscripting and xvalues
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1214";>1214
@@ -9847,7 +9847,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1672";>1672
 CD4
 Layout compatibility with multiple empty bases
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1673";>1673
@@ -9937,7 +9937,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1687";>1687
 C++14
 Conversions of operands of built-in operators
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1688";>1688
@@ -9991,7 +9991,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1696";>1696
 CD4
 Temporary lifetime and non-static data member initializers
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1697";>1697
@@ -10693,7 +10693,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1813";>1813
 CD4
 Direct vs indirect bases in standard-layout classes
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1814";>1814
@@ -11101,7 +11101,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1881";>1881
 CD4
 Standard-layout classes and unnamed bit-fields
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1882";>1882
@@ -12535,7 +12535,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2120";>2120
 CD4
 Array as first non-static data member in standard-layout class
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2121";>2121
@@ -13189,7 +13189,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2229";>2229
 tentatively ready
 Volatile unnamed bit-fields
-Clang 7
+Clang 7
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#2230";>2230

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=342927&r1=342926&r2=342927&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Mon Sep 24 16:21:09 2018
@@ -707,7 +707,7 @@ version 3.7.
   
 
 http://wg21.link/p0620r1";>P0620R0 (DR)
-Clang 7
+Clang 7
   
   
 
@@ -1025,7 +1025,7 @@ and library features that are not part o
   
 
 
-  
+  
 Clang 7 (http://wg21.link/p0096r5";>P0096R5)
   
 

Modified: cfe/trunk/www/make_cxx_dr_status
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/make_cxx_dr_status?rev=342927&r1=342926&r2=342927&view=diff
==
--- cfe/trunk/www/make_cxx_dr_status (original)
+++ cfe/trunk/www/make_cxx_dr_status Mon Sep 24 16:21:09 2018
@@ -111,9 +111,6 @@ def availability(issue):
   elif status == '8':
 avail = 'SVN'
 avail_style = ' class="svn"'
-  elif status == '7':
-avail = 'Clang 7'
-avail_style = ' class="svn"'
   elif re.match('^[0-9]+\.?[0-9]*', status):
 avail = 'Clang %s' % status
 avail_style = ' class="full"'


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


[PATCH] D52445: [Index] Use locations to uniquify function-scope BindingDecl USR

2018-09-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: akyrtzi, arphaman.
Herald added a subscriber: cfe-commits.

This makes BindingDecl's of the same name have different USRs, so that 
references can be correctly attributed.

  int a[1] = {};
  { auto [x] = a; x; }
  { auto [x] = a; x; }


Repository:
  rC Clang

https://reviews.llvm.org/D52445

Files:
  lib/Index/USRGeneration.cpp


Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (D->getParentFunctionOrMethod() && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);


Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (D->getParentFunctionOrMethod() && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342926 - [www] Update cxx_status to mark P0962R1 as done.

2018-09-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Sep 24 16:19:11 2018
New Revision: 342926

URL: http://llvm.org/viewvc/llvm-project?rev=342926&view=rev
Log:
[www] Update cxx_status to mark P0962R1 as done.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=342926&r1=342925&r2=342926&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Mon Sep 24 16:19:11 2018
@@ -318,7 +318,7 @@ with http://libcxx.llvm.org/";>l
   
 
 http://wg21.link/p0962r1";>P0962R1 (DR)
-No
+SVN
   
 
   Explicit virtual overrides


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


r342925 - P0962R1: only use the member form of 'begin' and 'end' in a range-based

2018-09-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Sep 24 16:17:44 2018
New Revision: 342925

URL: http://llvm.org/viewvc/llvm-project?rev=342925&view=rev
Log:
P0962R1: only use the member form of 'begin' and 'end' in a range-based
for loop if both members exist.

This resolves a DR whereby an errant 'begin' or 'end' member in a base
class could result in a derived class not being usable as a range with
non-member 'begin' and 'end'.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
cfe/trunk/test/SemaCXX/for-range-dereference.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=342925&r1=342924&r2=342925&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep 24 16:17:44 
2018
@@ -2254,8 +2254,6 @@ def err_for_range_incomplete_type : Erro
   "cannot use incomplete type %0 as a range">;
 def err_for_range_iter_deduction_failure : Error<
   "cannot use type %0 as an iterator">;
-def err_for_range_member_begin_end_mismatch : Error<
-  "range type %0 has '%select{begin|end}1' member but no '%select{end|begin}1' 
member">;
 def ext_for_range_begin_end_types_differ : ExtWarn<
   "'begin' and 'end' returning different types (%0 and %1) is a C++17 
extension">,
   InGroup;
@@ -2268,6 +2266,8 @@ def note_in_for_range: Note<
 def err_for_range_invalid: Error<
   "invalid range expression of type %0; no viable '%select{begin|end}1' "
   "function available">;
+def note_for_range_member_begin_end_ignored : Note<
+  "member is not a candidate because range type %0 has no 
'%select{end|begin}1' member">;
 def err_range_on_array_parameter : Error<
   "cannot build range expression with array function parameter %0 since "
   "parameter with array type %1 is treated as pointer type %2">;

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=342925&r1=342924&r2=342925&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Sep 24 16:17:44 2018
@@ -2149,6 +2149,56 @@ BuildNonArrayForRange(Sema &SemaRef, Exp
  Sema::LookupMemberName);
   LookupResult EndMemberLookup(SemaRef, EndNameInfo, Sema::LookupMemberName);
 
+  auto BuildBegin = [&] {
+*BEF = BEF_begin;
+Sema::ForRangeStatus RangeStatus =
+SemaRef.BuildForRangeBeginEndCall(ColonLoc, ColonLoc, BeginNameInfo,
+  BeginMemberLookup, CandidateSet,
+  BeginRange, BeginExpr);
+
+if (RangeStatus != Sema::FRS_Success) {
+  if (RangeStatus == Sema::FRS_DiagnosticIssued)
+SemaRef.Diag(BeginRange->getBeginLoc(), diag::note_in_for_range)
+<< ColonLoc << BEF_begin << BeginRange->getType();
+  return RangeStatus;
+}
+if (!CoawaitLoc.isInvalid()) {
+  // FIXME: getCurScope() should not be used during template instantiation.
+  // We should pick up the set of unqualified lookup results for operator
+  // co_await during the initial parse.
+  *BeginExpr = SemaRef.ActOnCoawaitExpr(SemaRef.getCurScope(), ColonLoc,
+BeginExpr->get());
+  if (BeginExpr->isInvalid())
+return Sema::FRS_DiagnosticIssued;
+}
+if (FinishForRangeVarDecl(SemaRef, BeginVar, BeginExpr->get(), ColonLoc,
+  diag::err_for_range_iter_deduction_failure)) {
+  NoteForRangeBeginEndFunction(SemaRef, BeginExpr->get(), *BEF);
+  return Sema::FRS_DiagnosticIssued;
+}
+return Sema::FRS_Success;
+  };
+
+  auto BuildEnd = [&] {
+*BEF = BEF_end;
+Sema::ForRangeStatus RangeStatus =
+SemaRef.BuildForRangeBeginEndCall(ColonLoc, ColonLoc, EndNameInfo,
+  EndMemberLookup, CandidateSet,
+  EndRange, EndExpr);
+if (RangeStatus != Sema::FRS_Success) {
+  if (RangeStatus == Sema::FRS_DiagnosticIssued)
+SemaRef.Diag(EndRange->getBeginLoc(), diag::note_in_for_range)
+<< ColonLoc << BEF_end << EndRange->getType();
+  return RangeStatus;
+}
+if (FinishForRangeVarDecl(SemaRef, EndVar, EndExpr->get(), ColonLoc,
+  diag::err_for_range_iter_deduction_failure)) {
+  NoteForRangeBeginEndFunction(SemaRef, EndExpr->get(), *BEF);
+  return Sema::FRS_DiagnosticIssued;
+}
+return Sema::FRS_Success;
+  };
+
   if (CXXRecordDecl *D = RangeType->getAsCXXRecordDecl()) {
 // - if _RangeT is a class type, the unqualified-ids begin and end are

[PATCH] D52398: Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D52398#1244074, @aaronpuchert wrote:

> No problem. Thanks for reviewing! I'm terribly sorry to be bombarding the two 
> of you with so many review requests lately, and I hope it'll soon be over.


No apologies necessary -- I love and appreciate the work you've been doing on 
thread safety analysis!


Repository:
  rC Clang

https://reviews.llvm.org/D52398



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


r342924 - [CUDA] Added basic support for compiling with CUDA-10.0

2018-09-24 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon Sep 24 16:10:44 2018
New Revision: 342924

URL: http://llvm.org/viewvc/llvm-project?rev=342924&view=rev
Log:
[CUDA] Added basic support for compiling with CUDA-10.0

Modified:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/lib/Basic/Cuda.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/include/clang/Basic/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=342924&r1=342923&r2=342924&view=diff
==
--- cfe/trunk/include/clang/Basic/Cuda.h (original)
+++ cfe/trunk/include/clang/Basic/Cuda.h Mon Sep 24 16:10:44 2018
@@ -24,7 +24,8 @@ enum class CudaVersion {
   CUDA_90,
   CUDA_91,
   CUDA_92,
-  LATEST = CUDA_92,
+  CUDA_100,
+  LATEST = CUDA_100,
 };
 const char *CudaVersionToString(CudaVersion V);
 
@@ -47,6 +48,7 @@ enum class CudaArch {
   SM_62,
   SM_70,
   SM_72,
+  SM_75,
   GFX600,
   GFX601,
   GFX700,
@@ -82,6 +84,7 @@ enum class CudaVirtualArch {
   COMPUTE_62,
   COMPUTE_70,
   COMPUTE_72,
+  COMPUTE_75,
   COMPUTE_AMDGCN,
 };
 const char *CudaVirtualArchToString(CudaVirtualArch A);

Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=342924&r1=342923&r2=342924&view=diff
==
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Mon Sep 24 16:10:44 2018
@@ -22,6 +22,8 @@ const char *CudaVersionToString(CudaVers
 return "9.1";
   case CudaVersion::CUDA_92:
 return "9.2";
+  case CudaVersion::CUDA_100:
+return "10.0";
   }
   llvm_unreachable("invalid enum");
 }
@@ -60,6 +62,8 @@ const char *CudaArchToString(CudaArch A)
 return "sm_70";
   case CudaArch::SM_72:
 return "sm_72";
+  case CudaArch::SM_75:
+return "sm_75";
   case CudaArch::GFX600: // tahiti
 return "gfx600";
   case CudaArch::GFX601: // pitcairn, verde, oland,hainan
@@ -106,6 +110,7 @@ CudaArch StringToCudaArch(llvm::StringRe
   .Case("sm_62", CudaArch::SM_62)
   .Case("sm_70", CudaArch::SM_70)
   .Case("sm_72", CudaArch::SM_72)
+  .Case("sm_75", CudaArch::SM_75)
   .Case("gfx600", CudaArch::GFX600)
   .Case("gfx601", CudaArch::GFX601)
   .Case("gfx700", CudaArch::GFX700)
@@ -152,6 +157,8 @@ const char *CudaVirtualArchToString(Cuda
 return "compute_70";
   case CudaVirtualArch::COMPUTE_72:
 return "compute_72";
+  case CudaVirtualArch::COMPUTE_75:
+return "compute_75";
   case CudaVirtualArch::COMPUTE_AMDGCN:
 return "compute_amdgcn";
   }
@@ -173,6 +180,7 @@ CudaVirtualArch StringToCudaVirtualArch(
   .Case("compute_62", CudaVirtualArch::COMPUTE_62)
   .Case("compute_70", CudaVirtualArch::COMPUTE_70)
   .Case("compute_72", CudaVirtualArch::COMPUTE_72)
+  .Case("compute_75", CudaVirtualArch::COMPUTE_75)
   .Case("compute_amdgcn", CudaVirtualArch::COMPUTE_AMDGCN)
   .Default(CudaVirtualArch::UNKNOWN);
 }
@@ -210,6 +218,8 @@ CudaVirtualArch VirtualArchForCudaArch(C
 return CudaVirtualArch::COMPUTE_70;
   case CudaArch::SM_72:
 return CudaVirtualArch::COMPUTE_72;
+  case CudaArch::SM_75:
+return CudaVirtualArch::COMPUTE_75;
   case CudaArch::GFX600:
   case CudaArch::GFX601:
   case CudaArch::GFX700:
@@ -252,6 +262,8 @@ CudaVersion MinVersionForCudaArch(CudaAr
 return CudaVersion::CUDA_90;
   case CudaArch::SM_72:
 return CudaVersion::CUDA_91;
+  case CudaArch::SM_75:
+return CudaVersion::CUDA_100;
   case CudaArch::GFX600:
   case CudaArch::GFX601:
   case CudaArch::GFX700:

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.cpp?rev=342924&r1=342923&r2=342924&view=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp Mon Sep 24 16:10:44 2018
@@ -221,6 +221,8 @@ void NVPTXTargetInfo::getTargetDefines(c
 return "700";
   case CudaArch::SM_72:
 return "720";
+  case CudaArch::SM_75:
+return "750";
   }
   llvm_unreachable("unhandled CudaArch");
 }();

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=342924&r1=342923&r2=342924&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Mon Sep 24 16:10:44 2018
@@ -59,6 +59,8 @@ static CudaVersion ParseCudaVersionFile(
 return CudaVersion::CUDA_91;
   if (Major == 9 && Minor == 2)
 return CudaVersion::CUDA_92;
+  if (Major == 10 && Minor == 0)
+return CudaVersion::CUDA_100;
   return CudaVersion:

[PATCH] D52443: Thread safety analysis: Examine constructor arguments

2018-09-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

There is a (technical) merge conflict between this change and 
https://reviews.llvm.org/D52395, but that shouldn't be of any concern for the 
review. The issues are rather independent. (I think.)


Repository:
  rC Clang

https://reviews.llvm.org/D52443



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


[PATCH] D52398: Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

2018-09-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

No problem. Thanks for reviewing! I'm terribly sorry to be bombarding the two 
of you with so many review requests lately, and I hope it'll soon be over.


Repository:
  rC Clang

https://reviews.llvm.org/D52398



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


[PATCH] D52443: Thread safety analysis: Examine constructor arguments

2018-09-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley.
Herald added a subscriber: cfe-commits.

Instead of only examining call arguments, we also examine constructor
arguments applying the same rules.

That was an oppurtunity for refactoring the examination procedure to
work with iterators instead of integer indices. For the case of
CallExprs no functional change is intended.


Repository:
  rC Clang

https://reviews.llvm.org/D52443

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -4999,8 +4999,13 @@
 void operator/(const Foo& f, const Foo& g);
 void operator*(const Foo& f, const Foo& g);
 
-
-
+// Test constructors.
+struct FooRead {
+  FooRead(const Foo &);
+};
+struct FooWrite {
+  FooWrite(Foo &);
+};
 
 class Bar {
 public:
@@ -5032,6 +5037,9 @@
 read2(10, foo);// expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
 destroy(mymove(foo));  // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
 
+FooRead reader(foo);   // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+FooWrite writer(foo);  // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+
 mwrite1(foo);   // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
 mwrite2(10, foo);   // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
 mread1(foo);// expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
Index: lib/Analysis/ThreadSafety.cpp
===
--- lib/Analysis/ThreadSafety.cpp
+++ lib/Analysis/ThreadSafety.cpp
@@ -1534,6 +1534,10 @@
  ProtectedOperationKind POK = POK_VarAccess);
 
   void handleCall(const Expr *Exp, const NamedDecl *D, VarDecl *VD = nullptr);
+  void ExamineCallArguments(const FunctionDecl *FD,
+CallExpr::const_arg_iterator ArgBegin,
+CallExpr::const_arg_iterator ArgEnd,
+bool OperatorFun);
 
 public:
   BuildLockset(ThreadSafetyAnalyzer *Anlzr, CFGBlockInfo &Info)
@@ -1934,6 +1938,43 @@
   checkAccess(CE->getSubExpr(), AK_Read);
 }
 
+void BuildLockset::ExamineCallArguments(const FunctionDecl *FD,
+CallExpr::const_arg_iterator ArgBegin,
+CallExpr::const_arg_iterator ArgEnd,
+bool OperatorFun) {
+  // Currently we can't do anything if we don't know the function declaration.
+  if (!FD)
+return;
+
+  // NO_THREAD_SAFETY_ANALYSIS does double duty here.  Normally it
+  // only turns off checking within the body of a function, but we also
+  // use it to turn off checking in arguments to the function.  This
+  // could result in some false negatives, but the alternative is to
+  // create yet another attribute.
+  if (FD->hasAttr())
+return;
+
+  const ArrayRef Params = FD->parameters();
+  auto Param = Params.begin();
+  if (OperatorFun) {
+// Ignore the first argument of operators; it's been checked elsewhere.
+++ArgBegin;
+
+// For method operators, the first argument is the implicit self argument,
+// and doesn't appear in the FunctionDecl, but for non-methods it does.
+if (!isa(FD))
+  ++Param;
+  }
+
+  // There can be default arguments, so we stop when one iterator is at end().
+  for (auto Arg = ArgBegin; Param != Params.end() && Arg != ArgEnd;
+   ++Param, ++Arg) {
+QualType Qt = (*Param)->getType();
+if (Qt->isReferenceType())
+  checkAccess(*Arg, AK_Read, POK_PassByRef);
+  }
+}
+
 void BuildLockset::VisitCallExpr(const CallExpr *Exp) {
   bool ExamineArgs = true;
   bool OperatorFun = false;
@@ -1990,41 +2031,8 @@
   }
 
   if (ExamineArgs) {
-if (const FunctionDecl *FD = Exp->getDirectCallee()) {
-  // NO_THREAD_SAFETY_ANALYSIS does double duty here.  Normally it
-  // only turns off checking within the body of a function, but we also
-  // use it to turn off checking in arguments to the function.  This
-  // could result in some false negatives, but the alternative is to
-  // create yet another attribute.
-  if (!FD->hasAttr()) {
-unsigned Fn = FD->getNumParams();
-unsigned Cn = Exp->getNumArgs();
-unsigned Skip = 0;
-
-unsigned i = 0;
-if (OperatorFun) {
-  if (isa(FD)) {
-// First arg in operator call is implicit self argument,
-// and doesn't appear in the FunctionDecl.
-Skip = 1;
-Cn

[PATCH] D52395: Thread safety analysis: Require exclusive lock for passing by non-const reference

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> Unlike checking const qualifiers on member functions, there are probably not 
> many false positives here: if a function takes a non-const reference, it will 
> in almost all cases modify the object that we passed it.

I'm not certain I agree with the predicate here. We can make that inference 
when there *is* a const qualifier on the parameter, but I don't I think we can 
make any assumptions about whether it will or won't modify the object passed in 
in the absence of a const qualifier. This has come up in the past for things 
like `C(C&)` being a valid copy constructor despite the parameter being 
non-const. We might need some data to back this assertion up.




Comment at: lib/Analysis/ThreadSafety.cpp:2023
   QualType Qt = Pvd->getType();
-  if (Qt->isReferenceType())
-checkAccess(Arg, AK_Read, POK_PassByRef);
+  if (const auto* RT = dyn_cast(&*Qt)) {
+if (RT->getPointeeType().isConstQualified())

This isn't specific to your changes, but this gives me the impression we don't 
distinguish between rvalue references and lvalue references, but that may be 
something of interest in here.


Repository:
  rC Clang

https://reviews.llvm.org/D52395



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


[PATCH] D52440: Emit lifetime markers for temporary function parameter aggregates

2018-09-24 Thread Ian Tessier via Phabricator via cfe-commits
itessier created this revision.
itessier added a reviewer: rjmccall.
Herald added a subscriber: cfe-commits.

Clang is not emitting lifetime markers for temporary function parameters, so 
more stack space is potentially being allocated than necessary.

A new parameter is added to the CreateAggTemp and EmitAnyExprToTemp functions 
to indicate whether to emit lifetime markers for aggregates, so that the 
EmitCallArg function can request them when evaluating an arg. The parameter is 
defaulted to false so that the behaviour of other callers is not affected.


Repository:
  rC Clang

https://reviews.llvm.org/D52440

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  test/CodeGenCXX/stack-reuse-miscompile.cpp
  test/CodeGenCXX/stack-reuse.cpp

Index: test/CodeGenCXX/stack-reuse.cpp
===
--- test/CodeGenCXX/stack-reuse.cpp
+++ test/CodeGenCXX/stack-reuse.cpp
@@ -27,7 +27,9 @@
 extern S_small foo_small();
 extern S_large foo_large();
 extern void bar_small(S_small*);
+extern void bar_small(S_small);
 extern void bar_large(S_large*);
+extern void bar_large(S_large);
 
 // Prevent mangling of function names.
 extern "C" {
@@ -130,6 +132,36 @@
   }
 }
 
+void small_temp_object() {
+// CHECK-LABEL: define void @small_temp_object
+// CHECK: call void @llvm.lifetime.start
+// CHECK: call void @_Z9foo_smallv
+// CHECK: call void @_Z9bar_small7S_small
+// CHECK: call void @llvm.lifetime.end
+// CHECK: call void @llvm.lifetime.start
+// CHECK: call void @_Z9foo_smallv
+// CHECK: call void @_Z9bar_small7S_small
+// CHECK: call void @llvm.lifetime.end
+
+  bar_small(foo_small());
+  bar_small(foo_small());
+}
+
+void large_temp_object() {
+// CHECK-LABEL: define void @large_temp_object
+// CHECK: call void @llvm.lifetime.start
+// CHECK: call void @_Z9foo_largev
+// CHECK: call void @_Z9bar_large7S_large
+// CHECK: call void @llvm.lifetime.end
+// CHECK: call void @llvm.lifetime.start
+// CHECK: call void @_Z9foo_largev
+// CHECK: call void @_Z9bar_large7S_large
+// CHECK: call void @llvm.lifetime.end
+
+  bar_large(foo_large());
+  bar_large(foo_large());
+}
+
 int large_combiner_test(S_large s) {
 // CHECK-LABEL: define i32 @large_combiner_test
 // CHECK: [[T2:%.*]] = alloca %struct.Combiner
Index: test/CodeGenCXX/stack-reuse-miscompile.cpp
===
--- test/CodeGenCXX/stack-reuse-miscompile.cpp
+++ test/CodeGenCXX/stack-reuse-miscompile.cpp
@@ -19,33 +19,39 @@
 
 const char * f(S s)
 {
-// It's essential that the lifetimes of all three T temporaries here are
+// It's essential that the lifetimes of the first three T temporaries here are
 // overlapping. They must all remain alive through the call to str().
 //
 // CHECK: [[T1:%.*]] = alloca %class.T, align 4
 // CHECK: [[T2:%.*]] = alloca %class.T, align 4
 // CHECK: [[T3:%.*]] = alloca %class.T, align 4
+// CHECK: [[T4:%.*]] = alloca %class.S, align 4
 //
 // FIXME: We could defer starting the lifetime of the return object of concat
 // until the call.
 // CHECK: [[T1i8:%.*]] = bitcast %class.T* [[T1]] to i8*
 // CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T1i8]])
 //
 // CHECK: [[T2i8:%.*]] = bitcast %class.T* [[T2]] to i8*
 // CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T2i8]])
-// CHECK: [[T4:%.*]] = call %class.T* @_ZN1TC1EPKc(%class.T* [[T2]], i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0))
+// CHECK: [[T5:%.*]] = call %class.T* @_ZN1TC1EPKc(%class.T* [[T2]], i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0))
 //
 // CHECK: [[T3i8:%.*]] = bitcast %class.T* [[T3]] to i8*
 // CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T3i8]])
-// CHECK: [[T5:%.*]] = call %class.T* @_ZN1TC1E1S(%class.T* [[T3]], [2 x i32] %{{.*}})
+//
+// CHECK: [[T4i8:%.*]] = bitcast %class.S* [[T4]] to i8*
+// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[T4i8]])
+//
+// CHECK: [[T6:%.*]] = call %class.T* @_ZN1TC1E1S(%class.T* [[T3]], [2 x i32] %{{.*}})
 //
 // CHECK: call void @_ZNK1T6concatERKS_(%class.T* sret [[T1]], %class.T* [[T2]], %class.T* dereferenceable(16) [[T3]])
-// CHECK: [[T6:%.*]] = call i8* @_ZNK1T3strEv(%class.T* [[T1]])
+// CHECK: [[T7:%.*]] = call i8* @_ZNK1T3strEv(%class.T* [[T1]])
 //
 // CHECK: call void @llvm.lifetime.end.p0i8(
 // CHECK: call void @llvm.lifetime.end.p0i8(
 // CHECK: call void @llvm.lifetime.end.p0i8(
-// CHECK: ret i8* [[T6]]
+// CHECK: call void @llvm.lifetime.end.p0i8(
+// CHECK: ret i8* [[T7]]
 
   return T("[").concat(T(s)).str();
 }
Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -322,6 +322,10 @@
 // WIN32: call void @llvm.memset.p0i8.i32(
 // WIN32: call i32 @"?getS@PR37146@@YA?AUS@1@

[PATCH] D52437: [CUDA] Add preliminary support for CUDA 10.0

2018-09-24 Thread Andrea Bocci via Phabricator via cfe-commits
fwyzard added a comment.

Thanks, indeed I missed some of the changes related to SM 7.5.


Repository:
  rC Clang

https://reviews.llvm.org/D52437



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


[PATCH] D52437: [CUDA] Add preliminary support for CUDA 10.0

2018-09-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Great to see someone beating me to add support for a new CUDA version. :-)
I've posted my patch in https://reviews.llvm.org/D52438. It's very similar to 
yours with a couple of  other necessary changes.


Repository:
  rC Clang

https://reviews.llvm.org/D52437



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


[PATCH] D52438: [CUDA] Add basic support for CUDA-10.0

2018-09-24 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, hiraditya, sanjoy, jholewinski.

https://reviews.llvm.org/D52438

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -54,6 +54,8 @@
  "Target SM 7.0">;
 def SM72 : SubtargetFeature<"sm_72", "SmVersion", "72",
  "Target SM 7.2">;
+def SM75 : SubtargetFeature<"sm_75", "SmVersion", "75",
+ "Target SM 7.5">;
 
 // PTX Versions
 def PTX32 : SubtargetFeature<"ptx32", "PTXVersion", "32",
@@ -72,6 +74,8 @@
  "Use PTX version 6.0">;
 def PTX61 : SubtargetFeature<"ptx61", "PTXVersion", "61",
  "Use PTX version 6.1">;
+def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
+ "Use PTX version 6.3">;
 
 //===--===//
 // NVPTX supported processors.
@@ -94,6 +98,7 @@
 def : Proc<"sm_62", [SM62, PTX50]>;
 def : Proc<"sm_70", [SM70, PTX60]>;
 def : Proc<"sm_72", [SM72, PTX61]>;
+def : Proc<"sm_75", [SM75, PTX63]>;
 
 def NVPTXInstrInfo : InstrInfo {
 }
Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,10 +62,15 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
 #error "Unsupported CUDA version!"
 #endif
 
+#pragma push_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__")
+#if CUDA_VERSION >= 1
+#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#endif
+
 // Make largest subset of device functions available during host
 // compilation -- SM_35 for the time being.
 #ifndef __CUDA_ARCH__
@@ -419,6 +424,7 @@
 #pragma pop_macro("dim3")
 #pragma pop_macro("uint3")
 #pragma pop_macro("__USE_FAST_MATH__")
+#pragma pop_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__")
 
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -59,6 +59,8 @@
 return CudaVersion::CUDA_91;
   if (Major == 9 && Minor == 2)
 return CudaVersion::CUDA_92;
+  if (Major == 10 && Minor == 0)
+return CudaVersion::CUDA_100;
   return CudaVersion::UNKNOWN;
 }
 
@@ -165,7 +167,7 @@
   if (FS.exists(FilePath)) {
 for (const char *GpuArchName :
  {"sm_30", "sm_32", "sm_35", "sm_37", "sm_50", "sm_52", "sm_53",
-  "sm_60", "sm_61", "sm_62", "sm_70", "sm_72"}) {
+  "sm_60", "sm_61", "sm_62", "sm_70", "sm_72", "sm_75"}) {
   const CudaArch GpuArch = StringToCudaArch(GpuArchName);
   if (Version >= MinVersionForCudaArch(GpuArch) &&
   Version <= MaxVersionForCudaArch(GpuArch))
@@ -628,6 +630,9 @@
   // defaults to. Use PTX4.2 by default, which is the PTX version that came with
   // CUDA-7.0.
   const char *PtxFeature = "+ptx42";
+  // TODO(tra): CUDA-10+ needs PTX 6.3 to support new features. However that
+  // requires fair amount of work on LLVM side. We'll keep using PTX 6.1 until
+  // all prerequisites are in place.
   if (CudaInstallation.version() >= CudaVersion::CUDA_91) {
 // CUDA-9.1 uses new instructions that are only available in PTX6.1+
 PtxFeature = "+ptx61";
Index: clang/lib/Basic/Targets/NVPTX.cpp
===
--- clang/lib/Basic/Targets/NVPTX.cpp
+++ clang/lib/Basic/Targets/NVPTX.cpp
@@ -221,6 +221,8 @@
 return "700";
   case CudaArch::SM_72:
 return "720";
+  case CudaArch::SM_75:
+return "750";
   }
   llvm_unreachable("unhandled CudaArch");
 }();
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -22,6 +22,8 @@
 return "9.1";
   case CudaVersion::CUDA_92:
 return "9.2";
+  case CudaVersion::CUDA_100:
+return "10.0";
   }
   llvm_unreachable("invalid enum");
 }
@@ -60,6 +62,8 @@
 return "sm_70";
   case CudaArch::SM_72:
 return "sm_72";
+  case CudaArch::SM_75:
+return "sm_75";
   case CudaArch::GFX600: // tahiti
 return "gfx600";
   case CudaArch::GFX601: // pitcairn, verde, oland,hainan
@@ -106,6 +110,7 @@
   .C

[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

2018-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Of the intrinsics we plan to implement, it seems that the ordering of 
legalization affects specifically the fixed point mul/div intrinsics since if 
they get expanded into other nodes, we will need to check again for legal types 
since performing scaled mul/div requires larger integers for a buffer. The 
remaining ones though I don't think require any extra legalization. Both 
saturation and saturated add/sub can be done without different sized operands.

For ssat specifically, I think this patch has most of the necessary code to 
have this ready for a formal review. I removed the passes for this one since it 
seems all expansion can be done safely in the DAG without any extra type or 
operation legalization.




Comment at: include/llvm/CodeGen/ISDOpcodes.h:264
+/// signed value is returned instead.
+SSAT,
+

ebevhan wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > With the way the rest is written, it doesn't seem like this DAG opcode is 
> > > ever used.
> > > 
> > > The way you would normally do this in DAG would be to:
> > > * Lower the intrinsic to this node in SelectionDAGBuilder, regardless of 
> > > type or operation legality
> > > * Deal with illegally typed nodes in LegalizeTypes
> > > * Deal with illegal opcodes in LegalizeDAG
> > > 
> > > I think that doing the legalization in DAG for some of the fixed-point 
> > > operations could be hard. Opcode legalization occurs after type 
> > > legalization, so the legalization for opcodes that have legal types but 
> > > where the target doesn't actually support the operation must be able to 
> > > legalize to valid types. I think this could get unnecessarily tricky. For 
> > > example, an N-bit, M-scale fixsmul must actually be done as N+M-bits or 
> > > greater, and if that type (or anything greater than it) isn't legal it 
> > > gets hairy.
> > > 
> > > There's also the issue of how a target specifies legality of these 
> > > operations. A target might support ISD::FIXSMUL on MVT::i16, but only 
> > > with a scale of 15. However, there's currently no way of expressing 
> > > legality of an operation based on anything than the type (in general). 
> > > Something would probably have to be added to 
> > > TargetLowering/TargetLoweringBase that lets targets specify the legality 
> > > of these operations. (The same issue applies to ssaturate; it might be 
> > > legal to do 'i32 ssaturate (X, 15)', but not 'i32 ssaturate (X, 19)')
> > > 
> > > 
> > > I think that doing the legalization in DAG for some of the fixed-point 
> > > operations could be hard. Opcode legalization occurs after type 
> > > legalization, so the legalization for opcodes that have legal types but 
> > > where the target doesn't actually support the operation must be able to 
> > > legalize to valid types. I think this could get unnecessarily tricky. For 
> > > example, an N-bit, M-scale fixsmul must actually be done as N+M-bits or 
> > > greater, and if that type (or anything greater than it) isn't legal it 
> > > gets hairy.
> > 
> > I'm not sure if I follow still. (Still learning how the instruction 
> > selection process works). So for the fixsmul example, is the problem that 
> > during the operation legalization step, the target may not be able to 
> > support an int that has N+M bits? Wouldn't this legalization occur during 
> > the first type legalization step before operation legalization, like we 
> > check if the target can support a N+M bit int before operation 
> > legalization? Then during the following optimization stage, have a DAG pass 
> > that will expand an illegal intrinsic operation into other DAG nodes.
> > 
> > > There's also the issue of how a target specifies legality of these 
> > > operations. A target might support ISD::FIXSMUL on MVT::i16, but only 
> > > with a scale of 15. However, there's currently no way of expressing 
> > > legality of an operation based on anything than the type (in general). 
> > > Something would probably have to be added to 
> > > TargetLowering/TargetLoweringBase that lets targets specify the legality 
> > > of these operations. (The same issue applies to ssaturate; it might be 
> > > legal to do 'i32 ssaturate (X, 15)', but not 'i32 ssaturate (X, 19)')
> > 
> > Also having trouble understanding this one. Is the problem that you don't 
> > have access to operand types during the instruction legalization step?
> > I'm not sure if I follow still. (Still learning how the instruction 
> > selection process works). So for the fixsmul example, is the problem that 
> > during the operation legalization step, the target may not be able to 
> > support an int that has N+M bits?
> 
> Correct. Operation legalization (as I understand it; I could be wrong!) can 
> not introduce illegal types into the DAG since type legalization occurs 
> first. Say that you have a 'i16 fixsmul(X, Y, 15)' on a target where i16 is 
> legal and i32 is not, and the fixsmul is not legal. Th

[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

2018-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 166756.
leonardchan added a reviewer: rjmccall.
leonardchan changed the repository for this revision from rC Clang to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D52286

Files:
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/IR/Intrinsics.td
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/LegalizeTypes.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/Generic/ssaturate.ll
  test/CodeGen/X86/ssaturate.ll

Index: test/CodeGen/X86/ssaturate.ll
===
--- /dev/null
+++ test/CodeGen/X86/ssaturate.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s
+
+declare i4 @llvm.ssaturate.i4  (i4, i32)
+declare i32 @llvm.ssaturate.i32  (i32, i32)
+
+define  i32 @func(i32 %x) {
+entry:
+; CHECK: func:
+; CHECK: 	cmpl	$127, %edi
+; CHECK-NEXT: 	movl	$127, %ecx
+; CHECK-NEXT: 	cmovlel	%edi, %ecx
+; CHECK-NEXT: 	cmpl	$-128, %edi
+; CHECK-NEXT: 	movl	$-128, %eax
+; CHECK-NEXT: 	cmovgel	%ecx, %eax
+; CHECK-NEXT: 	retq
+
+  %tmp = call i32 @llvm.ssaturate.i32( i32 %x, i32 8 )
+  ret i32 %tmp
+}
+
+define  i4 @func2(i4 %x) {
+entry:
+; CHECK: func2:
+; CHECK: # %bb.0:# %entry
+; CHECK-NEXT:movl%edi, %eax
+; CHECK-NEXT:# kill: def $al killed $al killed $eax
+; CHECK-NEXT:retq
+
+  %tmp = call i4 @llvm.ssaturate.i4( i4 %x, i32 8 )
+  ret i4 %tmp
+}
Index: test/CodeGen/Generic/ssaturate.ll
===
--- /dev/null
+++ test/CodeGen/Generic/ssaturate.ll
@@ -0,0 +1,26 @@
+; RUN: llc < %s
+
+declare i4 @llvm.ssaturate.i4  (i4, i32)
+declare i32 @llvm.ssaturate.i32  (i32, i32)
+
+define i32 @func() {
+entry:
+  %x = alloca i32, align 4
+
+  store i32 16, i32* %x, align 4
+  %val = load i32, i32* %x
+
+  %tmp = call i32 @llvm.ssaturate.i32( i32 %val, i32 4 )
+  ret i32 %tmp
+}
+
+define i4 @func2() {
+entry:
+  %x = alloca i4, align 1
+
+  store i4 1, i4* %x, align 1
+  %val = load i4, i4* %x
+
+  %tmp = call i4 @llvm.ssaturate.i4( i4 %val, i32 8 )
+  ret i4 %tmp
+}
Index: lib/CodeGen/TargetLoweringBase.cpp
===
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -608,6 +608,7 @@
 setOperationAction(ISD::UMIN, VT, Expand);
 setOperationAction(ISD::UMAX, VT, Expand);
 setOperationAction(ISD::ABS, VT, Expand);
+setOperationAction(ISD::SSAT, VT, Expand);
 
 // Overflow operations default to expand
 setOperationAction(ISD::SADDO, VT, Expand);
Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -282,6 +282,8 @@
   case ISD::SRA_PARTS:  return "sra_parts";
   case ISD::SRL_PARTS:  return "srl_parts";
 
+  case ISD::SSAT:   return "ssaturate";
+
   // Conversion operators.
   case ISD::SIGN_EXTEND:return "sign_extend";
   case ISD::ZERO_EXTEND:return "zero_extend";
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5763,6 +5763,12 @@
 setValue(&I, DAG.getSelect(sdl, VT, IsZeroShift, IsFSHL ? X : Y, Or));
 return nullptr;
   }
+  case Intrinsic::ssaturate: {
+SDValue Op1 = getValue(I.getArgOperand(0));
+SDValue Op2 = getValue(I.getArgOperand(1));
+setValue(&I, DAG.getNode(ISD::SSAT, sdl, Op1.getValueType(), Op1, Op2));
+return nullptr;
+  }
   case Intrinsic::stacksave: {
 SDValue Op = getRoot();
 Res = DAG.getNode(
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.h
===
--- lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -330,6 +330,7 @@
   SDValue PromoteIntRes_UNDEF(SDNode *N);
   SDValue PromoteIntRes_VAARG(SDNode *N);
   SDValue PromoteIntRes_XMULO(SDNode *N, unsigned ResNo);
+  SDValue PromoteIntRes_SSAT(SDNode *N);
 
   // Integer Operand Promotion.
   bool PromoteIntegerOperand(SDNode *N, unsigned OpNo);
Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===
--- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -141,6 +141,10 @@
   case ISD::ADDCARRY:
   case ISD::SUBCARRY:Res = PromoteIntRes_ADDSUBCARRY(N, ResNo); break;
 
+  case ISD::SSAT:
+Res = PromoteIntRes_

r342920 - [analyzer] Prevent crashes in FindLastStoreBRVisitor

2018-09-24 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Sep 24 14:20:30 2018
New Revision: 342920

URL: http://llvm.org/viewvc/llvm-project?rev=342920&view=rev
Log:
[analyzer] Prevent crashes in FindLastStoreBRVisitor

This patch is a band-aid. A proper solution would be too change
trackNullOrUndefValue to only try to dereference the pointer when it is
relevant to the problem.

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

Added:
cfe/trunk/test/Analysis/diagnostics/find_last_store.c
Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=342920&r1=342919&r2=342920&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Mon Sep 24 14:20:30 2018
@@ -83,6 +83,8 @@ public:
 BugReport &BR);
 };
 
+/// Finds last store into the given region,
+/// which is different from a given symbolic value.
 class FindLastStoreBRVisitor final : public BugReporterVisitor {
   const MemRegion *R;
   SVal V;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=342920&r1=342919&r2=342920&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Sep 24 
14:20:30 2018
@@ -1294,8 +1294,7 @@ FindLastStoreBRVisitor::VisitNode(const
 if (const auto *BDR =
   dyn_cast_or_null(V.getAsRegion())) {
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
-if (Optional KV =
-State->getSVal(OriginalR).getAs())
+if (auto KV = State->getSVal(OriginalR).getAs())
   BR.addVisitor(llvm::make_unique(
   *KV, OriginalR, EnableNullFPSuppression));
   }
@@ -1752,8 +1751,18 @@ bool bugreporter::trackNullOrUndefValue(
 else
   RVal = state->getSVal(L->getRegion());
 
-if (auto KV = RVal.getAs())
-  report.addVisitor(llvm::make_unique(
+// FIXME: this is a hack for fixing a later crash when attempting to
+// dereference a void* pointer.
+// We should not try to dereference pointers at all when we don't care
+// what is written inside the pointer.
+bool ShouldFindLastStore = true;
+if (const auto *SR = dyn_cast(L->getRegion()))
+  if (SR->getSymbol()->getType()->getPointeeType()->isVoidType())
+ShouldFindLastStore = false;
+
+if (ShouldFindLastStore)
+  if (auto KV = RVal.getAs())
+report.addVisitor(llvm::make_unique(
 *KV, L->getRegion(), EnableNullFPSuppression));
 
 const MemRegion *RegionRVal = RVal.getAsRegion();

Added: cfe/trunk/test/Analysis/diagnostics/find_last_store.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/find_last_store.c?rev=342920&view=auto
==
--- cfe/trunk/test/Analysis/diagnostics/find_last_store.c (added)
+++ cfe/trunk/test/Analysis/diagnostics/find_last_store.c Mon Sep 24 14:20:30 
2018
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+typedef struct { float b; } c;
+void *a();
+void *d() {
+  return a(); // expected-note{{Returning pointer}}
+}
+
+void no_find_last_store() {
+  c *e = d(); // expected-note{{Calling 'd'}}
+  // expected-note@-1{{Returning from 'd'}}
+  // expected-note@-2{{'e' initialized here}}
+
+  (void)(e || e->b); // expected-note{{Assuming 'e' is null}}
+  // expected-note@-1{{Left side of '||' is false}}
+  // expected-note@-2{{Access to field 'b' results in a dereference of a 
null pointer (loaded from variable 'e')}}
+  // expected-warning@-3{{Access to field 'b' results in a dereference of 
a null pointer (loaded from variable 'e')}}
+}


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


[PATCH] D52437: [CUDA] Add preliminary support for CUDA 10.0

2018-09-24 Thread Andrea Bocci via Phabricator via cfe-commits
fwyzard created this revision.
fwyzard added reviewers: tra, Hahnfeld.
Herald added a subscriber: cfe-commits.

Add the definitions for CUDA 10.0 and CUDA architecture 7.5 (Turing),
and define CUDA 10.0 as the highest supported version.

Starting with CUDA 10.0, the include files

  include/crt/*
  include/common_functions.h
  include/device_double_functions.h
  include/device_functions.h
  include/host_config.h
  include/host_defines.h
  include/math_functions.h

are marked as internal, and issue a warning if they are directly included.
To suppress the warning, __clang_cuda_runtime_wrapper.h defines the macro
__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__ before including any of them.


Repository:
  rC Clang

https://reviews.llvm.org/D52437

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
 #error "Unsupported CUDA version!"
 #endif
 
@@ -94,6 +94,9 @@
 #else
 #define __CUDA_LIBDEVICE__
 #endif
+#if CUDA_VERSION >= 1
+#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#endif
 // Disables definitions of device-side runtime support stubs in
 // cuda_device_runtime_api.h
 #include "driver_types.h"
@@ -420,5 +423,9 @@
 #pragma pop_macro("uint3")
 #pragma pop_macro("__USE_FAST_MATH__")
 
+#ifdef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#endif
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -59,6 +59,8 @@
 return CudaVersion::CUDA_91;
   if (Major == 9 && Minor == 2)
 return CudaVersion::CUDA_92;
+  if (Major == 10 && Minor == 0)
+return CudaVersion::CUDA_100;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -22,6 +22,8 @@
 return "9.1";
   case CudaVersion::CUDA_92:
 return "9.2";
+  case CudaVersion::CUDA_100:
+return "10.0";
   }
   llvm_unreachable("invalid enum");
 }
@@ -60,6 +62,8 @@
 return "sm_70";
   case CudaArch::SM_72:
 return "sm_72";
+  case CudaArch::SM_75:
+return "sm_75";
   case CudaArch::GFX600: // tahiti
 return "gfx600";
   case CudaArch::GFX601: // pitcairn, verde, oland,hainan
@@ -106,6 +110,7 @@
   .Case("sm_62", CudaArch::SM_62)
   .Case("sm_70", CudaArch::SM_70)
   .Case("sm_72", CudaArch::SM_72)
+  .Case("sm_75", CudaArch::SM_75)
   .Case("gfx600", CudaArch::GFX600)
   .Case("gfx601", CudaArch::GFX601)
   .Case("gfx700", CudaArch::GFX700)
@@ -152,6 +157,8 @@
 return "compute_70";
   case CudaVirtualArch::COMPUTE_72:
 return "compute_72";
+  case CudaVirtualArch::COMPUTE_75:
+return "compute_75";
   case CudaVirtualArch::COMPUTE_AMDGCN:
 return "compute_amdgcn";
   }
@@ -173,6 +180,7 @@
   .Case("compute_62", CudaVirtualArch::COMPUTE_62)
   .Case("compute_70", CudaVirtualArch::COMPUTE_70)
   .Case("compute_72", CudaVirtualArch::COMPUTE_72)
+  .Case("compute_75", CudaVirtualArch::COMPUTE_75)
   .Case("compute_amdgcn", CudaVirtualArch::COMPUTE_AMDGCN)
   .Default(CudaVirtualArch::UNKNOWN);
 }
@@ -210,6 +218,8 @@
 return CudaVirtualArch::COMPUTE_70;
   case CudaArch::SM_72:
 return CudaVirtualArch::COMPUTE_72;
+  case CudaArch::SM_75:
+return CudaVirtualArch::COMPUTE_75;
   case CudaArch::GFX600:
   case CudaArch::GFX601:
   case CudaArch::GFX700:
@@ -252,6 +262,8 @@
 return CudaVersion::CUDA_90;
   case CudaArch::SM_72:
 return CudaVersion::CUDA_91;
+  case CudaArch::SM_75:
+return CudaVersion::CUDA_100;
   case CudaArch::GFX600:
   case CudaArch::GFX601:
   case CudaArch::GFX700:
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -24,7 +24,8 @@
   CUDA_90,
   CUDA_91,
   CUDA_92,
-  LATEST = CUDA_92,
+  CUDA_100,
+  LATEST = CUDA_100,
 };
 const char *CudaVersionToString(CudaVersion V);
 
@@ -47,6 +48,7 @@
   SM_62,
   SM_70,
   SM_72,
+  SM_75,
   GFX600,
   GFX601,
   GFX700,
@@ -82,6 +84,7 @@
   COMPUTE_62,
   COMPUTE_70,
   COMPUTE_72,
+  COMPUTE_75,
   COMPUTE_AMDGCN,
 };
 const char *CudaVirtualArchToString(CudaVirtualArch A);

[PATCH] D52264: Deduplicate replacements from diagnostics.

2018-09-24 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52264



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


[PATCH] D52398: Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

2018-09-24 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, but you should give @delesley a chance to weigh in before you commit.


Repository:
  rC Clang

https://reviews.llvm.org/D52398



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


[PATCH] D52281: [clang-tidy] Add modernize check to use std::invoke in generic code

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:70
+  if (MFunctor && MFunctor->isTypeDependent()) {
+const auto *Paren = static_cast(MFunctor->getCallee());
+const auto *BinOp =

JonasToth wrote:
> Eugene.Zelenko wrote:
> > I think you should use LLVM's cast instead, but I'm not sure which one. 
> > Same for other places.
> in this case i think `const auto *BinOp = 
> dyn_cast(Paren->getSubExpr());` would match.
> 
> As a safety measure adding a `assert(BinOp && "No Binary Operator as 
> subexpression");` helps spotting bugs.
I agree; you'd want `dyn_cast` here. There's no need to add that assertion -- 
`dyn_cast` already asserts that the given value is non-null. If the value could 
be null and still be valid, you could use `dyn_cast_or_null` instead.


https://reviews.llvm.org/D52281



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

This now matches GCC AFAICT.  My only question is:

Should GCC instead warn for the typedef case for -std=c89 (non pedantic), 
according to C90 6.5.3?


Repository:
  rC Clang

https://reviews.llvm.org/D52248



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


[PATCH] D52136: [clang-tidy] Add modernize-concat-nested-namespaces check

2018-09-24 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.

Aside from the local `const` qualification stuff and some minor wordsmithing of 
the documentation, this LGTM.




Comment at: clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:52
+const NamespaceContextVec &Namespaces) {
+  std::ostringstream Result;
+  bool First = true;

wgml wrote:
> aaron.ballman wrote:
> > wgml wrote:
> > > aaron.ballman wrote:
> > > > Can this be rewritten with `llvm::for_each()` and a `Twine` so that we 
> > > > don't have to use `ostringstream` (which is a big hammer for this).
> > > The main advantage of `stringstream` was that it is concise.
> > > 
> > > I don't think I can effectively use `Twine` to build a result in a loop. 
> > > If I'm wrong, correct me, please.
> > > 
> > > I reworked `concatNamespaces` to use `SmallString` with another educated 
> > > guess of `40` for capacity.
> > The `Twine` idea I was thinking of is not too far off from what you have 
> > with `SmallString`, but perhaps is too clever:
> > ```
> > return std::accumulate(Namespaces.begin(), Namespaces.end(), llvm::Twine(), 
> > [](llvm::Twine Ret, const NamespaceDecl *ND) {
> >   return Ret + "::" + ND->getName();
> > }).str();
> > ```
> Yeah, I tried that, but Twine has it's `operator=` deleted.
Ugh, good catch! The current formulation is fine then, thank you!



Comment at: clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:31
+static bool singleNamedNamespaceChild(const NamespaceDecl &ND) {
+  const NamespaceDecl::decl_range Decls = ND.decls();
+  if (std::distance(Decls.begin(), Decls.end()) != 1)

wgml wrote:
> aaron.ballman wrote:
> > We usually only const-qualify local declarations when they're 
> > pointers/references, so you can drop the `const` here (and in several other 
> > places). It's not a hard and fast rule, but the clutter is not useful in 
> > such small functions.
> From my perspective, `const` is a easy way of declaring that my intention is 
> only to name given declaration only for reading and to improve code 
> readability. 
I wasn't making a value judgement about the coding style so much as pointing 
out that this is novel to the code base and we tend to avoid novel constructs 
unless there's a good reason to deviate. I don't see a strong justification 
here, so I'd prefer them to be removed for consistency.



Comment at: docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst:6
+
+Checks for use of nested namespaces in a form of ``namespace a { namespace b { 
... } }``
+and offers change to syntax introduced in C++17: ``namespace a::b { ... }``.

in a form of -> such as



Comment at: docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst:7
+Checks for use of nested namespaces in a form of ``namespace a { namespace b { 
... } }``
+and offers change to syntax introduced in C++17: ``namespace a::b { ... }``.
+Inlined namespaces are not modified.

offers change to syntax -> suggests changing to the more concise syntax



Comment at: docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst:8
+and offers change to syntax introduced in C++17: ``namespace a::b { ... }``.
+Inlined namespaces are not modified.
+

Inlined -> Inline


https://reviews.llvm.org/D52136



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


[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

2018-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 166746.
leonardchan added a comment.
Herald added a subscriber: cfe-commits.

- Removed passes since ssaturate can be expanded in the DAG


Repository:
  rC Clang

https://reviews.llvm.org/D52286

Files:
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/IR/Intrinsics.td
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/LegalizeTypes.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/Generic/ssaturate.ll

Index: test/CodeGen/Generic/ssaturate.ll
===
--- /dev/null
+++ test/CodeGen/Generic/ssaturate.ll
@@ -0,0 +1,26 @@
+; RUN: llc < %s
+
+declare i4 @llvm.ssaturate.i4  (i4, i32)
+declare i32 @llvm.ssaturate.i32  (i32, i32)
+
+define i32 @func() {
+entry:
+  %x = alloca i32, align 4
+
+  store i32 16, i32* %x, align 4
+  %val = load i32, i32* %x
+
+  %tmp = call i32 @llvm.ssaturate.i32( i32 %val, i32 4 )
+  ret i32 %tmp
+}
+
+define i4 @func2() {
+entry:
+  %x = alloca i4, align 1
+
+  store i4 1, i4* %x, align 1
+  %val = load i4, i4* %x
+
+  %tmp = call i4 @llvm.ssaturate.i4( i4 %val, i32 8 )
+  ret i4 %tmp
+}
Index: lib/CodeGen/TargetLoweringBase.cpp
===
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -608,6 +608,7 @@
 setOperationAction(ISD::UMIN, VT, Expand);
 setOperationAction(ISD::UMAX, VT, Expand);
 setOperationAction(ISD::ABS, VT, Expand);
+setOperationAction(ISD::SSAT, VT, Expand);
 
 // Overflow operations default to expand
 setOperationAction(ISD::SADDO, VT, Expand);
Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -282,6 +282,8 @@
   case ISD::SRA_PARTS:  return "sra_parts";
   case ISD::SRL_PARTS:  return "srl_parts";
 
+  case ISD::SSAT:   return "ssaturate";
+
   // Conversion operators.
   case ISD::SIGN_EXTEND:return "sign_extend";
   case ISD::ZERO_EXTEND:return "zero_extend";
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5763,6 +5763,12 @@
 setValue(&I, DAG.getSelect(sdl, VT, IsZeroShift, IsFSHL ? X : Y, Or));
 return nullptr;
   }
+  case Intrinsic::ssaturate: {
+SDValue Op1 = getValue(I.getArgOperand(0));
+SDValue Op2 = getValue(I.getArgOperand(1));
+setValue(&I, DAG.getNode(ISD::SSAT, sdl, Op1.getValueType(), Op1, Op2));
+return nullptr;
+  }
   case Intrinsic::stacksave: {
 SDValue Op = getRoot();
 Res = DAG.getNode(
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.h
===
--- lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -330,6 +330,7 @@
   SDValue PromoteIntRes_UNDEF(SDNode *N);
   SDValue PromoteIntRes_VAARG(SDNode *N);
   SDValue PromoteIntRes_XMULO(SDNode *N, unsigned ResNo);
+  SDValue PromoteIntRes_SSAT(SDNode *N);
 
   // Integer Operand Promotion.
   bool PromoteIntegerOperand(SDNode *N, unsigned OpNo);
Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===
--- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -141,6 +141,10 @@
   case ISD::ADDCARRY:
   case ISD::SUBCARRY:Res = PromoteIntRes_ADDSUBCARRY(N, ResNo); break;
 
+  case ISD::SSAT:
+Res = PromoteIntRes_SSAT(N);
+break;
+
   case ISD::ATOMIC_LOAD:
 Res = PromoteIntRes_Atomic0(cast(N)); break;
 
@@ -534,6 +538,12 @@
   return SDValue(Res.getNode(), 1);
 }
 
+SDValue DAGTypeLegalizer::PromoteIntRes_SSAT(SDNode *N) {
+  SDValue LHS = GetPromotedInteger(N->getOperand(0));
+  SDValue RHS = N->getOperand(1);
+  return DAG.getNode(N->getOpcode(), SDLoc(N), LHS.getValueType(), LHS, RHS);
+}
+
 SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(SDNode *N, unsigned ResNo) {
   if (ResNo == 1)
 return PromoteIntRes_Overflow(N);
Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===
--- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3461,6 +3461,36 @@
 }
 break;
   }
+  case ISD::SSAT: {
+SDValue SatBits = Node->getOperand(1);
+auto *SatBitsNode = dyn_cast(SatBits);
+if (!SatBitsNode)
+  report_fatal_error(
+  "Second argument of ssaturate intrinsic must be a constant integer");
+
+

[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166743.
nickdesaulniers added a comment.

- adjust wording in comment


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c


Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,71 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 51:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C99: 51:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C11: 51:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C17: 51:19: error: expected function body after function declarator
+CHECK-C17-PEDANTIC: 51:19: error: expected function body after function 
declarator
+
+CHECK-GNU89-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 51:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+*/
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1679,8 +1679,16 @@
 // C90 6.5.3 constra

[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166742.
nickdesaulniers added a comment.

- fix typo s/CNU/GNU/g and update NOTEs


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c


Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,71 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 51:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C99: 51:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C11: 51:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C17: 51:19: error: expected function body after function declarator
+CHECK-C17-PEDANTIC: 51:19: error: expected function body after function 
declarator
+
+CHECK-GNU89-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 51:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+*/
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1679,8 +1679,16 @@
 // C90 6

[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong, jholewinski.

For the OpenMP NVPTX toolchain choose default schedules which ensure coalescing 
on the GPU when in SPMD mode. This significantly increases the performance of 
offloaded target code.


Repository:
  rC Clang

https://reviews.llvm.org/D52434

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -34,7 +34,7 @@
 l = i;
   }
 
-  #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
+ #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
   for(int i = 0; i < n; i++) {
 aa[i] += 1;
   }
@@ -81,44 +81,44 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_distribute_default_init_4({{.+}}, {{.+}}, {{.+}} 1,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_distribute_default_init_4({{.+}}, {{.+}}, {{.+}} 1,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
 // CHECK: define {{.*}}void {{@__omp_offloading_.+}}({{.+}}, i{{32|64}} [[F_IN:%.+]])
 // CHECK: store {{.+}} [[F_IN]], {{.+}}* {{.+}},
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
 // CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
+// CHECK: call void @__kmpc_distribute_default_init_4({{.+}}, {{.+}}, {{.+}} 1, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
@@ -24,7 +24,7 @@
 // CHECK: define weak void @__omp_offloading_{{.*}}_main_l16(i{{64|32}} %{{[^,].*}}, i32* dereferenceable{{[^,]*}}, i{{64|32}} %{{[^,)]*}})
 // CHECK: [[TID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @
 // CHECK: call void @__kmpc_spmd_kernel_init(
-// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK: call void @__kmpc_distribute_default_init_4(
 
 // CHECK: call void [[PARALLEL:@.+]](i32* %{{.*}}, i32* %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} %{{.*}}, i{{64|32}} %{{.*}}, i32* %{{.*}})
 // CHECK: br label %
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

One important thing I forgot, that you cant rely on `ProgramState` due to 
tidy's constraints. Btw, how do you plan to make this into a tidy checker? To 
me it seems like it would amplify the already existing false positive issues 
(if I understand your currect way of thinking correctly).


Repository:
  rC Clang

https://reviews.llvm.org/D52390



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: test/Sema/gnu89-const.c:41-46
+CHECK-CNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier

gah, `CNU` typo!


Repository:
  rC Clang

https://reviews.llvm.org/D52248



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


[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-09-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/CMakeLists.txt:60
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  list(APPEND libraries gcc)
+endif()

I'm a little suspicious of this line, of forcibly linking against libgcc here, 
even if we might not have checked that it even exists.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51657



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166740.
nickdesaulniers added a comment.

- condense CHECK-prefixes into CHECK for const const


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c


Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,71 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 50:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 50:19: error: expected function body after function 
declarator
+CHECK-C99: 50:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 50:19: error: expected function body after function 
declarator
+CHECK-C11: 50:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 50:19: error: expected function body after function 
declarator
+CHECK-C17: 50:19: error: expected function body after function declarator
+CHECK-C17-PEDANTIC: 50:19: error: expected function body after function 
declarator
+
+CHECK-GNU89-NOT: 50:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU89-PEDANTIC: 50:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 50:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 50:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 50:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 50:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 50:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 50:1: warning: duplicate 'const' declaration 
specifier
+*/
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1679,8 +1679,16 @@

[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-09-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good, sorry for the delay.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51657



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166736.
nickdesaulniers added a comment.

- add ISO C tests, handle typedef case new tests found


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c

Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,87 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK-C89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 66:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C99: 66:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C11: 66:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 66:19: err

[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166737.
nickdesaulniers added a comment.

- remove debug statments


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c

Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,87 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK-C89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 66:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C99: 66:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C11: 66:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 66:19: error: expected function body aft

[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

> Thanks for all your detailed and helpful input, I will make sure to go over 
> all the comments and answer them, but it will take some time.

Cheers! I can't emphasize enough however that I might be wrong on what I've 
said, or say in this comment.

> It was my introduction to the clang tool-chain

I always struggled getting enough literature about the static analyzer, if you 
didn't come across these works already, it might be worth taking a look :)

1. http://lcs.ios.ac.cn/~xuzb/canalyze/memmodel.pdf
2. 
https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/README.txt
3. https://clang-analyzer.llvm.org/checker_dev_manual.html
4. 
https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/RegionStore.txt
5. 
https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf
 <--- by far the best guide for the static analyzer at the moment.
6. https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/IPA.txt

> A bit more background information on this checker and how it came to be might 
> help you and others to understand some of the choices I made, and also 
> address some of your general questions and worries.
>  I was hesitant about putting too much in the summary but it seems I should 
> have added more.

Summaries are one thing, that most likely won't be (and shouldn't have to be) 
read by a future maintainer, the code should speak for itself.

> This was a university assignment and I was encouraged to put it up here. This 
> code has seen quite a few iterations and criticism.

It's great that you put it up here! New checkers (which from what I've seen are 
mostly written by beginners) tend to go through in some cases a many month long 
review process, so I guess be prepared for some back and forth, but I 
personally really enjoyed the process, I hope you will too.

I have read the rest of your comment, thanks for the details! I can't say that 
I understand every aspect of your algorithm, but I have a couple question for 
the grand picture (but feel free to correct me if I misunderstood anything):

I can see that you use `check::PreCall, check::PostCall, check::EndFunction`, 
and you also modifiy the program state to have a fairly good idea about what 
execution path did the analyzer take, but a function's stack usage it 
calculated very roughly. Let's imagine that in the next example, `f` is only 
called after heavy stack usage:

  // Let's just pretend that this function actually
  // has a meaningful implementation that the analyzer
  // knows will return false in this case.
  bool hasStackEnoughSpace() { return false; }
  
  void f() {
if (hasStackEnoughSpace())
  // use the stack like an absolute madman
else
  chill();
  }

This is silly, but what it wants to demonstrate, that you could report a false 
positive here, despite the analyzer potentially knowing that that path will  
never be taken. To me it seems like you don't utilize the actual 
`ProgramState`, but I think you should.

To me it also seems like that you pretty much reinvent the compiler in this 
patch, by modeling almost everything the compiler does by itself. I'm sadly 
nowhere near an expert on this topic, but it begs the question whether there's 
an already existing solution to this. Let's wait for others to weigh in on 
this, maybe I'm wrong and this is what has to be done.

A couple tips for easier development and review process:

- I think before deep diving into the fixes, you really should split up this 
patch at least into an empty callback (essentially an announcement), and add 
each feature as a separate patch. Ideally, each time you implement a new 
feature, such as handling branches, you should make a neat patch with a small 
implementation and related test cases. As a beginner (and I suffered from this 
myself) this is exceptionally hard to do, because you can often find yourself 
deleting everything and starting all over, but I've grown to appreciate this 
principle as I often saved myself a whole lot of effort due to some feedback. 
However, making a rough proof of concept is in this case IMO a good idea, 
because it's hard to see at the start where the code will end up, but later it 
should be split up.
- Comment everything. I mean, `bool isSuccessful() const { return IsSuccessful; 
}` and similar functions speak for themselves, but ideally every non-trivial 
function and structure should be documented, as well as any non-trivial hackery 
inside a function.


Repository:
  rC Clang

https://reviews.llvm.org/D52390



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


[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for this patch, Tri!


Repository:
  rC Clang

https://reviews.llvm.org/D52399



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


[PATCH] D52273: [clangd] Initial implementation of expected types

2018-09-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Happy to speculate about what might work here, but I strongly believe the path 
forward here is to build the simplest version of this feature, without 
conversions, and try to avoid complicated conversion logic if we can get most 
of the benefit in simpler ways.

In https://reviews.llvm.org/D52273#1243652, @ilya-biryukov wrote:

> > This seems very clever, but extremely complicated - you've implemented much 
> > of C++'s conversion logic, it's not clear to me which parts are actually 
> > necessary to completion quality.
>
> Clearly the model that supports C++ conversions is something that **will** 
> improve code completion quality.


It's not clear that will be significant. This isn't hard to measure, so I'm not 
sure why we should guess. And I'm not sure why it all has to go in the first 
patch.

> I do agree it's not trivial, but would argue we at least want:
> 
> - qualification conversions (i.e. adding const)

Another approach here is just always dropping const. (And refs, and so on). 
This will create some false positives, but maybe they don't hurt much. This 
handles some true cases too, like invoking copy constructors.

> - user-defined conversions (e.g. operator bool is commonly useful think)

My **guess** is you're not going to measure a difference here, bool has lots of 
false positives and others are rare.

> - derived-to-base conversions (Derived* should convert to Base*)

Yes, probably. If this ends up being the only "chain" we have to follow, we're 
probably in good shape complexity-wise.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D52344: [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`.

2018-09-24 Thread Kristina Brooks via Phabricator via cfe-commits
kristina reopened this revision.
kristina added a comment.
This revision is now accepted and ready to land.

Cascade of build failures stemming from `GV->setSection(".rodata");`, reverted 
the commit, it seems that `CFString.c` is causing all those issues despite 
passing when ran locally.


Repository:
  rC Clang

https://reviews.llvm.org/D52344



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


r342912 - [CodeGen] Revert commit https://reviews.llvm.org/rL342717

2018-09-24 Thread Calixte Denizet via cfe-commits
Author: calixte
Date: Mon Sep 24 11:24:18 2018
New Revision: 342912

URL: http://llvm.org/viewvc/llvm-project?rev=342912&view=rev
Log:
[CodeGen] Revert commit https://reviews.llvm.org/rL342717

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/debug-info-scope-file.c
cfe/trunk/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
cfe/trunk/test/CodeGenObjC/arc-linetable.m
cfe/trunk/test/CodeGenObjC/debug-info-blocks.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=342912&r1=342911&r2=342912&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 24 11:24:18 2018
@@ -76,22 +76,20 @@ CGDebugInfo::~CGDebugInfo() {
 }
 
 ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
-   SourceLocation TemporaryLocation,
-   bool ImplicitCode)
+   SourceLocation TemporaryLocation)
 : CGF(&CGF) {
-  init(TemporaryLocation, false /* DefaultToEmpty */, ImplicitCode);
+  init(TemporaryLocation);
 }
 
 ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
bool DefaultToEmpty,
-   SourceLocation TemporaryLocation,
-   bool ImplicitCode)
+   SourceLocation TemporaryLocation)
 : CGF(&CGF) {
-  init(TemporaryLocation, DefaultToEmpty, ImplicitCode);
+  init(TemporaryLocation, DefaultToEmpty);
 }
 
 void ApplyDebugLocation::init(SourceLocation TemporaryLocation,
-  bool DefaultToEmpty, bool ImplicitCode) {
+  bool DefaultToEmpty) {
   auto *DI = CGF->getDebugInfo();
   if (!DI) {
 CGF = nullptr;
@@ -104,7 +102,7 @@ void ApplyDebugLocation::init(SourceLoca
 return;
 
   if (TemporaryLocation.isValid()) {
-DI->EmitLocation(CGF->Builder, TemporaryLocation, ImplicitCode);
+DI->EmitLocation(CGF->Builder, TemporaryLocation);
 return;
   }
 
@@ -3486,8 +3484,7 @@ void CGDebugInfo::EmitInlineFunctionEnd(
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
-void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
-   bool ImplicitCode) {
+void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) {
   // Update our current location
   setLocation(Loc);
 
@@ -3495,9 +3492,8 @@ void CGDebugInfo::EmitLocation(CGBuilder
 return;
 
   llvm::MDNode *Scope = LexicalBlockStack.back();
-  Builder.SetCurrentDebugLocation(
-  llvm::DebugLoc::get(getLineNumber(CurLoc), getColumnNumber(CurLoc), 
Scope,
-  CurInlinedAt, ImplicitCode));
+  Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
+  getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, CurInlinedAt));
 }
 
 void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) {
@@ -3544,7 +3540,7 @@ void CGDebugInfo::EmitLexicalBlockEnd(CG
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
 
   // Provide an entry in the line table for the end of the block.
-  EmitLocation(Builder, Loc, true /* ImplicitCode */);
+  EmitLocation(Builder, Loc);
 
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
@@ -3560,7 +3556,7 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil
   // Pop all regions for this function.
   while (LexicalBlockStack.size() != RCount) {
 // Provide an entry in the line table for the end of the block.
-EmitLocation(Builder, CurLoc, true /* ImplicitCode */);
+EmitLocation(Builder, CurLoc);
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=342912&r1=342911&r2=342912&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Sep 24 11:24:18 2018
@@ -377,9 +377,7 @@ public:
   /// Emit metadata to indicate a change in line/column information in
   /// the source file. If the location is invalid, the previous
   /// location will be reused.
-  /// \param ImplicitCode  True if the Loc must have coverage information
-  void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
-bool ImplicitCode = false);
+  void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc);
 
   /// Emit a call to llvm.dbg.function.sta

[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.

2018-09-24 Thread Tri Vo via Phabricator via cfe-commits
trong updated this revision to Diff 166722.
trong added a comment.

- Added test case for using -fcall-saved-x18 and -ffixed-x18 together.


Repository:
  rC Clang

https://reviews.llvm.org/D52399

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/AArch64.cpp
  test/Driver/aarch64-call-saved-x-register.c
  test/Driver/aarch64-fixed-call-saved-x-register.c

Index: test/Driver/aarch64-fixed-call-saved-x-register.c
===
--- /dev/null
+++ test/Driver/aarch64-fixed-call-saved-x-register.c
@@ -0,0 +1,8 @@
+// Check that -ffixed and -fcall-saved flags work correctly together.
+// RUN: %clang -target aarch64-none-gnu \
+// RUN: -ffixed-x18 \
+// RUN: -fcall-saved-x18 \
+// RUN: -### %s  2>&1 | FileCheck %s
+
+// CHECK: "-target-feature" "+reserve-x18"
+// CHECK: "-target-feature" "+call-saved-x18"
Index: test/Driver/aarch64-call-saved-x-register.c
===
--- /dev/null
+++ test/Driver/aarch64-call-saved-x-register.c
@@ -0,0 +1,58 @@
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x8 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X8 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x9 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X9 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x10 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X10 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x11 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X11 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x12 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X12 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x13 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X13 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x14 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X14 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x15 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X15 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x18 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X18 %s
+
+// Test all call-saved-x# options together.
+// RUN: %clang -target aarch64-none-gnu \
+// RUN: -fcall-saved-x8 \
+// RUN: -fcall-saved-x9 \
+// RUN: -fcall-saved-x10 \
+// RUN: -fcall-saved-x11 \
+// RUN: -fcall-saved-x12 \
+// RUN: -fcall-saved-x13 \
+// RUN: -fcall-saved-x14 \
+// RUN: -fcall-saved-x15 \
+// RUN: -fcall-saved-x18 \
+// RUN: -### %s  2>&1 | FileCheck %s \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X8 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X9 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X10 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X11 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X12 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X13 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X14 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X15 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X18
+
+// CHECK-CALL-SAVED-X8: "-target-feature" "+call-saved-x8"
+// CHECK-CALL-SAVED-X9: "-target-feature" "+call-saved-x9"
+// CHECK-CALL-SAVED-X10: "-target-feature" "+call-saved-x10"
+// CHECK-CALL-SAVED-X11: "-target-feature" "+call-saved-x11"
+// CHECK-CALL-SAVED-X12: "-target-feature" "+call-saved-x12"
+// CHECK-CALL-SAVED-X13: "-target-feature" "+call-saved-x13"
+// CHECK-CALL-SAVED-X14: "-target-feature" "+call-saved-x14"
+// CHECK-CALL-SAVED-X15: "-target-feature" "+call-saved-x15"
+// CHECK-CALL-SAVED-X18: "-target-feature" "+call-saved-x18"
Index: lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- lib/Driver/ToolChains/Arch/AArch64.cpp
+++ lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -225,6 +225,33 @@
   if (Args.hasArg(options::OPT_ffixed_x20))
 Features.push_back("+reserve-x20");
 
+  if (Args.hasArg(options::OPT_fcall_saved_x8))
+Features.push_back("+call-saved-x8");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x9))
+Features.push_back("+call-saved-x9");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x10))
+Features.push_back("+call-saved-x10");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x11))
+Features.push_back("+call-saved-x11");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x12))
+Features.push_back("+call-saved-x12");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x13))
+Features.push_back("+call-saved-x13");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x14))
+Features.push_back("+call-saved-x14");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x15))
+Features.push_back("+call-saved-x15");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x18))
+Features.push_back("+call-saved-x18");
+
   if (Args.hasArg(options::OPT_mno_neg_immediates))
 Features.push_back("+no-neg-immediates");
 }
Index: include/clang/Drive

[PATCH] D48184: [Power9] [CLANG] Add __float128 exponent GET and SET builtins

2018-09-24 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342911: [Power9] [CLANG] Add __float128 exponent GET and SET 
builtins (authored by stefanp, committed by ).
Herald added subscribers: cfe-commits, jsji, kristina.

Changed prior to commit:
  https://reviews.llvm.org/D48184?vs=151392&id=166721#toc

Repository:
  rC Clang

https://reviews.llvm.org/D48184

Files:
  include/clang/Basic/BuiltinsPPC.def
  test/CodeGen/builtins-ppc-p9-f128.c


Index: include/clang/Basic/BuiltinsPPC.def
===
--- include/clang/Basic/BuiltinsPPC.def
+++ include/clang/Basic/BuiltinsPPC.def
@@ -431,6 +431,8 @@
 BUILTIN(__builtin_divf128_round_to_odd, "LLdLLdLLd", "")
 BUILTIN(__builtin_fmaf128_round_to_odd, "LLdLLdLLdLLd", "")
 BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
+BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
+BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
Index: test/CodeGen/builtins-ppc-p9-f128.c
===
--- test/CodeGen/builtins-ppc-p9-f128.c
+++ test/CodeGen/builtins-ppc-p9-f128.c
@@ -48,3 +48,15 @@
 // CHECK-NEXT: ret double
 }
 
+__float128 insert_exp_qp(unsigned long long int b) {
+  return __builtin_vsx_scalar_insert_exp_qp(A, b);
+// CHECK: @llvm.ppc.scalar.insert.exp.qp(fp128 %{{.+}}, i64
+// CHECK-NEXT: ret fp128
+}
+
+unsigned long long int extract_exp() {
+  return __builtin_vsx_scalar_extract_expq(A);
+// CHECK: @llvm.ppc.scalar.extract.expq(fp128
+// CHECK-NEXT: ret i64
+}
+


Index: include/clang/Basic/BuiltinsPPC.def
===
--- include/clang/Basic/BuiltinsPPC.def
+++ include/clang/Basic/BuiltinsPPC.def
@@ -431,6 +431,8 @@
 BUILTIN(__builtin_divf128_round_to_odd, "LLdLLdLLd", "")
 BUILTIN(__builtin_fmaf128_round_to_odd, "LLdLLdLLdLLd", "")
 BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
+BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
+BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
Index: test/CodeGen/builtins-ppc-p9-f128.c
===
--- test/CodeGen/builtins-ppc-p9-f128.c
+++ test/CodeGen/builtins-ppc-p9-f128.c
@@ -48,3 +48,15 @@
 // CHECK-NEXT: ret double
 }
 
+__float128 insert_exp_qp(unsigned long long int b) {
+  return __builtin_vsx_scalar_insert_exp_qp(A, b);
+// CHECK: @llvm.ppc.scalar.insert.exp.qp(fp128 %{{.+}}, i64
+// CHECK-NEXT: ret fp128
+}
+
+unsigned long long int extract_exp() {
+  return __builtin_vsx_scalar_extract_expq(A);
+// CHECK: @llvm.ppc.scalar.extract.expq(fp128
+// CHECK-NEXT: ret i64
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342911 - [Power9] [CLANG] Add __float128 exponent GET and SET builtins

2018-09-24 Thread Stefan Pintilie via cfe-commits
Author: stefanp
Date: Mon Sep 24 11:14:50 2018
New Revision: 342911

URL: http://llvm.org/viewvc/llvm-project?rev=342911&view=rev
Log:
[Power9] [CLANG] Add __float128 exponent GET and SET builtins

Added

__builtin_vsx_scalar_extract_expq
__builtin_vsx_scalar_insert_exp_qp

Builtins should behave the same way as in GCC.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=342911&r1=342910&r2=342911&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Mon Sep 24 11:14:50 2018
@@ -431,6 +431,8 @@ BUILTIN(__builtin_mulf128_round_to_odd,
 BUILTIN(__builtin_divf128_round_to_odd, "LLdLLdLLd", "")
 BUILTIN(__builtin_fmaf128_round_to_odd, "LLdLLdLLdLLd", "")
 BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
+BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
+BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")

Modified: cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c?rev=342911&r1=342910&r2=342911&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c Mon Sep 24 11:14:50 2018
@@ -48,3 +48,15 @@ double testTruncOdd() {
 // CHECK-NEXT: ret double
 }
 
+__float128 insert_exp_qp(unsigned long long int b) {
+  return __builtin_vsx_scalar_insert_exp_qp(A, b);
+// CHECK: @llvm.ppc.scalar.insert.exp.qp(fp128 %{{.+}}, i64
+// CHECK-NEXT: ret fp128
+}
+
+unsigned long long int extract_exp() {
+  return __builtin_vsx_scalar_extract_expq(A);
+// CHECK: @llvm.ppc.scalar.extract.expq(fp128
+// CHECK-NEXT: ret i64
+}
+


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


r342909 - Fix the type of 1<<31 integer constants.

2018-09-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Sep 24 10:51:15 2018
New Revision: 342909

URL: http://llvm.org/viewvc/llvm-project?rev=342909&view=rev
Log:
Fix the type of 1<<31 integer constants.

Shifting into the sign bit is technically undefined behavior. No known
compiler exploits it though.

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/CodeGen/CGBlocks.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=342909&r1=342908&r2=342909&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Sep 24 10:51:15 2018
@@ -449,7 +449,7 @@ namespace SrcMgr {
 }
 
 static SLocEntry get(unsigned Offset, const FileInfo &FI) {
-  assert(!(Offset & (1 << 31)) && "Offset is too large");
+  assert(!(Offset & (1u << 31)) && "Offset is too large");
   SLocEntry E;
   E.Offset = Offset;
   E.IsExpansion = false;
@@ -458,7 +458,7 @@ namespace SrcMgr {
 }
 
 static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) {
-  assert(!(Offset & (1 << 31)) && "Offset is too large");
+  assert(!(Offset & (1u << 31)) && "Offset is too large");
   SLocEntry E;
   E.Offset = Offset;
   E.IsExpansion = true;

Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=342909&r1=342908&r2=342909&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Mon Sep 24 10:51:15 2018
@@ -60,7 +60,7 @@ enum BlockLiteralFlags {
   BLOCK_IS_GLOBAL = (1 << 28),
   BLOCK_USE_STRET = (1 << 29),
   BLOCK_HAS_SIGNATURE  =(1 << 30),
-  BLOCK_HAS_EXTENDED_LAYOUT = (1 << 31)
+  BLOCK_HAS_EXTENDED_LAYOUT = (1u << 31)
 };
 class BlockFlags {
   uint32_t flags;


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


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Maybe just move `StdCLibraryFunctionsChecker` to `core`? (`.apiModeling`?) We 
officially don't support disabling `core`, so i guess it kinda solves the 
issue. Also all of our languages are C-based, these functions are present on 
all platforms (if any of those aren't, we could split them out and keep in 
`unix`).


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/conversion.c:158
 extern int dostuff (void);
 int falsePositive2() {
   int c, n;

And this one


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:12380-12382
   }
 
+  if (LangOpts.CPlusPlus && II) {

lebedev.ri wrote:
> I think you could move it into the `if()` above?
You are correct, I'll hoist it.


https://reviews.llvm.org/D52421



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


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 166716.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated based on review feedback.


https://reviews.llvm.org/D52421

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -62,7 +62,7 @@
   void test() {
 char *field; // expected-warning {{declaration shadows a field of 'A'}}
 char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
-char *a1; // no warning 
+char *a1; // no warning
 char *a2; // no warning
 char *jj; // no warning
 char *jjj; // no warning
@@ -199,8 +199,8 @@
   using l=char; // no warning or error.
   using l=char; // no warning or error.
   typedef char l; // no warning or error.
- 
-  typedef char n; // no warning or error. 
+
+  typedef char n; // no warning or error.
   typedef char n; // no warning or error.
   using n=char; // no warning or error.
 }
@@ -222,3 +222,31 @@
   };
 }
 }
+
+namespace PR34120 {
+struct A {
+  int B; // expected-note {{declared here}}
+};
+
+class C : public A {
+  void D(int B) {} // expected-warning {{parameter 'B' shadows member inherited from type 'A'}}
+  void E() {
+extern void f(int B); // Ok
+  }
+};
+
+class Private {
+  int B;
+};
+class Derived : Private {
+  void D(int B) {} // Ok
+};
+
+struct Static {
+  static int B;
+};
+
+struct Derived2 : Static {
+  void D(int B) {}
+};
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2852,7 +2852,8 @@
 // Check if there is a field shadowing.
 void Sema::CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD) {
+  const CXXRecordDecl *RD,
+  bool DeclIsField) {
   if (Diags.isIgnored(diag::warn_shadow_field, Loc))
 return;
 
@@ -2892,7 +2893,7 @@
 if (AS_none !=
 CXXRecordDecl::MergeAccess(P.Access, BaseField->getAccess())) {
   Diag(Loc, diag::warn_shadow_field)
-<< FieldName << RD << Base;
+<< FieldName << RD << Base << DeclIsField;
   Diag(BaseField->getLocation(), diag::note_shadow_field);
   Bases.erase(It);
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12377,6 +12377,13 @@
 D.setInvalidType(true);
   }
 }
+
+if (LangOpts.CPlusPlus) {
+  DeclarationNameInfo DNI = GetNameForDeclarator(D);
+  if (auto *RD = dyn_cast(CurContext))
+CheckShadowInheritedFields(DNI.getLoc(), DNI.getName(), RD,
+   /*DeclIsField*/ false);
+}
   }
 
   // Temporarily put parameter variables in the translation unit, not
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -10524,7 +10524,8 @@
   /// Check if there is a field shadowing.
   void CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD);
+  const CXXRecordDecl *RD,
+  bool DeclIsField = true);
 
   /// Check if the given expression contains 'break' or 'continue'
   /// statement that produces control flow different from GCC.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9418,10 +9418,9 @@
   "__final is a GNU extension, consider using C++11 final">,
   InGroup;
 
-def warn_shadow_field :
-  Warning<"non-static data member %0 of %1 shadows member inherited from "
-  "type %2">,
-  InGroup, DefaultIgnore;
+def warn_shadow_field : Warning<
+  "%select{parameter|non-static data member}3 %0 %select{|of %1 }3shadows "
+  "member inherited from type %2">, InGroup, DefaultIgnore;
 def note_shadow_field : Note<"declared here">;
 
 def err_multiversion_required_in_redecl : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

The concept makes sense. @NoQ any comments? I don't recall seeing that pattern 
before.




Comment at: test/Analysis/conversion.c:144
 int isascii(int c);
 void falsePositive1() {
   char kb2[5];

Also the function name should be changed as well


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thanks!




Comment at: lib/Sema/SemaDecl.cpp:12380-12382
   }
 
+  if (LangOpts.CPlusPlus && II) {

I think you could move it into the `if()` above?


https://reviews.llvm.org/D52421



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


[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-09-24 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D52296#1241928, @probinson wrote:

> Do we generate the .dwo file directly these days?  If not, I can imagine 
> wanting to avoid the overhead of the objcopy hack; as long as the linker is 
> smart enough not to bother with the .debug_*.dwo sections this seems like a 
> build-time win.


We do generate them generically with no objcopy hack.

As far as the standard text here, IMO it was just there in case people didn't 
have an objcopy around or don't want to split it. I'm not sure why we would 
want the ability. That said, if we do I'd rather have it as dwarf5 without 
split-dwarf as an option rather than a -gsingle-file-split-dwarf option.


https://reviews.llvm.org/D52296



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


[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-09-24 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D52296#1241928, @probinson wrote:

> Do we generate the .dwo file directly these days?  If not, I can imagine 
> wanting to avoid the overhead of the objcopy hack; as long as the linker is 
> smart enough not to bother with the .debug_*.dwo sections this seems like a 
> build-time win.


We do generate them generically with no objcopy hack.

As far as the standard text here, IMO it was just there in case people didn't 
have an objcopy around or don't want to split it. I'm not sure why we would 
want the ability. That said, if we do I'd rather have it as dwarf5 without 
split-dwarf as an option rather than a -gsingle-file-split-dwarf option.


https://reviews.llvm.org/D52296



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


[PATCH] D52273: [clangd] Initial implementation of expected types

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ExpectedTypes.h:68
+
+/// Represents a type of partially applied conversion. Should be treated as an
+/// opaque value and can only be used to check whether the types are converible

sammccall wrote:
> this represents a type (in the c++ sense), not a conversion, right?
It's an "expression" with an extra data with some extra data (whether the user 
conversion was applied to get this expression)



Comment at: clangd/ExpectedTypes.h:82
+  static llvm::SmallVector
+  fromCompletionResult(ASTContext &Ctx, const CodeCompletionResult &R);
+

sammccall wrote:
> coupling to CompletionResult seems premature here, can we stick to passing 
> getExpectedType() until we know that abstraction needs to be broken?
There's some useful logic that is tied to completion results, e.g. to extract 
function return type `CompletionResult`.
Happy to accept a decl, but would keep the name `fromCompletionResult`. Does 
that LG?



Comment at: clangd/ExpectedTypes.h:213
+
+void collectConvertibleFrom(ASTContext &Ctx, MockExpr Source,
+llvm::function_ref OutF);

sammccall wrote:
> sammccall wrote:
> > why is implementing one of these directions not enough?
> > 
> > It should probably be:
> > As far as I can tell, derived-to-base is the tricky one here: it's an 
> > important conversion (albeit one we should leave out of the first patch), 
> > and you can't ask "what's convertible to base" since the answer is an open 
> > set you can't see.
> > 
> > So it seems the minimal set you need for handling pointer to base is `Type 
> > getRepresentative(Type)` and `set 
> > getRepresentativesAfterConversion(Type)` or so...
> names are unclear: is `collectConvertibleFrom(T)` the convertible-from types 
> for T (i.e the types T is convertible from), or the types that are 
> convertible from T?
Derived-to-base and user conversions.

We can't enumerate all derived classes for some type, so instead need to 
enumerate all bases when adding a symbol to the index.
We can't enumerate all types that have user-defined conversions to some type T, 
so we need to enumerate all user-defined conversions when adding a symbol 
instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D52252: Driver: render arguments for the embedded bitcode correctly

2018-09-24 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Thanks for doing this!

Can you add some test cases just to be complete? Other than that, LGTM!


Repository:
  rC Clang

https://reviews.llvm.org/D52252



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


[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-09-24 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 166710.
shuaiwang added a comment.

Added test case place holder for cases that should be supported in later 
patches.


Repository:
  rC Clang

https://reviews.llvm.org/D52219

Files:
  include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -52,11 +52,21 @@
 bool isMutated(const SmallVectorImpl &Results, ASTUnit *AST) {
   const auto *const S = selectFirst("stmt", Results);
   const auto *const E = selectFirst("expr", Results);
+  assert(S && E);
   return ExprMutationAnalyzer(*S, AST->getASTContext()).isMutated(E);
 }
 
+bool isPointeeMutated(const SmallVectorImpl &Results,
+  ASTUnit *AST) {
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);
+  assert(S && E);
+  return ExprMutationAnalyzer(*S, AST->getASTContext()).isPointeeMutated(E);
+}
+
 SmallVector
 mutatedBy(const SmallVectorImpl &Results, ASTUnit *AST) {
+  EXPECT_TRUE(isMutated(Results, AST));
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
@@ -71,6 +81,19 @@
   return Chain;
 }
 
+std::string pointeeMutatedBy(const SmallVectorImpl &Results,
+ ASTUnit *AST) {
+  EXPECT_TRUE(isPointeeMutated(Results, AST));
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);
+  ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+  const Stmt *By = Analyzer.findPointeeMutation(E);
+  std::string buffer;
+  llvm::raw_string_ostream stream(buffer);
+  By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
+  return StringRef(stream.str()).trim().str();
+}
+
 std::string removeSpace(std::string s) {
   s.erase(std::remove_if(s.begin(), s.end(),
  [](char c) { return std::isspace(c); }),
@@ -100,10 +123,14 @@
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
-  const auto AST = buildASTFromCode("void f() { int x; x; }");
-  const auto Results =
+  auto AST = buildASTFromCode("void f() { int x; x; }");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = buildASTFromCode("void f() { const int x = 0; x; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
 class AssignmentTest : public ::testing::TestWithParam {};
@@ -134,41 +161,111 @@
 Values("++x", "--x", "x++", "x--"), );
 
 TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) {
-  const auto AST = buildASTFromCode(
+  auto AST = buildASTFromCode(
   "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+  EXPECT_FALSE(isPointeeMutated(Results, AST.get()));
+
+  AST = buildASTFromCode(
+  "void f() { struct Foo { void mf(); }; Foo *p; p->mf(); }");
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "p->mf()");
+
+  AST = buildASTFromCode(
+  "void f() { struct Foo { void mf(); }; Foo *x; Foo *&p = x; p->mf(); }");
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "p->mf()");
 }
 
 TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
   auto AST = buildASTFromCodeWithArgs(
   "struct X { template  void mf(); };"
-  "template  void f() { X x; x.mf(); }",
+  "template  void f() { X x; x.mf(); }"
+  "template  void g() { X *p; p->mf(); }",
   {"-fno-delayed-template-parsing"});
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "p->mf()");
 
-  AST = buildASTFromCodeWithArgs("template  void f() { T x; x.mf(); }",
- {"-fno-delayed-template-parsing"});
+  AST =
+  buildASTFromCodeWithArgs("template  void f() { T x; x.mf(); }"
+   "template  void g() { T *p; p->mf(); }",
+   {"-fno-delayed-template

[PATCH] D46443: Add missing cstdalign header

2018-09-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: mclow.lists.
ldionne added a comment.

I believe this header has been deprecated. According to 
http://eel.is/c++draft/diff.cpp17.library, the effect of this header is 
nothing. @mclow.lists can you chime in?


Repository:
  rCXX libc++

https://reviews.llvm.org/D46443



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


[PATCH] D52273: [clangd] Initial implementation of expected types

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> This seems very clever, but extremely complicated - you've implemented much 
> of C++'s conversion logic, it's not clear to me which parts are actually 
> necessary to completion quality.

Clearly the model that supports C++ conversions is something that **will** 
improve code completion quality.
I do agree it's not trivial, but would argue we at least want:

- qualification conversions (i.e. adding const)
- user-defined conversions (e.g. operator bool is commonly useful think)
- derived-to-base conversions (Derived* should convert to Base*)

Without those, we don't support a bunch of useful cases.

> As chatted offline, I think the return type can be split into multiple 
> orthogonal signals. For example, const T & can be split into 3 independent 
> signals {const, type T, reference}. I think this can make the reasoning of 
> boosting/scoring easier for both index and code completion. Agree with Sam 
> that we should start with something simple (e.g. type matching without 
> conversing) and land basic components to make further evaluation possible.

Yeah, I do keep it in mind and I think it's a great idea. E.g., we can put all 
numeric types into one equivalence class and get rid of all numeric conversions.
That adds some complexity to the interface, though, I wanted to measure how the 
trivial solution (enumerate all types) works. To make sure we actually can't 
get away without it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D51568: [modules] Add `-fno-absolute-module-directory` flag for relocatable modules

2018-09-24 Thread Andrew Gallagher via Phabricator via cfe-commits
andrewjcg updated this revision to Diff 166709.
andrewjcg added a comment.

Dropping the module directory entirely and fully resolving paths on 
serialization
broke some things during deserialization, specifically when the deserializer 
wanted
to update paths to use an alternate module directory.

This switches to a different strategy of only relativizing the paths that are
actually under the module home dir, and adding a bit to the serialized paths to
indiciate this.  This bit is read on deserializiation to determine whether the
path is resolved against the module directory or not.


Repository:
  rC Clang

https://reviews.llvm.org/D51568

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderInternals.h
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  test/Modules/relocatable-modules.modulemap

Index: test/Modules/relocatable-modules.modulemap
===
--- /dev/null
+++ test/Modules/relocatable-modules.modulemap
@@ -0,0 +1,29 @@
+// Build two otherwise identical modules in two different directories and
+// verify that using `-fno-absolute-module-directory` makes them identical.
+//
+// RUN: rm -rf %t
+//
+// RUN: mkdir -p %t/p1
+// RUN: cd %t/p1
+// RUN: mkdir -p main other
+// RUN: grep "" %s > main/a.modulemap
+// RUN: grep "" %s > main/a.h
+// RUN: grep "" %s > other/b.h
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fno-absolute-module-directory \
+// RUN:   -fmodule-name="a" -Imain -I. -o - main/a.modulemap > a.pcm
+//
+// RUN: mkdir -p %t/p2
+// RUN: cd %t/p2
+// RUN: mkdir -p main other
+// RUN: grep "" %s > main/a.modulemap
+// RUN: grep "" %s > main/a.h
+// RUN: grep "" %s > other/b.h
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fno-absolute-module-directory \
+// RUN:   -fmodule-name="a" -Imain -I. -o - main/a.modulemap > a.pcm
+//
+// RUN: diff %t/p1/a.pcm %t/p2/a.pcm
+
+module "a" {// 
+}   // 
+
+#include "b.h"  // 
Index: lib/Serialization/GlobalModuleIndex.cpp
===
--- lib/Serialization/GlobalModuleIndex.cpp
+++ lib/Serialization/GlobalModuleIndex.cpp
@@ -628,6 +628,7 @@
 SmallString<128> ImportedFile(Record.begin() + Idx,
   Record.begin() + Idx + Length);
 Idx += Length;
+Idx++;  // Relative
 
 // Find the imported module file.
 const FileEntry *DependsOnFile
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1327,9 +1327,14 @@
 ///
 /// \return \c true if the path was changed.
 static bool cleanPathForOutput(FileManager &FileMgr,
-   SmallVectorImpl &Path) {
-  bool Changed = FileMgr.makeAbsolutePath(Path);
-  return Changed | llvm::sys::path::remove_dots(Path);
+   SmallVectorImpl &Path,
+   bool MakeAbsolute = true) {
+  bool Changed = false;
+  if (MakeAbsolute) {
+Changed |= FileMgr.makeAbsolutePath(Path);
+  }
+  Changed |= llvm::sys::path::remove_dots(Path);
+  return Changed;
 }
 
 /// Adjusts the given filename to only write out the portion of the
@@ -1493,7 +1498,10 @@
 
   if (WritingModule && WritingModule->Directory) {
 SmallString<128> BaseDir(WritingModule->Directory->getName());
-cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
+cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir,
+   !PP.getHeaderSearchInfo()
+.getHeaderSearchOpts()
+.NoAbsoluteModuleDirectory);
 
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
@@ -1708,6 +1716,7 @@
 auto FileAbbrev = std::make_shared();
 FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
+FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relative
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
 
@@ -1772,6 +1781,7 @@
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Overridden
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Transient
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Module map
+  IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relative
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
   unsigned IF

[clang-tools-extra] r342903 - [clangd] Fix uninit bool in r342888

2018-09-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Sep 24 09:52:48 2018
New Revision: 342903

URL: http://llvm.org/viewvc/llvm-project?rev=342903&view=rev
Log:
[clangd] Fix uninit bool in r342888

Modified:
clang-tools-extra/trunk/clangd/index/Serialization.cpp

Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=342903&r1=342902&r2=342903&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Mon Sep 24 09:52:48 
2018
@@ -33,7 +33,7 @@ Error makeError(const Twine &Msg) {
 // Reads binary data from a StringRef, and keeps track of position.
 class Reader {
   const char *Begin, *End;
-  bool Err;
+  bool Err = false;
 
 public:
   Reader(StringRef Data) : Begin(Data.begin()), End(Data.end()) {}


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


[PATCH] D43783: [OpenCL] Remove block invoke function from emitted block literal struct

2018-09-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D43783#1235126, @yaxunl wrote:

> In https://reviews.llvm.org/D43783#1235090, @Anastasia wrote:
>
> > Ping! Do you still plan to do this? :)
>
>
> Sorry I caught up in something else. Since there are some subsequent commits, 
> it may take some efforts to revert it.


No problem. Let me know if help is needed. :)

In https://reviews.llvm.org/D43783#1235126, @yaxunl wrote:

> In https://reviews.llvm.org/D43783#1235090, @Anastasia wrote:
>
> > Ping! Do you still plan to do this? :)
>
>
> Sorry I caught up in something else. Since there are some subsequent commits, 
> it may take some efforts to revert it.


Let me know if you need help. I am happy to do this myself.


Repository:
  rC Clang

https://reviews.llvm.org/D43783



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: test/Sema/gnu89.c:1-2
-// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
+// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-PEDANTIC %s
+// RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck %s
 

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > lebedev.ri wrote:
> > > This ideally needs positive tests. E.g.:
> > > * `-std=c89`
> > > * `-std=c89 -pedantic`
> > > * `-std=gnu99`
> > > * `-std=gnu99 -pedantic`
> > > * `-std=c99`
> > > * `-std=c99 -pedantic`
> > > 
> > Since `typeof` is a gnu extension, its use constitutes an error for all non 
> > gnu C standards, so it's moot to check for duplicate const specifiers from 
> > typeof exprs.
> > 
> > Since we're trying to match GCC's behavior here, GCC does not warn for 
> > `-std=gnu99` or `-std=gnu99 -pedantic` so I will add those test cases.
> https://godbolt.org/z/3trZdl
Ah, I can still put CHECKs for errors.  Will add additional tests.


Repository:
  rC Clang

https://reviews.llvm.org/D52248



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


[PATCH] D52422: [clangd] Handle template args for disabled function arg snippets

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/CodeComplete.cpp:1699
+  if (Opts.EnableSnippets) {
+log("Suffix: {0}", SnippetSuffix);
 LSP.textEdit->newText += SnippetSuffix;

Sorry, leftover from debug printing. Will remove


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52422



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


[PATCH] D52420: [clangd] Fix crash if pending computations were active on exit

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:483
+  // Destroy ClangdServer to ensure all worker threads finish.
+  Server.reset();
 

ioeric wrote:
> This woudn't work if `run()` is called multiple times. Maybe create a 
> `Server` in each `run()`? 
run() asserts it's never called multiple times, so we don't break the contract.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52420



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


[libunwind] r342901 - Reverting r342895

2018-09-24 Thread Luke Cheeseman via cfe-commits
Author: lukecheeseman
Date: Mon Sep 24 09:36:33 2018
New Revision: 342901

URL: http://llvm.org/viewvc/llvm-project?rev=342901&view=rev
Log:
Reverting r342895

- The used builtins do not compile for pre arm v8.3a targets with gcc


Modified:
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/dwarf2.h

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Mon Sep 24 09:36:33 2018
@@ -57,9 +57,6 @@ enum {
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
-#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
-  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
-#endif
 };
 
 struct unw_context_t {
@@ -550,8 +547,6 @@ enum {
   UNW_ARM64_X31 = 31,
   UNW_ARM64_SP  = 31,
   // reserved block
-  UNW_ARM64_RA_SIGN_STATE = 34,
-  // reserved block
   UNW_ARM64_D0  = 64,
   UNW_ARM64_D1  = 65,
   UNW_ARM64_D2  = 66,

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Mon Sep 24 09:36:33 2018
@@ -198,24 +198,6 @@ int DwarfInstructions::stepWithDwa
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
-#if defined(_LIBUNWIND_TARGET_AARCH64)
-  // If the target is aarch64 then the return address may have been signed
-  // using the v8.3 pointer authentication extensions. The original
-  // return address needs to be authenticated before the return address is
-  // restored. autia1716 is used instead of autia as autia1716 assembles
-  // to a NOP on pre-v8.3a architectures.
-  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
-#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
-return UNW_ECROSSRASIGNING;
-#else
-register unsigned long long x17 __asm("x17") = returnAddress;
-register unsigned long long x16 __asm("x16") = cfa;
-asm("autia1716": "+r"(x17): "r"(x16));
-returnAddress = x17;
-#endif
-  }
-#endif
-
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Mon Sep 24 09:36:33 2018
@@ -666,14 +666,6 @@ bool CFI_Parser::parseInstructions(A
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
-
-#if defined(_LIBUNWIND_TARGET_AARCH64)
-case DW_CFA_AARCH64_negate_ra_state:
-  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
-  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
-  break;
-#endif
-
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Mon Sep 24 09:36:33 2018
@@ -1786,7 +1786,7 @@ private:
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t __ra_sign_state; // RA sign state register
+uint64_t padding; // 16-byte align
   };
 
   GPRs_registers;
@@ -1822,8 +1822,6 @@ inline bool Registers_arm64::validRegist
 return false;
   if (regNum > 95)
 return false;
-  if (regNum == UNW_ARM64_RA_SIGN_STATE)
-return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   return true;
@@ -1834,11 +1832,8 @@ inline uint64_t Registers_arm64::getRegi
 return _registers.__pc;
   if (regNum == UNW_REG_SP)
 return _registers.__sp;
-  if (regNum == UNW_ARM64_RA_SIGN_STATE)
-return _registers.__ra_sign_state;
   if ((regNum >= 0) && (regNum < 32))
 return _registers.__x[regNum];
-
   _LIBUNWIND_AB

[PATCH] D50171: [python] [tests] Update test_code_completion

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

Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D50171



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


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-24 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342897: [python] [tests] Update test_code_completion 
(authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50171?vs=164871&id=166703#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50171

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


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342897 - [python] [tests] Update test_code_completion

2018-09-24 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Sep 24 09:10:25 2018
New Revision: 342897

URL: http://llvm.org/viewvc/llvm-project?rev=342897&view=rev
Log:
[python] [tests] Update test_code_completion

Update expected completions to match output generated by clang-7.0.

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

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

Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=342897&r1=342896&r2=342897&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Mon Sep 24 
09:10:25 2018
@@ -61,11 +61,11 @@ void f(P x, Q y) {
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


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


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D50171#1236792, @mgorny wrote:

> @ilya-biryukov, gentle ping. I'd like to patch this for 7.0.0 in Gentoo. Do 
> you think my patch would be good enough, or do you expect to submit something 
> else soonish?


Sorry about the delay.
LGTM to allow committing/cherrypicking. I'll make sure to investigate why the 
change was there and explain/fix this case and update this thread.


https://reviews.llvm.org/D50171



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


[libunwind] r342895 - [AArch64] Unwinding support for return address signing

2018-09-24 Thread Luke Cheeseman via cfe-commits
Author: lukecheeseman
Date: Mon Sep 24 08:55:35 2018
New Revision: 342895

URL: http://llvm.org/viewvc/llvm-project?rev=342895&view=rev
Log:
[AArch64] Unwinding support for return address signing

- When return address signing is enabled, the LR may be signed on function entry
- When an exception is thrown the return address is inspected used to unwind 
the call stack
- Before this happens, the return address must be correctly authenticated to 
avoid causing an abort by dereferencing the signed pointer

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


Modified:
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/dwarf2.h

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Mon Sep 24 08:55:35 2018
@@ -57,6 +57,9 @@ enum {
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
+#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
+#endif
 };
 
 struct unw_context_t {
@@ -547,6 +550,8 @@ enum {
   UNW_ARM64_X31 = 31,
   UNW_ARM64_SP  = 31,
   // reserved block
+  UNW_ARM64_RA_SIGN_STATE = 34,
+  // reserved block
   UNW_ARM64_D0  = 64,
   UNW_ARM64_D1  = 65,
   UNW_ARM64_D2  = 66,

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Mon Sep 24 08:55:35 2018
@@ -198,6 +198,24 @@ int DwarfInstructions::stepWithDwa
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+  // If the target is aarch64 then the return address may have been signed
+  // using the v8.3 pointer authentication extensions. The original
+  // return address needs to be authenticated before the return address is
+  // restored. autia1716 is used instead of autia as autia1716 assembles
+  // to a NOP on pre-v8.3a architectures.
+  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
+#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+return UNW_ECROSSRASIGNING;
+#else
+register unsigned long long x17 __asm("x17") = returnAddress;
+register unsigned long long x16 __asm("x16") = cfa;
+asm("autia1716": "+r"(x17): "r"(x16));
+returnAddress = x17;
+#endif
+  }
+#endif
+
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Mon Sep 24 08:55:35 2018
@@ -666,6 +666,14 @@ bool CFI_Parser::parseInstructions(A
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
+
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+case DW_CFA_AARCH64_negate_ra_state:
+  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
+  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
+  break;
+#endif
+
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Mon Sep 24 08:55:35 2018
@@ -1786,7 +1786,7 @@ private:
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t padding; // 16-byte align
+uint64_t __ra_sign_state; // RA sign state register
   };
 
   GPRs_registers;
@@ -1822,6 +1822,8 @@ inline bool Registers_arm64::validRegist
 return false;
   if (regNum > 95)
 return false;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   retur

[PATCH] D51432: [AArch64] Unwinding support for return address signing

2018-09-24 Thread Luke Cheeseman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342895: [AArch64] Unwinding support for return address 
signing (authored by LukeCheeseman, committed by ).
Herald added subscribers: llvm-commits, christof.

Changed prior to commit:
  https://reviews.llvm.org/D51432?vs=165775&id=166700#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51432

Files:
  libunwind/trunk/include/libunwind.h
  libunwind/trunk/src/DwarfInstructions.hpp
  libunwind/trunk/src/DwarfParser.hpp
  libunwind/trunk/src/Registers.hpp
  libunwind/trunk/src/dwarf2.h

Index: libunwind/trunk/src/DwarfInstructions.hpp
===
--- libunwind/trunk/src/DwarfInstructions.hpp
+++ libunwind/trunk/src/DwarfInstructions.hpp
@@ -198,6 +198,24 @@
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+  // If the target is aarch64 then the return address may have been signed
+  // using the v8.3 pointer authentication extensions. The original
+  // return address needs to be authenticated before the return address is
+  // restored. autia1716 is used instead of autia as autia1716 assembles
+  // to a NOP on pre-v8.3a architectures.
+  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
+#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+return UNW_ECROSSRASIGNING;
+#else
+register unsigned long long x17 __asm("x17") = returnAddress;
+register unsigned long long x16 __asm("x16") = cfa;
+asm("autia1716": "+r"(x17): "r"(x16));
+returnAddress = x17;
+#endif
+  }
+#endif
+
   // Return address is address after call site instruction, so setting IP to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);
Index: libunwind/trunk/src/dwarf2.h
===
--- libunwind/trunk/src/dwarf2.h
+++ libunwind/trunk/src/dwarf2.h
@@ -49,7 +49,10 @@
   // GNU extensions
   DW_CFA_GNU_window_save  = 0x2D,
   DW_CFA_GNU_args_size= 0x2E,
-  DW_CFA_GNU_negative_offset_extended = 0x2F
+  DW_CFA_GNU_negative_offset_extended = 0x2F,
+
+  // AARCH64 extensions
+  DW_CFA_AARCH64_negate_ra_state  = 0x2D
 };
 
 
Index: libunwind/trunk/src/DwarfParser.hpp
===
--- libunwind/trunk/src/DwarfParser.hpp
+++ libunwind/trunk/src/DwarfParser.hpp
@@ -666,6 +666,14 @@
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
+
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+case DW_CFA_AARCH64_negate_ra_state:
+  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
+  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
+  break;
+#endif
+
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {
Index: libunwind/trunk/src/Registers.hpp
===
--- libunwind/trunk/src/Registers.hpp
+++ libunwind/trunk/src/Registers.hpp
@@ -1786,7 +1786,7 @@
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t padding; // 16-byte align
+uint64_t __ra_sign_state; // RA sign state register
   };
 
   GPRs_registers;
@@ -1822,6 +1822,8 @@
 return false;
   if (regNum > 95)
 return false;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   return true;
@@ -1832,16 +1834,21 @@
 return _registers.__pc;
   if (regNum == UNW_REG_SP)
 return _registers.__sp;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return _registers.__ra_sign_state;
   if ((regNum >= 0) && (regNum < 32))
 return _registers.__x[regNum];
+
   _LIBUNWIND_ABORT("unsupported arm64 register");
 }
 
 inline void Registers_arm64::setRegister(int regNum, uint64_t value) {
   if (regNum == UNW_REG_IP)
 _registers.__pc = value;
   else if (regNum == UNW_REG_SP)
 _registers.__sp = value;
+  else if (regNum == UNW_ARM64_RA_SIGN_STATE)
+_registers.__ra_sign_state = value;
   else if ((regNum >= 0) && (regNum < 32))
 _registers.__x[regNum] = value;
   else
Index: libunwind/trunk/include/libunwind.h
===
--- libunwind/trunk/include/libunwind.h
+++ libunwind/trunk/include/libunwind.h
@@ -57,6 +57,9 @@
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
+#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
+#endif
 };
 
 struct unw_context_t {
@@ -547,6 +550,8 @@
   UNW_ARM64_

[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus edited reviewers, added: NoQ; removed: dergachev.a.
Szelethus added a comment.

Cool!




Comment at: test/Analysis/conversion.c:141
 
-// false positives..
+// old false positives..
 

I think this comment is no longer relevant ^-^


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


r342893 - Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`."

2018-09-24 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Mon Sep 24 08:26:08 2018
New Revision: 342893

URL: http://llvm.org/viewvc/llvm-project?rev=342893&view=rev
Log:
Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with 
`-fconstant-cfstrings`."

Seems to be causing buildbot failures, need to look into it.


Removed:
cfe/trunk/test/CodeGen/cfstring-elf.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/CFStrings.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342893&r1=342892&r2=342893&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 24 08:26:08 2018
@@ -4109,48 +4109,37 @@ CodeGenModule::GetAddrOfConstantCFString
 
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
-  
+
   // If we don't already have it, get __CFConstantStringClassReference.
   if (!CFConstantStringClassRef) {
 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
 Ty = llvm::ArrayType::get(Ty, 0);
-llvm::Constant *C =
-CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
-
-if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) {
-  llvm::GlobalValue *GV = nullptr;
-  
-  if ((GV = dyn_cast(C))) {
-IdentifierInfo &II = getContext().Idents.get(GV->getName());
-TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
-DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
-
-const VarDecl *VD = nullptr;
-for (const auto &Result : DC->lookup(&II))
-  if ((VD = dyn_cast(Result)))
-break;
-  
-if (getTriple().isOSBinFormatELF()) {
-  if (!VD)
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-}
-else {
-  if (!VD || !VD->hasAttr()) {
-GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  } else {
-GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  }
-}
-
-setDSOLocal(GV);
+llvm::GlobalValue *GV = cast(
+CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"));
+
+if (getTriple().isOSBinFormatCOFF()) {
+  IdentifierInfo &II = getContext().Idents.get(GV->getName());
+  TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
+  DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
+
+  const VarDecl *VD = nullptr;
+  for (const auto &Result : DC->lookup(&II))
+if ((VD = dyn_cast(Result)))
+  break;
+
+  if (!VD || !VD->hasAttr()) {
+GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  } else {
+GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
 }
-  
+setDSOLocal(GV);
+
 // Decay array -> ptr
 CFConstantStringClassRef =
-llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
+llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
   }
 
   QualType CFTy = getContext().getCFConstantStringType();
@@ -4196,11 +4185,7 @@ CodeGenModule::GetAddrOfConstantCFString
   if (getTriple().isOSBinFormatMachO())
 GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
-  // Make sure the literal ends up in .rodata to allow for safe ICF and for
-  // the static linker to adjust permissions to read-only later on.
-  else if (getTriple().isOSBinFormatELF())
-GV->setSection(".rodata");
-  
+
   // String.
   llvm::Constant *Str =
   llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);

Modified: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=342893&r1=342892&r2=342893&view=diff
==
--- cfe/trunk/test/CodeGen/CFStrings.c (original)
+++ cfe/trunk/test/CodeGen/CFStrings.c Mon Sep 24 08:26:08 2018
@@ -22,7 +22,7 @@ const CFStringRef one = (CFStringRef)__b
 const CFStringRef two = 
(CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f");
 
 // CHECK-COFF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 
1
-// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section ".rodata", align 1
+// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1
 // CHECK-MACHO: @.str = private unnamed_addr constant

[PATCH] D52420: [clangd] Fix crash if pending computations were active on exit

2018-09-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:483
+  // Destroy ClangdServer to ensure all worker threads finish.
+  Server.reset();
 

This woudn't work if `run()` is called multiple times. Maybe create a `Server` 
in each `run()`? 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52420



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


[PATCH] D52423: Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy created this revision.
donat.nagy added a reviewer: dergachev.a.
Herald added a subscriber: cfe-commits.

ConversionChecker produces false positives when it encounters the
idiomatic usage of certain well-known functions (e.g. getc() and the
character classification functions like isalpha()). To eliminate these
false positives, the analyzer needs some information about semantics of
these functions. This functionality have been implemented already in
StdCLibraryFunctionsChecker, so we simply load that automatically when
ConversionChecker is loaded.


Repository:
  rC Clang

https://reviews.llvm.org/D52423

Files:
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
  test/Analysis/conversion.c


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -138,15 +138,14 @@
 }
 
 
-// false positives..
+// old false positives..
 
 int isascii(int c);
 void falsePositive1() {
   char kb2[5];
   int X = 1000;
   if (isascii(X)) {
-// FIXME: should not warn here:
-kb2[0] = X; // expected-warning {{Loss of precision}}
+kb2[0] = X; // no-warning
   }
 }
 
@@ -175,8 +174,7 @@
   if (c == EOF)
 return(4);
   if (cp < &reply_string[sizeof(reply_string) - 1])
-// FIXME: should not warn here:
-*cp++ = c; // expected-warning {{Loss of precision}}
+*cp++ = c; // no-warning
 }
   }
 }
Index: lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
===
--- lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
+++ lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
@@ -23,5 +23,8 @@
 /// Register the part of MallocChecker connected to InnerPointerChecker.
 void registerInnerPointerCheckerAux(CheckerManager &Mgr);
 
+/// Register evaluation of some basic C standard library functions.
+void registerStdCLibraryFunctionsChecker(CheckerManager &mgr);
+
 }}
 #endif /* INTERCHECKERAPI_H_ */
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -23,6 +23,7 @@
 //
 
//===--===//
 #include "ClangSACheckers.h"
+#include "InterCheckerAPI.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -159,5 +160,6 @@
 }
 
 void ento::registerConversionChecker(CheckerManager &mgr) {
+  registerStdCLibraryFunctionsChecker(mgr);
   mgr.registerChecker();
 }


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -138,15 +138,14 @@
 }
 
 
-// false positives..
+// old false positives..
 
 int isascii(int c);
 void falsePositive1() {
   char kb2[5];
   int X = 1000;
   if (isascii(X)) {
-// FIXME: should not warn here:
-kb2[0] = X; // expected-warning {{Loss of precision}}
+kb2[0] = X; // no-warning
   }
 }
 
@@ -175,8 +174,7 @@
   if (c == EOF)
 return(4);
   if (cp < &reply_string[sizeof(reply_string) - 1])
-// FIXME: should not warn here:
-*cp++ = c; // expected-warning {{Loss of precision}}
+*cp++ = c; // no-warning
 }
   }
 }
Index: lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
===
--- lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
+++ lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
@@ -23,5 +23,8 @@
 /// Register the part of MallocChecker connected to InnerPointerChecker.
 void registerInnerPointerCheckerAux(CheckerManager &Mgr);
 
+/// Register evaluation of some basic C standard library functions.
+void registerStdCLibraryFunctionsChecker(CheckerManager &mgr);
+
 }}
 #endif /* INTERCHECKERAPI_H_ */
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -23,6 +23,7 @@
 //
 //===--===//
 #include "ClangSACheckers.h"
+#include "InterCheckerAPI.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -159,5 +160,6 @@
 }
 
 void ento::registerConversionChecker(CheckerManager &mgr) {
+  registerStdCLibraryFunctionsChecker(mgr);
   mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52422: [clangd] Handle template args for disabled function arg snippets

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: kadircet, ioeric, sammccall.
Herald added subscribers: arphaman, jkorous, MaskRay.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52422

Files:
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1741,32 +1741,65 @@
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;
   Opts.EnableFunctionArgSnippets = false;
-  const std::string Header =
-  R"cpp(
+
+  {
+auto Results = completions(
+R"cpp(
   void xfoo();
   void xfoo(int x, int y);
-  void xbar();
-  void f() {
-)cpp";
-  {
-auto Results = completions(Header + "\nxfo^", {}, Opts);
+  void f() { xfo^ })cpp",
+{}, Opts);
 EXPECT_THAT(
 Results.Completions,
 UnorderedElementsAre(AllOf(Named("xfoo"), SnippetSuffix("()")),
  AllOf(Named("xfoo"), SnippetSuffix("($0)";
   }
   {
-auto Results = completions(Header + "\nxba^", {}, Opts);
+auto Results = completions(
+R"cpp(
+  void xbar();
+  void f() { xba^ })cpp",
+{}, Opts);
 EXPECT_THAT(Results.Completions, UnorderedElementsAre(AllOf(
  Named("xbar"), SnippetSuffix("()";
   }
   {
 Opts.BundleOverloads = true;
-auto Results = completions(Header + "\nxfo^", {}, Opts);
+auto Results = completions(
+R"cpp(
+  void xfoo();
+  void xfoo(int x, int y);
+  void f() { xfo^ })cpp",
+{}, Opts);
 EXPECT_THAT(
 Results.Completions,
 UnorderedElementsAre(AllOf(Named("xfoo"), SnippetSuffix("($0)";
   }
+  {
+auto Results = completions(
+R"cpp(
+  template 
+  void xfoo(int a, U b);
+  void f() { xfo^ })cpp",
+{}, Opts);
+EXPECT_THAT(
+Results.Completions,
+UnorderedElementsAre(AllOf(Named("xfoo"), SnippetSuffix("<$1>($0)";
+  }
+  {
+auto Results = completions(
+R"cpp(
+  template 
+  class foo_class{};
+  template 
+  using foo_alias = T**;
+  void f() { foo_^ })cpp",
+{}, Opts);
+EXPECT_THAT(
+Results.Completions,
+UnorderedElementsAre(AllOf(Named("foo_class"), SnippetSuffix("<$0>")),
+ AllOf(Named("foo_alias"), SnippetSuffix("<$0>";
+  }
 }
 
 TEST(CompletionTest, SuggestOverrides) {
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -46,6 +46,7 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -482,13 +483,43 @@
 auto *Snippet = onlyValue<&BundledEntry::SnippetSuffix>();
 if (!Snippet)
   // All bundles are function calls.
+  // FIXME(ibiryukov): sometimes add template arguments to a snippet, e.g.
+  // we need to complete 'forward<$1>($0)'.
   return "($0)";
-if (!Snippet->empty() && !EnableFunctionArgSnippets &&
-((Completion.Kind == CompletionItemKind::Function) ||
- (Completion.Kind == CompletionItemKind::Method)) &&
-(Snippet->front() == '(') && (Snippet->back() == ')'))
-  // Check whether function has any parameters or not.
-  return Snippet->size() > 2 ? "($0)" : "()";
+if (EnableFunctionArgSnippets)
+  return *Snippet;
+
+// Replace argument snippets with a simplified pattern.
+if (Snippet->empty())
+  return "";
+if (Completion.Kind == CompletionItemKind::Function ||
+Completion.Kind == CompletionItemKind::Method) {
+  // Functions snippets can be of 2 types:
+  // - containing only function arguments, e.g.
+  //   foo(${1:int p1}, ${2:int p2});
+  //   We transform this pattern to '($0)' or '()'.
+  // - template arguments and function arguments, e.g.
+  //   foo<${1:class}>(${2:int p1}).
+  //   We transform this pattern to '<$1>($0)' or '<$0>()'.
+
+  bool EmptyArgs = llvm::StringRef(*Snippet).endswith("()");
+  if (Snippet->front() == '<')
+return EmptyArgs ? "<$0>()" : "<$1>($0)";
+  if (Snippet->front() == '(')
+return EmptyArgs ? "()" : "($0)";
+  return *Snippet; // Not an arg snippet?
+}
+if (Completion.Kind == CompletionItemKind::Reference ||
+Completion.Kind == CompletionItemKind::Class) {
+  if (Snippet->front() != '<')
+return *Snippet; // Not an arg snippet?
+
+  // Classes and template using aliases can only have template arguments,
+  // e.g. Foo<${1:class}>.
+  if (llvm::StringRef(*Snippet).endsw

r342890 - [CFString][ELF] Fix a missed test causing buildbot failures from 342883.

2018-09-24 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Mon Sep 24 07:52:48 2018
New Revision: 342890

URL: http://llvm.org/viewvc/llvm-project?rev=342890&view=rev
Log:
[CFString][ELF] Fix a missed test causing buildbot failures from 342883.

Accidetanlly forgot to update it, big sorry.


Modified:
cfe/trunk/test/CodeGen/CFStrings.c

Modified: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=342890&r1=342889&r2=342890&view=diff
==
--- cfe/trunk/test/CodeGen/CFStrings.c (original)
+++ cfe/trunk/test/CodeGen/CFStrings.c Mon Sep 24 07:52:48 2018
@@ -22,7 +22,7 @@ const CFStringRef one = (CFStringRef)__b
 const CFStringRef two = 
(CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f");
 
 // CHECK-COFF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 
1
-// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1
+// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section ".rodata", align 1
 // CHECK-MACHO: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section "__TEXT,__cstring,cstring_literals", align 1
 
 // CHECK-COFF: @_unnamed_cfstring_ = private global 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section "cfstring", align {{[48]}}
@@ -32,7 +32,7 @@ const CFStringRef two = (CFStringRef)__b
 // CHECK-MACHO64: @_unnamed_cfstring_ = private global 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, 
section "__DATA,__cfstring", align 8
 
 // CHECK-COFF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2
-// CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2
+// CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section ".rodata", align 2
 // CHECK-MACHO: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section "__TEXT,__ustring", 
align 2
 
 // CHECK-COFF: @_unnamed_cfstring_.2 = private global 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 2000, i8* bitcast 
([7 x i16]* @.str.1 to i8*), i32 6 }, section "cfstring", align {{[48]}}


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


r342889 - [VFS] Use llvm::StringMap instead of std::map. NFC

2018-09-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Sep 24 07:52:11 2018
New Revision: 342889

URL: http://llvm.org/viewvc/llvm-project?rev=342889&view=rev
Log:
[VFS] Use llvm::StringMap instead of std::map. NFC

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

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=342889&r1=342888&r2=342889&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Sep 24 07:52:11 2018
@@ -566,7 +566,7 @@ public:
 
 class InMemoryDirectory : public InMemoryNode {
   Status Stat;
-  std::map> Entries;
+  llvm::StringMap> Entries;
 
 public:
   InMemoryDirectory(Status Stat)


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


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: lebedev.ri, rsmith, dblaikie.

This patch diagnoses parameter names that shadow the names of inherited fields 
under -Wshadow-field. It addresses PR34120. Note, unlike GCC, we take into 
account the accessibility of the field when deciding whether to warn or not.


https://reviews.llvm.org/D52421

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -222,3 +222,23 @@
   };
 }
 }
+
+namespace PR34120 {
+struct A {
+  int B; // expected-note {{declared here}}
+};
+
+class C : public A {
+  void D(int B) {} // expected-warning {{parameter 'B' shadows member inherited from type 'A'}}
+  void E() {
+extern void f(int B); // Ok
+  }
+};
+
+class Private {
+  int B;
+};
+class Derived : Private {
+  void D(int B) {} // Ok
+};
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2852,7 +2852,8 @@
 // Check if there is a field shadowing.
 void Sema::CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD) {
+  const CXXRecordDecl *RD,
+  bool DeclIsField) {
   if (Diags.isIgnored(diag::warn_shadow_field, Loc))
 return;
 
@@ -2892,7 +2893,7 @@
 if (AS_none !=
 CXXRecordDecl::MergeAccess(P.Access, BaseField->getAccess())) {
   Diag(Loc, diag::warn_shadow_field)
-<< FieldName << RD << Base;
+<< FieldName << RD << Base << DeclIsField;
   Diag(BaseField->getLocation(), diag::note_shadow_field);
   Bases.erase(It);
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12379,6 +12379,13 @@
 }
   }
 
+  if (LangOpts.CPlusPlus && II) {
+DeclarationNameInfo DNI = GetNameForDeclarator(D);
+if (auto *RD = dyn_cast(CurContext))
+  CheckShadowInheritedFields(DNI.getLoc(), DNI.getName(), RD,
+ /*DeclIsField*/ false);
+  }
+
   // Temporarily put parameter variables in the translation unit, not
   // the enclosing context.  This prevents them from accidentally
   // looking like class members in C++.
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -10524,7 +10524,8 @@
   /// Check if there is a field shadowing.
   void CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD);
+  const CXXRecordDecl *RD,
+  bool DeclIsField = true);
 
   /// Check if the given expression contains 'break' or 'continue'
   /// statement that produces control flow different from GCC.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9418,10 +9418,9 @@
   "__final is a GNU extension, consider using C++11 final">,
   InGroup;
 
-def warn_shadow_field :
-  Warning<"non-static data member %0 of %1 shadows member inherited from "
-  "type %2">,
-  InGroup, DefaultIgnore;
+def warn_shadow_field : Warning<
+  "%select{parameter|non-static data member}3 %0 %select{|of %1 }3shadows "
+  "member inherited from type %2">, InGroup, DefaultIgnore;
 def note_shadow_field : Note<"declared here">;
 
 def err_multiversion_required_in_redecl : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r342888 - [clangd] Do bounds checks while reading data, otherwise var-length records are too painful. NFC

2018-09-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Sep 24 07:51:15 2018
New Revision: 342888

URL: http://llvm.org/viewvc/llvm-project?rev=342888&view=rev
Log:
[clangd] Do bounds checks while reading data, otherwise var-length records are 
too painful. NFC

Modified:
clang-tools-extra/trunk/clangd/index/Serialization.cpp

Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=342888&r1=342887&r2=342888&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Mon Sep 24 07:51:15 
2018
@@ -23,24 +23,83 @@ Error makeError(const Twine &Msg) {
 
 // IO PRIMITIVES
 // We use little-endian 32 bit ints, sometimes with variable-length encoding.
+//
+// Variable-length int encoding (varint) uses the bottom 7 bits of each byte
+// to encode the number, and the top bit to indicate whether more bytes follow.
+// e.g. 9a 2f means [0x1a and keep reading, 0x2f and stop].
+// This represents 0x1a | 0x2f<<7 = 6042.
+// A 32-bit integer takes 1-5 bytes to encode; small numbers are more compact.
 
-StringRef consume(StringRef &Data, int N) {
-  StringRef Ret = Data.take_front(N);
-  Data = Data.drop_front(N);
-  return Ret;
-}
+// Reads binary data from a StringRef, and keeps track of position.
+class Reader {
+  const char *Begin, *End;
+  bool Err;
 
-uint8_t consume8(StringRef &Data) {
-  uint8_t Ret = Data.front();
-  Data = Data.drop_front();
-  return Ret;
-}
+public:
+  Reader(StringRef Data) : Begin(Data.begin()), End(Data.end()) {}
+  // The "error" bit is set by reading past EOF or reading invalid data.
+  // When in an error state, reads may return zero values: callers should 
check.
+  bool err() const { return Err; }
+  // Did we read all the data, or encounter an error?
+  bool eof() const { return Begin == End || Err; }
+  // All the data we didn't read yet.
+  StringRef rest() const { return StringRef(Begin, End - Begin); }
+
+  uint8_t consume8() {
+if (LLVM_UNLIKELY(Begin == End)) {
+  Err = true;
+  return 0;
+}
+return *Begin++;
+  }
 
-uint32_t consume32(StringRef &Data) {
-  auto Ret = support::endian::read32le(Data.bytes_begin());
-  Data = Data.drop_front(4);
-  return Ret;
-}
+  uint32_t consume32() {
+if (LLVM_UNLIKELY(Begin + 4 > End)) {
+  Err = true;
+  return 0;
+}
+auto Ret = support::endian::read32le(Begin);
+Begin += 4;
+return Ret;
+  }
+
+  StringRef consume(int N) {
+if (LLVM_UNLIKELY(Begin + N > End)) {
+  Err = true;
+  return StringRef();
+}
+StringRef Ret(Begin, N);
+Begin += N;
+return Ret;
+  }
+
+  uint32_t consumeVar() {
+constexpr static uint8_t More = 1 << 7;
+uint8_t B = consume8();
+if (LLVM_LIKELY(!(B & More)))
+  return B;
+uint32_t Val = B & ~More;
+for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
+  B = consume8();
+  Val |= (B & ~More) << Shift;
+}
+return Val;
+  }
+
+  StringRef consumeString(ArrayRef Strings) {
+auto StringIndex = consumeVar();
+if (LLVM_UNLIKELY(StringIndex >= Strings.size())) {
+  Err = true;
+  return StringRef();
+}
+return Strings[StringIndex];
+  }
+
+  SymbolID consumeID() {
+StringRef Raw = consume(SymbolID::RawSize); // short if truncated.
+return LLVM_UNLIKELY(err()) ? SymbolID() : SymbolID::fromRaw(Raw);
+  }
+};
 
 void write32(uint32_t I, raw_ostream &OS) {
   char buf[4];
@@ -48,11 +107,6 @@ void write32(uint32_t I, raw_ostream &OS
   OS.write(buf, sizeof(buf));
 }
 
-// Variable-length int encoding (varint) uses the bottom 7 bits of each byte
-// to encode the number, and the top bit to indicate whether more bytes follow.
-// e.g. 9a 2f means [0x1a and keep reading, 0x2f and stop].
-// This represents 0x1a | 0x2f<<7 = 6042.
-// A 32-bit integer takes 1-5 bytes to encode; small numbers are more compact.
 void writeVar(uint32_t I, raw_ostream &OS) {
   constexpr static uint8_t More = 1 << 7;
   if (LLVM_LIKELY(I < 1 << 7)) {
@@ -69,19 +123,6 @@ void writeVar(uint32_t I, raw_ostream &O
   }
 }
 
-uint32_t consumeVar(StringRef &Data) {
-  constexpr static uint8_t More = 1 << 7;
-  uint8_t B = consume8(Data);
-  if (LLVM_LIKELY(!(B & More)))
-return B;
-  uint32_t Val = B & ~More;
-  for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
-B = consume8(Data);
-Val |= (B & ~More) << Shift;
-  }
-  return Val;
-}
-
 // STRING TABLE ENCODING
 // Index data has many string fields, and many strings are identical.
 // We store each string once, and refer to them by index.
@@ -146,30 +187,34 @@ struct StringTableIn {
 };
 
 Expected readStringTable(StringRef Data) {
-  if (Data.size() < 4)
-return makeError("Bad string table: not enough metadata");
-  size_t UncompressedSize = consume32(Data);
+  Reader R(Data);
+  size_t Uncompres

[PATCH] D51041: [clang-tidy] Don't run misc-unused-using-decls check in C++17.

2018-09-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/misc-unused-using-decls-cxx17.cpp:1
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- 
-fno-delayed-template-parsing -std=gnu++17
+

why gnu++17 and not standard?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51041



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


[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdUnit.cpp:119
 
+/// Collect and cache all file status from the underlying file system.
+class CollectStatCacheVFS : public vfs::FileSystem {

Would it make sense to add a `clang::vfs::ProxyFS` that proxies calls to 
underlying FS by default and allows to override some methods?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419



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


  1   2   >