Re: r302572 - Suppress all uses of LLVM_END_WITH_NULL. NFC.

2017-05-10 Thread Mikael Holmén via cfe-commits

Hi,

This commit gives a warning with clang 3.6:

In file included from 
../tools/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:17:
../tools/clang/lib/StaticAnalyzer/Checkers/SelectorExtras.h:23:40: 
error: braces around scalar initializer [-Werror]

  SmallVector II{{&Ctx.Idents.get(IIs)...}};
   ^
../tools/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:236:11: 
note: in instantiation of function template specialization 
'clang::ento::getKeywordSelector' requested here

  getKeywordSelector(Ctx, "caseInsensitiveCompare"),
  ^
1 error generated.

With 3.9 and 4.0 I don't see the warning. Is this a bug in 3.6 or what?

Are we supposed to not use an old clang as 3.6 to compile?

Regards,
Mikael


On 05/09/2017 09:31 PM, Serge Guelton via cfe-commits wrote:

Author: serge_sans_paille
Date: Tue May  9 14:31:30 2017
New Revision: 302572

URL: http://llvm.org/viewvc/llvm-project?rev=302572&view=rev
Log:
Suppress all uses of LLVM_END_WITH_NULL. NFC.

Use variadic templates instead of relying on  + sentinel.

This enforces better type checking and makes code more readable.

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=302572&r1=302571&r2=302572&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May  9 14:31:30 2017
@@ -961,9 +961,8 @@ llvm::Type *CodeGenModule::getBlockDescr
   //   const char *signature;   // the block signature
   //   const char *layout;  // reserved
   // };
-  BlockDescriptorType =
-llvm::StructType::create("struct.__block_descriptor",
- UnsignedLongTy, UnsignedLongTy, nullptr);
+  BlockDescriptorType = llvm::StructType::create(
+  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);

   // Now form a pointer to that.
   unsigned AddrSpace = 0;
@@ -987,9 +986,8 @@ llvm::Type *CodeGenModule::getGenericBlo
   //   struct __block_descriptor *__descriptor;
   // };
   GenericBlockLiteralType =
-llvm::StructType::create("struct.__block_literal_generic",
- VoidPtrTy, IntTy, IntTy, VoidPtrTy,
- BlockDescPtrTy, nullptr);
+  llvm::StructType::create("struct.__block_literal_generic", VoidPtrTy,
+   IntTy, IntTy, VoidPtrTy, BlockDescPtrTy);

   return GenericBlockLiteralType;
 }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302572&r1=302571&r2=302572&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May  9 14:31:30 2017
@@ -4571,7 +4571,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);

 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@ Value *CodeGenFunction::EmitAArch64Built
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);

 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
@@ -7373,8 +7373,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 // unsigned i

Re: r302572 - Suppress all uses of LLVM_END_WITH_NULL. NFC.

2017-05-10 Thread Mikael Holmén via cfe-commits



On 05/10/2017 09:37 AM, Mikael Holmén via cfe-commits wrote:

Hi,

This commit gives a warning with clang 3.6:

In file included from
../tools/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:17:

../tools/clang/lib/StaticAnalyzer/Checkers/SelectorExtras.h:23:40:
error: braces around scalar initializer [-Werror]
  SmallVector II{{&Ctx.Idents.get(IIs)...}};
   ^
../tools/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:236:11:
note: in instantiation of function template specialization
'clang::ento::getKeywordSelector' requested here
  getKeywordSelector(Ctx, "caseInsensitiveCompare"),
  ^
1 error generated.

With 3.9 and 4.0 I don't see the warning. Is this a bug in 3.6 or what?

Are we supposed to not use an old clang as 3.6 to compile?



http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library

The above link says clang 3.1 should work.

Could you make the code compile without warnings also for 3.6?

Regards,
Mikael


Regards,
Mikael


On 05/09/2017 09:31 PM, Serge Guelton via cfe-commits wrote:

Author: serge_sans_paille
Date: Tue May  9 14:31:30 2017
New Revision: 302572

URL: http://llvm.org/viewvc/llvm-project?rev=302572&view=rev
Log:
Suppress all uses of LLVM_END_WITH_NULL. NFC.

Use variadic templates instead of relying on  + sentinel.

This enforces better type checking and makes code more readable.

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=302572&r1=302571&r2=302572&view=diff

==

--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May  9 14:31:30 2017
@@ -961,9 +961,8 @@ llvm::Type *CodeGenModule::getBlockDescr
   //   const char *signature;   // the block signature
   //   const char *layout;  // reserved
   // };
-  BlockDescriptorType =
-llvm::StructType::create("struct.__block_descriptor",
- UnsignedLongTy, UnsignedLongTy, nullptr);
+  BlockDescriptorType = llvm::StructType::create(
+  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);

   // Now form a pointer to that.
   unsigned AddrSpace = 0;
@@ -987,9 +986,8 @@ llvm::Type *CodeGenModule::getGenericBlo
   //   struct __block_descriptor *__descriptor;
   // };
   GenericBlockLiteralType =
-llvm::StructType::create("struct.__block_literal_generic",
- VoidPtrTy, IntTy, IntTy, VoidPtrTy,
- BlockDescPtrTy, nullptr);
+  llvm::StructType::create("struct.__block_literal_generic",
VoidPtrTy,
+   IntTy, IntTy, VoidPtrTy, BlockDescPtrTy);

   return GenericBlockLiteralType;
 }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302572&r1=302571&r2=302572&view=diff

==

--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May  9 14:31:30 2017
@@ -4571,7 +4571,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 Function *F = CGM.getIntrinsic(BuiltinID ==
ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);

 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@ Value *CodeGenFunction::EmitAArch64Built
 Function *F = CGM.getIntrinsic(BuiltinID ==
AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nul

[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-05-10 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302624: Add ASTMatchRefactorer and ReplaceNodeWithTemplate 
to RefactoringCallbacks (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D29621?vs=98203&id=98412#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29621

Files:
  cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h
  cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp
  cfe/trunk/unittests/Tooling/RefactoringCallbacksTest.cpp

Index: cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h
===
--- cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h
+++ cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h
@@ -47,6 +47,32 @@
   Replacements Replace;
 };
 
+/// \brief Adaptor between \c ast_matchers::MatchFinder and \c
+/// tooling::RefactoringTool.
+///
+/// Runs AST matchers and stores the \c tooling::Replacements in a map.
+class ASTMatchRefactorer {
+public:
+  ASTMatchRefactorer(std::map &FileToReplaces);
+
+  template 
+  void addMatcher(const T &Matcher, RefactoringCallback *Callback) {
+MatchFinder.addMatcher(Matcher, Callback);
+Callbacks.push_back(Callback);
+  }
+
+  void addDynamicMatcher(const ast_matchers::internal::DynTypedMatcher &Matcher,
+ RefactoringCallback *Callback);
+
+  std::unique_ptr newASTConsumer();
+
+private:
+  friend class RefactoringASTConsumer;
+  std::vector Callbacks;
+  ast_matchers::MatchFinder MatchFinder;
+  std::map &FileToReplaces;
+};
+
 /// \brief Replace the text of the statement bound to \c FromId with the text in
 /// \c ToText.
 class ReplaceStmtWithText : public RefactoringCallback {
@@ -59,6 +85,29 @@
   std::string ToText;
 };
 
+/// \brief Replace the text of an AST node bound to \c FromId with the result of
+/// evaluating the template in \c ToTemplate.
+///
+/// Expressions of the form ${NodeName} in \c ToTemplate will be
+/// replaced by the text of the node bound to ${NodeName}. The string
+/// "$$" will be replaced by "$".
+class ReplaceNodeWithTemplate : public RefactoringCallback {
+public:
+  static llvm::Expected>
+  create(StringRef FromId, StringRef ToTemplate);
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  struct TemplateElement {
+enum { Literal, Identifier } Type;
+std::string Value;
+  };
+  ReplaceNodeWithTemplate(llvm::StringRef FromId,
+  std::vector &&Template);
+  std::string FromId;
+  std::vector Template;
+};
+
 /// \brief Replace the text of the statement bound to \c FromId with the text of
 /// the statement bound to \c ToId.
 class ReplaceStmtWithStmt : public RefactoringCallback {
Index: cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp
===
--- cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp
+++ cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp
@@ -9,8 +9,13 @@
 //
 //
 //===--===//
-#include "clang/Lex/Lexer.h"
 #include "clang/Tooling/RefactoringCallbacks.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+
+using llvm::StringError;
+using llvm::make_error;
 
 namespace clang {
 namespace tooling {
@@ -20,18 +25,62 @@
   return Replace;
 }
 
-static Replacement replaceStmtWithText(SourceManager &Sources,
-   const Stmt &From,
+ASTMatchRefactorer::ASTMatchRefactorer(
+std::map &FileToReplaces)
+: FileToReplaces(FileToReplaces) {}
+
+void ASTMatchRefactorer::addDynamicMatcher(
+const ast_matchers::internal::DynTypedMatcher &Matcher,
+RefactoringCallback *Callback) {
+  MatchFinder.addDynamicMatcher(Matcher, Callback);
+  Callbacks.push_back(Callback);
+}
+
+class RefactoringASTConsumer : public ASTConsumer {
+public:
+  RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
+  : Refactoring(Refactoring) {}
+
+  void HandleTranslationUnit(ASTContext &Context) override {
+// The ASTMatchRefactorer is re-used between translation units.
+// Clear the matchers so that each Replacement is only emitted once.
+for (const auto &Callback : Refactoring.Callbacks) {
+  Callback->getReplacements().clear();
+}
+Refactoring.MatchFinder.matchAST(Context);
+for (const auto &Callback : Refactoring.Callbacks) {
+  for (const auto &Replacement : Callback->getReplacements()) {
+llvm::Error Err =
+Refactoring.FileToReplaces[Replacement.getFilePath()].add(
+Replacement);
+if (Err) {
+  llvm::errs() << "Skipping replacement " << Replacement.toString()
+   << " due to this error:\n"
+   << toString(std::move(Err)) << "\n";
+}
+  }
+}
+  }
+
+private:
+  ASTMatchRefactorer &Refactoring;
+};
+
+std::unique_ptr ASTMatchRefa

r302624 - Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-05-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 10 02:48:45 2017
New Revision: 302624

URL: http://llvm.org/viewvc/llvm-project?rev=302624&view=rev
Log:
Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

Summary: This is the first change as part of developing a clang-query based 
search and replace tool.

Reviewers: klimek, bkramer, ioeric, sbenza, jbangert

Reviewed By: ioeric, jbangert

Subscribers: sbenza, ioeric, cfe-commits

Patch by Julian Bangert!

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

Modified:
cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h
cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp
cfe/trunk/unittests/Tooling/RefactoringCallbacksTest.cpp

Modified: cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h?rev=302624&r1=302623&r2=302624&view=diff
==
--- cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h (original)
+++ cfe/trunk/include/clang/Tooling/RefactoringCallbacks.h Wed May 10 02:48:45 
2017
@@ -47,6 +47,32 @@ protected:
   Replacements Replace;
 };
 
+/// \brief Adaptor between \c ast_matchers::MatchFinder and \c
+/// tooling::RefactoringTool.
+///
+/// Runs AST matchers and stores the \c tooling::Replacements in a map.
+class ASTMatchRefactorer {
+public:
+  ASTMatchRefactorer(std::map &FileToReplaces);
+
+  template 
+  void addMatcher(const T &Matcher, RefactoringCallback *Callback) {
+MatchFinder.addMatcher(Matcher, Callback);
+Callbacks.push_back(Callback);
+  }
+
+  void addDynamicMatcher(const ast_matchers::internal::DynTypedMatcher 
&Matcher,
+ RefactoringCallback *Callback);
+
+  std::unique_ptr newASTConsumer();
+
+private:
+  friend class RefactoringASTConsumer;
+  std::vector Callbacks;
+  ast_matchers::MatchFinder MatchFinder;
+  std::map &FileToReplaces;
+};
+
 /// \brief Replace the text of the statement bound to \c FromId with the text 
in
 /// \c ToText.
 class ReplaceStmtWithText : public RefactoringCallback {
@@ -59,6 +85,29 @@ private:
   std::string ToText;
 };
 
+/// \brief Replace the text of an AST node bound to \c FromId with the result 
of
+/// evaluating the template in \c ToTemplate.
+///
+/// Expressions of the form ${NodeName} in \c ToTemplate will be
+/// replaced by the text of the node bound to ${NodeName}. The string
+/// "$$" will be replaced by "$".
+class ReplaceNodeWithTemplate : public RefactoringCallback {
+public:
+  static llvm::Expected>
+  create(StringRef FromId, StringRef ToTemplate);
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  struct TemplateElement {
+enum { Literal, Identifier } Type;
+std::string Value;
+  };
+  ReplaceNodeWithTemplate(llvm::StringRef FromId,
+  std::vector &&Template);
+  std::string FromId;
+  std::vector Template;
+};
+
 /// \brief Replace the text of the statement bound to \c FromId with the text 
of
 /// the statement bound to \c ToId.
 class ReplaceStmtWithStmt : public RefactoringCallback {

Modified: cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp?rev=302624&r1=302623&r2=302624&view=diff
==
--- cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp (original)
+++ cfe/trunk/lib/Tooling/RefactoringCallbacks.cpp Wed May 10 02:48:45 2017
@@ -9,8 +9,13 @@
 //
 //
 
//===--===//
-#include "clang/Lex/Lexer.h"
 #include "clang/Tooling/RefactoringCallbacks.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+
+using llvm::StringError;
+using llvm::make_error;
 
 namespace clang {
 namespace tooling {
@@ -20,18 +25,62 @@ tooling::Replacements &RefactoringCallba
   return Replace;
 }
 
-static Replacement replaceStmtWithText(SourceManager &Sources,
-   const Stmt &From,
+ASTMatchRefactorer::ASTMatchRefactorer(
+std::map &FileToReplaces)
+: FileToReplaces(FileToReplaces) {}
+
+void ASTMatchRefactorer::addDynamicMatcher(
+const ast_matchers::internal::DynTypedMatcher &Matcher,
+RefactoringCallback *Callback) {
+  MatchFinder.addDynamicMatcher(Matcher, Callback);
+  Callbacks.push_back(Callback);
+}
+
+class RefactoringASTConsumer : public ASTConsumer {
+public:
+  RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
+  : Refactoring(Refactoring) {}
+
+  void HandleTranslationUnit(ASTContext &Context) override {
+// The ASTMatchRefactorer is re-used between translation units.
+// Clear the matchers so that each Replacement is only emitted once.
+for (const auto &Callback : Refactoring.Callbacks) {
+  Callback->getReplacements().clear();
+}

[libcxx] r302627 - Attempt to speculatively unbreak Apple build bots

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 03:04:50 2017
New Revision: 302627

URL: http://llvm.org/viewvc/llvm-project?rev=302627&view=rev
Log:
Attempt to speculatively unbreak Apple build bots

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302627&r1=302626&r2=302627&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Wed May 10 03:04:50 2017
@@ -1006,18 +1006,8 @@ class Configuration(object):
 sub.append(('%link', link_str))
 sub.append(('%build', build_str))
 # Configure exec prefix substitutions.
-exec_env_str = ''
-if not self.is_windows and len(self.exec_env) != 0:
-exec_env_str = 'env '
-for k, v in self.exec_env.items():
-exec_env_str += ' %s=%s' % (k, v)
 # Configure run env substitution.
-exec_str = exec_env_str
-if self.lit_config.useValgrind:
-exec_str = ' '.join(self.lit_config.valgrindArgs) + exec_env_str
-sub.append(('%exec', exec_str))
-# Configure run shortcut
-sub.append(('%run', exec_str + ' %t.exe'))
+sub.append(('%run', '%t.exe'))
 # Configure not program substitutions
 not_py = os.path.join(self.libcxx_src_root, 'utils', 'not.py')
 not_str = '%s %s ' % (pipes.quote(sys.executable), pipes.quote(not_py))


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


[libcxxabi] r302629 - Fix use of removed SH test replacement %exec

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 03:15:40 2017
New Revision: 302629

URL: http://llvm.org/viewvc/llvm-project?rev=302629&view=rev
Log:
Fix use of removed SH test replacement %exec

Modified:
libcxxabi/trunk/test/incomplete_type.sh.cpp

Modified: libcxxabi/trunk/test/incomplete_type.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/incomplete_type.sh.cpp?rev=302629&r1=302628&r2=302629&view=diff
==
--- libcxxabi/trunk/test/incomplete_type.sh.cpp (original)
+++ libcxxabi/trunk/test/incomplete_type.sh.cpp Wed May 10 03:15:40 2017
@@ -19,7 +19,7 @@
 // RUN: %cxx %flags %compile_flags -c %s -o %t.one.o
 // RUN: %cxx %flags %compile_flags -c %s -o %t.two.o -DTU_ONE
 // RUN: %cxx %flags %t.one.o %t.two.o %link_flags -o %t.exe
-// RUN: %exec %t.exe
+// RUN: %t.exe
 
 #include 
 #include 


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


[PATCH] D32898: [OpenCL] Handle OpenCL specific subelement types

2017-05-10 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 98416.

https://reviews.llvm.org/D32898

Files:
  lib/Sema/SemaInit.cpp
  test/SemaOpenCL/array-init.cl


Index: test/SemaOpenCL/array-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/array-init.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+__kernel void k1(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};
+}
+
+__kernel void k2(read_only pipe int p) {
+  reserve_id_t i1 = reserve_read_pipe(p, 1);
+  reserve_id_t i2 = reserve_read_pipe(p, 1);
+  reserve_id_t i[] = {i1, i2};
+}
+
+event_t create_event();
+__kernel void k3() {
+  event_t e1 = create_event();
+  event_t e2 = create_event();
+  event_t e[] = {e1, e2};
+}
+
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1209,7 +1209,7 @@
 
   } else {
 assert((ElemType->isRecordType() || ElemType->isVectorType() ||
-ElemType->isClkEventT()) && "Unexpected type");
+ElemType->isOpenCLSpecificType()) && "Unexpected type");
 
 // C99 6.7.8p13:
 //


Index: test/SemaOpenCL/array-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/array-init.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+__kernel void k1(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};
+}
+
+__kernel void k2(read_only pipe int p) {
+  reserve_id_t i1 = reserve_read_pipe(p, 1);
+  reserve_id_t i2 = reserve_read_pipe(p, 1);
+  reserve_id_t i[] = {i1, i2};
+}
+
+event_t create_event();
+__kernel void k3() {
+  event_t e1 = create_event();
+  event_t e2 = create_event();
+  event_t e[] = {e1, e2};
+}
+
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1209,7 +1209,7 @@
 
   } else {
 assert((ElemType->isRecordType() || ElemType->isVectorType() ||
-ElemType->isClkEventT()) && "Unexpected type");
+ElemType->isOpenCLSpecificType()) && "Unexpected type");
 
 // C99 6.7.8p13:
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-05-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D30748#750626, @idlecode wrote:

> Oh, sorry about this - I forgot. I will send patch during this weekend


No worries, I just stumbled upon the bug and recalled that there had been a 
patch to fix it.


https://reviews.llvm.org/D30748



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


[PATCH] D33033: [libc++] Fix PR32979 - types with a private std::enable_shared_from_this base break shared_ptr

2017-05-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch fixes bugs.llvm.org/PR32979.

[util.smartptr.shared.const] says:

> In the constructor definitions below, enables shared_from_this with p, for a 
> pointer p of type Y*, means
>  that if Y has an unambiguous and accessible base class that is a 
> specialization of enable_shared_from_-
>  this.

This means that libc++ needs to respect the access specifier of the base class, 
and not attempt to construct
and enabled_shared_from_this base if it is private. However access specifiers 
don't affect overload resolution
so our current implementation will attempt to construct the private base.

This patch uses SFINAE to correctly detect if the shared_ptr input has an 
accessible enable_shared_from_this
base class.


https://reviews.llvm.org/D33033

Files:
  include/memory
  
test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp


Index: 
test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
===
--- 
test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
+++ 
test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
@@ -49,6 +49,11 @@
 };
 
 
+struct PrivateBase : private std::enable_shared_from_this {
+std::weak_ptr get_weak() { return weak_from_this(); }
+};
+
+
 int main()
 {
 {  // https://bugs.llvm.org/show_bug.cgi?id=18843
@@ -74,6 +79,12 @@
 assert(p == q);
 assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share 
ownership
 }
+  {
+typedef std::shared_ptr APtr;
+typedef std::weak_ptr WeakAPtr;
+APtr a1 = std::make_shared();
+assert(a1.use_count() == 1);
+  }
 // Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
 // http://cplusplus.github.io/LWG/lwg-active.html#2529.
 // Test two different ways:
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -3924,7 +3924,10 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if*
+>::value,
+void>::type
 __enable_weak_this(const enable_shared_from_this<_Yp>* __e,
_OrigPtr* __ptr) _NOEXCEPT
 {
@@ -3943,6 +3946,7 @@
 template  friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
 };
 
+
 template
 inline
 _LIBCPP_CONSTEXPR


Index: test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
@@ -49,6 +49,11 @@
 };
 
 
+struct PrivateBase : private std::enable_shared_from_this {
+std::weak_ptr get_weak() { return weak_from_this(); }
+};
+
+
 int main()
 {
 {  // https://bugs.llvm.org/show_bug.cgi?id=18843
@@ -74,6 +79,12 @@
 assert(p == q);
 assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
 }
+  {
+typedef std::shared_ptr APtr;
+typedef std::weak_ptr WeakAPtr;
+APtr a1 = std::make_shared();
+assert(a1.use_count() == 1);
+  }
 // Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
 // http://cplusplus.github.io/LWG/lwg-active.html#2529.
 // Test two different ways:
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -3924,7 +3924,10 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if*
+>::value,
+void>::type
 __enable_weak_this(const enable_shared_from_this<_Yp>* __e,
_OrigPtr* __ptr) _NOEXCEPT
 {
@@ -3943,6 +3946,7 @@
 template  friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
 };
 
+
 template
 inline
 _LIBCPP_CONSTEXPR
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31383: [inline asm] "=i" output constraint support - gcc compatiblity

2017-05-10 Thread Ziv Izhar via Phabricator via cfe-commits
zizhar added a comment.

Ping


https://reviews.llvm.org/D31383



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


[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This is fantastic, thanks! I really like the shape of how it turned out to work.

Minor stuff and we're landing :)




Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:651
+ProgramStateRef ProgramState::addTaint(SVal V,
+   TaintTagType Kind) const {
+  SymbolRef Sym = V.getAsSymbol();

Whitespace seems a bit off.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:656-659
+  // If the SVal is a LazyCompoundVal it might only cover sub-region of a given
+  // symbol. For example, the LCV might represent a field in an uninitialized
+  // struct. In this case, the LCV encapsulates a conjured symbol and reference
+  // to the sub-region representing the struct field.

I still feel bad about producing API with very tricky pre-conditions. The LCV 
may have various forms - some may have empty store with no symbols at all, and 
others may be full of direct bindings that make the symbol essentially 
irrelevant. However, because the taint API is designed to be defensive to cases 
when taint cannot be added, and it sounds like a good thing, i guess we've 
taken the right approach here :)

I suggest commenting this more thoroughly though, something like:

> If the SVal represents a structure, try to mass-taint all values within the 
> structure. For now it only works efficiently on lazy compound values that 
> were conjured during a conservative evaluation of a function - either as 
> return values of functions that return structures or arrays by value, or as 
> values of structures or arrays passed into the function by reference, 
> directly or through pointer aliasing. Such lazy compound values are 
> characterized by having exactly one binding in their captured store within 
> their parent region, which is a conjured symbol default-bound to the base 
> region of the parent region.

Then inside `if (Sym)`:

> If the parent region is a base region, we add taint to the whole conjured 
> symbol.

> Otherwise, when the value represents a record-typed field within the conjured 
> structure, so we add partial taint for that symbol to that field.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:701-703
+  // Ignore partial taint if the entire parent symbol is already tainted.
+  if (contains(ParentSym))
+return this;

Speaking of taint tags: right now we didn't add support for multiple taint tags 
per symbol (because we have only one taint tag to choose from), but `addTaint` 
overwrites the tag. I guess we should do the same for now.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:715
+  TaintedSubRegions = TaintedSubRegions.add(SubRegion, Kind);
+  return set(ParentSym, TaintedSubRegions);
+}

Can we assert that the returned state is not empty, like in `addTaint`?


https://reviews.llvm.org/D30909



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


[PATCH] D32972: [index] Index simple dependent declaration references

2017-05-10 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked 2 inline comments as done.
Closed by commit rL302632: [index] Index simple dependent declaration 
references (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D32972?vs=98184&id=98421#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32972

Files:
  cfe/trunk/include/clang/AST/CXXInheritance.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/CXXInheritance.cpp
  cfe/trunk/lib/Index/IndexBody.cpp
  cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
  cfe/trunk/test/Index/Core/index-dependent-source.cpp

Index: cfe/trunk/include/clang/AST/CXXInheritance.h
===
--- cfe/trunk/include/clang/AST/CXXInheritance.h
+++ cfe/trunk/include/clang/AST/CXXInheritance.h
@@ -161,7 +161,8 @@
   void ComputeDeclsFound();
 
   bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record,
- CXXRecordDecl::BaseMatchesCallback BaseMatches);
+ CXXRecordDecl::BaseMatchesCallback BaseMatches,
+ bool LookupInDependent = false);
 
 public:
   typedef std::list::iterator paths_iterator;
Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -1563,10 +1563,13 @@
   /// \param Paths used to record the paths from this class to its base class
   /// subobjects that match the search criteria.
   ///
+  /// \param LookupInDependent can be set to true to extend the search to
+  /// dependent base classes.
+  ///
   /// \returns true if there exists any path from this class to a base class
   /// subobject that matches the search criteria.
-  bool lookupInBases(BaseMatchesCallback BaseMatches,
- CXXBasePaths &Paths) const;
+  bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths,
+ bool LookupInDependent = false) const;
 
   /// \brief Base-class lookup callback that determines whether the given
   /// base class specifier refers to a specific class declaration.
@@ -1608,6 +1611,16 @@
  CXXBasePath &Path, DeclarationName Name);
 
   /// \brief Base-class lookup callback that determines whether there exists
+  /// a member with the given name.
+  ///
+  /// This callback can be used with \c lookupInBases() to find members
+  /// of the given name within a C++ class hierarchy, including dependent
+  /// classes.
+  static bool
+  FindOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
+   CXXBasePath &Path, DeclarationName Name);
+
+  /// \brief Base-class lookup callback that determines whether there exists
   /// an OpenMP declare reduction member with the given name.
   ///
   /// This callback can be used with \c lookupInBases() to find members
@@ -1633,6 +1646,14 @@
   /// \brief Get the indirect primary bases for this class.
   void getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const;
 
+  /// Performs an imprecise lookup of a dependent name in this class.
+  ///
+  /// This function does not follow strict semantic rules and should be used
+  /// only when lookup rules can be relaxed, e.g. indexing.
+  std::vector
+  lookupDependentName(const DeclarationName &Name,
+  llvm::function_ref Filter);
+
   /// Renders and displays an inheritance diagram
   /// for this C++ class and all of its base classes (transitively) using
   /// GraphViz.
Index: cfe/trunk/test/Index/Core/index-dependent-source.cpp
===
--- cfe/trunk/test/Index/Core/index-dependent-source.cpp
+++ cfe/trunk/test/Index/Core/index-dependent-source.cpp
@@ -0,0 +1,124 @@
+// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s
+
+int invalid;
+
+class Base {
+  void baseFunction();
+
+  int baseField;
+
+  static void staticBaseFunction();
+};
+
+template
+class BaseTemplate {
+public:
+  T baseTemplateFunction();
+
+  T baseTemplateField;
+
+  static T baseTemplateVariable;
+};
+
+template
+class TemplateClass: public Base , public BaseTemplate {
+public:
+  ~TemplateClass();
+
+  T function() { }
+
+  static void staticFunction() { }
+
+  T field;
+
+  static T variable;
+
+  struct Struct { };
+
+  enum Enum { EnumValue };
+
+  using TypeAlias = S;
+  typedef T Typedef;
+
+  void overload1(const T &);
+  void overload1(const S &);
+};
+
+template
+void indexSimpleDependentDeclarations(const TemplateClass &object) {
+  // Valid instance members:
+  object.function();
+// CHECK: [[@LINE-1]]:10 | instance-method/C++ | function | c:@ST>2#T#T@TemplateClass@F@function# |  | Ref,Call,RelCall,RelCont | rel: 1
+  object.field;
+// CHECK: [[@LINE-1]]:10 | field/C++ | field | c:@ST>2#T#T@TemplateClass@FI@fi

r302632 - [index] Index simple dependent declaration references

2017-05-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 10 04:47:41 2017
New Revision: 302632

URL: http://llvm.org/viewvc/llvm-project?rev=302632&view=rev
Log:
[index] Index simple dependent declaration references

This commit implements basic support for indexing of dependent declaration
references. Now the indexer tries to find a suitable match in the base template
for a dependent member ref/decl ref/dependent type.

rdar://29158210

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

Added:
cfe/trunk/test/Index/Core/index-dependent-source.cpp
Modified:
cfe/trunk/include/clang/AST/CXXInheritance.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp

Modified: cfe/trunk/include/clang/AST/CXXInheritance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=302632&r1=302631&r2=302632&view=diff
==
--- cfe/trunk/include/clang/AST/CXXInheritance.h (original)
+++ cfe/trunk/include/clang/AST/CXXInheritance.h Wed May 10 04:47:41 2017
@@ -161,7 +161,8 @@ class CXXBasePaths {
   void ComputeDeclsFound();
 
   bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record,
- CXXRecordDecl::BaseMatchesCallback BaseMatches);
+ CXXRecordDecl::BaseMatchesCallback BaseMatches,
+ bool LookupInDependent = false);
 
 public:
   typedef std::list::iterator paths_iterator;

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=302632&r1=302631&r2=302632&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed May 10 04:47:41 2017
@@ -1563,10 +1563,13 @@ public:
   /// \param Paths used to record the paths from this class to its base class
   /// subobjects that match the search criteria.
   ///
+  /// \param LookupInDependent can be set to true to extend the search to
+  /// dependent base classes.
+  ///
   /// \returns true if there exists any path from this class to a base class
   /// subobject that matches the search criteria.
-  bool lookupInBases(BaseMatchesCallback BaseMatches,
- CXXBasePaths &Paths) const;
+  bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths,
+ bool LookupInDependent = false) const;
 
   /// \brief Base-class lookup callback that determines whether the given
   /// base class specifier refers to a specific class declaration.
@@ -1608,6 +1611,16 @@ public:
  CXXBasePath &Path, DeclarationName Name);
 
   /// \brief Base-class lookup callback that determines whether there exists
+  /// a member with the given name.
+  ///
+  /// This callback can be used with \c lookupInBases() to find members
+  /// of the given name within a C++ class hierarchy, including dependent
+  /// classes.
+  static bool
+  FindOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
+   CXXBasePath &Path, DeclarationName 
Name);
+
+  /// \brief Base-class lookup callback that determines whether there exists
   /// an OpenMP declare reduction member with the given name.
   ///
   /// This callback can be used with \c lookupInBases() to find members
@@ -1633,6 +1646,14 @@ public:
   /// \brief Get the indirect primary bases for this class.
   void getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const;
 
+  /// Performs an imprecise lookup of a dependent name in this class.
+  ///
+  /// This function does not follow strict semantic rules and should be used
+  /// only when lookup rules can be relaxed, e.g. indexing.
+  std::vector
+  lookupDependentName(const DeclarationName &Name,
+  llvm::function_ref Filter);
+
   /// Renders and displays an inheritance diagram
   /// for this C++ class and all of its base classes (transitively) using
   /// GraphViz.

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=302632&r1=302631&r2=302632&view=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Wed May 10 04:47:41 2017
@@ -13,6 +13,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/RecordLayout.h"
 #include "llvm/ADT/SetVector.h"
 #include 
@@ -174,9 +175,10 @@ bool CXXRecordDecl::forallBases(ForallBa
   return AllMatches;
 }
 
-bool CXXBasePaths::lookupInBases(
-ASTContext &Context, const CXXRecordDecl *Record,
-CXXRecordDecl::BaseMatchesCallback BaseMatche

r302630 - [OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins

2017-05-10 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Wed May 10 03:23:01 2017
New Revision: 302630

URL: http://llvm.org/viewvc/llvm-project?rev=302630&view=rev
Log:
[OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=302630&r1=302629&r2=302630&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Wed May 10 03:23:01 2017
@@ -14962,6 +14962,7 @@ float __purefn __ovld read_imagef(read_o
 #endif //cl_khr_gl_msaa_sharing
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 
 float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t 
sampler, float coord, float lod);
@@ -15037,6 +15038,7 @@ int4 __purefn __ovld read_imagei(read_on
 uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, float4 coord, float lod);
 
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 /**
 * Sampler-less Image Access
@@ -15135,6 +15137,7 @@ float __purefn __ovld read_imagef(read_w
 float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, 
int4 coord, int sample);
 #endif //cl_khr_gl_msaa_sharing
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t 
sampler, float coord, float lod);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t 
sampler, float coord, float lod);
@@ -15208,6 +15211,7 @@ float4 __purefn __ovld read_imagef(read_
 int4 __purefn __ovld read_imagei(read_write image3d_t image, sampler_t 
sampler, float4 coord, float lod);
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t 
sampler, float4 coord, float lod);
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
@@ -15319,6 +15323,7 @@ void __ovld write_imagef(write_only imag
 #endif //cl_khr_depth_images
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
@@ -15345,6 +15350,7 @@ void __ovld write_imagei(write_only imag
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
 #endif
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15391,6 +15397,7 @@ void __ovld write_imagef(read_write imag
 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, 
float color);
 #endif //cl_khr_depth_images
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
@@ -15417,6 +15424,7 @@ void __ovld write_imagei(read_write imag
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
 #endif
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15559,6 +15567,7 @@ int __ovld __cnfn get_image_depth(read_w
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 /**
  * Return the image miplevels.
@@ -15574,11 +15583,9 @@ int __ovld get_image_num_mip_levels(writ
 int __ovld get_image_num_mip_levels(write_only image3d_t image);
 #endif
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 int __ovld get_image_num_mip_levels(read_write image1d_t image);
 int __ovld get_image_num_mip_levels(read_write image2d_t image);
 int __ovld get_image_num_mip_levels(read_write image3d_t image);
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 int __ovld get_image_num_mip_levels(read_only image1d_array_t image);
 int __ovld get_image_num_mip_levels(read_only image2d_array_t image);
@@ -15590,14 +15597,13 @@ int __ovld get_image_num_mip_levels(writ
 int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t image);
 int __ovld get_image_num_mip_levels(write_only image2d_depth_t image);
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 int __ovld get_image_num_mip_levels(read_write image1d_array_t image);
 int __ovld get_image_num_mip_levels(read_write image2d_array_t image);
 int __ovld get_ima

[clang-tools-extra] r302637 - [clang-tidy] Add new cert-dcl21-cpp check

2017-05-10 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed May 10 06:16:55 2017
New Revision: 302637

URL: http://llvm.org/viewvc/llvm-project?rev=302637&view=rev
Log:
[clang-tidy] Add new cert-dcl21-cpp check 

This check flags postfix operator++/-- declarations,
where the return type is not a const object.

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

Added:
clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst
clang-tools-extra/trunk/test/clang-tidy/cert-dcl21-cpp.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=302637&r1=302636&r2=302637&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Wed May 10 
06:16:55 2017
@@ -20,6 +20,7 @@
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
 #include "LimitedRandomnessCheck.h"
+#include "PostfixOperatorCheck.h"
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
 #include "StrToNumCheck.h"
@@ -35,6 +36,8 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 // C++ checkers
 // DCL
+CheckFactories.registerCheck(
+"cert-dcl21-cpp");
 CheckFactories.registerCheck("cert-dcl50-cpp");
 CheckFactories.registerCheck(
 "cert-dcl54-cpp");

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=302637&r1=302636&r2=302637&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Wed May 10 06:16:55 
2017
@@ -6,6 +6,7 @@ add_clang_library(clangTidyCERTModule
   DontModifyStdNamespaceCheck.cpp
   FloatLoopCounter.cpp
   LimitedRandomnessCheck.cpp
+  PostfixOperatorCheck.cpp
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp
   StrToNumCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp?rev=302637&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp Wed May 10 
06:16:55 2017
@@ -0,0 +1,88 @@
+//===--- PostfixOperatorCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "PostfixOperatorCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void PostfixOperatorCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(functionDecl(anyOf(hasOverloadedOperatorName("++"),
+hasOverloadedOperatorName("--")))
+ .bind("decl"),
+ this);
+}
+
+void PostfixOperatorCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *FuncDecl = Result.Nodes.getNodeAs("decl");
+
+  bool HasThis = false;
+  if (const auto *MethodDecl = dyn_cast(FuncDecl))
+HasThis = MethodDecl->isInstance();
+
+  // Check if the operator is a postfix one.
+  if (FuncDecl->getNumParams() != (HasThis ? 1 : 2))
+return;
+
+  SourceRange ReturnRange = FuncDecl->getReturnTypeSourceRange();
+  SourceLocation Location = ReturnRange.getBegin();
+  if (!Location.isValid())
+return;
+
+  QualType ReturnType = FuncDecl->getReturnType();
+
+  // Warn when the operators return a reference.
+  if (const auto *RefType = ReturnType->getAs()) {
+auto Diag = diag(Location, "overloaded %0 returns a reference instead of a 
"
+   "constant object type")
+<< FuncDecl;
+
+if (Location.isMacroID() || ReturnType->getAs() ||
+RefType->getPointeeTypeAsWritten()->getAs())
+  return;
+
+QualType ReplaceType =
+  

[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

2017-05-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302637: [clang-tidy] Add new cert-dcl21-cpp check  (authored 
by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D32743?vs=98179&id=98426#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32743

Files:
  clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp
  clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/cert-dcl21-cpp.cpp

Index: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
@@ -20,6 +20,7 @@
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
 #include "LimitedRandomnessCheck.h"
+#include "PostfixOperatorCheck.h"
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
 #include "StrToNumCheck.h"
@@ -35,6 +36,8 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 // C++ checkers
 // DCL
+CheckFactories.registerCheck(
+"cert-dcl21-cpp");
 CheckFactories.registerCheck("cert-dcl50-cpp");
 CheckFactories.registerCheck(
 "cert-dcl54-cpp");
Index: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
@@ -6,6 +6,7 @@
   DontModifyStdNamespaceCheck.cpp
   FloatLoopCounter.cpp
   LimitedRandomnessCheck.cpp
+  PostfixOperatorCheck.cpp
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp
   StrToNumCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.h
@@ -0,0 +1,36 @@
+//===--- PostfixOperatorCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_POSTFIX_OPERATOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_POSTFIX_OPERATOR_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+/// Checks if the overloaded postfix ++ and -- operator return a constant
+/// object.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-postfix-operator.html
+class PostfixOperatorCheck : public ClangTidyCheck {
+public:
+  PostfixOperatorCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_POSTFIX_OPERATOR_H
Index: clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cert/PostfixOperatorCheck.cpp
@@ -0,0 +1,88 @@
+//===--- PostfixOperatorCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "PostfixOperatorCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void PostfixOperatorCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(functionDecl(anyOf(hasOverloadedOperatorName("++"),
+hasOverloadedOperatorName("--")))
+ .bind("decl"),
+ this);
+}
+
+void PostfixOperatorCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *FuncDecl = Result.Nodes.getNodeAs("decl");
+
+  boo

r302633 - [OpenCL] Handle OpenCL specific subelement types

2017-05-10 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Wed May 10 05:28:34 2017
New Revision: 302633

URL: http://llvm.org/viewvc/llvm-project?rev=302633&view=rev
Log:
[OpenCL] Handle OpenCL specific subelement types

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

Added:
cfe/trunk/test/SemaOpenCL/array-init.cl
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=302633&r1=302632&r2=302633&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed May 10 05:28:34 2017
@@ -1209,7 +1209,7 @@ void InitListChecker::CheckSubElementTyp
 
   } else {
 assert((ElemType->isRecordType() || ElemType->isVectorType() ||
-ElemType->isClkEventT()) && "Unexpected type");
+ElemType->isOpenCLSpecificType()) && "Unexpected type");
 
 // C99 6.7.8p13:
 //

Added: cfe/trunk/test/SemaOpenCL/array-init.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/array-init.cl?rev=302633&view=auto
==
--- cfe/trunk/test/SemaOpenCL/array-init.cl (added)
+++ cfe/trunk/test/SemaOpenCL/array-init.cl Wed May 10 05:28:34 2017
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+__kernel void k1(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};
+}
+
+__kernel void k2(read_only pipe int p) {
+  reserve_id_t i1 = reserve_read_pipe(p, 1);
+  reserve_id_t i2 = reserve_read_pipe(p, 1);
+  reserve_id_t i[] = {i1, i2};
+}
+
+event_t create_event();
+__kernel void k3() {
+  event_t e1 = create_event();
+  event_t e2 = create_event();
+  event_t e[] = {e1, e2};
+}
+


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


[PATCH] D32981: [ASTImporter] Improve handling of incomplete types

2017-05-10 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Looks good!




Comment at: lib/AST/ASTImporter.cpp:1757
   D2->setAnonymousStructOrUnion(true);
+if (PrevDecl) {
+  D2->setPreviousDecl(PrevDecl);

By the way, should we do the same for some other kinds of Decls (like 
FunctionDecl)? If so, could you write a NOTE comment?


Repository:
  rL LLVM

https://reviews.llvm.org/D32981



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Wei-Ren Chen via Phabricator via cfe-commits
chenwj added a comment.

In https://reviews.llvm.org/D32759#748916, @efriedma wrote:

> In https://reviews.llvm.org/D32759#748653, @chenwj wrote:
>
> > In https://reviews.llvm.org/D32759#748007, @efriedma wrote:
> >
> > > The difference between returning true and false here is just the way 
> > > error recovery works: when we return true, we know the type is invalid, 
> > > so we suppress it, and subsequent errors involving the declaration.  
> > > Example (Objective-C++) where we currently print two errors:
> >
> >
> > So when we see `T->isObjCObjectType()` is true, then we should return true 
> > since the return type is invalid?
>
>
> Yes.


@efriedma So @erichkeane 's patch looks okay?


https://reviews.llvm.org/D32759



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


[PATCH] D33033: [libc++] Fix PR32979 - types with a private std::enable_shared_from_this base break shared_ptr

2017-05-10 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D33033



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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-10 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In general, I prefer having the space between `static_assert(` and the 
condition.

That makes it easy (at least for me) to see if there's a `!` there or not.
Other than that, this LGTM.

FWIW, I think this is a language change that core got wrong, and it has already 
come back to bite us. (https://bugs.llvm.org/show_bug.cgi?id=28527)


https://reviews.llvm.org/D33021



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


[PATCH] D33006: clang-format: refine calculating brace types.

2017-05-10 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.


https://reviews.llvm.org/D33006



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

rjmccall wrote:
> Should this rule apply even in C++ mode?  I can't remember if there are any 
> OpenCL/C++ hybrids.
No. This rule (static local variable needs to be initialised with compile-time 
constant) only applies to C and OpenCL. 
In C++ static local variable can be initialised with non-compile-time constant, 
in which case Clang will emit atomic instructions to make sure it is only 
initialised once.

Currently OpenCL 2.2 defines OpenCL C++ but clang does not support it.


https://reviews.llvm.org/D32977



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


[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)

2017-05-10 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin updated this revision to Diff 98441.
a.sidorin added a reviewer: karkhaz.
a.sidorin added a comment.

Address review comments; add the context.


https://reviews.llvm.org/D32751

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/namespace/Inputs/namespace1.cpp
  test/ASTMerge/namespace/Inputs/namespace2.cpp
  test/ASTMerge/namespace/test.cpp

Index: test/ASTMerge/namespace/test.cpp
===
--- test/ASTMerge/namespace/test.cpp
+++ test/ASTMerge/namespace/test.cpp
@@ -1,6 +1,17 @@
-// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/namespace1.cpp
-// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/namespace2.cpp
-// RUN: not %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.1.ast %S/Inputs/namespace1.cpp
+// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.2.ast %S/Inputs/namespace2.cpp
+// RUN: not %clang_cc1 -std=c++1z -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+static_assert(TestAliasName::z == 4);
+static_assert(ContainsInline::z == 10);
+
+void testImport() {
+  typedef TestUnresolvedTypenameAndValueDecls::Derived Imported;
+  Imported a; // Successfull instantiation
+  static_assert(sizeof(Imported::foo) == sizeof(int));
+  static_assert(sizeof(TestUnresolvedTypenameAndValueDecls::Derived::NewUnresolvedUsingType) == sizeof(double));
+}
+
 
 // CHECK: namespace2.cpp:16:17: error: external variable 'z' declared with incompatible types in different translation units ('double' vs. 'float')
 // CHECK: namespace1.cpp:16:16: note: declared here with type 'float'
Index: test/ASTMerge/namespace/Inputs/namespace2.cpp
===
--- test/ASTMerge/namespace/Inputs/namespace2.cpp
+++ test/ASTMerge/namespace/Inputs/namespace2.cpp
@@ -15,3 +15,46 @@
 namespace N3 {
   extern double z;
 }
+
+namespace Enclosing {
+namespace Nested {
+  const int z = 4;
+}
+}
+
+namespace ContainsInline {
+  inline namespace Inline {
+const int z = 10;
+  }
+}
+
+namespace TestAliasName = Enclosing::Nested;
+// NOTE: There is no warning on this alias.
+namespace AliasWithSameName = Enclosing::Nested;
+
+namespace TestUsingDecls {
+
+namespace A {
+void foo();
+}
+namespace B {
+using A::foo; // <- a UsingDecl creating a UsingShadow
+}
+
+}// end namespace TestUsingDecls
+
+namespace TestUnresolvedTypenameAndValueDecls {
+
+template  class Base;
+template  class Derived : public Base {
+public:
+  using typename Base::foo;
+  using Base::bar;
+  typedef typename Derived::foo NewUnresolvedUsingType;
+};
+
+} // end namespace TestUnresolvedTypenameAndValueDecls
+
+namespace TestUsingNamespace {
+  using namespace Enclosing;
+}
Index: test/ASTMerge/namespace/Inputs/namespace1.cpp
===
--- test/ASTMerge/namespace/Inputs/namespace1.cpp
+++ test/ASTMerge/namespace/Inputs/namespace1.cpp
@@ -15,3 +15,13 @@
 namespace N3 {
   extern float z;
 }
+
+namespace AliasWithSameName = N3;
+
+namespace TestUnresolvedTypenameAndValueDecls {
+template  class Base {
+public:
+  typedef T foo;
+  void bar();
+};
+}
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -58,7 +58,7 @@
 QualType VisitExtVectorType(const ExtVectorType *T);
 QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T);
 QualType VisitFunctionProtoType(const FunctionProtoType *T);
-// FIXME: UnresolvedUsingType
+QualType VisitUnresolvedUsingType(const UnresolvedUsingType *T);
 QualType VisitParenType(const ParenType *T);
 QualType VisitTypedefType(const TypedefType *T);
 QualType VisitTypeOfExprType(const TypeOfExprType *T);
@@ -128,8 +128,8 @@
 TemplateParameterList *ImportTemplateParameterList(
  TemplateParameterList *Params);
 TemplateArgument ImportTemplateArgument(const TemplateArgument &From);
-TemplateArgumentLoc ImportTemplateArgumentLoc(
-const TemplateArgumentLoc &TALoc, bool &Error);
+Optional ImportTemplateArgumentLoc(
+const TemplateArgumentLoc &TALoc);
 bool ImportTemplateArguments(const TemplateArgument *FromArgs,
  unsigned NumFromArgs,
SmallVectorImpl &ToArgs);
@@ -142,10 +142,12 @@
 bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To);
 bool IsStructuralMatch(VarTemplateDecl *From, VarTemplateDecl *To);
 Decl *VisitDecl(Decl *D);
+Decl *VisitEmptyDecl(EmptyDecl *D);
 Decl *VisitAccessSpecDecl(AccessSpecDecl *D);
 Decl *VisitStaticAssertDecl(StaticAssertDecl *D);
 Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D);
 Decl *VisitNamespaceDecl(NamespaceDecl *D);
+Decl *VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
 Decl

r302654 - Use clang++-3.5 compatible initializer_list constructor

2017-05-10 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed May 10 08:22:11 2017
New Revision: 302654

URL: http://llvm.org/viewvc/llvm-project?rev=302654&view=rev
Log:
Use clang++-3.5 compatible initializer_list constructor

Otherwise, a warning is issued.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h?rev=302654&r1=302653&r2=302654&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h Wed May 10 08:22:11 
2017
@@ -20,7 +20,7 @@ static inline Selector getKeywordSelecto
   IdentifierInfos *... IIs) {
   static_assert(sizeof...(IdentifierInfos),
 "keyword selectors must have at least one argument");
-  SmallVector II{{&Ctx.Idents.get(IIs)...}};
+  SmallVector II({&Ctx.Idents.get(IIs)...});
 
   return Ctx.Selectors.getSelector(II.size(), &II[0]);
 }


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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-10 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 98445.
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Reduce the amount of calls to AddLazySpecializations. Remove assert.

In order to create a reasonable test I need to use 
`-error-on-deserialized-decl` and I hit a bug: 
https://bugs.llvm.org/show_bug.cgi?id=32988

Richard, could you help me out with the test? Maybe we could trigger this 
avoiding the abovementioned bug...


https://reviews.llvm.org/D29951

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReaderDecl.cpp
  test/Modules/Inputs/lazy-template-specializations/A.h
  test/Modules/Inputs/lazy-template-specializations/B.h
  test/Modules/Inputs/lazy-template-specializations/module.modulemap
  test/Modules/lazy-template-specializations.cpp

Index: test/Modules/lazy-template-specializations.cpp
===
--- /dev/null
+++ test/Modules/lazy-template-specializations.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -fr %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/lazy-template-specializations -std=c++11  \
+// RUN: -error-on-deserialized-decl S -Rmodule-build %s
+
+
+#include "A.h"
+
+namespace N {
+}
Index: test/Modules/Inputs/lazy-template-specializations/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/lazy-template-specializations/module.modulemap
@@ -0,0 +1,9 @@
+module A {
+  header "A.h"
+  export *
+}
+
+module B {
+  header "B.h"
+  export *
+}
Index: test/Modules/Inputs/lazy-template-specializations/B.h
===
--- /dev/null
+++ test/Modules/Inputs/lazy-template-specializations/B.h
@@ -0,0 +1,4 @@
+namespace N {
+  template  struct S { int a; };
+  template <> struct S { double b; };
+}
Index: test/Modules/Inputs/lazy-template-specializations/A.h
===
--- /dev/null
+++ test/Modules/Inputs/lazy-template-specializations/A.h
@@ -0,0 +1,3 @@
+#include "B.h"
+int i;
+
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1951,35 +1951,15 @@
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
- SmallVectorImpl &IDs) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
   if (ThisDeclID == Redecl.getFirstID()) {
 // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+Reader.AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2006,12 +1986,7 @@
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+Reader.AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2117,12 +2092,7 @@
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+Reader.AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3697,6 +3667,17 @@
   }
 }
   }
+  // Add the lazy specializations to the template.
+  assert((PendingLazySpecializationIDs.empty() || isa(D) ||
+  isa(D) || isa(D)) &&
+ "Must not have pending specializations");
+  if (auto *CTD = dyn_cast(D))
+AddLazySpecializations(CTD, PendingLazySpecializationIDs);
+  else if (auto *FTD = dyn_cast(D))
+AddLazySpecializations(FTD, PendingLazySpecializationIDs);
+  else if (auto *VTD = dyn_cast(D))
+AddLazySpecializations(VTD, PendingLazySpecializationIDs);
+  PendingLazySpecializationIDs.clear();
 
   // Load the pending visible updates f

r302658 - clang-format: refine calculating brace types.

2017-05-10 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed May 10 08:53:29 2017
New Revision: 302658

URL: http://llvm.org/viewvc/llvm-project?rev=302658&view=rev
Log:
clang-format: refine calculating brace types.

Summary:
For C++ code, opening parenthesis following a } indicate a braced init. For 
JavaScript and other languages, this is an invalid syntactical construct, 
unless the closing parenthesis belongs to a function - in which situation its a 
BK_Block.

This fixes indenting IIFEs following top level functions:

function foo() {}
(function() { codeHere(); }());

clang-format used to collapse these lines together.

Subscribers: klimek

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=302658&r1=302657&r2=302658&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed May 10 08:53:29 2017
@@ -368,9 +368,10 @@ void UnwrappedLineParser::calculateBrace
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
+  (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
tok::r_paren, tok::r_square, tok::l_brace,
-   tok::l_square, tok::l_paren, tok::ellipsis) ||
+   tok::l_square, tok::ellipsis) ||
   (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302658&r1=302657&r2=302658&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed May 10 08:53:29 2017
@@ -470,6 +470,16 @@ TEST_F(FormatTestJS, FormatsFreestanding
"  inner2(a, b);\n"
"}");
   verifyFormat("function f() {}");
+  verifyFormat("function aFunction() {}\n"
+   "(function f() {\n"
+   "  var x = 1;\n"
+   "}());\n");
+  // Known issue: this should wrap after {}, but calculateBraceTypes
+  // misclassifies the first braces as a BK_BracedInit.
+  verifyFormat("function aFunction(){} {\n"
+   "  let x = 1;\n"
+   "  console.log(x);\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, GeneratorFunctions) {


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


[PATCH] D33006: clang-format: refine calculating brace types.

2017-05-10 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302658: clang-format: refine calculating brace types. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D33006?vs=98309&id=98448#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33006

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -368,9 +368,10 @@
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
+  (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
tok::r_paren, tok::r_square, tok::l_brace,
-   tok::l_square, tok::l_paren, tok::ellipsis) ||
+   tok::l_square, tok::ellipsis) ||
   (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -470,6 +470,16 @@
"  inner2(a, b);\n"
"}");
   verifyFormat("function f() {}");
+  verifyFormat("function aFunction() {}\n"
+   "(function f() {\n"
+   "  var x = 1;\n"
+   "}());\n");
+  // Known issue: this should wrap after {}, but calculateBraceTypes
+  // misclassifies the first braces as a BK_BracedInit.
+  verifyFormat("function aFunction(){} {\n"
+   "  let x = 1;\n"
+   "  console.log(x);\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, GeneratorFunctions) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -368,9 +368,10 @@
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
+  (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
tok::r_paren, tok::r_square, tok::l_brace,
-   tok::l_square, tok::l_paren, tok::ellipsis) ||
+   tok::l_square, tok::ellipsis) ||
   (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -470,6 +470,16 @@
"  inner2(a, b);\n"
"}");
   verifyFormat("function f() {}");
+  verifyFormat("function aFunction() {}\n"
+   "(function f() {\n"
+   "  var x = 1;\n"
+   "}());\n");
+  // Known issue: this should wrap after {}, but calculateBraceTypes
+  // misclassifies the first braces as a BK_BracedInit.
+  verifyFormat("function aFunction(){} {\n"
+   "  let x = 1;\n"
+   "  console.log(x);\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, GeneratorFunctions) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)

2017-05-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a reviewer: szepet.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM! Adding Peter as a reviewer, as he is more experienced with the 
ASTImporter than me.


https://reviews.llvm.org/D32751



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


r302670 - Reland: [mips] Impose a threshold for coercion of aggregates

2017-05-10 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Wed May 10 09:28:18 2017
New Revision: 302670

URL: http://llvm.org/viewvc/llvm-project?rev=302670&view=rev
Log:
Reland: [mips] Impose a threshold for coercion of aggregates

Modified MipsABIInfo::classifyArgumentType so that it now coerces
aggregate structures only if the size of said aggregate is less than
16/64 bytes, depending on the ABI.

Patch by Stefan Maksimovic.

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

with minor changes (use regexp instead of the hardcoded values) to the test.


Added:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302670&r1=302669&r2=302670&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed May 10 09:28:18 2017
@@ -6693,6 +6693,14 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Added: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302670&view=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (added)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c Wed May 10 09:28:18 2017
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %{{[0-9]+}}, i32 inreg %{{[0-9]+}}, i16 inreg 
%{{[0-9]+}})
+// O32:  call void @f2(%struct.t2* byval align 4 %{{.*}})
+// O32:  call void @f3(%struct.t3* byval align 4 %{{.*}})
+
+// N32-N64:  call void @f1(i64 inreg %{{[0-9]+}}, i16 inreg %{{[0-9]+}})
+// N32-N64:  call void @f2(i64 inreg %{{[0-9]+}}, i64 inreg %{{[0-9]+}}, i32 
inreg %{{[0-9]+}})
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %{{.*}})
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+


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


[PATCH] D32891: [Sema][ObjC++] Objective-C++ support for __is_base_of(B, D)

2017-05-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM! A couple of comments below:




Comment at: lib/Sema/SemaExprCXX.cpp:4725
+if (!rhsRecord || !lhsRecord) {
+  const ObjCObjectType *lhsObjTy = LhsT->getAs();
+  const ObjCObjectType *rhsObjTy = RhsT->getAs();

Please capitalize `lhsObjTy` and `rhsObjTy`.



Comment at: test/SemaObjCXX/is-base-of.mm:14
+
+static_assert(!__is_base_of(NSObj *, NSChild *), "");
+static_assert(!__is_base_of(NSChild *, NSObj *), "");

I'd also add a test that verifies that `id` isn't a valid base, e.g:

```
static_assert(!__is_base_of(id, NSObj), "");
```


https://reviews.llvm.org/D32891



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


[PATCH] D33020: [Myriad] Pass -Xclang and -mllvm flags to moviCompile

2017-05-10 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

Will submit for you since you don't have an svn account.


https://reviews.llvm.org/D33020



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


[PATCH] D33042: [libclang] Allow to suspend a translation unit.

2017-05-10 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik created this revision.
Herald added a subscriber: klimek.

A suspended translation unit uses significantly less memory but on the other
side does not support any other calls than clang_reparseTranslationUnit to
resume it or clang_disposeTranslationUnit to dispose it completely.

This helps IDEs to reduce the memory footprint. The data that is freed
by a call to clang_suspendTranslationUnit will be re-generated on the
next (re)parse anyway. Used with a preamble, this allows pretty fast
resumption of the translation for further use (compared to disposal of
the translation unit and a parse from scratch).


Repository:
  rL LLVM

https://reviews.llvm.org/D33042

Files:
  include/clang-c/Index.h
  include/clang/Frontend/ASTUnit.h
  lib/Format/UnwrappedLineParser.cpp
  lib/Frontend/ASTUnit.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -470,6 +470,16 @@
"  inner2(a, b);\n"
"}");
   verifyFormat("function f() {}");
+  verifyFormat("function aFunction() {}\n"
+   "(function f() {\n"
+   "  var x = 1;\n"
+   "}());\n");
+  // Known issue: this should wrap after {}, but calculateBraceTypes
+  // misclassifies the first braces as a BK_BracedInit.
+  verifyFormat("function aFunction(){} {\n"
+   "  let x = 1;\n"
+   "  console.log(x);\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, GeneratorFunctions) {
Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -304,6 +304,7 @@
 clang_remap_getNumFiles
 clang_reparseTranslationUnit
 clang_saveTranslationUnit
+clang_suspendTranslationUnit
 clang_sortCodeCompletionResults
 clang_toggleCrashRecovery
 clang_tokenize
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3918,6 +3918,20 @@
   }
 }
 
+unsigned clang_suspendTranslationUnit(CXTranslationUnit CTUnit) {
+  if (CTUnit) {
+ASTUnit *Unit = cxtu::getASTUnit(CTUnit);
+
+if (Unit && Unit->isUnsafeToFree())
+  return false;
+
+Unit->ResetForParse();
+return true;
+  }
+
+  return false;
+}
+
 unsigned clang_defaultReparseOptions(CXTranslationUnit TU) {
   return CXReparse_None;
 }
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1729,6 +1729,8 @@
   return -1;
 
 if (Repeats > 1) {
+  clang_suspendTranslationUnit(TU);
+
   Err = clang_reparseTranslationUnit(TU, num_unsaved_files, unsaved_files,
  clang_defaultReparseOptions(TU));
   if (Err != CXError_Success) {
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1042,8 +1042,6 @@
 /// contain any translation-unit information, false otherwise.
 bool ASTUnit::Parse(std::shared_ptr PCHContainerOps,
 std::unique_ptr OverrideMainBuffer) {
-  SavedMainFileBuffer.reset();
-
   if (!Invocation)
 return true;
 
@@ -1090,18 +1088,11 @@
 Clang->createFileManager();
 FileMgr = &Clang->getFileManager();
   }
-  SourceMgr = new SourceManager(getDiagnostics(), *FileMgr,
-UserFilesAreVolatile);
-  TheSema.reset();
-  Ctx = nullptr;
-  PP = nullptr;
-  Reader = nullptr;
 
-  // Clear out old caches and data.
-  TopLevelDecls.clear();
-  clearFileLevelDecls();
-  CleanTemporaryFiles();
+  ResetForParse();
 
+  SourceMgr = new SourceManager(getDiagnostics(), *FileMgr,
+UserFilesAreVolatile);
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);
 TopLevelDeclsInPreamble.clear();
@@ -2094,6 +2085,21 @@
   return Result;
 }
 
+void ASTUnit::ResetForParse()
+{
+  SavedMainFileBuffer.reset();
+
+  SourceMgr.reset();
+  TheSema.reset();
+  Ctx.reset();
+  PP.reset();
+  Reader.reset();
+
+  TopLevelDecls.clear();
+  clearFileLevelDecls();
+  CleanTemporaryFiles();
+}
+
 ////
 // Code completion
 ////
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -368,9 +368,10 @@
   (Style.Language == FormatStyle::LK_JavaScript &&
Next

[PATCH] D33042: [libclang] Allow to suspend a translation unit.

2017-05-10 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik updated this revision to Diff 98461.

https://reviews.llvm.org/D33042

Files:
  include/clang-c/Index.h
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -304,6 +304,7 @@
 clang_remap_getNumFiles
 clang_reparseTranslationUnit
 clang_saveTranslationUnit
+clang_suspendTranslationUnit
 clang_sortCodeCompletionResults
 clang_toggleCrashRecovery
 clang_tokenize
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3918,6 +3918,20 @@
   }
 }
 
+unsigned clang_suspendTranslationUnit(CXTranslationUnit CTUnit) {
+  if (CTUnit) {
+ASTUnit *Unit = cxtu::getASTUnit(CTUnit);
+
+if (Unit && Unit->isUnsafeToFree())
+  return false;
+
+Unit->ResetForParse();
+return true;
+  }
+
+  return false;
+}
+
 unsigned clang_defaultReparseOptions(CXTranslationUnit TU) {
   return CXReparse_None;
 }
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1729,6 +1729,8 @@
   return -1;
 
 if (Repeats > 1) {
+  clang_suspendTranslationUnit(TU);
+
   Err = clang_reparseTranslationUnit(TU, num_unsaved_files, unsaved_files,
  clang_defaultReparseOptions(TU));
   if (Err != CXError_Success) {
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1042,8 +1042,6 @@
 /// contain any translation-unit information, false otherwise.
 bool ASTUnit::Parse(std::shared_ptr PCHContainerOps,
 std::unique_ptr OverrideMainBuffer) {
-  SavedMainFileBuffer.reset();
-
   if (!Invocation)
 return true;
 
@@ -1090,18 +1088,11 @@
 Clang->createFileManager();
 FileMgr = &Clang->getFileManager();
   }
-  SourceMgr = new SourceManager(getDiagnostics(), *FileMgr,
-UserFilesAreVolatile);
-  TheSema.reset();
-  Ctx = nullptr;
-  PP = nullptr;
-  Reader = nullptr;
 
-  // Clear out old caches and data.
-  TopLevelDecls.clear();
-  clearFileLevelDecls();
-  CleanTemporaryFiles();
+  ResetForParse();
 
+  SourceMgr = new SourceManager(getDiagnostics(), *FileMgr,
+UserFilesAreVolatile);
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);
 TopLevelDeclsInPreamble.clear();
@@ -2094,6 +2085,21 @@
   return Result;
 }
 
+void ASTUnit::ResetForParse()
+{
+  SavedMainFileBuffer.reset();
+
+  SourceMgr.reset();
+  TheSema.reset();
+  Ctx.reset();
+  PP.reset();
+  Reader.reset();
+
+  TopLevelDecls.clear();
+  clearFileLevelDecls();
+  CleanTemporaryFiles();
+}
+
 ////
 // Code completion
 ////
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -858,6 +858,11 @@
   bool Reparse(std::shared_ptr PCHContainerOps,
ArrayRef RemappedFiles = None);
 
+  /// \brief Free data that will be re-generated on the next parse.
+  ///
+  /// Preamble-related data is not affected.
+  void ResetForParse();
+
   /// \brief Perform code completion at the given file, line, and
   /// column within this translation unit.
   ///
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 38
+#define CINDEX_VERSION_MINOR 39
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -1419,6 +1419,15 @@
  unsigned options);
 
 /**
+ * \brief Suspend a translation unit in order to free memory associated with it.
+ *
+ * A suspended translation unit uses significantly less memory but on the other
+ * side does not support any other calls than \c clang_reparseTranslationUnit
+ * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
+ */
+CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
+
+/**
  * \brief Destroy the specified CXTranslationUnit object.
  */
 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
___
cfe-commits mai

[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 98463.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Use getStorageDuration to decide how to emit a function-scope variable.


https://reviews.llvm.org/D32977

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  test/CodeGenOpenCL/constant-addr-space-globals.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -5,7 +5,7 @@
 int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
 global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
-void kernel foo() {
+void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
   static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
   static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}}
@@ -15,6 +15,12 @@
 
   auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
   global int L4;   // expected-error{{function scope variable cannot be declared in global address space}}
+
+  constant int L5 = x; // expected-error {{initializer element is not a compile-time constant}}
+  global int *constant L6 = &G4;
+  private int *constant L7 = &x; // expected-error {{initializer element is not a compile-time constant}}
+  constant int *constant L8 = &L1;
+  local int *constant L9 = &L2; // expected-error {{initializer element is not a compile-time constant}}
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
@@ -29,4 +35,7 @@
   }
   global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
   extern constant float L4;
+  extern local float L5; // expected-error{{extern variable must reside in constant address space}}
+  static int L6 = 0; // expected-error{{variables in function scope cannot be declared static}}
+  static int L7; // expected-error{{variables in function scope cannot be declared static}}
 }
Index: test/CodeGenOpenCL/constant-addr-space-globals.cl
===
--- test/CodeGenOpenCL/constant-addr-space-globals.cl
+++ test/CodeGenOpenCL/constant-addr-space-globals.cl
@@ -11,17 +11,21 @@
 // but create a copy in the original address space (unless a variable itself is
 // in the constant address space).
 
-void foo(constant const int *p1, const int *p2, const int *p3);
+void foo(constant int* p, constant const int *p1, const int *p2, const int *p3);
 // CHECK: @k.arr1 = internal addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3]
 // CHECK: @k.arr2 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 4, i32 5, i32 6]
 // CHECK: @k.arr3 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 7, i32 8, i32 9]
+// CHECK: @k.var1 = internal addrspace(2) constant i32 1
 kernel void k(void) {
   // CHECK-NOT: %arr1 = alloca [3 x i32]
   constant const int arr1[] = {1, 2, 3};
   // CHECK: %arr2 = alloca [3 x i32]
   const int arr2[] = {4, 5, 6};
   // CHECK: %arr3 = alloca [3 x i32]
   int arr3[] = {7, 8, 9};
 
-  foo(arr1, arr2, arr3);
+  constant int var1 = 1;
+  
+  // CHECK: call spir_func void @foo(i32 addrspace(2)* @k.var1, i32 addrspace(2)* getelementptr inbounds ([3 x i32], [3 x i32] addrspace(2)* @k.arr1, i32 0, i32 0)
+  foo(&var1, arr1, arr2, arr3);
 }
Index: test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
===
--- test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
+++ test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
@@ -80,21 +80,21 @@
   // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR4]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}}
   int *FuncVar4 = Tmp1;
 
-  // CHECK-DAG: ![[FUNCVAR5:[0-9]+]] = !DILocalVariable(name: "FuncVar5", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR5]], metadata ![[NONE:[0-9]+]]), !dbg !{{[0-9]+}}
-  global int *constant FuncVar5 = KernelArg0;
-  // CHECK-DAG: ![[FUNCVAR6:[0-9]+]] = !DILocalVariable(name: "FuncVar6", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[FUNCVAR6]], metadata ![[NONE]]), !dbg !{{[0-9]+}}
-  constant int *constant FuncVar6 = KernelArg1;
-  // CHECK-DAG: ![[FUNCVAR7:[0-9]+]] = !DILocalVariable(name: "FuncVar7", scope: !{

r302677 - [libclang] Introduce clang_Cursor_isExternalSymbol that provides info about decls marked with external_source_symbol attribute

2017-05-10 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Wed May 10 10:10:36 2017
New Revision: 302677

URL: http://llvm.org/viewvc/llvm-project?rev=302677&view=rev
Log:
[libclang] Introduce clang_Cursor_isExternalSymbol that provides info about 
decls marked with external_source_symbol attribute

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/get-cursor.m
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=302677&r1=302676&r2=302677&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed May 10 10:10:36 2017
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 38
+#define CINDEX_VERSION_MINOR 39
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -4081,6 +4081,23 @@ CINDEX_LINKAGE unsigned clang_Cursor_isO
 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
 
 /**
+ * \brief Returns non-zero if the given cursor points to a symbol marked with
+ * external_source_symbol attribute.
+ *
+ * \param language If non-NULL, and the attribute is present, will be set to
+ * the 'language' string from the attribute.
+ *
+ * \param definedIn If non-NULL, and the attribute is present, will be set to
+ * the 'definedIn' string from the attribute.
+ *
+ * \param isGenerated If non-NULL, and the attribute is present, will be set to
+ * non-zero is the 'generated_declaration' is set in the attribute.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
+   CXString *language, CXString *definedIn,
+   unsigned *isGenerated);
+
+/**
  * \brief Given a cursor that represents a declaration, return the associated
  * comment's source range.  The range may include multiple consecutive comments
  * with whitespace in between.

Modified: cfe/trunk/test/Index/get-cursor.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.m?rev=302677&r1=302676&r2=302677&view=diff
==
--- cfe/trunk/test/Index/get-cursor.m (original)
+++ cfe/trunk/test/Index/get-cursor.m Wed May 10 10:10:36 2017
@@ -154,6 +154,12 @@ SomeT someVar;
 typedef MY_TYPE2(SomeT2) { int x; };
 SomeT2 someVar2;
 
+#define GEN_DECL(mod_name) 
__attribute__((external_source_symbol(language="Swift", defined_in=mod_name, 
generated_declaration)))
+
+GEN_DECL("some_module")
+@interface ExtCls
+-(void)method;
+@end
 
 // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck 
-check-prefix=CHECK-PROP %s
 // CHECK-PROP: ObjCPropertyDecl=foo1:4:26
@@ -226,3 +232,8 @@ SomeT2 someVar2;
 // CHECK-TRANSPARENT: 147:1 TypeRef=TokenPaste_t:144:9 Extent=[147:1 - 147:13] 
Spelling=TokenPaste_t ([147:1 - 147:13])
 // CHECK-TRANSPARENT: 151:1 TypeRef=SomeT:150:17 (Transparent: struct SomeT) 
Extent=[151:1 - 151:6] Spelling=SomeT ([151:1 - 151:6])
 // CHECK-TRANSPARENT: 155:1 TypeRef=SomeT2:154:18 Extent=[155:1 - 155:7] 
Spelling=SomeT2 ([155:1 - 155:7])
+
+// RUN: c-index-test -cursor-at=%s:160:12 -cursor-at=%s:161:8 %s | FileCheck 
-check-prefix=CHECK-EXTERNAL %s
+// CHECK-EXTERNAL: 160:12 ObjCInterfaceDecl=ExtCls:160:12 (external lang: 
Swift, defined: some_module, gen: 1)
+// CHECK-EXTERNAL: 161:8 ObjCInstanceMethodDecl=method:161:8 (external lang: 
Swift, defined: some_module, gen: 1)
+C
\ No newline at end of file

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=302677&r1=302676&r2=302677&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed May 10 10:10:36 2017
@@ -809,6 +809,19 @@ static void PrintCursor(CXCursor Cursor,
 if (clang_Cursor_isObjCOptional(Cursor))
   printf(" (@optional)");
 
+{
+  CXString language;
+  CXString definedIn;
+  unsigned generated;
+  if (clang_Cursor_isExternalSymbol(Cursor, &language, &definedIn,
+&generated)) {
+printf(" (external lang: %s, defined: %s, gen: %d)",
+clang_getCString(language), clang_getCString(definedIn), 
generated);
+clang_disposeString(language);
+clang_disposeString(definedIn);
+  }
+}
+
 if (Cursor.kind == CXCursor_IBOutletCollectionAttr) {
   CXType T =
 clang_getCanonicalType(clang_getIBOutletCollectionType(Cursor));

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/vie

[PATCH] D26953: clang-format: handle formatting on constexpr if

2017-05-10 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

This looks good to me, thanks. Sorry about the slow turnaround. Do you have 
commit access? If not, I can land it for you – but it also looks like you've 
contributed several patches by now, so you could also ask for commit access if 
you don't have it yet.


https://reviews.llvm.org/D26953



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

A testcase would be nice... but otherwise, yes.


https://reviews.llvm.org/D32759



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D32759#751026, @efriedma wrote:

> A testcase would be nice... but otherwise, yes.


Do you have a suggestion on how to write one?  I wasn't able to find any 
situation that changed behavior with the different return values.


https://reviews.llvm.org/D32759



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The testcase I wrote should change behavior, I think.


https://reviews.llvm.org/D32759



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


[PATCH] D33045: [libclang] Avoid more stats than necessary for reparse.

2017-05-10 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Hmm, looks like libclang/libclangTests/LibclangReparseTest.ReparseWithModule is 
flaky?

FAIL: Clang-Unit :: 
libclang/libclangTests/LibclangReparseTest.ReparseWithModule (10699 of 10701)

- TEST 'Clang-Unit :: 
libclang/libclangTests/LibclangReparseTest.ReparseWithModule' FAILED 


Note: Google Test filter = LibclangReparseTest.ReparseWithModule
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from LibclangReparseTest
[ RUN  ] LibclangReparseTest.ReparseWithModule
LIBCLANG FATAL ERROR: Unexpected end of file



Testing Time: 61.30s



Failing Tests (1):

Clang-Unit :: libclang/libclangTests/LibclangReparseTest.ReparseWithModule
  
  Expected Passes: 10621
  Expected Failures  : 19
  Unsupported Tests  : 60
  Unexpected Failures: 1

tools/clang/test/CMakeFiles/check-clang.dir/build.make:57: recipe for target 
'tools/clang/test/CMakeFiles/check-clang' failed
make[3]: *** [tools/clang/test/CMakeFiles/check-clang] Error 1
CMakeFiles/Makefile2:33822: recipe for target 
'tools/clang/test/CMakeFiles/check-clang.dir/all' failed
make[2]: *** [tools/clang/test/CMakeFiles/check-clang.dir/all] Error 2
CMakeFiles/Makefile2:33829: recipe for target 
'tools/clang/test/CMakeFiles/check-clang.dir/rule' failed
make[1]: *** [tools/clang/test/CMakeFiles/check-clang.dir/rule] Error 2
Makefile:7932: recipe for target 'check-clang' failed
make: *** [check-clang] Error 2
zsh: exit 2 make check-clang


https://reviews.llvm.org/D33045



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D32759#751028, @efriedma wrote:

> The testcase I wrote should change behavior, I think.


Alright, I'll look into it again...


https://reviews.llvm.org/D32759



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


[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-05-10 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

In https://reviews.llvm.org/D31885#748889, @rjmccall wrote:

> Sounds to me like we should just not apply struct-path TBAA data that runs 
> through a union field because either LLVM's representation can't handle it or 
> Clang isn't generating the representation right.  That should be simple to do 
> in a targeted place in Clang rather than awkwardly doing it retroactively 
> like in the current patch.


The TBAA information seems to be assembled from several smaller pieces during 
code generation.  There is already a check for unions in EmitLValueForField, 
which turns off path TBAA information for union fields, but that is not 
sufficient to avoid problems.  Both testcases will still fail with this code in 
place (the C++ testcase needs to be updated: it's missing "-O2 -std=c++11").


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


r302682 - [libclang] Fix typo in doc-comment, NFC

2017-05-10 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Wed May 10 10:48:16 2017
New Revision: 302682

URL: http://llvm.org/viewvc/llvm-project?rev=302682&view=rev
Log:
[libclang] Fix typo in doc-comment, NFC

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=302682&r1=302681&r2=302682&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed May 10 10:48:16 2017
@@ -4091,7 +4091,7 @@ CINDEX_LINKAGE unsigned clang_Cursor_isV
  * the 'definedIn' string from the attribute.
  *
  * \param isGenerated If non-NULL, and the attribute is present, will be set to
- * non-zero is the 'generated_declaration' is set in the attribute.
+ * non-zero if the 'generated_declaration' is set in the attribute.
  */
 CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
CXString *language, CXString *definedIn,


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


[PATCH] D26953: clang-format: handle formatting on constexpr if

2017-05-10 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg added a comment.

In https://reviews.llvm.org/D26953#751021, @thakis wrote:

> This looks good to me, thanks. Sorry about the slow turnaround. Do you have 
> commit access? If not, I can land it for you – but it also looks like you've 
> contributed several patches by now, so you could also ask for commit access 
> if you don't have it yet.


Thank you for the review. As @gnzlbg pointed out here (PR28867) 
, I tested with 
`AllowShortIfStatementsOnASingleLine` and it does not seem to work as intended. 
I didn't have time to fix that yet, so I'll probably delay this for now. If 
anyone has time, feel free to fix + land this instead of me.


https://reviews.llvm.org/D26953



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


[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-05-10 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

I'm not intimately familiar with clang, so if you know about a better place for 
doing this, please let me know.


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


Re: r302677 - [libclang] Introduce clang_Cursor_isExternalSymbol that provides info about decls marked with external_source_symbol attribute

2017-05-10 Thread Alex L via cfe-commits
On 10 May 2017 at 16:10, Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: akirtzidis
> Date: Wed May 10 10:10:36 2017
> New Revision: 302677
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302677&view=rev
> Log:
> [libclang] Introduce clang_Cursor_isExternalSymbol that provides info
> about decls marked with external_source_symbol attribute
>
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/test/Index/get-cursor.m
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/libclang.exports
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang-c/Index.h?rev=302677&r1=302676&r2=302677&view=diff
> 
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Wed May 10 10:10:36 2017
> @@ -32,7 +32,7 @@
>   * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>   */
>  #define CINDEX_VERSION_MAJOR 0
> -#define CINDEX_VERSION_MINOR 38
> +#define CINDEX_VERSION_MINOR 39
>
>  #define CINDEX_VERSION_ENCODE(major, minor) ( \
>((major) * 1)   \
> @@ -4081,6 +4081,23 @@ CINDEX_LINKAGE unsigned clang_Cursor_isO
>  CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
>
>  /**
> + * \brief Returns non-zero if the given cursor points to a symbol marked
> with
> + * external_source_symbol attribute.
> + *
> + * \param language If non-NULL, and the attribute is present, will be set
> to
> + * the 'language' string from the attribute.
> + *
> + * \param definedIn If non-NULL, and the attribute is present, will be
> set to
> + * the 'definedIn' string from the attribute.
> + *
> + * \param isGenerated If non-NULL, and the attribute is present, will be
> set to
> + * non-zero is the 'generated_declaration' is set in the attribute.
> + */
> +CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
> +   CXString *language, CXString
> *definedIn,
> +   unsigned *isGenerated);
> +
> +/**
>   * \brief Given a cursor that represents a declaration, return the
> associated
>   * comment's source range.  The range may include multiple consecutive
> comments
>   * with whitespace in between.
>
> Modified: cfe/trunk/test/Index/get-cursor.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/
> get-cursor.m?rev=302677&r1=302676&r2=302677&view=diff
> 
> ==
> --- cfe/trunk/test/Index/get-cursor.m (original)
> +++ cfe/trunk/test/Index/get-cursor.m Wed May 10 10:10:36 2017
> @@ -154,6 +154,12 @@ SomeT someVar;
>  typedef MY_TYPE2(SomeT2) { int x; };
>  SomeT2 someVar2;
>
> +#define GEN_DECL(mod_name) __attribute__((external_
> source_symbol(language="Swift", defined_in=mod_name,
> generated_declaration)))
> +
> +GEN_DECL("some_module")
> +@interface ExtCls
> +-(void)method;
> +@end
>
>  // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck
> -check-prefix=CHECK-PROP %s
>  // CHECK-PROP: ObjCPropertyDecl=foo1:4:26
> @@ -226,3 +232,8 @@ SomeT2 someVar2;
>  // CHECK-TRANSPARENT: 147:1 TypeRef=TokenPaste_t:144:9 Extent=[147:1 -
> 147:13] Spelling=TokenPaste_t ([147:1 - 147:13])
>  // CHECK-TRANSPARENT: 151:1 TypeRef=SomeT:150:17 (Transparent: struct
> SomeT) Extent=[151:1 - 151:6] Spelling=SomeT ([151:1 - 151:6])
>  // CHECK-TRANSPARENT: 155:1 TypeRef=SomeT2:154:18 Extent=[155:1 - 155:7]
> Spelling=SomeT2 ([155:1 - 155:7])
> +
> +// RUN: c-index-test -cursor-at=%s:160:12 -cursor-at=%s:161:8 %s |
> FileCheck -check-prefix=CHECK-EXTERNAL %s
> +// CHECK-EXTERNAL: 160:12 ObjCInterfaceDecl=ExtCls:160:12 (external
> lang: Swift, defined: some_module, gen: 1)
> +// CHECK-EXTERNAL: 161:8 ObjCInstanceMethodDecl=method:161:8 (external
> lang: Swift, defined: some_module, gen: 1)
> +C
> \ No newline at end of file
>
> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-
> index-test/c-index-test.c?rev=302677&r1=302676&r2=302677&view=diff
> 
> ==
> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
> +++ cfe/trunk/tools/c-index-test/c-index-test.c Wed May 10 10:10:36 2017
> @@ -809,6 +809,19 @@ static void PrintCursor(CXCursor Cursor,
>  if (clang_Cursor_isObjCOptional(Cursor))
>printf(" (@optional)");
>
> +{
> +  CXString language;
> +  CXString definedIn;
> +  unsigned generated;
> +  if (clang_Cursor_isExternalSymbol(Cursor, &language, &definedIn,
> +&generated)) {
> +printf(" (external lang: %s, defined: %s, gen: %d)",
> +clang_getCString(language), clang_getCString(definedIn),
> generated)

r302685 - Build the Apple-style stage2 with full debug info

2017-05-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed May 10 10:58:22 2017
New Revision: 302685

URL: http://llvm.org/viewvc/llvm-project?rev=302685&view=rev
Log:
Build the Apple-style stage2 with full debug info

Green dragon had a green stage2 modules bot for a long time now[1] and
it is time to retire it and make a modules build the default for
Apple-style stage2 builds.

This patch switches the debug info generation from -gline-tables-only
to -g since full debug info does no longer cause any memory issues
even for full LTO builds [2].

[1] http://green.lab.llvm.org/green/job/clang-stage2-cmake-modulesRDA_build/
[2] http://llvm.org/devmtg/2015-10/#talk19
rdar://problem/28672159

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=302685&r1=302684&r2=302685&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Wed May 10 10:58:22 2017
@@ -29,8 +29,6 @@ set(LLVM_BUILD_TESTS ON CACHE BOOL "")
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common 
-Wno-profile-instr-unprofiled" CACHE STRING "")
 set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common 
-Wno-profile-instr-unprofiled" CACHE STRING "")
-set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 
 set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")


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


[PATCH] D33049: [libcxx] Support for Objective-C++ tests

2017-05-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

This patch adds lit testing support for Objective-C++. I'm going to be working 
on improving Objective-C++ support in libc++ this summer, and it would be nice 
to write tests. I tested this patch on Ubuntu 16.04 with gcc 5.4, and it works 
fine (the .mm tests become UNSUPPORTED).

Thanks for taking a look!
Erik


https://reviews.llvm.org/D33049

Files:
  test/libcxx/selftest/test.fail.mm
  test/libcxx/selftest/test.pass.mm
  utils/libcxx/compiler.py
  utils/libcxx/test/config.py
  utils/libcxx/test/format.py

Index: utils/libcxx/test/format.py
===
--- utils/libcxx/test/format.py
+++ utils/libcxx/test/format.py
@@ -87,9 +87,10 @@
 name_root, name_ext = os.path.splitext(name)
 is_libcxx_test = test.path_in_suite[0] == 'libcxx'
 is_sh_test = name_root.endswith('.sh')
-is_pass_test = name.endswith('.pass.cpp')
-is_fail_test = name.endswith('.fail.cpp')
-assert is_sh_test or name_ext == '.cpp', 'non-cpp file must be sh test'
+is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
+is_fail_test = name.endswith('.fail.cpp') or name.endswith('.fail.mm')
+assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
+'non-cpp file must be sh test'
 
 if test.config.unsupported:
 return (lit.Test.UNSUPPORTED,
@@ -133,6 +134,8 @@
 if '#define _LIBCPP_ASSERT' in contents:
 test_cxx.useModules(False)
 
+is_objcxx = name_ext == '.mm'
+
 # Dispatch the test based on its suffix.
 if is_sh_test:
 if not isinstance(self.executor, LocalExecutor):
@@ -144,19 +147,19 @@
  self.execute_external, script,
  tmpBase)
 elif is_fail_test:
-return self._evaluate_fail_test(test, test_cxx, parsers)
+return self._evaluate_fail_test(test, test_cxx, parsers, is_objcxx)
 elif is_pass_test:
 return self._evaluate_pass_test(test, tmpBase, lit_config,
-test_cxx, parsers)
+test_cxx, parsers, is_objcxx)
 else:
 # No other test type is supported
 assert False
 
 def _clean(self, exec_path):  # pylint: disable=no-self-use
 libcxx.util.cleanFile(exec_path)
 
 def _evaluate_pass_test(self, test, tmpBase, lit_config,
-test_cxx, parsers):
+test_cxx, parsers, is_objcxx):
 execDir = os.path.dirname(test.getExecPath())
 source_path = test.getSourcePath()
 exec_path = tmpBase + '.exe'
@@ -166,8 +169,8 @@
 try:
 # Compile the test
 cmd, out, err, rc = test_cxx.compileLinkTwoSteps(
-source_path, out=exec_path, object_file=object_path,
-cwd=execDir)
+source_path, is_objcxx=is_objcxx, out=exec_path,
+object_file=object_path, cwd=execDir)
 compile_cmd = cmd
 if rc != 0:
 report = libcxx.util.makeReport(cmd, out, err, rc)
@@ -206,7 +209,7 @@
 libcxx.util.cleanFile(object_path)
 self._clean(exec_path)
 
-def _evaluate_fail_test(self, test, test_cxx, parsers):
+def _evaluate_fail_test(self, test, test_cxx, parsers, is_objcxx):
 source_path = test.getSourcePath()
 # FIXME: lift this detection into LLVM/LIT.
 with open(source_path, 'r') as f:
@@ -227,7 +230,8 @@
 if '-Wuser-defined-warnings' in test_cxx.warning_flags:
 test_cxx.warning_flags += ['-Wno-error=user-defined-warnings']
 
-cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull)
+cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull,
+ is_objcxx=is_objcxx)
 expected_rc = 0 if use_verify else 1
 if rc == expected_rc:
 return lit.Test.PASS, ''
Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -462,6 +462,12 @@
 self.config.available_features.add('glibc-%s' % maj_v)
 self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
 
+# Support Objective-C++ only on MacOS and if the compiler supports it.
+if not self.target_info.platform() == "darwin" or \
+   not self.target_info.is_host_macosx() or \
+   not self.cxx.hasCompileFlag(["-x", "objective-c++", "-fobjc-arc"]):
+self.config.available_features.add("no-objective-cxx")
+
 def configure_compile_flags(self):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not n

[clang-tools-extra] r302688 - [clang-tidy][CMake] Make clang-tidy usable as distribution component

2017-05-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May 10 11:20:54 2017
New Revision: 302688

URL: http://llvm.org/viewvc/llvm-project?rev=302688&view=rev
Log:
[clang-tidy][CMake] Make clang-tidy usable as distribution component

Use add_clang_tool rather than add_clang_executable to support
clang-tidy as a distribution component.

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

Modified:
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=302688&r1=302687&r2=302688&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Wed May 10 11:20:54 
2017
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
   support
   )
 
-add_clang_executable(clang-tidy
+add_clang_tool(clang-tidy
   ClangTidyMain.cpp
   )
 add_dependencies(clang-tidy


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


r302689 - [AST] RecursiveASTVisitor should not crash on lambdas with type attributes

2017-05-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 10 11:21:00 2017
New Revision: 302689

URL: http://llvm.org/viewvc/llvm-project?rev=302689&view=rev
Log:
[AST] RecursiveASTVisitor should not crash on lambdas with type attributes

rdar://31960860

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=302689&r1=302688&r2=302689&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed May 10 11:21:00 2017
@@ -2326,7 +2326,7 @@ DEF_TRAVERSE_STMT(LambdaExpr, {
   }
 
   TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
-  FunctionProtoTypeLoc Proto = TL.castAs();
+  FunctionProtoTypeLoc Proto = TL.getAsAdjusted();
 
   if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
 // Visit the whole type.

Modified: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=302689&r1=302688&r2=302689&view=diff
==
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp Wed May 10 11:21:00 
2017
@@ -52,6 +52,14 @@ TEST(RecursiveASTVisitor, TraverseLambda
   EXPECT_TRUE(Visitor.allBodiesHaveBeenTraversed());
 }
 
+TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) {
+  LambdaExprVisitor Visitor;
+  Visitor.ExpectMatch("", 1, 12);
+  EXPECT_TRUE(Visitor.runOver(
+  "void f() { [] () __attribute__ (( fastcall )) { return; }(); }",
+  LambdaExprVisitor::Lang_CXX14));
+}
+
 // Matches the (optional) capture-default of a lambda-introducer.
 class LambdaDefaultCaptureVisitor
   : public ExpectedLocationVisitor {


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


[PATCH] D32815: [clang-tidy][CMake] Make clang-tidy usable as distribution component

2017-05-10 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302688: [clang-tidy][CMake] Make clang-tidy usable as 
distribution component (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D32815?vs=97683&id=98479#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32815

Files:
  clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt


Index: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
@@ -2,7 +2,7 @@
   support
   )
 
-add_clang_executable(clang-tidy
+add_clang_tool(clang-tidy
   ClangTidyMain.cpp
   )
 add_dependencies(clang-tidy


Index: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
@@ -2,7 +2,7 @@
   support
   )
 
-add_clang_executable(clang-tidy
+add_clang_tool(clang-tidy
   ClangTidyMain.cpp
   )
 add_dependencies(clang-tidy
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-10 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added a comment.

In https://reviews.llvm.org/D33021#750831, @mclow.lists wrote:

> FWIW, I think this is a language change that core got wrong, and it has 
> already come back to bite us. (https://bugs.llvm.org/show_bug.cgi?id=28527)


Hmm we actually took steps to do the opposite in std::copy -- to use memcpy 
even in the presence of volatile -- as a result of this change.

It looks like Core wasn't a fan of doing this either, but that the Itanium ABI 
forced their hand.


https://reviews.llvm.org/D33021



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


Re: r302677 - [libclang] Introduce clang_Cursor_isExternalSymbol that provides info about decls marked with external_source_symbol attribute

2017-05-10 Thread Argyrios Kyrtzidis via cfe-commits
That’s a good idea, if you don’t get to it I’ll look into it at some point 
later on but it will probably not be soon.

> On May 10, 2017, at 9:10 AM, Alex L  wrote:
> 
> 
> 
> On 10 May 2017 at 16:10, Argyrios Kyrtzidis via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: akirtzidis
> Date: Wed May 10 10:10:36 2017
> New Revision: 302677
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=302677&view=rev 
> 
> Log:
> [libclang] Introduce clang_Cursor_isExternalSymbol that provides info about 
> decls marked with external_source_symbol attribute
> 
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/test/Index/get-cursor.m
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/libclang.exports
> 
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=302677&r1=302676&r2=302677&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Wed May 10 10:10:36 2017
> @@ -32,7 +32,7 @@
>   * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>   */
>  #define CINDEX_VERSION_MAJOR 0
> -#define CINDEX_VERSION_MINOR 38
> +#define CINDEX_VERSION_MINOR 39
> 
>  #define CINDEX_VERSION_ENCODE(major, minor) ( \
>((major) * 1)   \
> @@ -4081,6 +4081,23 @@ CINDEX_LINKAGE unsigned clang_Cursor_isO
>  CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
> 
>  /**
> + * \brief Returns non-zero if the given cursor points to a symbol marked with
> + * external_source_symbol attribute.
> + *
> + * \param language If non-NULL, and the attribute is present, will be set to
> + * the 'language' string from the attribute.
> + *
> + * \param definedIn If non-NULL, and the attribute is present, will be set to
> + * the 'definedIn' string from the attribute.
> + *
> + * \param isGenerated If non-NULL, and the attribute is present, will be set 
> to
> + * non-zero is the 'generated_declaration' is set in the attribute.
> + */
> +CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
> +   CXString *language, CXString 
> *definedIn,
> +   unsigned *isGenerated);
> +
> +/**
>   * \brief Given a cursor that represents a declaration, return the associated
>   * comment's source range.  The range may include multiple consecutive 
> comments
>   * with whitespace in between.
> 
> Modified: cfe/trunk/test/Index/get-cursor.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.m?rev=302677&r1=302676&r2=302677&view=diff
>  
> 
> ==
> --- cfe/trunk/test/Index/get-cursor.m (original)
> +++ cfe/trunk/test/Index/get-cursor.m Wed May 10 10:10:36 2017
> @@ -154,6 +154,12 @@ SomeT someVar;
>  typedef MY_TYPE2(SomeT2) { int x; };
>  SomeT2 someVar2;
> 
> +#define GEN_DECL(mod_name) 
> __attribute__((external_source_symbol(language="Swift", defined_in=mod_name, 
> generated_declaration)))
> +
> +GEN_DECL("some_module")
> +@interface ExtCls
> +-(void)method;
> +@end
> 
>  // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck 
> -check-prefix=CHECK-PROP %s
>  // CHECK-PROP: ObjCPropertyDecl=foo1:4:26
> @@ -226,3 +232,8 @@ SomeT2 someVar2;
>  // CHECK-TRANSPARENT: 147:1 TypeRef=TokenPaste_t:144:9 Extent=[147:1 - 
> 147:13] Spelling=TokenPaste_t ([147:1 - 147:13])
>  // CHECK-TRANSPARENT: 151:1 TypeRef=SomeT:150:17 (Transparent: struct SomeT) 
> Extent=[151:1 - 151:6] Spelling=SomeT ([151:1 - 151:6])
>  // CHECK-TRANSPARENT: 155:1 TypeRef=SomeT2:154:18 Extent=[155:1 - 155:7] 
> Spelling=SomeT2 ([155:1 - 155:7])
> +
> +// RUN: c-index-test -cursor-at=%s:160:12 -cursor-at=%s:161:8 %s | FileCheck 
> -check-prefix=CHECK-EXTERNAL %s
> +// CHECK-EXTERNAL: 160:12 ObjCInterfaceDecl=ExtCls:160:12 (external lang: 
> Swift, defined: some_module, gen: 1)
> +// CHECK-EXTERNAL: 161:8 ObjCInstanceMethodDecl=method:161:8 (external lang: 
> Swift, defined: some_module, gen: 1)
> +C
> \ No newline at end of file
> 
> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=302677&r1=302676&r2=302677&view=diff
>  
> 
> ==
> --- cfe/trunk/tools/c-index-test/c-inde

[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-05-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The right fix is probably just to make sure that EmitLValueForField doesn't add 
TBAA information when the base LValue doesn't have it.  That will also fix 
problems with recursive member access where the base is may_alias.


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-10 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added a comment.

In https://reviews.llvm.org/D33021#751145, @BillyONeal wrote:

> Hmm we actually took steps to do the opposite in std::copy -- to use 
> memcpy even in the presence of volatile -- as a result of this change.


;) http://imgur.com/a/PMKPS


https://reviews.llvm.org/D33021



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


[PATCH] D33030: [libcxxabi] Align unwindHeader on a double-word boundary

2017-05-10 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Something still isn't clear to me: the issue IIUC is not with the 
`unwindHeader` itself, but with the misaligned thrown object that is allocated 
right after the __cxa_exception itself. Isn't it?

Then are you aligning the `unwindHeader` field and by side-effect the size of 
the __cxa_exception structure becomes aligned and then the thrown object will 
be as well?


https://reviews.llvm.org/D33030



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


[PATCH] D33053: [PowerPC] Implement vec_xxpermdi builtin.

2017-05-10 Thread Tony Jiang via Phabricator via cfe-commits
jtony created this revision.

The vec_xxpermdi builtin is missing from altivec.h. This has been requested by 
developers working on libvpx for VP9 support for Google.  Initially, I tried to 
define a new intrinsic to map it to the corresponding PowerPC hard instruction 
(XXPERMDI) directly. But there was feedback from the community that this can be 
done without introducing new intrinsic.  This patch re-implement the 
vec_xxpermdi builtin by using the existing shuffleVector instruction just in 
the FE.


https://reviews.llvm.org/D33053

Files:
  include/clang/Basic/BuiltinsPPC.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/altivec.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins-ppc-error.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -1691,4 +1691,44 @@
   res_vd = vec_neg(vd);
 // CHECK: fsub <2 x double> , {{%[0-9]+}}
 // CHECK-LE: fsub <2 x double> , {{%[0-9]+}}
+
+res_vd = vec_xxpermdi(vd, vd, 0);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vf = vec_xxpermdi(vf, vf, 1);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vsll = vec_xxpermdi(vsll, vsll, 2);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vull = vec_xxpermdi(vull, vull, 3);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vsi = vec_xxpermdi(vsi, vsi, 0);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vui = vec_xxpermdi(vui, vui, 1);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vss = vec_xxpermdi(vss, vss, 2);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vus = vec_xxpermdi(vus, vus, 3);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vsc = vec_xxpermdi(vsc, vsc, 0);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vuc = vec_xxpermdi(vuc, vuc, 1);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
 }
Index: test/CodeGen/builtins-ppc-error.c
===
--- test/CodeGen/builtins-ppc-error.c
+++ test/CodeGen/builtins-ppc-error.c
@@ -13,8 +13,17 @@
 extern vector signed int vsi;
 extern vector unsigned char vuc;
 
-void testInsertWord1(void) {
+void testInsertWord(void) {
   int index = 5;
   vector unsigned char v1 = vec_insert4b(vsi, vuc, index); // expected-error {{argument to '__builtin_vsx_insertword' must be a constant integer}}
   vector unsigned long long v2 = vec_extract4b(vuc, index);   // expected-error {{argument to '__builtin_vsx_extractuword' must be a constant integer}}
 }
+
+void testXXPERMDI(void) {
+  int index = 5;
+  vec_xxpermdi(vsi); //expected-error {{too few arguments to function call, expected at least 3, have 1}}
+  vec_xxpermdi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected at most 3, have 4}}
+  vec_xxpermdi(vsi, vsi, index); //expected-error {{third argument to '__builtin_vsx_xxpermdi' must be a constant integer between 0-3}}
+  vec_xxpermdi(vsi, vsi, -1); //expected-error {{third argument to '__builtin_vsx_xxpermdi' must be a constant integer between 0-3}}
+  vec_xxpermdi(vsi, vuc, 2); //expected-error {{first two arguments to '__builtin_vsx_xxpermdi' must be the same type}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1696,6 +1696,8 @@
   case PPC::BI__builtin_tabortdci:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
+  case PPC::BI__builtin_vsx_xxpermdi:
+return SemaBuiltinVSX(TheCall, 3);
   }
   return SemaBuiltinConstantArgRange(TheCall, i, l, u

[PATCH] D32891: [Sema][ObjC++] Objective-C++ support for __is_base_of(B, D)

2017-05-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302695: [Sema] Objective-C++ support for type trait 
__is_base_of (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D32891?vs=97905&id=98490#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32891

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaObjCXX/is-base-of.mm


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -4720,10 +4720,24 @@
 // regard to cv-qualifiers.
 
 const RecordType *lhsRecord = LhsT->getAs();
-if (!lhsRecord) return false;
-
 const RecordType *rhsRecord = RhsT->getAs();
-if (!rhsRecord) return false;
+if (!rhsRecord || !lhsRecord) {
+  const ObjCObjectType *LHSObjTy = LhsT->getAs();
+  const ObjCObjectType *RHSObjTy = RhsT->getAs();
+  if (!LHSObjTy || !RHSObjTy)
+return false;
+
+  ObjCInterfaceDecl *BaseInterface = LHSObjTy->getInterface();
+  ObjCInterfaceDecl *DerivedInterface = RHSObjTy->getInterface();
+  if (!BaseInterface || !DerivedInterface)
+return false;
+
+  if (Self.RequireCompleteType(
+  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+return false;
+
+  return BaseInterface->isSuperClassOf(DerivedInterface);
+}
 
 assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT)
  == (lhsRecord == rhsRecord));
Index: cfe/trunk/test/SemaObjCXX/is-base-of.mm
===
--- cfe/trunk/test/SemaObjCXX/is-base-of.mm
+++ cfe/trunk/test/SemaObjCXX/is-base-of.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+@interface NSObj
+@end
+
+@interface NSChild : NSObj
+@end
+
+static_assert(__is_base_of(NSObj, NSChild), "");
+static_assert(!__is_base_of(NSChild, NSObj), "");
+
+static_assert(__is_base_of(NSObj, NSObj), "");
+
+static_assert(!__is_base_of(NSObj *, NSChild *), "");
+static_assert(!__is_base_of(NSChild *, NSObj *), "");
+
+static_assert(__is_base_of(const volatile NSObj, NSChild), "");
+static_assert(__is_base_of(NSObj, const volatile NSChild), "");
+
+@class NSForward; // expected-note{{forward declaration of class}}
+
+static_assert(!__is_base_of(NSForward, NSObj), "");
+static_assert(!__is_base_of(NSObj, NSForward), ""); // 
expected-error{{incomplete type 'NSForward'}}
+
+static_assert(!__is_base_of(id, NSObj), "");


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -4720,10 +4720,24 @@
 // regard to cv-qualifiers.
 
 const RecordType *lhsRecord = LhsT->getAs();
-if (!lhsRecord) return false;
-
 const RecordType *rhsRecord = RhsT->getAs();
-if (!rhsRecord) return false;
+if (!rhsRecord || !lhsRecord) {
+  const ObjCObjectType *LHSObjTy = LhsT->getAs();
+  const ObjCObjectType *RHSObjTy = RhsT->getAs();
+  if (!LHSObjTy || !RHSObjTy)
+return false;
+
+  ObjCInterfaceDecl *BaseInterface = LHSObjTy->getInterface();
+  ObjCInterfaceDecl *DerivedInterface = RHSObjTy->getInterface();
+  if (!BaseInterface || !DerivedInterface)
+return false;
+
+  if (Self.RequireCompleteType(
+  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+return false;
+
+  return BaseInterface->isSuperClassOf(DerivedInterface);
+}
 
 assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT)
  == (lhsRecord == rhsRecord));
Index: cfe/trunk/test/SemaObjCXX/is-base-of.mm
===
--- cfe/trunk/test/SemaObjCXX/is-base-of.mm
+++ cfe/trunk/test/SemaObjCXX/is-base-of.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+@interface NSObj
+@end
+
+@interface NSChild : NSObj
+@end
+
+static_assert(__is_base_of(NSObj, NSChild), "");
+static_assert(!__is_base_of(NSChild, NSObj), "");
+
+static_assert(__is_base_of(NSObj, NSObj), "");
+
+static_assert(!__is_base_of(NSObj *, NSChild *), "");
+static_assert(!__is_base_of(NSChild *, NSObj *), "");
+
+static_assert(__is_base_of(const volatile NSObj, NSChild), "");
+static_assert(__is_base_of(NSObj, const volatile NSChild), "");
+
+@class NSForward; // expected-note{{forward declaration of class}}
+
+static_assert(!__is_base_of(NSForward, NSObj), "");
+static_assert(!__is_base_of(NSObj, NSForward), ""); // expected-error{{incomplete type 'NSForward'}}
+
+static_assert(!__is_base_of(id, NSObj), "");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302695 - [Sema] Objective-C++ support for type trait __is_base_of

2017-05-10 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed May 10 12:18:56 2017
New Revision: 302695

URL: http://llvm.org/viewvc/llvm-project?rev=302695&view=rev
Log:
[Sema] Objective-C++ support for type trait __is_base_of

rdar://24308607

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

Added:
cfe/trunk/test/SemaObjCXX/is-base-of.mm
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=302695&r1=302694&r2=302695&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed May 10 12:18:56 2017
@@ -4720,10 +4720,24 @@ static bool EvaluateBinaryTypeTrait(Sema
 // regard to cv-qualifiers.
 
 const RecordType *lhsRecord = LhsT->getAs();
-if (!lhsRecord) return false;
-
 const RecordType *rhsRecord = RhsT->getAs();
-if (!rhsRecord) return false;
+if (!rhsRecord || !lhsRecord) {
+  const ObjCObjectType *LHSObjTy = LhsT->getAs();
+  const ObjCObjectType *RHSObjTy = RhsT->getAs();
+  if (!LHSObjTy || !RHSObjTy)
+return false;
+
+  ObjCInterfaceDecl *BaseInterface = LHSObjTy->getInterface();
+  ObjCInterfaceDecl *DerivedInterface = RHSObjTy->getInterface();
+  if (!BaseInterface || !DerivedInterface)
+return false;
+
+  if (Self.RequireCompleteType(
+  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+return false;
+
+  return BaseInterface->isSuperClassOf(DerivedInterface);
+}
 
 assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT)
  == (lhsRecord == rhsRecord));

Added: cfe/trunk/test/SemaObjCXX/is-base-of.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/is-base-of.mm?rev=302695&view=auto
==
--- cfe/trunk/test/SemaObjCXX/is-base-of.mm (added)
+++ cfe/trunk/test/SemaObjCXX/is-base-of.mm Wed May 10 12:18:56 2017
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+@interface NSObj
+@end
+
+@interface NSChild : NSObj
+@end
+
+static_assert(__is_base_of(NSObj, NSChild), "");
+static_assert(!__is_base_of(NSChild, NSObj), "");
+
+static_assert(__is_base_of(NSObj, NSObj), "");
+
+static_assert(!__is_base_of(NSObj *, NSChild *), "");
+static_assert(!__is_base_of(NSChild *, NSObj *), "");
+
+static_assert(__is_base_of(const volatile NSObj, NSChild), "");
+static_assert(__is_base_of(NSObj, const volatile NSChild), "");
+
+@class NSForward; // expected-note{{forward declaration of class}}
+
+static_assert(!__is_base_of(NSForward, NSObj), "");
+static_assert(!__is_base_of(NSObj, NSForward), ""); // 
expected-error{{incomplete type 'NSForward'}}
+
+static_assert(!__is_base_of(id, NSObj), "");


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


New gcc6 builder with -DLLVM_ENABLE_WERROR=ON

2017-05-10 Thread Galina Kistanova via cfe-commits
Hello everyone,

I'm about to set up a new builder which would build LLVM and Clang with
gcc-6 and -DLLVM_ENABLE_WERROR=ON.

Please find the staged builder connected to the silent master. Currently it
shows 14 warnings we would need to resolve before we could promote the
builder to the production.

http://lab.llvm.org:8014/builders/test-builder/builds/64

The files with warnings are:

llvm/utils/TableGen/AsmMatcherEmitter.cpp
llvm/lib/Fuzzer/FuzzerIOPosix.cpp
llvm/lib/Fuzzer/FuzzerMutate.cpp
llvm/unittests/Support/AlignOfTest.cpp
llvm/unittests/ProfileData/CoverageMappingTest.cpp
llvm/unittests/ProfileData/InstrProfTest.cpp
llvm/unittests/Support/MemoryTest.cpp
llvm/unittests/Support/Path.cpp
llvm/utils/unittest/googlemock/include/gmock/gmock-spec-builders.h

Would you take a look if that is in the area you own or interested in,
please?

I'll take care for the warnings nobody else would claim.

Thanks

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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-10 Thread Ryan Stringham via Phabricator via cfe-commits
stringham added a comment.

1. be used in a project of significant size (have dozens of contributors)
  - We are using this at Lucid Software (https://www.lucidchart.com & 
https://www.lucidpress.com) to format our JS and TS (we are using clang-format 
to automatically style over 650,000 lines of code)
  - It's not open source, but we do have dozens of contributors

2. have a publicly accessible style guide
  - We don't have a publicly available style guide, but here is Airbnb's 
Javascript Style guide's style definition which uses the dangling parens:
- 
https://github.com/airbnb/javascript#functions--signature-invocation-indentation
- I think this counts as a project of significant size with a publicly 
available style guide which would use this style rule.

3. have a person willing to contribute and maintain patches
  - Me
  - We currently have a fork of clang on github 
(https://github.com/lucidsoftware/clang) with this patch applied


https://reviews.llvm.org/D33029



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


[libcxxabi] r302698 - Fix use of now removed %exec test substitution

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 12:52:53 2017
New Revision: 302698

URL: http://llvm.org/viewvc/llvm-project?rev=302698&view=rev
Log:
Fix use of now removed %exec test substitution

Modified:
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s

Modified: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s?rev=302698&r1=302697&r2=302698&view=diff
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s 
(original)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s Wed 
May 10 12:52:53 2017
@@ -1,5 +1,5 @@
 @ RUN: %cxx %flags %link_flags %s -o %t.exe
-@ RUN: %exec %t.exe
+@ RUN: %t.exe
 @ UNSUPPORTED: libcxxabi-no-exceptions
 
 @ PURPOSE: Check that 0x00 is a valid value for ttype encoding.  LLVM and

Modified: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s?rev=302698&r1=302697&r2=302698&view=diff
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s 
(original)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s Wed 
May 10 12:52:53 2017
@@ -1,5 +1,5 @@
 @ RUN: %cxx %flags %link_flags %s -o %t.exe
-@ RUN: %exec %t.exe
+@ RUN: %t.exe
 @ UNSUPPORTED: libcxxabi-no-exceptions
 
 @ PURPOSE: Check that 0x90 is a valid value for ttype encoding.


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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 98495.
erichkeane added a reviewer: eli.friedman.
erichkeane added a comment.

Added a test, found a slight difference in behavior!


https://reviews.llvm.org/D32759

Files:
  lib/Sema/SemaType.cpp
  test/SemaObjC/method-bad-param.m


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2285,8 +2285,9 @@
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;
Index: test/SemaObjC/method-bad-param.m
===
--- test/SemaObjC/method-bad-param.m
+++ test/SemaObjC/method-bad-param.m
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared 
here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be 
passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned 
by value; did you forget * in 'foo'}}
 


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2285,8 +2285,9 @@
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;
Index: test/SemaObjC/method-bad-param.m
===
--- test/SemaObjC/method-bad-param.m
+++ test/SemaObjC/method-bad-param.m
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32981: [ASTImporter] Improve handling of incomplete types

2017-05-10 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 98497.
spyffe added a comment.

• Added a FIXME per Aleksei Sidorin's suggestion.


https://reviews.llvm.org/D32981

Files:
  include/clang/AST/ExternalASTMerger.h
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/ExternalASTMerger.cpp
  test/Import/conflicting-struct/Inputs/S1.cpp
  test/Import/conflicting-struct/Inputs/S2.cpp
  test/Import/conflicting-struct/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -42,6 +42,10 @@
 Imports("import", llvm::cl::ZeroOrMore,
 llvm::cl::desc("Path to a file containing declarations to import"));
 
+static llvm::cl::opt
+Direct("direct", llvm::cl::Optional,
+ llvm::cl::desc("Use the parsed declarations without indirection"));
+
 static llvm::cl::list
 ClangArgs("Xcc", llvm::cl::ZeroOrMore,
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -172,6 +176,14 @@
   return Ins;
 }
 
+std::unique_ptr
+BuildCompilerInstance(ArrayRef ClangArgs) {
+  std::vector ClangArgv(ClangArgs.size());
+  std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
+ [](const std::string &s) -> const char * { return s.data(); });
+  return init_convenience::BuildCompilerInstance(ClangArgv);
+}
+
 std::unique_ptr
 BuildASTContext(CompilerInstance &CI, SelectorTable &ST, Builtin::Context &BC) {
   auto AST = llvm::make_unique(
@@ -205,6 +217,21 @@
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
 }
 
+std::unique_ptr BuildIndirect(std::unique_ptr &CI) {
+  std::vector ClangArgv(ClangArgs.size());
+  std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
+ [](const std::string &s) -> const char * { return s.data(); });
+  std::unique_ptr IndirectCI =
+  init_convenience::BuildCompilerInstance(ClangArgv);
+  auto ST = llvm::make_unique();
+  auto BC = llvm::make_unique();
+  std::unique_ptr AST =
+  init_convenience::BuildASTContext(*IndirectCI, *ST, *BC);
+  IndirectCI->setASTContext(AST.release());
+  AddExternalSource(*IndirectCI, CI);
+  return IndirectCI;
+}
+
 llvm::Error ParseSource(const std::string &Path, CompilerInstance &CI,
 CodeGenerator &CG) {
   SourceManager &SM = CI.getSourceManager();
@@ -231,7 +258,9 @@
   std::unique_ptr AST =
   init_convenience::BuildASTContext(*CI, *ST, *BC);
   CI->setASTContext(AST.release());
-  AddExternalSource(*CI, Imports);
+  if (Imports.size()) {
+AddExternalSource(*CI, Imports);
+  }
 
   auto LLVMCtx = llvm::make_unique();
   std::unique_ptr CG =
@@ -268,12 +297,26 @@
   ImportCIs.push_back(std::move(*ImportCI));
 }
   }
+  std::vector> IndirectCIs;
+  if (!Direct) {
+for (auto &ImportCI : ImportCIs) {
+  llvm::Expected> IndirectCI =
+  BuildIndirect(ImportCI);
+  if (auto E = IndirectCI.takeError()) {
+llvm::errs() << llvm::toString(std::move(E));
+exit(-1);
+  } else {
+IndirectCIs.push_back(std::move(*IndirectCI));
+  }
+}
+  }
   llvm::Expected> ExpressionCI =
-  Parse(Expression, ImportCIs);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
   } else {
 return 0;
   }
 }
+
Index: test/Import/conflicting-struct/test.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/test.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-import-test --import %S/Inputs/S1.cpp --import %S/Inputs/S2.cpp -expression %s
+void expr() {
+  S MyS;
+  T MyT;
+  MyS.a = 3;
+  MyT.u.b = 2;
+}
Index: test/Import/conflicting-struct/Inputs/S2.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/Inputs/S2.cpp
@@ -0,0 +1,7 @@
+class U {
+  int b;
+};
+
+class T {
+  U u;
+};
Index: test/Import/conflicting-struct/Inputs/S1.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/Inputs/S1.cpp
@@ -0,0 +1,6 @@
+class T;
+
+class S {
+  T *t;
+  int a;
+};
Index: lib/AST/ExternalASTMerger.cpp
===
--- lib/AST/ExternalASTMerger.cpp
+++ lib/AST/ExternalASTMerger.cpp
@@ -178,3 +178,9 @@
 }
   });
 }
+
+void ExternalASTMerger::CompleteType(TagDecl *Tag) {
+  SmallVector Result;
+  FindExternalLexicalDecls(Tag, [](Decl::Kind) { return true; }, Result);
+  Tag->setHasExternalLexicalStorage(false);
+}
Index: lib/AST/ASTStructuralEquivalence.cpp
===
--- lib/AST/ASTStructuralEquivalence.cpp
+++ lib/AST

[PATCH] D32981: [ASTImporter] Improve handling of incomplete types

2017-05-10 Thread Sean Callanan via Phabricator via cfe-commits
spyffe marked an inline comment as done.
spyffe added inline comments.



Comment at: lib/AST/ASTImporter.cpp:1757
   D2->setAnonymousStructOrUnion(true);
+if (PrevDecl) {
+  D2->setPreviousDecl(PrevDecl);

a.sidorin wrote:
> By the way, should we do the same for some other kinds of Decls (like 
> FunctionDecl)? If so, could you write a NOTE comment?
I added this as a `FIXME`, in the style of the other notes about incomplete 
implementation in this file.


https://reviews.llvm.org/D32981



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


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7291
+  Address adjustAddrSpaceForAutoVar(Address A, const VarDecl *VD,
+  CodeGen::CodeGenFunction &CGF) const override;
 };

How about, instead of introducing a second method, we just change 
performAddrSpaceCast to take two AST address spaces and a flag indicating 
whether the address is known to be non-null?  Does your target have an 
AST-level address space for the stack?


https://reviews.llvm.org/D32248



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


[PATCH] D32332: Add support for transparent overloadable functions in clang

2017-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ItaniumMangle.cpp:583
+// Non-transparent overloadable functions need mangling.
+if (auto *A = FD->getAttr())
+  if (!A->isTransparent())

`const auto *`



Comment at: lib/AST/MicrosoftMangle.cpp:372
+// Non-transparent overloadable functions need mangling.
+if (auto *A = FD->getAttr())
+  if (!A->isTransparent())

`const auto *`



Comment at: lib/Sema/SemaDecl.cpp:2820
+for (const Decl *ND : Base->redecls())
+  if (auto *Ovl = ND->getAttr())
+if (!Ovl->isImplicit())

`const auto *`



Comment at: lib/Sema/SemaDecl.cpp:2921
+  const auto *NewOvl = New->getAttr();
+  if (NewOvl->isTransparent() != OldOvl->isTransparent()) {
+assert(!NewOvl->isImplicit() &&

Can `NewOvl` be null here (in an error case)?



Comment at: lib/Sema/SemaDecl.cpp:9303
+  } else if (!getLangOpts().CPlusPlus) {
+if (auto *NewOvl = NewFD->getAttr()) {
+  if (NewOvl->isTransparent()) {

`const auto *`



Comment at: lib/Sema/SemaDecl.cpp:9306-9307
+auto Transparent = llvm::find_if(Previous, [](const NamedDecl *ND) {
+  if (auto *FD = dyn_cast(ND))
+if (auto *Ovl =
+FD->getMostRecentDecl()->getAttr())

`const auto *` in both places.



Comment at: test/Sema/overloadable.c:189
+  void to_foo5(int) __attribute__((overloadable)); // expected-note {{previous 
overload}}
+  void to_foo5(int) __attribute__((transparently_overloadable)); // 
expected-error{{mismatched transparency}}
+

george.burgess.iv wrote:
> aaron.ballman wrote:
> > Why should this be a mismatch? Attributes can usually be added to 
> > redeclarations without an issue, and it's not unheard of for subsequent 
> > redeclarations to gain additional attributes. It seems like the behavior 
> > the user would expect from this is for the `transparently_overloadable` 
> > attribute to "win" and simply replaces, or silently augments, the 
> > `overloadable` attribute.
> my issue with this was:
> 
> ```
> // foo.h
> void foo(int) __attribute__((overloadable));
> 
> // foo.c
> void foo(int) __attribute__((overloadable)) {}
> 
> // bar.c
> #include "foo.h"
> 
> void foo(int) __attribute__((transparently_overloadable));
> 
> // calls to foo(int) now silently call @foo instead of the mangled version, 
> but only in this TU
> ```
> 
> though, i suppose this code going against our guidance of "overloads should 
> generally have internal linkage", and it's already possible to get yourself 
> in a similar situation today. so, as long as we don't allow `overloadable` to 
> "win" against `transparently_overloadable`, i'm OK with this.
Hmm, I can see how your example might cause confusion for the user as well. 
Perhaps downgrading it from an error to a warning and maybe putting something 
in the docs about why that warning could lead to bad things would be a good 
approach?


https://reviews.llvm.org/D32332



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Our behavior for your testcase is less than ideal (we should be generating an 
invalid declaration instead of just dropping it on the floor), but that's not 
something you need to fix here.

Could you also include the Objective-C++ testcase I wrote?  Or does it not work 
the way I expected?


https://reviews.llvm.org/D32759



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


[libcxx] r302707 - [test] support machinery changes for EDG & C1XX /Za

2017-05-10 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Wed May 10 14:10:49 2017
New Revision: 302707

URL: http://llvm.org/viewvc/llvm-project?rev=302707&view=rev
Log:
[test] support machinery changes for EDG & C1XX /Za

This change works around a couple of bugs:

1. EDG doesn't like explicit constexpr in a derived class. This program:

  struct Base {};
  struct Derived : Base {
  constexpr Derived() = default;
  };

  triggers "error: defaulted default constructor cannot be constexpr."

2. C1XX with /Za has no idea which constructor needs to be valid for copy 
elision.

The change also conditionally disables parts of the 
msvc_stdlib_force_include.hpp header that conflict with external configuration 
when _LIBCXX_IN_DEVCRT is defined.

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

Added:

libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
Modified:
libcxx/trunk/test/support/archetypes.hpp
libcxx/trunk/test/support/archetypes.ipp
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
libcxx/trunk/test/support/test_macros.h
libcxx/trunk/test/support/test_workarounds.h

Modified: libcxx/trunk/test/support/archetypes.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.hpp?rev=302707&r1=302706&r2=302707&view=diff
==
--- libcxx/trunk/test/support/archetypes.hpp (original)
+++ libcxx/trunk/test/support/archetypes.hpp Wed May 10 14:10:49 2017
@@ -5,6 +5,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 #if TEST_STD_VER >= 11
 
@@ -14,7 +15,9 @@ template 
 struct DepType : T {};
 
 struct NullBase {
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;
   NullBase(NullBase const&) = default;
   NullBase& operator=(NullBase const&) = default;
@@ -81,7 +84,9 @@ struct TestBase {
   ++assigned; ++value_assigned;
   return *this;
 }
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 ~TestBase() {
   assert(value != -999); assert(alive > 0);
   --alive; ++destroyed; value = -999;
@@ -144,7 +149,9 @@ struct ValueBase {
 }
 //~ValueBase() { assert(value != -999); value = -999; }
 int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
   return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
@@ -197,7 +204,9 @@ struct TrivialValueBase {
 template ::type = true>
 constexpr TrivialValueBase(std::initializer_list& il, int = 0) : 
value(static_cast(il.size())) {}
 int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 constexpr TrivialValueBase() noexcept : value(0) {}
 };
 

Modified: libcxx/trunk/test/support/archetypes.ipp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.ipp?rev=302707&r1=302706&r2=302707&view=diff
==
--- libcxx/trunk/test/support/archetypes.ipp (original)
+++ libcxx/trunk/test/support/archetypes.ipp Wed May 10 14:10:49 2017
@@ -6,7 +6,11 @@
 #define DEFINE_EXPLICIT
 #endif
 #ifndef DEFINE_CONSTEXPR
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #define DEFINE_CONSTEXPR constexpr
+#endif // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #endif
 #ifndef DEFINE_ASSIGN_CONSTEXPR
 #if TEST_STD_VER >= 14

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=302707&r1=302706&r2=302707&view=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Wed May 10 14:10:49 
2017
@@ -13,11 +13,13 @@
 // This header is force-included when running the libc++ tests against the
 // MSVC standard library.
 
-// Silence warnings about CRT machinery.
-#define _CRT_SECURE_NO_WARNINGS
-
-// Avoid assertion dialogs.
-#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#ifndef _LIBCXX_IN_DEVCRT
+// Silence warnings about CRT machinery.
+#define _CRT_SECURE_NO_WARNINGS
+
+// Avoid assertion dialogs.
+#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#endif // _LIBCXX_IN_DEVCRT
 
 #include 
 #include 
@@ -31,6 +33,7 @@
 #define _MSVC_STL_VER 42
 #endif
 
+#ifndef _LIBCXX_IN_DEVCRT
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
@@ -42,6 +45,7 @@ struct AssertionDialogAvoider {
 };
 
 cons

[PATCH] D32778: [libcxx] [test] Conditionally workaround C1XX/EDG bugs

2017-05-10 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302707: [test] support machinery changes for EDG & C1XX /Za 
(authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32778?vs=97530&id=98503#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32778

Files:
  libcxx/trunk/test/support/archetypes.hpp
  libcxx/trunk/test/support/archetypes.ipp
  libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
  libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
  libcxx/trunk/test/support/test_macros.h
  libcxx/trunk/test/support/test_workarounds.h

Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -52,10 +52,12 @@
 #define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
 #endif
 
-#if defined(__clang__)
-#define TEST_COMPILER_CLANG
+#if defined(__EDG__)
+# define TEST_COMPILER_EDG
+#elif defined(__clang__)
+# define TEST_COMPILER_CLANG
 # if defined(__apple_build_version__)
-#   define TEST_COMPILER_APPLE_CLANG
+#  define TEST_COMPILER_APPLE_CLANG
 # endif
 #elif defined(_MSC_VER)
 # define TEST_COMPILER_C1XX
Index: libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
===
--- libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
+++ libcxx/trunk/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
@@ -0,0 +1,41 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct X {
+X(int) {}
+
+X(X&&) = default;
+X& operator=(X&&) = default;
+
+private:
+X(const X&) = default;
+X& operator=(const X&) = default;
+};
+
+void PushFront(X&&) {}
+
+template
+auto test(int) -> decltype(PushFront(std::declval()), std::true_type{});
+auto test(long) -> std::false_type;
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK)
+static_assert(!decltype(test(0))::value, "");
+#else
+static_assert(decltype(test(0))::value, "");
+#endif
+}
Index: libcxx/trunk/test/support/test_workarounds.h
===
--- libcxx/trunk/test/support/test_workarounds.h
+++ libcxx/trunk/test/support/test_workarounds.h
@@ -13,9 +13,16 @@
 
 #include "test_macros.h"
 
+#if defined(TEST_COMPILER_EDG)
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#endif
+
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# ifndef _MSC_EXTENSIONS
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+# endif
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: libcxx/trunk/test/support/archetypes.ipp
===
--- libcxx/trunk/test/support/archetypes.ipp
+++ libcxx/trunk/test/support/archetypes.ipp
@@ -6,7 +6,11 @@
 #define DEFINE_EXPLICIT
 #endif
 #ifndef DEFINE_CONSTEXPR
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #define DEFINE_CONSTEXPR constexpr
+#endif // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #endif
 #ifndef DEFINE_ASSIGN_CONSTEXPR
 #if TEST_STD_VER >= 14
Index: libcxx/trunk/test/support/archetypes.hpp
===
--- libcxx/trunk/test/support/archetypes.hpp
+++ libcxx/trunk/test/support/archetypes.hpp
@@ -5,6 +5,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 #if TEST_STD_VER >= 11
 
@@ -14,7 +15,9 @@
 struct DepType : T {};
 
 struct NullBase {
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
   NullBase() = default;
   NullBase(NullBase const&) = default;
   NullBase& operator=(NullBase const&) = default;
@@ -81,7 +84,9 @@
   ++assigned; ++value_assigned;
   return *this;
 }
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 ~TestBase() {
   assert(value != -999); assert(alive > 0);
   --alive; ++destroyed; value = -999;
@@ -144,7 +149,9 @@
 }
 //~ValueBase() { assert(value != -999); value = -999; }
 int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
 constexpr static int check_value(int const&

[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D32759#751339, @efriedma wrote:

> Our behavior for your testcase is less than ideal (we should be generating an 
> invalid declaration instead of just dropping it on the floor), but that's not 
> something you need to fix here.
>
> Could you also include the Objective-C++ testcase I wrote?  Or does it not 
> work the way I expected?


I hadn't seen it.  I see from your diff now that you have a .mm file (p4.mm) 
which I presume is what you mean.  I'll check on it and get back to you on it.


https://reviews.llvm.org/D32759



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Err, I meant the one I wrote earlier in this thread: 
https://reviews.llvm.org/D32759#748007


https://reviews.llvm.org/D32759



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:158
+  // variable in constant address space in OpenCL.
+  if (D.getStorageDuration() != SD_Automatic && !D.hasExternalStorage()) {
 llvm::GlobalValue::LinkageTypes Linkage =

Please rearrange this function so that the D.hasExternalStorage() case below 
comes first; that will then simplify this condition.



Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

yaxunl wrote:
> rjmccall wrote:
> > Should this rule apply even in C++ mode?  I can't remember if there are any 
> > OpenCL/C++ hybrids.
> No. This rule (static local variable needs to be initialised with 
> compile-time constant) only applies to C and OpenCL. 
> In C++ static local variable can be initialised with non-compile-time 
> constant, in which case Clang will emit atomic instructions to make sure it 
> is only initialised once.
> 
> Currently OpenCL 2.2 defines OpenCL C++ but clang does not support it.
Yes, I understand that C++ generally allows static locals to be lazily 
initialized, and that that rule would (probably) still apply to ordinary static 
locals in OpenCL C++.  However, I would expect that OpenCL C++ rule is that 
__constant local variables still need to be statically initialized, because 
there's no plausible way in the OpenCL implementation model to actually put 
lazily-initialized variables in the constant address space.  Assuming that's 
correct, then I would recommend reworking this whole chain of conditions to:

  // Don't check the initializer if the declaration is malformed.
  if (VDecl->isInvalidDecl()) {
// do nothing

  // OpenCL __constant locals must be constant-initialized, even in OpenCL C++.
  } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
CheckForConstantInitializer(Init, DclT);

  // Otherwise, C++ does not restrict the initializer.
  } else if (getLangOpts().CPlusPlus) {
// do nothing

  // C99 6.7.8p4: All the expressions in an initializer for an object that has
  // static storage duration shall be constant expressions or string literals.
  } else if (VDecl->getStorageClass() == SC_Static) {
CheckForConstantInitializer(Init, DclT);

  // C89 is stricter than C99 for aggregate initializers.
  // C89 6.5.7p3: All the expressions [...] in an initializer list
  // for an object that has aggregate or union type shall be
  // constant expressions.
  } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() && 
isa(Init)) {
Expr *Culprit;
if (!Init->isConstantInitializer(Context, false, &Culprit)) {
  ...
}
  }


https://reviews.llvm.org/D32977



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D32759#751350, @efriedma wrote:

> Err, I meant the one I wrote earlier in this thread: 
> https://reviews.llvm.org/D32759#748007


AH! I missed that one.  I'll create a new file in SemaObjCXX then.


https://reviews.llvm.org/D32759



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > Should this rule apply even in C++ mode?  I can't remember if there are 
> > > any OpenCL/C++ hybrids.
> > No. This rule (static local variable needs to be initialised with 
> > compile-time constant) only applies to C and OpenCL. 
> > In C++ static local variable can be initialised with non-compile-time 
> > constant, in which case Clang will emit atomic instructions to make sure it 
> > is only initialised once.
> > 
> > Currently OpenCL 2.2 defines OpenCL C++ but clang does not support it.
> Yes, I understand that C++ generally allows static locals to be lazily 
> initialized, and that that rule would (probably) still apply to ordinary 
> static locals in OpenCL C++.  However, I would expect that OpenCL C++ rule is 
> that __constant local variables still need to be statically initialized, 
> because there's no plausible way in the OpenCL implementation model to 
> actually put lazily-initialized variables in the constant address space.  
> Assuming that's correct, then I would recommend reworking this whole chain of 
> conditions to:
> 
>   // Don't check the initializer if the declaration is malformed.
>   if (VDecl->isInvalidDecl()) {
> // do nothing
> 
>   // OpenCL __constant locals must be constant-initialized, even in OpenCL 
> C++.
>   } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
> CheckForConstantInitializer(Init, DclT);
> 
>   // Otherwise, C++ does not restrict the initializer.
>   } else if (getLangOpts().CPlusPlus) {
> // do nothing
> 
>   // C99 6.7.8p4: All the expressions in an initializer for an object that has
>   // static storage duration shall be constant expressions or string literals.
>   } else if (VDecl->getStorageClass() == SC_Static) {
> CheckForConstantInitializer(Init, DclT);
> 
>   // C89 is stricter than C99 for aggregate initializers.
>   // C89 6.5.7p3: All the expressions [...] in an initializer list
>   // for an object that has aggregate or union type shall be
>   // constant expressions.
>   } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() && 
> isa(Init)) {
> Expr *Culprit;
> if (!Init->isConstantInitializer(Context, false, &Culprit)) {
>   ...
> }
>   }
Agree that even OpenCL C++ is unable to lazy initialise function-scope var in 
constant addr space. Will do.


https://reviews.llvm.org/D32977



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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. The bots are already failing because I upgraded their compilers.

@BillyONeal Can you commit this soon so I can clean up any fallout?


https://reviews.llvm.org/D33021



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 98504.

https://reviews.llvm.org/D32759

Files:
  lib/Sema/SemaType.cpp
  test/SemaObjC/method-bad-param.m
  test/SemaObjCXX/method-bad-param.mm


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2285,8 +2285,9 @@
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;
Index: test/SemaObjCXX/method-bad-param.mm
===
--- test/SemaObjCXX/method-bad-param.mm
+++ test/SemaObjCXX/method-bad-param.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@class NSObject;
+template struct C {
+  static T f(); // expected-error {{interface type 'NSObject' cannot be 
returned by value; did you forget * in 'NSObject'?}}
+};
+int g() { NSObject *x = C::f(); }//expected-error {{no member named 
'f' in 'C'}} expected-note {{in instantiation of template class 
'C' requested here}}
Index: test/SemaObjC/method-bad-param.m
===
--- test/SemaObjC/method-bad-param.m
+++ test/SemaObjC/method-bad-param.m
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared 
here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be 
passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned 
by value; did you forget * in 'foo'}}
 


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2285,8 +2285,9 @@
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;
Index: test/SemaObjCXX/method-bad-param.mm
===
--- test/SemaObjCXX/method-bad-param.mm
+++ test/SemaObjCXX/method-bad-param.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@class NSObject;
+template struct C {
+  static T f(); // expected-error {{interface type 'NSObject' cannot be returned by value; did you forget * in 'NSObject'?}}
+};
+int g() { NSObject *x = C::f(); }//expected-error {{no member named 'f' in 'C'}} expected-note {{in instantiation of template class 'C' requested here}}
Index: test/SemaObjC/method-bad-param.m
===
--- test/SemaObjC/method-bad-param.m
+++ test/SemaObjC/method-bad-param.m
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-10 Thread Martin Probst via Phabricator via cfe-commits
mprobst added a comment.

So, currently clang-format doesn't really understand trailing commas in 
parenthesized lists (such as parameter declarations or lists). It should, and 
coincidentally I was just yesterday trying to get that working in 
https://reviews.llvm.org/D33023.

Regarding the option – I'm not sure we need to introduce an option for this. I 
think I'd prefer to just always break before the `l_paren` if the parenthesized 
list has a trailing comma, similar to how we format array or object literals.

I'm not sure about indentation of this though,  there are multiple options that 
all seem reasonable-ish:

  // (1) wrap back to 0 indent
  fnCall(
  param,
  param,
  param,
  );
  
  function fnDecl(
  param,
  param,
  param,
  ) {
code();
here();
  }
  
  // (2) wrap to +4 indent
  fnCall(
  param,
  param,
  param,
  );
  
  function fnDecl(
  param,
  param,
  param,
  ) {
code();
here();
  }
  
  // (3) keep on line
  fnCall(
  param,
  param,
  param,);
  
  function fnDecl(
  param,
  param,
  param,) {
code();
here();
  }

I was personally thinking more of option (2), as it's uncommon to me to wrap 
like (1) in the call situation. On the other hand (1) does look a lot better in 
the call situation, and also leaves more space for a return type. It's a 
stylistic question, so there isn't really a right or wrong, but I'd be cool 
with either of these, maybe with a preference for (1).

But in any case, if we can find agreement here, I think we should not introduce 
an option, and just make it how `clang-format` behaves for JS/TS code with 
trailing commas.


https://reviews.llvm.org/D33029



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


[libcxx] r302709 - [libc++] Fix PR32979 - types with a private std::enable_shared_from_this base break shared_ptr

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 14:35:49 2017
New Revision: 302709

URL: http://llvm.org/viewvc/llvm-project?rev=302709&view=rev
Log:
[libc++] Fix PR32979 -  types with a private std::enable_shared_from_this base 
break shared_ptr

Summary:
This patch fixes bugs.llvm.org/PR32979.

[util.smartptr.shared.const] says:
> In the constructor definitions below, enables shared_from_this with p, for a 
> pointer p of type Y*, means
> that if Y has an unambiguous and accessible base class that is a 
> specialization of enable_shared_from_-
> this.

This means that libc++ needs to respect the access specifier of the base class, 
and not attempt to construct
and enabled_shared_from_this base if it is private. However access specifiers 
don't affect overload resolution
so our current implementation will attempt to construct the private base. 

This patch uses SFINAE to correctly detect if the shared_ptr input has an 
accessible enable_shared_from_this
base class.

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=302709&r1=302708&r2=302709&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed May 10 14:35:49 2017
@@ -3924,7 +3924,10 @@ private:
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-void
+typename enable_if*
+>::value,
+void>::type
 __enable_weak_this(const enable_shared_from_this<_Yp>* __e,
_OrigPtr* __ptr) _NOEXCEPT
 {
@@ -3943,6 +3946,7 @@ private:
 template  friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
 };
 
+
 template
 inline
 _LIBCPP_CONSTEXPR

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp?rev=302709&r1=302708&r2=302709&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
 Wed May 10 14:35:49 2017
@@ -49,6 +49,11 @@ struct Bar : public Foo {
 };
 
 
+struct PrivateBase : private std::enable_shared_from_this {
+std::weak_ptr get_weak() { return weak_from_this(); }
+};
+
+
 int main()
 {
 {  // https://bugs.llvm.org/show_bug.cgi?id=18843
@@ -74,6 +79,12 @@ int main()
 assert(p == q);
 assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share 
ownership
 }
+  {
+typedef std::shared_ptr APtr;
+typedef std::weak_ptr WeakAPtr;
+APtr a1 = std::make_shared();
+assert(a1.use_count() == 1);
+  }
 // Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
 // http://cplusplus.github.io/LWG/lwg-active.html#2529.
 // Test two different ways:


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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-10 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 98506.
BillyONeal added a comment.

Added spaces requested by Marshal.


https://reviews.llvm.org/D33021

Files:
  
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp


Index: 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -22,13 +22,13 @@
 {
 static_assert( std::is_trivially_copyable::value, "");
 static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
 static_assert( std::is_trivially_copyable_v, "");
 static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
 #endif
 }
 


Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -22,13 +22,13 @@
 {
 static_assert( std::is_trivially_copyable::value, "");
 static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
 static_assert( std::is_trivially_copyable_v, "");
 static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302710: Update is_trivially_copyable tests with CWG 2094 
(authored by bion).

Changed prior to commit:
  https://reviews.llvm.org/D33021?vs=98506&id=98508#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33021

Files:
  
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp


Index: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -22,13 +22,13 @@
 {
 static_assert( std::is_trivially_copyable::value, "");
 static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
 static_assert( std::is_trivially_copyable_v, "");
 static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
 #endif
 }
 


Index: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -22,13 +22,13 @@
 {
 static_assert( std::is_trivially_copyable::value, "");
 static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
 static_assert( std::is_trivially_copyable_v, "");
 static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r302710 - Update is_trivially_copyable tests with CWG 2094

2017-05-10 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Wed May 10 14:43:31 2017
New Revision: 302710

URL: http://llvm.org/viewvc/llvm-project?rev=302710&view=rev
Log:
Update is_trivially_copyable tests with CWG 2094

Clang 5.0 implements these changes here: 
https://github.com/llvm-mirror/clang/commit/87cd035326a39523eeb1b295ad36cff337141ef9
MSVC++ will implement these changes in the first toolset update to 2017.

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

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp?rev=302710&r1=302709&r2=302710&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
 Wed May 10 14:43:31 2017
@@ -22,13 +22,13 @@ void test_is_trivially_copyable()
 {
 static_assert( std::is_trivially_copyable::value, "");
 static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
+static_assert( std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
 static_assert( std::is_trivially_copyable_v, "");
 static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
+static_assert( std::is_trivially_copyable_v, "");
 #endif
 }
 


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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-10 Thread Ryan Stringham via Phabricator via cfe-commits
stringham added a comment.

I think we should have the option whether or not a trailing comma is preset for 
a few reasons:

1. clang-format doesn't support enforcing adding trailing commas
2. trailing commas aren't always supported (if you use the rest operator)
  - `Uncaught SyntaxError: Rest parameter must be last formal parameter`
3. if you break before the opening paren, treating the surrounding parens as a 
"block" helps the developer match up the parens.

false:

  longFunctionCall(new longClassNameBeingInitialized(
  param1,
  param2,
  param3,
  param4,
  param5));

true:

  longFunctionCall(new longClassNameBeingInitialized(
  param1,
  param2,
  param3,
  param4,
  param5
  ));

also happens for function calls like this:

false:

  this.myList = [
  param1,
  functionCall(param)
  .chainedCall(
  longparam1,
  function(foo) {
  return calculateSomething(foo);
  }),
  param3,
  ];

true:

  this.myList = [
  param1,
  functionCall(param)
  .chainedCall(
  longparam1,
  function(foo) {
  return calculateSomething(foo);
  }
  ),
  param3,
  ];

can't put a trailing comma with the rest operator
false:

  class MyClass {
  constructor(
  param1,
  param2,
  ...args) {
  this.p1 = param1;
  }
  }

true:

  class MyClass {
  constructor(
  param1,
  param2,
  ...args
  ) {
  this.p1 = param1;
  }
  }


https://reviews.llvm.org/D33029



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 98510.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D32977

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  test/CodeGenOpenCL/constant-addr-space-globals.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -5,7 +5,7 @@
 int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
 global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
-void kernel foo() {
+void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
   static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
   static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}}
@@ -15,6 +15,12 @@
 
   auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
   global int L4;   // expected-error{{function scope variable cannot be declared in global address space}}
+
+  constant int L5 = x; // expected-error {{initializer element is not a compile-time constant}}
+  global int *constant L6 = &G4;
+  private int *constant L7 = &x; // expected-error {{initializer element is not a compile-time constant}}
+  constant int *constant L8 = &L1;
+  local int *constant L9 = &L2; // expected-error {{initializer element is not a compile-time constant}}
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
@@ -29,4 +35,7 @@
   }
   global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
   extern constant float L4;
+  extern local float L5; // expected-error{{extern variable must reside in constant address space}}
+  static int L6 = 0; // expected-error{{variables in function scope cannot be declared static}}
+  static int L7; // expected-error{{variables in function scope cannot be declared static}}
 }
Index: test/CodeGenOpenCL/constant-addr-space-globals.cl
===
--- test/CodeGenOpenCL/constant-addr-space-globals.cl
+++ test/CodeGenOpenCL/constant-addr-space-globals.cl
@@ -11,17 +11,21 @@
 // but create a copy in the original address space (unless a variable itself is
 // in the constant address space).
 
-void foo(constant const int *p1, const int *p2, const int *p3);
+void foo(constant int* p, constant const int *p1, const int *p2, const int *p3);
 // CHECK: @k.arr1 = internal addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3]
 // CHECK: @k.arr2 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 4, i32 5, i32 6]
 // CHECK: @k.arr3 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 7, i32 8, i32 9]
+// CHECK: @k.var1 = internal addrspace(2) constant i32 1
 kernel void k(void) {
   // CHECK-NOT: %arr1 = alloca [3 x i32]
   constant const int arr1[] = {1, 2, 3};
   // CHECK: %arr2 = alloca [3 x i32]
   const int arr2[] = {4, 5, 6};
   // CHECK: %arr3 = alloca [3 x i32]
   int arr3[] = {7, 8, 9};
 
-  foo(arr1, arr2, arr3);
+  constant int var1 = 1;
+  
+  // CHECK: call spir_func void @foo(i32 addrspace(2)* @k.var1, i32 addrspace(2)* getelementptr inbounds ([3 x i32], [3 x i32] addrspace(2)* @k.arr1, i32 0, i32 0)
+  foo(&var1, arr1, arr2, arr3);
 }
Index: test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
===
--- test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
+++ test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
@@ -80,21 +80,21 @@
   // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR4]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}}
   int *FuncVar4 = Tmp1;
 
-  // CHECK-DAG: ![[FUNCVAR5:[0-9]+]] = !DILocalVariable(name: "FuncVar5", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR5]], metadata ![[NONE:[0-9]+]]), !dbg !{{[0-9]+}}
-  global int *constant FuncVar5 = KernelArg0;
-  // CHECK-DAG: ![[FUNCVAR6:[0-9]+]] = !DILocalVariable(name: "FuncVar6", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[FUNCVAR6]], metadata ![[NONE]]), !dbg !{{[0-9]+}}
-  constant int *constant FuncVar6 = KernelArg1;
-  // CHECK-DAG: ![[FUNCVAR7:[0-9]+]] = !DILocalVariable(name: "FuncVar7", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+

[libcxx] r302713 - Clean up LIT failure output by not showing the entire environment

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 14:55:42 2017
New Revision: 302713

URL: http://llvm.org/viewvc/llvm-project?rev=302713&view=rev
Log:
Clean up LIT failure output by not showing the entire environment

Modified:
libcxx/trunk/utils/libcxx/test/executor.py

Modified: libcxx/trunk/utils/libcxx/test/executor.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/executor.py?rev=302713&r1=302712&r2=302713&view=diff
==
--- libcxx/trunk/utils/libcxx/test/executor.py (original)
+++ libcxx/trunk/utils/libcxx/test/executor.py Wed May 10 14:55:42 2017
@@ -38,36 +38,11 @@ class LocalExecutor(Executor):
 
 def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
 cmd = cmd or [exe_path]
-env_cmd = []
-if env:
-env_cmd += ['env']
-env_cmd += ['%s=%s' % (k, v) for k, v in env.items()]
 if work_dir == '.':
 work_dir = os.getcwd()
-if not self.is_windows:
-out, err, rc = executeCommand(env_cmd + cmd, cwd=work_dir)
-else:
-out, err, rc = executeCommand(cmd, cwd=work_dir,
-  env=self._build_windows_env(env))
-return (env_cmd + cmd, out, err, rc)
+out, err, rc = executeCommand(cmd, cwd=work_dir, env=env)
+return (cmd, out, err, rc)
 
-def _build_windows_env(self, exec_env):
-# FIXME: Finding Windows DLL's at runtime requires modifying the
-#   PATH environment variables. However we don't want to print out
-#   the entire PATH as part of the diagnostic for every failing test.
-#   Therefore this hack builds a new executable environment that
-#   merges the current environment and the supplied environment while
-#   still only printing the supplied environment in diagnostics.
-if not self.is_windows or exec_env is None:
-return None
-new_env = dict(os.environ)
-for key, value in exec_env.items():
-if key == 'PATH':
-assert value.strip() != '' and "expected non-empty path"
-new_env['PATH'] = "%s;%s" % (value, os.environ['PATH'])
-else:
-new_env[key] = value
-return new_env
 
 class PrefixExecutor(Executor):
 """Prefix an executor with some other command wrapper.


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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-10 Thread Ryan Stringham via Phabricator via cfe-commits
stringham added a comment.

If the parameter list fits within the column limit, and there are no trailing 
commas, then we don't end up wrapping the closing paren.

If it is long enough that it causes wrapping (regardless of trailing commas), 
and the wrapping happens directly after the opening paren, we break before the 
closing paren.


https://reviews.llvm.org/D33029



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D32759



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Err, oh, meant to add one minor comment: please rename "method-bad-param.mm" to 
"interface-return-type.mm".


https://reviews.llvm.org/D32759



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


[PATCH] D33061: [tooling] RefactoringCallbacks code cleanup

2017-05-10 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
alexshap created this object with visibility "All Users".

1. Add missing "explicit" for single argument constructors
2. Add missing std::move in ReplaceNodeWithTemplate constructor

and switch to pass-by-value idiom

Test plan:
make check-clang


Repository:
  rL LLVM

https://reviews.llvm.org/D33061

Files:
  include/clang/Tooling/RefactoringCallbacks.h
  lib/Tooling/RefactoringCallbacks.cpp


Index: lib/Tooling/RefactoringCallbacks.cpp
===
--- lib/Tooling/RefactoringCallbacks.cpp
+++ lib/Tooling/RefactoringCallbacks.cpp
@@ -38,7 +38,7 @@
 
 class RefactoringASTConsumer : public ASTConsumer {
 public:
-  RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
+  explicit RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
   : Refactoring(Refactoring) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
@@ -153,8 +153,8 @@
 }
 
 ReplaceNodeWithTemplate::ReplaceNodeWithTemplate(
-llvm::StringRef FromId, std::vector &&Template)
-: FromId(FromId), Template(Template) {}
+llvm::StringRef FromId, std::vector Template)
+: FromId(FromId), Template(std::move(Template)) {}
 
 llvm::Expected>
 ReplaceNodeWithTemplate::create(StringRef FromId, StringRef ToTemplate) {
@@ -193,7 +193,7 @@
 }
   }
   return std::unique_ptr(
-  new ReplaceNodeWithTemplate(FromId, std::move(ParsedTemplate)));
+   new ReplaceNodeWithTemplate(FromId, std::move(ParsedTemplate)));
 }
 
 void ReplaceNodeWithTemplate::run(
Index: include/clang/Tooling/RefactoringCallbacks.h
===
--- include/clang/Tooling/RefactoringCallbacks.h
+++ include/clang/Tooling/RefactoringCallbacks.h
@@ -53,7 +53,8 @@
 /// Runs AST matchers and stores the \c tooling::Replacements in a map.
 class ASTMatchRefactorer {
 public:
-  ASTMatchRefactorer(std::map &FileToReplaces);
+  explicit ASTMatchRefactorer(
+std::map &FileToReplaces);
 
   template 
   void addMatcher(const T &Matcher, RefactoringCallback *Callback) {
@@ -103,7 +104,7 @@
 std::string Value;
   };
   ReplaceNodeWithTemplate(llvm::StringRef FromId,
-  std::vector &&Template);
+  std::vector Template);
   std::string FromId;
   std::vector Template;
 };


Index: lib/Tooling/RefactoringCallbacks.cpp
===
--- lib/Tooling/RefactoringCallbacks.cpp
+++ lib/Tooling/RefactoringCallbacks.cpp
@@ -38,7 +38,7 @@
 
 class RefactoringASTConsumer : public ASTConsumer {
 public:
-  RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
+  explicit RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
   : Refactoring(Refactoring) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
@@ -153,8 +153,8 @@
 }
 
 ReplaceNodeWithTemplate::ReplaceNodeWithTemplate(
-llvm::StringRef FromId, std::vector &&Template)
-: FromId(FromId), Template(Template) {}
+llvm::StringRef FromId, std::vector Template)
+: FromId(FromId), Template(std::move(Template)) {}
 
 llvm::Expected>
 ReplaceNodeWithTemplate::create(StringRef FromId, StringRef ToTemplate) {
@@ -193,7 +193,7 @@
 }
   }
   return std::unique_ptr(
-  new ReplaceNodeWithTemplate(FromId, std::move(ParsedTemplate)));
+   new ReplaceNodeWithTemplate(FromId, std::move(ParsedTemplate)));
 }
 
 void ReplaceNodeWithTemplate::run(
Index: include/clang/Tooling/RefactoringCallbacks.h
===
--- include/clang/Tooling/RefactoringCallbacks.h
+++ include/clang/Tooling/RefactoringCallbacks.h
@@ -53,7 +53,8 @@
 /// Runs AST matchers and stores the \c tooling::Replacements in a map.
 class ASTMatchRefactorer {
 public:
-  ASTMatchRefactorer(std::map &FileToReplaces);
+  explicit ASTMatchRefactorer(
+std::map &FileToReplaces);
 
   template 
   void addMatcher(const T &Matcher, RefactoringCallback *Callback) {
@@ -103,7 +104,7 @@
 std::string Value;
   };
   ReplaceNodeWithTemplate(llvm::StringRef FromId,
-  std::vector &&Template);
+  std::vector Template);
   std::string FromId;
   std::vector Template;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302720 - Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed May 10 15:03:16 2017
New Revision: 302720

URL: http://llvm.org/viewvc/llvm-project?rev=302720&view=rev
Log:
Fix errored return value in CheckFunctionReturnType and add a fixit hint

As discovered by ChenWJ and listed on cfe-dev, the error for Objective C 
return type ended up being wrong. This fixes that. Additionally, as a 
"while we're there", the other usages of this error and the usage of the 
FP above both use a FixItHint, so I'll add it here.

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

Added:
cfe/trunk/test/SemaObjCXX/interface-return-type.mm
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/method-bad-param.m

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=302720&r1=302719&r2=302720&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 10 15:03:16 2017
@@ -2285,8 +2285,9 @@ bool Sema::CheckFunctionReturnType(QualT
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;

Modified: cfe/trunk/test/SemaObjC/method-bad-param.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-bad-param.m?rev=302720&r1=302719&r2=302720&view=diff
==
--- cfe/trunk/test/SemaObjC/method-bad-param.m (original)
+++ cfe/trunk/test/SemaObjC/method-bad-param.m Wed May 10 15:03:16 2017
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared 
here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be 
passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned 
by value; did you forget * in 'foo'}}
 

Added: cfe/trunk/test/SemaObjCXX/interface-return-type.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/interface-return-type.mm?rev=302720&view=auto
==
--- cfe/trunk/test/SemaObjCXX/interface-return-type.mm (added)
+++ cfe/trunk/test/SemaObjCXX/interface-return-type.mm Wed May 10 15:03:16 2017
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@class NSObject;
+template struct C {
+  static T f(); // expected-error {{interface type 'NSObject' cannot be 
returned by value; did you forget * in 'NSObject'?}}
+};
+int g() { NSObject *x = C::f(); }//expected-error {{no member named 
'f' in 'C'}} expected-note {{in instantiation of template class 
'C' requested here}}


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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-10 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302720: Fix errored return value in CheckFunctionReturnType 
and add a fixit hint (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D32759?vs=98504&id=98516#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32759

Files:
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaObjC/method-bad-param.m
  cfe/trunk/test/SemaObjCXX/interface-return-type.mm


Index: cfe/trunk/test/SemaObjC/method-bad-param.m
===
--- cfe/trunk/test/SemaObjC/method-bad-param.m
+++ cfe/trunk/test/SemaObjC/method-bad-param.m
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared 
here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be 
passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned 
by value; did you forget * in 'foo'}}
 
Index: cfe/trunk/test/SemaObjCXX/interface-return-type.mm
===
--- cfe/trunk/test/SemaObjCXX/interface-return-type.mm
+++ cfe/trunk/test/SemaObjCXX/interface-return-type.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@class NSObject;
+template struct C {
+  static T f(); // expected-error {{interface type 'NSObject' cannot be 
returned by value; did you forget * in 'NSObject'?}}
+};
+int g() { NSObject *x = C::f(); }//expected-error {{no member named 
'f' in 'C'}} expected-note {{in instantiation of template class 
'C' requested here}}
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2285,8 +2285,9 @@
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;


Index: cfe/trunk/test/SemaObjC/method-bad-param.m
===
--- cfe/trunk/test/SemaObjC/method-bad-param.m
+++ cfe/trunk/test/SemaObjC/method-bad-param.m
@@ -20,6 +20,12 @@
 }
 @end
 
+// Ensure that this function is properly marked as a failure.
+void func_with_bad_call(bar* b, foo* f) {
+  [b cc:5]; // expected-warning {{instance method '-cc:' not found}}
+// expected-note@-17 {{receiver is instance of class declared here}}
+}
+
 void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
 foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
 
Index: cfe/trunk/test/SemaObjCXX/interface-return-type.mm
===
--- cfe/trunk/test/SemaObjCXX/interface-return-type.mm
+++ cfe/trunk/test/SemaObjCXX/interface-return-type.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@class NSObject;
+template struct C {
+  static T f(); // expected-error {{interface type 'NSObject' cannot be returned by value; did you forget * in 'NSObject'?}}
+};
+int g() { NSObject *x = C::f(); }//expected-error {{no member named 'f' in 'C'}} expected-note {{in instantiation of template class 'C' requested here}}
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2285,8 +2285,9 @@
   // Methods cannot return interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCObjectType()) {
-Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
-return 0;
+Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
+<< 0 << T << FixItHint::CreateInsertion(Loc, "*");
+return true;
   }
 
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r302721 - Fix enable_shared_from_this test in C++11

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 15:09:20 2017
New Revision: 302721

URL: http://llvm.org/viewvc/llvm-project?rev=302721&view=rev
Log:
Fix enable_shared_from_this test in C++11

Modified:

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp?rev=302721&r1=302720&r2=302721&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
 Wed May 10 15:09:20 2017
@@ -50,7 +50,6 @@ struct Bar : public Foo {
 
 
 struct PrivateBase : private std::enable_shared_from_this {
-std::weak_ptr get_weak() { return weak_from_this(); }
 };
 
 
@@ -79,12 +78,12 @@ int main()
 assert(p == q);
 assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share 
ownership
 }
-  {
-typedef std::shared_ptr APtr;
-typedef std::weak_ptr WeakAPtr;
-APtr a1 = std::make_shared();
-assert(a1.use_count() == 1);
-  }
+{
+  typedef std::shared_ptr APtr;
+  typedef std::weak_ptr WeakAPtr;
+  APtr a1 = std::make_shared();
+  assert(a1.use_count() == 1);
+}
 // Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
 // http://cplusplus.github.io/LWG/lwg-active.html#2529.
 // Test two different ways:


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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-05-10 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

In https://reviews.llvm.org/D28952#750558, @iris wrote:

> How can I make z3constraintmanager.cpp work in the command line?Or how to 
> make z3 work?


You'll need a bleeding-edge build of Clang/LLVM, since this isn't available in 
any stable release yet. First, build or install a recent version of z3; 
`libz3-dev` in Debian/Ubuntu may work. Pass `-DCLANG_ANALYZER_BUILD_Z3=ON` to 
`cmake`, when building LLVM.  Then, when running `clang`, pass `-Xanalyzer 
-analyzer-constraints=z3`.


Repository:
  rL LLVM

https://reviews.llvm.org/D28952



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


[libcxx] r302723 - XFAIL is_trivially_copyable test for compilers that don't implement Core 2094

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 15:19:35 2017
New Revision: 302723

URL: http://llvm.org/viewvc/llvm-project?rev=302723&view=rev
Log:
XFAIL is_trivially_copyable test for compilers that don't implement Core 2094

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp?rev=302723&r1=302722&r2=302723&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
 Wed May 10 15:19:35 2017
@@ -11,7 +11,9 @@
 
 // is_trivially_copyable
 
-// XFAIL: gcc-4.9
+// These compilers have not implemented Core 2094 which makes volatile
+// qualified types trivially copyable.
+// XFAIL: clang-3, clang-4, apple-clang, gcc
 
 #include 
 #include 


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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 98528.
EricWF added a comment.

- General cleanup changes.

Libc++ trunk currently doesn't build under MinGW, so I'm not concerned about 
breaking that worse with this patch. I've set up a Appveyor builder to track 
MinGW so we can get it green later.

Also I'm planning on making all of the the changes suggested in inline 
comments, but in a follow up patch. I would like to keep this to simply 
renaming and restructuring include files.
With that in mind does anybody object to landing this?


https://reviews.llvm.org/D32988

Files:
  include/__mutex_base
  include/__threading_support
  include/algorithm
  include/ctype.h
  include/limits
  include/stdio.h
  include/stdlib.h
  include/support/win32/limits_msvc_win32.h
  include/support/win32/limits_win32.h
  include/support/win32/locale_mgmt_win32.h
  include/support/win32/locale_win32.h
  include/support/win32/msvc_builtin_support.h
  include/support/win32/support.h
  include/wchar.h
  src/string.cpp
  src/support/runtime/exception_pointer_msvc.ipp

Index: src/support/runtime/exception_pointer_msvc.ipp
===
--- src/support/runtime/exception_pointer_msvc.ipp
+++ src/support/runtime/exception_pointer_msvc.ipp
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include  // for _CRTIMP2_PURE
 
 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -13,9 +13,6 @@
 #include "cerrno"
 #include "limits"
 #include "stdexcept"
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/support.h"
-#endif // _LIBCPP_MSVCRT
 #include 
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -430,7 +427,7 @@
 #ifndef _LIBCPP_MSVCRT
 return swprintf;
 #else
-return static_cast(swprintf);
+return static_cast(_snwprintf);
 #endif
 }
 
Index: include/wchar.h
===
--- include/wchar.h
+++ include/wchar.h
@@ -166,9 +166,12 @@
 }
 #endif
 
-#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__))
-extern "C++" {
-#include  // pull in *swprintf defines
+#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT)
+extern "C" {
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+  size_t nmc, size_t len, mbstate_t *__restrict ps);
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+  size_t nwc, size_t len, mbstate_t *__restrict ps);
 }  // extern "C++"
 #endif  // __cplusplus && _LIBCPP_MSVCRT
 
Index: include/support/win32/support.h
===
--- include/support/win32/support.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// -*- C++ -*-
-//===--- support/win32/support.h --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-
-// Functions and constants used in libc++ that
-// are missing from the Windows C library.
-
-#include  // mbstate_t
-#include  // va_ macros
-// "builtins" not implemented here for Clang or GCC as they provide
-// implementations. Assuming required for elsewhere else, certainly MSVC.
-#if defined(_LIBCPP_COMPILER_MSVC)
-#include 
-#endif
-#define swprintf _snwprintf
-#define vswprintf _vsnwprintf
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-// The mingw headers already define these as static.
-#ifndef __MINGW32__
-extern "C" {
-
-int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
-int asprintf(char **sptr, const char *__restrict fmt, ...);
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
-  size_t nmc, size_t len, mbstate_t *__restrict ps);
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
-  size_t nwc, size_t len, mbstate_t *__restrict ps);
-}
-#endif // __MINGW32__
-
-#if defined(_LIBCPP_COMPILER_MSVC)
-
-// Bit builtin's make these assumptions when calling _BitScanForward/Reverse
-// etc. These assumptions are expected to be true for Win32/Win64 which this
-// file supports.
-static_assert(sizeof(unsigned long long) == 8, "");
-static_assert(sizeof(unsigned long) == 4, "");
-static_assert(sizeof(unsigned int) == 4, "");
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
-{
-  // Binary: 0101...
-  static const unsigned int m1 = 0x;
-  // Binary: 00110011..
-  static const unsigned int m2 = 0x;
-  // Binary:  4 zeros,  4 ones ...
-  static const unsigned int m4 = 0x0f0f0f0f;
-  /

[libcxx] r302724 - Implement LWG 2591 - Patch from K-Ballo

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 15:37:43 2017
New Revision: 302724

URL: http://llvm.org/viewvc/llvm-project?rev=302724&view=rev
Log:
Implement LWG 2591 - Patch from K-Ballo

Modified:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp?rev=302724&r1=302723&r2=302724&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
 Wed May 10 15:37:43 2017
@@ -63,6 +63,7 @@ int main()
 assert(A::count == 1);
 assert(f.target());
 assert(f.target() == 0);
+assert(f.target() == nullptr);
 }
 assert(A::count == 0);
 {
@@ -70,6 +71,7 @@ int main()
 assert(A::count == 0);
 assert(f.target());
 assert(f.target() == 0);
+assert(f.target() == nullptr);
 }
 assert(A::count == 0);
 {
@@ -77,6 +79,7 @@ int main()
 assert(A::count == 1);
 assert(f.target());
 assert(f.target() == 0);
+assert(f.target() == nullptr);
 }
 assert(A::count == 0);
 {
@@ -84,6 +87,7 @@ int main()
 assert(A::count == 0);
 assert(f.target());
 assert(f.target() == 0);
+assert(f.target() == nullptr);
 }
 assert(A::count == 0);
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=302724&r1=302723&r2=302724&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Wed May 10 15:37:43 2017
@@ -387,7 +387,7 @@
http://wg21.link/LWG2584";>2584 
ECMAScript IdentityEscape is ambiguousIssaquah
http://wg21.link/LWG2588";>2588[fund.ts.v2] "Convertible to 
bool" requirement in conjunction and 
disjunctionIssaquah
http://wg21.link/LWG2589";>2589match_results can't satisfy 
the requirements of a containerIssaquahComplete
-   http://wg21.link/LWG2591";>2591std::function's member 
template target() should not lead to undefined 
behaviourIssaquah
+   http://wg21.link/LWG2591";>2591std::function's member 
template target() should not lead to undefined 
behaviourIssaquahComplete
http://wg21.link/LWG2598";>2598addressof 
works on temporariesIssaquahComplete
http://wg21.link/LWG2664";>2664operator/ 
(and other append) semantics not useful if argument has 
rootIssaquahComplete
http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectIssaquahComplete


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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-10 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

LGTM


https://reviews.llvm.org/D32988



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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.

@compnerd I'm going to go ahead and land this and then submit a separate review 
for the changes you've requested. I hope you don't mind :-)


https://reviews.llvm.org/D32988



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


[libcxx] r302727 - [libc++] Refactor Windows support headers.

2017-05-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May 10 15:57:45 2017
New Revision: 302727

URL: http://llvm.org/viewvc/llvm-project?rev=302727&view=rev
Log:
[libc++] Refactor Windows support headers.

Summary:
This patch refactors and tries to remove as much of the Windows support headers 
as possible. This is needed because they currently introduce super weird 
include cycles and dependencies between STL and libc headers.

The changes in this patch are:

* remove `support/win32/support.h` completely. The required parts have either 
been moved into `support/win32/msvc_support.h` (for `MSVC` only helpers not 
needed by Clang), or directly into their respective `foo.h` headers.

* Combine `locale_win32.h` and `locale_mgmt_win32.h` into a single headers, 
this header should only be included within `__locale` or `locale` to avoid 
include cycles.

* Remove the unneeded parts of `limits_win32.h` and re-name it to 
`limits_msvc_win32.h` since it's only needed by Clang.

I've tested this patch using Clang on Windows, but I suspect it might 
technically regress our non-existent support for MSVC. Is somebody able to 
double check?

This refactor is needed to support upcoming fixes to `` on Windows.



Reviewers: bcraig, rmaprath, compnerd, EricWF

Reviewed By: EricWF

Subscribers: majnemer, cfe-commits

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

Added:
libcxx/trunk/include/support/win32/limits_msvc_win32.h
libcxx/trunk/include/support/win32/msvc_builtin_support.h
Removed:
libcxx/trunk/include/support/win32/limits_win32.h
libcxx/trunk/include/support/win32/locale_mgmt_win32.h
libcxx/trunk/include/support/win32/support.h
Modified:
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/__threading_support
libcxx/trunk/include/algorithm
libcxx/trunk/include/ctype.h
libcxx/trunk/include/limits
libcxx/trunk/include/stdio.h
libcxx/trunk/include/stdlib.h
libcxx/trunk/include/support/win32/locale_win32.h
libcxx/trunk/include/wchar.h
libcxx/trunk/src/string.cpp
libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=302727&r1=302726&r2=302727&view=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Wed May 10 15:57:45 2017
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include <__threading_support>
+#include <__undef_min_max>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=302727&r1=302726&r2=302727&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Wed May 10 15:57:45 2017
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include <__undef_min_max>
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=302727&r1=302726&r2=302727&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed May 10 15:57:45 2017
@@ -644,8 +644,8 @@ template 

Modified: libcxx/trunk/include/ctype.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctype.h?rev=302727&r1=302726&r2=302727&view=diff
==
--- libcxx/trunk/include/ctype.h (original)
+++ libcxx/trunk/include/ctype.h Wed May 10 15:57:45 2017
@@ -40,15 +40,6 @@ int toupper(int c);
 
 #ifdef __cplusplus
 
-#if defined(_LIBCPP_MSVCRT)
-// We support including .h headers inside 'extern "C"' contexts, so switch
-// back to C++ linkage before including these C++ headers.
-extern "C++" {
-  #include "support/win32/support.h"
-  #include "support/win32/locale_win32.h"
-}
-#endif // _LIBCPP_MSVCRT
-
 #undef isalnum
 #undef isalpha
 #undef isblank

Modified: libcxx/trunk/include/limits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/limits?rev=302727&r1=302726&r2=302727&view=diff
==
--- libcxx/trunk/include/limits (original)
+++ libcxx/trunk/include/limits Wed May 10 15:57:45 2017
@@ -111,8 +111,8 @@ template<> class numeric_limits
 
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/limits_win32.h"
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include "support/win32/limits_msvc_win32.h"
 #endif // _LIBCPP_MSVCRT
 
 #if defined(__IBMCPP__)

Modified: libcxx/trunk/include/stdio.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdio.h?rev=302727&r1=302726&r2=302727&view=diff
==

  1   2   >