[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-09-28 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

ping 3


https://reviews.llvm.org/D36390



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


r314387 - Add the new -Wnull-pointer-arithmetic warnings to the release notes

2017-09-28 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Thu Sep 28 01:00:18 2017
New Revision: 314387

URL: http://llvm.org/viewvc/llvm-project?rev=314387&view=rev
Log:
Add the new -Wnull-pointer-arithmetic warnings to the release notes

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


Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=314387&r1=314386&r2=314387&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Sep 28 01:00:18 2017
@@ -78,6 +78,11 @@ Improvements to Clang's diagnostics
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
+- ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
+  on a null pointer. Such pointer arithmetic has an undefined behavior if the
+  offset is nonzero. It also now warns about arithmetic on a null pointer
+  treated as a cast from integer to pointer (GNU extension).
+
 Non-comprehensive list of changes in this release
 -
 


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


[PATCH] D38186: Add the new -Wnull-pointer-arithmetic warnings to the release notes

2017-09-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru accepted this revision.
sylvestre.ledru added a comment.
This revision is now accepted and ready to land.

Thanks, it makes sense!
Landed in r314387


https://reviews.llvm.org/D38186



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


r314391 - Use std::is_trivial instead of is_trivially_copyable.

2017-09-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Sep 28 01:50:30 2017
New Revision: 314391

URL: http://llvm.org/viewvc/llvm-project?rev=314391&view=rev
Log:
Use std::is_trivial instead of is_trivially_copyable.

The oldest versions of GCC we support (before 5) didn't support that
trait. is_trivial is stronger superset that clang::Token fulfills, so
just use that instead.

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

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=314391&r1=314390&r2=314391&view=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Thu Sep 28 01:50:30 2017
@@ -62,11 +62,11 @@ MacroArgs *MacroArgs::create(const Macro
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
   if (!UnexpArgTokens.empty()) {
-static_assert(std::is_trivially_copyable::value,
+static_assert(std::is_trivial::value,
   "assume trivial copyability if copying into the "
   "uninitialized array (as opposed to reusing a cached "
   "MacroArgs)");
-std::copy(UnexpArgTokens.begin(), UnexpArgTokens.end(), 
+std::copy(UnexpArgTokens.begin(), UnexpArgTokens.end(),
   Result->getTrailingObjects());
   }
 


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


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

2017-09-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Ping.

In https://reviews.llvm.org/D36836#877642, @lebedev.ri wrote:

> In https://reviews.llvm.org/D36836#877636, @alexfh wrote:
>
> > > The metric is implemented as per COGNITIVE COMPLEXITY by SonarSource 
> > > specification version 1.2 (19 April 2017),
> >
> > Err, "I did ask them, and received an answer that it is it can be 
> > implemented in clang-tidy" might not be enough.
>
>
> F5372479: original_msg.txt 
>
>Hello Roman,
>   
>It would not, and I would be happy to be notified once done.
>   
>Thanks
>   
>Olivier
>   
>   > On Fri, Jul 28, 2017 at 6:17 PM Roman Lebedev  
> wrote:
>   > Hi.
>   > 
>   > I would like to know, what is the legal status of
>   > https://www.sonarsource.com/docs/CognitiveComplexity.pdf ?
>   > 
>   > If i (or someone else) is to implement the Specification described in
>   > that paper,
>   > which will produce the same results as the Cognitive Complexity in 
> SonarSource
>   > as part of some other static analyzer, for example as a LLVM's clang-tidy 
> check,
>   > would that be illegal thing to do?
>   > 
>   > Roman.
>-- 
>Olivier Gaudin | SonarSource
>CEO & Co-Founder
>+41 (0)22 510 2424
>http://sonarsource.com
>   
>
> Might not be enough?


@alexfh please specify, is that enough or not?


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


Re: [PATCH] D37826: Refine generation of TBAA information in clang

2017-09-28 Thread Ivan Kosarev via cfe-commits
Thanks for the ack Daniel. Hopefully others will eventually have a 
chance to review.


On 27/09/17 19:00, Daniel Berlin wrote:

(As i mentioned to hal offline, i'm too slammed to help here)

On Wed, Sep 27, 2017 at 8:47 AM, Ivan A. Kosarev via Phabricator 
mailto:revi...@reviews.llvm.org>> wrote:


kosarev added a comment.

Colleagues, please let me know if I can do anything else to help
with reviewing the patch. Thanks.


https://reviews.llvm.org/D37826 






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


[PATCH] D38354: Fix test by using -target instead of cc1 arguments (c-index-test goes through the driver)

2017-09-28 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab created this revision.

If LLVM_DEFAULT_TARGET_TRIPLE is a non-darwin triple, the file might
fail. This might allow us to take out the FIXME and REQUIRES lines, but I'd
rather let the bots double-check that the test is ok first.


https://reviews.llvm.org/D38354

Files:
  test/Index/pch-from-libclang.c


Index: test/Index/pch-from-libclang.c
===
--- test/Index/pch-from-libclang.c
+++ test/Index/pch-from-libclang.c
@@ -4,10 +4,10 @@
 // REQUIRES: system-darwin
 
 // RUN: %clang_cc1 -fsyntax-only %s -verify
-// RUN: c-index-test -write-pch %t.h.pch %s -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin
-// RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang 
-triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors
-// RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang 
-triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors 
-Xclang -verify
-// RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin | 
FileCheck %s
+// RUN: c-index-test -write-pch %t.h.pch %s -fmodules 
-fmodules-cache-path=%t.mcp -target x86_64-apple-darwin
+// RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -target 
x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors
+// RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -target 
x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors -Xclang -verify
+// RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules 
-fmodules-cache-path=%t.mcp -target x86_64-apple-darwin | FileCheck %s
 
 #ifndef HEADER
 #define HEADER


Index: test/Index/pch-from-libclang.c
===
--- test/Index/pch-from-libclang.c
+++ test/Index/pch-from-libclang.c
@@ -4,10 +4,10 @@
 // REQUIRES: system-darwin
 
 // RUN: %clang_cc1 -fsyntax-only %s -verify
-// RUN: c-index-test -write-pch %t.h.pch %s -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin
-// RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang -triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors
-// RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang -triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors -Xclang -verify
-// RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin | FileCheck %s
+// RUN: c-index-test -write-pch %t.h.pch %s -fmodules -fmodules-cache-path=%t.mcp -target x86_64-apple-darwin
+// RUN: %clang -fsyntax-only -include %t.h %s -Xclang -verify -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -target x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors
+// RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules -fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -target x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors -Xclang -verify
+// RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules -fmodules-cache-path=%t.mcp -target x86_64-apple-darwin | FileCheck %s
 
 #ifndef HEADER
 #define HEADER
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-09-28 Thread William Enright via Phabricator via cfe-commits
Nebiroth added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:20
 #include 
+#include 
 

malaperle wrote:
> William, did you perhaps miss this comment? I don't think unistd.h makes 
> sense here.
I indeed missed it.


https://reviews.llvm.org/D37150



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


[PATCH] D38277: [compiler-rt}[CMake] Fix configuration on PowerPC with sanitizers

2017-09-28 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld marked 2 inline comments as done.
Hahnfeld added a comment.

The error with `-DLLVM_USE_SANITIZER=Address` is

  -- Check if the system is big endian
  -- Searching 16 bit integer
  -- Looking for stddef.h
  -- Looking for stddef.h - not found
  -- Check size of unsigned short
  -- Check size of unsigned short - failed
  -- Check size of unsigned int
  -- Check size of unsigned int - failed
  -- Check size of unsigned long
  -- Check size of unsigned long - failed
  CMake Error at <...>/cmake/share/cmake-3.5/Modules/TestBigEndian.cmake:51 
(message):
no suitable type found
  Call Stack (most recent call first):
projects/compiler-rt/cmake/base-config-ix.cmake:151 (TEST_BIG_ENDIAN)
projects/compiler-rt/cmake/config-ix.cmake:138 (test_targets)
projects/compiler-rt/CMakeLists.txt:99 (include)

The reason is that the compile tests are performed with `-fsanitize=address 
-nodefaultlibs`. This gives a lot of undefined references because the runtime 
dependencies aren't linked in.


https://reviews.llvm.org/D38277



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


[PATCH] D38277: [compiler-rt][CMake] Fix configuration on PowerPC with sanitizers

2017-09-28 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 116977.
Hahnfeld retitled this revision from "[compiler-rt}[CMake] Fix configuration on 
PowerPC with sanitizers" to "[compiler-rt][CMake] Fix configuration on PowerPC 
with sanitizers".
Hahnfeld added a subscriber: gtbercea.

https://reviews.llvm.org/D38277

Files:
  cmake/base-config-ix.cmake


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -148,7 +148,13 @@
 endif()
   endif()
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+  # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
+  # will fail with this option when building with a sanitizer.
+  cmake_push_check_state()
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
+  cmake_pop_check_state()
+
   if(HOST_IS_BIG_ENDIAN)
 test_target_arch(powerpc64 "" "-m64")
   else()


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -148,7 +148,13 @@
 endif()
   endif()
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+  # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
+  # will fail with this option when building with a sanitizer.
+  cmake_push_check_state()
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
+  cmake_pop_check_state()
+
   if(HOST_IS_BIG_ENDIAN)
 test_target_arch(powerpc64 "" "-m64")
   else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38356: keeps include path order when emulate msvc compiler

2017-09-28 Thread comicfans44 via Phabricator via cfe-commits
comicfans44 created this revision.
comicfans44 added a project: clang.

clang will drop user supplied include path if it's already in system include 
paths to emulate gcc. if two files with same name both exist in user path and 
system path, and user set system path first in arguments, this leads different 
behavior to msvc. this patch preserve user include path order when emulating 
msvc.


Repository:
  rL LLVM

https://reviews.llvm.org/D38356

Files:
  clang/lib/Frontend/InitHeaderSearch.cpp


Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -99,7 +99,7 @@
 
   /// Realize - Merges all search path lists into one list and send it to
   /// HeaderSearch.
-  void Realize(const LangOptions &Lang);
+  void Realize(const LangOptions &Lang, bool msvc);
 };
 
 }  // end anonymous namespace.
@@ -493,7 +493,7 @@
 /// search list, remove the later (dead) ones.  Returns the number of 
non-system
 /// headers removed, which is used to update NumAngled.
 static unsigned RemoveDuplicates(std::vector &SearchList,
- unsigned First, bool Verbose) {
+ unsigned First, bool Verbose, bool msvc) {
   llvm::SmallPtrSet SeenDirs;
   llvm::SmallPtrSet SeenFrameworkDirs;
   llvm::SmallPtrSet SeenHeaderMaps;
@@ -525,7 +525,7 @@
 //
 // Since dupes of system dirs are rare, just rescan to find the original
 // that we're nuking instead of using a DenseMap.
-if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
+if (!msvc && (CurEntry.getDirCharacteristic() != SrcMgr::C_User)) {
   // Find the dir that this is the same of.
   unsigned FirstDir;
   for (FirstDir = First;; ++FirstDir) {
@@ -576,7 +576,7 @@
 }
 
 
-void InitHeaderSearch::Realize(const LangOptions &Lang) {
+void InitHeaderSearch::Realize(const LangOptions &Lang, bool msvc) {
   // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
   std::vector SearchList;
   SearchList.reserve(IncludePath.size());
@@ -587,14 +587,14 @@
   SearchList.push_back(Include.second);
 
   // Deduplicate and remember index.
-  RemoveDuplicates(SearchList, 0, Verbose);
+  RemoveDuplicates(SearchList, 0, Verbose, msvc);
   unsigned NumQuoted = SearchList.size();
 
   for (auto &Include : IncludePath)
 if (Include.first == Angled || Include.first == IndexHeaderMap)
   SearchList.push_back(Include.second);
 
-  RemoveDuplicates(SearchList, NumQuoted, Verbose);
+  RemoveDuplicates(SearchList, NumQuoted, Verbose, msvc);
   unsigned NumAngled = SearchList.size();
 
   for (auto &Include : IncludePath)
@@ -613,7 +613,8 @@
   // Remove duplicates across both the Angled and System directories.  GCC does
   // this and failing to remove duplicates across these two groups breaks
   // #include_next.
-  unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
+  unsigned NonSystemRemoved =
+  RemoveDuplicates(SearchList, NumQuoted, Verbose, msvc);
   NumAngled -= NonSystemRemoved;
 
   bool DontSearchCurDir = false;  // TODO: set to true if -I- is set?
@@ -673,5 +674,6 @@
   HS.getModuleMap().setBuiltinIncludeDir(Dir);
   }
 
-  Init.Realize(Lang);
+  Init.Realize(Lang,
+   Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC);
 }


Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -99,7 +99,7 @@
 
   /// Realize - Merges all search path lists into one list and send it to
   /// HeaderSearch.
-  void Realize(const LangOptions &Lang);
+  void Realize(const LangOptions &Lang, bool msvc);
 };
 
 }  // end anonymous namespace.
@@ -493,7 +493,7 @@
 /// search list, remove the later (dead) ones.  Returns the number of non-system
 /// headers removed, which is used to update NumAngled.
 static unsigned RemoveDuplicates(std::vector &SearchList,
- unsigned First, bool Verbose) {
+ unsigned First, bool Verbose, bool msvc) {
   llvm::SmallPtrSet SeenDirs;
   llvm::SmallPtrSet SeenFrameworkDirs;
   llvm::SmallPtrSet SeenHeaderMaps;
@@ -525,7 +525,7 @@
 //
 // Since dupes of system dirs are rare, just rescan to find the original
 // that we're nuking instead of using a DenseMap.
-if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
+if (!msvc && (CurEntry.getDirCharacteristic() != SrcMgr::C_User)) {
   // Find the dir that this is the same of.
   unsigned FirstDir;
   for (FirstDir = First;; ++FirstDir) {
@@ -576,7 +576,7 @@
 }
 
 
-void InitHeaderSearch::Realize(const LangOptions &Lang) {
+void InitHeaderSearch::Realize(const LangOptions &Lang, bool msvc) {
   // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
   std::vector S

[PATCH] D38357: [Support/Regex] Handle tabulators and escaped chars in square brackets.

2017-09-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.

This patch is motivated by bug #34739 
(https://bugs.llvm.org/show_bug.cgi?id=34739).
Clang-format misbehaves because escape sequence '\t' in regex is treated as 
literal 't'.
This patch handles escaped characters inside square brackets as well (so that 
somebody can write `R("^[\[\]\t]")` as a regex pattern).


https://reviews.llvm.org/D38357

Files:
  lib/Support/regcomp.c
  unittests/Support/RegexTest.cpp

Index: unittests/Support/RegexTest.cpp
===
--- unittests/Support/RegexTest.cpp
+++ unittests/Support/RegexTest.cpp
@@ -61,6 +61,76 @@
   EXPECT_TRUE(r5.match(String));
 }
 
+TEST_F(RegexTest, Tabulators) {
+  Regex r1("^\\t+$");
+  EXPECT_TRUE(r1.match("\t"));
+  EXPECT_TRUE(r1.match("\t\t\t"));
+  EXPECT_FALSE(r1.match(""));
+  EXPECT_FALSE(r1.match(" "));
+  EXPECT_FALSE(r1.match(" \t "));
+
+  Regex r2("^(\\t| )+$");
+  EXPECT_TRUE(r2.match("\t"));
+  EXPECT_TRUE(r2.match("\t\t\t"));
+  EXPECT_FALSE(r2.match(""));
+  EXPECT_TRUE(r2.match(" "));
+  EXPECT_TRUE(r2.match(" \t "));
+
+  Regex r3("^[\\t ]+$");
+  EXPECT_TRUE(r3.match("\t"));
+  EXPECT_TRUE(r3.match("\t\t\t"));
+  EXPECT_FALSE(r3.match(""));
+  EXPECT_TRUE(r3.match(" "));
+  EXPECT_TRUE(r3.match(" \t "));
+}
+
+TEST_F(RegexTest, EscapedBackslash) {
+  Regex r1("^+$");
+  EXPECT_TRUE(r1.match("\\"));
+  EXPECT_TRUE(r1.match("\\"));
+  EXPECT_FALSE(r1.match(""));
+  EXPECT_FALSE(r1.match(" "));
+  EXPECT_FALSE(r1.match(" \\ "));
+
+  Regex r2("^(| )+$");
+  EXPECT_TRUE(r2.match("\\"));
+  EXPECT_TRUE(r2.match("\\"));
+  EXPECT_FALSE(r2.match(""));
+  EXPECT_TRUE(r2.match(" "));
+  EXPECT_TRUE(r2.match(" \\ "));
+
+  Regex r3("^[ ]+$");
+  EXPECT_TRUE(r3.match("\\"));
+  EXPECT_TRUE(r3.match("\\"));
+  EXPECT_FALSE(r3.match(""));
+  EXPECT_TRUE(r3.match(" "));
+  EXPECT_TRUE(r3.match(" \\ "));
+}
+
+TEST_F(RegexTest, EscapedOrdinaryCharacters) {
+  Regex r1("^\\X+$");
+  EXPECT_TRUE(r1.match("X"));
+  EXPECT_TRUE(r1.match("XXX"));
+  EXPECT_FALSE(r1.match(""));
+  EXPECT_FALSE(r1.match(" "));
+  EXPECT_FALSE(r1.match(" X "));
+
+  Regex r2("^(\\X| )+$");
+  EXPECT_TRUE(r2.match("X"));
+  EXPECT_TRUE(r2.match("XXX"));
+  EXPECT_FALSE(r2.match(""));
+  EXPECT_TRUE(r2.match(" "));
+  EXPECT_TRUE(r2.match(" X "));
+
+  Regex r3("^[\\X ]+$");
+  EXPECT_TRUE(r3.match("X"));
+  EXPECT_TRUE(r3.match("XXX"));
+  EXPECT_FALSE(r3.match(""));
+  EXPECT_TRUE(r3.match(" "));
+  EXPECT_TRUE(r3.match(" X "));
+}
+
+
 TEST_F(RegexTest, Backreferences) {
   Regex r1("([a-z]+)_\\1");
   SmallVector Matches;
@@ -100,7 +170,7 @@
 
   EXPECT_EQ("aber", Regex("[0-9]+").sub("\\", "a1234ber", &Error));
   EXPECT_EQ(Error, "replacement string contained trailing backslash");
-  
+
   // Backreferences
   EXPECT_EQ("aa1234bber", Regex("a[0-9]+b").sub("a\\0b", "a1234ber", &Error));
   EXPECT_EQ("", Error);
Index: lib/Support/regcomp.c
===
--- lib/Support/regcomp.c
+++ lib/Support/regcomp.c
@@ -403,10 +403,17 @@
 			EMIT(O_BACK, backrefnum);
 			p->g->backrefs = 1;
 		} else {
-			/* Other chars are simply themselves when escaped with a backslash.
-			 */
-			ordinary(p, c);
-		}
+switch (c) {
+case 't':
+  ordinary(p, '\t');
+  break;
+default:
+  /* Other chars are simply themselves when escaped with a
+   * backslash. */
+  ordinary(p, c);
+  break;
+}
+}
 		break;
 	case '{':		/* okay as ordinary except if digit follows */
 		REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
@@ -787,7 +794,19 @@
 	default:		/* symbol, ordinary character, or range */
 /* xxx revision needed for multichar stuff */
 		start = p_b_symbol(p);
-		if (SEE('-') && MORE2() && PEEK2() != ']') {
+if ((start == '\\')) {
+  /* escape */
+  REQUIRE(MORE(), REG_EESCAPE);
+  c = GETNEXT();
+  switch (c) {
+  case 't':
+start = finish = '\t';
+break;
+  default:
+start = finish = c;
+break;
+  }
+		} else if (SEE('-') && MORE2() && PEEK2() != ']') {
 			/* range */
 			NEXT();
 			if (EAT('-'))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.

2017-09-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.

In `ProgramState::getSVal(Loc, QualType)`, the `QualType` parameter, which 
represents the type of the expected value, is optional. If it is not supplied, 
it is auto-detected by looking at the memory region in `Loc`. For typed-value 
regions such autodetection is trivial. For other kinds of regions (most 
importantly, for symbolic regions) it apparently never worked correctly: it 
detected the location type (pointer type), not the value type in this location 
(pointee type).

Our tests contain numerous cases when such autodetection was working 
incorrectly, but for existing tests it never mattered. There are three notable 
places where the type was regularly auto-detected incorrectly:

1. `ExprEngine::performTrivialCopy()`. Trivial copy from symbolic references 
never worked - test case attached.
2. `CallAndMessageChecker::uninitRefOrPointer()`. Here the code only cares if 
the value is `Undefined` or not, so autodetected type didn't matter.
3. `GTestChecker::modelAssertionResultBoolConstructor()`. This is how the issue 
was found in https://bugs.llvm.org/show_bug.cgi?id=34305 - test case attached.

I added a few more sanity checks - we'd now also fail with an assertion if we 
are unable to autodetect the pointer type, warning the author of the checker to 
pass the type explicitly.

It is sometimes indeed handy to put a void-pointer-typed `Loc` into 
`getSVal(Loc)`, as demonstrated in the `exercise-ps.c`'s `f2()` test through 
`CallAndMessageChecker` (case '2.' above). I handled this on the API side in 
order to simplify checker API, implicitly turning `void` into `char`, though i 
don't mind modifying `CallAndMessageChecker` to pass `CharTy` explicitly 
instead.


https://reviews.llvm.org/D38358

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/ctor.mm
  test/Analysis/gtest.cpp


Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -151,3 +151,9 @@
   ASSERT_TRUE(false);
   clang_analyzer_warnIfReached(); // no-warning
 }
+
+void testAssertSymbolic(const bool &b) {
+  ASSERT_TRUE(b);
+
+  clang_analyzer_eval(b); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -199,7 +199,7 @@
 Inner p;
   };
 
-  void testPOD() {
+  void testPOD(const POD &pp) {
 POD p;
 p.x = 1;
 POD p2 = p; // no-warning
@@ -210,6 +210,15 @@
 // Use rvalues as well.
 clang_analyzer_eval(POD(p3).x == 1); // expected-warning{{TRUE}}
 
+// Copy from symbolic references correctly.
+POD p4 = pp;
+// Make sure that p4.x contains a symbol after copy.
+if (p4.x > 0)
+  clang_analyzer_eval(p4.x > 0); // expected-warning{{TRUE}}
+// FIXME: Element region gets in the way, so these aren't the same symbols
+// as they should be.
+clang_analyzer_eval(pp.x == p4.x); // expected-warning{{UNKNOWN}}
+
 PODWrapper w;
 w.p.y = 1;
 PODWrapper w2 = w; // no-warning
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1393,17 +1393,20 @@
 return UnknownVal();
   }
 
-  if (isa(MR) ||
-  isa(MR) ||
-  isa(MR)) {
+  if (!isa(MR)) {
 if (T.isNull()) {
-  if (const TypedRegion *TR = dyn_cast(MR))
-T = TR->getLocationType();
-  else {
-const SymbolicRegion *SR = cast(MR);
-T = SR->getSymbol()->getType();
+  if (const TypedRegion *TR = dyn_cast(MR)) {
+T = TR->getLocationType()->getPointeeType();
+  } else if (const SymbolicRegion *SR = dyn_cast(MR)) {
+T = SR->getSymbol()->getType()->getPointeeType();
+if (T->isVoidType()) {
+  // When trying to dereference a void pointer, read the first byte.
+  T = Ctx.CharTy;
+}
   }
 }
+assert(!T.isNull() && "Unable to auto-detect binding type!");
+assert(!T->isVoidType() && "Attempted to retrieve a void value!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 


Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -151,3 +151,9 @@
   ASSERT_TRUE(false);
   clang_analyzer_warnIfReached(); // no-warning
 }
+
+void testAssertSymbolic(const bool &b) {
+  ASSERT_TRUE(b);
+
+  clang_analyzer_eval(b); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -199,7 +199,7 @@
 Inner p;
   };
 
-  void testPOD() {
+  void testPOD(const POD &pp) {
 POD p;
 p.x = 1;
 POD p2 = p; // no-warning
@@ -210,6 +210,15 @@
 // Use rvalues as well.
 clang_analyzer_eval(POD(

[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.

2017-09-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 116986.
NoQ added a comment.

Add a forgotten comment.


https://reviews.llvm.org/D38358

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/ctor.mm
  test/Analysis/gtest.cpp


Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -151,3 +151,10 @@
   ASSERT_TRUE(false);
   clang_analyzer_warnIfReached(); // no-warning
 }
+
+void testAssertSymbolic(const bool &b) {
+  ASSERT_TRUE(b);
+
+  // FIXME: Our solver doesn't handle this well yet.
+  clang_analyzer_eval(b); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -199,7 +199,7 @@
 Inner p;
   };
 
-  void testPOD() {
+  void testPOD(const POD &pp) {
 POD p;
 p.x = 1;
 POD p2 = p; // no-warning
@@ -210,6 +210,15 @@
 // Use rvalues as well.
 clang_analyzer_eval(POD(p3).x == 1); // expected-warning{{TRUE}}
 
+// Copy from symbolic references correctly.
+POD p4 = pp;
+// Make sure that p4.x contains a symbol after copy.
+if (p4.x > 0)
+  clang_analyzer_eval(p4.x > 0); // expected-warning{{TRUE}}
+// FIXME: Element region gets in the way, so these aren't the same symbols
+// as they should be.
+clang_analyzer_eval(pp.x == p4.x); // expected-warning{{UNKNOWN}}
+
 PODWrapper w;
 w.p.y = 1;
 PODWrapper w2 = w; // no-warning
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1393,17 +1393,20 @@
 return UnknownVal();
   }
 
-  if (isa(MR) ||
-  isa(MR) ||
-  isa(MR)) {
+  if (!isa(MR)) {
 if (T.isNull()) {
-  if (const TypedRegion *TR = dyn_cast(MR))
-T = TR->getLocationType();
-  else {
-const SymbolicRegion *SR = cast(MR);
-T = SR->getSymbol()->getType();
+  if (const TypedRegion *TR = dyn_cast(MR)) {
+T = TR->getLocationType()->getPointeeType();
+  } else if (const SymbolicRegion *SR = dyn_cast(MR)) {
+T = SR->getSymbol()->getType()->getPointeeType();
+if (T->isVoidType()) {
+  // When trying to dereference a void pointer, read the first byte.
+  T = Ctx.CharTy;
+}
   }
 }
+assert(!T.isNull() && "Unable to auto-detect binding type!");
+assert(!T->isVoidType() && "Attempted to retrieve a void value!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 


Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -151,3 +151,10 @@
   ASSERT_TRUE(false);
   clang_analyzer_warnIfReached(); // no-warning
 }
+
+void testAssertSymbolic(const bool &b) {
+  ASSERT_TRUE(b);
+
+  // FIXME: Our solver doesn't handle this well yet.
+  clang_analyzer_eval(b); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -199,7 +199,7 @@
 Inner p;
   };
 
-  void testPOD() {
+  void testPOD(const POD &pp) {
 POD p;
 p.x = 1;
 POD p2 = p; // no-warning
@@ -210,6 +210,15 @@
 // Use rvalues as well.
 clang_analyzer_eval(POD(p3).x == 1); // expected-warning{{TRUE}}
 
+// Copy from symbolic references correctly.
+POD p4 = pp;
+// Make sure that p4.x contains a symbol after copy.
+if (p4.x > 0)
+  clang_analyzer_eval(p4.x > 0); // expected-warning{{TRUE}}
+// FIXME: Element region gets in the way, so these aren't the same symbols
+// as they should be.
+clang_analyzer_eval(pp.x == p4.x); // expected-warning{{UNKNOWN}}
+
 PODWrapper w;
 w.p.y = 1;
 PODWrapper w2 = w; // no-warning
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1393,17 +1393,20 @@
 return UnknownVal();
   }
 
-  if (isa(MR) ||
-  isa(MR) ||
-  isa(MR)) {
+  if (!isa(MR)) {
 if (T.isNull()) {
-  if (const TypedRegion *TR = dyn_cast(MR))
-T = TR->getLocationType();
-  else {
-const SymbolicRegion *SR = cast(MR);
-T = SR->getSymbol()->getType();
+  if (const TypedRegion *TR = dyn_cast(MR)) {
+T = TR->getLocationType()->getPointeeType();
+  } else if (const SymbolicRegion *SR = dyn_cast(MR)) {
+T = SR->getSymbol()->getType()->getPointeeType();
+if (T->isVoidType()) {
+  // When trying to dereference a void pointer, read the first byte.
+  T = Ctx.CharTy;
+}
   }
 }
+assert(!T.isNull() && "Unable to auto-detect binding type!");
+assert(!T->is

[PATCH] D38362: Mark test as unsupported in C++98 as well

2017-09-28 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.

https://reviews.llvm.org/D38362

Files:
  test/std/re/re.alg/re.alg.match/exponential.pass.cpp


Index: test/std/re/re.alg/re.alg.match/exponential.pass.cpp
===
--- test/std/re/re.alg/re.alg.match/exponential.pass.cpp
+++ test/std/re/re.alg/re.alg.match/exponential.pass.cpp
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: libcpp-no-exceptions
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++98, c++03
 
 // template 
 // bool


Index: test/std/re/re.alg/re.alg.match/exponential.pass.cpp
===
--- test/std/re/re.alg/re.alg.match/exponential.pass.cpp
+++ test/std/re/re.alg/re.alg.match/exponential.pass.cpp
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: libcpp-no-exceptions
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++98, c++03
 
 // template 
 // bool
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.

2017-09-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 116992.
NoQ added a subscriber: alexfh.
NoQ added a comment.

Add @alexfh's small reproducer test case. It was so small i never noticed it 
until now!


https://reviews.llvm.org/D38358

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/ctor.mm
  test/Analysis/gtest.cpp


Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -151,3 +151,17 @@
   ASSERT_TRUE(false);
   clang_analyzer_warnIfReached(); // no-warning
 }
+
+void testAssertSymbolicPtr(const bool *b) {
+  ASSERT_TRUE(*b); // no-crash
+
+  // FIXME: Our solver doesn't handle this well yet.
+  clang_analyzer_eval(*b); // expected-warning{{UNKNOWN}}
+}
+
+void testAssertSymbolicRef(const bool &b) {
+  ASSERT_TRUE(b); // no-crash
+
+  // FIXME: Our solver doesn't handle this well yet.
+  clang_analyzer_eval(b); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -199,7 +199,7 @@
 Inner p;
   };
 
-  void testPOD() {
+  void testPOD(const POD &pp) {
 POD p;
 p.x = 1;
 POD p2 = p; // no-warning
@@ -210,6 +210,15 @@
 // Use rvalues as well.
 clang_analyzer_eval(POD(p3).x == 1); // expected-warning{{TRUE}}
 
+// Copy from symbolic references correctly.
+POD p4 = pp;
+// Make sure that p4.x contains a symbol after copy.
+if (p4.x > 0)
+  clang_analyzer_eval(p4.x > 0); // expected-warning{{TRUE}}
+// FIXME: Element region gets in the way, so these aren't the same symbols
+// as they should be.
+clang_analyzer_eval(pp.x == p4.x); // expected-warning{{UNKNOWN}}
+
 PODWrapper w;
 w.p.y = 1;
 PODWrapper w2 = w; // no-warning
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1393,17 +1393,20 @@
 return UnknownVal();
   }
 
-  if (isa(MR) ||
-  isa(MR) ||
-  isa(MR)) {
+  if (!isa(MR)) {
 if (T.isNull()) {
-  if (const TypedRegion *TR = dyn_cast(MR))
-T = TR->getLocationType();
-  else {
-const SymbolicRegion *SR = cast(MR);
-T = SR->getSymbol()->getType();
+  if (const TypedRegion *TR = dyn_cast(MR)) {
+T = TR->getLocationType()->getPointeeType();
+  } else if (const SymbolicRegion *SR = dyn_cast(MR)) {
+T = SR->getSymbol()->getType()->getPointeeType();
+if (T->isVoidType()) {
+  // When trying to dereference a void pointer, read the first byte.
+  T = Ctx.CharTy;
+}
   }
 }
+assert(!T.isNull() && "Unable to auto-detect binding type!");
+assert(!T->isVoidType() && "Attempted to retrieve a void value!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 


Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -151,3 +151,17 @@
   ASSERT_TRUE(false);
   clang_analyzer_warnIfReached(); // no-warning
 }
+
+void testAssertSymbolicPtr(const bool *b) {
+  ASSERT_TRUE(*b); // no-crash
+
+  // FIXME: Our solver doesn't handle this well yet.
+  clang_analyzer_eval(*b); // expected-warning{{UNKNOWN}}
+}
+
+void testAssertSymbolicRef(const bool &b) {
+  ASSERT_TRUE(b); // no-crash
+
+  // FIXME: Our solver doesn't handle this well yet.
+  clang_analyzer_eval(b); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -199,7 +199,7 @@
 Inner p;
   };
 
-  void testPOD() {
+  void testPOD(const POD &pp) {
 POD p;
 p.x = 1;
 POD p2 = p; // no-warning
@@ -210,6 +210,15 @@
 // Use rvalues as well.
 clang_analyzer_eval(POD(p3).x == 1); // expected-warning{{TRUE}}
 
+// Copy from symbolic references correctly.
+POD p4 = pp;
+// Make sure that p4.x contains a symbol after copy.
+if (p4.x > 0)
+  clang_analyzer_eval(p4.x > 0); // expected-warning{{TRUE}}
+// FIXME: Element region gets in the way, so these aren't the same symbols
+// as they should be.
+clang_analyzer_eval(pp.x == p4.x); // expected-warning{{UNKNOWN}}
+
 PODWrapper w;
 w.p.y = 1;
 PODWrapper w2 = w; // no-warning
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1393,17 +1393,20 @@
 return UnknownVal();
   }
 
-  if (isa(MR) ||
-  isa(MR) ||
-  isa(MR)) {
+  if (!isa(MR)) {
 if (T.isNull()) {
-  if (const TypedRegion *TR = dyn_cast(MR))
-T = TR->getLocationType();
-  else {
-const SymbolicRegion *SR = cast(

[PATCH] D36150: [clangd] LSP extension to switch between source/header file

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

Sorry for delays
@malaperle, thanks for submitting the patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D36150



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


[PATCH] D38364: Fix Modules/builtin-import.mm to be able to handle non-Darwin targets

2017-09-28 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab created this revision.

Also makes it pass on Darwin, if the default target triple is a Linux triple.


https://reviews.llvm.org/D38364

Files:
  test/Modules/builtin-import.mm


Index: test/Modules/builtin-import.mm
===
--- test/Modules/builtin-import.mm
+++ test/Modules/builtin-import.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
 
 #include 
 #include 


Index: test/Modules/builtin-import.mm
===
--- test/Modules/builtin-import.mm
+++ test/Modules/builtin-import.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem %S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
 
 #include 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.

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

Thank you for the fix! It seems to be the largest source of SA crashes on our 
code at the moment.


https://reviews.llvm.org/D38358



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


[PATCH] D38048: [clangd] Add textDocument/signatureHelp

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

Sorry for late response.




Comment at: clangd/ClangdUnit.cpp:610
+ParameterInformation Info;
+OptionalParameterLabel = getOptionalString(*Chunk.Optional);
+Result.label += OptionalParameterLabel;

Are we first concatenating the `CodeCompletionString` inside optional chunks 
and then trying to parse them again here?
Can we extract `ProcessChunks` function and recursively call it with 
`Chunk.Optional->Chunks`?



Comment at: clangd/ClangdUnit.cpp:650
+
+template 
+ReturnType

rwols wrote:
> Not sure if these template names are according to style.
It's ok. See my comment below, though, it looks like we can avoid making this 
function template in the first place.



Comment at: clangd/ClangdUnit.cpp:652
+ReturnType
+invokeClangAction(PathRef FileName, tooling::CompileCommand Command,
+  PrecompiledPreamble const *Preamble, StringRef Contents,

Maybe rename to `invokeCodeCompletion`? `invokeClangAction` seems too generic.



Comment at: clangd/ClangdUnit.cpp:705
+  Clang->setCodeCompletionConsumer(
+  new CodeCompleteConsumerType(FrontendOpts.CodeCompleteOpts, Results));
 

Maybe receive `CodeCompleteConsumer` and not make function template?
We can return whether calling an action succeeded instead.



Comment at: test/clangd/signature-help.test:39
+# I'm just putting the questionable result in here now as the expected result.
+# CHECK-DAG: {"label":"bar(float x = 0, int y = 42) -> 
void","parameters":[{"label":"float x = 0, int y = 42"}]}
+# 

rwols wrote:
> When there are multiple defaulted parameters after each other, the 
> CK_Optional chunk consists of *all* of those parameters, instead of a 
> CK_Optional chunk per parameter. This might require us to dive into 
> SemaCodeComplete.cpp to fix this. I'm just leaving it as-is right now.
But does `CodeCompletionString` inside `Chunk->Optional` contain those extra 
parameters as a separate chunk?



https://reviews.llvm.org/D38048



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


r314424 - Fix -Wcast-qual warning after r314336.

2017-09-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Sep 28 08:44:46 2017
New Revision: 314424

URL: http://llvm.org/viewvc/llvm-project?rev=314424&view=rev
Log:
Fix -Wcast-qual warning after r314336.

Modified:
cfe/trunk/lib/AST/ExternalASTMerger.cpp

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=314424&r1=314423&r2=314424&view=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Thu Sep 28 08:44:46 2017
@@ -212,7 +212,7 @@ void ExternalASTMerger::ForEachMatchingD
 }
 if (!DidCallback && LoggingEnabled())
   logs() << "(ExternalASTMerger*)" << (void*)this
- << " asserting for (DeclContext*)" << (void*)DC
+ << " asserting for (DeclContext*)" << (const void*)DC
  << ", (ASTContext*)" << (void*)&Target.AST
  << "\n";
 assert(DidCallback && "Couldn't find a source context matching our DC");


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


[PATCH] D38364: Fix Modules/builtin-import.mm to be able to handle non-Darwin targets

2017-09-28 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab updated this revision to Diff 117002.
filcab added a comment.

Add umbrella-header-include-builtin.mm too


https://reviews.llvm.org/D38364

Files:
  test/Modules/builtin-import.mm
  test/Modules/umbrella-header-include-builtin.mm


Index: test/Modules/umbrella-header-include-builtin.mm
===
--- test/Modules/umbrella-header-include-builtin.mm
+++ test/Modules/umbrella-header-include-builtin.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
 
Index: test/Modules/builtin-import.mm
===
--- test/Modules/builtin-import.mm
+++ test/Modules/builtin-import.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
 
 #include 
 #include 


Index: test/Modules/umbrella-header-include-builtin.mm
===
--- test/Modules/umbrella-header-include-builtin.mm
+++ test/Modules/umbrella-header-include-builtin.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem %S/Inputs/libc-libcxx/sysroot/usr/include -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
 
Index: test/Modules/builtin-import.mm
===
--- test/Modules/builtin-import.mm
+++ test/Modules/builtin-import.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem %S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
 
 #include 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38366: Fix a warning about casting a const pointer to void*

2017-09-28 Thread Nikolai Bozhenov via Phabricator via cfe-commits
n.bozhenov created this revision.

https://reviews.llvm.org/rL314336 introduced a new compile time warning about 
casting a const pointer to void*. Because of that the compiler fails to be 
built with `-Werror` flag. The suggested patch fixes the issue.


https://reviews.llvm.org/D38366

Files:
  clang/lib/AST/ExternalASTMerger.cpp


Index: clang/lib/AST/ExternalASTMerger.cpp
===
--- clang/lib/AST/ExternalASTMerger.cpp
+++ clang/lib/AST/ExternalASTMerger.cpp
@@ -212,7 +212,7 @@
 }
 if (!DidCallback && LoggingEnabled())
   logs() << "(ExternalASTMerger*)" << (void*)this
- << " asserting for (DeclContext*)" << (void*)DC
+ << " asserting for (DeclContext*)" << (const void*)DC
  << ", (ASTContext*)" << (void*)&Target.AST
  << "\n";
 assert(DidCallback && "Couldn't find a source context matching our DC");


Index: clang/lib/AST/ExternalASTMerger.cpp
===
--- clang/lib/AST/ExternalASTMerger.cpp
+++ clang/lib/AST/ExternalASTMerger.cpp
@@ -212,7 +212,7 @@
 }
 if (!DidCallback && LoggingEnabled())
   logs() << "(ExternalASTMerger*)" << (void*)this
- << " asserting for (DeclContext*)" << (void*)DC
+ << " asserting for (DeclContext*)" << (const void*)DC
  << ", (ASTContext*)" << (void*)&Target.AST
  << "\n";
 assert(DidCallback && "Couldn't find a source context matching our DC");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-09-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:82
 
 // FIXME(ibiryukov): Invalidate cached compilation databases on changes
+return Result;

Why remove this `FIXME`?



Comment at: clangd/tool/ClangdMain.cpp:86
+"The argument will be "
+"ignored.\n";
+CompileCommandsDirPath = llvm::None;

NIT: maybe join this with previous line?



Comment at: clangd/tool/ClangdMain.cpp:89
+  } else
+CompileCommandsDirPath = CompileCommandsDir;
 

NIT: don't mix branches with and without `{}`. Simply use `{}` on all branches 
in that case.


https://reviews.llvm.org/D37150



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

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



Comment at: lib/Sema/SemaType.cpp:6810
+  QualType &T, TypeAttrLocation TAL) {
+  if (!State.getSema().getLangOpts().OpenCL ||
+  T.getAddressSpace() != LangAS::Default)

Anastasia wrote:
> I think this could be checked before calling the function.
will do.



Comment at: lib/Sema/SemaType.cpp:6863
+  unsigned ImpAddr;
+  bool IsStatic = D.getDeclSpec().getStorageClassSpec() == 
DeclSpec::SCS_static;
+  // Put OpenCL automatic variable in private address space.

Anastasia wrote:
> Do we cover `extern` too?
will add.



Comment at: lib/Sema/SemaType.cpp:6872
+  ImpAddr = LangAS::opencl_private;
+else if (IsStatic)
+  ImpAddr = LangAS::opencl_global;

Anastasia wrote:
> I think we can't have this case for CL1.2 see s6.8. But I think it could 
> happen for `extern` though.
Right. I will remove setting implicit addr space for static var for CL1.2.

For extern var, for CL2.0 I will set implicit addr space to global.

However, for CL1.2 since only constant addr space is supported for file-scope 
var, I can only set the implicit addr space of an extern var to be constant. 
However I feel this may cause more confusion than convenience, therefore I will 
not set implicit addr space for extern var for CL1.2. If user does not use 
constant addr space with extern var explicitly, they will see diagnostics that 
extern var must have constant addr space. This is also the current behavior 
before my change.


https://reviews.llvm.org/D35082



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


[PATCH] D38366: Fix a warning about casting a const pointer to void*

2017-09-28 Thread Nikolai Bozhenov via Phabricator via cfe-commits
n.bozhenov abandoned this revision.
n.bozhenov added a comment.

Seems that it has been just fixed by https://reviews.llvm.org/rL314424 :-)
Abandoning this review.


https://reviews.llvm.org/D38366



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


r314427 - Consolidate std::move() detection code. No behavior change.

2017-09-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Sep 28 09:16:39 2017
New Revision: 314427

URL: http://llvm.org/viewvc/llvm-project?rev=314427&view=rev
Log:
Consolidate std::move() detection code. No behavior change.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/Analysis/Consumed.cpp
cfe/trunk/lib/Analysis/UninitializedValues.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=314427&r1=314426&r2=314427&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Sep 28 09:16:39 2017
@@ -2348,6 +2348,12 @@ public:
   SourceLocation getLocStart() const LLVM_READONLY;
   SourceLocation getLocEnd() const LLVM_READONLY;
 
+  bool isCallToStdMove() const {
+const FunctionDecl* FD = getDirectCallee();
+return getNumArgs() == 1 && FD && FD->isInStdNamespace() &&
+   FD->getIdentifier() && FD->getIdentifier()->isStr("move");
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() >= firstCallExprConstant &&
T->getStmtClass() <= lastCallExprConstant;

Modified: cfe/trunk/lib/Analysis/Consumed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=314427&r1=314426&r2=314427&view=diff
==
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Thu Sep 28 09:16:39 2017
@@ -749,8 +749,7 @@ void ConsumedStmtVisitor::VisitCallExpr(
 
   // Special case for the std::move function.
   // TODO: Make this more specific. (Deferred)
-  if (Call->getNumArgs() == 1 && FunDecl->getNameAsString() == "move" &&
-  FunDecl->isInStdNamespace()) {
+  if (Call->isCallToStdMove()) {
 copyInfo(Call->getArg(0), Call, CS_Consumed);
 return;
   }

Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=314427&r1=314426&r2=314427&view=diff
==
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Thu Sep 28 09:16:39 2017
@@ -440,16 +440,11 @@ static bool isPointerToConst(const QualT
 
 void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
   // Classify arguments to std::move as used.
-  if (CE->getNumArgs() == 1) {
-if (FunctionDecl *FD = CE->getDirectCallee()) {
-  if (FD->isInStdNamespace() && FD->getIdentifier() &&
-  FD->getIdentifier()->isStr("move")) {
-// RecordTypes are handled in SemaDeclCXX.cpp.
-if (!CE->getArg(0)->getType()->isRecordType())
-  classify(CE->getArg(0), Use);
-return;
-  }
-}
+  if (CE->isCallToStdMove()) {
+// RecordTypes are handled in SemaDeclCXX.cpp.
+if (!CE->getArg(0)->getType()->isRecordType())
+  classify(CE->getArg(0), Use);
+return;
   }
 
   // If a value is passed by const pointer or by const reference to a function,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=314427&r1=314426&r2=314427&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 28 09:16:39 2017
@@ -11765,9 +11765,7 @@ void Sema::DiagnoseSelfMove(const Expr *
 return;
 
   // Check for a call to std::move
-  const FunctionDecl *FD = CE->getDirectCallee();
-  if (!FD || !FD->isInStdNamespace() || !FD->getIdentifier() ||
-  !FD->getIdentifier()->isStr("move"))
+  if (!CE->isCallToStdMove())
 return;
 
   // Get argument from std::move

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=314427&r1=314426&r2=314427&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Sep 28 09:16:39 2017
@@ -9993,14 +9993,9 @@ namespace {
 
 void VisitCallExpr(CallExpr *E) {
   // Treat std::move as a use.
-  if (E->getNumArgs() == 1) {
-if (FunctionDecl *FD = E->getDirectCallee()) {
-  if (FD->isInStdNamespace() && FD->getIdentifier() &&
-  FD->getIdentifier()->isStr("move")) {
-HandleValue(E->getArg(0));
-return;
-  }
-}
+  if (E->isCallToStdMove()) {
+HandleValue(E->getArg(0));
+return;
   }
 
   Inherited::VisitCallExpr(E);

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cp

Re: Patch bug 27628

2017-09-28 Thread Antoni Boucher via cfe-commits

Any news on this?


Aaand the patch itself...

-K

On 9/8/2017 10:32 AM, Krzysztof Parzyszek via cfe-commits wrote:

This should to to cfe-commits.  Redirecting.

-Krzysztof

On 9/8/2017 10:25 AM, Antoni Boucher via llvm-commits wrote:

Hello.
I've fixed the bug 27628:
https://bugs.llvm.org/show_bug.cgi?id=27628

I attached the patch.

Thanks.


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





--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

-- next part --
An embedded and charset-unspecified text was scrubbed...
Name: clang-tidy-error-code.diff
URL: 


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


[PATCH] D38364: Fix Modules/builtin-import.mm to be able to handle non-Darwin targets

2017-09-28 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Thanks Filipe, LGTM


https://reviews.llvm.org/D38364



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


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

2017-09-28 Thread Masud Rahman via Phabricator via cfe-commits
frutiger added inline comments.



Comment at: bindings/python/clang/cindex.py:320
+return self._get_spelling()['offset']
 
 def __eq__(self, other):

compnerd wrote:
> Does it make sense to introduce two new properties `expansion` and `spelling` 
> and have the four fields be properties on those properties?  It seems like it 
> would be more pythonic.
I agree, but I was concerned about breaking existing users that might be using 
the expansion properties directly on this object.  Would marking them 
deprecated in the documentation suffice?


https://reviews.llvm.org/D37905



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


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

2017-09-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

Ping.

Brian, Stas,

Can you review this since Matt is on vacation? Thanks.


https://reviews.llvm.org/D37568



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


[PATCH] D38202: Add Documentation to attribute-nothrow. Additionally, limit to functions.

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

LGTM!


https://reviews.llvm.org/D38202



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 117020.
yaxunl marked 3 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments.


https://reviews.llvm.org/D35082

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/NVPTX.h
  lib/Basic/Targets/SPIR.h
  lib/Basic/Targets/TCE.h
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/blocks-opencl.cl
  test/CodeGenOpenCL/address-spaces-mangling.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/atomic-ops.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/extern.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/null_literal.cl
  test/SemaOpenCL/storageclass-cl20.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -5,6 +5,20 @@
 int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
 global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
+static float g_implicit_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
+static constant float g_constant_static_var = 0;
+static global float g_global_static_var = 0;   // expected-error {{program scope variable must reside in constant address space}}
+static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
+static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
+static generic float g_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
+
+extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
+extern constant float g_constant_extern_var;
+extern global float g_global_extern_var;   // expected-error {{extern variable must reside in constant address space}}
+extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
+extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}}
+extern generic float g_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
+
 void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
   static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
@@ -45,10 +59,17 @@
 __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}}
   }
 
+  static float l_implicit_static_var = 0;  // expected-error {{variables in function scope cannot be declared static}}
+  static constant float l_constant_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
+  static global float l_global_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
+  static local float l_local_static_var = 0;   // expected-error {{variables in function scope cannot be declared static}}
+  static private float l_private_static_var = 0;   // expected-error {{variables in function scope cannot be declared static}}
+  static generic float l_generic_static_var = 0;   // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{variables in function scope cannot be declared static}}
 
-  extern constant float L5;
-  extern local float L6; // expected-error{{extern variable must reside in constant address space}}
-
-  static int L7 = 0; // expected-error{{variables in function scope cannot be declared static}}
-  static int L8; // expected-error{{variables in function scope cannot be declared static}}
+  extern float l_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
+  extern constant float l_constant_extern_var;
+  extern global float l_global_extern_var;   // expected-error {{extern variable must reside in constant address space}}
+  extern local float l_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
+  extern private float l_private_extern_var; // 

[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-28 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.

This is somewhat complicated in that noexcept, throw(), and 
__attribute__(())/__declspec no throw are all synonyms for one another except 
for the type system effect differences between __attribute__ and __declspec, 
but I think our behavior here is reasonable.


https://reviews.llvm.org/D38209



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


[PATCH] D38205: [Sema] Warn on attribute nothrow conflicting with language specifiers

2017-09-28 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.

In https://reviews.llvm.org/D38205#882737, @erichkeane wrote:

> changes that were suggested by @aaron.ballman
>
> It DOES warn on the template correctly, however I'm not thrilled that it 
> misses the 'warning' info.  Any idea how I can get that information to give 
> that 'note'?  I'd like an "in instantiation of template ..." type note.


That's usually automatic. You might want to look at 
`Sema::EmitCurrentDiagnostic()` to see what's up, it's `PrintContextStack()` 
that does the magic.

The diagnostics LGTM as-is, but further improvement isn't discouraged.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1411
+def warn_nothrow_attr_disagrees_with_exception_specification
+: ExtWarn<"Attribute nothrow ignored, it disagrees with language specified 
"
+  "exception specification">,

aaron.ballman wrote:
> How about: `"attribute 'nothrow' ignored due to conflicting exception 
> specification"`
Close, but not quite. The warning should not be capitalized and it's missing 
single quotes around `nothrow`.


https://reviews.llvm.org/D38205



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


[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I think I will go ahead and commit this; it doesn't change the status quo for 
CodeView and if something is warranted we can do that in a follow-up.


https://reviews.llvm.org/D14358



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


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

2017-09-28 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner accepted this revision.
b-sumner added a comment.
This revision is now accepted and ready to land.

LGTM.  I think we can leave immediates to another patch.


https://reviews.llvm.org/D37568



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


[PATCH] D38371: [OpenMP] Initial implementation of teams distribute code generation

2017-09-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D38371



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


[PATCH] D38372: [OpenMP] Fix passing of -m arguments correctly

2017-09-28 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

The recent fix in https://reviews.llvm.org/D38258 was wrong: getAuxTriple() 
only returns
non-null values for the CUDA toolchain. That is why the now added
test for PPC and X86 failed.


https://reviews.llvm.org/D38372

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Compilation.cpp
  lib/Driver/ToolChain.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -71,6 +71,14 @@
 
 /// ###
 
+/// Check -march=pwr7 is NOT passed to x86_64-unknown-linux-gnu.
+// RUN:%clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=x86_64-unknown-linux-gnu -march=pwr7 %s 2>&1 \
+// RUN:| FileCheck -check-prefix=CHK-FOPENMP-MARCH-TO-X86 %s
+
+// CHK-FOPENMP-MARCH-TO-X86-NOT: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ###
+
 /// Check -Xopenmp-target triggers error when multiple triples are used.
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -801,74 +801,68 @@
 }
 
 llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
-const llvm::opt::DerivedArgList &Args,
-Action::OffloadKind DeviceOffloadKind,
-SmallVector &AllocatedArgs) const {
-  if (DeviceOffloadKind == Action::OFK_OpenMP) {
-DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
-const OptTable &Opts = getDriver().getOpts();
-bool Modified = false;
-
-// Handle -Xopenmp-target flags
-for (Arg *A : Args) {
-  // Exclude flags which may only apply to the host toolchain.
-  // Do not exclude flags when the host triple (AuxTriple)
-  // matches the current toolchain triple. If it is not present
-  // at all, target and host share a toolchain.
-  if (A->getOption().matches(options::OPT_m_Group)) {
-if (!getAuxTriple() || getAuxTriple()->str() == getTriple().str())
-  DAL->append(A);
-else
-  Modified = true;
-continue;
-  }
-
-  unsigned Index;
-  unsigned Prev;
-  bool XOpenMPTargetNoTriple = A->getOption().matches(
-  options::OPT_Xopenmp_target);
-
-  if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
-// Passing device args: -Xopenmp-target= -opt=val.
-if (A->getValue(0) == getTripleString())
-  Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
-else
-  continue;
-  } else if (XOpenMPTargetNoTriple) {
-// Passing device args: -Xopenmp-target -opt=val.
-Index = Args.getBaseArgs().MakeIndex(A->getValue(0));
-  } else {
+const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,
+SmallVectorImpl &AllocatedArgs) const {
+  DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
+  const OptTable &Opts = getDriver().getOpts();
+  bool Modified = false;
+
+  // Handle -Xopenmp-target flags
+  for (Arg *A : Args) {
+// Exclude flags which may only apply to the host toolchain.
+// Do not exclude flags when the host triple (AuxTriple)
+// matches the current toolchain triple. If it is not present
+// at all, target and host share a toolchain.
+if (A->getOption().matches(options::OPT_m_Group)) {
+  if (SameTripleAsHost)
 DAL->append(A);
+  else
+Modified = true;
+  continue;
+}
+
+unsigned Index;
+unsigned Prev;
+bool XOpenMPTargetNoTriple =
+A->getOption().matches(options::OPT_Xopenmp_target);
+
+if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
+  // Passing device args: -Xopenmp-target= -opt=val.
+  if (A->getValue(0) == getTripleString())
+Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
+  else
 continue;
-  }
-
-  // Parse the argument to -Xopenmp-target.
-  Prev = Index;
-  std::unique_ptr XOpenMPTargetArg(Opts.ParseOneArg(Args, Index));
-  if (!XOpenMPTargetArg || Index > Prev + 1) {
-getDriver().Diag(diag::err_drv_invalid_Xopenmp_target_with_args)
-<< A->getAsString(Args);
-continue;
-  }
-  if (XOpenMPTargetNoTriple && XOpenMPTargetArg &&
-  Args.getAllArgValues(
-  options::OPT_fopenmp_targets_EQ).size() != 1) {
-getDriver().Diag(diag::err_drv_Xopenmp_target_missing_triple);
-continue;
-  }
-  XOpenMPTargetArg->setBaseArg(A);
-  A = XOpenMPTargetArg.release();
-  AllocatedArgs.push_

r314444 - [DWARF] Allow forward declarations of a class template instantiation

2017-09-28 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Sep 28 11:37:02 2017
New Revision: 31

URL: http://llvm.org/viewvc/llvm-project?rev=31&view=rev
Log:
[DWARF] Allow forward declarations of a class template instantiation
to have child entries describing the template parameters.  This will
be on by default for SCE tuning.

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=31&r1=314443&r2=31&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Sep 28 11:37:02 2017
@@ -200,6 +200,9 @@ def arange_sections : Flag<["-"], "arang
 def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
+def debug_forward_template_params : Flag<["-"], 
"debug-forward-template-params">,
+  HelpText<"Emit complete descriptions of template parameters in forward"
+   " declarations">;
 def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">,
   HelpText<"Emit an error if a C++ static local initializer would need a guard 
variable">;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=31&r1=314443&r2=31&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Sep 28 11:37:02 2017
@@ -219,6 +219,10 @@ CODEGENOPT(EnableSplitDwarf, 1, 0) ///<
 CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in 
the
  ///< skeleton CU to allow for 
symbolication
 ///< of inline stack frames without .dwo 
files.
+CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
+ ///< template parameter descriptions 
in
+ ///< forward declarations (versus just
+ ///< including them in the name).
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=31&r1=314443&r2=31&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 28 11:37:02 2017
@@ -833,6 +833,10 @@ CGDebugInfo::getOrCreateRecordFwdDecl(co
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
   llvm::DINode::FlagFwdDecl, FullName);
+  if (CGM.getCodeGenOpts().DebugFwdTemplateParams)
+if (auto *TSpecial = dyn_cast(RD))
+  DBuilder.replaceArrays(RetTy, llvm::DINodeArray(),
+ CollectCXXTemplateParams(TSpecial, DefUnit));
   ReplaceMap.emplace_back(
   std::piecewise_construct, std::make_tuple(Ty),
   std::make_tuple(static_cast(RetTy)));

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=31&r1=314443&r2=31&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep 28 11:37:02 2017
@@ -2969,6 +2969,11 @@ static void RenderDebugOptions(const Too
 CmdArgs.push_back("-generate-type-units");
   }
 
+  // Decide how to render forward declarations of template instantiations.
+  // SCE wants full descriptions, others just get them in the name.
+  if (DebuggerTuning == llvm::DebuggerKind::SCE)
+CmdArgs.push_back("-debug-forward-template-params");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D);
 }
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=31&r1=314443&r2=31&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/li

[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-28 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL31: [DWARF] Allow forward declarations of a class 
template instantiation (authored by probinson).

Changed prior to commit:
  https://reviews.llvm.org/D14358?vs=116862&id=117030#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D14358

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -833,6 +833,10 @@
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
   llvm::DINode::FlagFwdDecl, FullName);
+  if (CGM.getCodeGenOpts().DebugFwdTemplateParams)
+if (auto *TSpecial = dyn_cast(RD))
+  DBuilder.replaceArrays(RetTy, llvm::DINodeArray(),
+ CollectCXXTemplateParams(TSpecial, DefUnit));
   ReplaceMap.emplace_back(
   std::piecewise_construct, std::make_tuple(Ty),
   std::make_tuple(static_cast(RetTy)));
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -2969,6 +2969,11 @@
 CmdArgs.push_back("-generate-type-units");
   }
 
+  // Decide how to render forward declarations of template instantiations.
+  // SCE wants full descriptions, others just get them in the name.
+  if (DebuggerTuning == llvm::DebuggerKind::SCE)
+CmdArgs.push_back("-debug-forward-template-params");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D);
 }
 
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -528,6 +528,7 @@
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
   Opts.DebugExplicitImport = Triple.isPS4CPU();
+  Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
 
   for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
 Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -200,6 +200,9 @@
 def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
+def debug_forward_template_params : Flag<["-"], 
"debug-forward-template-params">,
+  HelpText<"Emit complete descriptions of template parameters in forward"
+   " declarations">;
 def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">,
   HelpText<"Emit an error if a C++ static local initializer would need a guard 
variable">;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -219,6 +219,10 @@
 CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in 
the
  ///< skeleton CU to allow for 
symbolication
 ///< of inline stack frames without .dwo 
files.
+CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
+ ///< template parameter descriptions 
in
+ ///< forward declarations (versus just
+ ///< including them in the name).
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
Index: cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-fwd-template-param.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited 
-debug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=CHILD 
%s
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited 
-emit-llvm -o - | FileCheck --check-prefix=NONE %s
+// A DWARF forward declaration of a template instantiati

[clang-tools-extra] r314445 - [clangd] Skip informative qualifier chunks.

2017-09-28 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Sep 28 11:39:59 2017
New Revision: 314445

URL: http://llvm.org/viewvc/llvm-project?rev=314445&view=rev
Log:
[clangd] Skip informative qualifier chunks.

Summary:
Completion results look much nicer without them.
Informative qualifiers are stored for every method from a base class, even when
calling those methods does not require any qualifiers. For example,
struct Foo { int foo(); };
struct Bar : Foo { };
void test() { Bar(). // Completion item label was 'Foo::foo' before,
 // but inserted text was simply 'foo'.
 // We now simply show 'foo' in completion item label.

They effectively cluttered the completion list without providing much value.

Reviewers: bkramer, krasimir, rwols

Reviewed By: rwols

Subscribers: klimek, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=314445&r1=31&r2=314445&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Sep 28 11:39:59 2017
@@ -409,6 +409,11 @@ private:
 
 }; // CompletionItemsCollector
 
+bool isInformativeQualifierChunk(CodeCompletionString::Chunk const &Chunk) {
+  return Chunk.Kind == CodeCompletionString::CK_Informative &&
+ StringRef(Chunk.Text).endswith("::");
+}
+
 class PlainTextCompletionItemsCollector final
 : public CompletionItemsCollector {
 
@@ -421,6 +426,11 @@ private:
   void ProcessChunks(const CodeCompletionString &CCS,
  CompletionItem &Item) const override {
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // There's always exactly one CK_TypedText chunk.
@@ -453,6 +463,11 @@ private:
  CompletionItem &Item) const override {
 unsigned ArgCount = 0;
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // The piece of text that the user is expected to type to match

Added: clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion-qualifiers.test?rev=314445&view=auto
==
--- clang-tools-extra/trunk/test/clangd/completion-qualifiers.test (added)
+++ clang-tools-extra/trunk/test/clangd/completion-qualifiers.test Thu Sep 28 
11:39:59 2017
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class
 Foo {\n  public:\nint foo() const;\nint bar() const;\n};\n\nclass Bar 
: public Foo {\n  int foo() const;\n};\n\nvoid test() {\n  Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHECK-DAG: {"label":"foo() 
const","kind":2,"detail":"int","sortText":"200035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK-DAG: {"label":"bar() 
const","kind":2,"detail":"int","sortText":"37bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHECK-DAG: {"label":"Foo::foo() 
const","kind":2,"detail":"int","sortText":"37foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}


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


[PATCH] D38083: [clangd] Skip informative qualifier chunks.

2017-09-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314445: [clangd] Skip informative qualifier chunks. 
(authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38083

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/test/clangd/completion-qualifiers.test


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -409,6 +409,11 @@
 
 }; // CompletionItemsCollector
 
+bool isInformativeQualifierChunk(CodeCompletionString::Chunk const &Chunk) {
+  return Chunk.Kind == CodeCompletionString::CK_Informative &&
+ StringRef(Chunk.Text).endswith("::");
+}
+
 class PlainTextCompletionItemsCollector final
 : public CompletionItemsCollector {
 
@@ -421,6 +426,11 @@
   void ProcessChunks(const CodeCompletionString &CCS,
  CompletionItem &Item) const override {
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // There's always exactly one CK_TypedText chunk.
@@ -453,6 +463,11 @@
  CompletionItem &Item) const override {
 unsigned ArgCount = 0;
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // The piece of text that the user is expected to type to match
Index: clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
===
--- clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
+++ clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class
 Foo {\n  public:\nint foo() const;\nint bar() const;\n};\n\nclass Bar 
: public Foo {\n  int foo() const;\n};\n\nvoid test() {\n  Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHECK-DAG: {"label":"foo() 
const","kind":2,"detail":"int","sortText":"200035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK-DAG: {"label":"bar() 
const","kind":2,"detail":"int","sortText":"37bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHECK-DAG: {"label":"Foo::foo() 
const","kind":2,"detail":"int","sortText":"37foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -409,6 +409,11 @@
 
 }; // CompletionItemsCollector
 
+bool isInformativeQualifierChunk(CodeCompletionString::Chunk const &Chunk) {
+  return Chunk.Kind == CodeCompletionString::CK_Informative &&
+ StringRef(Chunk.Text).endswith("::");
+}
+
 class PlainTextCompletionItemsCollector final
 : public CompletionItemsCollector {
 
@@ -421,6 +426,11 @@
   void ProcessChunks(const CodeCompletionString &CCS,
  CompletionItem &Item) const override {
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // There's always exactly one CK_TypedText chunk.
@@ -453,6 +463,11 @@
  CompletionItem &Item) const override {
 unsigned ArgCount = 0;
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // The piece of text that the user is expected to type to match
Index: clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
==

Re: Patch bug 27628 (clang-tidy should exit with a failure code when there are errors)

2017-09-28 Thread Friedman, Eli via cfe-commits
When you're submitting a patch, please make sure you're sending it to 
the right list, and the "subject" line actually describes what the patch 
changes; otherwise, reviewers won't notice the patch.  Optionally, you 
can submit a patch using Phabricator, a tool which which makes patch 
reviews a little easier.  See 
http://llvm.org/docs/DeveloperPolicy.html#code-reviews


-Eli

On 9/28/2017 10:22 AM, Antoni Boucher via cfe-commits wrote:

Any news on this?


Aaand the patch itself...

-K

On 9/8/2017 10:32 AM, Krzysztof Parzyszek via cfe-commits wrote:

This should to to cfe-commits. Redirecting.

-Krzysztof

On 9/8/2017 10:25 AM, Antoni Boucher via llvm-commits wrote:

Hello.
I've fixed the bug 27628:
https://bugs.llvm.org/show_bug.cgi?id=27628

I attached the patch.

Thanks.


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





--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

-- next part --
An embedded and charset-unspecified text was scrubbed...
Name: clang-tidy-error-code.diff
URL: 


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



--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


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

2017-09-28 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314452: [AMDGPU] Allow flexible register names in inline asm 
constraints (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D37568?vs=116383&id=117037#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37568

Files:
  cfe/trunk/lib/Basic/Targets/AMDGPU.h
  cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl

Index: cfe/trunk/lib/Basic/Targets/AMDGPU.h
===
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.h
@@ -17,6 +17,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
 
@@ -115,17 +116,83 @@
 return None;
   }
 
+  /// Accepted register names: (n, m is unsigned integer, n < m)
+  /// v
+  /// s
+  /// {vn}, {v[n]}
+  /// {sn}, {s[n]}
+  /// {S} , where S is a special register name
+  {v[n:m]}
+  /// {s[n:m]}
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
-switch (*Name) {
-default:
-  break;
-case 'v': // vgpr
-case 's': // sgpr
+static const ::llvm::StringSet<> SpecialRegs({
+"exec", "vcc", "flat_scratch", "m0", "scc", "tba", "tma",
+"flat_scratch_lo", "flat_scratch_hi", "vcc_lo", "vcc_hi", "exec_lo",
+"exec_hi", "tma_lo", "tma_hi", "tba_lo", "tba_hi",
+});
+
+StringRef S(Name);
+bool HasLeftParen = false;
+if (S.front() == '{') {
+  HasLeftParen = true;
+  S = S.drop_front();
+}
+if (S.empty())
+  return false;
+if (S.front() != 'v' && S.front() != 's') {
+  if (!HasLeftParen)
+return false;
+  auto E = S.find('}');
+  if (!SpecialRegs.count(S.substr(0, E)))
+return false;
+  S = S.drop_front(E + 1);
+  if (!S.empty())
+return false;
+  // Found {S} where S is a special register.
+  Info.setAllowsRegister();
+  Name = S.data() - 1;
+  return true;
+}
+S = S.drop_front();
+if (!HasLeftParen) {
+  if (!S.empty())
+return false;
+  // Found s or v.
   Info.setAllowsRegister();
+  Name = S.data() - 1;
   return true;
 }
-return false;
+bool HasLeftBracket = false;
+if (!S.empty() && S.front() == '[') {
+  HasLeftBracket = true;
+  S = S.drop_front();
+}
+unsigned long long N;
+if (S.empty() || consumeUnsignedInteger(S, 10, N))
+  return false;
+if (!S.empty() && S.front() == ':') {
+  if (!HasLeftBracket)
+return false;
+  S = S.drop_front();
+  unsigned long long M;
+  if (consumeUnsignedInteger(S, 10, M) || N >= M)
+return false;
+}
+if (HasLeftBracket) {
+  if (S.empty() || S.front() != ']')
+return false;
+  S = S.drop_front();
+}
+if (S.empty() || S.front() != '}')
+  return false;
+S = S.drop_front();
+if (!S.empty())
+  return false;
+// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+Info.setAllowsRegister();
+Name = S.data() - 1;
+return true;
   }
 
   bool
Index: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
===
--- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
+++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
@@ -1,14 +1,76 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -triple amdgcn -fsyntax-only -verify %s
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
 kernel void test () {
 
   int sgpr = 0, vgpr = 0, imm = 0;
 
   // sgpr constraints
   __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
 
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec}" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exe" (imm) : ); // expected-error {{invalid input constraint '{exe' in asm}}
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec" (imm) : ); // expected-error {{invalid input constraint '{exec' in asm}}
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec}a" (imm) : ); // expected-error {{invalid input constraint '{exec}a' in asm}}
+
   // vgpr constraints
   __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
 }
+
+__kernel void
+test_float(const __global float *a, const __global float *b, __global float *c, unsigned i)
+{
+float ai = a[i];
+float bi = b[i];
+float ci;
+
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1}"(ci) : "{v2}"(ai), "{v3}"(bi) : );
+__asm("v_add_f32_e32 v1, v2, v3" : ""(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "="(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{inval

r314452 - [AMDGPU] Allow flexible register names in inline asm constraints

2017-09-28 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Sep 28 12:07:59 2017
New Revision: 314452

URL: http://llvm.org/viewvc/llvm-project?rev=314452&view=rev
Log:
[AMDGPU] Allow flexible register names in inline asm constraints

Currently AMDGPU inline asm only allow v and s as register names in constraints.

This patch allows the following register names in constraints: (n, m is 
unsigned integer, n < m)

v

s

{vn} or {v[n]}

{sn} or {s[n]}

{S} , where S is a special register name

{v[n:m]}

{s[n:m]}

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

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=314452&r1=314451&r2=314452&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Thu Sep 28 12:07:59 2017
@@ -17,6 +17,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
 
@@ -115,17 +116,83 @@ public:
 return None;
   }
 
+  /// Accepted register names: (n, m is unsigned integer, n < m)
+  /// v
+  /// s
+  /// {vn}, {v[n]}
+  /// {sn}, {s[n]}
+  /// {S} , where S is a special register name
+  {v[n:m]}
+  /// {s[n:m]}
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
-switch (*Name) {
-default:
-  break;
-case 'v': // vgpr
-case 's': // sgpr
+static const ::llvm::StringSet<> SpecialRegs({
+"exec", "vcc", "flat_scratch", "m0", "scc", "tba", "tma",
+"flat_scratch_lo", "flat_scratch_hi", "vcc_lo", "vcc_hi", "exec_lo",
+"exec_hi", "tma_lo", "tma_hi", "tba_lo", "tba_hi",
+});
+
+StringRef S(Name);
+bool HasLeftParen = false;
+if (S.front() == '{') {
+  HasLeftParen = true;
+  S = S.drop_front();
+}
+if (S.empty())
+  return false;
+if (S.front() != 'v' && S.front() != 's') {
+  if (!HasLeftParen)
+return false;
+  auto E = S.find('}');
+  if (!SpecialRegs.count(S.substr(0, E)))
+return false;
+  S = S.drop_front(E + 1);
+  if (!S.empty())
+return false;
+  // Found {S} where S is a special register.
+  Info.setAllowsRegister();
+  Name = S.data() - 1;
+  return true;
+}
+S = S.drop_front();
+if (!HasLeftParen) {
+  if (!S.empty())
+return false;
+  // Found s or v.
   Info.setAllowsRegister();
+  Name = S.data() - 1;
   return true;
 }
-return false;
+bool HasLeftBracket = false;
+if (!S.empty() && S.front() == '[') {
+  HasLeftBracket = true;
+  S = S.drop_front();
+}
+unsigned long long N;
+if (S.empty() || consumeUnsignedInteger(S, 10, N))
+  return false;
+if (!S.empty() && S.front() == ':') {
+  if (!HasLeftBracket)
+return false;
+  S = S.drop_front();
+  unsigned long long M;
+  if (consumeUnsignedInteger(S, 10, M) || N >= M)
+return false;
+}
+if (HasLeftBracket) {
+  if (S.empty() || S.front() != ']')
+return false;
+  S = S.drop_front();
+}
+if (S.empty() || S.front() != '}')
+  return false;
+S = S.drop_front();
+if (!S.empty())
+  return false;
+// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+Info.setAllowsRegister();
+Name = S.data() - 1;
+return true;
   }
 
   bool

Modified: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl?rev=314452&r1=314451&r2=314452&view=diff
==
--- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl (original)
+++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl Thu Sep 28 12:07:59 2017
@@ -1,6 +1,7 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -triple amdgcn -fsyntax-only -verify %s
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
 kernel void test () {
 
@@ -9,6 +10,67 @@ kernel void test () {
   // sgpr constraints
   __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
 
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec}" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exe" (imm) : ); // 
expected-error {{invalid input constraint '{exe' in asm}}
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec" (imm) : ); // 
expected-error {{invalid input constraint '{exec' in asm}}
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec}a" (imm) : ); // 
expected-error {{invalid input constraint '{exec}a' in asm}}
+
   

[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

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



Comment at: test/FixIt/format.m:256
+  // see the comment in PrintfSpecifier::fixType in PrintfFormatString.cpp.
+}
+

Can you add some positive tests that show "%t" and "%tu" working properly 
without warnings?


Repository:
  rL LLVM

https://reviews.llvm.org/D38270



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


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

2017-09-28 Thread Masud Rahman via Phabricator via cfe-commits
frutiger updated this revision to Diff 117041.
frutiger added a comment.

Updated as per review.


https://reviews.llvm.org/D37905

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

Index: tools/libclang/CXSourceLocation.cpp
===
--- tools/libclang/CXSourceLocation.cpp
+++ tools/libclang/CXSourceLocation.cpp
@@ -318,8 +318,7 @@
   
   const SourceManager &SM =
   *static_cast(location.ptr_data[0]);
-  // FIXME: This should call SourceManager::getSpellingLoc().
-  SourceLocation SpellLoc = SM.getFileLoc(Loc);
+  SourceLocation SpellLoc = SM.getSpellingLoc(Loc);
   std::pair LocInfo = SM.getDecomposedLoc(SpellLoc);
   FileID FID = LocInfo.first;
   unsigned FileOffset = LocInfo.second;
Index: bindings/python/tests/cindex/test_location.py
===
--- bindings/python/tests/cindex/test_location.py
+++ bindings/python/tests/cindex/test_location.py
@@ -93,3 +93,10 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 assert range1 != range3
+
+def test_spelling_location():
+tu = get_tu('''#define ONE int one
+ONE;''')
+one = get_cursor(tu, 'one')
+assert one.location.spelling.line == 1
+assert one.location.expansion.line == 2
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -211,25 +211,45 @@
 assert isinstance(res, _CXString)
 return conf.lib.clang_getCString(res)
 
+class Location(object):
+"""A Location is a specific kind of source location.  A SourceLocation
+refers to several kinds of locations (e.g.  spelling location vs. expansion
+location)."""
+
+def __init__(self, file, line, column, offset):
+self._file   = File(file) if file else None
+self._line   = int(line.value)
+self._column = int(column.value)
+self._offset = int(offset.value)
+
+
+@property
+def file(self):
+"""Get the file represented by this source location."""
+return self._file
+
+@property
+def line(self):
+"""Get the line represented by this source location."""
+return self._line
+
+@property
+def column(self):
+"""Get the column represented by this source location."""
+return self._column
+
+@property
+def offset(self):
+"""Get the file offset represented by this source location."""
+return self._offset
 
 class SourceLocation(Structure):
 """
 A SourceLocation represents a particular location within a source file.
 """
 _fields_ = [("ptr_data", c_void_p * 2), ("int_data", c_uint)]
-_data = None
-
-def _get_instantiation(self):
-if self._data is None:
-f, l, c, o = c_object_p(), c_uint(), c_uint(), c_uint()
-conf.lib.clang_getInstantiationLocation(self, byref(f), byref(l),
-byref(c), byref(o))
-if f:
-f = File(f)
-else:
-f = None
-self._data = (f, int(l.value), int(c.value), int(o.value))
-return self._data
+_expansion = None
+_spelling = None
 
 @staticmethod
 def from_position(tu, file, line, column):
@@ -249,25 +269,73 @@
 """
 return conf.lib.clang_getLocationForOffset(tu, file, offset)
 
+@property
+def expansion(self):
+"""
+The source location where then entity this object is referring to is
+expanded.
+"""
+if not self._expansion:
+file   = c_object_p()
+line   = c_uint()
+column = c_uint()
+offset = c_uint()
+conf.lib.clang_getExpansionLocation(self,
+byref(file),
+byref(line),
+byref(column),
+byref(offset))
+
+self._expansion = Location(file, line, column, offset)
+return self._expansion
+
+@property
+def spelling(self):
+"""
+The source location where then entity this object is referring to is
+written.
+"""
+if not self._spelling:
+file   = c_object_p()
+line   = c_uint()
+column = c_uint()
+offset = c_uint()
+conf.lib.clang_getSpellingLocation(self,
+   byref(file),
+   byref(line),
+   byref(column),
+   byref(offset))
+
+self._spelling = Location(file, line, c

Re: r314373 - [NFC] Don't use C++17 standard lib variable template helper traits, instead use ::value.

2017-09-28 Thread Faisal Vali via cfe-commits
Isn't this a C++11 feature though?

I'm not sure what to make of the fact that I haven't gotten any
complaints from the bots in over 12 hrs i think?

Should I just turn it into a comment?

Thanks!

Faisal Vali



On Wed, Sep 27, 2017 at 9:54 PM, James Y Knight  wrote:
> This still doesn't work on some compilers, because
> std::is_trivially_copyable isn't available:
> http://lab.llvm.org:8011/builders/aosp-O3-polly-before-vectorizer-unprofitable/builds/265/steps/build/logs/stdio
>
> On Wed, Sep 27, 2017 at 10:00 PM, Faisal Vali via cfe-commits
>  wrote:
>>
>> Author: faisalv
>> Date: Wed Sep 27 19:00:40 2017
>> New Revision: 314373
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=314373&view=rev
>> Log:
>> [NFC] Don't use C++17 standard lib variable template helper traits,
>> instead use ::value.
>>
>> Modified:
>> cfe/trunk/lib/Lex/MacroArgs.cpp
>>
>> Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=314373&r1=314372&r2=314373&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
>> +++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Sep 27 19:00:40 2017
>> @@ -62,7 +62,7 @@ MacroArgs *MacroArgs::create(const Macro
>>
>>// Copy the actual unexpanded tokens to immediately after the result
>> ptr.
>>if (!UnexpArgTokens.empty()) {
>> -static_assert(std::is_trivially_copyable_v,
>> +static_assert(std::is_trivially_copyable::value,
>>"assume trivial copyability if copying into the "
>>"uninitialized array (as opposed to reusing a cached "
>>"MacroArgs)");
>> @@ -96,7 +96,7 @@ MacroArgs *MacroArgs::deallocate() {
>>// Run the dtor to deallocate the vectors.
>>this->~MacroArgs();
>>// Release the memory for the object.
>> -  static_assert(std::is_trivially_destructible_v,
>> +  static_assert(std::is_trivially_destructible::value,
>>  "assume trivially destructible and forego destructors");
>>free(this);
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

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



Comment at: test/CXX/expr/expr.post/expr.sub/p1.cpp:3-6
+void pr34273() {
+  char Normal = "clang"[true]; // expected-no-diagnostics
+  char Special = true["clang"]; // expected-no-diagnostics
+}

I think this test should be added to test/Parser/ instead of CXX; this does not 
really appertain to [expr.sub]p1, which is more about the semantics than the 
parsing.



Comment at: test/CXX/expr/expr.post/expr.sub/p1.cpp:4-5
+void pr34273() {
+  char Normal = "clang"[true]; // expected-no-diagnostics
+  char Special = true["clang"]; // expected-no-diagnostics
+}

The "expected-no-diagnostics" comment should be right below the RUN line, and 
you only need it once.


https://reviews.llvm.org/D38342



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


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

2017-09-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D36836#883214, @lebedev.ri wrote:

> @alexfh please specify, is that enough or not?


I think it's sufficient, but we should put that information somewhere pertinent 
rather than just the review. In the past, we've put something into LICENSE.TXT 
to identify that we're in the clear, and that might be appropriate here as 
well. What do you think, @alexfh?


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


r314456 - Add Documentation to attribute-nothrow. Additionally, limit to functions.

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:08:03 2017
New Revision: 314456

URL: http://llvm.org/viewvc/llvm-project?rev=314456&view=rev
Log:
Add Documentation to attribute-nothrow. Additionally, limit to functions.

Attribute nothrow is only allowed on functions, so I added that. Additionally,
it lacks any documentation, so I added some.

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=314456&r1=314455&r2=314456&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Sep 28 13:08:03 2017
@@ -1437,7 +1437,8 @@ def NotTailCalled : InheritableAttr {
 
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoThrowDocs];
 }
 
 def NvWeak : IgnoredAttr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=314456&r1=314455&r2=314456&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Sep 28 13:08:03 2017
@@ -2727,6 +2727,18 @@ Marking virtual functions as ``not_tail_
   }];
 }
 
+def NoThrowDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` and Microsoft style
+``__declspec(nothrow)`` attribute as an equivilent of `noexcept` on function
+declarations. This attribute informs the compiler that the annotated function
+does not throw an exception. This prevents exception-unwinding. This attribute
+is particularly useful on functions in the C Standard Library that are
+guaranteed to not throw an exception.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=314456&r1=314455&r2=314456&view=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Thu Sep 
28 13:08:03 2017
@@ -40,6 +40,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)


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


[PATCH] D38202: Add Documentation to attribute-nothrow. Additionally, limit to functions.

2017-09-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314456: Add Documentation to attribute-nothrow. 
Additionally, limit to functions. (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38202?vs=116705&id=117044#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38202

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test


Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2727,6 +2727,18 @@
   }];
 }
 
+def NoThrowDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` and Microsoft style
+``__declspec(nothrow)`` attribute as an equivilent of `noexcept` on function
+declarations. This attribute informs the compiler that the annotated function
+does not throw an exception. This prevents exception-unwinding. This attribute
+is particularly useful on functions in the C Standard Library that are
+guaranteed to not throw an exception.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1437,7 +1437,8 @@
 
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoThrowDocs];
 }
 
 def NvWeak : IgnoredAttr {
Index: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -40,6 +40,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)


Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2727,6 +2727,18 @@
   }];
 }
 
+def NoThrowDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` and Microsoft style
+``__declspec(nothrow)`` attribute as an equivilent of `noexcept` on function
+declarations. This attribute informs the compiler that the annotated function
+does not throw an exception. This prevents exception-unwinding. This attribute
+is particularly useful on functions in the C Standard Library that are
+guaranteed to not throw an exception.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1437,7 +1437,8 @@
 
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoThrowDocs];
 }
 
 def NvWeak : IgnoredAttr {
Index: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -40,6 +40,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Fix for the issue 12176

2017-09-28 Thread Oscar Forner Martinez via cfe-commits

Hi,

Please find attached a diff to fix the issue 12176. Let me know if there 
is anything any improvements you can think of.


Best regards,

Oscar

Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h	(nonexistent)
+++ lib/Sema/DepthAndIndex.h	(working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex function -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair
+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
+return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp	(revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp	(working copy)
@@ -11,6 +11,7 @@
 //===--===/
 
 #include "clang/Sema/TemplateDeduction.h"
+#include "DepthAndIndex.h"
 #include "TreeTransform.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
   }
 }
 
-/// \brief Retrieve the depth and index of a template parameter.
-static std::pair
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
 /// \brief Retrieve the depth and index of an unexpanded parameter pack.
 static std::pair
 getDepthAndIndex(UnexpandedParameterPack UPP) {
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp	(revision 314321)
+++ lib/Sema/SemaTemplateInstantiate.cpp	(working copy)
@@ -11,6 +11,7 @@
 //===--===/
 
 #include "clang/Sema/SemaInternal.h"
+#include "DepthAndIndex.h"
 #include "TreeTransform.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
@@ -693,19 +694,6 @@
   return None;
 }
 
-/// \brief Retrieve the depth and index of a parameter pack.
-static std::pair 
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-  
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-  
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
 //===--===/
 // Template Instantiation for Types
 //===--===/
Index: lib/Sema/SemaTemplateVariadic.cpp
===
--- lib/Sema/SemaTemplateVariadic.cpp	(revision 314321)
+++ lib/Sema/SemaTemplateVariadic.cpp	(working copy)
@@ -10,6 +10,7 @@
 //===--===/
 
 #include "clang/Sema/Sema.h"
+#include "DepthAndIndex.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -26,19 +27,6 @@
 // Visitor that collects unexpanded parameter packs
 //
 
-/// \brief Retrieve the depth and index of a parameter pack.
-static std::pair 
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-  
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-  
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
 namespace {
   /// \brief A 

[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces

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



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:86
+  SourceLocation LBracketLocation = ND->getLocation();
+  auto NestedNamespaceBegin = LBracketLocation;
+

Do not use `auto` here (the type is not spelled out in the initialization, 
despite being relatively obvious. Same below.



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:90
+  // then bar instead of a single match. So if we got a nested namespace we 
have
+  // to skip the next ones
+  for (const auto &i : Ends) {

Missing a period at the end of the sentence.



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:91
+  // to skip the next ones
+  for (const auto &i : Ends) {
+if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin, i)) {

`i` does not meet the usual naming conventions; you might want to pick a 
slightly better name.



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:92
+  for (const auto &i : Ends) {
+if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin, i)) {
+  return;

You can elide the braces from the `if` statement.



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:109
+
+  if (IsNested) {
+Ends.push_back(LBracketLocation);

Elide braces



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:137
 
-  // Check if the namespace in the comment is the same.
-  if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) ||
-  (ND->getNameAsString() == NamespaceNameInComment &&
-   Anonymous.empty())) {
+  // C++17 nested namespace
+  if (IsNested && NestedNamespaceName == NamespaceNameInComment) {

Missing period in the comment



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:140-141
+return;
+  } // Check if the namespace in the comment is the same.
+  else if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) 
||
+   (ND->getNameAsString() == NamespaceNameInComment &&

I'd move the comments inside of the braces (the braces can be elided, but if 
the comments are in the body instead of out of it, I think they're fine to 
leave).



Comment at: clang-tidy/readability/NamespaceCommentCheck.h:37
   const unsigned SpacesBeforeComments;
+  llvm::SmallVector Ends;
 };

Why 7?



Comment at: test/clang-tidy/google-readability-nested-namespace-comments.cpp:6
+   
+   //so that namespace is not empty
+   void f();

Comment should start with a capital letter and end with punctuation.



Comment at: 
test/clang-tidy/google-readability-nested-namespace-comments.cpp:8-14
+   
+   
+   
+   
+   
+   
+   

Can remove the extra whitespace



Comment at: test/clang-tidy/google-readability-nested-namespace-comments.cpp:23
+// CHECK-FIXES: }  // namespace n1::n2
\ No newline at end of file


Please make sure there's a newline at the end of the file.


https://reviews.llvm.org/D38284



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


[libcxx] r314459 - [test] forwardlist.cons/move_noexcept.pass.cpp

2017-09-28 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Thu Sep 28 13:23:43 2017
New Revision: 314459

URL: http://llvm.org/viewvc/llvm-project?rev=314459&view=rev
Log:
[test] forwardlist.cons/move_noexcept.pass.cpp

* Don't forbid non-libc++ implementations from strengthening noexcept on 
forward_list's move constructor.

Modified:

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp?rev=314459&r1=314458&r2=314459&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
 Thu Sep 28 13:23:43 2017
@@ -45,9 +45,9 @@ int main()
 typedef std::forward_list> C;
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
-#endif // _LIBCPP_VERSION
 {
 typedef std::forward_list> C;
 static_assert(!std::is_nothrow_move_constructible::value, "");
 }
+#endif // _LIBCPP_VERSION
 }


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


r314460 - Fix test change missed in r314456

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:23:43 2017
New Revision: 314460

URL: http://llvm.org/viewvc/llvm-project?rev=314460&view=rev
Log:
Fix test change missed in r314456

Modified:
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=314460&r1=314459&r2=314460&view=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Thu Sep 
28 13:23:43 2017
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 65 attributes:
+// CHECK: #pragma clang attribute supports 66 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)


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


Re: Fix for the issue 12176

2017-09-28 Thread Jonathan Roelofs via cfe-commits

+silvas


On 9/28/17 2:19 PM, Oscar Forner Martinez via cfe-commits wrote:

Hi,

Please find attached a diff to fix the issue 12176.


Link for the lazy: llvm.org/PR12176

Let me know if there 
is anything any improvements you can think of.


Best regards,

Oscar


Extract-getDepthAndIndex-issue-12176.patch


Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h(nonexistent)
+++ lib/Sema/DepthAndIndex.h(working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex function 
-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair


This should be just a declaration and a doxygen comment for it. Drop the 
'static'. You can also drop the "\brief" since autobrief is turned on.


Then the body should go in a *.cpp somewhere in lib/Sema.


+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
+return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp  (revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp  (working copy)
@@ -11,6 +11,7 @@
  
//===--===/
  
  #include "clang/Sema/TemplateDeduction.h"

+#include "DepthAndIndex.h"
  #include "TreeTransform.h"
  #include "clang/AST/ASTContext.h"
  #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
}
  }
  
-/// \brief Retrieve the depth and index of a template parameter.

-static std::pair
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
  /// \brief Retrieve the depth and index of an unexpanded parameter pack.
  static std::pair
  getDepthAndIndex(UnexpandedParameterPack UPP) {


Maybe this ^ one should go too?


Index: lib/Sema/SemaTemplateInstantiate.cpp


snip


Jon




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



--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded / Siemens
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38380: [libunwind] Add CMake support for building for MinGW

2017-09-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added a subscriber: mgorny.

This is the cmake specific parts of https://reviews.llvm.org/D33601 (by Martell 
Malone) split out into a separate patch, to ease getting this part reviewed 
indendent of the rest of that patch.


https://reviews.llvm.org/D38380

Files:
  cmake/config-ix.cmake


Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,6 +29,19 @@
   elseif (LIBUNWIND_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+if (LIBUNWIND_USE_COMPILER_RT)
+  set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY})
+else ()
+  set(MINGW_RUNTIME gcc_s gcc)
+endif()
+set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt 
advapi32
+shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
+moldname mingwex msvcrt)
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()


Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,6 +29,19 @@
   elseif (LIBUNWIND_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+if (LIBUNWIND_USE_COMPILER_RT)
+  set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY})
+else ()
+  set(MINGW_RUNTIME gcc_s gcc)
+endif()
+set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32
+shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
+moldname mingwex msvcrt)
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38381: [libunwind] Skip building x86 parts of UnwindRegisters*.S when targeting SjLj

2017-09-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, aemerson.

This extends SVN r314197 (https://reviews.llvm.org/D38249) from the arm parts 
to the whole file (the x86 parts as well).


https://reviews.llvm.org/D38381

Files:
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S


Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -11,6 +11,8 @@
 
 .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 
 #
@@ -289,7 +291,7 @@
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -471,5 +473,7 @@
   l.sw 124(r3), r31
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -11,6 +11,8 @@
 
   .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
 #
@@ -308,7 +310,7 @@
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -491,5 +493,7 @@
 
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 


Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -11,6 +11,8 @@
 
 .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 
 #
@@ -289,7 +291,7 @@
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !(defined(__APPLE__) || defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -471,5 +473,7 @@
   l.sw 124(r3), r31
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -11,6 +11,8 @@
 
   .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
 #
@@ -308,7 +310,7 @@
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !(defined(__APPLE__) || defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -491,5 +493,7 @@
 
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314461 - [Sema] Warn on attribute nothrow conflicting with language specifiers

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:36:53 2017
New Revision: 314461

URL: http://llvm.org/viewvc/llvm-project?rev=314461&view=rev
Log:
[Sema] Warn on attribute nothrow conflicting with language specifiers

I discovered it was possible to create a 'nothrow' noexcept(false)
function, which is both non-sensical as well as seemingly breaking.

This patch warns if attribute nothrow is used with anything besides "noexcept".

"noexcept(true)" isn't possible, because the noexcept decl isn't parsed until
later.

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

Added:
cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp   
(with props)
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314461&r1=314460&r2=314461&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 28 13:36:53 
2017
@@ -1407,6 +1407,10 @@ def err_noexcept_needs_constant_expressi
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<
   "exception specification is not available until end of class definition">;
+def warn_nothrow_attr_disagrees_with_exception_specification
+: ExtWarn<"attribute 'nothrow' ignored due to conflicting exception "
+  "specification">,
+  InGroup;
 
 // C++ access checking
 def err_class_redeclared_with_different_access : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314461&r1=314460&r2=314461&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Sep 28 13:36:53 2017
@@ -1985,6 +1985,25 @@ static void handleNoReturnAttr(Sema &S,
   Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
+static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
+  assert(isa(D) && "attribute nothrow only valid on functions");
+
+  auto *FD = cast(D);
+  const auto *FPT = FD->getType()->getAs();
+
+  if (FPT && FPT->hasExceptionSpec() &&
+  FPT->getExceptionSpecType() != EST_BasicNoexcept) {
+S.Diag(Attrs.getLoc(),
+   diag::warn_nothrow_attr_disagrees_with_exception_specification);
+S.Diag(FD->getExceptionSpecSourceRange().getBegin(),
+   diag::note_previous_decl)
+<< "exception specification";
+  }
+
+  D->addAttr(::new (S.Context) NoThrowAttr(
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
+}
+
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
   if (S.CheckNoCallerSavedRegsAttr(Attr))
@@ -6211,7 +6230,7 @@ static void ProcessDeclAttribute(Sema &S
 handleNoReturnAttr(S, D, Attr);
 break;
   case AttributeList::AT_NoThrow:
-handleSimpleAttribute(S, D, Attr);
+handleNoThrowAttr(S, D, Attr);
 break;
   case AttributeList::AT_CUDAShared:
 handleSharedAttr(S, D, Attr);

Added: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp?rev=314461&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp 
(added)
+++ cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp Thu 
Sep 28 13:36:53 2017
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+struct S {
+  //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) S() noexcept(true);
+  //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) void Func1() noexcept(false);
+  __attribute__((nothrow)) void Func3() noexcept;
+};
+
+void throwing() noexcept(false);
+void non_throwing(bool b = true) noexcept;
+
+template 
+struct T {
+__attribute__((nothrow)) void f(Fn) noexcept(Fn());
+};
+
+//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+//expected-note@-4 {{exception specification declared here}}
+template struct T;
+template struct T;

Propchange: 
cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
--

[PATCH] D38205: [Sema] Warn on attribute nothrow conflicting with language specifiers

2017-09-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314461: [Sema] Warn on attribute nothrow conflicting with 
language specifiers (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38205?vs=116892&id=117050#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38205

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1985,6 +1985,25 @@
   Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
+static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
+  assert(isa(D) && "attribute nothrow only valid on functions");
+
+  auto *FD = cast(D);
+  const auto *FPT = FD->getType()->getAs();
+
+  if (FPT && FPT->hasExceptionSpec() &&
+  FPT->getExceptionSpecType() != EST_BasicNoexcept) {
+S.Diag(Attrs.getLoc(),
+   diag::warn_nothrow_attr_disagrees_with_exception_specification);
+S.Diag(FD->getExceptionSpecSourceRange().getBegin(),
+   diag::note_previous_decl)
+<< "exception specification";
+  }
+
+  D->addAttr(::new (S.Context) NoThrowAttr(
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
+}
+
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
   if (S.CheckNoCallerSavedRegsAttr(Attr))
@@ -6211,7 +6230,7 @@
 handleNoReturnAttr(S, D, Attr);
 break;
   case AttributeList::AT_NoThrow:
-handleSimpleAttribute(S, D, Attr);
+handleNoThrowAttr(S, D, Attr);
 break;
   case AttributeList::AT_CUDAShared:
 handleSharedAttr(S, D, Attr);
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1407,6 +1407,10 @@
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<
   "exception specification is not available until end of class definition">;
+def warn_nothrow_attr_disagrees_with_exception_specification
+: ExtWarn<"attribute 'nothrow' ignored due to conflicting exception "
+  "specification">,
+  InGroup;
 
 // C++ access checking
 def err_class_redeclared_with_different_access : Error<
Index: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
===
--- cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
+++ cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+struct S {
+  //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) S() noexcept(true);
+  //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) void Func1() noexcept(false);
+  __attribute__((nothrow)) void Func3() noexcept;
+};
+
+void throwing() noexcept(false);
+void non_throwing(bool b = true) noexcept;
+
+template 
+struct T {
+__attribute__((nothrow)) void f(Fn) noexcept(Fn());
+};
+
+//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting 
exception specification}}
+//expected-note@-4 {{exception specification declared here}}
+template struct T;
+template struct T;


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1985,6 +1985,25 @@
   Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
+static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
+  assert(isa(D) && "attribute nothrow only valid on functions");
+
+  auto *FD = cast(D);
+  const auto *FPT = FD->getType()->getAs();
+
+  if (FPT && FPT->hasExceptionSpec() &&
+  FPT->getExceptionSpecType() != EST_BasicNoexcept) {
+S.Diag(Attrs.getLoc(),
+   diag::warn_nothrow_attr_disagrees_with_exception_specification);
+S.Diag(FD->getExceptionSpecSourceRange().getBegin(),
+   diag::note_previous_decl)
+<< "exception specification";
+  }
+
+  D->addAttr(::new (S.Context) NoThrowAttr(
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
+}
+
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
 

Re: Fix for the issue 12176

2017-09-28 Thread Oscar Forner Martinez via cfe-commits

Hi Jonathan,

Thanks for the input. I will amend it and update it. I created an entry 
in Phabricator too (https://reviews.llvm.org/D38382).


Best regards,
Oscar


On 28/09/17 21:28, Jonathan Roelofs wrote:

+silvas


On 9/28/17 2:19 PM, Oscar Forner Martinez via cfe-commits wrote:

Hi,

Please find attached a diff to fix the issue 12176.


Link for the lazy: llvm.org/PR12176


Let me know if there is anything any improvements you can think of.

Best regards,

Oscar


Extract-getDepthAndIndex-issue-12176.patch


Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h    (nonexistent)
+++ lib/Sema/DepthAndIndex.h    (working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex 
function -*- C++ -*-===//

+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open 
Source

+// License. See LICENSE.TXT for details.
+//===--===// 


+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===// 


+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair


This should be just a declaration and a doxygen comment for it. Drop 
the 'static'. You can also drop the "\brief" since autobrief is turned 
on.


Then the body should go in a *.cpp somewhere in lib/Sema.


+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+    return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

+    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp    (revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp    (working copy)
@@ -11,6 +11,7 @@
//===--===/
    #include "clang/Sema/TemplateDeduction.h"
+#include "DepthAndIndex.h"
  #include "TreeTransform.h"
  #include "clang/AST/ASTContext.h"
  #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
    }
  }
  -/// \brief Retrieve the depth and index of a template parameter.
-static std::pair
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-    return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

-    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
  /// \brief Retrieve the depth and index of an unexpanded parameter 
pack.

  static std::pair
  getDepthAndIndex(UnexpandedParameterPack UPP) {


Maybe this ^ one should go too?


Index: lib/Sema/SemaTemplateInstantiate.cpp


snip


Jon




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





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


r314462 - [Sema] Correct nothrow inherited by noexcept

2017-09-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 28 13:47:10 2017
New Revision: 314462

URL: http://llvm.org/viewvc/llvm-project?rev=314462&view=rev
Log:
[Sema] Correct nothrow inherited by noexcept

As reported in https://bugs.llvm.org/show_bug.cgi?id=33235,
a noexcept function was unable to inherit from a nothrow defaulted
constructor. Attribute "nothrow" is supposed to be semantically
identical to noexcept, and in fact, a number of other places in the
code treat them identically.

This patch simply checks the RecordDecl for the correct attribute in
the case where no other exception specifier was set.

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

Added:
cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp   (with props)
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=314462&r1=314461&r2=314462&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 28 13:47:10 2017
@@ -167,6 +167,9 @@ Sema::ImplicitExceptionSpecification::Ca
   if (ComputedEST == EST_None)
 return;
 
+  if (EST == EST_None && Method->hasAttr())
+EST = EST_BasicNoexcept;
+
   switch(EST) {
   // If this function can throw any exceptions, make a note of that.
   case EST_MSAny:

Added: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp?rev=314462&view=auto
==
--- cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp (added)
+++ cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp Thu Sep 28 13:47:10 2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+// expected-no-diagnostics
+struct Base {
+  __attribute__((nothrow)) Base() {}
+};
+
+struct Derived : Base {
+  Derived() noexcept = default;
+};
+
+struct Base2 {
+   Base2() noexcept {}
+};
+
+struct Derived2 : Base2 {
+  __attribute__((nothrow)) Derived2() = default;
+};
+
+struct Base3 {
+  __attribute__((nothrow)) Base3() {}
+};
+
+struct Derived3 : Base3 {
+  __attribute__((nothrow)) Derived3() = default;
+};

Propchange: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
--
svn:mime-type = text/plain


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


[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314462: [Sema] Correct nothrow inherited by noexcept 
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38209?vs=116840&id=117053#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38209

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -167,6 +167,9 @@
   if (ComputedEST == EST_None)
 return;
 
+  if (EST == EST_None && Method->hasAttr())
+EST = EST_BasicNoexcept;
+
   switch(EST) {
   // If this function can throw any exceptions, make a note of that.
   case EST_MSAny:
Index: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
===
--- cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
+++ cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+// expected-no-diagnostics
+struct Base {
+  __attribute__((nothrow)) Base() {}
+};
+
+struct Derived : Base {
+  Derived() noexcept = default;
+};
+
+struct Base2 {
+   Base2() noexcept {}
+};
+
+struct Derived2 : Base2 {
+  __attribute__((nothrow)) Derived2() = default;
+};
+
+struct Base3 {
+  __attribute__((nothrow)) Base3() {}
+};
+
+struct Derived3 : Base3 {
+  __attribute__((nothrow)) Derived3() = default;
+};


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -167,6 +167,9 @@
   if (ComputedEST == EST_None)
 return;
 
+  if (EST == EST_None && Method->hasAttr())
+EST = EST_BasicNoexcept;
+
   switch(EST) {
   // If this function can throw any exceptions, make a note of that.
   case EST_MSAny:
Index: cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
===
--- cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
+++ cfe/trunk/test/SemaCXX/nothrow-as-noexcept-ctor.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14
+
+// expected-no-diagnostics
+struct Base {
+  __attribute__((nothrow)) Base() {}
+};
+
+struct Derived : Base {
+  Derived() noexcept = default;
+};
+
+struct Base2 {
+   Base2() noexcept {}
+};
+
+struct Derived2 : Base2 {
+  __attribute__((nothrow)) Derived2() = default;
+};
+
+struct Base3 {
+  __attribute__((nothrow)) Base3() {}
+};
+
+struct Derived3 : Base3 {
+  __attribute__((nothrow)) Derived3() = default;
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 117051.
Rakete added a comment.

- Moved test to test/CXX/

Do I actually need to -verify the test if no diagnostics are expected?

Thanks @aaron.ballman


https://reviews.llvm.org/D38342

Files:
  lib/Parse/ParseExpr.cpp
  test/Parser/cxx-bool.cpp


Index: test/Parser/cxx-bool.cpp
===
--- test/Parser/cxx-bool.cpp
+++ test/Parser/cxx-bool.cpp
@@ -2,3 +2,9 @@
 
 bool a = true;
 bool b = false;
+
+namespace pr34273 {
+  char c = "clang"[true];
+  char d = true["clang"];
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:


Index: test/Parser/cxx-bool.cpp
===
--- test/Parser/cxx-bool.cpp
+++ test/Parser/cxx-bool.cpp
@@ -2,3 +2,9 @@
 
 bool a = true;
 bool b = false;
+
+namespace pr34273 {
+  char c = "clang"[true];
+  char d = true["clang"];
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D38342#883872, @Rakete wrote:

> - Moved test to test/CXX/
>
>   Do I actually need to -verify the test if no diagnostics are expected?
>
>   Thanks @aaron.ballman


Yes, you need to make sure that verify is on the RUN line. The existing test is 
broken like that (good catch). You should add -verify to the run line and // 
expected-no-diagnostics below it.


https://reviews.llvm.org/D38342



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


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 117054.
Rakete added a comment.

- Fixed test case for bools

Ah got it! Thanks!!


https://reviews.llvm.org/D38342

Files:
  lib/Parse/ParseExpr.cpp
  test/Parser/cxx-bool.cpp


Index: test/Parser/cxx-bool.cpp
===
--- test/Parser/cxx-bool.cpp
+++ test/Parser/cxx-bool.cpp
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
 
 bool a = true;
 bool b = false;
+
+namespace pr34273 {
+  char c = "clang"[true];
+  char d = true["clang"];
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:


Index: test/Parser/cxx-bool.cpp
===
--- test/Parser/cxx-bool.cpp
+++ test/Parser/cxx-bool.cpp
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
 
 bool a = true;
 bool b = false;
+
+namespace pr34273 {
+  char c = "clang"[true];
+  char d = true["clang"];
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 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! Do you need me to commit on your behalf?


https://reviews.llvm.org/D38342



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


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

Yes please :) Thanks @aaron.ballman


https://reviews.llvm.org/D38342



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


r314463 - Properly parse a postfix expression following a Boolean literal. Fixes PR34273.

2017-09-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Sep 28 14:29:18 2017
New Revision: 314463

URL: http://llvm.org/viewvc/llvm-project?rev=314463&view=rev
Log:
Properly parse a postfix expression following a Boolean literal. Fixes PR34273.

Patch by Nicolas Lesser.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/Parser/cxx-bool.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=314463&r1=314462&r2=314463&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Sep 28 14:29:18 2017
@@ -798,7 +798,8 @@ ExprResult Parser::ParseCastExpression(b
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:

Modified: cfe/trunk/test/Parser/cxx-bool.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-bool.cpp?rev=314463&r1=314462&r2=314463&view=diff
==
--- cfe/trunk/test/Parser/cxx-bool.cpp (original)
+++ cfe/trunk/test/Parser/cxx-bool.cpp Thu Sep 28 14:29:18 2017
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
 
 bool a = true;
 bool b = false;
+
+namespace pr34273 {
+  char c = "clang"[true];
+  char d = true["clang"];
+}
+


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


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed in r314463.

Btw, if you're not in the IRC channel (#llvm on OFTC), you should hang out in 
there to make sure no build bots break due to the commit.


https://reviews.llvm.org/D38342



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


Re: [PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-28 Thread Nicolas Lesser via cfe-commits
Yeah, I hang out there :) Will do for sure
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 117061.
alexshap added a comment.

Add positive tests


Repository:
  rL LLVM

https://reviews.llvm.org/D38270

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Analysis/ScanfFormatString.cpp
  test/FixIt/format.m
  test/Sema/format-strings-scanf.c

Index: test/Sema/format-strings-scanf.c
===
--- test/Sema/format-strings-scanf.c
+++ test/Sema/format-strings-scanf.c
@@ -13,6 +13,16 @@
   unsigned short : (short)0,   \
   unsigned char : (signed char)0))
 typedef __SSIZE_TYPE__ ssize_t; 
+
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define __UNSIGNED_PTRDIFF_TYPE__  \
+  __typeof__(_Generic((__PTRDIFF_TYPE__)0, \
+  long long int : (unsigned long long int)0,   \
+  long int : (unsigned long int)0, \
+  int : (unsigned int)0,   \
+  short : (unsigned short)0,   \
+  signed char : (unsigned char)0))
+
 typedef struct _FILE FILE;
 typedef __WCHAR_TYPE__ wchar_t;
 
@@ -200,6 +210,26 @@
   scanf("%zn", &d3); // expected-warning-re{{format specifies type 'ssize_t *' (aka '{{.+}}') but the argument has type 'double *'}}
 }
 
+void test_ptrdiff_t_types() {
+  __UNSIGNED_PTRDIFF_TYPE__ p1 = 0;
+  scanf("%tu", &p1); // No warning.
+
+  double d1 = 0.;
+  scanf("%tu", &d1); // expected-warning-re{{format specifies type 'unsigned ptrdiff_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+
+  ptrdiff_t p2 = 0;
+  scanf("%td", &p2); // No warning.
+  
+  double d2 = 0.;
+  scanf("%td", &d2); // expected-warning-re{{format specifies type 'ptrdiff_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+
+  ptrdiff_t p3 = 0;
+  scanf("%tn", &p3); // No warning.
+  
+  double d3 = 0.;
+  scanf("%tn", &d3); // expected-warning-re{{format specifies type 'ptrdiff_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+}
+
 void check_conditional_literal(char *s, int *i) {
   scanf(0 ? "%s" : "%d", i); // no warning
   scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char *'}}
Index: test/FixIt/format.m
===
--- test/FixIt/format.m
+++ test/FixIt/format.m
@@ -242,6 +242,37 @@
   // see the comment in PrintfSpecifier::fixType in PrintfFormatString.cpp.
 }
 
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define __UNSIGNED_PTRDIFF_TYPE__  \
+  __typeof__(_Generic((__PTRDIFF_TYPE__)0, \
+  long long int : (unsigned long long int)0,   \
+  long int : (unsigned long int)0, \
+  int : (unsigned int)0,   \
+  short : (unsigned short)0,   \
+  signed char : (unsigned char)0))
+
+void testPtrDiffTypes() {
+  __UNSIGNED_PTRDIFF_TYPE__ p1 = 0;
+  printf("%tu", p1);  // No warning.
+
+  printf("%tu", 0.f); // expected-warning-re{{format specifies type 'unsigned ptrdiff_t' (aka '{{.+}}') but the argument has type 'float'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:14}:"%f"
+  
+  ptrdiff_t p2 = 0;
+  printf("%td", p2);  // No warning.
+
+  printf("%td", 0.f); // expected-warning-re{{format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type 'float'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:14}:"%f"
+
+  ptrdiff_t p3 = 0;
+  printf("%tn", &p3); // No warning.
+
+  short x;
+  printf("%tn", &x); // expected-warning-re{{format specifies type 'ptrdiff_t *' (aka '{{.+}}') but the argument has type 'short *'}}
+  // PrintfSpecifier::fixType doesn't handle %n, so a fix-it is not emitted,
+  // see the comment in PrintfSpecifier::fixType in PrintfFormatString.cpp.
+}
+
 void testEnum() {
   typedef enum {
 ImplicitA = 1,
Index: lib/Analysis/ScanfFormatString.cpp
===
--- lib/Analysis/ScanfFormatString.cpp
+++ lib/Analysis/ScanfFormatString.cpp
@@ -291,8 +291,8 @@
 case LengthModifier::AsSizeT:
   return ArgType::PtrTo(ArgType(Ctx.getSizeType(), "size_t"));
 case LengthModifier::AsPtrDiff:
-  // FIXME: Unsigned version of ptrdiff_t?
-  return ArgType();
+  return ArgType::PtrTo(
+  ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t"));
 case LengthModifier::AsLongDouble:
   // GNU extension.
   return ArgType::PtrTo(Ctx.UnsignedLongL

Re: r314373 - [NFC] Don't use C++17 standard lib variable template helper traits, instead use ::value.

2017-09-28 Thread James Y Knight via cfe-commits
It was fixed in r314391, to use is_trivial instead of is_trivially_copyable.


On Thu, Sep 28, 2017 at 3:57 PM, Faisal Vali  wrote:

> Isn't this a C++11 feature though?
>
> I'm not sure what to make of the fact that I haven't gotten any
> complaints from the bots in over 12 hrs i think?
>
> Should I just turn it into a comment?
>
> Thanks!
>
> Faisal Vali
>
>
>
> On Wed, Sep 27, 2017 at 9:54 PM, James Y Knight 
> wrote:
> > This still doesn't work on some compilers, because
> > std::is_trivially_copyable isn't available:
> > http://lab.llvm.org:8011/builders/aosp-O3-polly-before-
> vectorizer-unprofitable/builds/265/steps/build/logs/stdio
> >
> > On Wed, Sep 27, 2017 at 10:00 PM, Faisal Vali via cfe-commits
> >  wrote:
> >>
> >> Author: faisalv
> >> Date: Wed Sep 27 19:00:40 2017
> >> New Revision: 314373
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=314373&view=rev
> >> Log:
> >> [NFC] Don't use C++17 standard lib variable template helper traits,
> >> instead use ::value.
> >>
> >> Modified:
> >> cfe/trunk/lib/Lex/MacroArgs.cpp
> >>
> >> Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> MacroArgs.cpp?rev=314373&r1=314372&r2=314373&view=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
> >> +++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Sep 27 19:00:40 2017
> >> @@ -62,7 +62,7 @@ MacroArgs *MacroArgs::create(const Macro
> >>
> >>// Copy the actual unexpanded tokens to immediately after the result
> >> ptr.
> >>if (!UnexpArgTokens.empty()) {
> >> -static_assert(std::is_trivially_copyable_v,
> >> +static_assert(std::is_trivially_copyable::value,
> >>"assume trivial copyability if copying into the "
> >>"uninitialized array (as opposed to reusing a cached
> "
> >>"MacroArgs)");
> >> @@ -96,7 +96,7 @@ MacroArgs *MacroArgs::deallocate() {
> >>// Run the dtor to deallocate the vectors.
> >>this->~MacroArgs();
> >>// Release the memory for the object.
> >> -  static_assert(std::is_trivially_destructible_v,
> >> +  static_assert(std::is_trivially_destructible::value,
> >>  "assume trivially destructible and forego
> destructors");
> >>free(this);
> >>
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-28 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!


Repository:
  rL LLVM

https://reviews.llvm.org/D38270



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


r314470 - [clang] Add getUnsignedPointerDiffType method

2017-09-28 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Thu Sep 28 16:11:31 2017
New Revision: 314470

URL: http://llvm.org/viewvc/llvm-project?rev=314470&view=rev
Log:
[clang] Add getUnsignedPointerDiffType method

C11 standard refers to the unsigned counterpart of the type ptrdiff_t 
in the paragraph 7.21.6.1p7 where it defines the format specifier %tu.
In Clang (in PrintfFormatString.cpp, lines 508-510) there is a FIXME for this 
case,
in particular, Clang didn't diagnose %tu issues at all, i.e.
it didn't emit any warnings on the code printf("%tu", 3.14).
In this diff we add a method getUnsignedPointerDiffType for getting the 
corresponding type
similarly to how it's already done in the other analogous cases (size_t, 
ssize_t, ptrdiff_t etc)
and fix -Wformat diagnostics for %tu plus the emitted fix-it as well.

Test plan: make check-all

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Analysis/ScanfFormatString.cpp
cfe/trunk/test/FixIt/format.m
cfe/trunk/test/Sema/format-strings-scanf.c

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=314470&r1=314469&r2=314470&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Sep 28 16:11:31 2017
@@ -1489,6 +1489,11 @@ public:
   /// . Pointer - pointer requires this (C99 6.5.6p9).
   QualType getPointerDiffType() const;
 
+  /// \brief Return the unique unsigned counterpart of "ptrdiff_t"
+  /// integer type. The standard (C11 7.21.6.1p7) refers to this type
+  /// in the definition of %tu format specifier.
+  QualType getUnsignedPointerDiffType() const;
+
   /// \brief Return the unique type for "pid_t" defined in
   /// . We need this to compute the correct type for vfork().
   QualType getProcessIDType() const;

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=314470&r1=314469&r2=314470&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Sep 28 16:11:31 2017
@@ -248,6 +248,9 @@ public:
   IntType getPtrDiffType(unsigned AddrSpace) const {
 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
   }
+  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
+  }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getUIntPtrType() const {
 return getCorrespondingUnsignedType(IntPtrType);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=314470&r1=314469&r2=314470&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Sep 28 16:11:31 2017
@@ -4571,6 +4571,13 @@ QualType ASTContext::getPointerDiffType(
   return getFromTargetType(Target->getPtrDiffType(0));
 }
 
+/// \brief Return the unique unsigned counterpart of "ptrdiff_t"
+/// integer type. The standard (C11 7.21.6.1p7) refers to this type
+/// in the definition of %tu format specifier.
+QualType ASTContext::getUnsignedPointerDiffType() const {
+  return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+}
+
 /// \brief Return the unique type for "pid_t" defined in
 /// . We need this to compute the correct type for vfork().
 QualType ASTContext::getProcessIDType() const {

Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=314470&r1=314469&r2=314470&view=diff
==
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Thu Sep 28 16:11:31 2017
@@ -505,9 +505,7 @@ ArgType PrintfSpecifier::getArgType(ASTC
? ArgType(Ctx.UnsignedLongLongTy, "unsigned __int64")
: ArgType(Ctx.UnsignedIntTy, "unsigned __int32");
   case LengthModifier::AsPtrDiff:
-// FIXME: How to get the corresponding unsigned
-// version of ptrdiff_t?
-return ArgType();
+return ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t");
   case LengthModifier::AsAllocate:
   case LengthModifier::AsMAllocate:
   case LengthModifier::AsWide:

Modified: cfe/trunk/lib/Analysis/ScanfFormatString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ScanfFormatString.cpp?rev=3144

[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314470: [clang] Add getUnsignedPointerDiffType method 
(authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D38270?vs=117061&id=117075#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38270

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Analysis/PrintfFormatString.cpp
  cfe/trunk/lib/Analysis/ScanfFormatString.cpp
  cfe/trunk/test/FixIt/format.m
  cfe/trunk/test/Sema/format-strings-scanf.c

Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -4571,6 +4571,13 @@
   return getFromTargetType(Target->getPtrDiffType(0));
 }
 
+/// \brief Return the unique unsigned counterpart of "ptrdiff_t"
+/// integer type. The standard (C11 7.21.6.1p7) refers to this type
+/// in the definition of %tu format specifier.
+QualType ASTContext::getUnsignedPointerDiffType() const {
+  return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+}
+
 /// \brief Return the unique type for "pid_t" defined in
 /// . We need this to compute the correct type for vfork().
 QualType ASTContext::getProcessIDType() const {
Index: cfe/trunk/lib/Analysis/ScanfFormatString.cpp
===
--- cfe/trunk/lib/Analysis/ScanfFormatString.cpp
+++ cfe/trunk/lib/Analysis/ScanfFormatString.cpp
@@ -291,8 +291,8 @@
 case LengthModifier::AsSizeT:
   return ArgType::PtrTo(ArgType(Ctx.getSizeType(), "size_t"));
 case LengthModifier::AsPtrDiff:
-  // FIXME: Unsigned version of ptrdiff_t?
-  return ArgType();
+  return ArgType::PtrTo(
+  ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t"));
 case LengthModifier::AsLongDouble:
   // GNU extension.
   return ArgType::PtrTo(Ctx.UnsignedLongLongTy);
Index: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
===
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp
@@ -505,9 +505,7 @@
? ArgType(Ctx.UnsignedLongLongTy, "unsigned __int64")
: ArgType(Ctx.UnsignedIntTy, "unsigned __int32");
   case LengthModifier::AsPtrDiff:
-// FIXME: How to get the corresponding unsigned
-// version of ptrdiff_t?
-return ArgType();
+return ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t");
   case LengthModifier::AsAllocate:
   case LengthModifier::AsMAllocate:
   case LengthModifier::AsWide:
Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -1489,6 +1489,11 @@
   /// . Pointer - pointer requires this (C99 6.5.6p9).
   QualType getPointerDiffType() const;
 
+  /// \brief Return the unique unsigned counterpart of "ptrdiff_t"
+  /// integer type. The standard (C11 7.21.6.1p7) refers to this type
+  /// in the definition of %tu format specifier.
+  QualType getUnsignedPointerDiffType() const;
+
   /// \brief Return the unique type for "pid_t" defined in
   /// . We need this to compute the correct type for vfork().
   QualType getProcessIDType() const;
Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -248,6 +248,9 @@
   IntType getPtrDiffType(unsigned AddrSpace) const {
 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
   }
+  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
+  }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getUIntPtrType() const {
 return getCorrespondingUnsignedType(IntPtrType);
Index: cfe/trunk/test/FixIt/format.m
===
--- cfe/trunk/test/FixIt/format.m
+++ cfe/trunk/test/FixIt/format.m
@@ -242,6 +242,37 @@
   // see the comment in PrintfSpecifier::fixType in PrintfFormatString.cpp.
 }
 
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define __UNSIGNED_PTRDIFF_TYPE__  \
+  __typeof__(_Generic((__PTRDIFF_TYPE__)0, \
+  long long int : (unsigned long long int)0,   \
+  long int : (unsigned long int)0, \
+  int : (unsigned int)0,   \
+  short : (unsigned short)0,   \
+

r314473 - [Sema] Put nullability fix-it after the end of the pointer.

2017-09-28 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Sep 28 16:18:49 2017
New Revision: 314473

URL: http://llvm.org/viewvc/llvm-project?rev=314473&view=rev
Log:
[Sema] Put nullability fix-it after the end of the pointer.

Fixes nullability fix-it for `id`. With this change
nullability specifier is inserted after ">" instead of between
"id" and "<".

rdar://problem/34260995

Reviewers: jordan_rose, doug.gregor, ahatanak, arphaman

Reviewed By: jordan_rose

Subscribers: cfe-commits

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


Added:
cfe/trunk/test/FixIt/Inputs/nullability-objc.h
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/FixIt/nullability.mm
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=314473&r1=314472&r2=314473&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 28 16:18:49 2017
@@ -229,6 +229,10 @@ struct FileNullability {
   /// not have a corresponding nullability annotation.
   SourceLocation PointerLoc;
 
+  /// The end location for the first pointer declarator in the file. Used for
+  /// placing fix-its.
+  SourceLocation PointerEndLoc;
+
   /// Which kind of pointer declarator we saw.
   uint8_t PointerKind;
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=314473&r1=314472&r2=314473&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Sep 28 16:18:49 2017
@@ -3500,7 +3500,8 @@ static void fixItNullability(Sema &S, Di
 
 static void emitNullabilityConsistencyWarning(Sema &S,
   SimplePointerKind PointerKind,
-  SourceLocation PointerLoc) {
+  SourceLocation PointerLoc,
+  SourceLocation PointerEndLoc) {
   assert(PointerLoc.isValid());
 
   if (PointerKind == SimplePointerKind::Array) {
@@ -3510,14 +3511,15 @@ static void emitNullabilityConsistencyWa
   << static_cast(PointerKind);
   }
 
-  if (PointerLoc.isMacroID())
+  auto FixItLoc = PointerEndLoc.isValid() ? PointerEndLoc : PointerLoc;
+  if (FixItLoc.isMacroID())
 return;
 
   auto addFixIt = [&](NullabilityKind Nullability) {
-auto Diag = S.Diag(PointerLoc, diag::note_nullability_fix_it);
+auto Diag = S.Diag(FixItLoc, diag::note_nullability_fix_it);
 Diag << static_cast(Nullability);
 Diag << static_cast(PointerKind);
-fixItNullability(S, Diag, PointerLoc, Nullability);
+fixItNullability(S, Diag, FixItLoc, Nullability);
   };
   addFixIt(NullabilityKind::Nullable);
   addFixIt(NullabilityKind::NonNull);
@@ -3529,9 +3531,10 @@ static void emitNullabilityConsistencyWa
 ///
 /// If the file has \e not seen other uses of nullability, this particular
 /// pointer is saved for possible later diagnosis. See recordNullabilitySeen().
-static void checkNullabilityConsistency(Sema &S,
-SimplePointerKind pointerKind,
-SourceLocation pointerLoc) {
+static void
+checkNullabilityConsistency(Sema &S, SimplePointerKind pointerKind,
+SourceLocation pointerLoc,
+SourceLocation pointerEndLoc = SourceLocation()) {
   // Determine which file we're performing consistency checking for.
   FileID file = getNullabilityCompletenessCheckFileID(S, pointerLoc);
   if (file.isInvalid())
@@ -3552,6 +3555,7 @@ static void checkNullabilityConsistency(
 if (fileNullability.PointerLoc.isInvalid() &&
 !S.Context.getDiagnostics().isIgnored(diagKind, pointerLoc)) {
   fileNullability.PointerLoc = pointerLoc;
+  fileNullability.PointerEndLoc = pointerEndLoc;
   fileNullability.PointerKind = static_cast(pointerKind);
 }
 
@@ -3559,7 +3563,7 @@ static void checkNullabilityConsistency(
   }
 
   // Complain about missing nullability.
-  emitNullabilityConsistencyWarning(S, pointerKind, pointerLoc);
+  emitNullabilityConsistencyWarning(S, pointerKind, pointerLoc, pointerEndLoc);
 }
 
 /// Marks that a nullability feature has been used in the file containing
@@ -3585,7 +3589,8 @@ static void recordNullabilitySeen(Sema &
 return;
 
   auto kind = static_cast(fileNullability.PointerKind);
-  emitNullabilityConsistencyWarning(S, kind, fileNullability.PointerLoc);
+  emitNullabilityConsistencyWarning(S, kind, fileNullability.PointerLoc,
+fileNullability.PointerEndLoc);
 }
 
 /// Returns true if any of the declarator chunks before \p endIndex include a
@@ -3895,6 

[PATCH] D38327: [Sema] Put nullability fix-it after the end of the pointer.

2017-09-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314473: [Sema] Put nullability fix-it after the end of the 
pointer. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D38327?vs=116861&id=117076#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38327

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/FixIt/Inputs/nullability-objc.h
  cfe/trunk/test/FixIt/nullability.mm
  cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -229,6 +229,10 @@
   /// not have a corresponding nullability annotation.
   SourceLocation PointerLoc;
 
+  /// The end location for the first pointer declarator in the file. Used for
+  /// placing fix-its.
+  SourceLocation PointerEndLoc;
+
   /// Which kind of pointer declarator we saw.
   uint8_t PointerKind;
 
Index: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h
===
--- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h
+++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h
@@ -6,9 +6,9 @@
 
 void g3(const
 id // expected-warning{{missing a nullability type specifier}}
+volatile
 // expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
 // expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
-volatile
 * // expected-warning{{missing a nullability type specifier}}
 // expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
 // expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
Index: cfe/trunk/test/FixIt/nullability.mm
===
--- cfe/trunk/test/FixIt/nullability.mm
+++ cfe/trunk/test/FixIt/nullability.mm
@@ -2,8 +2,10 @@
 // RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fblocks -std=gnu++11 -I %S/Inputs %s >%t.txt 2>&1
 // RUN: FileCheck %s < %t.txt
 // RUN: FileCheck %S/Inputs/nullability.h < %t.txt
+// RUN: FileCheck %S/Inputs/nullability-objc.h < %t.txt
 
 #include "nullability.h"
+#include "nullability-objc.h"
 
 #pragma clang assume_nonnull begin
 
Index: cfe/trunk/test/FixIt/Inputs/nullability-objc.h
===
--- cfe/trunk/test/FixIt/Inputs/nullability-objc.h
+++ cfe/trunk/test/FixIt/Inputs/nullability-objc.h
@@ -0,0 +1,48 @@
+@class Item;
+@class Container;
+@protocol Protocol;
+
+// rdar://problem/34260995
+// The first pointer in the file is handled in a different way so need
+// a separate test for this case even if the parameter type is the same as in
+// objcIdParameterWithProtocol.
+void objcIdParameterWithProtocolFirstInFile(id i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:57-[[@LINE-3]]:57}:" _Nullable"
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:57-[[@LINE-4]]:57}:" _Nonnull"
+
+int * _Nonnull forceNullabilityWarningsObjC(void);
+
+void objcClassParameter(Item *i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:31-[[@LINE-3]]:31}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:31-[[@LINE-4]]:31}:" _Nonnull "
+
+void objcClassParameterWithProtocol(Item *i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:53-[[@LINE-3]]:53}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:53-[[@LINE-4]]:53}:" _Nonnull "
+
+// rdar://problem/34260995
+void objcIdParameterWithProtocol(id i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:46-[[@LINE-3]]:46}:" _Nullable"
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:46-[[@LINE-4]]:46}:" _Nonnull"
+
+// Class parameters don't have nullability type specifier.
+void objcParameterizedClassParameter(Container *c); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:57-[[@LINE-3]]:57}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:57-[[@LINE-4]]:57}:" _Nonnull "
+
+// Class param

[PATCH] D38327: [Sema] Put nullability fix-it after the end of the pointer.

2017-09-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D38327#882540, @jordan_rose wrote:

> Nice catch, Volodymyr! Looks good to me.


Thanks for the quick review, Jordan.


Repository:
  rL LLVM

https://reviews.llvm.org/D38327



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


[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.

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

This is such a nasty bug! It is great to see a fix. I have two comments inline, 
one of which is just a nit.




Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1404
+  // When trying to dereference a void pointer, read the first byte.
+  T = Ctx.CharTy;
+}

Nit: It seems a bit odd to read the first byte here since (unless I'm 
misunderstanding) this would never be triggered by actual C semantics, only by 
a checker. Did you consider just returning UnknownVal() in this case?



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1408
 }
+assert(!T.isNull() && "Unable to auto-detect binding type!");
+assert(!T->isVoidType() && "Attempted to retrieve a void value!");

I think you missed handling the AllocaRegion case from the old version in your 
new version. This means the assert will fire on the following when core.alpha 
is enabled:
```
void foo(void *dest) {
  void *src = __builtin_alloca(5);
  memcpy(dest, src, 1);
}
```


https://reviews.llvm.org/D38358



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


[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

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

Artem: Sorry it too me so long to review this! For CXXStdInitializerListExpr 
this looks great. However, I don't think we want ObjCBoxedExprs to escape their 
arguments. It looks to me like these expressions copy their argument values and 
don't hold on to them.




Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1127
+// only consist of ObjC objects, and escapes of ObjC objects
+// aren't so important (eg., retain count checker ignores them).
+if (isa(Ex) ||

Note that we do have other ObjC checkers that rely on escaping of ObjC objects, 
such as the ObjCLoopChecker and ObjCDeallocChecker. I think having the TODO is 
great, but I'd like you to remove the the bit about "escapes of ObjC objects 
aren't so important".



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1129
+if (isa(Ex) ||
+(isa(Ex) &&
+ cast(Ex)->getSubExpr()->getType()->isRecordType()))

In general, I don't think we want things passed to ObjCBoxedExpr to escape. The 
boxed values are copied and encoded when they are boxed, so the boxed 
expression doesn't take ownership of them.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1132
+  for (auto Child : Ex->children()) {
+if (!Child)
+  continue;

Is this 'if' needed?



Comment at: test/Analysis/objc-boxing.m:66
+  BoxableStruct bs;
+  bs.str = strdup("dynamic string"); // The duped string shall be owned by val.
+  NSValue *val = @(bs); // no-warning

In this case the duped string is not owned by `val`. NSValue doesn't take 
ownership of the string, so this *will* leak and we should warn about it.


https://reviews.llvm.org/D35216



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


[PATCH] D37954: Try to shorten system header paths when using -MD depfiles

2017-09-28 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added a comment.

Any objection for merging these patches? I rebased today (no changes needed) 
and it still passes clang-tests.


https://reviews.llvm.org/D37954



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


r314483 - [NFC] Rename variable 'Arguments' to 'Parameters' when lexing the Macro Definition.

2017-09-28 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Thu Sep 28 19:17:31 2017
New Revision: 314483

URL: http://llvm.org/viewvc/llvm-project?rev=314483&view=rev
Log:
[NFC] Rename variable 'Arguments' to 'Parameters' when lexing the Macro 
Definition.

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

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=314483&r1=314482&r2=314483&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Sep 28 19:17:31 2017
@@ -2137,14 +2137,14 @@ void Preprocessor::HandleIncludeMacrosDi
 /// closing ), updating MI with what we learn.  Return true if an error occurs
 /// parsing the arg list.
 bool Preprocessor::ReadMacroParameterList(MacroInfo *MI, Token &Tok) {
-  SmallVector Arguments;
+  SmallVector Parameters;
 
   while (true) {
 LexUnexpandedToken(Tok);
 switch (Tok.getKind()) {
 case tok::r_paren:
   // Found the end of the argument list.
-  if (Arguments.empty())  // #define FOO()
+  if (Parameters.empty())  // #define FOO()
 return false;
   // Otherwise we have #define FOO(A,)
   Diag(Tok, diag::err_pp_expected_ident_in_arg_list);
@@ -2168,9 +2168,9 @@ bool Preprocessor::ReadMacroParameterLis
 return true;
   }
   // Add the __VA_ARGS__ identifier as an argument.
-  Arguments.push_back(Ident__VA_ARGS__);
+  Parameters.push_back(Ident__VA_ARGS__);
   MI->setIsC99Varargs();
-  MI->setParameterList(Arguments, BP);
+  MI->setParameterList(Parameters, BP);
   return false;
 case tok::eod:  // #define X(
   Diag(Tok, diag::err_pp_missing_rparen_in_macro_def);
@@ -2187,14 +2187,14 @@ bool Preprocessor::ReadMacroParameterLis
 
   // If this is already used as an argument, it is used multiple times 
(e.g.
   // #define X(A,A.
-  if (std::find(Arguments.begin(), Arguments.end(), II) !=
-  Arguments.end()) {  // C99 6.10.3p6
+  if (std::find(Parameters.begin(), Parameters.end(), II) !=
+  Parameters.end()) {  // C99 6.10.3p6
 Diag(Tok, diag::err_pp_duplicate_name_in_arg_list) << II;
 return true;
   }
 
   // Add the argument to the macro info.
-  Arguments.push_back(II);
+  Parameters.push_back(II);
 
   // Lex the token after the identifier.
   LexUnexpandedToken(Tok);
@@ -2204,7 +2204,7 @@ bool Preprocessor::ReadMacroParameterLis
 Diag(Tok, diag::err_pp_expected_comma_in_arg_list);
 return true;
   case tok::r_paren: // #define X(A)
-MI->setParameterList(Arguments, BP);
+MI->setParameterList(Parameters, BP);
 return false;
   case tok::comma:  // #define X(A,
 break;
@@ -2220,7 +2220,7 @@ bool Preprocessor::ReadMacroParameterLis
 }
 
 MI->setIsGNUVarargs();
-MI->setParameterList(Arguments, BP);
+MI->setParameterList(Parameters, BP);
 return false;
   }
 }


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


r314484 - [NFC] Replace 'arguments' with 'parameters' in comments relating to lexing a macro definition.

2017-09-28 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Thu Sep 28 19:43:22 2017
New Revision: 314484

URL: http://llvm.org/viewvc/llvm-project?rev=314484&view=rev
Log:
[NFC] Replace 'arguments' with 'parameters' in comments relating to lexing a 
macro definition.

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

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=314484&r1=314483&r2=314484&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Sep 28 19:43:22 2017
@@ -2132,10 +2132,10 @@ void Preprocessor::HandleIncludeMacrosDi
 // Preprocessor Macro Directive Handling.
 
//===--===//
 
-/// ReadMacroParameterList - The ( starting an argument list of a macro
-/// definition has just been read.  Lex the rest of the arguments and the
+/// ReadMacroParameterList - The ( starting a parameter list of a macro
+/// definition has just been read.  Lex the rest of the parameters and the
 /// closing ), updating MI with what we learn.  Return true if an error occurs
-/// parsing the arg list.
+/// parsing the param list.
 bool Preprocessor::ReadMacroParameterList(MacroInfo *MI, Token &Tok) {
   SmallVector Parameters;
 
@@ -2143,7 +2143,7 @@ bool Preprocessor::ReadMacroParameterLis
 LexUnexpandedToken(Tok);
 switch (Tok.getKind()) {
 case tok::r_paren:
-  // Found the end of the argument list.
+  // Found the end of the parameter list.
   if (Parameters.empty())  // #define FOO()
 return false;
   // Otherwise we have #define FOO(A,)
@@ -2167,7 +2167,7 @@ bool Preprocessor::ReadMacroParameterLis
 Diag(Tok, diag::err_pp_missing_rparen_in_macro_def);
 return true;
   }
-  // Add the __VA_ARGS__ identifier as an argument.
+  // Add the __VA_ARGS__ identifier as a parameter.
   Parameters.push_back(Ident__VA_ARGS__);
   MI->setIsC99Varargs();
   MI->setParameterList(Parameters, BP);
@@ -2185,7 +2185,7 @@ bool Preprocessor::ReadMacroParameterLis
 return true;
   }
 
-  // If this is already used as an argument, it is used multiple times 
(e.g.
+  // If this is already used as a parameter, it is used multiple times 
(e.g.
   // #define X(A,A.
   if (std::find(Parameters.begin(), Parameters.end(), II) !=
   Parameters.end()) {  // C99 6.10.3p6
@@ -2193,7 +2193,7 @@ bool Preprocessor::ReadMacroParameterLis
 return true;
   }
 
-  // Add the argument to the macro info.
+  // Add the parameter to the macro info.
   Parameters.push_back(II);
 
   // Lex the token after the identifier.


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


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

2017-09-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added inline comments.
This revision is now accepted and ready to land.



Comment at: bindings/python/clang/cindex.py:320
+return self._get_spelling()['offset']
 
 def __eq__(self, other):

frutiger wrote:
> compnerd wrote:
> > Does it make sense to introduce two new properties `expansion` and 
> > `spelling` and have the four fields be properties on those properties?  It 
> > seems like it would be more pythonic.
> I agree, but I was concerned about breaking existing users that might be 
> using the expansion properties directly on this object.  Would marking them 
> deprecated in the documentation suffice?
Yeah, I think thats a great approach.


https://reviews.llvm.org/D37905



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


[PATCH] D38381: [libunwind] Skip building x86 parts of UnwindRegisters*.S when targeting SjLj

2017-09-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

I really wish that there was a way to handle this in the build system instead.


https://reviews.llvm.org/D38381



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


[PATCH] D38380: [libunwind] Add CMake support for building for MinGW

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

With an explanation of the `gcc_s` vs `gcc`, I think this LG.




Comment at: cmake/config-ix.cmake:38
+else ()
+  set(MINGW_RUNTIME gcc_s gcc)
+endif()

This seems really weird.  `gcc_s` and `gcc` are the same library, the former is 
the shared version of the latter.  Is this really correct?


https://reviews.llvm.org/D38380



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


[PATCH] D38250: [libunwind] Implement the Get/SetTopOfFunctionStack functions via a __thread TLS variable

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

Ugh, I was mixing up `_Unwind_SjLj_Register` with this function.




Comment at: src/Unwind-sjlj.c:468
 
+#ifndef __APPLE__
+__thread struct _Unwind_FunctionContext *stack = NULL;

I would prefer:

#if !defined(__APPLE__)



Comment at: src/Unwind-sjlj.c:469
+#ifndef __APPLE__
+__thread struct _Unwind_FunctionContext *stack = NULL;
+

Please make this `static`.



Comment at: src/Unwind-sjlj.c:481
+#endif // !defined(__APPLE__)
+
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)

Can't both of these also be static?


https://reviews.llvm.org/D38250



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


[PATCH] D38250: [libunwind] Implement the Get/SetTopOfFunctionStack functions via a __thread TLS variable

2017-09-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/Unwind-sjlj.c:468
 
+#ifndef __APPLE__
+__thread struct _Unwind_FunctionContext *stack = NULL;

compnerd wrote:
> I would prefer:
> 
> #if !defined(__APPLE__)
Sure, I can change that.



Comment at: src/Unwind-sjlj.c:469
+#ifndef __APPLE__
+__thread struct _Unwind_FunctionContext *stack = NULL;
+

compnerd wrote:
> Please make this `static`.
Oh, indeed, yes, I'll change that.



Comment at: src/Unwind-sjlj.c:481
+#endif // !defined(__APPLE__)
+
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)

compnerd wrote:
> Can't both of these also be static?
No, since they're declared earlier as non-static.


https://reviews.llvm.org/D38250



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


[PATCH] D38250: [libunwind] Implement the Get/SetTopOfFunctionStack functions via a __thread TLS variable

2017-09-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 117089.
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Made the tls variable static, changed ifndef into !defined().


https://reviews.llvm.org/D38250

Files:
  src/Unwind-sjlj.c


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -465,4 +465,18 @@
   return 0;
 }
 
+#if !defined(__APPLE__)
+static __thread struct _Unwind_FunctionContext *stack = NULL;
+
+_LIBUNWIND_HIDDEN
+struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+  return stack;
+}
+
+_LIBUNWIND_HIDDEN
+void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+  stack = fc;
+}
+#endif // !defined(__APPLE__)
+
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -465,4 +465,18 @@
   return 0;
 }
 
+#if !defined(__APPLE__)
+static __thread struct _Unwind_FunctionContext *stack = NULL;
+
+_LIBUNWIND_HIDDEN
+struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+  return stack;
+}
+
+_LIBUNWIND_HIDDEN
+void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+  stack = fc;
+}
+#endif // !defined(__APPLE__)
+
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38380: [libunwind] Add CMake support for building for MinGW

2017-09-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: cmake/config-ix.cmake:38
+else ()
+  set(MINGW_RUNTIME gcc_s gcc)
+endif()

compnerd wrote:
> This seems really weird.  `gcc_s` and `gcc` are the same library, the former 
> is the shared version of the latter.  Is this really correct?
I think so; my impression is that `libgcc.a` contains some object files that 
end up linked into every module, even if you're otherwise using a shared 
`libgcc_s_.dll`.

In any case, this is identical to the same lines in libcxxabi and libcxx as 
well; the only difference is in the library name above in `if 
(_USE_COMPILER_RT)`, so if there needs to be a change, it should be 
changed there as well.


https://reviews.llvm.org/D38380



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


[libunwind] r314492 - Skip building x86 parts of UnwindRegisters*.S when targeting SjLj

2017-09-28 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Sep 28 23:09:09 2017
New Revision: 314492

URL: http://llvm.org/viewvc/llvm-project?rev=314492&view=rev
Log:
Skip building x86 parts of UnwindRegisters*.S when targeting SjLj

This extends SVN r314197 from the arm parts to the whole file.

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

Modified:
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S

Modified: libunwind/trunk/src/UnwindRegistersRestore.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=314492&r1=314491&r2=314492&view=diff
==
--- libunwind/trunk/src/UnwindRegistersRestore.S (original)
+++ libunwind/trunk/src/UnwindRegistersRestore.S Thu Sep 28 23:09:09 2017
@@ -11,6 +11,8 @@
 
   .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
 #
@@ -308,7 +310,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -491,5 +493,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
 
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 

Modified: libunwind/trunk/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=314492&r1=314491&r2=314492&view=diff
==
--- libunwind/trunk/src/UnwindRegistersSave.S (original)
+++ libunwind/trunk/src/UnwindRegistersSave.S Thu Sep 28 23:09:09 2017
@@ -11,6 +11,8 @@
 
 .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 
 #
@@ -289,7 +291,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -471,5 +473,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   l.sw 124(r3), r31
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 


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


[PATCH] D38381: [libunwind] Skip building x86 parts of UnwindRegisters*.S when targeting SjLj

2017-09-28 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314492: Skip building x86 parts of UnwindRegisters*.S when 
targeting SjLj (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D38381?vs=117047&id=117092#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38381

Files:
  libunwind/trunk/src/UnwindRegistersRestore.S
  libunwind/trunk/src/UnwindRegistersSave.S


Index: libunwind/trunk/src/UnwindRegistersSave.S
===
--- libunwind/trunk/src/UnwindRegistersSave.S
+++ libunwind/trunk/src/UnwindRegistersSave.S
@@ -11,6 +11,8 @@
 
 .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 
 #
@@ -289,7 +291,7 @@
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -471,5 +473,7 @@
   l.sw 124(r3), r31
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 
Index: libunwind/trunk/src/UnwindRegistersRestore.S
===
--- libunwind/trunk/src/UnwindRegistersRestore.S
+++ libunwind/trunk/src/UnwindRegistersRestore.S
@@ -11,6 +11,8 @@
 
   .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
 #
@@ -308,7 +310,7 @@
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -491,5 +493,7 @@
 
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 


Index: libunwind/trunk/src/UnwindRegistersSave.S
===
--- libunwind/trunk/src/UnwindRegistersSave.S
+++ libunwind/trunk/src/UnwindRegistersSave.S
@@ -11,6 +11,8 @@
 
 .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 
 #
@@ -289,7 +291,7 @@
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !(defined(__APPLE__) || defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -471,5 +473,7 @@
   l.sw 124(r3), r31
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 
Index: libunwind/trunk/src/UnwindRegistersRestore.S
===
--- libunwind/trunk/src/UnwindRegistersRestore.S
+++ libunwind/trunk/src/UnwindRegistersRestore.S
@@ -11,6 +11,8 @@
 
   .text
 
+#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+
 #if defined(__i386__)
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
 #
@@ -308,7 +310,7 @@
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !(defined(__APPLE__) || defined(__USING_SJLJ_EXCEPTIONS__))
+#elif defined(__arm__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
@@ -491,5 +493,7 @@
 
 #endif
 
+#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits