[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297004: [clang-tidy] misc-use-after-move: Fix failing 
assertion (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D30569?vs=90462&id=90658#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30569

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp


Index: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -398,7 +398,7 @@
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall)
+  if (!MovingCall || !MovingCall->getExprLoc().isValid())
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;
Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
@@ -282,7 +282,7 @@
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was 
moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;


Index: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -398,7 +398,7 @@
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall)
+  if (!MovingCall || !MovingCall->getExprLoc().isValid())
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;
Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
@@ -282,7 +282,7 @@
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r297004 - [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Martin Bohme via cfe-commits
Author: mboehme
Date: Mon Mar  6 02:55:42 2017
New Revision: 297004

URL: http://llvm.org/viewvc/llvm-project?rev=297004&view=rev
Log:
[clang-tidy] misc-use-after-move: Fix failing assertion

Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp?rev=297004&r1=297003&r2=297004&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp Mon Mar  6 
02:55:42 2017
@@ -398,7 +398,7 @@ void UseAfterMoveCheck::check(const Matc
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall)
+  if (!MovingCall || !MovingCall->getExprLoc().isValid())
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp?rev=297004&r1=297003&r2=297004&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp Mon Mar  6 
02:55:42 2017
@@ -282,7 +282,7 @@ void moveInInitList() {
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@ void movedTypeIsDependentType() {
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was 
moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;


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


[PATCH] D30636: [analyzer] Fix crash when building CFG with variable of incomplete type

2017-03-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.

I've included a unit test with a function template containing a variable
of incomplete type. Clang compiles this without errors (the standard
does not require a diagnostic in this case). Without the fix, this case
triggers the crash.


https://reviews.llvm.org/D30636

Files:
  lib/Analysis/CFG.cpp
  unittests/Analysis/CFGTest.cpp


Index: unittests/Analysis/CFGTest.cpp
===
--- unittests/Analysis/CFGTest.cpp
+++ unittests/Analysis/CFGTest.cpp
@@ -35,7 +35,9 @@
 if (!Body)
   return;
 TheBuildResult = SawFunctionBody;
-if (CFG::buildCFG(nullptr, Body, Result.Context, CFG::BuildOptions()))
+CFG::BuildOptions Options;
+Options.AddImplicitDtors = true;
+if (CFG::buildCFG(nullptr, Body, Result.Context, Options))
 TheBuildResult = BuiltCFG;
   }
 };
@@ -75,6 +77,16 @@
   EXPECT_EQ(BuiltCFG, BuildCFG(Code));
 }
 
+// Constructing a CFG on a function template with a variable of incomplete type
+// should not crash.
+TEST(CFG, VariableOfIncompleteType) {
+  const char *Code = "template void f() {\n"
+ "  class Undefined;\n"
+ "  Undefined u;\n"
+ "}\n";
+  EXPECT_EQ(BuiltCFG, BuildCFG(Code));
+}
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1390,7 +1390,7 @@
 
   // Check if type is a C++ class with non-trivial destructor.
   if (const CXXRecordDecl *CD = QT->getAsCXXRecordDecl())
-if (!CD->hasTrivialDestructor()) {
+if (CD->hasDefinition() && !CD->hasTrivialDestructor()) {
   // Add the variable to scope
   Scope = createOrReuseLocalScope(Scope);
   Scope->addVar(VD);


Index: unittests/Analysis/CFGTest.cpp
===
--- unittests/Analysis/CFGTest.cpp
+++ unittests/Analysis/CFGTest.cpp
@@ -35,7 +35,9 @@
 if (!Body)
   return;
 TheBuildResult = SawFunctionBody;
-if (CFG::buildCFG(nullptr, Body, Result.Context, CFG::BuildOptions()))
+CFG::BuildOptions Options;
+Options.AddImplicitDtors = true;
+if (CFG::buildCFG(nullptr, Body, Result.Context, Options))
 TheBuildResult = BuiltCFG;
   }
 };
@@ -75,6 +77,16 @@
   EXPECT_EQ(BuiltCFG, BuildCFG(Code));
 }
 
+// Constructing a CFG on a function template with a variable of incomplete type
+// should not crash.
+TEST(CFG, VariableOfIncompleteType) {
+  const char *Code = "template void f() {\n"
+ "  class Undefined;\n"
+ "  Undefined u;\n"
+ "}\n";
+  EXPECT_EQ(BuiltCFG, BuildCFG(Code));
+}
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1390,7 +1390,7 @@
 
   // Check if type is a C++ class with non-trivial destructor.
   if (const CXXRecordDecl *CD = QT->getAsCXXRecordDecl())
-if (!CD->hasTrivialDestructor()) {
+if (CD->hasDefinition() && !CD->hasTrivialDestructor()) {
   // Add the variable to scope
   Scope = createOrReuseLocalScope(Scope);
   Scope->addVar(VD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r297005 - Do not include GCC "resource" directory into the set of built-in include paths on MingW.

2017-03-06 Thread Anton Korobeynikov via cfe-commits
Author: asl
Date: Mon Mar  6 03:32:56 2017
New Revision: 297005

URL: http://llvm.org/viewvc/llvm-project?rev=297005&view=rev
Log:
Do not include GCC "resource" directory into the set of built-in include paths 
on MingW.

Patch by Mateusz Mikuła.

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


Modified:
cfe/trunk/lib/Driver/MinGWToolChain.cpp
cfe/trunk/test/Driver/mingw.cpp

Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=297005&r1=297004&r2=297005&view=diff
==
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Mon Mar  6 03:32:56 2017
@@ -148,23 +148,17 @@ void MinGW::printVerboseInfo(raw_ostream
 // c:\mingw\lib\gcc\mingw32\4.8.1\include\c++
 // c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\mingw32
 // c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\backward
-// c:\mingw\lib\gcc\mingw32\4.8.1\include
 // c:\mingw\include
-// c:\mingw\lib\gcc\mingw32\4.8.1\include-fixed
 // c:\mingw\mingw32\include
 
 // Windows, mingw-w64 mingw-builds
-// c:\mingw32\lib\gcc\i686-w64-mingw32\4.9.1\include
-// c:\mingw32\lib\gcc\i686-w64-mingw32\4.9.1\include-fixed
 // c:\mingw32\i686-w64-mingw32\include
 // c:\mingw32\i686-w64-mingw32\include\c++
 // c:\mingw32\i686-w64-mingw32\include\c++\i686-w64-mingw32
 // c:\mingw32\i686-w64-mingw32\include\c++\backward
 
 // Windows, mingw-w64 msys2
-// c:\msys64\mingw32\lib\gcc\i686-w64-mingw32\4.9.2\include
 // c:\msys64\mingw32\include
-// c:\msys64\mingw32\lib\gcc\i686-w64-mingw32\4.9.2\include-fixed
 // c:\msys64\mingw32\i686-w64-mingw32\include
 // c:\msys64\mingw32\include\c++\4.9.2
 // c:\msys64\mingw32\include\c++\4.9.2\i686-w64-mingw32
@@ -174,24 +168,18 @@ void MinGW::printVerboseInfo(raw_ostream
 // /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++
 // /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32
 // /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward
-// /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include
-// /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include-fixed
 // /usr/x86_64-w64-mingw32/sys-root/mingw/include
 
 // Arch Linux
 // /usr/i686-w64-mingw32/include/c++/5.1.0
 // /usr/i686-w64-mingw32/include/c++/5.1.0/i686-w64-mingw32
 // /usr/i686-w64-mingw32/include/c++/5.1.0/backward
-// /usr/lib/gcc/i686-w64-mingw32/5.1.0/include
-// /usr/lib/gcc/i686-w64-mingw32/5.1.0/include-fixed
 // /usr/i686-w64-mingw32/include
 
 // Ubuntu
 // /usr/include/c++/4.8
 // /usr/include/c++/4.8/x86_64-w64-mingw32
 // /usr/include/c++/4.8/backward
-// /usr/lib/gcc/x86_64-w64-mingw32/4.8/include
-// /usr/lib/gcc/x86_64-w64-mingw32/4.8/include-fixed
 // /usr/x86_64-w64-mingw32/include
 
 void MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
@@ -209,15 +197,11 @@ void MinGW::AddClangSystemIncludeArgs(co
 return;
 
   if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) {
-llvm::SmallString<1024> IncludeDir(GccLibDir);
-llvm::sys::path::append(IncludeDir, "include");
-addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
-IncludeDir += "-fixed";
 // openSUSE
 addSystemInclude(DriverArgs, CC1Args,
  Base + Arch + "/sys-root/mingw/include");
-addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
   }
+
   addSystemInclude(DriverArgs, CC1Args,
Base + Arch + llvm::sys::path::get_separator() + "include");
   addSystemInclude(DriverArgs, CC1Args, Base + "include");

Modified: cfe/trunk/test/Driver/mingw.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw.cpp?rev=297005&r1=297004&r2=297005&view=diff
==
--- cfe/trunk/test/Driver/mingw.cpp (original)
+++ cfe/trunk/test/Driver/mingw.cpp Mon Mar  6 03:32:56 2017
@@ -7,8 +7,6 @@
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}{{/|}}Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include"
-// CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include-fixed"
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}mingw32{{/|}}include"
 // CHECK_MINGW_ORG_TREE: 
{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}include
 
@@ -17,8 +15,6 @@
 // CHECK_MINGW_BUILDS_TRE

[PATCH] D29464: [MinGWToolChain] Don't use GCC headers on Win32

2017-03-06 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297005: Do not include GCC "resource" directory into the set 
of built-in include paths… (authored by asl).

Changed prior to commit:
  https://reviews.llvm.org/D29464?vs=87827&id=90661#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29464

Files:
  cfe/trunk/lib/Driver/MinGWToolChain.cpp
  cfe/trunk/test/Driver/mingw.cpp

Index: cfe/trunk/test/Driver/mingw.cpp
===
--- cfe/trunk/test/Driver/mingw.cpp
+++ cfe/trunk/test/Driver/mingw.cpp
@@ -7,53 +7,41 @@
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
 // CHECK_MINGW_ORG_TREE: "{{.*}}{{/|}}Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include"
-// CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include-fixed"
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}mingw32{{/|}}include"
 // CHECK_MINGW_ORG_TREE: {{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}include
 
 
 // RUN: %clang -target i686-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_mingw_builds_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_BUILDS_TREE %s
 // CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++"
 // CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}i686-w64-mingw32"
 // CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}lib{{/|}}gcc{{/|}}i686-w64-mingw32{{/|}}4.9.1{{/|}}include"
-// CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}lib{{/|}}gcc{{/|}}i686-w64-mingw32{{/|}}4.9.1{{/|}}include-fixed"
 // CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
 
 
 // RUN: %clang -target i686-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_msys2_tree/msys64/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_MSYS_TREE %s
 // CHECK_MINGW_MSYS_TREE: "{{.*}}/Inputs/mingw_msys2_tree/msys64{{/|}}mingw32{{/|}}include{{/|}}c++{{/|}}4.9.2"
 // CHECK_MINGW_MSYS_TREE: "{{.*}}/Inputs/mingw_msys2_tree/msys64/mingw32{{/|}}include{{/|}}c++{{/|}}4.9.2{{/|}}i686-w64-mingw32"
 // CHECK_MINGW_MSYS_TREE: "{{.*}}/Inputs/mingw_msys2_tree/msys64/mingw32{{/|}}include{{/|}}c++{{/|}}4.9.2{{/|}}backward"
-// CHECK_MINGW_MSYS_TREE:  "{{.*}}/Inputs/mingw_msys2_tree/msys64/mingw32{{/|}}lib{{/|}}gcc{{/|}}i686-w64-mingw32{{/|}}4.9.2{{/|}}include"
-// CHECK_MINGW_MSYS_TREE:  "{{.*}}/Inputs/mingw_msys2_tree/msys64/mingw32{{/|}}lib{{/|}}gcc{{/|}}i686-w64-mingw32{{/|}}4.9.2{{/|}}include-fixed"
 // CHECK_MINGW_MSYS_TREE: "{{.*}}/Inputs/mingw_msys2_tree/msys64/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
 // CHECK_MINGW_MSYS_TREE: "{{.*}}/Inputs/mingw_msys2_tree/msys64/mingw32{{/|}}include"
 
 
 // RUN: %clang -target x86_64-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_opensuse_tree/usr %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_OPENSUSE_TREE %s
 // CHECK_MINGW_OPENSUSE_TREE: "{{.*}}/Inputs/mingw_opensuse_tree/usr{{/|}}lib64{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.1.0{{/|}}include{{/|}}c++"
 // CHECK_MINGW_OPENSUSE_TREE: "{{.*}}/Inputs/mingw_opensuse_tree/usr{{/|}}lib64{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.1.0{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_OPENSUSE_TREE: "{{.*}}/Inputs/mingw_opensuse_tree/usr{{/|}}lib64{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.1.0{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_MINGW_OPENSUSE_TREE: "{{.*}}/Inputs/mingw_opensuse_tree/usr{{/|}}lib64{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.1.0{{/|}}include"
 // CHECK_MINGW_OPENSUSE_TREE: "{{.*}}/Inputs/mingw_opensuse_tree/usr{{/|}}x86_64-w64-mingw32/sys-root/mingw/include"
-// CHECK_MINGW_OPENSUSE_TREE: "{{.*}}/Inputs/mingw_opensuse_tree/usr{{/|}}lib64{{/|}}gc

[PATCH] D30636: [analyzer] Fix crash when building CFG with variable of incomplete type

2017-03-06 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D30636



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


[PATCH] D29464: [MinGWToolChain] Don't use GCC headers on Win32

2017-03-06 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Thank you.


Repository:
  rL LLVM

https://reviews.llvm.org/D29464



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


[PATCH] D29772: Create msbuild only when using MSVC

2017-03-06 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Thank you.


https://reviews.llvm.org/D29772



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


[clang-tools-extra] r297006 - Revert "[clang-tidy] misc-use-after-move: Fix failing assertion"

2017-03-06 Thread Martin Bohme via cfe-commits
Author: mboehme
Date: Mon Mar  6 03:46:27 2017
New Revision: 297006

URL: http://llvm.org/viewvc/llvm-project?rev=297006&view=rev
Log:
Revert "[clang-tidy] misc-use-after-move: Fix failing assertion"

This reverts commit r297004; it was causing buildbots to fail.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp?rev=297006&r1=297005&r2=297006&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp Mon Mar  6 
03:46:27 2017
@@ -398,7 +398,7 @@ void UseAfterMoveCheck::check(const Matc
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall || !MovingCall->getExprLoc().isValid())
+  if (!MovingCall)
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp?rev=297006&r1=297005&r2=297006&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp Mon Mar  6 
03:46:27 2017
@@ -282,7 +282,7 @@ void moveInInitList() {
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
 }
 
 void lambdas() {
@@ -397,21 +397,6 @@ void movedTypeIsDependentType() {
 }
 template void movedTypeIsDependentType();
 
-// We handle the case correctly where the move consists of an implicit call
-// to a conversion operator.
-void implicitConversionOperator() {
-  struct Convertible {
-operator A() && { return A(); }
-  };
-  void takeA(A a);
-
-  Convertible convertible;
-  takeA(std::move(convertible));
-  convertible;
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was 
moved
-  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
-}
-
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;


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


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-03-06 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:54
+// FIXME use DiagnosticIDs::Level::Note
+diag(NoExceptRange.getBegin(), "in a function declared no-throw here:", 
DiagnosticIDs::Note)
+<< FixItHint::CreateRemoval(NoExceptRange);

alexfh wrote:
> Prazek wrote:
> > sbarzowski wrote:
> > > Prazek wrote:
> > > > sbarzowski wrote:
> > > > > alexfh wrote:
> > > > > > nit: `nothrow` (without a dash), no colon needed (it will look 
> > > > > > weird, since the location is mentioned _before_ the message, not 
> > > > > > after it)
> > > > > No, it's after the message now. When I changed the level to note the 
> > > > > order of messages changed as well.
> > > > > 
> > > > > It looks like that:
> > > > > ```
> > > > > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:5:5:
> > > > >  warning: 'throw' expression in a function declared with a 
> > > > > non-throwing exception specification [misc-throw-with-noexcept]
> > > > > throw 5;
> > > > > ^
> > > > > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
> > > > >  note: FIX-IT applied suggested code changes
> > > > > void f_throw_with_ne() noexcept(true) {
> > > > >^
> > > > > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
> > > > >  note: in a function declared nothrow here:
> > > > > void f_throw_with_ne() noexcept(true) {
> > > > >^
> > > > > 
> > > > > ```
> > > > > 
> > > > > So, should I leave the colon or remove it anyway?
> > > > I think that the best way would be to have warnings in order:
> > > > 
> > > > warning function declared nothrow here have throw statement inside:
> > > > Note: throw statement here
> > > > 
> > > > Note: Fixit applied for every other declaration
> > > > 
> > > > What do you think Alex?
> > > > 
> > > > 
> > > > 
> > > @Prazek 
> > > So, do you suggest that we don't emit anything for additional 
> > > declarations (without -fix)?
> > > 
> > > BTW (in the current version) I don't know if I can control if FIX-IT goes 
> > > first or the location message. As you can see in the code the FIX-IT goes 
> > > after the location.
> > Yep, there is no need for user to know all the locations if he doesn't want 
> > to perform fixit. This way it is easier to read the warning.
> The `FIX-IT applied suggested code changes` notes are shown by clang-tidy 
> itself and only when the user passes -fix flag. There's no way to control 
> them from the check (apart from removing fixes or attaching them to a 
> different warning).
That's right, but does it make sense to show user all the places where the 
function was declared?
I am not sure what clang would normally do



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.h:20
+///\brief Warns about using throw in function declared as noexcept.
+/// It complains about every throw, even if it is caught later.
+class ThrowWithNoexceptCheck : public ClangTidyCheck {

aaron.ballman wrote:
> What is the false positive rate with this check over a large codebase that 
> uses exceptions?
Do you know any good project to check it?


https://reviews.llvm.org/D19201



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: JDevlieghere.

https://reviews.llvm.org/D30639

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,14 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_vale = 0) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), 
hasCastKind(CK_NullToMemberPointer)),
+  
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,14 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_vale = 0) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
+  unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/clang-tidy/modernize-use-nullptr.cpp:252
+ public:
+  explicit TemplateClass(int a, T default_vale = 0) {}
+};

vale -> value


https://reviews.llvm.org/D30639



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


[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization

2017-03-06 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

I saw the same changes in the following review: https://reviews.llvm.org/D17438

I don't know in that way I could determine that atomic variable was initialized 
by macro ATOMIC_VAR_INIT. Anyway I added check that atomic variables can be 
initialize only in global scope.
I think that we can discuss this change.


https://reviews.llvm.org/D30643

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/SemaOpenCL/atomic-init.cl


Index: test/SemaOpenCL/atomic-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-init.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify  %s
+
+global atomic_int a1 = 0;
+
+kernel void test_atomic_initialization() {
+  atomic_int a2 = 0; // expected-error {{initialization of atomic variables is 
restricted to variables in global address space}}
+  private atomic_int a3 = 0; // expected-error {{initialization of atomic 
variables is restricted to variables in global address space}}
+  local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have 
an initializer}}
+  global atomic_int a5 = 0; // expected-error {{function scope variable cannot 
be declared in global address space}}
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6489,6 +6489,21 @@
   << Init->getSourceRange();
   }
 
+  // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global 
scope
+  QualType ETy = Entity.getType();
+  Qualifiers TyQualifiers = ETy.getQualifiers();
+  bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
+ TyQualifiers.getAddressSpace() == LangAS::opencl_global;
+
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200 &&
+  ETy->isAtomicType() && !HasGlobalAS &&
+  Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) {
+const Expr *Init = Args[0];
+S.Diag(Init->getLocStart(), diag::err_atomic_init_addressspace) <<
+SourceRange(Entity.getDecl()->getLocStart(), Init->getLocEnd());
+return ExprError();
+  }
+
   // Diagnose cases where we initialize a pointer to an array temporary, and 
the
   // pointer obviously outlives the temporary.
   if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8258,6 +8258,9 @@
   "return value cannot be qualified with address space">;
 def err_opencl_constant_no_init : Error<
   "variable in constant address space must be initialized">;
+// Atomics
+def err_atomic_init_addressspace : Error<
+  "initialization of atomic variables is restricted to variables in global 
address space">;
 def err_atomic_init_constant : Error<
   "atomic variable can only be assigned to a compile time constant"
   " in the declaration statement in the program scope">;


Index: test/SemaOpenCL/atomic-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-init.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify  %s
+
+global atomic_int a1 = 0;
+
+kernel void test_atomic_initialization() {
+  atomic_int a2 = 0; // expected-error {{initialization of atomic variables is restricted to variables in global address space}}
+  private atomic_int a3 = 0; // expected-error {{initialization of atomic variables is restricted to variables in global address space}}
+  local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have an initializer}}
+  global atomic_int a5 = 0; // expected-error {{function scope variable cannot be declared in global address space}}
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6489,6 +6489,21 @@
   << Init->getSourceRange();
   }
 
+  // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope
+  QualType ETy = Entity.getType();
+  Qualifiers TyQualifiers = ETy.getQualifiers();
+  bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
+ TyQualifiers.getAddressSpace() == LangAS::opencl_global;
+
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200 &&
+  ETy->isAtomicType() && !HasGlobalAS &&
+  Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) {
+const Expr *Init = Args[0];
+S.Diag(Init->getLocStart(), diag::err_atomic_init_addressspace) <<
+SourceRange(Entity.getDecl()->getLocStart(), Init->getLocEnd());
+return ExprError();
+  }
+
   // Diagnose cases where we initialize a pointer to an array temporary, and the
   // pointer obviously outlives the

[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 90677.
hokein marked an inline comment as done.
hokein added a comment.

typo: vale => value.


https://reviews.llvm.org/D30639

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,14 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), 
hasCastKind(CK_NullToMemberPointer)),
+  
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,14 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
+  unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30157: [analyzer] Improve valist check

2017-03-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 90676.
xazax.hun marked an inline comment as done.
xazax.hun added a comment.

- Improve the readability of test files.
- Rebased on latest ToT.


https://reviews.llvm.org/D30157

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/valist-uninitialized-no-undef.c
  test/Analysis/valist-uninitialized.c
  test/Analysis/valist-unterminated.c

Index: test/Analysis/valist-unterminated.c
===
--- test/Analysis/valist-unterminated.c
+++ test/Analysis/valist-unterminated.c
@@ -1,49 +1,56 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -triple hexagon-unknown-linux -analyzer-checker=core,valist.Unterminated,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,valist.Unterminated,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
 
 void f1(int fst, ...) {
   va_list va;
   va_start(va, fst); // expected-note{{Initialized va_list}}
-  return; // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}
+  return; // expected-warning{{Initialized va_list 'va' is leaked}}
+  // expected-note@-1{{Initialized va_list 'va' is leaked}}
 }
 
 void f2(int fst, ...) {
   va_list va;
   va_start(va, fst); // expected-note{{Initialized va_list}}
   va_end(va); // expected-note{{Ended va_list}}
   va_start(va, fst); // expected-note{{Initialized va_list}}
-} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}}
+} // expected-warning{{Initialized va_list 'va' is leaked}}
+  // expected-note@-1{{Initialized va_list 'va' is leaked}}
 
 void f3(int fst, ...) {
   va_list va, va2;
   va_start(va, fst);
   va_copy(va2, va); // expected-note{{Initialized va_list}}
-  va_end(va); // expected-warning{{Initialized va_list 'va2' is leaked}} expected-note{{Initialized va_list 'va2' is leaked}}
+  va_end(va); // expected-warning{{Initialized va_list 'va2' is leaked}}
+  // expected-note@-1{{Initialized va_list 'va2' is leaked}}
 }
 
 void f4(va_list *fst, ...) {
   va_start(*fst, fst); // expected-note{{Initialized va_list}}
-  return; // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}}
+  return; // expected-warning{{Initialized va_list is leaked}}
+  // expected-note@-1{{Initialized va_list is leaked}}
 }
 
 void f5(va_list fst, ...) {
-  va_start(fst, fst);
-  //FIXME: this should cause a warning
-} // no-warning
+  va_start(fst, fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list}}
+  // expected-note@-1{{Initialized va_list}}
 
 void f6(va_list *fst, ...) {
   va_start(*fst, fst); // expected-note{{Initialized va_list}}
   (void)va_arg(*fst, int);
   //FIXME: this should NOT cause a warning
-  va_end(*fst); // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}}
+  va_end(*fst); // expected-warning{{Initialized va_list is leaked}}
+  // expected-note@-1{{Initialized va_list is leaked}}
 }
 
 void f7(int *fst, ...) {
   va_list x;
   va_list *y = &x;
   va_start(*y,fst); // expected-note{{Initialized va_list}}
-} // expected-warning{{Initialized va_list 'x' is leaked}} expected-note{{Initialized va_list 'x' is leaked}}
+} // expected-warning{{Initialized va_list 'x' is leaked}}
+  // expected-note@-1{{Initialized va_list 'x' is leaked}}
 
 void f8(int *fst, ...) {
   va_list x;
@@ -54,9 +61,12 @@
 
 void reinit(int *fst, ...) {
   va_list va;
-  va_start(va, fst); // expected-note{{Initialized va_list}} expected-note{{Initialized va_list}}
-  va_start(va, fst); // expected-warning{{Initialized va_list 'va' is initialized again}} expected-note{{Initialized va_list 'va' is initialized again}}
-} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+ // expected-note@-1{{Initialized va_list}}
+  va_start(va, fst); // expected-warning{{Initialized va_list 'va' is initialized again}}
+  // expected-note@-1{{Initialized va_list 'va' is initialized again}}
+} // expected-warning{{Initialized va_list 'va' is leaked}}
+  // expected-note@-1{{Initialized va_list 'va' is leaked}}
 
 void reinitOk(int *fst, ...) {
   va_list va;
@@ -69,20 +79,23 @@
 void copyself(int fst, ...) {
   va_list va;
   va_start(va, fst); // expected-note{{Initialized va_list}}
-  va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copie

[PATCH] D30157: [analyzer] Improve valist check

2017-03-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D30157#689374, @danielmarjamaki wrote:

> I am running this checker right now on various projects. Here are currently 
> seen results.. https://drive.google.com/open?id=0BykPmWrCOxt2STZMOXZ5OGlwM3c
>
> Feel free to look at it and see if there are FPs or TPs.


Thank you for running this check on those projects! I did not do a deep review 
of the findings but some of the results I checked are true positives. Also, the 
number of results are not scary, none of the projects generated tons of results.


https://reviews.llvm.org/D30157



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: test/clang-tidy/modernize-use-nullptr.cpp:252
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+};

It might be great to have a test case for:

```

template
class TemplateClass {
 public:
  explicit TemplateClass(int a, T *default_value = 0) {}
```


https://reviews.llvm.org/D30639



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


Re: r296927 - Add arch-specific directory to search path

2017-03-06 Thread Benjamin Kramer via cfe-commits
On Sat, Mar 4, 2017 at 12:20 AM, Pirama Arumuga Nainar via cfe-commits
 wrote:
> Author: pirama
> Date: Fri Mar  3 17:20:49 2017
> New Revision: 296927
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296927&view=rev
> Log:
> Add arch-specific directory to search path
>
> Summary:
>
> This change adds an arch-specific subdirectory in /lib/
> to the linker search path.  This path also gets added as '-rpath' for
> native compilation if a runtime is linked in as a shared object.  This
> allows arch-specific libraries to be installed alongside clang.
>
> Reviewers: danalbert, cbergstrom, javed.absar
>
> Subscribers: srhines
>
> Differential Revision: https://reviews.llvm.org/D30015
>
> Added:
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/
> 
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/
> 
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/
> 
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/
> 
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
> 
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/
> 
> cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
> cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
> cfe/trunk/test/Driver/arch-specific-libdir.c
> Modified:
> cfe/trunk/include/clang/Driver/ToolChain.h
> cfe/trunk/lib/Driver/ToolChain.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/lit.cfg
>
> Modified: cfe/trunk/include/clang/Driver/ToolChain.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=296927&r1=296926&r2=296927&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
> +++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Mar  3 17:20:49 2017
> @@ -299,6 +299,11 @@ public:
>const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
>   StringRef Component,
>   bool Shared = false) const;
> +
> +  // Returns /lib//.  This is used by runtimes 
> (such
> +  // as OpenMP) to find arch-specific libraries.
> +  std::string getArchSpecificLibPath() const;
> +
>/// needsProfileRT - returns true if instrumentation profile is on.
>static bool needsProfileRT(const llvm::opt::ArgList &Args);
>
>
> Modified: cfe/trunk/lib/Driver/ToolChain.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=296927&r1=296926&r2=296927&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Mar  3 17:20:49 2017
> @@ -10,6 +10,7 @@
>  #include "clang/Driver/ToolChain.h"
>  #include "Tools.h"
>  #include "clang/Basic/ObjCRuntime.h"
> +#include "clang/Basic/VirtualFileSystem.h"
>  #include "clang/Config/config.h"
>  #include "clang/Driver/Action.h"
>  #include "clang/Driver/Driver.h"
> @@ -74,6 +75,10 @@ ToolChain::ToolChain(const Driver &D, co
>  if (!isThreadModelSupported(A->getValue()))
>D.Diag(diag::err_drv_invalid_thread_model_for_target)
><< A->getValue() << A->getAsString(Args);
> +
> +  std::string CandidateLibPath = getArchSpecificLibPath();
> +  if (getVFS().exists(CandidateLibPath))
> +getFilePaths().push_back(CandidateLibPath);
>  }
>
>  ToolChain::~ToolChain() {
> @@ -320,6 +325,14 @@ const char *ToolChain::getCompilerRTArgS
>return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
>  }
>
> +std::string ToolChain::getArchSpecificLibPath() const {
> +  SmallString<128> Path(getDriver().ResourceDir);
> +  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
> +  llvm::sys::path::append(Path, "lib", OSLibName,
> +  llvm::Triple::getArchTypeName(getArch()));
> +  return Path.str();
> +}
> +
>  bool ToolChain::needsProfileRT(const ArgList &Args) {
>if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
> false) ||
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=296927&r1=296926&r2=296927&view=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar  3 17:20:49 2017
> @@ -14,6 +14,7 @@
>  #include "clang/Basic/LangOptions.h"
>  #include "clang/Basic/ObjCRu

[PATCH] D30534: [analyzer] When creating a temporary object copy, properly copy the value into it.

2017-03-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ planned changes to this revision.
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:286
+  // FIXME: Why do we need to do that if WipeV was known to begin with?
+  State = State->bindLoc(Reg, ExV, LC);
+

a.sidorin wrote:
> If I understand correcly, if we call `bindLoc()`, we call 
> `checkRegionChanges()` callbacks. And if we `bindLoc()` twice, we call them 
> twice too. Is this what we want here?
This is actually an excellent question.


https://reviews.llvm.org/D30534



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

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

LG


https://reviews.llvm.org/D30639



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 90691.
hokein marked an inline comment as done.
hokein added a comment.

Add more tests.


https://reviews.llvm.org/D30639

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,20 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+
+  void h(T *default_value = 0) {}
+
+  void f(int* p = 0) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+// CHECK-FIXES: void f(int* p = nullptr) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), 
hasCastKind(CK_NullToMemberPointer)),
+  
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,20 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+
+  void h(T *default_value = 0) {}
+
+  void f(int* p = 0) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+// CHECK-FIXES: void f(int* p = nullptr) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
+  unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: test/clang-tidy/modernize-use-nullptr.cpp:254
+
+  void h(T *default_value = 0) {}
+

Great! Thanks for adding this test. I have the impression we do want to warn 
and fix this case however. What do you think?


https://reviews.llvm.org/D30639



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: test/clang-tidy/modernize-use-nullptr.cpp:252
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+};

xazax.hun wrote:
> It might be great to have a test case for:
> 
> ```
> 
> template
> class TemplateClass {
>  public:
>   explicit TemplateClass(int a, T *default_value = 0) {}
> ```
Good catch. Done.


https://reviews.llvm.org/D30639



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


[PATCH] D30650: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: test/clang-tidy/misc-use-after-move.cpp:285
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }

The column in this message was nondeterministically being reported as either 6 
or 7. Disallowing InitListExpr as the moving call should guarantee that this 
will always be 7.


https://reviews.llvm.org/D30650



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


[PATCH] D30650: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added a subscriber: JDevlieghere.

I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.

This patch also fixes nondeterministic behavior in the source code
location reported for the move when the move is constained in an init list;
this was causing buildbot failures in the previous attempt to submit
this patch (see https://reviews.llvm.org/D30569 and 
https://reviews.llvm.org/rL297004).


https://reviews.llvm.org/D30650

Files:
  clang-tidy/misc/UseAfterMoveCheck.cpp
  test/clang-tidy/misc-use-after-move.cpp


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -282,7 +282,7 @@
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was 
moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -384,6 +384,13 @@
   // the direct ancestor of the std::move() that isn't one of the node
   // types ignored by ignoringParenImpCasts().
   stmt(forEach(expr(ignoringParenImpCasts(CallMoveMatcher))),
+   // Don't allow an InitListExpr to be the moving call. An 
InitListExpr
+   // has both a syntactic and a semantic form, and the parent-child
+   // relationships are different between the two. This could cause an
+   // InitListExpr to be analyzed as the moving call in addition to the
+   // Expr that we actually want, resulting in two diagnostics with
+   // different code locations for the same move.
+   unless(initListExpr()),
unless(expr(ignoringParenImpCasts(equalsBoundNode("call-move")
   .bind("moving-call"),
   this);
@@ -398,7 +405,7 @@
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall)
+  if (!MovingCall || !MovingCall->getExprLoc().isValid())
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -282,7 +282,7 @@
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -384,6 +384,13 @@
   // the direct ancestor of the std::move() that isn't one of the node
   // types ignored by ignoringParenImpCasts().
   stmt(forEach(expr(ignoringParenImpCasts(CallMoveMatcher))),
+   // Don't allow an InitListExpr to be the moving call. An InitListExpr
+   // has both a syntactic and a semantic form, and the parent-child
+   // relationships are different between the two. This could cause an
+   // InitListExpr to be analyzed as the moving call in addition to the
+   // Expr that we actually want, resulting in two diagnostics with
+   // different code l

[PATCH] D30465: [mips] Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64

2017-03-06 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

This wasn't trapped by my filters when it was first posted - sorry about that. 
In future if it's a mips related patch you can add me directly as a reviewer 
when posting the patch. Changing the subscribers doesn't nag the list or the 
newly added person. Also, please upload patches with context - 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

From my reading of the GCC sources with OpenBSD's patches and r282184, LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D30465



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


[clang-tools-extra] r297009 - [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Mar  6 08:46:44 2017
New Revision: 297009

URL: http://llvm.org/viewvc/llvm-project?rev=297009&view=rev
Log:
[clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: xazax.hun, malcolm.parsons, JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=297009&r1=297008&r2=297009&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Mon Mar  6 
08:46:44 2017
@@ -39,6 +39,7 @@ AST_MATCHER(Type, sugaredNullptrType) {
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), 
hasCastKind(CK_NullToMemberPointer)),
+  
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=297009&r1=297008&r2=297009&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Mon Mar  
6 08:46:44 2017
@@ -244,3 +244,20 @@ void f() {
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+
+  void h(T *default_value = 0) {}
+
+  void f(int* p = 0) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+// CHECK-FIXES: void f(int* p = nullptr) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}


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


[PATCH] D30532: Add examples to clang-format configuration

2017-03-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru marked 2 inline comments as done.
sylvestre.ledru added a comment.

Daniel, it is good for me now. 
Once it is accepted, I will work on the rest in a separate commit if that is ok 
with you;


https://reviews.llvm.org/D30532



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297009: [clang-tidy] Ignore substituted template types in 
modernize-use-nullptr check. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D30639?vs=90691&id=90694#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30639

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,20 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+
+  void h(T *default_value = 0) {}
+
+  void f(int* p = 0) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+// CHECK-FIXES: void f(int* p = nullptr) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), 
hasCastKind(CK_NullToMemberPointer)),
+  
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -244,3 +244,20 @@
   bool a;
   a = ZZ(Hash());
 }
+
+// Test on ignoring substituted template types.
+template
+class TemplateClass {
+ public:
+  explicit TemplateClass(int a, T default_value = 0) {}
+
+  void h(T *default_value = 0) {}
+
+  void f(int* p = 0) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+// CHECK-FIXES: void f(int* p = nullptr) {}
+};
+
+void IgnoreSubstTemplateType() {
+  TemplateClass a(1);
+}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -39,6 +39,7 @@
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
   anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
+  unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(,
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r297010 - Do not display highlights for clang-include-fixer-at-point

2017-03-06 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Mar  6 08:49:26 2017
New Revision: 297010

URL: http://llvm.org/viewvc/llvm-project?rev=297010&view=rev
Log:
Do not display highlights for clang-include-fixer-at-point

Summary: When invoking clang-include-fixer-at-point, the QuerySymbolInfos point 
to offset 0, length 0. Rather than showing a hidden overlay, do not show any 
overlay at all for zero-length symbols.

Patch by Torsten Marek!

Reviewers: hokein, klimek

Reviewed By: hokein

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

Modified:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el?rev=297010&r1=297009&r2=297010&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el 
(original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el Mon 
Mar  6 08:49:26 2017
@@ -51,4 +51,15 @@
 (goto-char (point-max))
 (should (equal (clang-include-fixer--symbol-at-point) "bbb::cc"
 
+(ert-deftest clang-include-fixer--highlight ()
+  (with-temp-buffer
+(insert "util::Status foo;\n")
+(setq buffer-file-coding-system 'utf-8-unix)
+(should (equal nil (clang-include-fixer--highlight
+'((Range . ((Offset . 0) (Length . 0)))
+(let ((overlay (clang-include-fixer--highlight
+'((Range . ((Offset . 1) (Length . 12)))
+  (should (equal 2 (overlay-start overlay)))
+  (should (equal 14 (overlay-end overlay))
+
 ;;; clang-include-fixer-test.el ends here

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=297010&r1=297009&r2=297010&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Mon Mar  
6 08:49:26 2017
@@ -299,12 +299,14 @@ They are replaced by the single element
 (let ((symbol (clang-include-fixer--symbol-name .QuerySymbolInfos))
   ;; Add temporary highlighting so that the user knows which
   ;; symbols the current session is about.
-  (overlays (mapcar #'clang-include-fixer--highlight 
.QuerySymbolInfos)))
+  (overlays (remove nil
+(mapcar #'clang-include-fixer--highlight 
.QuerySymbolInfos
   (unwind-protect
   (save-excursion
 ;; While prompting, go to the closest overlay so that the user sees
 ;; some context.
-(goto-char (clang-include-fixer--closest-overlay overlays))
+(when overlays
+  (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
   (let* ((header (completing-read
@@ -330,16 +332,17 @@ Raise a signal if the symbol name is not
 (car symbols)))
 
 (defun clang-include-fixer--highlight (symbol-info)
-  "Add an overlay to highlight SYMBOL-INFO.
-Return the overlay object."
-  (let ((overlay (let-alist symbol-info
-   (make-overlay
-(clang-include-fixer--filepos-to-bufferpos
- .Range.Offset 'approximate)
-(clang-include-fixer--filepos-to-bufferpos
- (+ .Range.Offset .Range.Length) 'approximate)
-(overlay-put overlay 'face 'clang-include-fixer-highlight)
-overlay))
+  "Add an overlay to highlight SYMBOL-INFO, if it points to a non-empty range.
+Return the overlay object, or nil."
+  (let-alist symbol-info
+(unless (zerop .Range.Length)
+  (let ((overlay (make-overlay
+  (clang-include-fixer--filepos-to-bufferpos
+   .Range.Offset 'approximate)
+  (clang-include-fixer--filepos-to-bufferpos
+   (+ .Range.Offset .Range.Length) 'approximate
+(overlay-put overlay 'face 'clang-include-fixer-highlight)
+overlay
 
 (defun clang-include-fixer--closest-overlay (overlays)
   "Return the start of the overlay in OVERLAYS that is closest to point."


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


[PATCH] D30650: [clang-tidy] misc-use-after-move: Fix failing assertion

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

LG. So you won the flappy column game? ;)


https://reviews.llvm.org/D30650



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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp:254
+
+  void h(T *default_value = 0) {}
+

Maybe as a separate patch, but I think it might be worth to warn here. WDYT? 
(Sorry for the double post, the previous one is disappeared after the commit.)


Repository:
  rL LLVM

https://reviews.llvm.org/D30639



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


[PATCH] D30650: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In https://reviews.llvm.org/D30650#693136, @alexfh wrote:

> LG. So you won the flappy column game? ;)


I hope so... ;)


https://reviews.llvm.org/D30650



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


[PATCH] D30650: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I think we should refactor this check as part of Static Analyzer, since it's 
path-sensitive.


https://reviews.llvm.org/D30650



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


[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types

2017-03-06 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297019: [Sema][ObjC] Warn about 'performSelector' calls with 
selectors (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D30174?vs=90473&id=90709#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30174

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/DeclObjC.cpp
  cfe/trunk/lib/Basic/IdentifierTable.cpp
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/test/SemaObjC/unsafe-perform-selector.m

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6016,6 +6016,12 @@
   "adding '%0' to '%1' might cause circular dependency in container">,
   InGroup>;
 def note_objc_circular_container_declared_here : Note<"'%0' declared here">;
+def warn_objc_unsafe_perform_selector : Warning<
+  "%0 is incompatible with selectors that return a "
+  "%select{struct|union|vector}1 type">,
+  InGroup>;
+def note_objc_unsafe_perform_selector_method_declared_here :  Note<
+  "method %0 that returns %1 declared here">;
 
 def warn_setter_getter_impl_required : Warning<
   "property %0 requires method %1 to be defined - "
Index: cfe/trunk/test/SemaObjC/unsafe-perform-selector.m
===
--- cfe/trunk/test/SemaObjC/unsafe-perform-selector.m
+++ cfe/trunk/test/SemaObjC/unsafe-perform-selector.m
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// rdar://12056271
+
+@class Thread;
+
+__attribute__((objc_root_class))
+@interface NSObject
+
+- (id)performSelector:(SEL)sel;
+- (void)performSelectorInBackground:(SEL)sel withObject:(id)arg;
+- (void)performSelectorOnMainThread:(SEL)sel;
+
+- (void)performSelectorOnMainThread:(SEL)aSelector
+   onThread:(Thread *)thread
+ withObject:(id)arg
+  waitUntilDone:(int)wait
+  modes:(id *)array;
+
+@end
+
+typedef struct { int x; int y; int width; int height; } Rectangle;
+
+struct Struct { Rectangle r; };
+
+typedef union { int x; float f; } Union;
+
+@interface Base : NSObject
+
+- (struct Struct)returnsStruct2; // expected-note {{method 'returnsStruct2' that returns 'struct Struct' declared here}}
+- (Union)returnsId;
+
+@end
+
+@protocol IP
+
+- (Union)returnsUnion; // expected-note 2 {{method 'returnsUnion' that returns 'Union' declared here}}
+
+@end
+
+typedef __attribute__((__ext_vector_type__(3))) float float3;
+typedef int int4 __attribute__ ((vector_size (16)));
+
+@interface I : Base
+
+- (Rectangle)returnsStruct; // expected-note 4 {{method 'returnsStruct' that returns 'Rectangle' declared here}}
+- (id)returnsId; // shadows base 'returnsId'
+- (int)returnsInt;
+- (I *)returnPtr;
+- (float3)returnsExtVector; // expected-note {{method 'returnsExtVector' that returns 'float3' (vector of 3 'float' values) declared here}}
+- (int4)returnsVector; // expected-note {{method 'returnsVector' that returns 'int4' (vector of 4 'int' values) declared here}}
+
++ (Rectangle)returnsStructClass; // expected-note 2 {{method 'returnsStructClass' that returns 'Rectangle' declared here}}
++ (void)returnsUnion; // Not really
+
+@end
+
+void foo(I *i) {
+  [i performSelector: @selector(returnsStruct)]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+  [i performSelectorInBackground: @selector(returnsStruct) withObject:0]; // expected-warning {{'performSelectorInBackground:withObject:' is incompatible with selectors that return a struct type}}
+  [i performSelector: ((@selector(returnsUnion)))]; // expected-warning {{'performSelector:' is incompatible with selectors that return a union type}}
+  [i performSelectorOnMainThread: @selector(returnsStruct2)]; // expected-warning {{'performSelectorOnMainThread:' is incompatible with selectors that return a struct type}}
+  [I performSelector: (@selector(returnsStructClass))]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+
+  [i performSelector: @selector(returnsId)];
+  [i performSelector: @selector(returnsInt)];
+  [i performSelector: @selector(returnsPtr)];
+  [I performSelector: @selector(returnsUnion)]; // No warning expected
+
+  id obj = i;
+  [obj performSelector: @selector(returnsId)];
+  [obj performSelector: @selector(returnsStruct)];
+}
+
+@interface SubClass: I
+
+@end
+
+@interface SubClass ()
+- (struct Struct)returnsSubStructExt; // expected-note {{method 'returnsSubStructExt' that returns 'struct Struct' declared here}} expected-note {{method 'returnsSubStructExt' declared here}}
+@end
+
+@implementation SubClass // expected-warning {{method definition for 'returnsSubStructExt' not found}}
+

[PATCH] D30532: Add examples to clang-format configuration

2017-03-06 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Thank you for doing this!


https://reviews.llvm.org/D30532



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


[libcxx] r297021 - Update list with changes from Kona meeting

2017-03-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Mar  6 10:06:02 2017
New Revision: 297021

URL: http://llvm.org/viewvc/llvm-project?rev=297021&view=rev
Log:
Update list with changes from Kona meeting

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297021&r1=297020&r2=297021&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 10:06:02 2017
@@ -105,7 +105,7 @@
http://wg21.link/p0174r2";>p0174r2LWGDeprecating 
Vestigial Library Parts in C++17Oulu
http://wg21.link/p0175r1";>p0175r1LWGSynopses for 
the C libraryOulu
http://wg21.link/p0180r2";>p0180r2LWGReserve a New 
Library Namespace for Future StandardizationOuluNothing to 
don/a
-   http://wg21.link/p0181r1";>p0181r1LWGOrdered by 
DefaultOulu
+   http://wg21.link/p0181r1";>p0181r1LWGOrdered by 
DefaultOuluRemoved in Konan/a
http://wg21.link/p0209r2";>p0209r2LWGmake_from_tuple:
 apply for constructionOuluComplete3.9
http://wg21.link/p0219r1";>p0219r1LWGRelative Paths 
for FilesystemOulu
http://wg21.link/p0254r2";>p0254r2LWGIntegrating 
std::string_view and 
std::stringOuluComplete4.0
@@ -140,6 +140,24 @@
http://wg21.link/P0516R0";>P0516R0LWGClarify That 
shared_future’s Copy Operations have Wide 
ContractsIssaquahComplete4.0
http://wg21.link/P0517R0";>P0517R0LWGMake 
future_error 
ConstructibleIssaquahComplete4.0
http://wg21.link/P0521R0";>P0521R0LWGProposed 
Resolution for CA 14 (shared_ptr 
use_count/unique)IssaquahNothing to 
don/a
+   
+   http://wg21.link/P0317R1";>P0317R1LWGDirectory Entry 
Caching for FilesystemKona
+   http://wg21.link/P0492R2";>P0492R2LWGProposed 
Resolution of C++17 National Body Comments for 
FilesystemsKona
+   http://wg21.link/P0430R2";>P0430R2LWGFile system 
library on non-POSIX-like operating 
systemsKona
+   http://wg21.link/P0452R1";>P0452R1LWGUnifying 
 Parallel AlgorithmsKona
+   http://wg21.link/P0518R1";>P0518R1LWGAllowing copies 
as arguments to function objects given to parallel algorithms in response to 
CH11Kona
+   http://wg21.link/P0523R1";>P0523R1LWGWording for CH 
10: Complexity of parallel algorithmsKona
+   http://wg21.link/P0574R1";>P0574R1LWGAlgorithm 
Complexity Constraints and Parallel 
OverloadsKona
+   http://wg21.link/P0467R2";>P0467R2LWGIterator 
Concerns for Parallel AlgorithmsKona
+   http://wg21.link/P0623R0";>P0623R0LWGFinal C++17 
Parallel Algorithms FixesKona
+   http://wg21.link/P0604R0";>P0604R0LWGResolving GB 
55, US 84, US 85, US 86Kona
+   http://wg21.link/P0607R0";>P0607R0LWGInline 
Variables for the Standard LibraryKona
+   http://wg21.link/P0618R0";>P0618R0LWGDeprecating 
Kona
+   http://wg21.link/P0156R2";>P0156R2LWGVariadic Lock 
guardKona
+   http://wg21.link/P0599R1";>P0599R1LWGnoexcept for 
hash functionsKona
+   http://wg21.link/P0433R2";>P0433R2LWGToward a 
resolution of US7 and US14: Integrating template deduction for class templates 
into the standard libraryKona
+   http://wg21.link/P0558R1";>P0558R1LWGResolving 
atomic named base class 
inconsistenciesKona
+   http://wg21.link/P0548R1";>P0548R1LWGcommon_type and 
durationKona
 
 
   
@@ -332,7 +350,7 @@
http://wg21.link/LWG2726";>2726[recursive_]directory_iterator::increment(error_code&)
 is underspecifiedOuluComplete
http://wg21.link/LWG2727";>2727Parallel 
algorithms with constexpr specifierOulu
http://wg21.link/LWG2728";>2728status(p).permissions() and 
symlink_status(p).permissions() are not 
specifiedOuluComplete
-
+   
http://wg21.link/LWG2062";>2062Effect 
contradictions w/o no-throw guarantee of std::function 
swapsIssaquahComplete
http://wg21.link/LWG2166";>2166Heap 
property underspecified?Issaquah
http://wg21.link/LWG2221";>2221No 
formatted output operator for nullptrIssaquah
@@ -410,14 +428,65 @@
http://wg21.link/LWG2773";>2773Making 
std::ignore constexprIssaquahComplete
http://wg21.link/LWG2777";>2777basic_string_view::copy should 
use char_traits::copyIssaquahComplete
http://wg21.link/LWG2778";>2778basic_string_view is missing 
constexprIssaquahComplete
-
+   
+   http://wg21.link/LWG2260";>2260Missing 
requirement for Allocator::pointerKona
+   http://wg21.link/LWG2676";>2676Provide 
filesystem::path overloads for File-based 
streamsKona
+   http://wg21.link/LWG2768";>2768any_cast 
and move semanticsKona
+   http://wg21.link/LWG2769";>2769Redundant 
const in the return type of any_cast(const 
any&)Kona
+   http://wg21.link/LWG2781";>2781Contradictory requirements for 
std::function and std::reference_wrapperKona
+   http://wg21.link/LWG2782";>2782scoped_allocator_adaptor 
constructors must be constr

r297019 - [Sema][ObjC] Warn about 'performSelector' calls with selectors

2017-03-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Mar  6 09:58:34 2017
New Revision: 297019

URL: http://llvm.org/viewvc/llvm-project?rev=297019&view=rev
Log:
[Sema][ObjC] Warn about 'performSelector' calls with selectors
that return record or vector types

The performSelector family of methods from Foundation use objc_msgSend to
dispatch the selector invocations to objects. However, method calls to methods
that return record types might have to use the objc_msgSend_stret as the return
value won't find into the register. This is also supported by this sentence from
performSelector documentation: "The method should not have a significant return
value and should take a single argument of type id, or no arguments". This
commit adds a new warning that warns when a selector which corresponds to a
method that returns a record type is passed into performSelector.

rdar://12056271

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

Added:
cfe/trunk/test/SemaObjC/unsafe-perform-selector.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=297019&r1=297018&r2=297019&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Mar  6 09:58:34 
2017
@@ -6016,6 +6016,12 @@ def warn_objc_circular_container : Warni
   "adding '%0' to '%1' might cause circular dependency in container">,
   InGroup>;
 def note_objc_circular_container_declared_here : Note<"'%0' declared here">;
+def warn_objc_unsafe_perform_selector : Warning<
+  "%0 is incompatible with selectors that return a "
+  "%select{struct|union|vector}1 type">,
+  InGroup>;
+def note_objc_unsafe_perform_selector_method_declared_here :  Note<
+  "method %0 that returns %1 declared here">;
 
 def warn_setter_getter_impl_required : Warning<
   "property %0 requires method %1 to be defined - "

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=297019&r1=297018&r2=297019&view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Mon Mar  6 09:58:34 2017
@@ -979,11 +979,12 @@ ObjCMethodFamily ObjCMethodDecl::getMeth
 break;
   
   case OMF_performSelector:
-if (!isInstanceMethod() || !getReturnType()->isObjCIdType())
+if (!isInstanceMethod() ||
+!(getReturnType()->isObjCIdType() || getReturnType()->isVoidType()))
   family = OMF_None;
 else {
   unsigned noParams = param_size();
-  if (noParams < 1 || noParams > 3)
+  if (noParams < 1 || noParams > 5)
 family = OMF_None;
   else {
 ObjCMethodDecl::param_type_iterator it = param_type_begin();
@@ -992,10 +993,11 @@ ObjCMethodFamily ObjCMethodDecl::getMeth
   family = OMF_None;
   break;
 }
-while (--noParams) {
-  it++;
-  ArgT = (*it);
-  if (!ArgT->isObjCIdType()) {
+// The first type should generally always be 'id' or 'Thread *', the
+// other types can vary.
+if (noParams > 1) {
+  ArgT = *(it + 1);
+  if (!ArgT->isObjCObjectPointerType()) {
 family = OMF_None;
 break;
   }

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=297019&r1=297018&r2=297019&view=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Mon Mar  6 09:58:34 2017
@@ -487,8 +487,10 @@ ObjCMethodFamily Selector::getMethodFami
 if (name == "self") return OMF_self;
 if (name == "initialize") return OMF_initialize;
   }
- 
-  if (name == "performSelector") return OMF_performSelector;
+
+  if (name == "performSelector" || name == "performSelectorInBackground" ||
+  name == "performSelectorOnMainThread")
+return OMF_performSelector;
 
   // The other method families may begin with a prefix of underscores.
   while (!name.empty() && name.front() == '_')

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=297019&r1=297018&r2=297019&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Mar  6 09:58:34 2017
@@ -2266,6 +2266,52 @@ static void checkCocoaAPI(Sema &S, const
  edit::rewriteObjCRedundantCallWithLiteral)

[libcxx] r297022 - Header update with info about the current status of C++17

2017-03-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Mar  6 10:09:02 2017
New Revision: 297022

URL: http://llvm.org/viewvc/llvm-project?rev=297022&view=rev
Log:
Header update with info about the current status of C++17

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297022&r1=297021&r2=297022&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 10:09:02 2017
@@ -35,7 +35,8 @@
   libc++ C++1z Status
   
 
-  In November 2014, the C++ standard committee created a draft for the next 
version of the C++ standard, known here as "C++1z" (probably to be C++17)
+  In November 2014, the C++ standard committee created a draft for the next 
version of the C++ standard, known here as "C++1z" (probably to be C++17).
+  In February 2017, the C++ standard committee approved this draft, and 
sent it to ISO for approval as C++17
   This page shows the status of libc++; the status of clang's support of 
the language features is http://clang.llvm.org/cxx_status.html#cxx17";>here.
 
   The groups that have contributed papers:


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


[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp:254
+
+  void h(T *default_value = 0) {}
+

xazax.hun wrote:
> Maybe as a separate patch, but I think it might be worth to warn here. WDYT? 
> (Sorry for the double post, the previous one is disappeared after the commit.)
Seems reasonable, but probably not an extremely frequent case. Deserves a FIXME 
at least.


Repository:
  rL LLVM

https://reviews.llvm.org/D30639



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


r297023 - [CodeGen][Blocks] Refactor capture handling in code that generates

2017-03-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Mar  6 10:23:04 2017
New Revision: 297023

URL: http://llvm.org/viewvc/llvm-project?rev=297023&view=rev
Log:
[CodeGen][Blocks] Refactor capture handling in code that generates
block copy/destroy routines

This is a preparation commit for work on merging unique block copy/destroy
helper functions.

rdar://22950898

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

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

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=297023&r1=297022&r2=297023&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon Mar  6 10:23:04 2017
@@ -1373,6 +1373,103 @@ CodeGenFunction::GenerateBlockFunction(G
   return fn;
 }
 
+namespace {
+
+/// Represents a type of copy/destroy operation that should be performed for an
+/// entity that's captured by a block.
+enum class BlockCaptureEntityKind {
+  CXXRecord, // Copy or destroy
+  ARCWeak,
+  ARCStrong,
+  BlockObject, // Assign or release
+  None
+};
+
+/// Represents a captured entity that requires extra operations in order for
+/// this entity to be copied or destroyed correctly.
+struct BlockCaptureManagedEntity {
+  BlockCaptureEntityKind Kind;
+  BlockFieldFlags Flags;
+  const BlockDecl::Capture &CI;
+  const CGBlockInfo::Capture &Capture;
+
+  BlockCaptureManagedEntity(BlockCaptureEntityKind Type, BlockFieldFlags Flags,
+const BlockDecl::Capture &CI,
+const CGBlockInfo::Capture &Capture)
+  : Kind(Type), Flags(Flags), CI(CI), Capture(Capture) {}
+};
+
+} // end anonymous namespace
+
+static std::pair
+computeCopyInfoForBlockCapture(const BlockDecl::Capture &CI, QualType T,
+   const LangOptions &LangOpts) {
+  if (CI.getCopyExpr()) {
+assert(!CI.isByRef());
+// don't bother computing flags
+return std::make_pair(BlockCaptureEntityKind::CXXRecord, 
BlockFieldFlags());
+  }
+  BlockFieldFlags Flags;
+  if (CI.isByRef()) {
+Flags = BLOCK_FIELD_IS_BYREF;
+if (T.isObjCGCWeak())
+  Flags |= BLOCK_FIELD_IS_WEAK;
+return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
+  }
+  if (!T->isObjCRetainableType())
+// For all other types, the memcpy is fine.
+return std::make_pair(BlockCaptureEntityKind::None, Flags);
+
+  Flags = BLOCK_FIELD_IS_OBJECT;
+  bool isBlockPointer = T->isBlockPointerType();
+  if (isBlockPointer)
+Flags = BLOCK_FIELD_IS_BLOCK;
+
+  // Special rules for ARC captures:
+  Qualifiers QS = T.getQualifiers();
+
+  // We need to register __weak direct captures with the runtime.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Weak)
+return std::make_pair(BlockCaptureEntityKind::ARCWeak, Flags);
+
+  // We need to retain the copied value for __strong direct captures.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Strong) {
+// If it's a block pointer, we have to copy the block and
+// assign that to the destination pointer, so we might as
+// well use _Block_object_assign.  Otherwise we can avoid that.
+return std::make_pair(!isBlockPointer ? BlockCaptureEntityKind::ARCStrong
+  : 
BlockCaptureEntityKind::BlockObject,
+  Flags);
+  }
+
+  // Non-ARC captures of retainable pointers are strong and
+  // therefore require a call to _Block_object_assign.
+  if (!QS.getObjCLifetime() && !LangOpts.ObjCAutoRefCount)
+return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
+
+  // Otherwise the memcpy is fine.
+  return std::make_pair(BlockCaptureEntityKind::None, Flags);
+}
+
+/// Find the set of block captures that need to be explicitly copied or 
destroy.
+static void findBlockCapturedManagedEntities(
+const CGBlockInfo &BlockInfo, const LangOptions &LangOpts,
+SmallVectorImpl &ManagedCaptures,
+llvm::function_ref(
+const BlockDecl::Capture &, QualType, const LangOptions &)>
+Predicate) {
+  for (const auto &CI : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+const CGBlockInfo::Capture &Capture = BlockInfo.getCapture(Variable);
+if (Capture.isConstant())
+  continue;
+
+auto Info = Predicate(CI, Variable->getType(), LangOpts);
+if (Info.first != BlockCaptureEntityKind::None)
+  ManagedCaptures.emplace_back(Info.first, Info.second, CI, Capture);
+  }
+}
+
 /// Generate the copy-helper function for a block closure object:
 ///   static void block_copy_helper(block_t *dst, block_t *src);
 /// The runtime will have previously initialized 'dst' by doing a
@@ -1431,78 +1528,28 @@ CodeGenFunction::GenerateCopyHelperFunct
   dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
   dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
 
-  const BlockDecl *blockDecl

[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-03-06 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297023: [CodeGen][Blocks] Refactor capture handling in code 
that generates (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D30345?vs=90197&id=90712#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30345

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp

Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp
===
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp
@@ -1373,6 +1373,103 @@
   return fn;
 }
 
+namespace {
+
+/// Represents a type of copy/destroy operation that should be performed for an
+/// entity that's captured by a block.
+enum class BlockCaptureEntityKind {
+  CXXRecord, // Copy or destroy
+  ARCWeak,
+  ARCStrong,
+  BlockObject, // Assign or release
+  None
+};
+
+/// Represents a captured entity that requires extra operations in order for
+/// this entity to be copied or destroyed correctly.
+struct BlockCaptureManagedEntity {
+  BlockCaptureEntityKind Kind;
+  BlockFieldFlags Flags;
+  const BlockDecl::Capture &CI;
+  const CGBlockInfo::Capture &Capture;
+
+  BlockCaptureManagedEntity(BlockCaptureEntityKind Type, BlockFieldFlags Flags,
+const BlockDecl::Capture &CI,
+const CGBlockInfo::Capture &Capture)
+  : Kind(Type), Flags(Flags), CI(CI), Capture(Capture) {}
+};
+
+} // end anonymous namespace
+
+static std::pair
+computeCopyInfoForBlockCapture(const BlockDecl::Capture &CI, QualType T,
+   const LangOptions &LangOpts) {
+  if (CI.getCopyExpr()) {
+assert(!CI.isByRef());
+// don't bother computing flags
+return std::make_pair(BlockCaptureEntityKind::CXXRecord, BlockFieldFlags());
+  }
+  BlockFieldFlags Flags;
+  if (CI.isByRef()) {
+Flags = BLOCK_FIELD_IS_BYREF;
+if (T.isObjCGCWeak())
+  Flags |= BLOCK_FIELD_IS_WEAK;
+return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
+  }
+  if (!T->isObjCRetainableType())
+// For all other types, the memcpy is fine.
+return std::make_pair(BlockCaptureEntityKind::None, Flags);
+
+  Flags = BLOCK_FIELD_IS_OBJECT;
+  bool isBlockPointer = T->isBlockPointerType();
+  if (isBlockPointer)
+Flags = BLOCK_FIELD_IS_BLOCK;
+
+  // Special rules for ARC captures:
+  Qualifiers QS = T.getQualifiers();
+
+  // We need to register __weak direct captures with the runtime.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Weak)
+return std::make_pair(BlockCaptureEntityKind::ARCWeak, Flags);
+
+  // We need to retain the copied value for __strong direct captures.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Strong) {
+// If it's a block pointer, we have to copy the block and
+// assign that to the destination pointer, so we might as
+// well use _Block_object_assign.  Otherwise we can avoid that.
+return std::make_pair(!isBlockPointer ? BlockCaptureEntityKind::ARCStrong
+  : BlockCaptureEntityKind::BlockObject,
+  Flags);
+  }
+
+  // Non-ARC captures of retainable pointers are strong and
+  // therefore require a call to _Block_object_assign.
+  if (!QS.getObjCLifetime() && !LangOpts.ObjCAutoRefCount)
+return std::make_pair(BlockCaptureEntityKind::BlockObject, Flags);
+
+  // Otherwise the memcpy is fine.
+  return std::make_pair(BlockCaptureEntityKind::None, Flags);
+}
+
+/// Find the set of block captures that need to be explicitly copied or destroy.
+static void findBlockCapturedManagedEntities(
+const CGBlockInfo &BlockInfo, const LangOptions &LangOpts,
+SmallVectorImpl &ManagedCaptures,
+llvm::function_ref(
+const BlockDecl::Capture &, QualType, const LangOptions &)>
+Predicate) {
+  for (const auto &CI : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+const CGBlockInfo::Capture &Capture = BlockInfo.getCapture(Variable);
+if (Capture.isConstant())
+  continue;
+
+auto Info = Predicate(CI, Variable->getType(), LangOpts);
+if (Info.first != BlockCaptureEntityKind::None)
+  ManagedCaptures.emplace_back(Info.first, Info.second, CI, Capture);
+  }
+}
+
 /// Generate the copy-helper function for a block closure object:
 ///   static void block_copy_helper(block_t *dst, block_t *src);
 /// The runtime will have previously initialized 'dst' by doing a
@@ -1431,78 +1528,28 @@
   dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
   dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
 
-  const BlockDecl *blockDecl = blockInfo.getBlockDecl();
-
-  for (const auto &CI : blockDecl->captures()) {
-const VarDecl *variable = CI.getVariable();
-QualType type = variable->getType();
-
-const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable);
-if (capture.isConstant()) continue;
-
-const Expr *copyExpr = CI.ge

[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.

2017-03-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp:254
+
+  void h(T *default_value = 0) {}
+

alexfh wrote:
> xazax.hun wrote:
> > Maybe as a separate patch, but I think it might be worth to warn here. 
> > WDYT? (Sorry for the double post, the previous one is disappeared after the 
> > commit.)
> Seems reasonable, but probably not an extremely frequent case. Deserves a 
> FIXME at least.
+1, patch are welcome.


Repository:
  rL LLVM

https://reviews.llvm.org/D30639



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


[PATCH] D30659: [clang-format] Make NamespaceEndCommentFixer add at most one comment

2017-03-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: klimek.

Until now, NamespaceEndCommentFixer was adding missing comments for every run,
which results in multiple end comments for:

  namespace {
int i;
int j;
  }
  #if A
int a = 1;
  #else
int a = 2;
  #endif

result before:

  namespace {
int i;
int j;
  }// namespace // namespace
  #if A
int a = 1;
  #else
int a = 2;
  #endif

result after:

  namespace {
int i;
int j;
  }// namespace
  #if A
int a = 1;
  #else
int a = 2;
  #endif


https://reviews.llvm.org/D30659

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -388,6 +388,24 @@
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -135,7 +135,9 @@
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized) continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -388,6 +388,24 @@
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -135,7 +135,9 @@
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized) continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30659: [clang-format] Make NamespaceEndCommentFixer add at most one comment

2017-03-06 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Would probably be interesting to add these test cases:

  #if A
  namespace A {
  #else
  namespace B {
  #endif
  int i;
  int j;
  }//namespace A

and:

  namespace A {
  int i;
  int j;
  #if A
  }//namespace A
  #else
  }//namespace A
  #endif




Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:139
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized) continue;
+RBraceTok->Finalized = true;

Use clang-format :). (there should be a linebreak before "continue".


https://reviews.llvm.org/D30659



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


r297025 - Add examples to clang-format configuration

2017-03-06 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Mar  6 10:35:28 2017
New Revision: 297025

URL: http://llvm.org/viewvc/llvm-project?rev=297025&view=rev
Log:
Add examples to clang-format configuration

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: krasimir, kimgr, cfe-commits

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

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

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=297025&r1=297024&r2=297025&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Mar  6 10:35:28 2017
@@ -213,6 +213,20 @@ the configuration (without a prefix: ``A
   If ``true``, aligns escaped newlines as far left as possible.
   Otherwise puts them into the right-most column.
 
+  .. code-block:: c++
+
+true:
+#define A   \
+  int ; \
+  int b;\
+  int dd;
+
+false:
+#define A  
\
+  int ;
\
+  int b;   
\
+  int dd;
+
 **AlignOperands** (``bool``)
   If ``true``, horizontally align operands of binary and ternary
   expressions.
@@ -228,6 +242,12 @@ the configuration (without a prefix: ``A
 **AlignTrailingComments** (``bool``)
   If ``true``, aligns trailing comments.
 
+  .. code-block:: c++
+
+true:   false:
+int a; // My comment a  vs. int a; // My comment a
+int b = 2; // comment  bint b = 2; // comment about b
+
 **AllowAllParametersOfDeclarationOnNextLine** (``bool``)
   Allow putting all parameters of a function declaration onto
   the next line even if ``BinPackParameters`` is ``false``.
@@ -240,6 +260,17 @@ the configuration (without a prefix: ``A
 **AllowShortCaseLabelsOnASingleLine** (``bool``)
   If ``true``, short case labels will be contracted to a single line.
 
+  .. code-block:: c++
+
+true:   false:
+switch (a) {vs. switch (a) {
+case 1: x = 1; break;   case 1:
+case 2: return;   x = 1;
+} break;
+case 2:
+  return;
+}
+
 **AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``)
   Dependent on the value, ``int f() { return 0; }`` can be put on a
   single line.
@@ -316,10 +347,23 @@ the configuration (without a prefix: ``A
   the string at that point leads to it being indented
   ``ContinuationIndentWidth`` spaces from the start of the line.
 
+  .. code-block:: c++
+
+ true:  false:
+  = vs.  = ""
+ """";
+ "";
+
 **AlwaysBreakTemplateDeclarations** (``bool``)
   If ``true``, always break after the ``template<...>`` of a template
   declaration.
 
+  .. code-block:: c++
+
+ true:  false:
+ template   vs. template  class C {};
+ class C {};
+
 **BinPackArguments** (``bool``)
   If ``false``, a function call's arguments will either be all on the
   same line or will have one line each.
@@ -411,6 +455,14 @@ the configuration (without a prefix: ``A
   Always break constructor initializers before commas and align
   the commas with the colon.
 
+  .. code-block:: c++
+
+ true:  false:
+ SomeClass::Constructor()   vs. SomeClass::Constructor() : a(a),
+ : a(a)   b(b),
+ , b(b)   c(c) {}
+ , c(c) {}
+
 **BreakStringLiterals** (``bool``)
   Allow breaking string literals when formatting.
 
@@ -475,6 +527,13 @@ the configuration (without a prefix: ``A
   If ``true``, clang-format adds missing namespace end comments and
   fixes invalid existing ones.
 
+  .. code-block:: c++
+
+ true:  false:
+ namespace a {  vs. namespace a {
+ foo(); foo();
+ } // namespace a;  }
+
 **ForEachMacros** (``std::vector``)
   A vector of macros that should be interpreted as foreach loops
   instead of as function calls.
@@ -683,9 +742,20 @@ the configuration (without a prefix: ``A
 **SpaceAfterTemplateKeyword** (``bool``)
   If ``true``, a space will be inserted after the 'template' keyword.
 
+  .. code-bl

r297027 - [Docs] Add missing quotes to the language literal in the

2017-03-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Mar  6 10:37:06 2017
New Revision: 297027

URL: http://llvm.org/viewvc/llvm-project?rev=297027&view=rev
Log:
[Docs] Add missing quotes to the language literal in the
external_source_symbol attribute docs

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=297027&r1=297026&r2=297027&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar  6 10:37:06 2017
@@ -987,7 +987,7 @@ that ``SwiftProtocol`` actually originat
 
 .. code-block:: objc
 
-  __attribute__((external_source_symbol(language=Swift,defined_in="module")))
+  __attribute__((external_source_symbol(language="Swift",defined_in="module")))
   @protocol SwiftProtocol
   @required
   - (void) method;


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


[PATCH] D30659: [clang-format] Make NamespaceEndCommentFixer add at most one comment

2017-03-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 90715.
krasimir added a comment.

- Added missing newline


https://reviews.llvm.org/D30659

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -388,6 +388,24 @@
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -135,7 +135,10 @@
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized)
+  continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -388,6 +388,24 @@
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -135,7 +135,10 @@
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized)
+  continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30659: [clang-format] Make NamespaceEndCommentFixer add at most one comment

2017-03-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297028: [clang-format] Make NamespaceEndCommentFixer add at 
most one comment (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D30659?vs=90715&id=90716#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30659

Files:
  cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
  cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp


Index: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -135,7 +135,10 @@
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized)
+  continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&
Index: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -388,6 +388,24 @@
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,


Index: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -135,7 +135,10 @@
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized)
+  continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&
Index: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -388,6 +388,24 @@
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r297028 - [clang-format] Make NamespaceEndCommentFixer add at most one comment

2017-03-06 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Mar  6 10:44:45 2017
New Revision: 297028

URL: http://llvm.org/viewvc/llvm-project?rev=297028&view=rev
Log:
[clang-format] Make NamespaceEndCommentFixer add at most one comment

Summary:
Until now, NamespaceEndCommentFixer was adding missing comments for every run,
which results in multiple end comments for:
```
namespace {
  int i;
  int j;
}
#if A
  int a = 1;
#else
  int a = 2;
#endif
```
result before:

```
namespace {
  int i;
  int j;
}// namespace // namespace
#if A
  int a = 1;
#else
  int a = 2;
#endif
```
result after:
```
namespace {
  int i;
  int j;
}// namespace
#if A
  int a = 1;
#else
  int a = 2;
#endif
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Modified: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp?rev=297028&r1=297027&r2=297028&view=diff
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp (original)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp Mon Mar  6 10:44:45 2017
@@ -135,7 +135,10 @@ tooling::Replacements NamespaceEndCommen
   NamespaceTok = NamespaceTok->getNextNonComment();
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
-const FormatToken *RBraceTok = EndLine->First;
+FormatToken *RBraceTok = EndLine->First;
+if (RBraceTok->Finalized)
+  continue;
+RBraceTok->Finalized = true;
 const std::string NamespaceName = computeName(NamespaceTok);
 bool AddNewline = (I + 1 < E) &&
   AnnotatedLines[I + 1]->First->NewlinesBefore == 0 &&

Modified: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp?rev=297028&r1=297027&r2=297028&view=diff
==
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp (original)
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp Mon Mar  6 
10:44:45 2017
@@ -388,6 +388,24 @@ TEST_F(NamespaceEndCommentsFixerTest,
 "  int i;\n"
 "}\n"
 "}\n"));
+  EXPECT_EQ("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}// namespace\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif",
+fixNamespaceEndComments("namespace {\n"
+"  int i;\n"
+"  int j;\n"
+"}\n"
+"#if A\n"
+"  int i;\n"
+"#else\n"
+"  int j;\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,


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


r297030 - [modules] Make GNUMode a normal language option to fix module compilation.

2017-03-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Mar  6 10:54:40 2017
New Revision: 297030

URL: http://llvm.org/viewvc/llvm-project?rev=297030&view=rev
Log:
[modules] Make GNUMode a normal language option to fix module compilation.

GNUMode shouldn't be a benign language option because it influences the
resulting AST when checking for the existence of GNUMode-specific macro
"linux" (e.g. by having code inside #ifdef linux). This patch marks it as a
normal language option so it gets correctly passed to the compiler invocation
for the used modules.

The added test case illustrated this because it compiles without modules, but
fails when using modules.

Patch by Raphael Isemann (D30496)!

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=297030&r1=297029&r2=297030&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Mar  6 10:54:40 2017
@@ -107,7 +107,7 @@ LANGOPT(WChar , 1, CPlusPlus
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
 BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
-BENIGN_LANGOPT(GNUMode, 1, 1, "GNU extensions")
+LANGOPT(GNUMode   , 1, 1, "GNU extensions")
 LANGOPT(GNUKeywords   , 1, 1, "GNU keywords")
 BENIGN_LANGOPT(ImplicitInt, 1, !C99 && !CPlusPlus, "C89 implicit 'int'")
 LANGOPT(Digraphs  , 1, 0, "digraphs")


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


[PATCH] D26065: Improve diagnostics if friend function redefines file-level function.

2017-03-06 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Ping.


https://reviews.llvm.org/D26065



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


[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/CodeGenCXX/ubsan-bitfields.cpp:21
+  // CHECK: call void @__ubsan_handle_load_invalid_value
+  return s->e1;
+}

Can we avoid the check if the bitfield is 2 bits wide?



Comment at: test/CodeGenObjC/ubsan-bool.m:25
+  // OBJC:  [[ASHR:%.*]] = ashr i8 [[SHL]], 7
+  // OBJC:  [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize
+  // OBJC: call void @__ubsan_handle_load_invalid_value

One unrelated thing that I noticed in the IR, the `zext`s to `i64` are emitted 
before the branch, even though they are used only in the `invalid_value` 
blocks. I know that the optimizer can move those anyway, but would there any be 
any benefit in moving them into the blocks at the frontend IRGen level?



Comment at: test/CodeGenObjC/ubsan-bool.m:26
+  // OBJC:  [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+

Is it possible to avoid the check here since the bitfield is just one bit wide?


https://reviews.llvm.org/D30423



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


r297034 - [clang-format] Add tests for ambiguous namespaces to the comment fixer

2017-03-06 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Mar  6 11:29:25 2017
New Revision: 297034

URL: http://llvm.org/viewvc/llvm-project?rev=297034&view=rev
Log:
[clang-format] Add tests for ambiguous namespaces to the comment fixer

Modified:
cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Modified: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp?rev=297034&r1=297033&r2=297034&view=diff
==
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp (original)
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp Mon Mar  6 
11:29:25 2017
@@ -406,6 +406,86 @@ TEST_F(NamespaceEndCommentsFixerTest,
 "#else\n"
 "  int j;\n"
 "#endif"));
+  EXPECT_EQ("#if A\n"
+"namespace A {\n"
+"#else\n"
+"namespace B {\n"
+"#endif\n"
+"int i;\n"
+"int j;\n"
+"}",
+fixNamespaceEndComments("#if A\n"
+"namespace A {\n"
+"#else\n"
+"namespace B {\n"
+"#endif\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ("#if A\n"
+"namespace A {\n"
+"#else\n"
+"namespace B {\n"
+"#endif\n"
+"int i;\n"
+"int j;\n"
+"} // namespace A",
+fixNamespaceEndComments("#if A\n"
+"namespace A {\n"
+"#else\n"
+"namespace B {\n"
+"#endif\n"
+"int i;\n"
+"int j;\n"
+"} // namespace A"));
+  EXPECT_EQ("#if A\n"
+"namespace A {\n"
+"#else\n"
+"namespace B {\n"
+"#endif\n"
+"int i;\n"
+"int j;\n"
+"} // namespace B",
+fixNamespaceEndComments("#if A\n"
+"namespace A {\n"
+"#else\n"
+"namespace B {\n"
+"#endif\n"
+"int i;\n"
+"int j;\n"
+"} // namespace B"));
+  EXPECT_EQ("namespace A\n"
+"int i;\n"
+"int j;\n"
+"#if A\n"
+"}\n"
+"#else\n"
+"}\n"
+"#endif",
+fixNamespaceEndComments("namespace A\n"
+"int i;\n"
+"int j;\n"
+"#if A\n"
+"}\n"
+"#else\n"
+"}\n"
+"#endif"));
+  EXPECT_EQ("namespace A\n"
+"int i;\n"
+"int j;\n"
+"#if A\n"
+"} // namespace A\n"
+"#else\n"
+"} // namespace A\n"
+"#endif",
+fixNamespaceEndComments("namespace A\n"
+"int i;\n"
+"int j;\n"
+"#if A\n"
+"} // namespace A\n"
+"#else\n"
+"} // namespace A\n"
+"#endif"));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest,


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


[PATCH] D30662: Update clang filtering for mxcsr

2017-03-06 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor created this revision.

This patch updates the clang function that filters the mxcsr register name to 
recognize that mxcsr is being split into two pseduo-registers that model the 
control and status bits separately.


Repository:
  rL LLVM

https://reviews.llvm.org/D30662

Files:
  lib/Parse/ParseStmtAsm.cpp


Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -623,8 +623,9 @@
 
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber
   // constraints. Clang always adds fpsr to the clobber list anyway.
+  // Note that mxcsr is modeled as two separate registers.
   llvm::erase_if(Clobbers, [](const std::string &C) {
-return C == "fpsw" || C == "mxcsr";
+return C == "fpsw" || C == "mxcsr_c" || C == "mxcsr_s";
   });
 
   // Build the vector of clobber StringRefs.


Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -623,8 +623,9 @@
 
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber
   // constraints. Clang always adds fpsr to the clobber list anyway.
+  // Note that mxcsr is modeled as two separate registers.
   llvm::erase_if(Clobbers, [](const std::string &C) {
-return C == "fpsw" || C == "mxcsr";
+return C == "fpsw" || C == "mxcsr_c" || C == "mxcsr_s";
   });
 
   // Build the vector of clobber StringRefs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-03-06 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Sean,

It is good to have the ability of recursive lookup. But for me (and I'm sorry), 
the code becomes very hard to understand: I need to track if the Decl/DC is in 
the source AST or in the AST being imported, if it was imported or if was in 
the AST before across lambdas and calls. Can we make this more clear?




Comment at: tools/clang-import-test/clang-import-test.cpp:201
+  Decl *Imported(Decl *From, Decl *To) override {
+if (auto ToTag = llvm::dyn_cast(To)) {
+  ToTag->setHasExternalLexicalStorage();

Can we make the usage of qualified and non-qualified casts consistent? Usually, 
casts are used as unqualified.



Comment at: tools/clang-import-test/clang-import-test.cpp:298
+
+std::vector CompleteDecls;
+std::vector ForwardDecls;

I guess we can use `SmallVector`s here too.



Comment at: tools/clang-import-test/clang-import-test.cpp:303
+  if (IsForwardDeclaration(C.first)) {
+if (std::none_of(ForwardDecls.begin(), ForwardDecls.end(),
+ [&C](Candidate &D) {

Nit: to make the code cleaner, we can extract this `std::none_of` to a separate 
function like `IsFoundAsForward()`. Nested lambdas are harder to read.



Comment at: tools/clang-import-test/clang-import-test.cpp:333
+Decls.resize(DeclsToReport.size());
+std::transform(DeclsToReport.begin(), DeclsToReport.end(), Decls.begin(),
+   [](Candidate &C) {

The loop:
```
Decls.reserve(DeclsToReport.size());
for (Candidate &C : DeclsToReport)
  Decls.push_back(cast(C.second->Import(C.first)));
```
will look a bit nicer here. What do you think?


Repository:
  rL LLVM

https://reviews.llvm.org/D30435



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


Re: r297034 - [clang-format] Add tests for ambiguous namespaces to the comment fixer

2017-03-06 Thread Daniel Jasper via cfe-commits
On Mon, Mar 6, 2017 at 6:29 PM, Krasimir Georgiev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: krasimir
> Date: Mon Mar  6 11:29:25 2017
> New Revision: 297034
>
> URL: http://llvm.org/viewvc/llvm-project?rev=297034&view=rev
> Log:
> [clang-format] Add tests for ambiguous namespaces to the comment fixer
>
> Modified:
> cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
>
> Modified: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/
> NamespaceEndCommentsFixerTest.cpp?rev=297034&r1=297033&r2=297034&view=diff
> 
> ==
> --- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
> (original)
> +++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp Mon Mar
> 6 11:29:25 2017
> @@ -406,6 +406,86 @@ TEST_F(NamespaceEndCommentsFixerTest,
>  "#else\n"
>  "  int j;\n"
>  "#endif"));
> +  EXPECT_EQ("#if A\n"
> +"namespace A {\n"
> +"#else\n"
> +"namespace B {\n"
> +"#endif\n"
> +"int i;\n"
> +"int j;\n"
> +"}",
> +fixNamespaceEndComments("#if A\n"
> +"namespace A {\n"
> +"#else\n"
> +"namespace B {\n"
> +"#endif\n"
> +"int i;\n"
> +"int j;\n"
> +"}"));
>

I don't understand why we aren't adding "// namespace A" here. I mean I
don't think it matters much, but it seems weird to me.


> +  EXPECT_EQ("#if A\n"
> +"namespace A {\n"
> +"#else\n"
> +"namespace B {\n"
> +"#endif\n"
> +"int i;\n"
> +"int j;\n"
> +"} // namespace A",
> +fixNamespaceEndComments("#if A\n"
> +"namespace A {\n"
> +"#else\n"
> +"namespace B {\n"
> +"#endif\n"
> +"int i;\n"
> +"int j;\n"
> +"} // namespace A"));
>

I'd consider merging this test with the previous one. Might make it more
obvious what the difference is. But I am not sure.


> +  EXPECT_EQ("#if A\n"
> +"namespace A {\n"
> +"#else\n"
> +"namespace B {\n"
> +"#endif\n"
> +"int i;\n"
> +"int j;\n"
> +"} // namespace B",
> +fixNamespaceEndComments("#if A\n"
> +"namespace A {\n"
> +"#else\n"
> +"namespace B {\n"
> +"#endif\n"
> +"int i;\n"
> +"int j;\n"
> +"} // namespace B"));
> +  EXPECT_EQ("namespace A\n"
> +"int i;\n"
> +"int j;\n"
> +"#if A\n"
> +"}\n"
> +"#else\n"
> +"}\n"
> +"#endif",
> +fixNamespaceEndComments("namespace A\n"
> +"int i;\n"
> +"int j;\n"
> +"#if A\n"
> +"}\n"
> +"#else\n"
> +"}\n"
> +"#endif"));
>

Similarly, I would have expected us to insert "//namespace A" here. Why
don't we. Is that related to the missing "{" after "namespace A"?


> +  EXPECT_EQ("namespace A\n"
> +"int i;\n"
> +"int j;\n"
> +"#if A\n"
> +"} // namespace A\n"
> +"#else\n"
> +"} // namespace A\n"
> +"#endif",
> +fixNamespaceEndComments("namespace A\n"
> +"int i;\n"
> +"int j;\n"
> +"#if A\n"
> +"} // namespace A\n"
> +"#else\n"
> +"} // namespace A\n"
> +"#endif"));
>  }
>
>  TEST_F(NamespaceEndCommentsFixerTest,
>
>
> ___
> 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
ht

r297037 - [modules] Add missing test from r297030.

2017-03-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Mar  6 11:47:57 2017
New Revision: 297037

URL: http://llvm.org/viewvc/llvm-project?rev=297037&view=rev
Log:
[modules] Add missing test from r297030.

Added:
cfe/trunk/test/Modules/Inputs/gnumode-non-benign/
cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h
cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap
cfe/trunk/test/Modules/gnumode-non-benign.cpp

Added: cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h?rev=297037&view=auto
==
--- cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h (added)
+++ cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h Mon Mar  6 
11:47:57 2017
@@ -0,0 +1,5 @@
+// Check for GNUMode = 1 by looking for the "linux" define which only exists
+// for GNUMode = 1.
+#ifdef linux
+ #error "Submodule has GNUMode=1"
+#endif

Added: cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap?rev=297037&view=auto
==
--- cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap Mon Mar  
6 11:47:57 2017
@@ -0,0 +1 @@
+module "module.h" { header "module.h"}

Added: cfe/trunk/test/Modules/gnumode-non-benign.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/gnumode-non-benign.cpp?rev=297037&view=auto
==
--- cfe/trunk/test/Modules/gnumode-non-benign.cpp (added)
+++ cfe/trunk/test/Modules/gnumode-non-benign.cpp Mon Mar  6 11:47:57 2017
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -I%S/Inputs/gnumode-non-benign -verify %s
+
+// expected-no-diagnostics
+
+// This test ensures that submodules have the same GNUMode language option
+// setting as the main clang invocation.
+// Note that we set GNUMode = 0 with -std=c++11 for this file.
+
+// This module fails to compile with GNUMode = 1.
+#include "module.h"


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


[PATCH] D27092: Add RecursionChecker for finding infinite recursion

2017-03-06 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

This is waiting for a resolution on a CallEvent API patch as described in 
https://reviews.llvm.org/D27091.

This is blocked on https://reviews.llvm.org/D27091.




Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:29
+// this patch.
+REGISTER_SET_WITH_PROGRAMSTATE(DirtyStackFrames,
+   const clang::StackFrameContext *)

 


https://reviews.llvm.org/D27092



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


Re: r296927 - Add arch-specific directory to search path

2017-03-06 Thread Pirama Arumuga Nainar via cfe-commits
Adding Reid, Michal


On Mon, Mar 6, 2017 at 5:01 AM, Benjamin Kramer  wrote:

> On Sat, Mar 4, 2017 at 12:20 AM, Pirama Arumuga Nainar via cfe-commits
>  wrote:
> > Author: pirama
> > Date: Fri Mar  3 17:20:49 2017
> > New Revision: 296927
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=296927&view=rev
> > Log:
> > Add arch-specific directory to search path
> >
> > Summary:
> >
> > This change adds an arch-specific subdirectory in /lib/
> > to the linker search path.  This path also gets added as '-rpath' for
> > native compilation if a runtime is linked in as a shared object.  This
> > allows arch-specific libraries to be installed alongside clang.
> >
> > Reviewers: danalbert, cbergstrom, javed.absar
> >
> > Subscribers: srhines
> >
> > Differential Revision: https://reviews.llvm.org/D30015
> >
> > Added:
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/aarch64/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/aarch64/.keep
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/arm/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/arm/.keep
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/i386/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/i386/.keep
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/x86_64/
> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
> lib/linux/x86_64/.keep
> > cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
> > cfe/trunk/test/Driver/arch-specific-libdir.c
> > Modified:
> > cfe/trunk/include/clang/Driver/ToolChain.h
> > cfe/trunk/lib/Driver/ToolChain.cpp
> > cfe/trunk/lib/Driver/Tools.cpp
> > cfe/trunk/test/lit.cfg
> >
> > Modified: cfe/trunk/include/clang/Driver/ToolChain.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/ToolChain.h?rev=296927&r1=296926&r2=296927&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
> > +++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Mar  3 17:20:49 2017
> > @@ -299,6 +299,11 @@ public:
> >const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
> >   StringRef Component,
> >   bool Shared = false) const;
> > +
> > +  // Returns /lib//.  This is used by
> runtimes (such
> > +  // as OpenMP) to find arch-specific libraries.
> > +  std::string getArchSpecificLibPath() const;
> > +
> >/// needsProfileRT - returns true if instrumentation profile is on.
> >static bool needsProfileRT(const llvm::opt::ArgList &Args);
> >
> >
> > Modified: cfe/trunk/lib/Driver/ToolChain.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChain.cpp?rev=296927&r1=296926&r2=296927&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Mar  3 17:20:49 2017
> > @@ -10,6 +10,7 @@
> >  #include "clang/Driver/ToolChain.h"
> >  #include "Tools.h"
> >  #include "clang/Basic/ObjCRuntime.h"
> > +#include "clang/Basic/VirtualFileSystem.h"
> >  #include "clang/Config/config.h"
> >  #include "clang/Driver/Action.h"
> >  #include "clang/Driver/Driver.h"
> > @@ -74,6 +75,10 @@ ToolChain::ToolChain(const Driver &D, co
> >  if (!isThreadModelSupported(A->getValue()))
> >D.Diag(diag::err_drv_invalid_thread_model_for_target)
> ><< A->getValue() << A->getAsString(Args);
> > +
> > +  std::string CandidateLibPath = getArchSpecificLibPath();
> > +  if (getVFS().exists(CandidateLibPath))
> > +getFilePaths().push_back(CandidateLibPath);
> >  }
> >
> >  ToolChain::~ToolChain() {
> > @@ -320,6 +325,14 @@ const char *ToolChain::getCompilerRTArgS
> >return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
> >  }
> >
> > +std::string ToolChain::getArchSpecificLibPath() const {
> > +  SmallString<128> Path(getDriver().ResourceDir);
> > +  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
> > +  llvm::sys::path::append(Path, "lib", OSLibName,
> > +  llvm::Triple::getArchTypeName(getArch()));
> > +  return Path.str();
> > +}
> > +
> >  bool ToolChain::needsProfileRT(const ArgList &Args) {
> >if (Args.hasFlag(options::OPT_fprofile_arcs,
> options::OPT_fno_profile_arcs,
> > false) ||
> >
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> Tools.cpp?rev=296927&r1=296926&r

[PATCH] D30663: Use filename in linemarker when compiling preprocessed source (Revised)

2017-03-06 Thread Taewook Oh via Phabricator via cfe-commits
twoh created this revision.

This is a revised version of https://reviews.llvm.org/D28796. Included test is 
changed to
resolve the target compatibility issue reported 
(https://reviews.llvm.org/rL293032).


https://reviews.llvm.org/D30663

Files:
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/FrontendAction.cpp
  test/Frontend/preprocessed-input.c

Index: test/Frontend/preprocessed-input.c
===
--- /dev/null
+++ test/Frontend/preprocessed-input.c
@@ -0,0 +1,3 @@
+// RUN: %clang -E -o %t.i %s
+// RUN: %clang -emit-llvm -S -o - %t.i | FileCheck %s
+// CHECK: source_filename = {{.*}}preprocessed-input.c"{{$}}
Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -19,6 +19,7 @@
 #include "clang/Frontend/MultiplexConsumer.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Parse/ParseAST.h"
@@ -187,6 +188,42 @@
   return llvm::make_unique(std::move(Consumers));
 }
 
+// For preprocessed files, if the first line is the linemarker and specifies
+// the original source file name, use that name as the input file name.
+static bool ReadOriginalFileName(CompilerInstance &CI, std::string &InputFile)
+{
+  bool Invalid = false;
+  auto &SourceMgr = CI.getSourceManager();
+  auto MainFileID = SourceMgr.getMainFileID();
+  const auto *MainFileBuf = SourceMgr.getBuffer(MainFileID, &Invalid);
+  if (Invalid)
+return false;
+
+  std::unique_ptr RawLexer(
+  new Lexer(MainFileID, MainFileBuf, SourceMgr, CI.getLangOpts()));
+
+  // If the first line has the syntax of
+  //
+  // # NUM "FILENAME"
+  //
+  // we use FILENAME as the input file name.
+  Token T;
+  if (RawLexer->LexFromRawLexer(T) || T.getKind() != tok::hash)
+return false;
+  if (RawLexer->LexFromRawLexer(T) || T.isAtStartOfLine() ||
+  T.getKind() != tok::numeric_constant)
+return false;
+  RawLexer->LexFromRawLexer(T);
+  if (T.isAtStartOfLine() || T.getKind() != tok::string_literal)
+return false;
+
+  StringLiteralParser Literal(T, CI.getPreprocessor());
+  if (Literal.hadError)
+return false;
+  InputFile = Literal.GetString().str();
+  return true;
+}
+
 bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
  const FrontendInputFile &Input) {
   assert(!Instance && "Already processing a source file!");
@@ -338,6 +375,13 @@
 if (!isModelParsingAction())
   CI.createASTContext();
 
+// For preprocessed files, check if the first line specifies the original
+// source file name with a linemarker.
+std::string OrigFile;
+if (Input.isPreprocessed())
+  if (ReadOriginalFileName(CI, OrigFile))
+InputFile = OrigFile;
+
 std::unique_ptr Consumer =
 CreateWrappedASTConsumer(CI, InputFile);
 if (!Consumer)
@@ -430,9 +474,9 @@
 
   // If there is a layout overrides file, attach an external AST source that
   // provides the layouts from that file.
-  if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() && 
+  if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() &&
   CI.hasASTContext() && !CI.getASTContext().getExternalSource()) {
-IntrusiveRefCntPtr 
+IntrusiveRefCntPtr
   Override(new LayoutOverrideSource(
  CI.getFrontendOpts().OverrideRecordLayoutsFile));
 CI.getASTContext().setExternalSource(Override);
Index: include/clang/Frontend/FrontendOptions.h
===
--- include/clang/Frontend/FrontendOptions.h
+++ include/clang/Frontend/FrontendOptions.h
@@ -81,7 +81,7 @@
   IK_LLVM_IR
 };
 
-  
+
 /// \brief An input file for the front end.
 class FrontendInputFile {
   /// \brief The file name, or "-" to read from standard input.
@@ -109,6 +109,13 @@
   bool isEmpty() const { return File.empty() && Buffer == nullptr; }
   bool isFile() const { return !isBuffer(); }
   bool isBuffer() const { return Buffer != nullptr; }
+  bool isPreprocessed() const {
+return Kind == IK_PreprocessedC ||
+   Kind == IK_PreprocessedCXX ||
+   Kind == IK_PreprocessedObjC ||
+   Kind == IK_PreprocessedObjCXX ||
+   Kind == IK_PreprocessedCuda;
+  }
 
   StringRef getFile() const {
 assert(isFile());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30435: [clang-import-test] Lookup inside entities

2017-03-06 Thread Sean Callanan via cfe-commits
Aleksei,

thank you for your comments!

I appreciate your comments in particular about source/destination confusion.  I 
can relate to this, as this was (a) an area that confused me while I was 
working on this code in LLDB; and (b) it was something I had to keep straight 
in my head even when doing the work here.  I will implement a type-system based 
solution to this and update the patch, then you can have a look and we'll 
decide if it looks better that way.
The std::transform is more efficient than the for loop because it reallocates 
the array once at the beginning, instead of progressively as we push_back.  
This means the asymptotic runtime of this loop will be worse than the 
std::transform.  Is that an acceptable trade?
The other points are well-taken – in particular, I like your idea about 
breaking the std::none_of block out into a function.  I'll apply them in an 
updated patch.

Sean

> On Mar 6, 2017, at 9:48 AM, Aleksei Sidorin via Phabricator 
> mailto:revi...@reviews.llvm.org>> wrote:
> 
> a.sidorin added a comment.
> 
> Hello Sean,
> 
> It is good to have the ability of recursive lookup. But for me (and I'm 
> sorry), the code becomes very hard to understand: I need to track if the 
> Decl/DC is in the source AST or in the AST being imported, if it was imported 
> or if was in the AST before across lambdas and calls. Can we make this more 
> clear?
> 
> 
> 
> 
> Comment at: tools/clang-import-test/clang-import-test.cpp:201
> +  Decl *Imported(Decl *From, Decl *To) override {
> +if (auto ToTag = llvm::dyn_cast(To)) {
> +  ToTag->setHasExternalLexicalStorage();
> 
> Can we make the usage of qualified and non-qualified casts consistent? 
> Usually, casts are used as unqualified.
> 
> 
> 
> Comment at: tools/clang-import-test/clang-import-test.cpp:298
> +
> +std::vector CompleteDecls;
> +std::vector ForwardDecls;
> 
> I guess we can use `SmallVector`s here too.
> 
> 
> 
> Comment at: tools/clang-import-test/clang-import-test.cpp:303
> +  if (IsForwardDeclaration(C.first)) {
> +if (std::none_of(ForwardDecls.begin(), ForwardDecls.end(),
> + [&C](Candidate &D) {
> 
> Nit: to make the code cleaner, we can extract this `std::none_of` to a 
> separate function like `IsFoundAsForward()`. Nested lambdas are harder to 
> read.
> 
> 
> 
> Comment at: tools/clang-import-test/clang-import-test.cpp:333
> +Decls.resize(DeclsToReport.size());
> +std::transform(DeclsToReport.begin(), DeclsToReport.end(), Decls.begin(),
> +   [](Candidate &C) {
> 
> The loop:
> ```
> Decls.reserve(DeclsToReport.size());
> for (Candidate &C : DeclsToReport)
>  Decls.push_back(cast(C.second->Import(C.first)));
> ```
> will look a bit nicer here. What do you think?
> 
> 
> Repository:
>  rL LLVM
> 
> https://reviews.llvm.org/D30435 
> 
> 
> 

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


[PATCH] D30489: [analyzer] catch out of bounds for VLA

2017-03-06 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna requested changes to this revision.
zaks.anna added a comment.
This revision now requires changes to proceed.

Following Gabor's suggestion, we should investigate if ArrayBoundCheckerV2 
supports this. If not it's possible that we are hitting the Constraint Solver 
limitations.


Repository:
  rL LLVM

https://reviews.llvm.org/D30489



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


Re: r296927 - Add arch-specific directory to search path

2017-03-06 Thread Benjamin Kramer via cfe-commits
On Mon, Mar 6, 2017 at 7:00 PM, Pirama Arumuga Nainar  wrote:
> Adding Reid, Michal
>
>
> On Mon, Mar 6, 2017 at 5:01 AM, Benjamin Kramer  wrote:
>>
>> On Sat, Mar 4, 2017 at 12:20 AM, Pirama Arumuga Nainar via cfe-commits
>>  wrote:
>> > Author: pirama
>> > Date: Fri Mar  3 17:20:49 2017
>> > New Revision: 296927
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=296927&view=rev
>> > Log:
>> > Add arch-specific directory to search path
>> >
>> > Summary:
>> >
>> > This change adds an arch-specific subdirectory in /lib/
>> > to the linker search path.  This path also gets added as '-rpath' for
>> > native compilation if a runtime is linked in as a shared object.  This
>> > allows arch-specific libraries to be installed alongside clang.
>> >
>> > Reviewers: danalbert, cbergstrom, javed.absar
>> >
>> > Subscribers: srhines
>> >
>> > Differential Revision: https://reviews.llvm.org/D30015
>> >
>> > Added:
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/
>> >
>> > cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
>> > cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
>> > cfe/trunk/test/Driver/arch-specific-libdir.c
>> > Modified:
>> > cfe/trunk/include/clang/Driver/ToolChain.h
>> > cfe/trunk/lib/Driver/ToolChain.cpp
>> > cfe/trunk/lib/Driver/Tools.cpp
>> > cfe/trunk/test/lit.cfg
>> >
>> > Modified: cfe/trunk/include/clang/Driver/ToolChain.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=296927&r1=296926&r2=296927&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
>> > +++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Mar  3 17:20:49 2017
>> > @@ -299,6 +299,11 @@ public:
>> >const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
>> >   StringRef Component,
>> >   bool Shared = false) const;
>> > +
>> > +  // Returns /lib//.  This is used by
>> > runtimes (such
>> > +  // as OpenMP) to find arch-specific libraries.
>> > +  std::string getArchSpecificLibPath() const;
>> > +
>> >/// needsProfileRT - returns true if instrumentation profile is on.
>> >static bool needsProfileRT(const llvm::opt::ArgList &Args);
>> >
>> >
>> > Modified: cfe/trunk/lib/Driver/ToolChain.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=296927&r1=296926&r2=296927&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
>> > +++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Mar  3 17:20:49 2017
>> > @@ -10,6 +10,7 @@
>> >  #include "clang/Driver/ToolChain.h"
>> >  #include "Tools.h"
>> >  #include "clang/Basic/ObjCRuntime.h"
>> > +#include "clang/Basic/VirtualFileSystem.h"
>> >  #include "clang/Config/config.h"
>> >  #include "clang/Driver/Action.h"
>> >  #include "clang/Driver/Driver.h"
>> > @@ -74,6 +75,10 @@ ToolChain::ToolChain(const Driver &D, co
>> >  if (!isThreadModelSupported(A->getValue()))
>> >D.Diag(diag::err_drv_invalid_thread_model_for_target)
>> ><< A->getValue() << A->getAsString(Args);
>> > +
>> > +  std::string CandidateLibPath = getArchSpecificLibPath();
>> > +  if (getVFS().exists(CandidateLibPath))
>> > +getFilePaths().push_back(CandidateLibPath);
>> >  }
>> >
>> >  ToolChain::~ToolChain() {
>> > @@ -320,6 +325,14 @@ const char *ToolChain::getCompilerRTArgS
>> >return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
>> >  }
>> >
>> > +std::string ToolChain::getArchSpecificLibPath() const {
>> > +  SmallString<128> Path(getDriver().ResourceDir);
>> > +  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" :
>> > getOS();
>> > +  llvm::sys::path::append(Path, "lib", OSLibName,
>> > +  llvm::Triple::getArchTypeName(getArch()));
>> > +  return Path.str();
>> > +}
>> > +
>> >  bool ToolChain::needsProfileRT(const ArgList &Args) {
>> >if (Args.hasFlag(options::OPT_fprofile_arcs,
>> > options::OPT_fno_profile_arcs,
>> >  

[PATCH] D30663: Use filename in linemarker when compiling preprocessed source (Revised)

2017-03-06 Thread Bob Haarman via Phabricator via cfe-commits
inglorion added inline comments.



Comment at: test/Frontend/preprocessed-input.c:3
+// RUN: %clang -emit-llvm -S -o - %t.i | FileCheck %s
+// CHECK: source_filename = {{.*}}preprocessed-input.c"{{$}}

Actually, I think you don't even have to run the preprocessor - you can just 
put the file with the linemarker here and check that the name from the 
linemarker is propagated, right?

Also, it seems that there is a similar issue to the one you're trying to fix 
when going from .ll to .o (or .ll to .s, for that matter) - the name is taken 
from the file you're reading from, not from the source_filename directive in 
that file. Of course, that doesn't differ from gcc (given that gcc doesn't 
handle .ll files), but you may want to address that, too, for consistency.


https://reviews.llvm.org/D30663



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


[PATCH] D17469: [libcxx] Add deployment knobs to tests (for Apple platforms)

2017-03-06 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a subscriber: mehdi_amini.
dexonsmith added a comment.

Mehdi, are you interested in rebasing this?


https://reviews.llvm.org/D17469



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


r297050 - Further fixes and improvements to the ConstantInitBuilder API.

2017-03-06 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Mar  6 13:04:16 2017
New Revision: 297050

URL: http://llvm.org/viewvc/llvm-project?rev=297050&view=rev
Log:
Further fixes and improvements to the ConstantInitBuilder API.

Added:
cfe/trunk/include/clang/CodeGen/ConstantInitFuture.h
Modified:
cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h
cfe/trunk/lib/CodeGen/ConstantInitBuilder.cpp

Modified: cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h?rev=297050&r1=297049&r2=297050&view=diff
==
--- cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h (original)
+++ cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h Mon Mar  6 13:04:16 
2017
@@ -21,6 +21,7 @@
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/GlobalValue.h"
 #include "clang/AST/CharUnits.h"
+#include "clang/CodeGen/ConstantInitFuture.h"
 
 #include 
 
@@ -60,18 +61,17 @@ class ConstantInitBuilderBase {
   std::vector SelfReferences;
   bool Frozen = false;
 
+  friend class ConstantInitFuture;
   friend class ConstantAggregateBuilderBase;
   template 
   friend class ConstantAggregateBuilderTemplateBase;
 
-  // The rule for CachedOffset is that anything which removes elements
-  // from the Buffer
-
 protected:
   explicit ConstantInitBuilderBase(CodeGenModule &CGM) : CGM(CGM) {}
 
   ~ConstantInitBuilderBase() {
 assert(Buffer.empty() && "didn't claim all values out of buffer");
+assert(SelfReferences.empty() && "didn't apply all self-references");
   }
 
 private:
@@ -83,10 +83,14 @@ private:
= llvm::GlobalValue::InternalLinkage,
  unsigned addressSpace = 0);
 
+  ConstantInitFuture createFuture(llvm::Constant *initializer);
+
   void setGlobalInitializer(llvm::GlobalVariable *GV,
 llvm::Constant *initializer);
 
   void resolveSelfReferences(llvm::GlobalVariable *GV);
+
+  void abandon(size_t newEnd);
 };
 
 /// A concrete base class for struct and array aggregate
@@ -99,6 +103,7 @@ protected:
   mutable size_t CachedOffsetEnd = 0;
   bool Finished = false;
   bool Frozen = false;
+  bool Packed = false;
   mutable CharUnits CachedOffsetFromGlobal;
 
   llvm::SmallVectorImpl &getBuffer() {
@@ -150,17 +155,32 @@ public:
   // properly to satisfy the assert in the destructor.
   ConstantAggregateBuilderBase(ConstantAggregateBuilderBase &&other)
 : Builder(other.Builder), Parent(other.Parent), Begin(other.Begin),
-  Finished(other.Finished), Frozen(other.Frozen) {
+  CachedOffsetEnd(other.CachedOffsetEnd),
+  Finished(other.Finished), Frozen(other.Frozen), Packed(other.Packed),
+  CachedOffsetFromGlobal(other.CachedOffsetFromGlobal) {
 other.Finished = true;
   }
   ConstantAggregateBuilderBase &operator=(ConstantAggregateBuilderBase &&other)
 = delete;
 
+  /// Return the number of elements that have been added to
+  /// this struct or array.
+  size_t size() const {
+assert(!this->Finished && "cannot query after finishing builder");
+assert(!this->Frozen && "cannot query while sub-builder is active");
+assert(this->Begin <= this->getBuffer().size());
+return this->getBuffer().size() - this->Begin;
+  }
+
+  /// Return true if no elements have yet been added to this struct or array.
+  bool empty() const {
+return size() == 0;
+  }
+
   /// Abandon this builder completely.
   void abandon() {
 markFinished();
-auto &buffer = Builder.Buffer;
-buffer.erase(buffer.begin() + Begin, buffer.end());
+Builder.abandon(Begin);
   }
 
   /// Add a new value to this initializer.
@@ -224,6 +244,9 @@ public:
 
   /// Return the offset from the start of the initializer to the
   /// next position, assuming no padding is required prior to it.
+  ///
+  /// This operation will not succeed if any unsized placeholders are
+  /// currently in place in the initializer.
   CharUnits getNextOffsetFromGlobal() const {
 assert(!Finished && "cannot add more values after finishing builder");
 assert(!Frozen && "cannot add values while subbuilder is active");
@@ -253,6 +276,9 @@ public:
 return Builder.Buffer.size() - 1;
   }
 
+  /// Add a placeholder, giving the expected type that will be filled in.
+  PlaceholderPosition addPlaceholderWithSize(llvm::Type *expectedType);
+
   /// Fill a previously-added placeholder.
   void fillPlaceholderWithInt(PlaceholderPosition position,
   llvm::IntegerType *type, uint64_t value,
@@ -354,6 +380,19 @@ public:
 assert(!this->Parent && "finishing non-root builder");
 return this->Builder.setGlobalInitializer(global, asImpl().finishImpl());
   }
+
+  /// Given that this builder was created by beginning an array or struct
+  /// directly on a ConstantInitBuilder, finish the array/struct and
+  /// return a future which can be used to install the 

Re: Patch for Bug 30413, including test case

2017-03-06 Thread Lobron, David via cfe-commits
Hi Akira,

Pardon my slowness in addressing your question.

> This patch changes the encoding of an id conforming to a protocol, which I 
> think was not intended: For example:
> 
> @encode(id)
> 
> Would passing IVD to the call to getObjCEncodingForType in 
> CGObjCGNU::GenerateClass solve the problem?

Are you suggesting that passing IVD instead of just IVD->getType() will tell 
getObjCEncodingForType whether the code being compiled is a protocol, as 
opposed to an object?  I'm a little confused here, because IVD is an object of 
type ObjCIvarDecl, which is supposed to represent an instance variable, not a 
protocol.  Also, I don't see anything in the definition of ObjCIvarDecl (in 
AST/DeclObjC.h) that would tell us whether it represents an instance variable 
or a protocol.  Can you explain the case you are concerned about a little more?

If IVD can in fact tell us whether the code being compiled is an object, then 
we can make the EncodeClassNames argument of getObjCEncodingForTypeImpl true 
for ivars and false for protocols.

Thanks!

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


[PATCH] D30663: Use filename in linemarker when compiling preprocessed source (Revised)

2017-03-06 Thread Taewook Oh via Phabricator via cfe-commits
twoh added inline comments.



Comment at: test/Frontend/preprocessed-input.c:3
+// RUN: %clang -emit-llvm -S -o - %t.i | FileCheck %s
+// CHECK: source_filename = {{.*}}preprocessed-input.c"{{$}}

inglorion wrote:
> Actually, I think you don't even have to run the preprocessor - you can just 
> put the file with the linemarker here and check that the name from the 
> linemarker is propagated, right?
> 
> Also, it seems that there is a similar issue to the one you're trying to fix 
> when going from .ll to .o (or .ll to .s, for that matter) - the name is taken 
> from the file you're reading from, not from the source_filename directive in 
> that file. Of course, that doesn't differ from gcc (given that gcc doesn't 
> handle .ll files), but you may want to address that, too, for consistency.
@inglorion Thanks for the comments! Putting preprocessed file makes sense to 
me. 

I recognize the second issue. If I do something like

```
clang -E -o test.i /abspath/test.c
clang -g -c -o test.o test.i
```

DW_AT_name is still test.i (for gcc, it is taken from the linemarker as well). 

Moreover, if we use the absolute path of test.i for clang, i.e.

```
clang -g -c -o test.o /abspath/test.i
```

DW_AT_name becomes /abspath/test.i where DW_AT_comp_dir is /abspath. I think 
this could be a problem if the user of the object file assumes that DW_AT_name 
is a relative to DW_AT_comp_dir. I'm planning to address this with a separate 
patch.


https://reviews.llvm.org/D30663



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


r297057 - [MS] Add support for __ud2 and __int2c MSVC intrinsics

2017-03-06 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Mar  6 13:43:16 2017
New Revision: 297057

URL: http://llvm.org/viewvc/llvm-project?rev=297057&view=rev
Log:
[MS] Add support for __ud2 and __int2c MSVC intrinsics

This was requested in PR31958 and elsewhere.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=297057&r1=297056&r2=297057&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Mar  6 13:43:16 2017
@@ -1829,6 +1829,8 @@ TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi
 TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
 TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
+TARGET_HEADER_BUILTIN(__int2c, "v",   "nr", "intrin.h", ALL_MS_LANGUAGES, 
"")
+TARGET_HEADER_BUILTIN(__ud2,   "v",   "nr", "intrin.h", ALL_MS_LANGUAGES, 
"")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=297057&r1=297056&r2=297057&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Mar  6 13:43:16 2017
@@ -7982,6 +7982,21 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 // instruction, but it will create a memset that won't be optimized away.
 return Builder.CreateMemSet(Ops[0], Ops[1], Ops[2], 1, true);
   }
+  case X86::BI__ud2:
+// llvm.trap makes a ud2a instruction on x86.
+return EmitTrapCall(Intrinsic::trap);
+  case X86::BI__int2c: {
+// This syscall signals a driver assertion failure in x86 NT kernels.
+llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
+llvm::InlineAsm *IA =
+llvm::InlineAsm::get(FTy, "int $$0x2c", "", /*SideEffects=*/true);
+llvm::AttributeSet NoReturnAttr =
+AttributeSet::get(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
+  llvm::Attribute::NoReturn);
+CallSite CS = Builder.CreateCall(IA);
+CS.setAttributes(NoReturnAttr);
+return CS.getInstruction();
+  }
   }
 }
 

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=297057&r1=297056&r2=297057&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Mon Mar  6 13:43:16 2017
@@ -79,7 +79,6 @@ void __incfsdword(unsigned long);
 void __incfsword(unsigned long);
 unsigned long __indword(unsigned short);
 void __indwordstring(unsigned short, unsigned long *, unsigned long);
-void __int2c(void);
 void __invlpg(void *);
 unsigned short __inword(unsigned short);
 void __inwordstring(unsigned short, unsigned short *, unsigned long);
@@ -141,7 +140,6 @@ void __svm_stgi(void);
 void __svm_vmload(size_t);
 void __svm_vmrun(size_t);
 void __svm_vmsave(size_t);
-void __ud2(void);
 unsigned __int64 __ull_rshift(unsigned __int64, int);
 void __vmx_off(void);
 void __vmx_vmptrst(unsigned __int64 *);

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=297057&r1=297056&r2=297057&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Mon Mar  6 13:43:16 2017
@@ -28,6 +28,20 @@ void test__stosb(unsigned char *Dest, un
 // CHECK-X64:   tail call void @llvm.memset.p0i8.i64(i8* %Dest, i8 %Data, i64 
%Count, i32 1, i1 true)
 // CHECK-X64:   ret void
 // CHECK-X64: }
+
+void test__ud2(void) {
+  __ud2();
+}
+// CHECK-INTEL-LABEL: define{{.*}} void @test__ud2()
+// CHECK-INTEL: call void @llvm.trap()
+
+void test__int2c(void) {
+  __int2c();
+}
+// CHECK-INTEL-LABEL: define{{.*}} void @test__int2c()
+// CHECK-INTEL: call void asm sideeffect "int $$0x2c", ""() 
#[[NORETURN:[0-9]+]]
+
+
 #endif
 
 void *test_ReturnAddress() {
@@ -425,7 +439,7 @@ void test__fastfail() {
 }
 // CHECK-LABEL: define{{.*}} void @test__fastfail()
 // CHECK-ARM: call void asm sideeffect "udf #251", "{r0}"(i32 42) 
#[[NORETURN:[0-9]+]]
-// CHECK-INTEL: call void asm sideeffect "int $$0x29", "{cx}"(i32 42) 
#[[NORETURN:[0-9]+]]
+// CHECK-INTEL: call void asm sideeffect "int $$0x29", "{cx}"(i32 42) 
#[[NORETURN]]
 
 // Attributes come last.
 


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


[PATCH] D26316: [coroutines] Build and pass coroutine_handle to await_suspend.

2017-03-06 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov commandeered this revision.
GorNishanov edited reviewers, added: EricWF; removed: GorNishanov.
GorNishanov added a comment.

Comandeering this patch.
Last week Richard gave me some feedback in person on this code (in the full 
coroutine implementation not this patch in particular). I am going to implement 
the feedback and adjust this patch and resubmit for review.


https://reviews.llvm.org/D26316



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


[PATCH] D30427: Fix whitespace before token-paste of an argument.

2017-03-06 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping


https://reviews.llvm.org/D30427



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


[PATCH] D30663: Use filename in linemarker when compiling preprocessed source (Revised)

2017-03-06 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 90735.
twoh added a comment.
Herald added a subscriber: mehdi_amini.

addressing comments from @inglorion


https://reviews.llvm.org/D30663

Files:
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/FrontendAction.cpp
  test/Frontend/preprocessed-input.i

Index: test/Frontend/preprocessed-input.i
===
--- /dev/null
+++ test/Frontend/preprocessed-input.i
@@ -0,0 +1,10 @@
+# 1 "preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
+// CHECK: source_filename = "preprocessed-input.c"{{$}}
Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -19,6 +19,7 @@
 #include "clang/Frontend/MultiplexConsumer.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Parse/ParseAST.h"
@@ -187,6 +188,42 @@
   return llvm::make_unique(std::move(Consumers));
 }
 
+// For preprocessed files, if the first line is the linemarker and specifies
+// the original source file name, use that name as the input file name.
+static bool ReadOriginalFileName(CompilerInstance &CI, std::string &InputFile)
+{
+  bool Invalid = false;
+  auto &SourceMgr = CI.getSourceManager();
+  auto MainFileID = SourceMgr.getMainFileID();
+  const auto *MainFileBuf = SourceMgr.getBuffer(MainFileID, &Invalid);
+  if (Invalid)
+return false;
+
+  std::unique_ptr RawLexer(
+  new Lexer(MainFileID, MainFileBuf, SourceMgr, CI.getLangOpts()));
+
+  // If the first line has the syntax of
+  //
+  // # NUM "FILENAME"
+  //
+  // we use FILENAME as the input file name.
+  Token T;
+  if (RawLexer->LexFromRawLexer(T) || T.getKind() != tok::hash)
+return false;
+  if (RawLexer->LexFromRawLexer(T) || T.isAtStartOfLine() ||
+  T.getKind() != tok::numeric_constant)
+return false;
+  RawLexer->LexFromRawLexer(T);
+  if (T.isAtStartOfLine() || T.getKind() != tok::string_literal)
+return false;
+
+  StringLiteralParser Literal(T, CI.getPreprocessor());
+  if (Literal.hadError)
+return false;
+  InputFile = Literal.GetString().str();
+  return true;
+}
+
 bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
  const FrontendInputFile &Input) {
   assert(!Instance && "Already processing a source file!");
@@ -338,6 +375,13 @@
 if (!isModelParsingAction())
   CI.createASTContext();
 
+// For preprocessed files, check if the first line specifies the original
+// source file name with a linemarker.
+std::string OrigFile;
+if (Input.isPreprocessed())
+  if (ReadOriginalFileName(CI, OrigFile))
+InputFile = OrigFile;
+
 std::unique_ptr Consumer =
 CreateWrappedASTConsumer(CI, InputFile);
 if (!Consumer)
@@ -430,9 +474,9 @@
 
   // If there is a layout overrides file, attach an external AST source that
   // provides the layouts from that file.
-  if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() && 
+  if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() &&
   CI.hasASTContext() && !CI.getASTContext().getExternalSource()) {
-IntrusiveRefCntPtr 
+IntrusiveRefCntPtr
   Override(new LayoutOverrideSource(
  CI.getFrontendOpts().OverrideRecordLayoutsFile));
 CI.getASTContext().setExternalSource(Override);
Index: include/clang/Frontend/FrontendOptions.h
===
--- include/clang/Frontend/FrontendOptions.h
+++ include/clang/Frontend/FrontendOptions.h
@@ -81,7 +81,7 @@
   IK_LLVM_IR
 };
 
-  
+
 /// \brief An input file for the front end.
 class FrontendInputFile {
   /// \brief The file name, or "-" to read from standard input.
@@ -109,6 +109,13 @@
   bool isEmpty() const { return File.empty() && Buffer == nullptr; }
   bool isFile() const { return !isBuffer(); }
   bool isBuffer() const { return Buffer != nullptr; }
+  bool isPreprocessed() const {
+return Kind == IK_PreprocessedC ||
+   Kind == IK_PreprocessedCXX ||
+   Kind == IK_PreprocessedObjC ||
+   Kind == IK_PreprocessedObjCXX ||
+   Kind == IK_PreprocessedCuda;
+  }
 
   StringRef getFile() const {
 assert(isFile());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30662: Update clang filtering for mxcsr

2017-03-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Is it possible to add a test case (possibly in CodeGen)?


Repository:
  rL LLVM

https://reviews.llvm.org/D30662



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


Re: [PATCH] D30435: [clang-import-test] Lookup inside entities

2017-03-06 Thread Sean Callanan via cfe-commits
Gosh, I missed the reserve() call.  Sorry!  I'll be happy to implement this 
change.

Sean

> On Mar 6, 2017, at 10:05 AM, Sean Callanan  wrote:
> 
> Aleksei,
> 
> thank you for your comments!
> 
> I appreciate your comments in particular about source/destination confusion.  
> I can relate to this, as this was (a) an area that confused me while I was 
> working on this code in LLDB; and (b) it was something I had to keep straight 
> in my head even when doing the work here.  I will implement a type-system 
> based solution to this and update the patch, then you can have a look and 
> we'll decide if it looks better that way.
> The std::transform is more efficient than the for loop because it reallocates 
> the array once at the beginning, instead of progressively as we push_back.  
> This means the asymptotic runtime of this loop will be worse than the 
> std::transform.  Is that an acceptable trade?
> The other points are well-taken – in particular, I like your idea about 
> breaking the std::none_of block out into a function.  I'll apply them in an 
> updated patch.
> 
> Sean
> 
>> On Mar 6, 2017, at 9:48 AM, Aleksei Sidorin via Phabricator 
>> mailto:revi...@reviews.llvm.org>> wrote:
>> 
>> a.sidorin added a comment.
>> 
>> Hello Sean,
>> 
>> It is good to have the ability of recursive lookup. But for me (and I'm 
>> sorry), the code becomes very hard to understand: I need to track if the 
>> Decl/DC is in the source AST or in the AST being imported, if it was 
>> imported or if was in the AST before across lambdas and calls. Can we make 
>> this more clear?
>> 
>> 
>> 
>> 
>> Comment at: tools/clang-import-test/clang-import-test.cpp:201
>> +  Decl *Imported(Decl *From, Decl *To) override {
>> +if (auto ToTag = llvm::dyn_cast(To)) {
>> +  ToTag->setHasExternalLexicalStorage();
>> 
>> Can we make the usage of qualified and non-qualified casts consistent? 
>> Usually, casts are used as unqualified.
>> 
>> 
>> 
>> Comment at: tools/clang-import-test/clang-import-test.cpp:298
>> +
>> +std::vector CompleteDecls;
>> +std::vector ForwardDecls;
>> 
>> I guess we can use `SmallVector`s here too.
>> 
>> 
>> 
>> Comment at: tools/clang-import-test/clang-import-test.cpp:303
>> +  if (IsForwardDeclaration(C.first)) {
>> +if (std::none_of(ForwardDecls.begin(), ForwardDecls.end(),
>> + [&C](Candidate &D) {
>> 
>> Nit: to make the code cleaner, we can extract this `std::none_of` to a 
>> separate function like `IsFoundAsForward()`. Nested lambdas are harder to 
>> read.
>> 
>> 
>> 
>> Comment at: tools/clang-import-test/clang-import-test.cpp:333
>> +Decls.resize(DeclsToReport.size());
>> +std::transform(DeclsToReport.begin(), DeclsToReport.end(), 
>> Decls.begin(),
>> +   [](Candidate &C) {
>> 
>> The loop:
>> ```
>> Decls.reserve(DeclsToReport.size());
>> for (Candidate &C : DeclsToReport)
>>  Decls.push_back(cast(C.second->Import(C.first)));
>> ```
>> will look a bit nicer here. What do you think?
>> 
>> 
>> Repository:
>>  rL LLVM
>> 
>> https://reviews.llvm.org/D30435 
>> 
>> 
>> 
> 

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


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-03-06 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.h:20
+///\brief Warns about using throw in function declared as noexcept.
+/// It complains about every throw, even if it is caught later.
+class ThrowWithNoexceptCheck : public ClangTidyCheck {

Prazek wrote:
> aaron.ballman wrote:
> > What is the false positive rate with this check over a large codebase that 
> > uses exceptions?
> Do you know any good project to check it?
LibreOffice might be a candidate, see 
 for details on how 
to generate a compile database for it (since it does not use cmake), then you 
can start testing.


https://reviews.llvm.org/D19201



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


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-03-06 Thread Stanisław Barzowski via Phabricator via cfe-commits
sbarzowski added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.h:20
+///\brief Warns about using throw in function declared as noexcept.
+/// It complains about every throw, even if it is caught later.
+class ThrowWithNoexceptCheck : public ClangTidyCheck {

vmiklos wrote:
> Prazek wrote:
> > aaron.ballman wrote:
> > > What is the false positive rate with this check over a large codebase 
> > > that uses exceptions?
> > Do you know any good project to check it?
> LibreOffice might be a candidate, see 
>  for details on 
> how to generate a compile database for it (since it does not use cmake), then 
> you can start testing.
Thanks. However it's not just about using exception. To be meaningful I need a 
project that use noexcept in more than a few places.

Here are some projects that I found:
https://github.com/facebook/hhvm/search?utf8=%E2%9C%93&q=noexcept
https://github.com/facebook/folly/search?utf8=%E2%9C%93&q=noexcept
https://github.com/Tencent/mars/search?utf8=%E2%9C%93&q=noexcept
https://github.com/facebook/rocksdb/search?utf8=%E2%9C%93&q=noexcept
https://github.com/CRYTEK-CRYENGINE/CRYENGINE/search?utf8=%E2%9C%93&q=noexcept
https://github.com/SFTtech/openage/search?utf8=%E2%9C%93&q=noexcept
https://github.com/facebook/watchman/search?utf8=%E2%9C%93&q=noexcept
https://github.com/facebook/proxygen/search?utf8=%E2%9C%93&q=noexcept
https://github.com/philsquared/Catch/search?utf8=%E2%9C%93&q=noexcept
https://github.com/sandstorm-io/capnproto/search?utf8=%E2%9C%93&q=noexcept
https://github.com/miloyip/rapidjson/search?utf8=%E2%9C%93&q=noexcept

I've tried HHVM so far, and ran into some problems compiling it. Anyway I'm 
working on it.


https://reviews.llvm.org/D19201



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


[libcxx] r297065 - Updated email address in `CREDITS.txt`.

2017-03-06 Thread Michael Park via cfe-commits
Author: mpark
Date: Mon Mar  6 14:46:55 2017
New Revision: 297065

URL: http://llvm.org/viewvc/llvm-project?rev=297065&view=rev
Log:
Updated email address in `CREDITS.txt`.

Modified:
libcxx/trunk/CREDITS.TXT

Modified: libcxx/trunk/CREDITS.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CREDITS.TXT?rev=297065&r1=297064&r2=297065&view=diff
==
--- libcxx/trunk/CREDITS.TXT (original)
+++ libcxx/trunk/CREDITS.TXT Mon Mar  6 14:46:55 2017
@@ -81,7 +81,7 @@ E: andrew.c.mor...@gmail.com
 D: Minor patches and Linux fixes.
 
 N: Michael Park
-E: mp...@apache.org
+E: mcyp...@gmail.com
 D: Implementation of .
 
 N: Arvid Picciani


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


[libcxx] r297066 - Mark two any_cast issues as complete

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 14:49:42 2017
New Revision: 297066

URL: http://llvm.org/viewvc/llvm-project?rev=297066&view=rev
Log:
Mark two any_cast issues as complete

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297066&r1=297065&r2=297066&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 14:49:42 2017
@@ -432,8 +432,8 @@

http://wg21.link/LWG2260";>2260Missing 
requirement for Allocator::pointerKona
http://wg21.link/LWG2676";>2676Provide 
filesystem::path overloads for File-based 
streamsKona
-   http://wg21.link/LWG2768";>2768any_cast 
and move semanticsKona
-   http://wg21.link/LWG2769";>2769Redundant 
const in the return type of any_cast(const 
any&)Kona
+   http://wg21.link/LWG2768";>2768any_cast 
and move semanticsKonaComplete
+   http://wg21.link/LWG2769";>2769Redundant 
const in the return type of any_cast(const 
any&)KonaComplete
http://wg21.link/LWG2781";>2781Contradictory requirements for 
std::function and std::reference_wrapperKona
http://wg21.link/LWG2782";>2782scoped_allocator_adaptor 
constructors must be constrainedKona
http://wg21.link/LWG2784";>2784Resolution 
to LWG 2484 is missing "otherwise, no effects" and is hard to 
parseKona


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


[libcxx] r297069 - Mark LWG 2781 as complete. No changes required

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 14:56:13 2017
New Revision: 297069

URL: http://llvm.org/viewvc/llvm-project?rev=297069&view=rev
Log:
Mark LWG 2781 as complete. No changes required

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297069&r1=297068&r2=297069&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 14:56:13 2017
@@ -434,7 +434,7 @@
http://wg21.link/LWG2676";>2676Provide 
filesystem::path overloads for File-based 
streamsKona
http://wg21.link/LWG2768";>2768any_cast 
and move semanticsKonaComplete
http://wg21.link/LWG2769";>2769Redundant 
const in the return type of any_cast(const 
any&)KonaComplete
-   http://wg21.link/LWG2781";>2781Contradictory requirements for 
std::function and std::reference_wrapperKona
+   http://wg21.link/LWG2781";>2781Contradictory requirements for 
std::function and std::reference_wrapperKonaComplete
http://wg21.link/LWG2782";>2782scoped_allocator_adaptor 
constructors must be constrainedKona
http://wg21.link/LWG2784";>2784Resolution 
to LWG 2484 is missing "otherwise, no effects" and is hard to 
parseKona
http://wg21.link/LWG2785";>2785quoted 
should work with basic_string_viewKona


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


[PATCH] D30590: Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-06 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Hal and I discussed exactly the same problem (in the context of coroutines) on 
Saturday and came up with exactly the same approach :) I think this is the 
right direction.




Comment at: lib/CodeGen/CGExprComplex.cpp:204-206
+Scope.ensureDominatingValue(&Vals.first);
+Scope.ensureDominatingValue(&Vals.second);
+Scope.ForceCleanup();

I'm a little concerned about the loose connection between 
`ensureDominatingValue` and `ForrceCleanup` here -- if you forget the 
`ForceCleanup`, you get silent misbehavior. How about removing 
`ensureDominatingValue` and instead passing a `std::initializer_list` 
to `ForceCleanup`?



Comment at: lib/CodeGen/CodeGenFunction.h:539
   private:
+SmallVector ValuesToReload;
 

If you keep a `SmallVector` here, set its inline size to 2 to avoid allocations 
for the `_Complex` case.


https://reviews.llvm.org/D30590



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


[libcxx] r297071 - Implement LWG 2787 - [file_status.cons] is inconsistent

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 15:02:06 2017
New Revision: 297071

URL: http://llvm.org/viewvc/llvm-project?rev=297071&view=rev
Log:
Implement LWG 2787 - [file_status.cons] is inconsistent

Modified:
libcxx/trunk/include/experimental/filesystem

libcxx/trunk/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=297071&r1=297070&r2=297071&view=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Mon Mar  6 15:02:06 2017
@@ -408,8 +408,10 @@ class _LIBCPP_TYPE_VIS file_status
 public:
 // constructors
 _LIBCPP_INLINE_VISIBILITY
-explicit file_status(file_type __ft = file_type::none,
- perms __prms   = perms::unknown) _NOEXCEPT
+file_status() _NOEXCEPT : file_status(file_type::none) {}
+_LIBCPP_INLINE_VISIBILITY
+explicit file_status(file_type __ft,
+ perms __prms = perms::unknown) _NOEXCEPT
   : __ft_(__ft), __prms_(__prms)
 {}
 

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp?rev=297071&r1=297070&r2=297071&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp
 Mon Mar  6 15:02:06 2017
@@ -30,8 +30,8 @@ int main() {
   {
 static_assert(std::is_nothrow_default_constructible::value,
   "The default constructor must be noexcept");
-static_assert(!test_convertible(),
-  "The default constructor must be explicit");
+static_assert(test_convertible(),
+  "The default constructor must not be explicit");
 const file_status f;
 assert(f.type()  == file_type::none);
 assert(f.permissions() == perms::unknown);

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297071&r1=297070&r2=297071&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 15:02:06 2017
@@ -439,7 +439,7 @@
http://wg21.link/LWG2784";>2784Resolution 
to LWG 2484 is missing "otherwise, no effects" and is hard to 
parseKona
http://wg21.link/LWG2785";>2785quoted 
should work with basic_string_viewKona
http://wg21.link/LWG2786";>2786Annex C 
should mention shared_ptr changes for array 
supportKona
-   http://wg21.link/LWG2787";>2787§[file_status.cons] 
doesn't match class definitionKona
+   http://wg21.link/LWG2787";>2787§[file_status.cons] 
doesn't match class definitionKonaComplete
http://wg21.link/LWG2788";>2788basic_string range mutators 
unintentionally require a default constructible 
allocatorKona
http://wg21.link/LWG2789";>2789Equivalence 
of contained objectsKona
http://wg21.link/LWG2790";>2790Missing 
specification of 
istreambuf_iterator::operator->Kona


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


[libcxx] r297073 - Mark LWG 2789 as complete. No changes required

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 15:07:18 2017
New Revision: 297073

URL: http://llvm.org/viewvc/llvm-project?rev=297073&view=rev
Log:
Mark LWG 2789 as complete. No changes required

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297073&r1=297072&r2=297073&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 15:07:18 2017
@@ -441,7 +441,7 @@
http://wg21.link/LWG2786";>2786Annex C 
should mention shared_ptr changes for array 
supportKona
http://wg21.link/LWG2787";>2787§[file_status.cons] 
doesn't match class definitionKonaComplete
http://wg21.link/LWG2788";>2788basic_string range mutators 
unintentionally require a default constructible 
allocatorKona
-   http://wg21.link/LWG2789";>2789Equivalence 
of contained objectsKona
+   http://wg21.link/LWG2789";>2789Equivalence 
of contained objectsKonaComplete
http://wg21.link/LWG2790";>2790Missing 
specification of 
istreambuf_iterator::operator->Kona
http://wg21.link/LWG2794";>2794Missing 
requirements for allocator pointersKona
http://wg21.link/LWG2795";>2795§[global.functions] 
provides incorrect example of ADL useKona


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


[libcxx] r297074 - Mark LWG 2806 as complete. Libc++ speculatively shiped this change in 4.0

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 15:09:02 2017
New Revision: 297074

URL: http://llvm.org/viewvc/llvm-project?rev=297074&view=rev
Log:
Mark LWG 2806 as complete. Libc++ speculatively shiped this change in 4.0

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297074&r1=297073&r2=297074&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Mar  6 15:09:02 2017
@@ -449,7 +449,7 @@
http://wg21.link/LWG2801";>2801Default-constructibility of 
unique_ptrKona
http://wg21.link/LWG2802";>2802shared_ptr 
constructor requirements for a deleterKona
http://wg21.link/LWG2804";>2804Unconditional constexpr 
default constructor for istream_iteratorKona
-   http://wg21.link/LWG2806";>2806Base class 
of bad_optional_accessKona
+   http://wg21.link/LWG2806";>2806Base class 
of bad_optional_accessKonaComplete
http://wg21.link/LWG2807";>2807std::invoke 
should use std::is_nothrow_callableKona
http://wg21.link/LWG2812";>2812Range 
access is available with Kona
http://wg21.link/LWG2824";>2824list::sort 
should say that the order of elements is unspecified if an exception is 
thrownKona


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


r297076 - [coroutines] Add co_return statement emission

2017-03-06 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Mon Mar  6 15:12:54 2017
New Revision: 297076

URL: http://llvm.org/viewvc/llvm-project?rev=297076&view=rev
Log:
[coroutines] Add co_return statement emission

Summary:
Added co_return statement emission.

Tweaked coro-alloc.cpp test to use co_return to trigger coroutine processing 
instead of co_await, since this change starts emitting the body of the 
coroutine and await expression handling has not been upstreamed yet.

Reviewers: rsmith, majnemer, EricWF, aaron.ballman

Reviewed By: rsmith

Subscribers: majnemer, llvm-commits, mehdi_amini

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

Added:
cfe/trunk/test/CodeGenCoroutines/coro-return.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCoroutine.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp

Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=297076&r1=297075&r2=297076&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Mon Mar  6 15:12:54 2017
@@ -21,6 +21,13 @@ namespace clang {
 namespace CodeGen {
 
 struct CGCoroData {
+
+  // Stores the jump destination just before the final suspend. Coreturn
+  // statements jumps to this point after calling return_xxx promise member.
+  CodeGenFunction::JumpDest FinalJD;
+
+  unsigned CoreturnCount = 0;
+
   // Stores the llvm.coro.id emitted in the function so that we can supply it
   // as the first argument to coro.begin, coro.alloc and coro.free intrinsics.
   // Note: llvm.coro.id returns a token that cannot be directly expressed in a
@@ -59,19 +66,46 @@ static void createCoroData(CodeGenFuncti
   CurCoro.Data->CoroIdExpr = CoroIdExpr;
 }
 
+void CodeGenFunction::EmitCoreturnStmt(CoreturnStmt const &S) {
+  ++CurCoro.Data->CoreturnCount;
+  EmitStmt(S.getPromiseCall());
+  EmitBranchThroughCleanup(CurCoro.Data->FinalJD);
+}
+
 void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
   auto *NullPtr = llvm::ConstantPointerNull::get(Builder.getInt8PtrTy());
   auto &TI = CGM.getContext().getTargetInfo();
   unsigned NewAlign = TI.getNewAlign() / TI.getCharWidth();
 
+  auto *FinalBB = createBasicBlock("coro.final");
+
   auto *CoroId = Builder.CreateCall(
   CGM.getIntrinsic(llvm::Intrinsic::coro_id),
   {Builder.getInt32(NewAlign), NullPtr, NullPtr, NullPtr});
   createCoroData(*this, CurCoro, CoroId);
 
   EmitScalarExpr(S.getAllocate());
-  // FIXME: Emit the rest of the coroutine.
+
+  // FIXME: Setup cleanup scopes.
+
+  EmitStmt(S.getPromiseDeclStmt());
+
+  CurCoro.Data->FinalJD = getJumpDestInCurrentScope(FinalBB);
+
+  // FIXME: Emit initial suspend and more before the body.
+
+  EmitStmt(S.getBody());
+
+  // See if we need to generate final suspend.
+  const bool CanFallthrough = Builder.GetInsertBlock();
+  const bool HasCoreturns = CurCoro.Data->CoreturnCount > 0;
+  if (CanFallthrough || HasCoreturns) {
+EmitBlock(FinalBB);
+// FIXME: Emit final suspend.
+  }
   EmitStmt(S.getDeallocate());
+
+  // FIXME: Emit return for the coroutine return object.
 }
 
 // Emit coroutine intrinsic and patch up arguments of the token type.

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=297076&r1=297075&r2=297076&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Mar  6 15:12:54 2017
@@ -145,7 +145,7 @@ void CodeGenFunction::EmitStmt(const Stm
 EmitCoroutineBody(cast(*S));
 break;
   case Stmt::CoreturnStmtClass:
-CGM.ErrorUnsupported(S, "coroutine");
+EmitCoreturnStmt(cast(*S));
 break;
   case Stmt::CapturedStmtClass: {
 const CapturedStmt *CS = cast(S);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=297076&r1=297075&r2=297076&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Mar  6 15:12:54 2017
@@ -2506,6 +2506,7 @@ public:
   void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S);
 
   void EmitCoroutineBody(const CoroutineBodyStmt &S);
+  void EmitCoreturnStmt(const CoreturnStmt &S);
   RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID);
 
   void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);

Modified: cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp?rev=297076&r1=297075&r2=297076&view=diff
===

[libcxx] r297079 - Add list of filesystem NB comments to TODO.TXT so they can be tracked separately

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 15:23:36 2017
New Revision: 297079

URL: http://llvm.org/viewvc/llvm-project?rev=297079&view=rev
Log:
Add list of filesystem NB comments to TODO.TXT so they can be tracked separately

Modified:
libcxx/trunk/TODO.TXT

Modified: libcxx/trunk/TODO.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/TODO.TXT?rev=297079&r1=297078&r2=297079&view=diff
==
--- libcxx/trunk/TODO.TXT (original)
+++ libcxx/trunk/TODO.TXT Mon Mar  6 15:23:36 2017
@@ -17,6 +17,56 @@ Test Suite Tasks
 * Improve the quality and portability of the locale test data.
 * Convert failure tests to use Clang Verify.
 
+Filesystem Tasks
+
+* P0492r2 - Implement National body comments for Filesystem
+* INCOMPLETE - US 25: has_filename() is equivalent to just !empty()
+* INCOMPLETE - US 31: Everything is defined in terms of one implicit host 
system
+* INCOMPLETE - US 32: Meaning of 27.10.2.1 unclear
+* INCOMPLETE - US 33: Definition of canonical path problematic
+* INCOMPLETE - US 34: Are there attributes of a file that are not an 
aspect of the file system?
+* INCOMPLETE - US 35: What synchronization is required to avoid a file 
system race?
+* INCOMPLETE - US 36: Symbolic links themselves are attached to a 
directory via (hard) links
+* INCOMPLETE - US 37: The term “redundant current directory (dot) 
elements” is not defined
+* INCOMPLETE - US 38: Duplicates §17.3.16
+* INCOMPLETE - US 39: Remove note: Dot and dot-dot are not directories
+* INCOMPLETE - US 40: Not all directories have a parent.
+* INCOMPLETE - US 41: The term “parent directory” for a 
(non-directory) file is unusual
+* INCOMPLETE - US 42: Pathname resolution does not always resolve a symlink
+* INCOMPLETE - US 43: Concerns about encoded character types
+* INCOMPLETE - US 44: Definition of path in terms of a string requires 
leaky abstraction
+* INCOMPLETE - US 45: Generic format portability compromised by 
unspecified root-name
+* INCOMPLETE - US 46: filename can be empty so productions for 
relative-path are redundant
+* INCOMPLETE - US 47: “.” and “..” already match the name 
production
+* INCOMPLETE - US 48: Multiple separators are often meaningful in a 
root-name
+* INCOMPLETE - US 49: What does “method of conversion method” mean?
+* INCOMPLETE - US 50: 27.10.8.1 ¶ 1.4 largely redundant with ¶ 1.3
+* INCOMPLETE - US 51: Failing to add / when appending empty string 
prevents useful apps
+* INCOMPLETE - US 52: remove_filename() postcondition is not by itself a 
definition
+* INCOMPLETE - US 53: remove_filename()'s name does not correspond to its 
behavior
+* INCOMPLETE - US 54: remove_filename() is broken
+* INCOMPLETE - US 55: replace_extension()'s use of path as parameter is 
inappropriate
+* INCOMPLETE - US 56: Remove replace_extension()'s conditional addition of 
period
+* INCOMPLETE - US 57: On Windows, absolute paths will sort in among 
relative paths
+* INCOMPLETE - US 58: parent_path() behavior for root paths is useless
+* INCOMPLETE - US 59: filename() returning path for single path components 
is bizarre
+* INCOMPLETE - US 60: path("/foo/").filename()==path(".") is surprising
+* INCOMPLETE - US 61: Leading dots in filename() should not begin an 
extension
+* INCOMPLETE - US 62: It is important that stem()+extension()==filename()
+* INCOMPLETE - US 63: lexically_normal() inconsistently treats trailing 
"/" but not "/.." as directory
+* INCOMPLETE - US 73, CA 2: root-name is effectively implementation defined
+* INCOMPLETE - US 74, CA 3: The term “pathname” is ambiguous in some 
contexts
+* INCOMPLETE - US 75, CA 4: Extra flag in path constructors is needed
+* INCOMPLETE - US 76, CA 5: root-name definition is over-specified.
+* INCOMPLETE - US 77, CA 6: operator/ and other appends not useful if arg 
has root-name
+* INCOMPLETE - US 78, CA 7: Member absolute() in 27.10.4.1 is 
overspecified for non-POSIX-like O/S
+* INCOMPLETE - US 79, CA 8: Some operation functions are overspecified for 
implementation-defined file types
+* INCOMPLETE - US 185: Fold error_code and non-error_code signatures into 
one signature
+* INCOMPLETE - FI 14: directory_entry comparisons are members
+* INCOMPLETE - Late 36: permissions() error_code overload should be 
noexcept
+* INCOMPLETE - Late 37: permissions() actions should be separate parameter
+* INCOMPLETE - Late 42: resize_file() Postcondition missing argument
+
 Misc Tasks
 ==
 * Find all sequences of >2 underscores and eradicate them.


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


[PATCH] D30662: Update clang filtering for mxcsr

2017-03-06 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

In https://reviews.llvm.org/D30662#693559, @ahatanak wrote:

> Is it possible to add a test case (possibly in CodeGen)?


This is covered by CodeGen/ms-inline-asm.c, which Reid added after I broke this 
adding the mxcsr register a couple of weeks ago.


Repository:
  rL LLVM

https://reviews.llvm.org/D30662



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


[PATCH] D30650: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-06 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D30650#693165, @Eugene.Zelenko wrote:

> I think we should refactor this check as part of Static Analyzer, since it's 
> path-sensitive.


We can think about trying this as a SA checker, but it's irrelevant to this 
patch.


https://reviews.llvm.org/D30650



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


[PATCH] D30590: Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CGExprComplex.cpp:204-206
+Scope.ensureDominatingValue(&Vals.first);
+Scope.ensureDominatingValue(&Vals.second);
+Scope.ForceCleanup();

rsmith wrote:
> I'm a little concerned about the loose connection between 
> `ensureDominatingValue` and `ForrceCleanup` here -- if you forget the 
> `ForceCleanup`, you get silent misbehavior. How about removing 
> `ensureDominatingValue` and instead passing a 
> `std::initializer_list` to `ForceCleanup`?
Done.



Comment at: lib/CodeGen/CodeGenFunction.h:539
   private:
+SmallVector ValuesToReload;
 

rsmith wrote:
> If you keep a `SmallVector` here, set its inline size to 2 to avoid 
> allocations for the `_Complex` case.
I removed it. Also, who wants to waste a whole pointer of stack space for 
_Complex expression evaluation. ;)


https://reviews.llvm.org/D30590



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


[PATCH] D30590: Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 90743.
rnk added a comment.

- comments


https://reviews.llvm.org/D30590

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/stmtexpr.cpp

Index: test/CodeGenCXX/stmtexpr.cpp
===
--- test/CodeGenCXX/stmtexpr.cpp
+++ test/CodeGenCXX/stmtexpr.cpp
@@ -80,3 +80,85 @@
   y = ({ A a(1); if (b) goto G; a.i; });
   G: return y;
 }
+
+// When we emit a full expression with cleanups that contains branches out of
+// the full expression, the result of the inner expression (the call to
+// call_with_cleanups in this case) may not dominate the fallthrough destination
+// of the shared cleanup block.
+//
+// In this case the CFG will be a sequence of two diamonds, but the only
+// dynamically possible execution paths are both left hand branches and both
+// right hand branches. The first diamond LHS will call bar, and the second
+// diamond LHS will assign the result to v, but the call to bar does not
+// dominate the assignment.
+int bar(A, int);
+extern "C" int cleanup_exit_scalar(bool b) {
+  int v = bar(A(1), ({ if (b) return 42; 13; }));
+  return v;
+}
+
+// CHECK-LABEL: define i32 @cleanup_exit_scalar({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: %[[v:[^ ]*]] = call i32 @_Z3bar1Ai({{.*}})
+// CHECK-NEXT: store i32 %[[v]], i32* %[[tmp:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v:[^ ]*]] = load i32, i32* %[[tmp]]
+// CHECK-NEXT: store i32 %[[v]], i32* %v
+
+// No need to spill when the expression result is a constant, constants don't
+// have dominance problems.
+extern "C" int cleanup_exit_scalar_constant(bool b) {
+  int v = (A(1), (void)({ if (b) return 42; 0; }), 13);
+  return v;
+}
+
+// CHECK-LABEL: define i32 @cleanup_exit_scalar_constant({{.*}})
+// CHECK: store i32 13, i32* %v
+
+// Check for the same bug for lvalue expression evaluation kind.
+// FIXME: What about non-reference lvalues, like bitfield lvalues and vector
+// lvalues?
+int &getref();
+extern "C" int cleanup_exit_lvalue(bool cond) {
+  int &r = (A(1), ({ if (cond) return 0; (void)0; }), getref());
+  return r;
+}
+// CHECK-LABEL: define i32 @cleanup_exit_lvalue({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: %[[v:[^ ]*]] = call dereferenceable(4) i32* @_Z6getrefv({{.*}})
+// CHECK-NEXT: store i32* %[[v]], i32** %[[tmp:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v:[^ ]*]] = load i32*, i32** %[[tmp]]
+// CHECK-NEXT: store i32* %[[v]], i32** %r
+
+
+// We handle ExprWithCleanups for complex evaluation type separately, and it had
+// the same bug.
+_Complex float bar_complex(A, int);
+extern "C" int cleanup_exit_complex(bool b) {
+  _Complex float v = bar_complex(A(1), ({ if (b) return 42; 13; }));
+  return v;
+}
+
+// CHECK-LABEL: define i32 @cleanup_exit_complex({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: call {{.*}} @_Z11bar_complex1Ai({{.*}})
+// CHECK: store float %{{.*}}, float* %[[tmp1:[^, ]*]]
+// CHECK: store float %{{.*}}, float* %[[tmp2:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v1:[^ ]*]] = load float, float* %[[tmp1]]
+// CHECK: %[[v2:[^ ]*]] = load float, float* %[[tmp2]]
+// CHECK: store float %[[v1]], float* %v.realp
+// CHECK: store float %[[v2]], float* %v.imagp
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -580,14 +580,10 @@
   CGF.DidCallStackSave = false;
 }
 
-/// \brief Exit this cleanup scope, emitting any accumulated
-/// cleanups.
+/// \brief Exit this cleanup scope, emitting any accumulated cleanups.
 ~RunCleanupsScope() {
-  if (PerformCleanup) {
-CGF.DidCallStackSave = OldDidCallStackSave;
-CGF.PopCleanupBlocks(CleanupStackDepth,
- LifetimeExtendedCleanupStackSize);
-  }
+  if (PerformCleanup)
+ForceCleanup();
 }
 
 /// \brief Determine whether this scope requires any cleanups.
@@ -597,11 +593,15 @@
 
 /// \brief Force the emission of cleanups now, instead of waiting
 /// until this object is destroyed.
-void ForceCleanup() {
+/// \param ValuesToReload - A list of values that need to be available at
+/// the insertion point after cleanup emission. If cleanup emission created
+/// a shared cleanup block, these value pointers will be rewritten.
+/// Otherwise, they not will be modified.
+void ForceCleanup(std::initializer_list ValuesToReload = {}) {
   assert(PerformCleanup && "Already forced cleanup"

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-03-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hey, really sorry for the delay here.




Comment at: lib/Sema/SemaExpr.cpp:8007
+static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
+   QualType OtherIntTy) {
+  QualType IntTy = Int->get()->getType().getUnqualifiedType();

This doesn't look clang-formated. 



Comment at: lib/Sema/SemaExpr.cpp:8034
+NumBits > S.Context.getIntWidth(OtherIntTy))
+  return true;
+  } else {

Instead of the else here, you can:
   
  return (IntSigned != OtherIntSigned &&
  NumBits > S.Context.getIntWidth(OtherIntTy))
   }

   return (Order < 0);



Comment at: lib/Sema/SemaExpr.cpp:8092
+ExprResult *Vector) {
+  QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
+  QualType VectorTy = Vector->get()->getType().getUnqualifiedType();

Can you please add an assertion to the beginning of this function to guarantee 
that the vector is never a ext-vector type? I wanna make sure we don't 
accidentally use this in the future for ext-vectors. 



Comment at: test/Sema/vector-gcc-compat.c:61
+  //match.
+  v2i64_r = v2i64_a == 1; // expected-warning {{incompatible vector types 
assigning to 'v2i64' (vector of 2 'long long' values) from 'long 
__attribute__((ext_vector_type(2)))' (vector of 2 'long' values)}}
+  v2i64_r = v2i64_a != 1; // expected-warning {{incompatible vector types 
assigning to 'v2i64' (vector of 2 'long long' values) from 'long 
__attribute__((ext_vector_type(2)))' (vector of 2 'long' values)}}

Can you double check where 'long __attribute__((ext_vector_type(2)))' comes 
from?

We have regressed in the past year in the way ext-vector interacts with 
non-ext-vectors, and I don't wanna make it worse until we actually have time to 
fix that; there's a lot of code out there relying on bitcasts between 
ext-vectors and non-ext-vectors to bridge between intrinsics headers and 
ext-vector code.


https://reviews.llvm.org/D25866



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


[PATCH] D26057: [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.

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



Comment at: include/clang/Sema/ScopeInfo.h:138-140
+  /// \brief Whether this function has already built, or tried to build, the
+  /// the initial and final coroutine suspend points.
+  bool NeedsCoroutineSuspends : 1;

Is the comment here correct? It seems a slightly odd match for the member name.



Comment at: lib/Sema/SemaCoroutine.cpp:33
 /// function type.
 static QualType lookupPromiseType(Sema &S, const FunctionProtoType *FnType,
+  SourceLocation KwLoc,

rsmith wrote:
> EricWF wrote:
> > The changes to this function are all unrelated cleanup/improvements.
> Just go ahead and commit these separately then.
Please commit these changes separately if they're cleanups unrelated to the 
main purpose of the patch.



Comment at: lib/Sema/TreeTransform.h:6974-6975
+
+  // FIXME(EricWF): Remove this
+  assert(isa(LookupResult.get()) && "Expected lookup 
expr");
+

Remove this :) (This is already checked by the `cast` below.)


https://reviews.llvm.org/D26057



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


[PATCH] D30662: Update clang filtering for mxcsr

2017-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think we should really change this code to filter out clobber registers that 
do not name valid gcc inline asm clobbers. That's basically what we require 
later. I think if you change this condition to just check 
Target.isValidGCCRegisterName.


Repository:
  rL LLVM

https://reviews.llvm.org/D30662



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


r297084 - Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-06 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Mar  6 16:18:34 2017
New Revision: 297084

URL: http://llvm.org/viewvc/llvm-project?rev=297084&view=rev
Log:
Don't assume cleanup emission preserves dominance in expr evaluation

Summary:
Because of the existence branches out of GNU statement expressions, it
is possible that emitting cleanups for a full expression may cause the
new insertion point to not be dominated by the result of the inner
expression. Consider this example:

  struct Foo { Foo(); ~Foo(); int x; };
  int g(Foo, int);
  int f(bool cond) {
int n = g(Foo(), ({ if (cond) return 0; 42; }));
return n;
  }

Before this change, result of the call to 'g' did not dominate its use
in the store to 'n'. The early return exit from the statement expression
branches to a shared cleanup block, which ends in a switch between the
fallthrough destination (the assignment to 'n') or the function exit
block.

This change solves the problem by spilling and reloading expression
evaluation results when any of the active cleanups have branches.

I audited the other call sites of enterFullExpression, and they don't
appear to keep and Values live across the site of the cleanup, except in
ARC code. I wasn't able to create a test case for ARC that exhibits this
problem, though.

Reviewers: rjmccall, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenCXX/stmtexpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=297084&r1=297083&r2=297084&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Mon Mar  6 16:18:34 2017
@@ -418,11 +418,15 @@ void CodeGenFunction::ResolveBranchFixup
 }
 
 /// Pops cleanup blocks until the given savepoint is reached.
-void CodeGenFunction::PopCleanupBlocks(EHScopeStack::stable_iterator Old) {
+void CodeGenFunction::PopCleanupBlocks(
+EHScopeStack::stable_iterator Old,
+std::initializer_list ValuesToReload) {
   assert(Old.isValid());
 
+  bool HadBranches = false;
   while (EHStack.stable_begin() != Old) {
 EHCleanupScope &Scope = cast(*EHStack.begin());
+HadBranches |= Scope.hasBranches();
 
 // As long as Old strictly encloses the scope's enclosing normal
 // cleanup, we're going to emit another normal cleanup which
@@ -432,14 +436,41 @@ void CodeGenFunction::PopCleanupBlocks(E
 
 PopCleanupBlock(FallThroughIsBranchThrough);
   }
+
+  // If we didn't have any branches, the insertion point before cleanups must
+  // dominate the current insertion point and we don't need to reload any
+  // values.
+  if (!HadBranches)
+return;
+
+  // Spill and reload all values that the caller wants to be live at the 
current
+  // insertion point.
+  for (llvm::Value **ReloadedValue : ValuesToReload) {
+auto *Inst = dyn_cast_or_null(*ReloadedValue);
+if (!Inst)
+  continue;
+Address Tmp =
+CreateDefaultAlignTempAlloca(Inst->getType(), "tmp.exprcleanup");
+
+// Find an insertion point after Inst and spill it to the temporary.
+llvm::BasicBlock::iterator InsertBefore;
+if (auto *Invoke = dyn_cast(Inst))
+  InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
+else
+  InsertBefore = std::next(Inst->getIterator());
+CGBuilderTy(CGM, &*InsertBefore).CreateStore(Inst, Tmp);
+
+// Reload the value at the current insertion point.
+*ReloadedValue = Builder.CreateLoad(Tmp);
+  }
 }
 
 /// Pops cleanup blocks until the given savepoint is reached, then add the
 /// cleanups from the given savepoint in the lifetime-extended cleanups stack.
-void
-CodeGenFunction::PopCleanupBlocks(EHScopeStack::stable_iterator Old,
-  size_t OldLifetimeExtendedSize) {
-  PopCleanupBlocks(Old);
+void CodeGenFunction::PopCleanupBlocks(
+EHScopeStack::stable_iterator Old, size_t OldLifetimeExtendedSize,
+std::initializer_list ValuesToReload) {
+  PopCleanupBlocks(Old, ValuesToReload);
 
   // Move our deferred cleanups onto the EH stack.
   for (size_t I = OldLifetimeExtendedSize,

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=297084&r1=297083&r2=297084&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Mar  6 16:18:34 2017
@@ -1069,7 +1069,19 @@ LValue CodeGenFunction::EmitLValue(const
 const auto *cleanups = cast(E);
 enterFullExpression(cleanups);
 RunCleanupsScope Scope(*this);
-return EmitLValue(cleanups->getSubExpr(

[PATCH] D30590: Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-06 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297084: Don't assume cleanup emission preserves dominance in 
expr evaluation (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D30590?vs=90743&id=90747#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30590

Files:
  cfe/trunk/lib/CodeGen/CGCleanup.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprComplex.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGenCXX/stmtexpr.cpp

Index: cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
===
--- cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
+++ cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
@@ -80,3 +80,85 @@
   y = ({ A a(1); if (b) goto G; a.i; });
   G: return y;
 }
+
+// When we emit a full expression with cleanups that contains branches out of
+// the full expression, the result of the inner expression (the call to
+// call_with_cleanups in this case) may not dominate the fallthrough destination
+// of the shared cleanup block.
+//
+// In this case the CFG will be a sequence of two diamonds, but the only
+// dynamically possible execution paths are both left hand branches and both
+// right hand branches. The first diamond LHS will call bar, and the second
+// diamond LHS will assign the result to v, but the call to bar does not
+// dominate the assignment.
+int bar(A, int);
+extern "C" int cleanup_exit_scalar(bool b) {
+  int v = bar(A(1), ({ if (b) return 42; 13; }));
+  return v;
+}
+
+// CHECK-LABEL: define i32 @cleanup_exit_scalar({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: %[[v:[^ ]*]] = call i32 @_Z3bar1Ai({{.*}})
+// CHECK-NEXT: store i32 %[[v]], i32* %[[tmp:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v:[^ ]*]] = load i32, i32* %[[tmp]]
+// CHECK-NEXT: store i32 %[[v]], i32* %v
+
+// No need to spill when the expression result is a constant, constants don't
+// have dominance problems.
+extern "C" int cleanup_exit_scalar_constant(bool b) {
+  int v = (A(1), (void)({ if (b) return 42; 0; }), 13);
+  return v;
+}
+
+// CHECK-LABEL: define i32 @cleanup_exit_scalar_constant({{.*}})
+// CHECK: store i32 13, i32* %v
+
+// Check for the same bug for lvalue expression evaluation kind.
+// FIXME: What about non-reference lvalues, like bitfield lvalues and vector
+// lvalues?
+int &getref();
+extern "C" int cleanup_exit_lvalue(bool cond) {
+  int &r = (A(1), ({ if (cond) return 0; (void)0; }), getref());
+  return r;
+}
+// CHECK-LABEL: define i32 @cleanup_exit_lvalue({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: %[[v:[^ ]*]] = call dereferenceable(4) i32* @_Z6getrefv({{.*}})
+// CHECK-NEXT: store i32* %[[v]], i32** %[[tmp:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v:[^ ]*]] = load i32*, i32** %[[tmp]]
+// CHECK-NEXT: store i32* %[[v]], i32** %r
+
+
+// We handle ExprWithCleanups for complex evaluation type separately, and it had
+// the same bug.
+_Complex float bar_complex(A, int);
+extern "C" int cleanup_exit_complex(bool b) {
+  _Complex float v = bar_complex(A(1), ({ if (b) return 42; 13; }));
+  return v;
+}
+
+// CHECK-LABEL: define i32 @cleanup_exit_complex({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: call {{.*}} @_Z11bar_complex1Ai({{.*}})
+// CHECK: store float %{{.*}}, float* %[[tmp1:[^, ]*]]
+// CHECK: store float %{{.*}}, float* %[[tmp2:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v1:[^ ]*]] = load float, float* %[[tmp1]]
+// CHECK: %[[v2:[^ ]*]] = load float, float* %[[tmp2]]
+// CHECK: store float %[[v1]], float* %v.realp
+// CHECK: store float %[[v2]], float* %v.imagp
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -580,14 +580,10 @@
   CGF.DidCallStackSave = false;
 }
 
-/// \brief Exit this cleanup scope, emitting any accumulated
-/// cleanups.
+/// \brief Exit this cleanup scope, emitting any accumulated cleanups.
 ~RunCleanupsScope() {
-  if (PerformCleanup) {
-CGF.DidCallStackSave = OldDidCallStackSave;
-CGF.PopCleanupBlocks(CleanupStackDepth,
- LifetimeExtendedCleanupStackSize);
-  }
+  if (PerformCleanup)
+ForceCleanup();
 }
 
 /// \brief Determine whether this scope requires any cleanups.
@@ -597,11 +593,15 @@
 
 /// \brief Force the emission of cleanups now, instead of waiting
 /// until this object is destroyed.
-void ForceCleanup() {
+/// \param ValuesToReload - A list of values that need to b

[PATCH] D28218: Small optimizations for SourceManager::getFileID()

2017-03-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Daniel,

This seems pretty nice. Can you share how much performance improvements you got 
by this / how did you test it?


https://reviews.llvm.org/D28218



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


[PATCH] D28218: Small optimizations for SourceManager::getFileID()

2017-03-06 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: lib/Basic/SourceManager.cpp:843
 if (E.getOffset() <= SLocOffset) {
   FileID Res = FileID::get(-int(I) - 2);
 

not particularly important (and unrelated to your changes) - nit - s /C-style 
cast / static_cast / ?


https://reviews.llvm.org/D28218



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


r297089 - [coroutines] Improve diagnostics when building implicit constructs.

2017-03-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Mar  6 16:52:28 2017
New Revision: 297089

URL: http://llvm.org/viewvc/llvm-project?rev=297089&view=rev
Log:
[coroutines] Improve diagnostics when building implicit constructs.

Previously when a coroutine was building the implicit setup/destroy
constructs it would emit diagostics about failures on the first 
co_await/co_return/co_yield
it encountered. This was confusing because that construct may not itself be 
ill-formed.

This patch moves the diagnostics to the function start instead.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=297089&r1=297088&r2=297089&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Mar  6 16:52:28 
2017
@@ -8837,6 +8837,8 @@ def err_implied_std_coroutine_traits_pro
   "this function cannot be a coroutine: %q0 has no member named 
'promise_type'">;
 def err_implied_std_coroutine_traits_promise_type_not_class : Error<
   "this function cannot be a coroutine: %0 is not a class">;
+def err_coroutine_promise_type_incomplete : Error<
+  "this function cannot be a coroutine: %0 is an incomplete type">;
 def err_coroutine_traits_missing_specialization : Error<
   "this function cannot be a coroutine: missing definition of "
   "specialization %q0">;

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=297089&r1=297088&r2=297089&view=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Mon Mar  6 16:52:28 2017
@@ -24,18 +24,19 @@ using namespace sema;
 /// Look up the std::coroutine_traits<...>::promise_type for the given
 /// function type.
 static QualType lookupPromiseType(Sema &S, const FunctionProtoType *FnType,
-  SourceLocation Loc) {
+  SourceLocation KwLoc,
+  SourceLocation FuncLoc) {
   // FIXME: Cache std::coroutine_traits once we've found it.
   NamespaceDecl *StdExp = S.lookupStdExperimentalNamespace();
   if (!StdExp) {
-S.Diag(Loc, diag::err_implied_std_coroutine_traits_not_found);
+S.Diag(KwLoc, diag::err_implied_std_coroutine_traits_not_found);
 return QualType();
   }
 
   LookupResult Result(S, &S.PP.getIdentifierTable().get("coroutine_traits"),
-  Loc, Sema::LookupOrdinaryName);
+  FuncLoc, Sema::LookupOrdinaryName);
   if (!S.LookupQualifiedName(Result, StdExp)) {
-S.Diag(Loc, diag::err_implied_std_coroutine_traits_not_found);
+S.Diag(KwLoc, diag::err_implied_std_coroutine_traits_not_found);
 return QualType();
   }
 
@@ -49,52 +50,58 @@ static QualType lookupPromiseType(Sema &
   }
 
   // Form template argument list for coroutine_traits.
-  TemplateArgumentListInfo Args(Loc, Loc);
+  TemplateArgumentListInfo Args(KwLoc, KwLoc);
   Args.addArgument(TemplateArgumentLoc(
   TemplateArgument(FnType->getReturnType()),
-  S.Context.getTrivialTypeSourceInfo(FnType->getReturnType(), Loc)));
+  S.Context.getTrivialTypeSourceInfo(FnType->getReturnType(), KwLoc)));
   // FIXME: If the function is a non-static member function, add the type
   // of the implicit object parameter before the formal parameters.
   for (QualType T : FnType->getParamTypes())
 Args.addArgument(TemplateArgumentLoc(
-TemplateArgument(T), S.Context.getTrivialTypeSourceInfo(T, Loc)));
+TemplateArgument(T), S.Context.getTrivialTypeSourceInfo(T, KwLoc)));
 
   // Build the template-id.
   QualType CoroTrait =
-  S.CheckTemplateIdType(TemplateName(CoroTraits), Loc, Args);
+  S.CheckTemplateIdType(TemplateName(CoroTraits), KwLoc, Args);
   if (CoroTrait.isNull())
 return QualType();
-  if (S.RequireCompleteType(Loc, CoroTrait,
+  if (S.RequireCompleteType(KwLoc, CoroTrait,
 diag::err_coroutine_traits_missing_specialization))
 return QualType();
 
-  CXXRecordDecl *RD = CoroTrait->getAsCXXRecordDecl();
+  auto *RD = CoroTrait->getAsCXXRecordDecl();
   assert(RD && "specialization of class template is not a class?");
 
   // Look up the ::promise_type member.
-  LookupResult R(S, &S.PP.getIdentifierTable().get("promise_type"), Loc,
+  LookupResult R(S, &S.PP.getIdentifierTable().get("promise_type"), KwLoc,
  Sema::LookupOrdinaryName);
   S.LookupQualifiedName(R, RD);
   auto *Promise = R.getAsSingle();
   if (!Promise) {
-S.Diag(Loc, diag::err_implied_std_coroutine_traits_promise_type_not_found)
+S.Diag(F

Re: r297084 - Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-06 Thread Richard Smith via cfe-commits
On 6 March 2017 at 14:18, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Mon Mar  6 16:18:34 2017
> New Revision: 297084
>
> URL: http://llvm.org/viewvc/llvm-project?rev=297084&view=rev
> Log:
> Don't assume cleanup emission preserves dominance in expr evaluation
>
> Summary:
> Because of the existence branches out of GNU statement expressions, it
> is possible that emitting cleanups for a full expression may cause the
> new insertion point to not be dominated by the result of the inner
> expression. Consider this example:
>
>   struct Foo { Foo(); ~Foo(); int x; };
>   int g(Foo, int);
>   int f(bool cond) {
> int n = g(Foo(), ({ if (cond) return 0; 42; }));
> return n;
>   }
>
> Before this change, result of the call to 'g' did not dominate its use
> in the store to 'n'. The early return exit from the statement expression
> branches to a shared cleanup block, which ends in a switch between the
> fallthrough destination (the assignment to 'n') or the function exit
> block.
>
> This change solves the problem by spilling and reloading expression
> evaluation results when any of the active cleanups have branches.
>
> I audited the other call sites of enterFullExpression, and they don't
> appear to keep and Values live across the site of the cleanup, except in
> ARC code. I wasn't able to create a test case for ARC that exhibits this
> problem, though.
>
> Reviewers: rjmccall, rsmith
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D30590
>
> Modified:
> cfe/trunk/lib/CodeGen/CGCleanup.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprComplex.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGCleanup.cpp?rev=297084&r1=297083&r2=297084&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Mon Mar  6 16:18:34 2017
> @@ -418,11 +418,15 @@ void CodeGenFunction::ResolveBranchFixup
>  }
>
>  /// Pops cleanup blocks until the given savepoint is reached.
> -void CodeGenFunction::PopCleanupBlocks(EHScopeStack::stable_iterator
> Old) {
> +void CodeGenFunction::PopCleanupBlocks(
> +EHScopeStack::stable_iterator Old,
> +std::initializer_list ValuesToReload) {
>assert(Old.isValid());
>
> +  bool HadBranches = false;
>while (EHStack.stable_begin() != Old) {
>  EHCleanupScope &Scope = cast(*EHStack.begin());
> +HadBranches |= Scope.hasBranches();
>
>  // As long as Old strictly encloses the scope's enclosing normal
>  // cleanup, we're going to emit another normal cleanup which
> @@ -432,14 +436,41 @@ void CodeGenFunction::PopCleanupBlocks(E
>
>  PopCleanupBlock(FallThroughIsBranchThrough);
>}
> +
> +  // If we didn't have any branches, the insertion point before cleanups
> must
> +  // dominate the current insertion point and we don't need to reload any
> +  // values.
> +  if (!HadBranches)
> +return;
> +
> +  // Spill and reload all values that the caller wants to be live at the
> current
> +  // insertion point.
> +  for (llvm::Value **ReloadedValue : ValuesToReload) {
> +auto *Inst = dyn_cast_or_null(*ReloadedValue);
> +if (!Inst)
> +  continue;
> +Address Tmp =
> +CreateDefaultAlignTempAlloca(Inst->getType(), "tmp.exprcleanup");
> +
> +// Find an insertion point after Inst and spill it to the temporary.
> +llvm::BasicBlock::iterator InsertBefore;
> +if (auto *Invoke = dyn_cast(Inst))
> +  InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
> +else
> +  InsertBefore = std::next(Inst->getIterator());
> +CGBuilderTy(CGM, &*InsertBefore).CreateStore(Inst, Tmp);
> +
> +// Reload the value at the current insertion point.
> +*ReloadedValue = Builder.CreateLoad(Tmp);
> +  }
>  }
>
>  /// Pops cleanup blocks until the given savepoint is reached, then add the
>  /// cleanups from the given savepoint in the lifetime-extended cleanups
> stack.
> -void
> -CodeGenFunction::PopCleanupBlocks(EHScopeStack::stable_iterator Old,
> -  size_t OldLifetimeExtendedSize) {
> -  PopCleanupBlocks(Old);
> +void CodeGenFunction::PopCleanupBlocks(
> +EHScopeStack::stable_iterator Old, size_t OldLifetimeExtendedSize,
> +std::initializer_list ValuesToReload) {
> +  PopCleanupBlocks(Old, ValuesToReload);
>
>// Move our deferred cleanups onto the EH stack.
>for (size_t I = OldLifetimeExtendedSize,
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=297084&r1=297083&r2=297084&view=diff
> 
> =

[PATCH] D29117: SPARC: allow usage of floating-point registers in inline ASM

2017-03-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi,

Thanks for working on this. Few questions:

- What happens with the validation if +soft-float is used?
- What about the 'e' mode, can you double check if the sparc backend support 
these instructions? If so it might be interesting to add it here.

Also, please attach patches with full context, it's easier to review.


https://reviews.llvm.org/D29117



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


  1   2   >