r351304 - [test] Disable Python binding tests w/ LLVM_ENABLE_PIC=OFF

2019-01-16 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Wed Jan 16 00:05:13 2019
New Revision: 351304

URL: http://llvm.org/viewvc/llvm-project?rev=351304&view=rev
Log:
[test] Disable Python binding tests w/ LLVM_ENABLE_PIC=OFF

Disable Python binding tests when LLVM_ENABLE_PIC is disabled,
as libclang.so is not being built in that case.  Reported by Nico Weber.

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

Modified:
cfe/trunk/bindings/python/tests/CMakeLists.txt

Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=351304&r1=351303&r2=351304&view=diff
==
--- cfe/trunk/bindings/python/tests/CMakeLists.txt (original)
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt Wed Jan 16 00:05:13 2019
@@ -10,6 +10,11 @@ add_custom_target(check-clang-python
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.


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


[PATCH] D56732: [clang] [test] Disable Python binding tests w/ LLVM_ENABLE_PIC=OFF

2019-01-16 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351304: [test] Disable Python binding tests w/ 
LLVM_ENABLE_PIC=OFF (authored by mgorny, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56732/new/

https://reviews.llvm.org/D56732

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -10,6 +10,11 @@
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -10,6 +10,11 @@
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r351306 - [clangd] Fix XPC after rCTE351280

2019-01-16 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed Jan 16 00:13:15 2019
New Revision: 351306

URL: http://llvm.org/viewvc/llvm-project?rev=351306&view=rev
Log:
[clangd] Fix XPC after rCTE351280

Modified:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=351306&r1=351305&r2=351306&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Jan 16 00:13:15 2019
@@ -417,11 +417,11 @@ int main(int argc, char *argv[]) {
 
   std::unique_ptr TransportLayer;
   if (getenv("CLANGD_AS_XPC_SERVICE")) {
-#ifdef CLANGD_BUILD_XPC
+#if CLANGD_BUILD_XPC
 TransportLayer = newXPCTransport();
 #else
-errs() << "This clangd binary wasn't built with XPC support.\n";
-return ErrorResultCode::CantRunAsXPCService;
+llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
+return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
 TransportLayer = newJSONTransport(


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


[PATCH] D54428: [clangd] XPC transport layer, framework, test-client

2019-01-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D54428#1359333 , @tamur wrote:

> This patch seems to have broken the compilation. I get the following error on 
> a linux platform:
>  [12/14] Linking CXX executable bin/clangd
>  FAILED: bin/clangd 
>  : && 
> /usr/local/google/home/tamur/src/llvm/2018_nov_12/llvm/Stable/bin/clang++  
> -fPIC -fvisibility-inlines-hidden -Werror=date-time 
> -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra 
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
> -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
> -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color 
> -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
> -Wno-nested-anon-types  -fuse-ld=lld -Wl,--color-diagnostics 
> -Wl,-allow-shlib-undefined -Wl,-O3 -Wl,--gc-sections 
> tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o  
> -o bin/clangd  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.so.8svn 
> -lpthread lib/libclangBasic.so.8svn lib/libclangDaemon.so.8svn 
> lib/libclangFormat.so.8svn lib/libclangFrontend.so.8svn 
> lib/libclangSema.so.8svn lib/libclangTooling.so.8svn 
> lib/libclangToolingCore.so.8svn && :
>  ld.lld: error: undefined symbol: clang::clangd::newXPCTransport()


Fixed by rCTE351306 


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54428/new/

https://reviews.llvm.org/D54428



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


[clang-tools-extra] r351307 - [clang-tidy] Avoid fuchsia-overloaded-operator false positive with lambdas after r351047

2019-01-16 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jan 16 00:29:54 2019
New Revision: 351307

URL: http://llvm.org/viewvc/llvm-project?rev=351307&view=rev
Log:
[clang-tidy] Avoid fuchsia-overloaded-operator false positive with lambdas 
after r351047

Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp?rev=351307&r1=351306&r2=351307&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp Wed 
Jan 16 00:29:54 2019
@@ -21,6 +21,8 @@ AST_MATCHER(FunctionDecl, isFuchsiaOverl
 if (CXXMethodNode->isCopyAssignmentOperator() ||
 CXXMethodNode->isMoveAssignmentOperator())
   return false;
+if (CXXMethodNode->getParent()->isLambda())
+  return false;
   }
   return Node.isOverloadedOperator();
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp?rev=351307&r1=351306&r2=351307&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp Wed 
Jan 16 00:29:54 2019
@@ -19,3 +19,5 @@ A operator-(const A &A1, const A &A2);
 
 void operator delete(void*, void*) throw();
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: overloading 'operator delete' is 
disallowed
+
+auto x = []{};


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


[PATCH] D56657: [clang-tidy] bugprone-string-constructor: Catch string from nullptr.

2019-01-16 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 181985.
courbet marked 2 inline comments as done.
courbet added a comment.

clang-format + add test


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56657/new/

https://reviews.llvm.org/D56657

Files:
  clang-tidy/bugprone/StringConstructorCheck.cpp
  test/clang-tidy/bugprone-string-constructor.cpp


Index: test/clang-tidy/bugprone-string-constructor.cpp
===
--- test/clang-tidy/bugprone-string-constructor.cpp
+++ test/clang-tidy/bugprone-string-constructor.cpp
@@ -9,6 +9,7 @@
 struct basic_string {
   basic_string();
   basic_string(const C*, unsigned int size);
+  basic_string(const C *, const A &allocator = A());
   basic_string(unsigned int size, C c);
 };
 typedef basic_string string;
@@ -45,6 +46,15 @@
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string 
literal size
   std::string q5(kText3,  0x100);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+  std::string q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr 
is undefined behaviour
+  std::string q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr 
is undefined behaviour
+}
+
+std::string StringFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr 
is undefined behaviour
 }
 
 void Valid() {
@@ -53,4 +63,5 @@
   std::wstring wstr(4, L'x');
   std::string s1("test", 4);
   std::string s2("test", 3);
+  std::string s3("test");
 }
Index: clang-tidy/bugprone/StringConstructorCheck.cpp
===
--- clang-tidy/bugprone/StringConstructorCheck.cpp
+++ clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -100,6 +100,15 @@
integerLiteral().bind("int"))
   .bind("constructor"),
   this);
+
+  // Check the literal string constructor with char pointer.
+  // [i.e. string (const char* s);]
+  Finder->addMatcher(
+  cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(0, expr().bind("from-ptr")),
+   hasArgument(1, unless(hasType(isInteger()
+  .bind("constructor"),
+  this);
 }
 
 void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) {
@@ -128,6 +137,13 @@
 if (Lit->getValue().ugt(Str->getLength())) {
   diag(Loc, "length is bigger then string literal size");
 }
+  } else if (const auto *Ptr = Result.Nodes.getNodeAs("from-ptr")) {
+Expr::EvalResult ConstPtr;
+if (Ptr->EvaluateAsRValue(ConstPtr, Ctx) &&
+((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isNullValue()) ||
+ (ConstPtr.Val.isLValue() && ConstPtr.Val.isNullPointer( {
+  diag(Loc, "constructing string from nullptr is undefined behaviour");
+}
   }
 }
 


Index: test/clang-tidy/bugprone-string-constructor.cpp
===
--- test/clang-tidy/bugprone-string-constructor.cpp
+++ test/clang-tidy/bugprone-string-constructor.cpp
@@ -9,6 +9,7 @@
 struct basic_string {
   basic_string();
   basic_string(const C*, unsigned int size);
+  basic_string(const C *, const A &allocator = A());
   basic_string(unsigned int size, C c);
 };
 typedef basic_string string;
@@ -45,6 +46,15 @@
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
   std::string q5(kText3,  0x100);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+  std::string q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr is undefined behaviour
+  std::string q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour
+}
+
+std::string StringFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour
 }
 
 void Valid() {
@@ -53,4 +63,5 @@
   std::wstring wstr(4, L'x');
   std::string s1("test", 4);
   std::string s2("test", 3);
+  std::string s3("test");
 }
Index: clang-tidy/bugprone/StringConstructorCheck.cpp
===
--- clang-tidy/bugprone/StringConstructorCheck.cpp
+++ clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -100,6 +100,15 @@
integerLiteral().bind("int"))
   .bind("constructor"),
   this);
+
+  // Check the literal string constructor with char pointer.
+  // [i.e. string (const char* s);]
+  Finder->addMatcher(
+  cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(0, expr().bind("from-ptr")),
+   hasArgument(1, unless(hasType(isInteger()
+  .bind("c

[PATCH] D56657: [clang-tidy] bugprone-string-constructor: Catch string from nullptr.

2019-01-16 Thread Clement Courbet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE351308: [clang-tidy] bugprone-string-constructor: Catch 
string from nullptr. (authored by courbet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56657?vs=181985&id=181986#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56657/new/

https://reviews.llvm.org/D56657

Files:
  clang-tidy/bugprone/StringConstructorCheck.cpp
  test/clang-tidy/bugprone-string-constructor.cpp


Index: test/clang-tidy/bugprone-string-constructor.cpp
===
--- test/clang-tidy/bugprone-string-constructor.cpp
+++ test/clang-tidy/bugprone-string-constructor.cpp
@@ -9,6 +9,7 @@
 struct basic_string {
   basic_string();
   basic_string(const C*, unsigned int size);
+  basic_string(const C *, const A &allocator = A());
   basic_string(unsigned int size, C c);
 };
 typedef basic_string string;
@@ -45,6 +46,15 @@
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string 
literal size
   std::string q5(kText3,  0x100);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+  std::string q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr 
is undefined behaviour
+  std::string q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr 
is undefined behaviour
+}
+
+std::string StringFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr 
is undefined behaviour
 }
 
 void Valid() {
@@ -53,4 +63,5 @@
   std::wstring wstr(4, L'x');
   std::string s1("test", 4);
   std::string s2("test", 3);
+  std::string s3("test");
 }
Index: clang-tidy/bugprone/StringConstructorCheck.cpp
===
--- clang-tidy/bugprone/StringConstructorCheck.cpp
+++ clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -100,6 +100,15 @@
integerLiteral().bind("int"))
   .bind("constructor"),
   this);
+
+  // Check the literal string constructor with char pointer.
+  // [i.e. string (const char* s);]
+  Finder->addMatcher(
+  cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(0, expr().bind("from-ptr")),
+   hasArgument(1, unless(hasType(isInteger()
+  .bind("constructor"),
+  this);
 }
 
 void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) {
@@ -128,6 +137,13 @@
 if (Lit->getValue().ugt(Str->getLength())) {
   diag(Loc, "length is bigger then string literal size");
 }
+  } else if (const auto *Ptr = Result.Nodes.getNodeAs("from-ptr")) {
+Expr::EvalResult ConstPtr;
+if (Ptr->EvaluateAsRValue(ConstPtr, Ctx) &&
+((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isNullValue()) ||
+ (ConstPtr.Val.isLValue() && ConstPtr.Val.isNullPointer( {
+  diag(Loc, "constructing string from nullptr is undefined behaviour");
+}
   }
 }
 


Index: test/clang-tidy/bugprone-string-constructor.cpp
===
--- test/clang-tidy/bugprone-string-constructor.cpp
+++ test/clang-tidy/bugprone-string-constructor.cpp
@@ -9,6 +9,7 @@
 struct basic_string {
   basic_string();
   basic_string(const C*, unsigned int size);
+  basic_string(const C *, const A &allocator = A());
   basic_string(unsigned int size, C c);
 };
 typedef basic_string string;
@@ -45,6 +46,15 @@
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
   std::string q5(kText3,  0x100);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+  std::string q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr is undefined behaviour
+  std::string q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour
+}
+
+std::string StringFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour
 }
 
 void Valid() {
@@ -53,4 +63,5 @@
   std::wstring wstr(4, L'x');
   std::string s1("test", 4);
   std::string s2("test", 3);
+  std::string s3("test");
 }
Index: clang-tidy/bugprone/StringConstructorCheck.cpp
===
--- clang-tidy/bugprone/StringConstructorCheck.cpp
+++ clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -100,6 +100,15 @@
integerLiteral().bind("int"))
   .bind("constructor"),
   this);
+
+  // Check the literal string constructor with char pointer.
+  // [i.e. string (const char* s);]
+  Finder->addMatcher(
+  cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string")))

[PATCH] D56657: [clang-tidy] bugprone-string-constructor: Catch string from nullptr.

2019-01-16 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

Thanks.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56657/new/

https://reviews.llvm.org/D56657



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


[clang-tools-extra] r351308 - [clang-tidy] bugprone-string-constructor: Catch string from nullptr.

2019-01-16 Thread Clement Courbet via cfe-commits
Author: courbet
Date: Wed Jan 16 00:36:23 2019
New Revision: 351308

URL: http://llvm.org/viewvc/llvm-project?rev=351308&view=rev
Log:
[clang-tidy] bugprone-string-constructor: Catch string from nullptr.

Summary: Context: https://twitter.com/willkirkby/status/1084219580799741953

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp?rev=351308&r1=351307&r2=351308&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp Wed 
Jan 16 00:36:23 2019
@@ -100,6 +100,15 @@ void StringConstructorCheck::registerMat
integerLiteral().bind("int"))
   .bind("constructor"),
   this);
+
+  // Check the literal string constructor with char pointer.
+  // [i.e. string (const char* s);]
+  Finder->addMatcher(
+  cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(0, expr().bind("from-ptr")),
+   hasArgument(1, unless(hasType(isInteger()
+  .bind("constructor"),
+  this);
 }
 
 void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) {
@@ -128,6 +137,13 @@ void StringConstructorCheck::check(const
 if (Lit->getValue().ugt(Str->getLength())) {
   diag(Loc, "length is bigger then string literal size");
 }
+  } else if (const auto *Ptr = Result.Nodes.getNodeAs("from-ptr")) {
+Expr::EvalResult ConstPtr;
+if (Ptr->EvaluateAsRValue(ConstPtr, Ctx) &&
+((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isNullValue()) ||
+ (ConstPtr.Val.isLValue() && ConstPtr.Val.isNullPointer( {
+  diag(Loc, "constructing string from nullptr is undefined behaviour");
+}
   }
 }
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-constructor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-string-constructor.cpp?rev=351308&r1=351307&r2=351308&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-string-constructor.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-string-constructor.cpp Wed 
Jan 16 00:36:23 2019
@@ -9,6 +9,7 @@ template  string;
@@ -45,6 +46,15 @@ void Test() {
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string 
literal size
   std::string q5(kText3,  0x100);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+  std::string q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr 
is undefined behaviour
+  std::string q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr 
is undefined behaviour
+}
+
+std::string StringFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr 
is undefined behaviour
 }
 
 void Valid() {
@@ -53,4 +63,5 @@ void Valid() {
   std::wstring wstr(4, L'x');
   std::string s1("test", 4);
   std::string s2("test", 3);
+  std::string s3("test");
 }


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


[PATCH] D54428: [clangd] XPC transport layer, framework, test-client

2019-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry for not getting back to this, but it looks good.

I'm really glad about how minimal the changes are outside xpc/, because it 
makes it less likely we'll accidentally break something that can only be tested 
on mac.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54428/new/

https://reviews.llvm.org/D54428



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


r351312 - UsersManual.rst: Update the clang-cl flags section

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 01:13:47 2019
New Revision: 351312

URL: http://llvm.org/viewvc/llvm-project?rev=351312&view=rev
Log:
UsersManual.rst: Update the clang-cl flags section

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=351312&r1=351311&r2=351312&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Jan 16 01:13:47 2019
@@ -2928,20 +2928,23 @@ Execute ``clang-cl /?`` to see a list of
   /GA Assume thread-local variables are defined in the 
executable
   /Gd Set __cdecl as a default calling convention
   /GF-Disable string pooling
+  /GF Enable string pooling (default)
   /GR-Disable emission of RTTI data
   /Gregcall   Set __regcall as a default calling convention
   /GR Enable emission of RTTI data
   /Gr Set __fastcall as a default calling convention
   /GS-Disable buffer security check
-  /GS Enable buffer security check
-  /Gs  Set stack probe size
-  /guard:  Enable Control Flow Guard with /guard:cf
+  /GS Enable buffer security check (default)
+  /Gs Use stack probes (default)
+  /Gs  Set stack probe size (default 4096)
+  /guard:  Enable Control Flow Guard with /guard:cf,
+  or only the table with /guard:cf,nochecks
   /Gv Set __vectorcall as a default calling convention
   /Gw-Don't put each data item in its own section
   /Gw Put each data item in its own section
   /GX-Disable exception handling
   /GX Enable exception handling
-  /Gy-Don't put each function in its own section
+  /Gy-Don't put each function in its own section 
(default)
   /Gy Put each function in its own section
   /Gz Set __stdcall as a default calling convention
   /help   Display available options
@@ -2955,16 +2958,28 @@ Execute ``clang-cl /?`` to see a list of
   /MD Use DLL run-time
   /MTdUse static debug run-time
   /MT Use static run-time
+  /O0 Disable optimization
+  /O1 Optimize for size  (same as /Og /Os /Oy /Ob2 
/GF /Gy)
+  /O2 Optimize for speed (same as /Og /Oi /Ot /Oy /Ob2 
/GF /Gy)
+  /Ob0Disable function inlining
+  /Ob1Only inline functions which are (explicitly or 
implicitly) marked inline
+  /Ob2Inline functions as deemed beneficial by the 
compiler
   /Od Disable optimization
+  /Og No effect
   /Oi-Disable use of builtin functions
   /Oi Enable use of builtin functions
   /Os Optimize for size
   /Ot Optimize for speed
-  /O   Optimization level
+  /Ox Deprecated (same as /Og /Oi /Ot /Oy /Ob2); use 
/O2 instead
+  /Oy-Disable frame pointer omission (x86 only, 
default)
+  /Oy Enable frame pointer omission (x86 only)
+  /O   Set multiple /O flags at once; e.g. '/O2y-' for 
'/O2 /Oy-'
   /o   Set output file or directory (ends in / or \)
   /P  Preprocess to file
   /Qvec-  Disable the loop vectorization passes
   /Qvec   Enable the loop vectorization passes
+  /showFilenames- Don't print the name of each compiled file 
(default)
+  /showFilenames  Print the name of each compiled file
   /showIncludes   Print info about included files to stderr
   /source-charset: Source encoding, supports only UTF-8
   /std:Language standard to compile for
@@ -3049,6 +3064,7 @@ Execute ``clang-cl /?`` to see a list of
   -fno-complete-member-pointers
   Do not require member pointer base types to be 
complete if they would be significant under the Microsoft ABI
   -fno-coverage-mapping   Disable code coverage analysis
+  -fno-crash-diagnostics  Disable auto-generation of preprocessed source 
files and a script for reproduction during a clang crash
   -fno-debug-macroDo not emit macro debug information
   -fno-delayed-template-parsing
 

r351314 - [NewPM][TSan] Reiterate the TSan port

2019-01-16 Thread Philip Pfaffe via cfe-commits
Author: pfaffe
Date: Wed Jan 16 01:28:01 2019
New Revision: 351314

URL: http://llvm.org/viewvc/llvm-project?rev=351314&view=rev
Log:
[NewPM][TSan] Reiterate the TSan port

Summary:
Second iteration of D56433 which got reverted in rL350719. The problem
in the previous version was that we dropped the thunk calling the tsan init
function. The new version keeps the thunk which should appease dyld, but is not
actually OK wrt. the current semantics of function passes. Hence, add a
helper to insert the functions only on the first time. The helper
allows hooking into the insertion to be able to append them to the
global ctors list.

Reviewers: chandlerc, vitalybuka, fedor.sergeev, leonardchan

Subscribers: hiraditya, bollu, llvm-commits

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

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=351314&r1=351313&r2=351314&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jan 16 01:28:01 2019
@@ -53,9 +53,10 @@
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
+#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
@@ -305,7 +306,7 @@ static void addKernelMemorySanitizerPass
 
 static void addThreadSanitizerPass(const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) {
-  PM.add(createThreadSanitizerPass());
+  PM.add(createThreadSanitizerLegacyPassPass());
 }
 
 static void addDataFlowSanitizerPass(const PassManagerBuilder &Builder,


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


[PATCH] D56538: [NewPM][TSan] Reiterate the TSan port

2019-01-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351314: [NewPM][TSan] Reiterate the TSan port (authored by 
pfaffe, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56538?vs=181821&id=181994#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56538/new/

https://reviews.llvm.org/D56538

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -53,9 +53,10 @@
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
+#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
@@ -305,7 +306,7 @@
 
 static void addThreadSanitizerPass(const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) {
-  PM.add(createThreadSanitizerPass());
+  PM.add(createThreadSanitizerLegacyPassPass());
 }
 
 static void addDataFlowSanitizerPass(const PassManagerBuilder &Builder,


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -53,9 +53,10 @@
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
+#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
@@ -305,7 +306,7 @@
 
 static void addThreadSanitizerPass(const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) {
-  PM.add(createThreadSanitizerPass());
+  PM.add(createThreadSanitizerLegacyPassPass());
 }
 
 static void addDataFlowSanitizerPass(const PassManagerBuilder &Builder,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351316 - Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-16 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jan 16 01:41:26 2019
New Revision: 351316

URL: http://llvm.org/viewvc/llvm-project?rev=351316&view=rev
Log:
Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file 
without compilation database.

This reverts commit r351282, and re-lands r351222 and r351229 with the
use-after-free fixed.

Added:
cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
Modified:
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=351316&r1=351315&r2=351316&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed Jan 16 01:41:26 2019
@@ -227,6 +227,16 @@ struct FilterUnusedFlags {
   }
 };
 
+std::string GetClangToolCommand() {
+  static int Dummy;
+  std::string ClangExecutable =
+  llvm::sys::fs::getMainExecutable("clang", (void *)&Dummy);
+  SmallString<128> ClangToolPath;
+  ClangToolPath = llvm::sys::path::parent_path(ClangExecutable);
+  llvm::sys::path::append(ClangToolPath, "clang-tool");
+  return ClangToolPath.str();
+}
+
 } // namespace
 
 /// Strips any positional args and possible argv[0] from a command-line
@@ -266,9 +276,10 @@ static bool stripPositionalArgs(std::vec
   Diagnostics));
   NewDriver->setCheckInputsExist(false);
 
-  // This becomes the new argv[0]. The value is actually not important as it
-  // isn't used for invoking Tools.
-  Args.insert(Args.begin(), "clang-tool");
+  // This becomes the new argv[0]. The value is used to detect libc++ include
+  // dirs on Mac, it isn't used for other platforms.
+  std::string Argv0 = GetClangToolCommand();
+  Args.insert(Args.begin(), Argv0.c_str());
 
   // By adding -c, we force the driver to treat compilation as the last phase.
   // It will then issue warnings via Diagnostics about un-used options that
@@ -366,7 +377,7 @@ FixedCompilationDatabase::loadFromFile(S
 
 FixedCompilationDatabase::
 FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine) {
-  std::vector ToolCommandLine(1, "clang-tool");
+  std::vector ToolCommandLine(1, GetClangToolCommand());
   ToolCommandLine.insert(ToolCommandLine.end(),
  CommandLine.begin(), CommandLine.end());
   CompileCommands.emplace_back(Directory, StringRef(),

Added: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351316&view=auto
==
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(added)
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp Wed 
Jan 16 01:41:26 2019
@@ -0,0 +1,16 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure our libTooling-based tools emulate this properly with
+// fixed compilation database.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// RUN: cp $(which clang-check) %t/mock-libcxx/bin/
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- -stdlib=libc++
+
+#include 
+vector v;

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=351316&r1=351315&r2=351316&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Wed Jan 16 01:41:26 
2019
@@ -14,11 +14,15 @@
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 
+using testing::ElementsAre;
+using testing::EndsWith;
+
 static void expectFailure(StringRef JSONDatabase, StringRef Explanation) {
   std::string ErrorMessage;
   EXPECT_EQ(nullptr,
@@ -467,21 +471,15 @@ TEST(unescapeJsonCommandLine, ParsesSing
 }
 
 TEST(FixedCompilationDatabase, ReturnsFixedCommandLine) {
-  std::vector CommandLine;
-  CommandLine.push_back("one");
-  CommandLine.push_back("two");
-  FixedCompilationDatabase Database(".", CommandLine);
+  FixedCompilationDatabase Database(".", /*CommandLine*/ {"one", "two"});
   StringRef FileName("source");
   std::vector Result =
 Database.getCompileCommands(FileName);
   ASSERT_EQ(1ul, Result.size());
-  std::vector ExpectedCommandLine(1, "clang-tool");
-  ExpectedComm

[PATCH] D56429: fix python3 compability issue

2019-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille accepted this revision.
serge-sans-paille added inline comments.
This revision is now accepted and ready to land.



Comment at: bindings/python/clang/cindex.py:2998
+for i,(name,contents) in enumerate(unsaved_files):
+if hasattr(contents, "read"):
+contents = contents.read()

roxma wrote:
> serge-sans-paille wrote:
> > serge-sans-paille wrote:
> > > Why did you remove the FIXME comment?
> > @roxma LGTM except this FIXME removal.
> @serge-sans-paille
> 
> the `contents.read()` looks almost the same as line 2817.
> 
> It is better to keep the code consistent. The FIXME doesn't seem to be 
> helpful.
ok, I'll trust you on this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56429/new/

https://reviews.llvm.org/D56429



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


r351317 - [Support] Remove error return value from one overload of fs::make_absolute

2019-01-16 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Jan 16 01:55:32 2019
New Revision: 351317

URL: http://llvm.org/viewvc/llvm-project?rev=351317&view=rev
Log:
[Support] Remove error return value from one overload of fs::make_absolute

Summary:
The version of make_absolute which accepted a specific directory to use
as the "base" for the computation could never fail, even though it
returned a std::error_code. The reason for that seems to be historical
-- the CWD flavour (which can fail due to failure to retrieve CWD) was
there first, and the new version was implemented by extending that.

This removes the error return value from the non-CWD overload and
reimplements the CWD version on top of that. This enables us to remove
some dead code where people were pessimistically trying to handle the
errors returned from this function.

Reviewers: zturner, sammccall

Subscribers: hiraditya, kristina, llvm-commits

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

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

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=351317&r1=351316&r2=351317&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Jan 16 01:55:32 2019
@@ -1678,9 +1678,8 @@ std::string HeaderSearch::suggestPathToF
 StringRef Dir = SearchDirs[I].getDir()->getName();
 llvm::SmallString<32> DirPath(Dir.begin(), Dir.end());
 if (!WorkingDir.empty() && !path::is_absolute(Dir)) {
-  auto err = fs::make_absolute(WorkingDir, DirPath);
-  if (!err)
-path::remove_dots(DirPath, /*remove_dot_dot=*/true);
+  fs::make_absolute(WorkingDir, DirPath);
+  path::remove_dots(DirPath, /*remove_dot_dot=*/true);
   Dir = DirPath;
 }
 for (auto NI = path::begin(File), NE = path::end(File),


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


[PATCH] D56599: [Support] Remove error return value from one overload of fs::make_absolute

2019-01-16 Thread Pavel Labath via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351317: [Support] Remove error return value from one 
overload of fs::make_absolute (authored by labath, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56599?vs=181273&id=181997#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56599/new/

https://reviews.llvm.org/D56599

Files:
  lib/Lex/HeaderSearch.cpp


Index: lib/Lex/HeaderSearch.cpp
===
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -1678,9 +1678,8 @@
 StringRef Dir = SearchDirs[I].getDir()->getName();
 llvm::SmallString<32> DirPath(Dir.begin(), Dir.end());
 if (!WorkingDir.empty() && !path::is_absolute(Dir)) {
-  auto err = fs::make_absolute(WorkingDir, DirPath);
-  if (!err)
-path::remove_dots(DirPath, /*remove_dot_dot=*/true);
+  fs::make_absolute(WorkingDir, DirPath);
+  path::remove_dots(DirPath, /*remove_dot_dot=*/true);
   Dir = DirPath;
 }
 for (auto NI = path::begin(File), NE = path::end(File),


Index: lib/Lex/HeaderSearch.cpp
===
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -1678,9 +1678,8 @@
 StringRef Dir = SearchDirs[I].getDir()->getName();
 llvm::SmallString<32> DirPath(Dir.begin(), Dir.end());
 if (!WorkingDir.empty() && !path::is_absolute(Dir)) {
-  auto err = fs::make_absolute(WorkingDir, DirPath);
-  if (!err)
-path::remove_dots(DirPath, /*remove_dot_dot=*/true);
+  fs::make_absolute(WorkingDir, DirPath);
+  path::remove_dots(DirPath, /*remove_dot_dot=*/true);
   Dir = DirPath;
 }
 for (auto NI = path::begin(File), NE = path::end(File),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56776: [MSP430] Fix msp430-toolchain.c on Windows (added in rL351228)

2019-01-16 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56776

Files:
  test/Driver/msp430-toolchain.c


Index: test/Driver/msp430-toolchain.c
===
--- test/Driver/msp430-toolchain.c
+++ test/Driver/msp430-toolchain.c
@@ -8,44 +8,44 @@
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430 %s
 
-// MSP430: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crt0.o"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o"
+// MSP430: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crt0.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtbegin.o"
 // MSP430: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" "-lnosys" 
"--end-group"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crtn.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtend.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crtn.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-DFT-LIB %s
 
-// MSP430-NO-DFT-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430-NO-DFT-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crt0.o"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o"
+// MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crt0.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtbegin.o"
 // MSP430-NO-DFT-LIB: "--start-group" "-lmul_none" "-lgcc" "--end-group"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crtn.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtend.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crtn.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-START %s
 
-// MSP430-NO-START: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430-NO-START: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
+// MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
 // MSP430-NO-START: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" 
"-lnosys" "--end-group"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostdlib \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-STD-LIB %s
 
-// MSP430-NO-STD-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/m

[clang-tools-extra] r351319 - Fix build breakage from llvm r351317

2019-01-16 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Jan 16 02:26:52 2019
New Revision: 351319

URL: http://llvm.org/viewvc/llvm-project?rev=351319&view=rev
Log:
Fix build breakage from llvm r351317

The two-argument version of  llvm::sys::fs::make_absolute no longer
returns an error code.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=351319&r1=351318&r2=351319&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed Jan 16 02:26:52 2019
@@ -76,10 +76,7 @@ std::string MakeAbsolutePath(StringRef C
 return "";
   llvm::SmallString<128> InitialDirectory(CurrentDir);
   llvm::SmallString<128> AbsolutePath(Path);
-  if (std::error_code EC =
-  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
-llvm::errs() << "Warning: could not make absolute file: '" << EC.message()
- << '\n';
+  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath);
   return CleanPath(std::move(AbsolutePath));
 }
 

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=351319&r1=351318&r2=351319&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Jan 16 02:26:52 2019
@@ -223,9 +223,7 @@ public:
 Body = Body.ltrim('/');
 llvm::SmallVector Path(Body.begin(), Body.end());
 path::native(Path);
-auto Err = fs::make_absolute(TestScheme::TestDir, Path);
-if (Err)
-  llvm_unreachable("Failed to make absolute path in test scheme.");
+fs::make_absolute(TestScheme::TestDir, Path);
 return std::string(Path.begin(), Path.end());
   }
 


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


[PATCH] D56718: [clangd] Update docs to mention YCM integration and new LSP features

2019-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: docs/clangd.rst:129
+`Installation section on your OS
+`_ for instructions.
+

ilya-biryukov wrote:
> I believe this does not mention how to install clangd, though (and 
> libclang-based is still the default, right?) Do we want to mention how to 
> configure it to use clangd here?
That's actually the reason I haven't submitted this one for review. I am 
preparing a PR to YCM folks which will hopefully include clangd in installation 
process


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56718/new/

https://reviews.llvm.org/D56718



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added a comment.

In D55850#1358812 , @rjmccall wrote:

> Okay, so is this ready to re-review independently?


Yes, please. It should be fine to review on its own. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55850/new/

https://reviews.llvm.org/D55850



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


[clang-tools-extra] r351320 - Bump the trunk version to 9.0.0svn

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 02:57:02 2019
New Revision: 351320

URL: http://llvm.org/viewvc/llvm-project?rev=351320&view=rev
Log:
Bump the trunk version to 9.0.0svn

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/conf.py

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=351320&r1=351319&r2=351320&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Jan 16 02:57:02 2019
@@ -1,5 +1,5 @@
 ===
-Extra Clang Tools 8.0.0 (In-Progress) Release Notes
+Extra Clang Tools 9.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 8.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 9.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -32,7 +32,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 8.0.0?
+What's New in Extra Clang Tools 9.0.0?
 ==
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -57,47 +57,7 @@ The improvements are...
 Improvements to clang-query
 ---
 
-- A new command line parameter ``--preload`` was added to
-  run commands from a file and then start the interactive interpreter.
-
-- The command ``q`` can was added as an alias for ``quit`` to exit the
-  ``clang-query`` interpreter.
-
-- It is now possible to bind to named values (the result of ``let``
-  expressions). For example:
-
-  .. code-block:: none
-
-let fn functionDecl()
-match fn.bind("foo")
-
-- It is now possible to write comments in ``clang-query`` code. This
-  is primarily useful when using script-mode. Comments are all content
-  following the ``#`` character on a line:
-
-  .. code-block:: none
-
-# This is a comment
-match fn.bind("foo") # This is a trailing comment
-
-- The new ``set print-matcher true`` command now causes ``clang-query`` to
-  print the evaluated matcher together with the resulting bindings.
-
-- A new output mode ``detailed-ast`` was added to ``clang-query``. The
-  existing ``dump`` output mode is now a deprecated alias
-  for ``detailed-ast``
-
-- Output modes can now be enabled or disabled non-exclusively.  For example,
-
-  .. code-block:: none
-
-# Enable detailed-ast without disabling other output, such as diag
-enable output detailed-ast
-m functionDecl()
-
-# Disable detailed-ast only
-disable output detailed-ast
-m functionDecl()
+- ...
 
 Improvements to clang-rename
 
@@ -107,201 +67,7 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New :doc:`abseil-duration-comparison
-  ` check.
-
-  Checks for comparisons which should be done in the ``absl::Duration`` domain
-  instead of the float of integer domains.
-
-- New :doc:`abseil-duration-division
-  ` check.
-
-  Checks for uses of ``absl::Duration`` division that is done in a
-  floating-point context, and recommends the use of a function that
-  returns a floating-point value.
-
-- New :doc:`abseil-duration-factory-float
-  ` check.
-
-  Checks for cases where the floating-point overloads of various
-  ``absl::Duration`` factory functions are called when the more-efficient
-  integer versions could be used instead.
-
-- New :doc:`abseil-duration-factory-scale
-  ` check.
-
-  Checks for cases where arguments to ``absl::Duration`` factory functions are
-  scaled internally and could be changed to a different factory function.
-
-- New :doc:`abseil-duration-subtraction
-  ` check.
-
-  Checks for cases where subtraction should be performed in the
-  ``absl::Duration`` domain.
-
-- New :doc:`abseil-faster-strsplit-delimiter
-  ` check.
-
-  Finds instances of ``absl::StrSplit()`` or ``absl::MaxSplits()`` where the
-  delimiter is a single character string literal and replaces with a character.
-

r351320 - Bump the trunk version to 9.0.0svn

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 02:57:02 2019
New Revision: 351320

URL: http://llvm.org/viewvc/llvm-project?rev=351320&view=rev
Log:
Bump the trunk version to 9.0.0svn

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/conf.py

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351320&r1=351319&r2=351320&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jan 16 02:57:02 2019
@@ -1,5 +1,5 @@
 ===
-Clang 8.0.0 (In-Progress) Release Notes
+Clang 9.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Clang C/C++/Objective-C
-frontend, part of the LLVM Compiler Infrastructure, release 8.0.0. Here we
+frontend, part of the LLVM Compiler Infrastructure, release 9.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
@@ -35,7 +35,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Clang 8.0.0?
+What's New in Clang 9.0.0?
 ==
 
 Some of the major new features and improvements to Clang are listed
@@ -46,96 +46,22 @@ sections with improvements to Clang's su
 Major New Features
 --
 
-- Clang supports use of a profile remapping file, which permits
-  profile data captured for one version of a program to be applied
-  when building another version where symbols have changed (for
-  example, due to renaming a class or namespace).
-  See the :doc:`UsersManual` for details.
+- ...
 
 Improvements to Clang's diagnostics
 ^^^
 
-- ``-Wextra-semi-stmt`` is a new diagnostic that diagnoses extra semicolons,
-  much like ``-Wextra-semi``. This new diagnostic diagnoses all *unnecessary*
-  null statements (expression statements without an expression), unless: the
-  semicolon directly follows a macro that was expanded to nothing or if the
-  semicolon is within the macro itself. This applies to macros defined in 
system
-  headers as well as user-defined macros.
-
-  .. code-block:: c++
-
-  #define MACRO(x) int x;
-  #define NULLMACRO(varname)
-
-  void test() {
-; // <- warning: ';' with no preceding expression is a null statement
-
-while (true)
-  ; // OK, it is needed.
-
-switch (my_enum) {
-case E1:
-  // stuff
-  break;
-case E2:
-  ; // OK, it is needed.
-}
-
-MACRO(v0;) // Extra semicolon, but within macro, so ignored.
-
-MACRO(v1); // <- warning: ';' with no preceding expression is a null 
statement
-
-NULLMACRO(v2); // ignored, NULLMACRO expanded to nothing.
-  }
-
-- ``-Wempty-init-stmt`` is a new diagnostic that diagnoses empty 
init-statements
-  of ``if``, ``switch``, ``range-based for``, unless: the semicolon directly
-  follows a macro that was expanded to nothing or if the semicolon is within 
the
-  macro itself (both macros from system headers, and normal macros). This
-  diagnostic is in the ``-Wextra-semi-stmt`` group and is enabled in
-  ``-Wextra``.
-
-  .. code-block:: c++
-
-  void test() {
-if(; // <- warning: init-statement of 'if' is a null statement
-   true)
-  ;
-
-switch (; // <- warning: init-statement of 'switch' is a null statement
-x) {
-  ...
-}
-
-for (; // <- warning: init-statement of 'range-based for' is a null 
statement
- int y : S())
-  ;
-  }
-
+- ...
 
 Non-comprehensive list of changes in this release
 -
 
-- The experimental feature Pretokenized Headers (PTH) was removed in its
-  entirely from Clang. The feature did not properly work with about 1/3 of the
-  possible tokens available and was unmaintained.
-
-- The internals of libc++ include directory detection on MacOS have changed.
-  Instead of running a search based on the ``-resource-dir`` flag, the search
-  is now based on the path of the compiler in the filesystem. The default
-  behaviour should not change. However, if you override ``-resource-dir``
-  manually and rely on the old behaviour you will need to add appropr

[libunwind] r351320 - Bump the trunk version to 9.0.0svn

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 02:57:02 2019
New Revision: 351320

URL: http://llvm.org/viewvc/llvm-project?rev=351320&view=rev
Log:
Bump the trunk version to 9.0.0svn

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/docs/conf.py

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=351320&r1=351319&r2=351320&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Jan 16 02:57:02 2019
@@ -81,7 +81,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 8.0.0svn)
+  set(PACKAGE_VERSION 9.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

Modified: libunwind/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/conf.py?rev=351320&r1=351319&r2=351320&view=diff
==
--- libunwind/trunk/docs/conf.py (original)
+++ libunwind/trunk/docs/conf.py Wed Jan 16 02:57:02 2019
@@ -48,9 +48,9 @@ copyright = u'2011-%d, LLVM Project' % d
 # built documents.
 #
 # The short X.Y version.
-version = '8.0'
+version = '9.0'
 # The full version, including alpha/beta/rc tags.
-release = '8.0'
+release = '9.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[libunwind] r351321 - Creating release_80 branch off revision 351319

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 03:00:55 2019
New Revision: 351321

URL: http://llvm.org/viewvc/llvm-project?rev=351321&view=rev
Log:
Creating release_80 branch off revision 351319

Added:
libunwind/branches/release_80/
  - copied from r351319, libunwind/trunk/

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


[libclc] r351321 - Creating release_80 branch off revision 351319

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 03:00:55 2019
New Revision: 351321

URL: http://llvm.org/viewvc/llvm-project?rev=351321&view=rev
Log:
Creating release_80 branch off revision 351319

Added:
libclc/branches/release_80/
  - copied from r351319, libclc/trunk/

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


[PATCH] D56632: [analyzer] Track region liveness only through base regions.

2019-01-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

Thanks, LGTM! It is interesting to see if we need to traverse all the super 
regions in `scanReachableSymbols`, but if we need to change something there, I 
would prefer that to be in a separate patch. 
If visiting the whole super region chain proved to be redundant I would 
recommend removing it for clarity regardless of having a performance impact.

If you find out the reason why we need `markElementIndicesLive`, documenting 
that would also be useful. But it is also independent of this change. 
Maybe something like we could learn new information regarding the indices after 
they are dead?
Like:

  void f(int i, char *c) {
  char e = c[i];
  if (strlen(c) == 5) {
   // The value of `i` is no longer used, could be dead
   // but we did learn something new. Assuming no UB, `i <= 5` (if null 
terminated).
   // So maybe having symbols for indices around for representing the 
info above is useful?
  }
  }

One fundamental question is, do we have one property here or two?
Maybe the liveness analysis we use for leaks (and other purposes?),
and the garbage collection of symbols are inherently two different kind of 
things that are only slightly related?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56632/new/

https://reviews.llvm.org/D56632



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


[PATCH] D56735: [OpenCL] Fix overloading ranking rules to work correctly for address space coversions

2019-01-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D56735#1358222 , @rjmccall wrote:

> Is there a reason not to just do `T1.getQualifiers() == T2.getQualifiers()`?


I tried this but it causes ObjC test to fail test/SemaObjCXX/arc-overloading.mm.

  38 // Simple overloading
  39 int &f2(id __strong const *); // expected-note{{candidate function}}
  40 float &f2(id __autoreleasing const *); // expected-note{{candidate 
function}}
  41 
  42 void test_f2() {
  43   id __strong *sip;
  44   id __strong const *csip;
  45   id __weak *wip;
  46   id __autoreleasing *aip;
  47   id __unsafe_unretained *uip;
  48 
  49   // Prefer non-ownership conversions to ownership conversions.
  50   int &ir1 = f2(sip);
  51   int &ir2 = f2(csip);
  52   float &fr1 = f2(aip);
  53 
  54   f2(uip); // expected-error{{call to 'f2' is ambiguous}}
  55 }

Clang fails to resolve the overloads:

  error: 'error' diagnostics seen but not expected: 
File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
50: call to 'f2' is ambiguous
File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
52: call to 'f2' is ambiguous
  error: 'note' diagnostics seen but not expected: 
File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
39: candidate function
File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
40: candidate function
File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
39: candidate function
File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
40: candidate function

Since CVR quals for both overloads of `f2` are the same it didn't continue 
ranking the other qualifiers before. But now when it continues looking at the 
other qualifiers it finds that `__strong` and `__autoreleasing` are disjoint 
and exits at the following return statement in 
`CompareQualificationConversions`:

  } else {
// Qualifiers are disjoint.
return ImplicitConversionSequence::Indistinguishable;
  }

I feel the logic here doesn't apply to this case because it doesn't take into 
account that for the passed in function argument there is no ownership 
qualification conversion for one of the overloads. But I don't have a good idea 
how to fix this easily other than just keep fast pathing  ObjC qual here.

May be if we add a separate qualification conversion for ObjC ownership 
qualification only we will end up with more conversion steps for one overload 
and therefore it will be possible to resolve the ambiguity? Do you have any 
other suggestions or do you think someone else could help?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56735/new/

https://reviews.llvm.org/D56735



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 182012.
Anastasia added a comment.

Fixed wording on the comment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55850/new/

https://reviews.llvm.org/D55850

Files:
  include/clang/Sema/ParsedAttr.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/method-overload-address-space.cl
  test/SemaOpenCLCXX/method-overload-address-space.cl

Index: test/SemaOpenCLCXX/method-overload-address-space.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/method-overload-address-space.cl
@@ -0,0 +1,20 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+
+struct C {
+  void m1() __local __local; //expected-warning{{multiple identical address spaces specified for type}}
+  //expected-note@-1{{candidate function}}
+  void m1() __global;
+  //expected-note@-1{{candidate function}}
+  void m2() __global __local; //expected-error{{multiple address spaces specified for type}}
+};
+
+__global C c_glob;
+
+__kernel void bar() {
+  __local C c_loc;
+  C c_priv;
+
+  c_glob.m1();
+  c_loc.m1();
+  c_priv.m1(); //expected-error{{no matching member function for call to 'm1'}}
+}
Index: test/CodeGenOpenCLCXX/method-overload-address-space.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/method-overload-address-space.cl
@@ -0,0 +1,35 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct C {
+  void foo() __local;
+  void foo() __global;
+  void foo();
+  void bar();
+};
+
+__global C c1;
+
+__kernel void k() {
+  __local C c2;
+  C c3;
+  __global C &c_ref = c1;
+  __global C *c_ptr;
+
+  // CHECK: call void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c1.foo();
+  // CHECK: call void @_ZNU3AS31C3fooEv(%struct.C addrspace(3)*
+  c2.foo();
+  // CHECK: call void @_ZNU3AS41C3fooEv(%struct.C addrspace(4)*
+  c3.foo();
+  // CHECK: call void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c_ptr->foo();
+  // CHECK: void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c_ref.foo();
+
+  // CHECK: call void @_ZNU3AS41C3barEv(%struct.C addrspace(4)* addrspacecast (%struct.C addrspace(1)* @c1 to %struct.C addrspace(4)*))
+  c1.bar();
+  //FIXME: Doesn't compile yet
+  //c_ptr->bar();
+  // CHECK: call void @_ZNU3AS41C3barEv(%struct.C addrspace(4)* addrspacecast (%struct.C addrspace(1)* @c1 to %struct.C addrspace(4)*))
+  c_ref.bar();
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3916,6 +3916,25 @@
   llvm_unreachable("unknown NullabilityKind");
 }
 
+// Diagnose whether this is a case with the multiple addr spaces.
+// Returns true if this is an invalid case.
+// ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified
+// by qualifiers for two or more different address spaces."
+static bool DiagnoseMultipleAddrSpaceAttributes(Sema &S, LangAS ASOld,
+LangAS ASNew,
+SourceLocation AttrLoc) {
+  if (ASOld != LangAS::Default) {
+if (ASOld != ASNew) {
+  S.Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
+  return true;
+} else
+  // Emit a warning if they are identical; it's likely unintended.
+  S.Diag(AttrLoc,
+ diag::warn_attribute_address_multiple_identical_qualifiers);
+  }
+  return false;
+}
+
 static TypeSourceInfo *
 GetTypeSourceInfoForDeclarator(TypeProcessingState &State,
QualType T, TypeSourceInfo *ReturnTypeInfo);
@@ -4823,18 +4842,35 @@
   Exceptions,
   EPI.ExceptionSpec);
 
-const auto &Spec = D.getCXXScopeSpec();
+// FIXME: Set address space from attrs for C++ mode here.
 // OpenCLCPlusPlus: A class member function has an address space.
-if (state.getSema().getLangOpts().OpenCLCPlusPlus &&
-((!Spec.isEmpty() &&
-  Spec.getScopeRep()->getKind() == NestedNameSpecifier::TypeSpec) ||
- state.getDeclarator().getContext() ==
- DeclaratorContext::MemberContext)) {
-  LangAS CurAS = EPI.TypeQuals.getAddressSpace();
+auto IsClassMember = [&]() {
+  return (!state.getDeclarator().getCXXScopeSpec().isEmpty() &&
+  state.getDeclarator()
+  .getCXXScopeSpec()
+  .getScopeRep()
+  ->getKind() == NestedNameSpecifier::TypeSpec) ||
+ state.getDeclarator().getContext() ==
+ DeclaratorContext::MemberContext;
+};
+
+if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
+  LangAS ASIdx = LangAS::Default;
+  /

[PATCH] D56632: [analyzer] Track region liveness only through base regions.

2019-01-16 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/symbol-reaper.cpp:31
+  clang_analyzer_eval(glob); // expected-warning{{TRUE}}
+ // expected-warning@-1{{SYMBOL DEAD}}
+}

NoQ wrote:
> Szelethus wrote:
> > N00b question: What does `SYMBOL DEAD` mean here exactly?
> It's a warning produced by `clang_analyzer_warnOnDeadSymbol(a.x)` when the 
> value that was in `a.x` (that was there when that function was called) dies. 
> This is an `ExprInspection` utility that was created in order to test 
> `SymbolReaper` more directly. See `symbol-reaper.c` for more such tests.
Oooh right. I thought it's produced by `clang_analyzer_eval(glob);`. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56632/new/

https://reviews.llvm.org/D56632



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


[PATCH] D56751: [ASTDump] Mark variadic declarations with a tag instead of child node

2019-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you add a test for a variadic lambda in C++ as well? I suspect it will work 
out of the box, but the extra test coverage would be good to have. We should 
probably have a K&R C function example as well to ensure it doesn't print as 
variadic. e.g., `void func();` in C mode.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56751/new/

https://reviews.llvm.org/D56751



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


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Will take a look.
For reference: the particular failing test was added in r351222 (D56680 
), not in this change.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54630/new/

https://reviews.llvm.org/D54630



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


[PATCH] D56753: [ASTDump] Mark null params with a tag rather than a child node

2019-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Do we have any test coverage for this change? IIRC, this was one we couldn't 
figure out how to trigger?




Comment at: lib/AST/ASTDumper.cpp:637
+  if (!D->param_begin() && D->getNumParams())
+OS << " >";
+

Extra whitespace at the start of the string literal, or is that intentional? 
Also, do we want to standardize on `<<>>` with three brackets instead of 
two?



Comment at: lib/AST/ASTDumper.cpp:642
 
-  if (!D->param_begin() && D->getNumParams())
-dumpChild([=] { OS << ">"; });
-  else
-for (const ParmVarDecl *Parameter : D->parameters())
+  if (D->param_begin() || !D->getNumParams())
+for (const auto *Parameter : D->parameters())

You can drop `getNumParams()` here -- if `param_begin()` returns a non-null 
value, `getNumParams()` must return a non-zero value.

(`param_begin()` is implemented in terms of `parameters()`, which calls 
`getNumParams()` when setting up the returned `ArrayRef`.)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56753/new/

https://reviews.llvm.org/D56753



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


r351334 - Set '-target' flag in the test checking the MacOS include dir

2019-01-16 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jan 16 05:18:59 2019
New Revision: 351334

URL: http://llvm.org/viewvc/llvm-project?rev=351334&view=rev
Log:
Set '-target' flag in the test checking the MacOS include dir

To fix a buildbot failure on PS4, see
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/42251

The test was added in r351222 and aims to check only a particular
Mac configuration. However it relied on the default compiler target
by default, therefore unintentionally failing on PS4.

Modified:
cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp

Modified: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351334&r1=351333&r2=351334&view=diff
==
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(original)
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp Wed 
Jan 16 05:18:59 2019
@@ -10,7 +10,7 @@
 //
 // RUN: cp $(which clang-check) %t/mock-libcxx/bin/
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- -stdlib=libc++
+// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- -stdlib=libc++ 
-target x86_64-apple-darwin
 
 #include 
 vector v;


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


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

r351334 should fix this.
However, this is an indication that libc++ living alongside the compiler (i.e. 
in `/bin/../include/c++/v1`) cannot be found on PS4.
I am not familiar with PS4 myself, but I believe it would be reasonable to 
assume finding libc++ living alongside the clang itself should work on all 
platforms, including PS4.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54630/new/

https://reviews.llvm.org/D54630



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


[PATCH] D56752: [ASTDump] Mark BlockDecls which capture this with a tag

2019-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Was there no test coverage for this situation? If not, can you add some?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56752/new/

https://reviews.llvm.org/D56752



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


[PATCH] D56753: [ASTDump] Mark null params with a tag rather than a child node

2019-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTDumper.cpp:637
+  if (!D->param_begin() && D->getNumParams())
+OS << " >";
+

aaron.ballman wrote:
> Extra whitespace at the start of the string literal, or is that intentional? 
> Also, do we want to standardize on `<<>>` with three brackets instead 
> of two?
Ah, I understand the whitespace now, so that was intentional I believe. 
Question remains about whether we want to also switch to use `<<<` consistently 
remains though.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56753/new/

https://reviews.llvm.org/D56753



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


[libunwind] r351338 - Drop svn version suffix

2019-01-16 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 16 05:27:08 2019
New Revision: 351338

URL: http://llvm.org/viewvc/llvm-project?rev=351338&view=rev
Log:
Drop svn version suffix

Modified:
libunwind/branches/release_80/CMakeLists.txt

Modified: libunwind/branches/release_80/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_80/CMakeLists.txt?rev=351338&r1=351337&r2=351338&view=diff
==
--- libunwind/branches/release_80/CMakeLists.txt (original)
+++ libunwind/branches/release_80/CMakeLists.txt Wed Jan 16 05:27:08 2019
@@ -81,7 +81,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 8.0.0svn)
+  set(PACKAGE_VERSION 8.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


r351340 - [MSP430] Fix msp430-toolchain.c on Windows (added in r351228)

2019-01-16 Thread Anton Korobeynikov via cfe-commits
Author: asl
Date: Wed Jan 16 05:28:30 2019
New Revision: 351340

URL: http://llvm.org/viewvc/llvm-project?rev=351340&view=rev
Log:
[MSP430] Fix msp430-toolchain.c on Windows (added in r351228)

Patch by Kristina Bessonova!

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


Modified:
cfe/trunk/test/Driver/msp430-toolchain.c

Modified: cfe/trunk/test/Driver/msp430-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msp430-toolchain.c?rev=351340&r1=351339&r2=351340&view=diff
==
--- cfe/trunk/test/Driver/msp430-toolchain.c (original)
+++ cfe/trunk/test/Driver/msp430-toolchain.c Wed Jan 16 05:28:30 2019
@@ -8,44 +8,44 @@
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430 %s
 
-// MSP430: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crt0.o"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o"
+// MSP430: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crt0.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtbegin.o"
 // MSP430: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" "-lnosys" 
"--end-group"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crtn.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtend.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crtn.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-DFT-LIB %s
 
-// MSP430-NO-DFT-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430-NO-DFT-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crt0.o"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o"
+// MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crt0.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtbegin.o"
 // MSP430-NO-DFT-LIB: "--start-group" "-lmul_none" "-lgcc" "--end-group"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crtn.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtend.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crtn.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-START %s
 
-// MSP430-NO-START: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430-NO-START: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
+// MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
 // MSP430-NO-START: 

[PATCH] D56776: [MSP430] Fix msp430-toolchain.c on Windows (added in rL351228)

2019-01-16 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351340: [MSP430] Fix msp430-toolchain.c on Windows (added in 
r351228) (authored by asl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56776?vs=181998&id=182017#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56776/new/

https://reviews.llvm.org/D56776

Files:
  test/Driver/msp430-toolchain.c


Index: test/Driver/msp430-toolchain.c
===
--- test/Driver/msp430-toolchain.c
+++ test/Driver/msp430-toolchain.c
@@ -8,44 +8,44 @@
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430 %s
 
-// MSP430: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crt0.o"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o"
+// MSP430: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crt0.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtbegin.o"
 // MSP430: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" "-lnosys" 
"--end-group"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o"
-// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crtn.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtend.o"
+// MSP430: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crtn.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-DFT-LIB %s
 
-// MSP430-NO-DFT-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430-NO-DFT-LIB: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crt0.o"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o"
+// MSP430-NO-DFT-LIB: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crt0.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtbegin.o"
 // MSP430-NO-DFT-LIB: "--start-group" "-lmul_none" "-lgcc" "--end-group"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o"
-// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430/crtn.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|}}crtend.o"
+// MSP430-NO-DFT-LIB: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430{{/|}}crtn.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-NO-START %s
 
-// MSP430-NO-START: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../bin/msp430-elf-ld"
+// MSP430-NO-START: 
"{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430"
-// MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../../../msp430-elf/lib/430"
+// MSP430-NO-START: 
"-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|}}..{{/|}}msp430-elf{{/|}}lib/430"
 // MSP430-NO-START: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" 
"-lnosys" "--end-group"
 
 // RUN: %clang

Re: r351334 - Set '-target' flag in the test checking the MacOS include dir

2019-01-16 Thread Hans Wennborg via cfe-commits
Merged to 8.0 in r351343.

On Wed, Jan 16, 2019 at 2:22 PM Ilya Biryukov via cfe-commits
 wrote:
>
> Author: ibiryukov
> Date: Wed Jan 16 05:18:59 2019
> New Revision: 351334
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351334&view=rev
> Log:
> Set '-target' flag in the test checking the MacOS include dir
>
> To fix a buildbot failure on PS4, see
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/42251
>
> The test was added in r351222 and aims to check only a particular
> Mac configuration. However it relied on the default compiler target
> by default, therefore unintentionally failing on PS4.
>
> Modified:
> cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
>
> Modified: 
> cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351334&r1=351333&r2=351334&view=diff
> ==
> --- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
> (original)
> +++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
> Wed Jan 16 05:18:59 2019
> @@ -10,7 +10,7 @@
>  //
>  // RUN: cp $(which clang-check) %t/mock-libcxx/bin/
>  // RUN: cp "%s" "%t/test.cpp"
> -// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- 
> -stdlib=libc++
> +// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- 
> -stdlib=libc++ -target x86_64-apple-darwin
>
>  #include 
>  vector v;
>
>
> ___
> 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


r351344 - [MSP430] Improve support of 'interrupt' attribute

2019-01-16 Thread Anton Korobeynikov via cfe-commits
Author: asl
Date: Wed Jan 16 05:44:01 2019
New Revision: 351344

URL: http://llvm.org/viewvc/llvm-project?rev=351344&view=rev
Log:
[MSP430] Improve support of 'interrupt' attribute

* Accept as an argument constants in range 0..63 (aligned with TI headers and 
linker scripts provided with TI GCC toolchain).
* Emit function attribute 'interrupt'='xx' instead of aliases (used in the 
backend to create a section for particular interrupt vector).
* Add more diagnostics.

Patch by Kristina Bessonova!

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

Added:
cfe/trunk/test/CodeGen/attr-msp430.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-msp430.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351344&r1=351343&r2=351344&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan 16 05:44:01 
2019
@@ -274,6 +274,10 @@ def warn_riscv_interrupt_attribute : War
"RISC-V 'interrupt' attribute only applies to functions that have "
"%select{no parameters|a 'void' return type}0">,
InGroup;
+def warn_msp430_interrupt_attribute : Warning<
+   "MSP430 'interrupt' attribute only applies to functions that have "
+   "%select{no parameters|a 'void' return type}0">,
+   InGroup;
 def warn_unused_parameter : Warning<"unused parameter %0">,
   InGroup, DefaultIgnore;
 def warn_unused_variable : Warning<"unused variable %0">,

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=351344&r1=351343&r2=351344&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jan 16 05:44:01 2019
@@ -6774,21 +6774,19 @@ void MSP430TargetCodeGenInfo::setTargetA
   if (GV->isDeclaration())
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
-if (const MSP430InterruptAttr *attr = FD->getAttr()) {
-  // Handle 'interrupt' attribute:
-  llvm::Function *F = cast(GV);
+const auto *InterruptAttr = FD->getAttr();
+if (!InterruptAttr)
+  return;
 
-  // Step 1: Set ISR calling convention.
-  F->setCallingConv(llvm::CallingConv::MSP430_INTR);
+// Handle 'interrupt' attribute:
+llvm::Function *F = cast(GV);
 
-  // Step 2: Add attributes goodness.
-  F->addFnAttr(llvm::Attribute::NoInline);
+// Step 1: Set ISR calling convention.
+F->setCallingConv(llvm::CallingConv::MSP430_INTR);
 
-  // Step 3: Emit ISR vector alias.
-  unsigned Num = attr->getNumber() / 2;
-  llvm::GlobalAlias::create(llvm::Function::ExternalLinkage,
-"__isr_" + Twine(Num), F);
-}
+// Step 2: Add attributes goodness.
+F->addFnAttr(llvm::Attribute::NoInline);
+F->addFnAttr("interrupt", llvm::utostr(InterruptAttr->getNumber()));
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=351344&r1=351343&r2=351344&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan 16 05:44:01 2019
@@ -5377,6 +5377,27 @@ static void handleARMInterruptAttr(Sema
 }
 
 static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // MSP430 'interrupt' attribute is applied to
+  // a function with no parameters and void return type.
+  if (!isFunctionOrMethod(D)) {
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< "'interrupt'" << ExpectedFunctionOrMethod;
+return;
+  }
+
+  if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
+S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
+<< 0;
+return;
+  }
+
+  if (!getFunctionOrMethodResultType(D)->isVoidType()) {
+S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
+<< 1;
+return;
+  }
+
+  // The attribute takes one integer argument.
   if (!checkAttributeNumArgs(S, AL, 1))
 return;
 
@@ -5386,8 +5407,6 @@ static void handleMSP430InterruptAttr(Se
 return;
   }
 
-  // FIXME: Check for decl - it should be void ()(void).
-
   Expr *NumParamsExpr = static_cast(AL.getArgAsExpr(0));
   llvm::APSInt NumParams(32);
   if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) {
@@ -5396,9 +5415,9 @@ static void handleMSP430InterruptAttr(Se
 << NumParamsExpr->getSourceRange();
 return;
   }
-
+  // The argument should be in range 0..63.
   unsigned Num = Num

[PATCH] D56663: [MSP430] Improve support of 'interrupt' attribute

2019-01-16 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351344: [MSP430] Improve support of 'interrupt' 
attribute (authored by asl, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56663/new/

https://reviews.llvm.org/D56663

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/attr-msp430.c
  cfe/trunk/test/Sema/attr-msp430.c

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -5377,6 +5377,27 @@
 }
 
 static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // MSP430 'interrupt' attribute is applied to
+  // a function with no parameters and void return type.
+  if (!isFunctionOrMethod(D)) {
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< "'interrupt'" << ExpectedFunctionOrMethod;
+return;
+  }
+
+  if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
+S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
+<< 0;
+return;
+  }
+
+  if (!getFunctionOrMethodResultType(D)->isVoidType()) {
+S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
+<< 1;
+return;
+  }
+
+  // The attribute takes one integer argument.
   if (!checkAttributeNumArgs(S, AL, 1))
 return;
 
@@ -5386,8 +5407,6 @@
 return;
   }
 
-  // FIXME: Check for decl - it should be void ()(void).
-
   Expr *NumParamsExpr = static_cast(AL.getArgAsExpr(0));
   llvm::APSInt NumParams(32);
   if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) {
@@ -5396,9 +5415,9 @@
 << NumParamsExpr->getSourceRange();
 return;
   }
-
+  // The argument should be in range 0..63.
   unsigned Num = NumParams.getLimitedValue(255);
-  if ((Num & 1) || Num > 30) {
+  if (Num > 63) {
 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
 << AL << (int)NumParams.getSExtValue()
 << NumParamsExpr->getSourceRange();
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6774,21 +6774,19 @@
   if (GV->isDeclaration())
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
-if (const MSP430InterruptAttr *attr = FD->getAttr()) {
-  // Handle 'interrupt' attribute:
-  llvm::Function *F = cast(GV);
+const auto *InterruptAttr = FD->getAttr();
+if (!InterruptAttr)
+  return;
 
-  // Step 1: Set ISR calling convention.
-  F->setCallingConv(llvm::CallingConv::MSP430_INTR);
+// Handle 'interrupt' attribute:
+llvm::Function *F = cast(GV);
 
-  // Step 2: Add attributes goodness.
-  F->addFnAttr(llvm::Attribute::NoInline);
+// Step 1: Set ISR calling convention.
+F->setCallingConv(llvm::CallingConv::MSP430_INTR);
 
-  // Step 3: Emit ISR vector alias.
-  unsigned Num = attr->getNumber() / 2;
-  llvm::GlobalAlias::create(llvm::Function::ExternalLinkage,
-"__isr_" + Twine(Num), F);
-}
+// Step 2: Add attributes goodness.
+F->addFnAttr(llvm::Attribute::NoInline);
+F->addFnAttr("interrupt", llvm::utostr(InterruptAttr->getNumber()));
   }
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -274,6 +274,10 @@
"RISC-V 'interrupt' attribute only applies to functions that have "
"%select{no parameters|a 'void' return type}0">,
InGroup;
+def warn_msp430_interrupt_attribute : Warning<
+   "MSP430 'interrupt' attribute only applies to functions that have "
+   "%select{no parameters|a 'void' return type}0">,
+   InGroup;
 def warn_unused_parameter : Warning<"unused parameter %0">,
   InGroup, DefaultIgnore;
 def warn_unused_variable : Warning<"unused variable %0">,
Index: cfe/trunk/test/Sema/attr-msp430.c
===
--- cfe/trunk/test/Sema/attr-msp430.c
+++ cfe/trunk/test/Sema/attr-msp430.c
@@ -1,6 +1,13 @@
 // RUN: %clang_cc1 -triple msp430-unknown-unknown -fsyntax-only -verify %s
 
+__attribute__((interrupt(1))) int t; // expected-warning {{'interrupt' attribute only applies to functions}}
+
 int i;
-void f(void) __attribute__((interrupt(i))); /* expected-error {{'interrupt' attribute requires an integer constant}} */
+__attribute__((interrupt(i))) void f(void); // expected-error {{'interrupt' attribute requires an integer constant}}
+__attribute__((interrupt(1, 2))) void f2(void); // expected-error {{'interrupt

[PATCH] D56663: [MSP430] Improve support of 'interrupt' attribute

2019-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:5388
+
+  if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
+S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)

What should happen if the function does not have a prototype? Should that be 
diagnosed? e.g., a K&R C function in C mode accepts an arbitrary number of 
arguments (which can include zero).


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56663/new/

https://reviews.llvm.org/D56663



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


Re: r351160 - [X86] Make _xgetbv/_xsetbv on non-windows platforms

2019-01-16 Thread Benjamin Kramer via cfe-commits
v8 is fixed, feel free to land this after the release branch :)

On Wed, Jan 16, 2019 at 12:57 AM Craig Topper 
wrote:

> This isn't blocking anything. Just doing some archaeology because I
> noticed we had an intrinsic in the backend, but it wasn't used by the
> frontend due to a previous revert a couple years ago.
>
> ~Craig
>
>
> On Tue, Jan 15, 2019 at 3:47 PM Benjamin Kramer 
> wrote:
>
>> I think the only viable solution is to make v8 not define reserved
>> identifiers & reland this change. That will take some time, so unless this
>> is blocking something important I'd prefer to reland after the release cut
>> so the world can catch up before the next release. I can take care of
>> sending v8 a patch if nobody else feels like doing it.
>>
>> On Tue, Jan 15, 2019 at 11:28 PM Craig Topper 
>> wrote:
>>
>>> any suggestions on how to proceed here?
>>>
>>> ~Craig
>>>
>>>
>>> On Tue, Jan 15, 2019 at 10:56 AM Benjamin Kramer 
>>> wrote:
>>>
 I think the main issue is that libstdc++ 4.9 includes x86intrin.h
 transitively from . That's probably broken with all compilers :(

 On Tue, Jan 15, 2019 at 7:31 PM Craig Topper 
 wrote:

> Does V8 work with gcc which also has _xgetbv? Or is it because I had
> to make _xgetbv a macro to make the patch work?
>
> ~Craig
>
>
> On Tue, Jan 15, 2019 at 9:28 AM Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> I rolled it back for now in r351210, this pattern seems to be quite
>> common even outside of v8. Let's figure out if we can keep the code 
>> working
>> or if it needs to be fixed all over the place :(
>>
>> On Tue, Jan 15, 2019 at 3:02 PM Benjamin Kramer 
>> wrote:
>>
>>> I'm seeing breakages on v8 with this, it defines its own _xgetbv.
>>> Any ideas what do do about this?
>>>
>>>
>>> https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36
>>>
>>> src/x64/assembler-x64.cc:35:1: error: inline variables are
>>> incompatible with C++ standards before C++17
>>> [-Werror,-Wc++98-c++11-c++14-compat]
>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>> ^
>>> include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'
>>> # define V8_INLINE inline __attribute__((always_inline))
>>>^
>>> src/x64/assembler-x64.cc:35:41: error: expected ')'
>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>> ^
>>> src/x64/assembler-x64.cc:35:20: note: to match this '('
>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>^
>>> lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro
>>> '_xgetbv'
>>> #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))
>>>
>>> On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ctopper
 Date: Mon Jan 14 21:03:18 2019
 New Revision: 351160

 URL: http://llvm.org/viewvc/llvm-project?rev=351160&view=rev
 Log:
 [X86] Make _xgetbv/_xsetbv on non-windows platforms

 Summary:
 This patch attempts to redo what was tried in r278783, but was
 reverted.

 These intrinsics should be available on non-windows platforms with
 "xsave" feature check. But on Windows platforms they shouldn't have 
 feature
 check since that's how MSVC behaves.

 To accomplish this I've added a MS builtin with no feature check.
 And a normal gcc builtin with a feature check. When _MSC_VER is not 
 defined
 _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.

 I've moved the forward declarations from intrin.h to immintrin.h to
 match the MSDN documentation and used that as the header file for the 
 MS
 builtin.

 I'm not super happy with this implementation, and I'm open to
 suggestions for better ways to do it.

 Reviewers: rnk, RKSimon, spatel

 Reviewed By: rnk

 Subscribers: cfe-commits

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

 Modified:
 cfe/trunk/include/clang/Basic/BuiltinsX86.def
 cfe/trunk/lib/CodeGen/CGBuiltin.cpp
 cfe/trunk/lib/Headers/immintrin.h
 cfe/trunk/lib/Headers/intrin.h
 cfe/trunk/lib/Headers/xsaveintrin.h
 cfe/trunk/test/CodeGen/builtins-x86.c
 cfe/trunk/test/CodeGen/x86_32-xsave.c
 cfe/trunk/test/CodeGen/x86_64-xsave.c
 cfe/trunk/test/Headers/ms-intrin.cpp

 Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX8

[PATCH] D55447: [Sema] Fix Modified Type in address_space AttributedType

2019-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/tools/libclang/CXType.cpp:132
+  if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes) &&
+  ATT->getAttrKind() != attr::AddressSpace) {
 return MakeCXType(ATT->getModifiedType(), TU);

leonardchan wrote:
> aaron.ballman wrote:
> > leonardchan wrote:
> > > leonardchan wrote:
> > > > aaron.ballman wrote:
> > > > > leonardchan wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > leonardchan wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > leonardchan wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > leonardchan wrote:
> > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > This change seems surprising -- if the parsing 
> > > > > > > > > > > > > options say the caller does not want attributed 
> > > > > > > > > > > > > types, why are we returning one anyway for address 
> > > > > > > > > > > > > space?
> > > > > > > > > > > > This has to do with ensuring `clang_getAddressSpace` 
> > > > > > > > > > > > still returns the proper address_space. It does this by 
> > > > > > > > > > > > essentially checking the qualifiers of the type, which 
> > > > > > > > > > > > we now attach to the `AttributedType` whereas before it 
> > > > > > > > > > > > was attached to the modified type.
> > > > > > > > > > > > 
> > > > > > > > > > > > This extra condition is necessary for ensuring that 
> > > > > > > > > > > > calling `clang_getAddressSpace` points to the qualified 
> > > > > > > > > > > > AttributedType instead of the unqualified modified type.
> > > > > > > > > > > My fear is that this will be breaking assumptions in 
> > > > > > > > > > > third-party code. If someone disables 
> > > > > > > > > > > `CXTranslationUnit_IncludeAttributedTypes`, they are 
> > > > > > > > > > > unlikely to expect to receive an `AttributedType` and may 
> > > > > > > > > > > react poorly to it.
> > > > > > > > > > Instead check if the type is address_space attributed and 
> > > > > > > > > > apply the qualifiers the modified type.
> > > > > > > > > Sure, they can always modify their code to handle it 
> > > > > > > > > gracefully, but it's a silent, breaking change to a somewhat 
> > > > > > > > > stable API which is why I was prodding about it.
> > > > > > > > > 
> > > > > > > > > After talking with @rsmith, we're thinking the correct change 
> > > > > > > > > here is to return the attributed type when the user asks for 
> > > > > > > > > it, but return the equivalent type rather than the modified 
> > > > > > > > > type if the user doesn't want attribute sugar (for all 
> > > > > > > > > attributes, not just address spaces). This way, when a user 
> > > > > > > > > asks for CXType for one of these, they always get a correct 
> > > > > > > > > type but sometimes it has attribute type sugar and sometimes 
> > > > > > > > > it doesn't, depending on the parsing options.
> > > > > > > > > 
> > > > > > > > > This is still a silent, breaking change in behavior, which is 
> > > > > > > > > unfortunate. It should probably come with a mention in the 
> > > > > > > > > release notes about the change to the API and some unit tests 
> > > > > > > > > as well.
> > > > > > > > Ok. In the case of qualifiers then, should the equivalent type 
> > > > > > > > still contain the address_space qualifiers when creating the 
> > > > > > > > AttributedType?
> > > > > > > I believe so, yes -- that would ensure it's the minimally 
> > > > > > > desugared type which the type is canonically equivalent to.
> > > > > > Sorry for the holdup. So for an AddressSpace AttributedType, we 
> > > > > > attach the qualifiers only to the equivalent type.
> > > > > > 
> > > > > > As for this though, the only problem I ran into with returning the 
> > > > > > equivalent type is for AttributedTypes with `attr::ObjCKindOf`, a 
> > > > > > test expects returning the modified type which is an 
> > > > > > `ObjCInterface` instead of the equivalent type which is an 
> > > > > > `ObjCObject`. The test itself just tests printing of a type, but 
> > > > > > I'm not sure how significant or intentional printing this specific 
> > > > > > way was.
> > > > > Which test was failing because of this?
> > > > clang/test/Index/print-type.m
> > > Specifically just the check:
> > > 
> > > ```
> > > CHECK: ParmDecl=p:6:36 (Definition) [type=__kindof Foo *] 
> > > [typekind=ObjCObjectPointer] [canonicaltype=__kindof Foo *] 
> > > [canonicaltypekind=ObjCObjectPointer] [basetype=Foo] 
> > > [basekind=ObjCInterface] [isPOD=1] [pointeetype=Foo] 
> > > [pointeekind=ObjCInterface]
> > > ```
> > > 
> > > Where the last 2 fields we're instead `[pointeetype=__kindof Foo] 
> > > [pointeekind=ObjCObject]` instead of what they are now.
> > I looked at the review adding the impacted test case and I did not have the 
> > impression this was a principled decision so much as "that's what it 
> > prints". I suspect we'd be fine removing the hack an

Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-16 Thread Aaron Ballman via cfe-commits
On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka  wrote:
>
> Yes, the behavior of the compiler doesn’t match what’s explained in the 
> documentation anymore.
>
> Please take a look at the attached patch, which updates the documentation.

Patch mostly LGTM, but I did have one wording suggestion.

> diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td
> index 5773a92c9c..ca3cfcf9b2 100644
> --- a/include/clang/Basic/AttrDocs.td
> +++ b/include/clang/Basic/AttrDocs.td
> @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
>let Category = DocCatVariable;
>let Content = [{
>  The ``trivial_abi`` attribute can be applied to a C++ class, struct, or 
> union.
> -It instructs the compiler to pass and return the type using the C ABI for the
> +``trivial_abi`` has the following effects:
> +
> +- It instructs the compiler to pass and return the type using the C ABI for 
> the
>  underlying type when the type would otherwise be considered non-trivial for 
> the
>  purpose of calls.
> -A class annotated with `trivial_abi` can have non-trivial destructors or 
> copy/move constructors without automatically becoming non-trivial for the 
> purposes of calls. For example:
> +- It makes the destructor and copy and move constructors of the class trivial
> +that would otherwise be considered non-trivial under the C++ ABI rules.

How about: It makes the destructor, copy constructors, and move
constructors of the class trivial even if they would otherwise be
non-trivial under the C++ ABI rules.

~Aaron

> +
> +For example:
>
>.. code-block:: c++
>
> -// A is trivial for the purposes of calls because `trivial_abi` makes the
> -// user-provided special functions trivial.
> +// A is trivial for the purposes of calls despite having a destructor and
> +// copy and move constructors that are non-trivial under the C++ ABI 
> rules.
>  struct __attribute__((trivial_abi)) A {
>~A();
>A(const A &);
> @@ -2495,11 +2500,26 @@ A class annotated with `trivial_abi` can have 
> non-trivial destructors or copy/mo
>  };
>
>  // B's destructor and copy/move constructor are considered trivial for 
> the
> -// purpose of calls because A is trivial.
> +// purpose of calls because A's destructor and copy and move constructors
> +// are treated as being trivial.
>  struct B {
>A a;
>  };
>
> +// C is trivial for the purposes of calls despite having all of its copy 
> and
> +// move constructors deleted.
> +struct __attribute__((trivial_abi)) C {
> +  C(const C &) = delete;
> +  C(C &&) = delete;
> +  int x;
> +};
> +
> +// D is non-trivial for the purposes of calls since it isn't annotated 
> with
> +// trivial_abi and all of its copy and move constructors are deleted.
> +struct D {
> +  C c;
> +};
> +
>  If a type is trivial for the purposes of calls, has a non-trivial destructor,
>  and is passed as an argument by value, the convention is that the callee will
>  destroy the object before returning.
>
>
>
>
> CC’ing a couple more people who commented on the original patch.
>
> On Jan 10, 2019, at 11:30 PM, Richard Smith  wrote:
>
> This is an ABI break (theoretically), but due to its nature I'm not too 
> concerned.
>
> Please update the documentation for the attribute to describe these new 
> semantics, though: the documentation currently says that we're just treating 
> certain special members as if they were trivial when determining whether we 
> can pass in registers, and that's not true any more, because the ABI says 
> that classes with only deleted copy and move ctors is never passed in 
> registers regardless of triviality.
>
> On Thu, 10 Jan 2019, 23:10 Akira Hatanaka via cfe-commits 
> >
>> Author: ahatanak
>> Date: Thu Jan 10 23:06:38 2019
>> New Revision: 350920
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=350920&view=rev
>> Log:
>> [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed
>> to it is a trivial_abi class.
>>
>> A class that has all of its copy and move constructors deleted can still
>> be passed or returned in registers if the class is annotated with
>> trivial_abi.
>>
>> This fixes PR39683.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/test/CodeGenCXX/trivial_abi.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=350920&r1=350919&r2=350920&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jan 10 23:06:38 2019
>> @@ -5886,6 +5886,9 @@ static bool canPassInRegisters(Sema &S,
>>if (D->isDependentType() || D->isInvalidDecl())
>>  return false;
>>
>> +  if (D->hasAttr())
>> +return true;
>> +
>>// Clang <= 4 used the pre-C++11 rule, which ignores move operations.
>>// The

Re: r351316 - Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-16 Thread Jeremy Morse via cfe-commits
Hi Sam,

Unfortunately this trips up a variety of buildbots:

http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/22376
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15053
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/22376
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/3401
http://lab.llvm.org:8011/builders/lldb-amd64-ninja-netbsd8/builds/18177

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/22919

For the Windows machines at least, I don't believe lit can cope with
replicating shell subprocesses and thus the use of $(which...). (I could be
wrong there, but it matches up with the error messages).

"clang-check-mac-libcxx-fixed-compilation-db.cpp" sounds like it's
mac-specific, maybe only "REQUIRES: system-darwin" is needed?

--
Thanks,
Jeremy


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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-16 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added a comment.

Changes still look reasonable, but the preceding path 
(https://reviews.llvm.org/D56769) needs some work.




Comment at: lib/CodeGen/CGDebugInfo.cpp:607
   llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
+  MainFileName, remapDIPath(getCurrentDirname()), CSInfo,
   getSource(SM, SM.getMainFileID()));

Any reason for dropping `remapDIPath` here? Wouldn't this result in the full 
path being included even when using:

clang -fdebug-prefix-map=/full/path/= /full/path/source.c



Comment at: lib/Lex/PPMacroExpansion.cpp:1466
+  for (const auto &Entry : MacroPrefixMap)
+if(llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+  break;

Style: space between `if` and `(`


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-16 Thread Dan McGregor via Phabricator via cfe-commits
dankm marked an inline comment as done.
dankm added a comment.

  I'll update the style nit, and spend some non-tired time on the string 
remapping. Thanks




Comment at: lib/CodeGen/CGDebugInfo.cpp:607
   llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
+  MainFileName, remapDIPath(getCurrentDirname()), CSInfo,
   getSource(SM, SM.getMainFileID()));

Lekensteyn wrote:
> Any reason for dropping `remapDIPath` here? Wouldn't this result in the full 
> path being included even when using:
> 
> clang -fdebug-prefix-map=/full/path/= /full/path/source.c
Whoops. That probably shouldn't have been included this round. This is a 
bugfix. MainFileName is already remapped from earlier in this function, this 
keeps it from remapping twice if you have an empty old prefix.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-16 Thread Dan McGregor via Phabricator via cfe-commits
dankm updated this revision to Diff 182037.
dankm added a comment.

Update style.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/debug-prefix-map.c
  test/Driver/debug-prefix-map.S
  test/Driver/debug-prefix-map.c
  test/Preprocessor/file_test.c
  test/Preprocessor/file_test.h

Index: test/Preprocessor/file_test.h
===
--- /dev/null
+++ test/Preprocessor/file_test.h
@@ -0,0 +1,2 @@
+filename: __FILE__
+basefile: __BASE_FILE__
Index: test/Preprocessor/file_test.c
===
--- /dev/null
+++ test/Preprocessor/file_test.c
@@ -0,0 +1,22 @@
+// RUN: %clang -E -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | FileCheck %s
+// RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | FileCheck %s
+// RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH=empty -c -o - %s | FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang -E -fmacro-prefix-map=%p/= -c -o - %s | FileCheck %s --check-prefix CHECK-REMOVE
+
+filename: __FILE__
+#include "file_test.h"
+
+// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
+// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.h"
+// CHECK: basefile: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
+// CHECK-NOT: filename:
+
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.h"
+// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
+// CHECK-EVIL-NOT: filename:
+
+// CHECK-REMOVE: filename: "file_test.c"
+// CHECK-REMOVE: filename: "file_test.h"
+// CHECK-REMOVE: basefile: "file_test.c"
+// CHECK-REMOVE-NOT: filename:
Index: test/Driver/debug-prefix-map.c
===
--- test/Driver/debug-prefix-map.c
+++ test/Driver/debug-prefix-map.c
@@ -1,9 +1,28 @@
-// RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-INVALID
-// RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-SIMPLE
-// RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COMPLEX
-// RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-EMPTY
+// RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-INVALID
+// RUN: %clang -### -fmacro-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-INVALID
+// RUN: %clang -### -ffile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-FILE-INVALID
 
-// CHECK-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
-// CHECK-SIMPLE: fdebug-prefix-map=old=new
-// CHECK-COMPLEX: fdebug-prefix-map=old=n=ew
-// CHECK-EMPTY: fdebug-prefix-map=old=
+// RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
+// RUN: %clang -### -fmacro-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
+// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+
+// RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
+// RUN: %clang -### -fmacro-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
+// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+
+// RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
+// RUN: %clang -### -fmacro-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
+// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+
+// CHECK-DEBUG-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
+// CHECK-MACRO-INVALID: error: invalid argument 'old' to -fmacro-prefix-map
+// CHECK-FILE-INVALID: error: invalid argument 'old' to -ffile-prefix-map
+// CHECK-DEBUG-SIMPLE: fdebug-prefix-map=old=new
+// CHECK-MACRO-SIMPLE: fmacro-prefix-map=old=new
+// CHECK-DEBUG-COMPLEX: fdebug-prefix-map=old=n=ew
+// CHECK-MACRO-COMPLEX: fmacro-prefix-map=old=n=ew
+// CHECK-DEBUG-EMPTY: fdebug-prefix-map=old=
+// CHECK-MACRO-EMPTY: fmacro-pr

[clang-tools-extra] r351348 - [clang-tidy] Move the macro helper function to a common location; NFC

2019-01-16 Thread Hyrum Wright via cfe-commits
Author: hwright
Date: Wed Jan 16 06:49:32 2019
New Revision: 351348

URL: http://llvm.org/viewvc/llvm-project?rev=351348&view=rev
Log:
[clang-tidy] Move the macro helper function to a common location; NFC

This is useful for multiple checks.

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp?rev=351348&r1=351347&r2=351348&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp Wed 
Jan 16 06:49:32 2019
@@ -19,26 +19,6 @@ namespace clang {
 namespace tidy {
 namespace abseil {
 
-/// Return `true` if `E` is a either: not a macro at all; or an argument to
-/// one. In the latter case, we should still transform it.
-static bool IsValidMacro(const MatchFinder::MatchResult &Result,
- const Expr *E) {
-  if (!E->getBeginLoc().isMacroID())
-return true;
-
-  SourceLocation Loc = E->getBeginLoc();
-  // We want to get closer towards the initial macro typed into the source only
-  // if the location is being expanded as a macro argument.
-  while (Result.SourceManager->isMacroArgExpansion(Loc)) {
-// We are calling getImmediateMacroCallerLoc, but note it is essentially
-// equivalent to calling getImmediateSpellingLoc in this context according
-// to Clang implementation. We are not calling getImmediateSpellingLoc
-// because Clang comment says it "should not generally be used by clients."
-Loc = Result.SourceManager->getImmediateMacroCallerLoc(Loc);
-  }
-  return !Loc.isMacroID();
-}
-
 void DurationComparisonCheck::registerMatchers(MatchFinder *Finder) {
   auto Matcher =
   binaryOperator(anyOf(hasOperatorName(">"), hasOperatorName(">="),
@@ -64,8 +44,8 @@ void DurationComparisonCheck::check(cons
   // want to handle the case of rewriting both sides. This is much simpler if
   // we unconditionally try and rewrite both, and let the rewriter determine
   // if nothing needs to be done.
-  if (!IsValidMacro(Result, Binop->getLHS()) ||
-  !IsValidMacro(Result, Binop->getRHS()))
+  if (!isNotInMacro(Result, Binop->getLHS()) ||
+  !isNotInMacro(Result, Binop->getRHS()))
 return;
   std::string LhsReplacement =
   rewriteExprFromNumberToDuration(Result, *Scale, Binop->getLHS());

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp?rev=351348&r1=351347&r2=351348&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp Wed Jan 16 
06:49:32 2019
@@ -216,6 +216,23 @@ std::string rewriteExprFromNumberToDurat
   .str();
 }
 
+bool isNotInMacro(const MatchFinder::MatchResult &Result, const Expr *E) {
+  if (!E->getBeginLoc().isMacroID())
+return true;
+
+  SourceLocation Loc = E->getBeginLoc();
+  // We want to get closer towards the initial macro typed into the source only
+  // if the location is being expanded as a macro argument.
+  while (Result.SourceManager->isMacroArgExpansion(Loc)) {
+// We are calling getImmediateMacroCallerLoc, but note it is essentially
+// equivalent to calling getImmediateSpellingLoc in this context according
+// to Clang implementation. We are not calling getImmediateSpellingLoc
+// because Clang comment says it "should not generally be used by clients."
+Loc = Result.SourceManager->getImmediateMacroCallerLoc(Loc);
+  }
+  return !Loc.isMacroID();
+}
+
 } // namespace abseil
 } // namespace tidy
 } // namespace clang

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h?rev=351348&r1=351347&r2=351348&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h Wed Jan 16 
06:49:32 2019
@@ -75,6 +75,11 @@ std::string rewriteExprFromNumberToDurat
 const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale,
 const Expr *Node);
 
+/// Return `true` if `E` is a either: not a macro at all; or an argument to
+/// one.  In the both cases, we often want to do the transformation.
+bool isNotInMacro(const ast_matchers::MatchFinder::MatchResult &Result,
+  

Re: r351316 - Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-16 Thread Sam McCall via cfe-commits
+Ilya who understands the test better...

Some are fixed by r351334 with -target, Ilya could you take a look at
windows? Otherwise we could use REQUIRES...

On Wed, Jan 16, 2019, 15:16 Jeremy Morse  Hi Sam,
>
> Unfortunately this trips up a variety of buildbots:
>
> http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/22376
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15053
> http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/22376
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/3401
>
> http://lab.llvm.org:8011/builders/lldb-amd64-ninja-netbsd8/builds/18177
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/22919
>
> For the Windows machines at least, I don't believe lit can cope with
> replicating shell subprocesses and thus the use of $(which...). (I could be
> wrong there, but it matches up with the error messages).
>
> "clang-check-mac-libcxx-fixed-compilation-db.cpp" sounds like it's
> mac-specific, maybe only "REQUIRES: system-darwin" is needed?
>
> --
> Thanks,
> Jeremy
>
>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56532: [clang-tidy] Add the abseil-duration-conversion-cast check

2019-01-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 182043.
hwright marked 6 inline comments as done.
hwright added a comment.

Address reviewer comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56532/new/

https://reviews.llvm.org/D56532

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationConversionCastCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-conversion-cast.cpp

Index: test/clang-tidy/abseil-duration-conversion-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-conversion-cast.cpp
@@ -0,0 +1,95 @@
+// RUN: %check_clang_tidy %s abseil-duration-conversion-cast %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1;
+  double x;
+  int i;
+
+  i = static_cast(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = static_cast(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleHours(d1);
+  i = static_cast(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Minutes(d1);
+  x = static_cast(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMinutes(d1);
+  i = static_cast(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Seconds(d1);
+  x = static_cast(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleSeconds(d1);
+  i = static_cast(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Milliseconds(d1);
+  x = static_cast(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMilliseconds(d1);
+  i = static_cast(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Microseconds(d1);
+  x = static_cast(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+  i = static_cast(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Nanoseconds(d1);
+  x = static_cast(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleNanoseconds(d1);
+
+  // Functional-style casts
+  i = int(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = float(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-piont number rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // C-style casts
+  i = (int) absl::ToDoubleHours(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1

[PATCH] D56532: [clang-tidy] Add the abseil-duration-conversion-cast check

2019-01-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: clang-tidy/abseil/DurationComparisonCheck.cpp:47-48
   // if nothing needs to be done.
-  if (!IsValidMacro(Result, Binop->getLHS()) ||
-  !IsValidMacro(Result, Binop->getRHS()))
+  if (!isNotInMacro(Result, Binop->getLHS()) ||
+  !isNotInMacro(Result, Binop->getRHS()))
 return;

aaron.ballman wrote:
> I think this change (and the related removal) should be landed separately as 
> a NFC commit once this one lands, as it's logically separate from the new 
> check.
I've gone ahead and done the change separately, which should clean this up.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56532/new/

https://reviews.llvm.org/D56532



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-16 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:607
   llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
+  MainFileName, remapDIPath(getCurrentDirname()), CSInfo,
   getSource(SM, SM.getMainFileID()));

dankm wrote:
> Lekensteyn wrote:
> > Any reason for dropping `remapDIPath` here? Wouldn't this result in the 
> > full path being included even when using:
> > 
> > clang -fdebug-prefix-map=/full/path/= /full/path/source.c
> Whoops. That probably shouldn't have been included this round. This is a 
> bugfix. MainFileName is already remapped from earlier in this function, this 
> keeps it from remapping twice if you have an empty old prefix.
The remapping was done here:
```c
  std::string MainFileDir;
  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
MainFileDir = remapDIPath(MainFile->getDir()->getName());
```

(Observation: the declaration could probably be moved inside the `if` block 
since it is not used outside.)

What about the second case though? For example, assume `/tmp/testdir/mytest.ii`:
```
# 1 "/tmp/mytest.c"
# 1 ""
# 1 ""
# 31 ""
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "" 2
# 1 "/tmp/mytest.c"
int main(int argc, const char *argv[])
{
return 0;
}
```

What happens if you now compile with `clang -fdebug-prefix-map=/tmp/=/bla/ 
/tmp/testdir/mytest.ii` from `/tmp/testdir`?

Unless this affects the current patch, consider moving it to a separate change.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466



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


[PATCH] D56663: [MSP430] Improve support of 'interrupt' attribute

2019-01-16 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:5388
+
+  if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
+S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)

aaron.ballman wrote:
> What should happen if the function does not have a prototype? Should that be 
> diagnosed? e.g., a K&R C function in C mode accepts an arbitrary number of 
> arguments (which can include zero).
Currently, in a case like this
```
__attribute__((interrupt(0))) void foo();

void foo(int i) {
  i++;
}
```
frontend reports no warnings, but backend fails with the following error:
```
fatal error: error in backend: ISRs cannot have arguments
```
But definitely, that should be diagnosed early.
I'll take care of this. Thanks! 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56663/new/

https://reviews.llvm.org/D56663



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


r351350 - Added a test case for dumping blocks that capture 'this'; NFC.

2019-01-16 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jan 16 07:40:23 2019
New Revision: 351350

URL: http://llvm.org/viewvc/llvm-project?rev=351350&view=rev
Log:
Added a test case for dumping blocks that capture 'this'; NFC.

Modified:
cfe/trunk/test/AST/ast-dump-decl.mm

Modified: cfe/trunk/test/AST/ast-dump-decl.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.mm?rev=351350&r1=351349&r2=351350&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.mm (original)
+++ cfe/trunk/test/AST/ast-dump-decl.mm Wed Jan 16 07:40:23 2019
@@ -31,3 +31,20 @@ struct BoxingTest {
 };
 
 // CHECK: ObjCBoxedExpr{{.*}} ''{{$}}
+
+struct Test {
+  void f() {
+^{ this->yada(); }();
+// CHECK:  ExprWithCleanups {{.*}}  'void'
+// CHECK-NEXT:   cleanup Block
+// CHECK-NEXT:   CallExpr {{.*}}  'void'
+// CHECK-NEXT: BlockExpr {{.*}}  'void (^)()'
+// CHECK-NEXT:   BlockDecl {{.*}}  col:5
+// CHECK-NEXT: capture this
+// CHECK-NEXT: CompoundStmt {{.*}} 
+// CHECK-NEXT:   CXXMemberCallExpr {{.*}}  'void'
+// CHECK-NEXT: MemberExpr {{.*}}  '' ->yada
+// CHECK-NEXT:   CXXThisExpr {{.*}}  'Test *' this
+  }
+  void yada();
+};


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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-16 Thread Dan McGregor via Phabricator via cfe-commits
dankm updated this revision to Diff 182047.
dankm added a comment.

Undo accidental change.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/debug-prefix-map.c
  test/Driver/debug-prefix-map.S
  test/Driver/debug-prefix-map.c
  test/Preprocessor/file_test.c
  test/Preprocessor/file_test.h

Index: test/Preprocessor/file_test.h
===
--- /dev/null
+++ test/Preprocessor/file_test.h
@@ -0,0 +1,2 @@
+filename: __FILE__
+basefile: __BASE_FILE__
Index: test/Preprocessor/file_test.c
===
--- /dev/null
+++ test/Preprocessor/file_test.c
@@ -0,0 +1,22 @@
+// RUN: %clang -E -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | FileCheck %s
+// RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | FileCheck %s
+// RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH=empty -c -o - %s | FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang -E -fmacro-prefix-map=%p/= -c -o - %s | FileCheck %s --check-prefix CHECK-REMOVE
+
+filename: __FILE__
+#include "file_test.h"
+
+// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
+// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.h"
+// CHECK: basefile: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
+// CHECK-NOT: filename:
+
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.h"
+// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
+// CHECK-EVIL-NOT: filename:
+
+// CHECK-REMOVE: filename: "file_test.c"
+// CHECK-REMOVE: filename: "file_test.h"
+// CHECK-REMOVE: basefile: "file_test.c"
+// CHECK-REMOVE-NOT: filename:
Index: test/Driver/debug-prefix-map.c
===
--- test/Driver/debug-prefix-map.c
+++ test/Driver/debug-prefix-map.c
@@ -1,9 +1,28 @@
-// RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-INVALID
-// RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-SIMPLE
-// RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COMPLEX
-// RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-EMPTY
+// RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-INVALID
+// RUN: %clang -### -fmacro-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-INVALID
+// RUN: %clang -### -ffile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-FILE-INVALID
 
-// CHECK-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
-// CHECK-SIMPLE: fdebug-prefix-map=old=new
-// CHECK-COMPLEX: fdebug-prefix-map=old=n=ew
-// CHECK-EMPTY: fdebug-prefix-map=old=
+// RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
+// RUN: %clang -### -fmacro-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
+// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+
+// RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
+// RUN: %clang -### -fmacro-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
+// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+
+// RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
+// RUN: %clang -### -fmacro-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
+// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+
+// CHECK-DEBUG-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
+// CHECK-MACRO-INVALID: error: invalid argument 'old' to -fmacro-prefix-map
+// CHECK-FILE-INVALID: error: invalid argument 'old' to -ffile-prefix-map
+// CHECK-DEBUG-SIMPLE: fdebug-prefix-map=old=new
+// CHECK-MACRO-SIMPLE: fmacro-prefix-map=old=new
+// CHECK-DEBUG-COMPLEX: fdebug-prefix-map=old=n=ew
+// CHECK-MACRO-COMPLEX: fmacro-prefix-map=old=n=ew
+// CHECK-DEBUG-EMPTY: fdebug-prefix-map=old=
+// CHECK-MACRO-EMPTY:

[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-16 Thread Dan McGregor via Phabricator via cfe-commits
dankm marked an inline comment as done.
dankm added a comment.

Sure, I'll (eventually) make a separate review.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1359275 , @rjmccall wrote:

> In D56411#1352602 , @yaxunl wrote:
>
> > In D56411#1352332 , @rjmccall 
> > wrote:
> >
> > > This patch still doesn't make any sense.  You don't need to do any 
> > > special validation when passing a function as a template argument.  When 
> > > Sema instantiates the template definition, it'll rebuild the expressions 
> > > that refer to the template parameter, which will trigger the normal 
> > > checking for whether those expressions are illegally referencing a host 
> > > function from the device, etc.  All you need to do is suppress that 
> > > checking (whether it happens in a template definition or not) for 
> > > references from non-potentially-evaluated contexts.
> >
> >
> > If you look at line 6583 of lib/Sema/SemaTemplate.cpp, you will see clang 
> > does the check if the function needs overloading resolution. However, clang 
> > missed the check if the function does not need overloading resolution. 
> > That's why I need to add the check at line 6593. All the other stuff is 
> > just to help make this check.
> >
> > why clang does not do the reference check when there is no overloading 
> > resolution?
>
>
> We should have already done the check for a non-overloaded function reference 
> as part of building the DRE.  See `Sema::BuildDeclarationNameExpr`.  Template 
> argument checking can resolve an overload set based on the type of the 
> template parameter, so overload sets have to be treated specially there.
>
> > I think in usual cases clang already does that check during template 
> > argument parsing, so it does not need to do that again at line 6593. 
> > Unfortunately, for CUDA host/device check, it has to be skipped in template 
> > argument parsing and deferred to line 6593.
>
> Again, you really should not ever impose this restriction in template 
> arguments.


Sorry I do not quite get it. Are you suggesting there should be no diagnostics 
in the lit test kernel-template-with-func-arg.cu? Or do you think they should 
be diagnosed but should be done in a different way than the current approach? 
Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56786: Changes to `CXXMemberExpr` matchers.

2019-01-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
Herald added a subscriber: cfe-commits.

Assorted changes to matchers for `CXXMemberExpr`:

- fixes the comments on `hasObjectExpression`,
- clarifies comments on `thisPointerType` and `on`,
- adds comments to `onImplicitObjectArgument`
- adds new matcher `invokedAtType`, a variant of `thisPointerType` (like `on` 
is a variant of `onImplicitObjectArgument`).


Repository:
  rC Clang

https://reviews.llvm.org/D56786

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -470,6 +470,124 @@
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto MatchesType = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc",
+  MatchesType));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc",
+  MatchesType));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, InvokedAtType) {
+  auto M = cxxMemberCallExpr(invokedAtType(cxxRecordDecl(hasName("Y";
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc",
+  M));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+void z(Y *y) { y->m(); }
+  )cc",
+  M));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc",
+  M));
+}
+
+TEST(Matcher, HasObjectExpr) {
+  auto M = memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return x.m; }
+};
+  )cc",
+  M));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return m; }
+};
+  )cc",
+  M));
+}
+
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
   StatementMatcher ArgumentY =
 declRefExpr(to(varDecl(hasName("y".bind("arg");
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2887,14 +2887,22 @@
  InnerMatcher.matches(*UnderlyingDecl, Finder, Builder);
 }
 
-/// Matches on the implicit object argument of a member call expression.
+/// Matches on the implicit object argument of a member call expression, after
+/// stripping off any parentheses or implicit casts.
 ///
-/// Example matches y.x()
-///   (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))
+/// Given
 /// \code
-///   class Y { public: void x(); };
-///   void z() { Y y; y.x(); }
-/// \endcode
+///   class Y { public: void m(); };
+///   Y g();
+///   class X : public Y {};
+///   void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
+/// \endcode
+/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")
+///   matches `y.m()`, `(g()).m()` and `x.m()`.
+/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")
+///   matches `x.m()`.
+/// cxxMemberCallExpr(on(callExpr()))
+///   matches `(g()).m()`
 ///
 /// FIXME: Overload to allow directly matching types?
 AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher,
@@ -3254,6 +3262,23 

[PATCH] D56786: Changes to `CXXMemberExpr` matchers.

2019-01-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Can you break this up into multiple commits?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56786/new/

https://reviews.llvm.org/D56786



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


r351355 - Added test cases for dumping variadic-like functions; NFC.

2019-01-16 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jan 16 08:12:30 2019
New Revision: 351355

URL: http://llvm.org/viewvc/llvm-project?rev=351355&view=rev
Log:
Added test cases for dumping variadic-like functions; NFC.

Modified:
cfe/trunk/test/AST/ast-dump-decl.c
cfe/trunk/test/AST/ast-dump-expr.cpp
cfe/trunk/test/AST/ast-dump-funcs.cpp

Modified: cfe/trunk/test/AST/ast-dump-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.c?rev=351355&r1=351354&r2=351355&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.c (original)
+++ cfe/trunk/test/AST/ast-dump-decl.c Wed Jan 16 08:12:30 2019
@@ -128,6 +128,9 @@ int TestFunctionDeclProto(int x);
 // CHECK:  FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)'
 // CHECK-NEXT:   ParmVarDecl{{.*}} x
 
+void TestFunctionDeclNoProto();
+// CHECK:  FunctionDecl{{.*}} TestFunctionDeclNoProto 'void ()'
+
 extern int TestFunctionDeclSC();
 // CHECK:  FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern
 

Modified: cfe/trunk/test/AST/ast-dump-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-expr.cpp?rev=351355&r1=351354&r2=351355&view=diff
==
--- cfe/trunk/test/AST/ast-dump-expr.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-expr.cpp Wed Jan 16 08:12:30 2019
@@ -294,6 +294,24 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
+  [](int a, ...){};
+  // CHECK: LambdaExpr 0x{{[^ ]*}}  '(lambda at 
{{.*}}:[[@LINE-1]]:3)'
+  // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}}  col:3 implicit class 
definition
+  // CHECK-NEXT: DefinitionData lambda
+  // CHECK-NEXT: DefaultConstructor
+  // CHECK-NEXT: CopyConstructor
+  // CHECK-NEXT: MoveConstructor
+  // CHECK-NEXT: CopyAssignment
+  // CHECK-NEXT: MoveAssignment
+  // CHECK-NEXT: Destructor
+  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto (int, ...) const' inline
+  // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
+  // CHECK-NEXT: CompoundStmt
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const)(int, ...)' inline
+  // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto (int, ...)' static inline
+  // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+
   [a...]{};
   // CHECK: LambdaExpr 0x{{[^ ]*}}  '(lambda at 
{{.*}}:[[@LINE-1]]:3)'
   // CHECK-NEXT: CXXRecordDecl 0x{{[^ ]*}}  col:3 implicit class 
definition

Modified: cfe/trunk/test/AST/ast-dump-funcs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-funcs.cpp?rev=351355&r1=351354&r2=351355&view=diff
==
--- cfe/trunk/test/AST/ast-dump-funcs.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-funcs.cpp Wed Jan 16 08:12:30 2019
@@ -118,6 +118,11 @@ void m(int) {}
 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:11 'int'
 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
+void n(int, ...) {}
+// CHECK: FunctionDecl 0x{{[^ ]*}}  col:6 n 'void 
(int, ...)'
+// CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:11 'int'
+// CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+
 int main() {
   // CHECK: FunctionDecl 0x{{[^ ]*}}  
line:[[@LINE-1]]:5 main 'int ()'
   a1(); // Causes this to be marked 'used'


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


[PATCH] D56786: Changes to `CXXMemberExpr` matchers.

2019-01-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D56786#1359879 , @steveire wrote:

> Can you break this up into multiple commits?


Sure, but any suggestions on granularity?  E.g. i can split into two: the 
fixes/clarifications in one and the new matcher in another; or i could split 
into four -- one for each bullet, etc.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56786/new/

https://reviews.llvm.org/D56786



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


[PATCH] D56786: [ASTMatchers] Changes to `CXXMemberExpr` matchers.

2019-01-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D56786#1359903 , @ymandel wrote:

> In D56786#1359879 , @steveire wrote:
>
> > Can you break this up into multiple commits?
>
>
> Sure, but any suggestions on granularity?  E.g. i can split into two: the 
> fixes/clarifications in one and the new matcher in another; or i could split 
> into four -- one for each bullet, etc.


Each matcher separately would be best, you then end up with 3x NFC doc-only 
changes, and 2x matchers.




Comment at: include/clang/ASTMatchers/ASTMatchers.h:3346
+
+/// Overloaded to match the type's declaration.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,

How is this different from the other one?
Presumably it should have it's own docs.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3350-3353
+  using ::clang::ast_matchers::on;
+  using ::clang::ast_matchers::anyOf;
+  using ::clang::ast_matchers::hasType;
+  using ::clang::ast_matchers::pointsTo;

I don't think these are needed.
You don't have them in the matcher above yet it presumably compiles.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56786/new/

https://reviews.llvm.org/D56786



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


[PATCH] D56731: Add -Wimplicit-ctad warning to diagnose CTAD on types with no user defined deduction guides.

2019-01-16 Thread Geoffrey Romer via Phabricator via cfe-commits
gromer marked an inline comment as done.
gromer added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2129
+def warn_class_template_argument_deduction_no_user_defined_guides : Warning<
+  "using class template argument deduction for %0 that has no user-defined 
deduction guides" >,
+  InGroup, DefaultIgnore;

EricWF wrote:
> rsmith wrote:
> > gromer wrote:
> > > I'd prefer a phrasing more along the lines of "using class template 
> > > argument deduction for %0 that might not intentionally support it". That 
> > > gives us more room to do things like add an attribute later if necessary, 
> > > and it helps the user understand why this warning indicates a potential 
> > > problem.
> > I like that approach; something like "using class template argument 
> > deduction for %0 that might not intend to support it" -- or perhaps more 
> > directly "%0 might not intend to support class template argument deduction" 
> > -- along with a note describing how to syntactically suppress the warning 
> > (w"add a deduction guide to suppress this warning" or "use the 
> > [[clang::ctad]] attribute to suppress this warning" or whatever we decide 
> > is best).
> This sounds like a reasonable change to me. Done.
> 
> I'm not sure an attribute is needed at this point; AFAIK there is no case 
> where a user defined guide can't be added. Even if it's just a dummy guide to 
> suppress the warning. For example:
> 
> ```
> 
> struct allow_ctad_t {
>   allow_ctad_t() = delete;
> };
> 
> template 
> struct TestSuppression {
>   TestSuppression(int, T) {}
> };
> TestSuppression(allow_ctad_t) -> TestSuppression;
> ```
> 
> Also, before we add an attribute, we want to be sure that it's not harmful to 
> allowing users to suppress the warning without actually addressing the root 
> problem (tha implicit CTAD results are often surprising). I would like to see 
> real world examples of types that don't need user-defined guides to work.
> 
> I'm not sure an attribute is needed at this point

I agree; I just want to keep the option open in case we decide we need one 
later.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56731/new/

https://reviews.llvm.org/D56731



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


Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-16 Thread John McCall via cfe-commits



On 16 Jan 2019, at 9:13, Aaron Ballman wrote:

On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka  
wrote:


Yes, the behavior of the compiler doesn’t match what’s explained 
in the documentation anymore.


Please take a look at the attached patch, which updates the 
documentation.


Patch mostly LGTM, but I did have one wording suggestion.

diff --git a/include/clang/Basic/AttrDocs.td 
b/include/clang/Basic/AttrDocs.td

index 5773a92c9c..ca3cfcf9b2 100644
--- a/include/clang/Basic/AttrDocs.td
+++ b/include/clang/Basic/AttrDocs.td
@@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
 The ``trivial_abi`` attribute can be applied to a C++ class, struct, 
or union.
-It instructs the compiler to pass and return the type using the C 
ABI for the

+``trivial_abi`` has the following effects:
+
+- It instructs the compiler to pass and return the type using the C 
ABI for the
 underlying type when the type would otherwise be considered 
non-trivial for the

 purpose of calls.
-A class annotated with `trivial_abi` can have non-trivial 
destructors or copy/move constructors without automatically becoming 
non-trivial for the purposes of calls. For example:
+- It makes the destructor and copy and move constructors of the 
class trivial
+that would otherwise be considered non-trivial under the C++ ABI 
rules.


How about: It makes the destructor, copy constructors, and move
constructors of the class trivial even if they would otherwise be
non-trivial under the C++ ABI rules.


Let's not say that it makes them trivial, because it doesn't.  It causes
their immediate non-triviality to be ignored for the purposes of 
deciding

whether the type can be passed in registers.

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


[PATCH] D56790: [OpenMP] Update release notes with OpenMP related changes

2019-01-16 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong.

Update release notes with OpenMP related changes.


Repository:
  rC Clang

https://reviews.llvm.org/D56790

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -252,6 +252,14 @@
 
 - General performance improvement.
 
+- New collapse clause scheme to avoid expensive remainder operations.
+
+- New default schedule for distribute and parallel constructs.
+
+- Simplified code generation for distribute and parallel in SPMD mode.
+
+- Flag for user to limit collapsed loop counter width when safe to do so.
+
 CUDA Support in Clang
 -
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -252,6 +252,14 @@
 
 - General performance improvement.
 
+- New collapse clause scheme to avoid expensive remainder operations.
+
+- New default schedule for distribute and parallel constructs.
+
+- Simplified code generation for distribute and parallel in SPMD mode.
+
+- Flag for user to limit collapsed loop counter width when safe to do so.
+
 CUDA Support in Clang
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56786: [ASTMatchers] Changes to `CXXMemberExpr` matchers.

2019-01-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

It is always valuable to split changes which are independent. Usually you can 
extract NFC changes first and then look at what remains to split it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56786/new/

https://reviews.llvm.org/D56786



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


[PATCH] D56066: [OpenCL] Address space for default class members

2019-01-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 2 inline comments as done.
Anastasia added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:78
+RecTy = Context.getAddrSpaceQualType(
+RecTy, MD->getTypeQualifiers().getAddressSpace());
   return Context.getPointerType(CanQualType::CreateUnsafe(RecTy));

Anastasia wrote:
> rjmccall wrote:
> > Would you mind making a patch to rename this (and the method on 
> > `FunctionProtoType`) to something like `getMethodQualifiers`?  It can be a 
> > follow-up instead of blocking this.
> Sure. I will prepare a separate patch for this.
FYI, covered by: https://reviews.llvm.org/D56792


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56066/new/

https://reviews.llvm.org/D56066



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


[PATCH] D56735: [OpenCL] Fix overloading ranking rules to work correctly for address space conversions

2019-01-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D56735#1359590 , @Anastasia wrote:

> In D56735#1358222 , @rjmccall wrote:
>
> > Is there a reason not to just do `T1.getQualifiers() == T2.getQualifiers()`?
>
>
> I tried this but it causes ObjC test to fail 
> test/SemaObjCXX/arc-overloading.mm.
>
>   38 // Simple overloading
>   39 int &f2(id __strong const *); // expected-note{{candidate function}}
>   40 float &f2(id __autoreleasing const *); // expected-note{{candidate 
> function}}
>   41 
>   42 void test_f2() {
>   43   id __strong *sip;
>   44   id __strong const *csip;
>   45   id __weak *wip;
>   46   id __autoreleasing *aip;
>   47   id __unsafe_unretained *uip;
>   48 
>   49   // Prefer non-ownership conversions to ownership conversions.
>   50   int &ir1 = f2(sip);
>   51   int &ir2 = f2(csip);
>   52   float &fr1 = f2(aip);
>   53 
>   54   f2(uip); // expected-error{{call to 'f2' is ambiguous}}
>   55 }
>   
>
> Clang fails to resolve the overloads:
>
>   error: 'error' diagnostics seen but not expected: 
> File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
> 50: call to 'f2' is ambiguous
> File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
> 52: call to 'f2' is ambiguous
>   error: 'note' diagnostics seen but not expected: 
> File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
> 39: candidate function
> File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
> 40: candidate function
> File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
> 39: candidate function
> File /data/llvm/llvm/tools/clang/test/SemaObjCXX/arc-overloading.mm Line 
> 40: candidate function
>   
>
> Since CVR quals for both overloads of `f2` are the same it didn't continue 
> ranking the other qualifiers before. But now when it continues looking at the 
> other qualifiers it finds that `__strong` and `__autoreleasing` are disjoint 
> and exits at the following return statement in 
> `CompareQualificationConversions`:
>
>   } else {
> // Qualifiers are disjoint.
> return ImplicitConversionSequence::Indistinguishable;
>   }
>   
>
> I feel the logic here doesn't apply to this case because it doesn't take into 
> account that for the passed in function argument there is no ownership 
> qualification conversion for one of the overloads. But I don't have a good 
> idea how to fix this easily other than just keep fast pathing  ObjC qual here.
>
> May be if we add a separate qualification conversion for ObjC ownership 
> qualification only we will end up with more conversion steps for one overload 
> and therefore it will be possible to resolve the ambiguity? Do you have any 
> other suggestions or do you think someone else could help?


For now, let's just remove the ownership qualifiers before comparing and leave 
a comment explaining that considering them here seems to interfere with the ARC 
overload rule.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56735/new/

https://reviews.llvm.org/D56735



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


[PATCH] D56792: Rename getTypeQualifiers to getMethodQualifiers

2019-01-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added subscribers: arphaman, eraman.

Use more descriptive name for the method qualifiers getter.

This change was suggested in 
https://reviews.llvm.org/D56066?id=179477#inline-496961


https://reviews.llvm.org/D56792

Files:
  include/clang/AST/CanonicalType.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/AST/VTableBuilder.cpp
  lib/CodeGen/CGCall.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTWriter.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -8361,7 +8361,7 @@
   const Decl *D = cxcursor::getCursorDecl(C);
   const CXXMethodDecl *Method =
   D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
-  return (Method && Method->getTypeQualifiers().hasConst()) ? 1 : 0;
+  return (Method && Method->getMethodQualifiers().hasConst()) ? 1 : 0;
 }
 
 unsigned clang_CXXMethod_isDefaulted(CXCursor C) {
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -310,7 +310,7 @@
 
   Record.push_back(T->isVariadic());
   Record.push_back(T->hasTrailingReturn());
-  Record.push_back(T->getTypeQuals().getAsOpaqueValue());
+  Record.push_back(T->getMethodQuals().getAsOpaqueValue());
   Record.push_back(static_cast(T->getRefQualifier()));
   addExceptionSpec(T, Record);
 
@@ -323,7 +323,7 @@
   Record.push_back(T->getExtParameterInfo(I).getOpaqueValue());
   }
 
-  if (T->isVariadic() || T->hasTrailingReturn() || T->getTypeQuals() ||
+  if (T->isVariadic() || T->hasTrailingReturn() || T->getMethodQuals() ||
   T->getRefQualifier() || T->getExceptionSpecType() != EST_None ||
   T->hasExtParameterInfos())
 AbbrevToUse = 0;
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1868,7 +1868,7 @@
 }
 
 static std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy){
-  std::string Quals = FnTy->getTypeQuals().getAsString();
+  std::string Quals = FnTy->getMethodQuals().getAsString();
 
   switch (FnTy->getRefQualifier()) {
   case RQ_None:
@@ -1910,7 +1910,7 @@
QualifiedFunctionKind QFK) {
   // Does T refer to a function type with a cv-qualifier or a ref-qualifier?
   const FunctionProtoType *FPT = T->getAs();
-  if (!FPT || (FPT->getTypeQuals().empty() && FPT->getRefQualifier() == RQ_None))
+  if (!FPT || (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == RQ_None))
 return false;
 
   S.Diag(Loc, diag::err_compound_qualified_function_type)
@@ -3963,7 +3963,7 @@
 
   // Does T refer to a function type with a cv-qualifier or a ref-qualifier?
   bool IsQualifiedFunction = T->isFunctionProtoType() &&
-  (!T->castAs()->getTypeQuals().empty() ||
+  (!T->castAs()->getMethodQuals().empty() ||
T->castAs()->getRefQualifier() != RQ_None);
 
   // If T is 'decltype(auto)', the only declarators we can have are parens
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3506,7 +3506,7 @@
   Qualifiers ThisTypeQuals;
   if (CXXMethodDecl *Method = dyn_cast(D)) {
 ThisContext = cast(Owner);
-ThisTypeQuals = Method->getTypeQualifiers();
+ThisTypeQuals = Method->getMethodQualifiers();
   }
 
   TypeSourceInfo *NewTInfo
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1671,8 +1671,8 @@
   const FunctionProtoType *FunctionProtoParam =
 cast(Param);
 
-  if (FunctionProtoParam->getTypeQuals()
-!= FunctionProtoArg->getTypeQuals() ||
+  if (FunctionProtoParam->getMethodQuals()
+!= FunctionProtoArg->getMethodQuals() ||
   FunctionProtoParam->getRefQualifier()
 != FunctionProtoArg->getRefQualifier() ||
   FunctionProtoParam->isVariadic() != FunctionProtoArg->isVariadic())
@@ -3082,7 +3082,7 @@
 CXXRecordDecl *ThisContext = nullptr;
 if (CXXMethodDecl *Method = dyn_cast(Function)) {
   ThisContext = Method->getParent();
-  ThisTypeQuals = Method->getT

[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think the diagnostic should come during instantiation when you find an 
evaluated use of a host function within a device function.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56790: [OpenMP] Update release notes with OpenMP related changes

2019-01-16 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, but you need to commit it into release 8.0




Comment at: docs/ReleaseNotes.rst:261
+
+- Flag for user to limit collapsed loop counter width when safe to do so.
+

Add option name. Also, update `OpenMPSupport.rst` to reflect these changes


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56790/new/

https://reviews.llvm.org/D56790



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


Re: r351316 - Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-16 Thread Jeremy Morse via cfe-commits
We do rather need this working for our downstream merging to continue, and
to clear up the buildbots -- without objection I'll drop the  "REQUIRES:
system-darwin" line in there. Depending on what's actually supposed to be
tested that might be sufficient, but please do follow up.

--
Thanks,
Jeremy


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


[PATCH] D56792: Rename getTypeQualifiers to getMethodQualifiers

2019-01-16 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a reviewer: rsmith.
rjmccall added a comment.

LGTM, but I'd like Richard to also sign off on the name.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56792/new/

https://reviews.llvm.org/D56792



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


[PATCH] D56267: [clangd] Interfaces for writing code actions

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182078.
ilya-biryukov added a comment.
Herald added a subscriber: mgrang.

- Rename ActionProvider to Tweak
- Update an interface of Tweak
- ActionInputs -> Tweak::Selection
- Remove CodeAction.h, use tweak registry instead


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56267/new/

https://reviews.llvm.org/D56267

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/refactor/Tweak.cpp
  clangd/refactor/Tweak.h
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -25,7 +25,8 @@
 # CHECK-NEXT:  "documentSymbolProvider": true,
 # CHECK-NEXT:  "executeCommandProvider": {
 # CHECK-NEXT:"commands": [
-# CHECK-NEXT:  "clangd.applyFix"
+# CHECK-NEXT:  "clangd.applyFix",
+# CHECK-NEXT:  "clangd.applyCodeAction"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "hoverProvider": true,
Index: clangd/refactor/Tweak.h
===
--- /dev/null
+++ clangd/refactor/Tweak.h
@@ -0,0 +1,98 @@
+//===--- Tweak.h -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Tweaks are small refactoring-like actions that run over the AST and produce
+// the set of edits as a result. They are local, i.e. they should take the
+// current editor context, e.g. the cursor position and selection into account.
+// The actions are executed in two stages:
+//   - Stage 1 should check whether the action is available in a current
+// context. It should be cheap and fast to compute as it is executed for all
+// available actions on every client request, which happen quite frequently.
+//   - Stage 2 is performed after stage 1 and can be more expensive to compute.
+// It is performed when the user actually chooses the action.
+// To avoid extra round-trips and AST reads, actions can also produce results on
+// stage 1 in cases when the actions are fast to compute.
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_ACTIONS_TWEAK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_ACTIONS_TWEAK_H
+
+#include "ClangdUnit.h"
+#include "Protocol.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+namespace clang {
+namespace clangd {
+
+using TweakID = llvm::StringRef;
+
+/// An interface base for small context-sensitive refactoring actions.
+class Tweak {
+public:
+  /// Input to prepare and apply tweaks.
+  struct Selection {
+static llvm::Optional create(llvm::StringRef File,
+llvm::StringRef Code,
+ParsedAST &AST, Range Selection);
+
+/// The path of an active document the action was invoked in.
+llvm::StringRef File;
+/// The text of the active document.
+llvm::StringRef Code;
+/// Parsed AST of the active file.
+ParsedAST &AST;
+/// A location of the cursor in the editor.
+SourceLocation Cursor;
+// FIXME: add selection when there are checks relying on it.
+// FIXME: provide a way to get sources and ASTs for other files.
+// FIXME: cache some commonly required information (e.g. AST nodes under
+//cursor) to avoid redundant AST visit in every action.
+  };
+  virtual ~Tweak() = default;
+  /// A unique id of the action. The convention is to
+  /// lower-case-with-dashes for the identifier.
+  virtual TweakID id() = 0;
+  /// Run the first stage of the action. The non-None result indicates that the
+  /// action is available and should be shown to the user. Returns None if the
+  /// action is not available.
+  /// This function should be fast, if the action requires non-trivial work it
+  /// should be moved into 'apply'.
+  /// Returns true iff the action is available and apply() can be called on it.
+  virtual bool prepare(const Selection &Sel) = 0;
+  /// Run the second stage of the action that would produce the actual changes.
+  /// EXPECTS: prepare() was called and returned true.
+  virtual Expected apply(const Selection &Sel) = 0;
+  /// A one-line title of the action that should be shown to the users in the
+  /// UI.
+  /// EXPECTS: prepare() was called and returned true.
+  virtual std::string title() const = 0;
+};
+
+/// Contains all actions s

[PATCH] D56610: [clangd] A code action to qualify an unqualified name

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182079.
ilya-biryukov added a comment.

- Update after changes to parent revision


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56610/new/

https://reviews.llvm.org/D56610

Files:
  clangd/CMakeLists.txt
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/refactor/tweaks/QualifyName.cpp
  clangd/refactor/tweaks/QualifyName.h

Index: clangd/refactor/tweaks/QualifyName.h
===
--- /dev/null
+++ clangd/refactor/tweaks/QualifyName.h
@@ -0,0 +1,42 @@
+//===--- QualifyName.h ---*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Fully qualifies a name under a cursor.
+// Before:
+//   using namespace std;
+//   ^vector foo;
+// After:
+//   std::vector foo;
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_QUALIFYNAME_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_QUALIFYNAME_H
+
+#include "refactor/Tweak.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace clangd {
+
+class QualifyName : public Tweak {
+public:
+  TweakID id() override { return llvm::StringLiteral("qualify-name"); }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  SourceLocation InsertLoc;
+  std::string Qualifier;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif
\ No newline at end of file
Index: clangd/refactor/tweaks/QualifyName.cpp
===
--- /dev/null
+++ clangd/refactor/tweaks/QualifyName.cpp
@@ -0,0 +1,163 @@
+//===--- QualifyName.cpp -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "QualifyName.h"
+#include "AST.h"
+#include "ClangdUnit.h"
+#include "SourceCode.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+
+REGISTER_TWEAK(QualifyName);
+
+namespace {
+struct Reference {
+  SourceLocation Begin;
+  NamedDecl *Target = nullptr;
+
+  operator bool() const { return Target != nullptr; }
+};
+
+NamedDecl *toReferencedDecl(NestedNameSpecifier *NNS) {
+  switch (NNS->getKind()) {
+  case clang::NestedNameSpecifier::Namespace:
+return NNS->getAsNamespace();
+  case clang::NestedNameSpecifier::NamespaceAlias:
+return NNS->getAsNamespaceAlias();
+  case clang::NestedNameSpecifier::TypeSpec:
+  case clang::NestedNameSpecifier::TypeSpecWithTemplate:
+return nullptr; // FIXME: handle this situation, retrieve the thing
+// referenced inside a type.
+  case clang::NestedNameSpecifier::Identifier:
+  case clang::NestedNameSpecifier::Super:
+  case clang::NestedNameSpecifier::Global: // FIXME: could return
+   // TranslationUnitDecl.
+return nullptr;
+return nullptr;
+  }
+  llvm_unreachable("unhandled NestedNameSpecifier kind.");
+}
+
+class LocateInsertLoc : public RecursiveASTVisitor {
+public:
+  LocateInsertLoc(ASTContext &Ctx, SourceLocation CursorLoc,
+  Reference &UnqualRef)
+  : Ctx(Ctx), CursorLoc(CursorLoc), UnqualRef(UnqualRef) {}
+
+  bool shouldWalkTypesOfTypeLocs() const { return false; }
+
+  // FIXME: RAT does not have VisitNestedNameSpecifierLoc. Should we add that?
+  bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+if (!RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(NNS))
+  return false;
+return VisitNestedNameSpecifierLoc(NNS);
+  }
+
+  bool VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+if (NNS.getPrefix())
+  return true; // we want only unqualified names.
+auto &SM = Ctx.getSourceManager();
+auto Rng = toHalfOpenFileRange(SM, Ctx.getLangOpts(), NNS.getSourceRange());
+if (!Rng)
+  return true;
+if (!halfOpenRangeContains(SM, *Rng, CursorLoc))
+  return true;
+auto *Target = toReferencedDecl(NNS.getNestedNameSpecifier());
+if (!Target)
+  return true; // continue traversal to recurse into types, if any.
+UnqualRef.Begin = Rng->getBegin();
+UnqualRef.Target = Target;
+return false; // we found the insertion point.
+  }
+
+  bool VisitDeclRefExpr(DeclRefExp

r351360 - Add a REQUIRES: darwin line for a mac test.

2019-01-16 Thread Jeremy Morse via cfe-commits
Author: jmorse
Date: Wed Jan 16 09:41:29 2019
New Revision: 351360

URL: http://llvm.org/viewvc/llvm-project?rev=351360&view=rev
Log:
Add a REQUIRES: darwin line for a mac test.

This test, apparently for macs, fails on Windows as lit can't emulate
the shell subprocess $(which...) correctly. Some other netbsd and linux
buildbots also fail here. Limit to macs as a temporary workaround.

Modified:
cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp

Modified: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351360&r1=351359&r2=351360&view=diff
==
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(original)
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp Wed 
Jan 16 09:41:29 2019
@@ -11,6 +11,6 @@
 // RUN: cp $(which clang-check) %t/mock-libcxx/bin/
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- -stdlib=libc++ 
-target x86_64-apple-darwin
-
+// REQUIRES: system-darwin
 #include 
 vector v;


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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182080.
ilya-biryukov added a comment.

- Update after changes to parent revision


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56611/new/

https://reviews.llvm.org/D56611

Files:
  clangd/CMakeLists.txt
  clangd/refactor/tweaks/SwapIfBranches.cpp
  clangd/refactor/tweaks/SwapIfBranches.h

Index: clangd/refactor/tweaks/SwapIfBranches.h
===
--- /dev/null
+++ clangd/refactor/tweaks/SwapIfBranches.h
@@ -0,0 +1,41 @@
+//===--- SwapIfBrances.h -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Swaps the 'then' and 'else' branch of the if statement.
+// Before:
+//   if (foo) { return 10; } else { continue; }
+// After:
+//   if (foo) { continue; } else { return 10; }
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_SWAPIFBRANCHES_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_SWAPIFBRANCHES_H
+
+#include "refactor/Tweak.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace clangd {
+
+class SwapIfBranches : public Tweak {
+public:
+  TweakID id() override { return llvm::StringLiteral("swap-if-brances"); }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  tooling::Replacements Result;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif
\ No newline at end of file
Index: clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- /dev/null
+++ clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -0,0 +1,102 @@
+//===--- SwapIfBranches.cpp --*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "SwapIfBranches.h"
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+
+REGISTER_TWEAK(SwapIfBranches);
+
+namespace {
+class FindIfUnderCursor : public RecursiveASTVisitor {
+public:
+  FindIfUnderCursor(ASTContext &Ctx, SourceLocation CursorLoc, IfStmt *&Result)
+  : Ctx(Ctx), CursorLoc(CursorLoc), Result(Result) {}
+
+  bool VisitIfStmt(IfStmt *If) {
+auto R = toHalfOpenFileRange(Ctx.getSourceManager(), Ctx.getLangOpts(),
+ SourceRange(If->getIfLoc()));
+if (!R)
+  return true;
+if (!halfOpenRangeContains(Ctx.getSourceManager(), *R, CursorLoc))
+  return true;
+Result = If;
+return false;
+  }
+
+private:
+  ASTContext &Ctx;
+  SourceLocation CursorLoc;
+  IfStmt *&Result;
+};
+} // namespace
+
+bool SwapIfBranches::prepare(const Selection &Inputs) {
+
+  auto &Ctx = Inputs.AST.getASTContext();
+  auto &SrcMgr = Ctx.getSourceManager();
+  IfStmt *If = nullptr;
+  FindIfUnderCursor(Ctx, Inputs.Cursor, If).TraverseAST(Ctx);
+  if (!If)
+return false;
+
+  // avoid dealing with single-statement brances, they require careful handling
+  // to avoid changing semantics of the code (i.e. dangling else).
+  if (!llvm::dyn_cast_or_null(If->getThen()) ||
+  !llvm::dyn_cast_or_null(If->getElse()))
+return false;
+
+  auto ThenRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getThen()->getSourceRange());
+  if (!ThenRng)
+return false;
+  auto ElseRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getElse()->getSourceRange());
+  if (!ElseRng)
+return false;
+
+  llvm::StringRef ThenCode = toSourceCode(SrcMgr, *ThenRng);
+  llvm::StringRef ElseCode = toSourceCode(SrcMgr, *ElseRng);
+
+  if (auto Err = Result.add(tooling::Replacement(SrcMgr, ThenRng->getBegin(),
+ ThenCode.size(), ElseCode))) {
+llvm::consumeError(std::move(Err));
+return false;
+  }
+  if (auto Err = Result.add(tool

[PATCH] D56612: [clangd] A code action to remove 'using namespace'

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182082.
ilya-biryukov added a comment.

- Update after changes to parent revision


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56612/new/

https://reviews.llvm.org/D56612

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/CMakeLists.txt
  clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clangd/refactor/tweaks/RemoveUsingNamespace.h

Index: clangd/refactor/tweaks/RemoveUsingNamespace.h
===
--- /dev/null
+++ clangd/refactor/tweaks/RemoveUsingNamespace.h
@@ -0,0 +1,42 @@
+//===--- RemoveUsingNamespace.h --*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Removes the 'using namespace' under the cursor and qualifies all accesses in 
+// the current file. E.g.,
+//   using namespace std;
+//   vector foo(std::map);
+// Would become:
+//   std::vector foo(std::map);
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_REMOVEUSINGNAMESPACE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_REMOVEUSINGNAMESPACE_H
+
+#include "refactor/Tweak.h"
+
+namespace clang {
+namespace clangd {
+
+class RemoveUsingNamespace : public Tweak {
+public:
+  TweakID id() override {
+return llvm::StringLiteral("remove-using-namespace");
+  }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  UsingDirectiveDecl *TargetDirective = nullptr;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- /dev/null
+++ clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -0,0 +1,188 @@
+//===--- RemoveUsingNamespace.cpp *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "RemoveUsingNamespace.h"
+#include "AST.h"
+#include "ClangdUnit.h"
+#include "SourceCode.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
+#include "llvm/ADT/ScopeExit.h"
+
+namespace clang {
+namespace clangd {
+
+REGISTER_TWEAK(RemoveUsingNamespace);
+
+namespace {
+class FindNodeUnderCursor : public RecursiveASTVisitor {
+public:
+  FindNodeUnderCursor(SourceLocation SearchedLoc, UsingDirectiveDecl *&Result)
+  : SearchedLoc(SearchedLoc), Result(Result) {}
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
+if (D->getUsingLoc() != SearchedLoc)
+  return true;
+
+Result = D;
+return false;
+  }
+
+private:
+  SourceLocation SearchedLoc;
+  UsingDirectiveDecl *&Result;
+};
+
+class FindSameUsings : public RecursiveASTVisitor {
+public:
+  FindSameUsings(UsingDirectiveDecl &Target,
+ std::vector &Results)
+  : TargetNS(Target.getNominatedNamespace()),
+TargetCtx(Target.getDeclContext()), Results(Results) {}
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
+if (D->getNominatedNamespace() != TargetNS ||
+D->getDeclContext() != TargetCtx)
+  return true;
+
+Results.push_back(D);
+return true;
+  }
+
+private:
+  NamespaceDecl *TargetNS;
+  DeclContext *TargetCtx;
+  std::vector &Results;
+};
+
+class FindIdentsToQualify
+: public tooling::RecursiveSymbolVisitor {
+public:
+  FindIdentsToQualify(ASTContext &Ctx, NamespaceDecl &TargetNS,
+  std::vector &ResultIdents)
+  : RecursiveSymbolVisitor(Ctx.getSourceManager(), Ctx.getLangOpts()),
+Ctx(Ctx), TargetNS(TargetNS), ResultIdents(ResultIdents) {}
+
+  bool visitSymbolOccurrence(const NamedDecl *D,
+ llvm::ArrayRef NameRanges) {
+if (!D || D->getCanonicalDecl() == TargetNS.getCanonicalDecl())
+  return true;
+if (!D->getDeclName().isIdentifier() ||
+D->getDeclName().getNameKind() == DeclarationName::CXXOperatorName)
+  return true; // do not add qualifiers for non-idents, e.g. 'operator+'.
+// Check the symbol is unqualified and references something inside our
+// namespace.
+// FIXME: add a check it's unqualified.
+if (!TargetNS.InEnclosingNamespaceSetOf(D->getDeclContext()))
+  return true;
+// FIXME: handle more tricky cases, e.g. we don't need the qualifier if we
+//have the using decls for some entities

Re: r351316 - Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-16 Thread Jeremy Morse via cfe-commits
Platform REQUIRES added in r351360, please do revert & fix if this test is
supposed to work elsewhere.

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


[PATCH] D56610: [clangd] A code action to qualify an unqualified name

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/SourceCode.h:64
 
+/// Turns a token range into a half-open range and checks its correctness.
+/// The resulting range will have only valid source location on both sides, 
both

jkorous wrote:
> It seems to me the range is actually closed on both sides.
> Do I get it right that the result is?
> 
> ```
> [begin of first token : end of last token]
> ```
> 
> Wouldn't some name like `toWholeTokenRange` be easier to understand?
The range is supposed to be half-open to allow representing points as empty 
range starting at the specified position.
This literally represents two byte offsets inside the same file. 

My plan is to introduce a class to capture this abstraction, but let me see how 
the review goes.



Comment at: clangd/SourceCode.h:81
+/// Preconditions: isValidFileRange(R) == true, L is a file location.
+bool halfOpenRangeContains(const SourceManager &Mgr, SourceRange R,
+   SourceLocation L);

jkorous wrote:
> I'd find it helpful to mention that the range is actually interpreted as 
> closed-open (knowing which half is which).
Good point, will do.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56610/new/

https://reviews.llvm.org/D56610



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


[PATCH] D56735: [OpenCL] Fix overloading ranking rules to work correctly for address space conversions

2019-01-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 182084.
Anastasia added a comment.

- Changed the condition to use all qualifiers except for ObjC ownership ones.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56735/new/

https://reviews.llvm.org/D56735

Files:
  lib/Sema/SemaOverload.cpp
  test/SemaOpenCLCXX/address_space_overloading.cl


Index: test/SemaOpenCLCXX/address_space_overloading.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/address_space_overloading.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+
+// expected-no-diagnostics
+void foo(const __global int *a);
+void foo(const __generic int *a);
+
+void kernel ker() {
+  __global int *a;
+  __generic int *c;
+  __local int *d;
+  foo(a);
+  foo(c);
+  foo(d);
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -4019,9 +4019,12 @@
 // to unwrap. This essentially mimics what
 // IsQualificationConversion does, but here we're checking for a
 // strict subset of qualifiers.
-if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
+if (T1.getQualifiers().withoutObjCLifetime() ==
+T2.getQualifiers().withoutObjCLifetime())
   // The qualifiers are the same, so this doesn't tell us anything
   // about how the sequences rank.
+  // ObjC ownership quals are omitted above as they interfere with
+  // the ARC overload rule.
   ;
 else if (T2.isMoreQualifiedThan(T1)) {
   // T1 has fewer qualifiers, so it could be the better sequence.


Index: test/SemaOpenCLCXX/address_space_overloading.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/address_space_overloading.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+
+// expected-no-diagnostics
+void foo(const __global int *a);
+void foo(const __generic int *a);
+
+void kernel ker() {
+  __global int *a;
+  __generic int *c;
+  __local int *d;
+  foo(a);
+  foo(c);
+  foo(d);
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -4019,9 +4019,12 @@
 // to unwrap. This essentially mimics what
 // IsQualificationConversion does, but here we're checking for a
 // strict subset of qualifiers.
-if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
+if (T1.getQualifiers().withoutObjCLifetime() ==
+T2.getQualifiers().withoutObjCLifetime())
   // The qualifiers are the same, so this doesn't tell us anything
   // about how the sequences rank.
+  // ObjC ownership quals are omitted above as they interfere with
+  // the ARC overload rule.
   ;
 else if (T2.isMoreQualifiedThan(T1)) {
   // T1 has fewer qualifiers, so it could be the better sequence.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56651: [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl

2019-01-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Thank you, this looks good but perhaps some refactoring would help improve the 
change.




Comment at: lib/AST/ASTImporter.cpp:3243
+
+  if (R) {
+CXXDestructorDecl *ToDtor = cast(*R);

a_sidorin wrote:
> It's better to move this code to VisitFunctionDecl to keep all related stuff 
> together.
I am not sure I agree. Having everything in `VisitFunctionDecl` makes this code 
harder to maintain. 





Comment at: lib/AST/ASTImporter.cpp:3246
+
+auto Imp = importSeq(const_cast(D->getOperatorDelete()),
+ D->getOperatorDeleteThisArg());

a_sidorin wrote:
> Moving this code to VisitFunctionDecl will also allow us not to create a dtor 
> if this import fails.
At what point in `VisitFunctionDecl` would you expect this change to bail out 
of? A possible refactor would be to move this code to a separate function and 
then call that function at that point in `VisitFunctionDecl`. This would 
prevent `VisitFunctionDecl` from becoming even larger and I think address your 
concern.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56651/new/

https://reviews.llvm.org/D56651



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


Re: r344241 - [tests] Include Python binding tests in CMake rules

2019-01-16 Thread Nico Weber via cfe-commits
(Follow-up: Michał landed a fix in r351304. Thanks!)

On Tue, Jan 15, 2019 at 1:21 PM Nico Weber  wrote:

> As long as check-all passes with LLVM_ENABLE_PIC=OFF I'm happy :-) (Note
> it's .dylib on macOS and .dll on Windows, and by default
> setting LLVM_ENABLE_PIC=OFF causes a static library to be created instead
> on non-win).
>
> On Tue, Jan 15, 2019 at 1:16 PM Michał Górny  wrote:
>
>> On Tue, 2019-01-15 at 13:10 -0500, Nico Weber wrote:
>> > The tests probably shouldn't run when LLVM_ENABLE_PIC=OFF is set, since
>> > they all fail there (due to lib/libclang.so not existing).
>>
>> Hmm, maybe we could make them conditional to the existence
>> of libclang.so target?  Would that work for you?
>>
>> >
>> > On Thu, Oct 11, 2018 at 7:59 AM Michal Gorny via cfe-commits <
>> > cfe-commits@lists.llvm.org> wrote:
>> >
>> > > Author: mgorny
>> > > Date: Thu Oct 11 04:58:14 2018
>> > > New Revision: 344241
>> > >
>> > > URL: http://llvm.org/viewvc/llvm-project?rev=344241&view=rev
>> > > Log:
>> > > [tests] Include Python binding tests in CMake rules
>> > >
>> > > Add a new CMake rule check-clang-python to run the Python bindings'
>> > > test suite, and include it in check-all.
>> > >
>> > > Differential Revision: https://reviews.llvm.org/D52840
>> > >
>> > > Added:
>> > > cfe/trunk/bindings/python/tests/CMakeLists.txt
>> > > Modified:
>> > > cfe/trunk/CMakeLists.txt
>> > >
>> > > Modified: cfe/trunk/CMakeLists.txt
>> > > URL:
>> > >
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=344241&r1=344240&r2=344241&view=diff
>> > >
>> > >
>> ==
>> > > --- cfe/trunk/CMakeLists.txt (original)
>> > > +++ cfe/trunk/CMakeLists.txt Thu Oct 11 04:58:14 2018
>> > > @@ -502,6 +502,7 @@ if( CLANG_INCLUDE_TESTS )
>> > >)
>> > >endif()
>> > >add_subdirectory(utils/perf-training)
>> > > +  add_subdirectory(bindings/python/tests)
>> > >  endif()
>> > >
>> > >  option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang
>> docs."
>> > >
>> > > Added: cfe/trunk/bindings/python/tests/CMakeLists.txt
>> > > URL:
>> > >
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344241&view=auto
>> > >
>> > >
>> ==
>> > > --- cfe/trunk/bindings/python/tests/CMakeLists.txt (added)
>> > > +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Thu Oct 11
>> 04:58:14 2018
>> > > @@ -0,0 +1,7 @@
>> > > +# Test target to run Python test suite from main build.
>> > > +
>> > > +add_custom_target(check-clang-python
>> > > +   COMMAND CLANG_LIBRARY_PATH=$
>> > > ${PYTHON_EXECUTABLE} -m unittest discover
>> > > +   DEPENDS libclang
>> > > +   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
>> > > +add_dependencies(check-all check-clang-python)
>> > >
>> > >
>> > > ___
>> > > cfe-commits mailing list
>> > > cfe-commits@lists.llvm.org
>> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> > >
>>
>> --
>> Best regards,
>> Michał Górny
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55447: [Sema] Fix Modified Type in address_space AttributedType

2019-01-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 182092.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55447/new/

https://reviews.llvm.org/D55447

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/address_space_attribute.cpp
  clang/test/Index/print-type.m
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -129,7 +129,9 @@
 // Handle attributed types as the original type
 if (auto *ATT = T->getAs()) {
   if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes)) {
-return MakeCXType(ATT->getModifiedType(), TU);
+// Return the equivalent type which represents the canonically
+// equivalent type.
+return MakeCXType(ATT->getEquivalentType(), TU);
   }
 }
 // Handle paren types as the original type
Index: clang/test/Index/print-type.m
===
--- clang/test/Index/print-type.m
+++ clang/test/Index/print-type.m
@@ -19,6 +19,6 @@
 // CHECK: ObjCInstanceMethodDecl=methodIn:andOut::5:10 (variadic) [Bycopy,] [type=] [typekind=Invalid] [resulttype=id] [resulttypekind=ObjCId] [args= [int] [Int] [short *] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=i:5:27 (Definition) [In,] [type=int] [typekind=Int] [isPOD=1]
 // CHECK: ParmDecl=j:5:49 (Definition) [Out,] [type=short *] [typekind=Pointer] [isPOD=1] [pointeetype=short] [pointeekind=Short]
-// CHECK: ParmDecl=p:6:36 (Definition) [type=__kindof Foo *] [typekind=ObjCObjectPointer] [canonicaltype=__kindof Foo *] [canonicaltypekind=ObjCObjectPointer] [basetype=Foo] [basekind=ObjCInterface] [isPOD=1] [pointeetype=Foo] [pointeekind=ObjCInterface]
+// CHECK: ParmDecl=p:6:36 (Definition) [type=__kindof Foo *] [typekind=ObjCObjectPointer] [canonicaltype=__kindof Foo *] [canonicaltypekind=ObjCObjectPointer] [basetype=Foo] [basekind=ObjCInterface] [isPOD=1] [pointeetype=__kindof Foo] [pointeekind=ObjCObject]
 // CHECK: ObjCPropertyDecl=classProp:7:23 [class,] [type=int] [typekind=Int] [isPOD=1]
 // CHECK: ObjCInstanceMethodDecl=generic:11:12 [type=] [typekind=Invalid] [resulttype=SomeType] [resulttypekind=ObjCTypeParam] [isPOD=0]
Index: clang/test/AST/address_space_attribute.cpp
===
--- /dev/null
+++ clang/test/AST/address_space_attribute.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+
+// Veryify the ordering of the address_space attribute still comes before the
+// type whereas other attributes are still printed after.
+
+template 
+void func() {
+  // CHECK: VarDecl {{.*}} x '__attribute__((address_space(1))) int *'
+  __attribute__((address_space(1))) int *x;
+
+  // CHECK: VarDecl {{.*}} a 'int * __attribute__((noderef))'
+  int __attribute__((noderef)) * a;
+
+  // CHECK: VarDecl {{.*}} y '__attribute__((address_space(2))) int *'
+  __attribute__((address_space(I))) int *y;
+
+  // CHECK: VarDecl {{.*}} z '__attribute__((address_space(3))) int *'
+  [[clang::address_space(3)]] int *z;
+}
+
+void func2() {
+  func<2>();
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5756,28 +5756,27 @@
 // Type Attribute Processing
 //===--===//
 
-/// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression
-/// is uninstantiated. If instantiated it will apply the appropriate address space
-/// to the type. This function allows dependent template variables to be used in
-/// conjunction with the address_space attribute
-QualType Sema::BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace,
- SourceLocation AttrLoc) {
+/// Build an AddressSpace index from a constant expression and diagnose any
+/// errors related to invalid address_spaces. Returns true on successfully
+/// building an AddressSpace index.
+static bool BuildAddressSpaceIndex(Sema &S, LangAS &ASIdx,
+   const Expr *AddrSpace,
+   SourceLocation AttrLoc) {
   if (!AddrSpace->isValueDependent()) {
-
 llvm::APSInt addrSpace(32);
-if (!AddrSpace->isIntegerConstantExpr(addrSpace, Context)) {
-  Diag(AttrLoc, diag::err_attribute_argument_type)
+if (!AddrSpace->isIntegerConstantExpr(addrSpace, S.Context)) {
+  S.Diag(AttrLoc, diag::err_attribute_argument_type)
   << "'address_space'" << AANT_ArgumentIntegerConstant
   << AddrSpace->getSourceRange();
-  return QualType();
+  return false;
 }
 
 // Bounds checking.

[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2019-01-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D53738#1359135 , @rjmccall wrote:

> I think that's the right direction, yeah.
>
> I thought I told you it was fine to commit this patch under that assumption 
> awhile ago.  Did I just never click "accept"?


Whoops. I don't think there was an accept, so I kept this patch on hold.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53738/new/

https://reviews.llvm.org/D53738



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


r351364 - [Fixed Point Arithmetic] Fixed Point Addition

2019-01-16 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Jan 16 10:13:59 2019
New Revision: 351364

URL: http://llvm.org/viewvc/llvm-project?rev=351364&view=rev
Log:
[Fixed Point Arithmetic] Fixed Point Addition

This patch covers addition between fixed point types and other fixed point
types or integers, using the conversion rules described in 4.1.4 of N1169.

Usual arithmetic rules do not apply to binary operations when one of the
operands is a fixed point type, and the result of the operation must be
calculated with the full precision of the operands, so we should not perform
any casting to a common type.

This patch does not include constant expression evaluation for addition of
fixed point types. That will be addressed in another patch since I think this
one is already big enough.

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

Added:
cfe/trunk/test/Frontend/fixed_point_add.c
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/FixedPoint.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/FixedPoint.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Frontend/fixed_point_conversions.c

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=351364&r1=351363&r2=351364&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jan 16 10:13:59 2019
@@ -2624,6 +2624,12 @@ public:
   // corresponding saturated type for a given fixed point type.
   QualType getCorrespondingSaturatedType(QualType Ty) const;
 
+  // This method accepts fixed point types and returns the corresponding signed
+  // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned
+  // fixed point types because there are unsigned integer types like bool and
+  // char8_t that don't have signed equivalents.
+  QualType getCorrespondingSignedFixedPointType(QualType Ty) const;
+
   
//======//
   //Integer Values
   
//======//

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=351364&r1=351363&r2=351364&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jan 16 10:13:59 2019
@@ -2269,6 +2269,9 @@ public:
   /// ISO/IEC JTC1 SC22 WG14 N1169.
   bool isFixedPointType() const;
 
+  /// Return true if this is a fixed point or integer type.
+  bool isFixedPointOrIntegerType() const;
+
   /// Return true if this is a saturated fixed point type according to
   /// ISO/IEC JTC1 SC22 WG14 N1169. This type can be signed or unsigned.
   bool isSaturatedFixedPointType() const;
@@ -6596,6 +6599,10 @@ inline bool Type::isFixedPointType() con
   return false;
 }
 
+inline bool Type::isFixedPointOrIntegerType() const {
+  return isFixedPointType() || isIntegerType();
+}
+
 inline bool Type::isSaturatedFixedPointType() const {
   if (const auto *BT = dyn_cast(CanonicalType)) {
 return BT->getKind() >= BuiltinType::SatShortAccum &&

Modified: cfe/trunk/include/clang/Basic/FixedPoint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=351364&r1=351363&r2=351364&view=diff
==
--- cfe/trunk/include/clang/Basic/FixedPoint.h (original)
+++ cfe/trunk/include/clang/Basic/FixedPoint.h Wed Jan 16 10:13:59 2019
@@ -18,6 +18,7 @@
 #define LLVM_CLANG_BASIC_FIXEDPOINT_H
 
 #include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 
@@ -36,6 +37,8 @@ public:
   : Width(Width), Scale(Scale), IsSigned(IsSigned),
 IsSaturated(IsSaturated), HasUnsignedPadding(HasUnsignedPadding) {
 assert(Width >= Scale && "Not enough room for the scale");
+assert(!(IsSigned && HasUnsignedPadding) &&
+   "Cannot have unsigned padding on a signed type.");
   }
 
   unsigned getWidth() const { return Width; }
@@ -46,6 +49,9 @@ public:
 
   void setSaturated(bool Saturated) { IsSaturated = Saturated; }
 
+  /// Return the number of integral bits represented by these semantics. These
+  /// are separate from the fractional bits and do not include the sign or
+  /// padding bit.
   unsigned getIntegralBits() const {
 if (IsSigned || (!IsSigned && HasUnsignedPadding))
   return Width - Scale - 1;
@@ -53,6 +59,21 @@ public:
   return Width - Scale;
   }
 
+  /// Return the FixedPointSemantics that allows for calculating the full
+  /// precision semantic that can precisely represent the precision and ranges
+ 

[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2019-01-16 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351364: [Fixed Point Arithmetic] Fixed Point Addition 
(authored by leonardchan, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53738?vs=176862&id=182094#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53738/new/

https://reviews.llvm.org/D53738

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/FixedPoint.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Basic/FixedPoint.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Frontend/fixed_point_add.c
  cfe/trunk/test/Frontend/fixed_point_conversions.c

Index: cfe/trunk/test/Frontend/fixed_point_conversions.c
===
--- cfe/trunk/test/Frontend/fixed_point_conversions.c
+++ cfe/trunk/test/Frontend/fixed_point_conversions.c
@@ -214,19 +214,17 @@
   // Only get overflow checking if signed fract to unsigned accum
   sat_ua = sat_sf;
   // DEFAULT:  [[FRACT:%[0-9a-z]+]] = load i8, i8* %sat_sf, align 1
-  // DEFAULT-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i17
-  // DEFAULT-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i17 [[FRACT_EXT]], 9
-  // DEFAULT-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i17 [[ACCUM]], 0
-  // DEFAULT-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i17 0, i17 [[ACCUM]]
-  // DEFAULT-NEXT: [[RESULT_EXT:%[0-9a-z]+]] = sext i17 [[RESULT]] to i32
-  // DEFAULT-NEXT: store i32 [[RESULT_EXT]], i32* %sat_ua, align 4
+  // DEFAULT-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i32
+  // DEFAULT-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i32 [[FRACT_EXT]], 9
+  // DEFAULT-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i32 [[ACCUM]], 0
+  // DEFAULT-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i32 0, i32 [[ACCUM]]
+  // DEFAULT-NEXT: store i32 [[RESULT]], i32* %sat_ua, align 4
   // SAME:  [[FRACT:%[0-9a-z]+]] = load i8, i8* %sat_sf, align 1
-  // SAME-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i16
-  // SAME-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i16 [[FRACT_EXT]], 8
-  // SAME-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i16 [[ACCUM]], 0
-  // SAME-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i16 0, i16 [[ACCUM]]
-  // SAME-NEXT: [[RESULT_EXT:%[0-9a-z]+]] = sext i16 [[RESULT]] to i32
-  // SAME-NEXT: store i32 [[RESULT_EXT]], i32* %sat_ua, align 4
+  // SAME-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i32
+  // SAME-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i32 [[FRACT_EXT]], 8
+  // SAME-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i32 [[ACCUM]], 0
+  // SAME-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i32 0, i32 [[ACCUM]]
+  // SAME-NEXT: store i32 [[RESULT]], i32* %sat_ua, align 4
 }
 
 void TestFixedPointCastBetFractAccum() {
Index: cfe/trunk/test/Frontend/fixed_point_add.c
===
--- cfe/trunk/test/Frontend/fixed_point_add.c
+++ cfe/trunk/test/Frontend/fixed_point_add.c
@@ -0,0 +1,390 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+void SignedAddition() {
+  // CHECK-LABEL: SignedAddition
+  short _Accum sa;
+  _Accum a, b, c, d;
+  long _Accum la;
+  unsigned short _Accum usa;
+  unsigned _Accum ua;
+  unsigned long _Accum ula;
+
+  short _Fract sf;
+  _Fract f;
+  long _Fract lf;
+  unsigned short _Fract usf;
+  unsigned _Fract uf;
+  unsigned long _Fract ulf;
+
+  // Same type
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SA2:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i16 [[SA]], [[SA2]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa + sa;
+
+  // To larger scale and larger width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i32
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i32 [[EXT_SA]], 8
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i32 [[SA]], [[A]]
+  // CHECK-NEXT: store i32 [[SUM]], i32* %a, align 4
+  a = sa + a;
+
+  // To same scale and smaller width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SF:%[0-9]+]] = load i8, i8* %sf, align 1
+  // CHECK-NEXT: [[EXT_SF:%[a-z0-9]+]] = sext i8 [[SF]] to i16
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i16 [[SA]], [[EXT_SF]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa + sf;
+
+  // To smaller scale and same width.
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[F:%[0-9]+]] = load i16, i16* %f, align 2
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]]

[PATCH] D56786: [ASTMatchers] Changes to `CXXMemberExpr` matchers.

2019-01-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added a comment.

In D56786#1359920 , @lebedev.ri wrote:

> In D56786#1359903 , @ymandel wrote:
>
> > In D56786#1359879 , @steveire 
> > wrote:
> >
> > > Can you break this up into multiple commits?
> >
> >
> > Sure, but any suggestions on granularity?  E.g. i can split into two: the 
> > fixes/clarifications in one and the new matcher in another; or i could 
> > split into four -- one for each bullet, etc.
>
>
> Each matcher separately would be best, you then end up with 3x NFC doc-only 
> changes, and 2x matchers.


Once I'm splitting, I'd prefer to bundle the tests with the corresponding 
comment changes, but I see how that would break the NFC split (assuming tests 
count as "functional changes").  So, if the NFC changes are separate, should 
all the tests be bundled together, or split into separate patches?  For 
example, I can put the tests for existing matchers into one patch, and the new 
matcher and its test into a separate patch. WDYT?




Comment at: include/clang/ASTMatchers/ASTMatchers.h:3346
+
+/// Overloaded to match the type's declaration.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,

lebedev.ri wrote:
> How is this different from the other one?
> Presumably it should have it's own docs.
I was following what we've done elsewhere for overloads (e.g. line 3312 above), 
but am happy to expand this if you recommend. Personally, I think more 
documentation is better, but wanted to stick w/ the standard practice.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3350-3353
+  using ::clang::ast_matchers::on;
+  using ::clang::ast_matchers::anyOf;
+  using ::clang::ast_matchers::hasType;
+  using ::clang::ast_matchers::pointsTo;

lebedev.ri wrote:
> I don't think these are needed.
> You don't have them in the matcher above yet it presumably compiles.
Right -- those are leftover from development (which took place in a different 
namespace originally).  Will remove once I split this patch.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56786/new/

https://reviews.llvm.org/D56786



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


Re: r351316 - Reapply [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-16 Thread Greg Bedwell via cfe-commits
> > Unfortunately this trips up a variety of buildbots:
> Platform REQUIRES added in r351360, please do revert & fix if this test
is supposed to work elsewhere.

Looks like the test fail just made it into the release-8.0.0 branch by a
few commits.  I think we'll need Jeremy's fix r351360 or/and any subsequent
'more correct' test updates (if required) to get check-all on the branch
into a passing state.

-Greg

On Wed, 16 Jan 2019 at 17:49, Jeremy Morse via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Platform REQUIRES added in r351360, please do revert & fix if this test is
> supposed to work elsewhere.
>
> --
> Thanks,
> Jeremy
>
> ___
> 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] D56611: [clangd] A code action to swap branches of an if statement

2019-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182102.
ilya-biryukov added a comment.

- Fix a typo in the id of the SwapIfBranches


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56611/new/

https://reviews.llvm.org/D56611

Files:
  clangd/CMakeLists.txt
  clangd/refactor/tweaks/SwapIfBranches.cpp
  clangd/refactor/tweaks/SwapIfBranches.h

Index: clangd/refactor/tweaks/SwapIfBranches.h
===
--- /dev/null
+++ clangd/refactor/tweaks/SwapIfBranches.h
@@ -0,0 +1,41 @@
+//===--- SwapIfBrances.h -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Swaps the 'then' and 'else' branch of the if statement.
+// Before:
+//   if (foo) { return 10; } else { continue; }
+// After:
+//   if (foo) { continue; } else { return 10; }
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_SWAPIFBRANCHES_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_TWEAKS_SWAPIFBRANCHES_H
+
+#include "refactor/Tweak.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace clangd {
+
+class SwapIfBranches : public Tweak {
+public:
+  TweakID id() override { return llvm::StringLiteral("swap-if-branches"); }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  tooling::Replacements Result;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif
\ No newline at end of file
Index: clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- /dev/null
+++ clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -0,0 +1,102 @@
+//===--- SwapIfBranches.cpp --*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "SwapIfBranches.h"
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+
+REGISTER_TWEAK(SwapIfBranches);
+
+namespace {
+class FindIfUnderCursor : public RecursiveASTVisitor {
+public:
+  FindIfUnderCursor(ASTContext &Ctx, SourceLocation CursorLoc, IfStmt *&Result)
+  : Ctx(Ctx), CursorLoc(CursorLoc), Result(Result) {}
+
+  bool VisitIfStmt(IfStmt *If) {
+auto R = toHalfOpenFileRange(Ctx.getSourceManager(), Ctx.getLangOpts(),
+ SourceRange(If->getIfLoc()));
+if (!R)
+  return true;
+if (!halfOpenRangeContains(Ctx.getSourceManager(), *R, CursorLoc))
+  return true;
+Result = If;
+return false;
+  }
+
+private:
+  ASTContext &Ctx;
+  SourceLocation CursorLoc;
+  IfStmt *&Result;
+};
+} // namespace
+
+bool SwapIfBranches::prepare(const Selection &Inputs) {
+
+  auto &Ctx = Inputs.AST.getASTContext();
+  auto &SrcMgr = Ctx.getSourceManager();
+  IfStmt *If = nullptr;
+  FindIfUnderCursor(Ctx, Inputs.Cursor, If).TraverseAST(Ctx);
+  if (!If)
+return false;
+
+  // avoid dealing with single-statement brances, they require careful handling
+  // to avoid changing semantics of the code (i.e. dangling else).
+  if (!llvm::dyn_cast_or_null(If->getThen()) ||
+  !llvm::dyn_cast_or_null(If->getElse()))
+return false;
+
+  auto ThenRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getThen()->getSourceRange());
+  if (!ThenRng)
+return false;
+  auto ElseRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getElse()->getSourceRange());
+  if (!ElseRng)
+return false;
+
+  llvm::StringRef ThenCode = toSourceCode(SrcMgr, *ThenRng);
+  llvm::StringRef ElseCode = toSourceCode(SrcMgr, *ElseRng);
+
+  if (auto Err = Result.add(tooling::Replacement(SrcMgr, ThenRng->getBegin(),
+ ThenCode.size(), ElseCode))) {
+llvm::consumeError(std::move(Err));
+return false;
+  }
+  if (auto Err = Result.add(

r351368 - [Fixed Point Arithmetic] Add APFixedPoint to APValue

2019-01-16 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Jan 16 10:53:05 2019
New Revision: 351368

URL: http://llvm.org/viewvc/llvm-project?rev=351368&view=rev
Log:
[Fixed Point Arithmetic] Add APFixedPoint to APValue

This adds APFixedPoint to the union of values that can be represented with an 
APValue.

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

Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/FixedPoint.h
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Basic/FixedPoint.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=351368&r1=351367&r2=351368&view=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Wed Jan 16 10:53:05 2019
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_APVALUE_H
 #define LLVM_CLANG_AST_APVALUE_H
 
+#include "clang/Basic/FixedPoint.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
@@ -43,6 +44,7 @@ public:
 Uninitialized,
 Int,
 Float,
+FixedPoint,
 ComplexInt,
 ComplexFloat,
 LValue,
@@ -175,6 +177,9 @@ public:
   explicit APValue(APFloat F) : Kind(Uninitialized) {
 MakeFloat(); setFloat(std::move(F));
   }
+  explicit APValue(APFixedPoint FX) : Kind(Uninitialized) {
+MakeFixedPoint(std::move(FX));
+  }
   explicit APValue(const APValue *E, unsigned N) : Kind(Uninitialized) {
 MakeVector(); setVector(E, N);
   }
@@ -233,6 +238,7 @@ public:
   bool isUninit() const { return Kind == Uninitialized; }
   bool isInt() const { return Kind == Int; }
   bool isFloat() const { return Kind == Float; }
+  bool isFixedPoint() const { return Kind == FixedPoint; }
   bool isComplexInt() const { return Kind == ComplexInt; }
   bool isComplexFloat() const { return Kind == ComplexFloat; }
   bool isLValue() const { return Kind == LValue; }
@@ -265,6 +271,14 @@ public:
 return const_cast(this)->getFloat();
   }
 
+  APFixedPoint &getFixedPoint() {
+assert(isFixedPoint() && "Invalid accessor");
+return *(APFixedPoint *)(char *)Data.buffer;
+  }
+  const APFixedPoint &getFixedPoint() const {
+return const_cast(this)->getFixedPoint();
+  }
+
   APSInt &getComplexIntReal() {
 assert(isComplexInt() && "Invalid accessor");
 return ((ComplexAPSInt*)(char*)Data.buffer)->Real;
@@ -406,6 +420,10 @@ public:
 assert(isFloat() && "Invalid accessor");
 *(APFloat *)(char *)Data.buffer = std::move(F);
   }
+  void setFixedPoint(APFixedPoint FX) {
+assert(isFixedPoint() && "Invalid accessor");
+*(APFixedPoint *)(char *)Data.buffer = std::move(FX);
+  }
   void setVector(const APValue *E, unsigned N) {
 assert(isVector() && "Invalid accessor");
 ((Vec*)(char*)Data.buffer)->Elts = new APValue[N];
@@ -465,6 +483,11 @@ private:
 new ((void*)(char*)Data.buffer) APFloat(0.0);
 Kind = Float;
   }
+  void MakeFixedPoint(APFixedPoint &&FX) {
+assert(isUninit() && "Bad state change");
+new ((void *)(char *)Data.buffer) APFixedPoint(std::move(FX));
+Kind = FixedPoint;
+  }
   void MakeVector() {
 assert(isUninit() && "Bad state change");
 new ((void*)(char*)Data.buffer) Vec();

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=351368&r1=351367&r2=351368&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jan 16 10:53:05 2019
@@ -6848,6 +6848,8 @@ QualType DecayedType::getPointeeType() c
 
 // Get the decimal string representation of a fixed point type, represented
 // as a scaled integer.
+// TODO: At some point, we should change the arguments to instead just accept 
an
+// APFixedPoint instead of APSInt and scale.
 void FixedPointValueToString(SmallVectorImpl &Str, llvm::APSInt Val,
  unsigned Scale);
 

Modified: cfe/trunk/include/clang/Basic/FixedPoint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=351368&r1=351367&r2=351368&view=diff
==
--- cfe/trunk/include/clang/Basic/FixedPoint.h (original)
+++ cfe/trunk/include/clang/Basic/FixedPoint.h Wed Jan 16 10:53:05 2019
@@ -18,6 +18,7 @@
 #define LLVM_CLANG_BASIC_FIXEDPOINT_H
 
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -104,19 +105,25 @@ class APFixedPoint {
: APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()),
   Sema) {}
 
+  

[PATCH] D56746: [Fixed Point Arithmetic] Add APFixedPoint to APValue

2019-01-16 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351368: [Fixed Point Arithmetic] Add APFixedPoint to APValue 
(authored by leonardchan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56746?vs=181918&id=182103#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56746/new/

https://reviews.llvm.org/D56746

Files:
  include/clang/AST/APValue.h
  include/clang/AST/Type.h
  include/clang/Basic/FixedPoint.h
  lib/AST/APValue.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Type.cpp
  lib/Basic/FixedPoint.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/SemaTemplate.cpp

Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -6848,6 +6848,8 @@
 
 // Get the decimal string representation of a fixed point type, represented
 // as a scaled integer.
+// TODO: At some point, we should change the arguments to instead just accept an
+// APFixedPoint instead of APSInt and scale.
 void FixedPointValueToString(SmallVectorImpl &Str, llvm::APSInt Val,
  unsigned Scale);
 
Index: include/clang/AST/APValue.h
===
--- include/clang/AST/APValue.h
+++ include/clang/AST/APValue.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_APVALUE_H
 #define LLVM_CLANG_AST_APVALUE_H
 
+#include "clang/Basic/FixedPoint.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
@@ -43,6 +44,7 @@
 Uninitialized,
 Int,
 Float,
+FixedPoint,
 ComplexInt,
 ComplexFloat,
 LValue,
@@ -175,6 +177,9 @@
   explicit APValue(APFloat F) : Kind(Uninitialized) {
 MakeFloat(); setFloat(std::move(F));
   }
+  explicit APValue(APFixedPoint FX) : Kind(Uninitialized) {
+MakeFixedPoint(std::move(FX));
+  }
   explicit APValue(const APValue *E, unsigned N) : Kind(Uninitialized) {
 MakeVector(); setVector(E, N);
   }
@@ -233,6 +238,7 @@
   bool isUninit() const { return Kind == Uninitialized; }
   bool isInt() const { return Kind == Int; }
   bool isFloat() const { return Kind == Float; }
+  bool isFixedPoint() const { return Kind == FixedPoint; }
   bool isComplexInt() const { return Kind == ComplexInt; }
   bool isComplexFloat() const { return Kind == ComplexFloat; }
   bool isLValue() const { return Kind == LValue; }
@@ -265,6 +271,14 @@
 return const_cast(this)->getFloat();
   }
 
+  APFixedPoint &getFixedPoint() {
+assert(isFixedPoint() && "Invalid accessor");
+return *(APFixedPoint *)(char *)Data.buffer;
+  }
+  const APFixedPoint &getFixedPoint() const {
+return const_cast(this)->getFixedPoint();
+  }
+
   APSInt &getComplexIntReal() {
 assert(isComplexInt() && "Invalid accessor");
 return ((ComplexAPSInt*)(char*)Data.buffer)->Real;
@@ -406,6 +420,10 @@
 assert(isFloat() && "Invalid accessor");
 *(APFloat *)(char *)Data.buffer = std::move(F);
   }
+  void setFixedPoint(APFixedPoint FX) {
+assert(isFixedPoint() && "Invalid accessor");
+*(APFixedPoint *)(char *)Data.buffer = std::move(FX);
+  }
   void setVector(const APValue *E, unsigned N) {
 assert(isVector() && "Invalid accessor");
 ((Vec*)(char*)Data.buffer)->Elts = new APValue[N];
@@ -465,6 +483,11 @@
 new ((void*)(char*)Data.buffer) APFloat(0.0);
 Kind = Float;
   }
+  void MakeFixedPoint(APFixedPoint &&FX) {
+assert(isUninit() && "Bad state change");
+new ((void *)(char *)Data.buffer) APFixedPoint(std::move(FX));
+Kind = FixedPoint;
+  }
   void MakeVector() {
 assert(isUninit() && "Bad state change");
 new ((void*)(char*)Data.buffer) Vec();
Index: include/clang/Basic/FixedPoint.h
===
--- include/clang/Basic/FixedPoint.h
+++ include/clang/Basic/FixedPoint.h
@@ -18,6 +18,7 @@
 #define LLVM_CLANG_BASIC_FIXEDPOINT_H
 
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -104,19 +105,25 @@
: APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()),
   Sema) {}
 
+   // Zero initialization.
+   APFixedPoint(const FixedPointSemantics &Sema) : APFixedPoint(0, Sema) {}
+
llvm::APSInt getValue() const { return llvm::APSInt(Val, !Sema.isSigned()); }
inline unsigned getWidth() const { return Sema.getWidth(); }
inline unsigned getScale() const { return Sema.getScale(); }
inline bool isSaturated() const { return Sema.isSaturated(); }
inline bool isSigned() const { return Sema.isSigned(); }
inline bool hasPadding() const { return Sema.hasUnsignedPadding(); }
+   FixedPointSemantics getSemantics() const { return Sema; }
+
+   bool getBoolValue() const { return Val.getBoolValue(); }
 
// Convert this number to match the semantics provided.
APFixedPoint convert(const FixedPointSemantics &DstSema

[PATCH] D56735: [OpenCL] Fix overloading ranking rules to work correctly for address space conversions

2019-01-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks, LGTM.

Well, actually, could you improve the test case to verify that the right 
overload is called?  This should be easy because C++ type-checking is 
bottom-up: just make the functions return something distinguishable, e.g. 
`struct`s that declare different members.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56735/new/

https://reviews.llvm.org/D56735



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


[PATCH] D55844: [Fixed Point Arithmetic] Fixed Point Subtraction

2019-01-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3451
+  case BO_Comma:
+llvm_unreachable("Found unimplemented fixed point binary operation");
   }

rjmccall wrote:
> Please create a separate case for the non-arithmetic operators 
> (pointer-to-member, assignment, comma) that will obviously never end up in 
> this function.
> 
> Otherwise, LGTM.
Done. Although this patch wasn't marked as ready to land, do you mean that I 
can commit it still with the LGTM?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55844/new/

https://reviews.llvm.org/D55844



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


[PATCH] D55844: [Fixed Point Arithmetic] Fixed Point Subtraction

2019-01-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 182108.
leonardchan marked 2 inline comments as done.

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55844/new/

https://reviews.llvm.org/D55844

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_sub.c

Index: clang/test/Frontend/fixed_point_sub.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_sub.c
@@ -0,0 +1,390 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+void SignedSubtraction() {
+  // CHECK-LABEL: SignedSubtraction
+  short _Accum sa;
+  _Accum a, b, c, d;
+  long _Accum la;
+  unsigned short _Accum usa;
+  unsigned _Accum ua;
+  unsigned long _Accum ula;
+
+  short _Fract sf;
+  _Fract f;
+  long _Fract lf;
+  unsigned short _Fract usf;
+  unsigned _Fract uf;
+  unsigned long _Fract ulf;
+
+  // Same type
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SA2:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i16 [[SA]], [[SA2]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa - sa;
+
+  // To larger scale and larger width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i32
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i32 [[EXT_SA]], 8
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i32 [[SA]], [[A]]
+  // CHECK-NEXT: store i32 [[SUM]], i32* %a, align 4
+  a = sa - a;
+
+  // To same scale and smaller width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SF:%[0-9]+]] = load i8, i8* %sf, align 1
+  // CHECK-NEXT: [[EXT_SF:%[a-z0-9]+]] = sext i8 [[SF]] to i16
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i16 [[SA]], [[EXT_SF]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa - sf;
+
+  // To smaller scale and same width.
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[F:%[0-9]+]] = load i16, i16* %f, align 2
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i24
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i24 [[EXT_SA]], 8
+  // CHECK-NEXT: [[EXT_F:%[a-z0-9]+]] = sext i16 [[F]] to i24
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i24 [[SA]], [[EXT_F]]
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = ashr i24 [[SUM]], 8
+  // CHECK-NEXT: [[TRUNC_RES:%[a-z0-9]+]] = trunc i24 [[RES]] to i16
+  // CHECK-NEXT: store i16 [[TRUNC_RES]], i16* %sa, align 2
+  sa = sa - f;
+
+  // To smaller scale and smaller width
+  // CHECK:  [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[SF:%[0-9]+]] = load i8, i8* %sf, align 1
+  // CHECK-NEXT: [[EXT_SF:%[a-z0-9]+]] = sext i8 [[SF]] to i32
+  // CHECK-NEXT: [[SF:%[a-z0-9]+]] = shl i32 [[EXT_SF]], 8
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i32 [[A]], [[SF]]
+  // CHECK-NEXT: store i32 [[SUM]], i32* %a, align 4
+  a = a - sf;
+
+  // To larger scale and same width
+  // CHECK:  [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[LF:%[0-9]+]] = load i32, i32* %lf, align 4
+  // CHECK-NEXT: [[EXT_A:%[a-z0-9]+]] = sext i32 [[A]] to i48
+  // CHECK-NEXT: [[A:%[a-z0-9]+]] = shl i48 [[EXT_A]], 16
+  // CHECK-NEXT: [[EXT_LF:%[a-z0-9]+]] = sext i32 [[LF]] to i48
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i48 [[A]], [[EXT_LF]]
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = ashr i48 [[SUM]], 16
+  // CHECK-NEXT: [[TRUNC_RES:%[a-z0-9]+]] = trunc i48 [[RES]] to i32
+  // CHECK-NEXT: store i32 [[TRUNC_RES]], i32* %a, align 4
+  a = a - lf;
+
+  // With corresponding unsigned type
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[USA:%[0-9]+]] = load i16, i16* %usa, align 2
+  // SIGNED-NEXT: [[SA_EXT:%[a-z0-9]+]] = sext i16 [[SA]] to i17
+  // SIGNED-NEXT: [[SA:%[a-z0-9]+]] = shl i17 [[SA_EXT]], 1
+  // SIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i16 [[USA]] to i17
+  // SIGNED-NEXT: [[SUM:%[0-9]+]] = sub i17 [[SA]], [[USA_EXT]]
+  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = ashr i17 [[SUM]], 1
+  // SIGNED-NEXT: [[SUM:%[a-z0-9]+]] = trunc i17 [[RESULT]] to i16
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = sub i16 [[SA]], [[USA]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa - usa;
+
+  // With unsigned of larger scale
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[USA:%[0-9]+]] = load i32, i32* %ua, align 4
+  // SIGNED-NEXT: [[SA_EXT:%[a-z0-9]+]] = sext i16 [[SA]] to i33
+  // SIGNED-NEXT: [[SA:%[a-z0-9]+]] = shl i33 [[SA_EXT]], 9
+  // SIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i32 [[USA]] to i33
+  // SIGNED-NEXT: [[SUM:%[0-9]+]] = sub i33 [[SA]], [[USA_EXT]]
+  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = ashr i33 [[SUM]], 1
+  // SIGNED-NEXT: [[SUM:%[a

[PATCH] D55844: [Fixed Point Arithmetic] Fixed Point Subtraction

2019-01-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't pay attention to "ready to land" because I assume that you're verifying 
that your patch actually works as promised in practice, at least as far as the 
tests are concerned (and presumably my review catches deeper issues). If there 
are substantial changes that landed after my review, then I need to re-review; 
otherwise, you should feel free to commit with that kind of provisional LGTM 
when you've satisfied the provisions.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55844/new/

https://reviews.llvm.org/D55844



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


  1   2   >