r256631 - clang-format: [JS] Support TypeScript 1.6 user defined type guards.

2015-12-30 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Dec 30 02:00:58 2015
New Revision: 256631

URL: http://llvm.org/viewvc/llvm-project?rev=256631&view=rev
Log:
clang-format: [JS] Support TypeScript 1.6 user defined type guards.

Before:
  function foo(check: Object): check
  is{foo: string, bar: string, baz: string, foobar: string} {
return 'bar' in check;
  }

After:
  function foo(check: Object):
  check is {foo: string, bar: string, baz: string, foobar: string} {
return 'bar' in check;
  }

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=256631&r1=256630&r2=256631&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Wed Dec 30 02:00:58 2015
@@ -536,6 +536,7 @@ struct AdditionalKeywords {
 kw_finally = &IdentTable.get("finally");
 kw_function = &IdentTable.get("function");
 kw_import = &IdentTable.get("import");
+kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
 kw_var = &IdentTable.get("var");
 
@@ -580,6 +581,7 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_function;
   IdentifierInfo *kw_import;
+  IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;
   IdentifierInfo *kw_var;
 

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256631&r1=256630&r2=256631&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Dec 30 02:00:58 2015
@@ -1996,6 +1996,8 @@ bool TokenAnnotator::spaceRequiredBefore
 if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow,
  Keywords.kw_in))
   return true;
+if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
+  return true;
 if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
   return false;
 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
@@ -2239,6 +2241,8 @@ bool TokenAnnotator::canBreakBefore(cons
   return false;
 if (Left.is(TT_JsTypeColon))
   return true;
+if (Right.NestingLevel == 0 && Right.is(Keywords.kw_is))
+  return false;
   }
 
   if (Left.is(tok::at))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=256631&r1=256630&r2=256631&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Dec 30 02:00:58 2015
@@ -962,6 +962,14 @@ TEST_F(FormatTestJS, TypeArguments) {
" {}");
 }
 
+TEST_F(FormatTestJS, UserDefinedTypeGuards) {
+  verifyFormat(
+  "function foo(check: Object):\n"
+  "check is {foo: string, bar: string, baz: string, foobar: string} 
{\n"
+  "  return 'bar' in check;\n"
+  "}\n");
+}
+
 TEST_F(FormatTestJS, OptionalTypes) {
   verifyFormat("function x(a?: b, c?, d?) {}");
   verifyFormat("class X {\n"


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


Re: [PATCH] D15797: [clang-tidy] Fix readability-braces-around-statements assert failure

2015-12-30 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D15797#317793, @mattsta wrote:

> It's difficult to track down *why* the invalid locations are happening 
> because by the time we get to an invalid location, all source location 
> information is lost.  The best I've been able to come up with is fixing the 
> early return conditions (which were previously impossible to reach due to 
> asserts catching the invalid conditions first).
>
> It's easy to have these happen on any large codebase (e.g. try to recursively 
> clang-tidy the erlang source tree with readability-braces-around-statements).


I'd still like to add a test for this (and I have a different idea on how to 
fix this, namely return an invalid location from `findRParenLoc` instead of 
asserting). If you can't come up with a test case, I'll try to find one myself 
by running on some files, but we absolutely have to add a test to avoid 
regressions when this code is changed again.


Repository:
  rL LLVM

http://reviews.llvm.org/D15797



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


Re: [PATCH] D15623: Add UnnecessaryCopyInitialization check to new "performance" module in ClangTidy

2015-12-30 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good! I'll commit the patch for you.


http://reviews.llvm.org/D15623



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


Re: [PATCH] D15623: Add UnnecessaryCopyInitialization check to new "performance" module in ClangTidy

2015-12-30 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256632: [clang-tidy] Add UnnecessaryCopyInitialization check 
to new "performance"… (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D15623?vs=43743&id=43776#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15623

Files:
  clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/Makefile
  clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -0,0 +1,152 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+
+struct ExpensiveToCopyType {
+  ExpensiveToCopyType() {}
+  virtual ~ExpensiveToCopyType() {}
+  const ExpensiveToCopyType &reference() const { return *this; }
+};
+
+struct TrivialToCopyType {
+  const TrivialToCopyType &reference() const { return *this; }
+};
+
+const ExpensiveToCopyType &ExpensiveTypeReference() {
+  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
+  return *Type;
+}
+
+const TrivialToCopyType &TrivialTypeReference() {
+  static const TrivialToCopyType *Type = new TrivialToCopyType();
+  return *Type;
+}
+
+void PositiveFunctionCall() {
+  const auto AutoAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
+  const auto AutoCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
+  const ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
+  const ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+}
+
+void PositiveMethodCallConstReferenceParam(const ExpensiveToCopyType &Obj) {
+  const auto AutoAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  const auto AutoCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  const ExpensiveToCopyType VarAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+}
+
+void PositiveMethodCallConstParam(const ExpensiveToCopyType Obj) {
+  const auto AutoAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  const auto AutoCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  const ExpensiveToCopyType VarAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+}
+
+void Po

[clang-tools-extra] r256632 - [clang-tidy] Add UnnecessaryCopyInitialization check to new "performance" module in ClangTidy

2015-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 30 04:24:40 2015
New Revision: 256632

URL: http://llvm.org/viewvc/llvm-project?rev=256632&view=rev
Log:
[clang-tidy] Add UnnecessaryCopyInitialization check to new "performance" 
module in ClangTidy

Summary:
The patch adds a new ClangTidy check that detects when expensive-to-copy types 
are unnecessarily copy initialized from a const reference that has the same or 
are larger scope than the copy.

It currently only detects this when the copied variable is const qualified. But 
this will be extended to non const variables if they are only used in a const 
fashion.

Reviewers: alexfh

Subscribers: cfe-commits

Patch by Felix Berger!

Differential Revision: http://reviews.llvm.org/D15623

Added:
clang-tools-extra/trunk/clang-tidy/performance/
clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/Makefile
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=256632&r1=256631&r2=256632&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Wed Dec 30 04:24:40 2015
@@ -32,5 +32,6 @@ add_subdirectory(cppcoreguidelines)
 add_subdirectory(google)
 add_subdirectory(misc)
 add_subdirectory(modernize)
+add_subdirectory(performance)
 add_subdirectory(readability)
 add_subdirectory(utils)

Modified: clang-tools-extra/trunk/clang-tidy/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/Makefile?rev=256632&r1=256631&r2=256632&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/Makefile (original)
+++ clang-tools-extra/trunk/clang-tidy/Makefile Wed Dec 30 04:24:40 2015
@@ -11,6 +11,6 @@ CLANG_LEVEL := ../../..
 LIBRARYNAME := clangTidy
 include $(CLANG_LEVEL)/../../Makefile.config
 
-DIRS = utils cert cppcoreguidelines readability llvm google misc modernize tool
+DIRS = utils cert cppcoreguidelines readability llvm google misc modernize 
performance tool
 
 include $(CLANG_LEVEL)/Makefile

Added: clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt?rev=256632&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt Wed Dec 30 
04:24:40 2015
@@ -0,0 +1,14 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyPerformanceModule
+  PerformanceTidyModule.cpp
+  UnnecessaryCopyInitialization.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )

Added: clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp?rev=256632&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp 
Wed Dec 30 04:24:40 2015
@@ -0,0 +1,39 @@
+//===--- PeformanceTidyModule.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 "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+
+#include "UnnecessaryCopyInitialization.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+class PerformanceModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-unnecessary-copy-initialization");
+  }
+};
+
+// Register the 

[clang-tools-extra] r256633 - [clang-tidy] Fix configure build

2015-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 30 04:44:08 2015
New Revision: 256633

URL: http://llvm.org/viewvc/llvm-project?rev=256633&view=rev
Log:
[clang-tidy] Fix configure build

Modified:
clang-tools-extra/trunk/clang-tidy/tool/Makefile

Modified: clang-tools-extra/trunk/clang-tidy/tool/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/Makefile?rev=256633&r1=256632&r2=256633&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/Makefile (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/Makefile Wed Dec 30 04:44:08 2015
@@ -17,7 +17,8 @@ TOOL_NO_EXPORTS = 1
 include $(CLANG_LEVEL)/../../Makefile.config
 LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \
-   clangTidyMiscModule.a clangTidyModernizeModule.a 
clangTidyReadability.a \
+   clangTidyMiscModule.a clangTidyModernizeModule.a \
+  clangTidyPerformanceModule.a clangTidyReadability.a \
   clangTidyUtils.a clangTidyCERTModule.a clangStaticAnalyzerFrontend.a 
\
   clangTidyCppCoreGuidelinesModule.a \
   clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \


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


[clang-tools-extra] r256634 - [clang-tidy] Add the missing Makefile

2015-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 30 04:56:00 2015
New Revision: 256634

URL: http://llvm.org/viewvc/llvm-project?rev=256634&view=rev
Log:
[clang-tidy] Add the missing Makefile

Added:
clang-tools-extra/trunk/clang-tidy/performance/Makefile

Added: clang-tools-extra/trunk/clang-tidy/performance/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/Makefile?rev=256634&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/performance/Makefile (added)
+++ clang-tools-extra/trunk/clang-tidy/performance/Makefile Wed Dec 30 04:56:00 
2015
@@ -0,0 +1,12 @@
+##===- clang-tidy/performance/Makefile -*- Makefile 
-*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===--===##
+CLANG_LEVEL := ../../../..
+LIBRARYNAME := clangTidyPerformanceModule
+
+include $(CLANG_LEVEL)/Makefile


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


[clang-tools-extra] r256636 - [clang-tidy] Use hasLocalStorage() to identify unnecessary copy initializations to exclude static local variables.

2015-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 30 05:35:50 2015
New Revision: 256636

URL: http://llvm.org/viewvc/llvm-project?rev=256636&view=rev
Log:
[clang-tidy] Use hasLocalStorage() to identify unnecessary copy initializations 
to exclude static local variables.

Summary: Since local static variables can outlive other local variables exclude 
them from the unnecessary copy initialization check.

Reviewers: alexfh

Patch by Felix Berger!

Differential Revision: http://reviews.llvm.org/D15822

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp?rev=256636&r1=256635&r2=256636&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
 Wed Dec 30 05:35:50 2015
@@ -19,7 +19,6 @@ namespace performance {
 using namespace ::clang::ast_matchers;
 
 namespace {
-AST_MATCHER(VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl(); }
 AST_MATCHER(QualType, isPointerType) { return Node->isPointerType(); }
 } // namespace
 
@@ -43,7 +42,7 @@ void UnnecessaryCopyInitialization::regi
unless(callee(cxxMethodDecl(;
   Finder->addMatcher(
   varDecl(
-  isLocalVarDecl(), hasType(isConstQualified()),
+  hasLocalStorage(), hasType(isConstQualified()),
   hasType(matchers::isExpensiveToCopy()),
   hasInitializer(cxxConstructExpr(
   hasDeclaration(cxxConstructorDecl(isCopyConstructor())),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp?rev=256636&r1=256635&r2=256636&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
 Wed Dec 30 05:35:50 2015
@@ -110,6 +110,10 @@ void NegativeFunctionCallTrivialType() {
   const TrivialToCopyType VarCopyConstructed(TrivialTypeReference());
 }
 
+void NegativeStaticLocalVar(const ExpensiveToCopyType &Obj) {
+  static const auto StaticVar = Obj.reference();
+}
+
 void NegativeFunctionCallExpensiveTypeNonConstVariable() {
   auto AutoAssigned = ExpensiveTypeReference();
   auto AutoCopyConstructed(ExpensiveTypeReference());


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


[clang-tools-extra] r256637 - [clang-tidy] Don't use delegating constructors

2015-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 30 05:39:30 2015
New Revision: 256637

URL: http://llvm.org/viewvc/llvm-project?rev=256637&view=rev
Log:
[clang-tidy] Don't use delegating constructors

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h?rev=256637&r1=256636&r2=256637&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h 
Wed Dec 30 05:39:30 2015
@@ -26,7 +26,8 @@ namespace performance {
 // const references, and const pointers to const.
 class UnnecessaryCopyInitialization : public ClangTidyCheck {
 public:
-  using ClangTidyCheck::ClangTidyCheck;
+  UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };


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


r256639 - [OPENMP 4.5] Allow 'ordered' clause on 'loop simd' constructs.

2015-12-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Dec 30 06:06:23 2015
New Revision: 256639

URL: http://llvm.org/viewvc/llvm-project?rev=256639&view=rev
Log:
[OPENMP 4.5] Allow 'ordered' clause on 'loop simd' constructs.
OpenMP 4.5 allows to use 'ordered' clause without parameter on 'loop simd' 
constructs.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=256639&r1=256638&r2=256639&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 30 06:06:23 
2015
@@ -7969,6 +7969,8 @@ def err_omp_schedule_nonmonotonic_static
   "'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' 
schedule kind">;
 def err_omp_schedule_nonmonotonic_ordered : Error<
   "'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 
'ordered' clause is specified">;
+def err_omp_ordered_simd : Error<
+  "'ordered' clause with a parameter can not be specified in '#pragma omp %0' 
directive">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=256639&r1=256638&r2=256639&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Dec 30 06:06:23 2015
@@ -220,6 +220,7 @@ OPENMP_FOR_SIMD_CLAUSE(safelen)
 OPENMP_FOR_SIMD_CLAUSE(simdlen)
 OPENMP_FOR_SIMD_CLAUSE(linear)
 OPENMP_FOR_SIMD_CLAUSE(aligned)
+OPENMP_FOR_SIMD_CLAUSE(ordered)
 
 // Clauses allowed for OpenMP directive 'omp sections'.
 OPENMP_SECTIONS_CLAUSE(private)
@@ -303,6 +304,7 @@ OPENMP_PARALLEL_FOR_SIMD_CLAUSE(safelen)
 OPENMP_PARALLEL_FOR_SIMD_CLAUSE(simdlen)
 OPENMP_PARALLEL_FOR_SIMD_CLAUSE(linear)
 OPENMP_PARALLEL_FOR_SIMD_CLAUSE(aligned)
+OPENMP_PARALLEL_FOR_SIMD_CLAUSE(ordered)
 
 // Clauses allowed for OpenMP directive 'parallel sections'.
 OPENMP_PARALLEL_SECTIONS_CLAUSE(if)

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=256639&r1=256638&r2=256639&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 30 06:06:23 2015
@@ -1680,6 +1680,13 @@ StmtResult Sema::ActOnOpenMPRegionEnd(St
 }
 ErrorFound = true;
   }
+  if (isOpenMPWorksharingDirective(DSAStack->getCurrentDirective()) &&
+  isOpenMPSimdDirective(DSAStack->getCurrentDirective()) && OC &&
+  OC->getNumForLoops()) {
+Diag(OC->getLocStart(), diag::err_omp_ordered_simd)
+<< getOpenMPDirectiveName(DSAStack->getCurrentDirective());
+ErrorFound = true;
+  }
   if (ErrorFound) {
 ActOnCapturedRegionError();
 return StmtError();

Modified: cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_ast_print.cpp?rev=256639&r1=256638&r2=256639&view=diff
==
--- cfe/trunk/test/OpenMP/for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_ast_print.cpp Wed Dec 30 06:06:23 2015
@@ -14,8 +14,8 @@ template T reduct(T* a
   N myind;
   T sum = (T)0;
 // CHECK: T sum = (T)0;
-#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr)
-// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) 
aligned(arr)
+#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr) ordered
+// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) 
aligned(arr) ordered
   for (i = 0; i < num; ++i) {
 myind = ind;
 T cur = arr[myind];
@@ -92,8 +92,8 @@ int main (int argc, char **argv) {
   int k1=0,k2=0;
   static int *a;
 // CHECK: static int *a;
-#pragma omp for simd
-// CHECK-NEXT: #pragma omp for simd
+#pragma omp for simd ordered
+// CHECK-NEXT: #pragma omp for simd ordered
   for (int i=0; i < 2; ++i)*a=2;
 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
 // CHECK-NEXT: *a = 2;

Modified: cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk

[PATCH] D15823: Support virtual-near-miss check.

2015-12-30 Thread Cong Liu via cfe-commits
congliu created this revision.
congliu added a reviewer: alexfh.
congliu added a subscriber: cfe-commits.

Virtual function override near miss detection. Function complete. Test 
complete. Do not conduct Fix for now.

http://reviews.llvm.org/D15823

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tidy/misc/VirtualNearMissCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-virtual-near-miss.rst
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s misc-virtual-near-miss %t
+
+struct Base{
+  virtual void func();
+  virtual void gunk();
+};
+
+struct Derived:Base{
+  // Should warn
+  // Should not warn "do you want to override 'gunk'?", becuase gunk is already
+  // overriden by this class
+  virtual void funk();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'? [misc-virtual-near-miss]
+
+  // Should warn
+  void func2();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'? [misc-virtual-near-miss]
+
+  void func22(); // Should not warn
+
+  void gunk(); // Should not warn because gunk is override
+
+  // Should warn
+  void fun();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'? [misc-virtual-near-miss]
+};
+
+class Father{
+ public:
+  Father();
+  virtual void func();
+  virtual Father* create(int i);
+};
+
+class Mother{
+ public:
+  Mother();
+  static void method();
+  virtual int method(int argc, const char** argv);
+  virtual int method(int argc) const;
+};
+
+class Child : Father, Mother{
+ public:
+  Child();
+
+  // Should warn
+  virtual void func2();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'? [misc-virtual-near-miss]
+
+  int methoe(int x, char** strs); // Should not warn because param type miss match
+
+  int methoe(int x); // Should not warn because const type miss match
+
+  void methof(int x, const char** strs); // Should not warn because return type miss match
+
+  // Should warn
+  int methoh(int x, const char** strs);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'method'? [misc-virtual-near-miss]
+
+  // Should warn
+  virtual Child* creat(int i);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'create'? [misc-virtual-near-miss]
+
+ private:
+  void funk(); //Should not warn because access miss match
+};
Index: docs/clang-tidy/checks/misc-virtual-near-miss.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-virtual-near-miss.rst
@@ -0,0 +1,4 @@
+misc-virtual-near-miss
+==
+
+FIXME: Describe what patterns does the check detect and why. Give examples.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -56,6 +56,7 @@
misc-unused-alias-decls
misc-unused-parameters
misc-unused-raii
+   misc-virtual-near-miss
modernize-loop-convert
modernize-make-unique
modernize-pass-by-value
Index: clang-tidy/misc/VirtualNearMissCheck.h
===
--- /dev/null
+++ clang-tidy/misc/VirtualNearMissCheck.h
@@ -0,0 +1,75 @@
+//===--- VirtualNearMissCheck.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_MISC_VIRTUAL_NEAR_MISS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H
+
+#include "../ClangTidy.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-virtual-near-miss.html
+class VirtualNearMissCheck : public ClangTidyCheck {
+public:
+  VirtualNearMissCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+  static int editDistance(const std::string &SourceStr, const std::string &TargetStr);
+private:
+  /// Return true if the given method overrides some method.
+  bool isOverrideMethod(const CXXMethodDecl *DerivedMD);
+
+  /// Return true if the given method is possible to be overriden by some other
+  /// method.
+  //It should look up the possible_map or update it.

r256640 - clang-format: Slightly row back on r256343 by increasing penalty for

2015-12-30 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Dec 30 06:23:00 2015
New Revision: 256640

URL: http://llvm.org/viewvc/llvm-project?rev=256640&view=rev
Log:
clang-format: Slightly row back on r256343 by increasing penalty for
breaking between array subscripts.

Before:
  if ( && aaa[a]
 [a])
After:
  if ( &&
  aaa[a][a])

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256640&r1=256639&r2=256640&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Dec 30 06:23:00 2015
@@ -1715,8 +1715,10 @@ unsigned TokenAnnotator::splitPenalty(co
   Right.Next->is(TT_DictLiteral)))
 return 1;
   if (Right.is(tok::l_square)) {
-if (Style.Language == FormatStyle::LK_Proto || Left.is(tok::r_square))
+if (Style.Language == FormatStyle::LK_Proto)
   return 1;
+if (Left.is(tok::r_square))
+  return 25;
 // Slightly prefer formatting local lambda definitions like functions.
 if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal))
   return 50;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256640&r1=256639&r2=256640&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Dec 30 06:23:00 2015
@@ -6047,6 +6047,8 @@ TEST_F(FormatTest, FormatsArrays) {
" [b] = c;");
   verifyFormat("a[aaa()]\n"
" [bbb()] = c;");
+  verifyFormat("if ( &&\n"
+   "aaa[a][a]) {\n}");
   verifyFormat("aa\n"
"[] = 
ccc;");
   verifyFormat("aa\n"


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


Re: [PATCH] D7164: Recognize "CC" and "clang-CC" as C++ compiler aliases on FreeBSD

2015-12-30 Thread Dimitry Andric via cfe-commits
dim updated this revision to Diff 43784.
dim added a comment.

Updating this diff for the moving of FindDriverSuffix() to 
lib/Driver/ToolChain.cpp.


http://reviews.llvm.org/D7164

Files:
  lib/Driver/ToolChain.cpp

Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -105,11 +105,17 @@
   {"clang", nullptr},
   {"clang++", "--driver-mode=g++"},
   {"clang-c++", "--driver-mode=g++"},
+#ifdef __FreeBSD__
+  {"clang-CC", "--driver-mode=g++"},
+#endif
   {"clang-cc", nullptr},
   {"clang-cpp", "--driver-mode=cpp"},
   {"clang-g++", "--driver-mode=g++"},
   {"clang-gcc", nullptr},
   {"clang-cl", "--driver-mode=cl"},
+#ifdef __FreeBSD__
+  {"CC", "--driver-mode=g++"},
+#endif
   {"cc", nullptr},
   {"cpp", "--driver-mode=cpp"},
   {"cl", "--driver-mode=cl"},


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -105,11 +105,17 @@
   {"clang", nullptr},
   {"clang++", "--driver-mode=g++"},
   {"clang-c++", "--driver-mode=g++"},
+#ifdef __FreeBSD__
+  {"clang-CC", "--driver-mode=g++"},
+#endif
   {"clang-cc", nullptr},
   {"clang-cpp", "--driver-mode=cpp"},
   {"clang-g++", "--driver-mode=g++"},
   {"clang-gcc", nullptr},
   {"clang-cl", "--driver-mode=cl"},
+#ifdef __FreeBSD__
+  {"CC", "--driver-mode=g++"},
+#endif
   {"cc", nullptr},
   {"cpp", "--driver-mode=cpp"},
   {"cl", "--driver-mode=cl"},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15823: Support virtual-near-miss check.

2015-12-30 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for working on this! See the initial set of comments inline.



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:21
@@ +20,3 @@
+
+int VirtualNearMissCheck::editDistance(const std::string &SourceStr,
+const std::string &TargeStr){

Parameters should be `StringRef` instead of `const std::string &`. `StringRef` 
is the most common way to pass a read-only string to a function in LLVM.

Also, there's already `StringRef::edit_distance`. It should do what you need, I 
guess.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:23
@@ +22,3 @@
+const std::string &TargeStr){
+  int len_source = SourceStr.size();
+  int len_target = TargeStr.size();

Please use LLVM naming conventions 
(http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly).


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:59
@@ +58,3 @@
+bool VirtualNearMissCheck::isOverrideMethod(const CXXMethodDecl *MD){
+  return MD->size_overridden_methods() > 0 || MD->hasAttr();
+}

Why is the `hasAttr()` part needed? Do you have an example of 
code that results in `size_overridden_methods() == 0` and 
`hasAttr() == true`?


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:62
@@ +61,3 @@
+
+bool VirtualNearMissCheck::equalWithoutName(const CXXMethodDecl *BaseMD, const 
CXXMethodDecl *DerivedMD){
+  if (BaseMD->getTypeQualifiers() != DerivedMD->getTypeQualifiers())

Please maintain 80-columns limit. The easiest way to do this is to use 
clang-format (with -style=LLVM, if needed).


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:72
@@ +71,3 @@
+
+  if (BaseMD->getType()  == DerivedMD->getType())
+return true;

nit: Extra space before `==`. Please use clang-format.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:79
@@ +78,3 @@
+  if (BaseReturnType->isReferenceType() && 
DerivedReturnType->isReferenceType()){
+BaseReturnType = BaseReturnType.getNonReferenceType();
+DerivedReturnType = DerivedReturnType.getNonReferenceType();

You can call `.getNonReferenceType()` unconditionally to make the code shorter.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:84
@@ +83,3 @@
+DerivedReturnType = DerivedReturnType->getPointeeType();
+  }else {
+return false;

clang-format


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:85
@@ +84,3 @@
+  }else {
+return false;
+  }

What if both return types are not references and are not pointers? Why do you 
return `false` in this case?


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:128
@@ +127,3 @@
+is_possible = it->second;
+  } else{
+is_possible = !(BaseMD->isImplicit())

clang-format


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:129
@@ +128,3 @@
+  } else{
+is_possible = !(BaseMD->isImplicit())
+&& !(dyn_cast(BaseMD))

No parentheses are needed around method calls here. Please remove.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:130
@@ +129,3 @@
+is_possible = !(BaseMD->isImplicit())
+&& !(dyn_cast(BaseMD))
+&& BaseMD->isVirtual();

Please use `isa` instead of `dyn_cast` in boolean context.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:139
@@ +138,3 @@
+ const CXXRecordDecl *DerivedRD){
+  auto key = std::make_pair(generateMethodID(BaseMD), 
DerivedRD->getQualifiedNameAsString());
+  auto it = overriden_map_.find(key);

clang-format


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:144
@@ +143,3 @@
+is_overriden = it->second;
+  } else{
+is_overriden = false;

clang-format


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:173
@@ +172,3 @@
+
+  if (Result.SourceManager->isInSystemHeader(DerivedMD->getLocation())){
+return;

It's not common to use braces around one-line `if` bodies in LLVM/Clang code. 
Please remove the braces.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:197
@@ +196,3 @@
+if (editDistance(BaseMDName, DerivedMDName) <= kNearMissThreshold){
+  // virtual-near-miss found
+  diag(DerivedMD->getLocStart(), "do you want to override '%0'?")

Comments should use proper Capitalization and punctuation. See 
http://llvm.org/docs/CodingStandards.html#commenting for details.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:200
@@ +199,3 @@
+  << BaseMD->getName();
+  // Auto fix could be risky
+  // const auto Fixup = 
FixItHint

r256641 - Disable generating movt on FreeBSD.

2015-12-30 Thread Davide Italiano via cfe-commits
Author: davide
Date: Wed Dec 30 07:53:25 2015
New Revision: 256641

URL: http://llvm.org/viewvc/llvm-project?rev=256641&view=rev
Log:
Disable generating movt on FreeBSD.

It's sort of an hack, but we have no choice.
The linker in the base system doesn't handle that correctly (yet).
Once FreeBSD will import lld, this can be backed out.

Patch by: Andrew Turner!

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/arm-no-movt.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256641&r1=256640&r2=256641&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 30 07:53:25 2015
@@ -938,8 +938,8 @@ static void getARMTargetFeatures(const T
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
-  // The kext linker doesn't know how to deal with movw/movt.
-  if (KernelOrKext)
+  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
+  if (KernelOrKext || Triple.isOSFreeBSD())
 Features.push_back("+no-movt");
 }
 

Modified: cfe/trunk/test/Driver/arm-no-movt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-no-movt.c?rev=256641&r1=256640&r2=256641&view=diff
==
--- cfe/trunk/test/Driver/arm-no-movt.c (original)
+++ cfe/trunk/test/Driver/arm-no-movt.c Wed Dec 30 07:53:25 2015
@@ -4,6 +4,11 @@
 // RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-KERNEL
 
+// RUN: %clang -target armv7-gnueabi-freebsd11 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-FREEBSD
+
 // CHECK-DEFAULT-NOT: "-target-feature" "+no-movt"
 
 // CHECK-KERNEL: "-target-feature" "+no-movt"
+
+// CHECK-FREEBSD: "-target-feature" "+no-movt"


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


Re: [PATCH] D15647: [X86] Fix stack alignment for MCU target (Clang part)

2015-12-30 Thread Anton Nadolskiy via cfe-commits
anadolskiy updated this revision to Diff 43788.
anadolskiy added a comment.

Thanks for review John. Addressed your comment.


http://reviews.llvm.org/D15647

Files:
  tools/clang/include/clang/Basic/TargetInfo.h
  tools/clang/lib/AST/ASTContext.cpp
  tools/clang/lib/Basic/Targets.cpp
  tools/clang/test/CodeGen/iamcu-abi.c

Index: tools/clang/test/CodeGen/iamcu-abi.c
===
--- tools/clang/test/CodeGen/iamcu-abi.c
+++ tools/clang/test/CodeGen/iamcu-abi.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-pc-elfiamcu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: target datalayout = "e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32"
+// CHECK: target triple = "i386-pc-elfiamcu"
+
+
+void food(double *d);
+void fooll(long long *ll);
+void fooull(unsigned long long *ull);
+void foold(long double *ld);
+
+// CHECK-LABEL: define void @testdouble()
+// CHECK: alloca double, align 4
+void testdouble() {
+  double d = 2.0;
+  food(&d);
+}
+
+// CHECK-LABEL: define void @testlonglong()
+// CHECK: alloca i64, align 4
+void testlonglong() {
+  long long ll = 2;
+  fooll(&ll);
+}
+
+// CHECK-LABEL: define void @testunsignedlonglong()
+// CHECK: alloca i64, align 4
+void testunsignedlonglong() {
+  unsigned long long ull = 2;
+  fooull(&ull);	
+}
+
+// CHECK-LABEL: define void @testlongdouble()
+// CHECK: alloca double, align 4
+void testlongdouble() {
+  long double ld = 2.0;
+  foold(&ld);
+}
Index: tools/clang/lib/Basic/Targets.cpp
===
--- tools/clang/lib/Basic/Targets.cpp
+++ tools/clang/lib/Basic/Targets.cpp
@@ -3877,6 +3877,8 @@
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+DataLayoutString =
+"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
@@ -3890,6 +3892,10 @@
 Builder.defineMacro("__iamcu");
 Builder.defineMacro("__iamcu__");
   }
+
+  bool allowsLargerPreferedTypeAlignment() const override {
+return false;
+  }
 };
 
 // RTEMS Target
@@ -7439,6 +7445,9 @@
 // R0=ExceptionPointerRegister R1=ExceptionSelectorRegister
 return (RegNo < 2)? RegNo : -1;
   }
+  bool allowsLargerPreferedTypeAlignment() const override {
+return false;
+  }
 };
 
 const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
Index: tools/clang/lib/AST/ASTContext.cpp
===
--- tools/clang/lib/AST/ASTContext.cpp
+++ tools/clang/lib/AST/ASTContext.cpp
@@ -1898,8 +1898,8 @@
   if (T->isMemberPointerType())
 return getPreferredTypeAlign(getPointerDiffType().getTypePtr());
 
-  if (Target->getTriple().getArch() == llvm::Triple::xcore)
-return ABIAlign;  // Never overalign on XCore.
+  if (!Target->allowsLargerPreferedTypeAlignment())
+return ABIAlign;
 
   // Double and long long should be naturally aligned if possible.
   if (const ComplexType *CT = T->getAs())
Index: tools/clang/include/clang/Basic/TargetInfo.h
===
--- tools/clang/include/clang/Basic/TargetInfo.h
+++ tools/clang/include/clang/Basic/TargetInfo.h
@@ -931,6 +931,9 @@
 return false;
   }
 
+  /// \brief Whether target allows to overalign ABI-specified prefered alignment
+  virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
+
 protected:
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
 return PointerWidth;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15813: [libcxx] Refactoring target_info.py used by lit tests

2015-12-30 Thread Ben Craig via cfe-commits
bcraig added a comment.

Apologies for the swarm of breakages this caused.  Thanks for the late night 
(for me at least) locale fix EricWF!


http://reviews.llvm.org/D15813



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


Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2015-12-30 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2504
@@ -2493,3 +2503,3 @@
 
 // Availability attribute
 def warn_availability_unknown_platform : Warning<

>> It would be good to model these new diagnostics after the MIPS interrupt 
>> diagnostics.
>> 
>> def warn_mips_interrupt_attribute : Warning<
>>"MIPS 'interrupt' attribute only applies to functions that have "
>>"%select{no parameters|a 'void' return type}0">,
>>InGroup;

> Ok, will do

This does not appear to have been completed yet.


Comment at: lib/Sema/SemaDeclAttr.cpp:4556
@@ +4555,3 @@
+  // e) The 2nd argument (if any) must be an unsigned integer.
+  if (!isFunctionOrMethod(D) || !hasFunctionProto(D) ||
+  !D->getDeclContext()->isFileContext()) {

>> Yes, we allow any non-member functions.
> Then we should have a test that shows this working with a named namespace 
> interrupt function. Also, it's a bit odd to me that members of named 
> namespaces are fine, but static member functions are not. This disallows 
> possibly-sensible code (like a private static member function of a class for 
> better encapsulation).

I don't see a test using a named namespace with an interrupt function (though I 
do see one disallowing a static member function). Also, I am still wondering 
why there is a restriction against static member functions. (I looked at GCC's 
docs and they do not claim to support this attribute for these targets, so I'm 
not certain what this design is based on.)


Comment at: test/SemaCXX/attr-x86-interrupt.cpp:51
@@ +50,3 @@
+template 
+void bar(T *a) {
+  foo9(a); // expected-error {{interrupt service routine can't be called 
directly}}

Ah, I'm sorry, I wasn't very clear with my template request. I was looking for 
something like (in addition to what you've added):
```
template 
void bar(Fn F) {
  F(nullptr); // Should this diagnose? I expect not.
}

__attribute__((interrupt)) void foo(int *) {}
void f() {
  bar(foo);
}
```


http://reviews.llvm.org/D15709



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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-30 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


http://reviews.llvm.org/D15524



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


r256643 - When performing an implicit from float to bool, the floating point value must be *exactly* zero in order for the conversion to result in 0. This does not involve a conversion through an inte

2015-12-30 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec 30 08:26:07 2015
New Revision: 256643

URL: http://llvm.org/viewvc/llvm-project?rev=256643&view=rev
Log:
When performing an implicit from float to bool, the floating point value must 
be *exactly* zero in order for the conversion to result in 0. This does not 
involve a conversion through an integer value, and so truncation of the value 
is not performed.

This patch address PR25876.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=256643&r1=256642&r2=256643&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Dec 30 08:26:07 2015
@@ -6983,7 +6983,7 @@ void DiagnoseFloatingLiteralImpCast(Sema
 
   SmallString<16> PrettyTargetValue;
   if (T->isSpecificBuiltinType(BuiltinType::Bool))
-PrettyTargetValue = IntegerValue == 0 ? "false" : "true";
+PrettyTargetValue = Value.isZero() ? "false" : "true";
   else
 IntegerValue.toString(PrettyTargetValue);
 

Modified: cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp?rev=256643&r1=256642&r2=256643&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp Wed Dec 30 08:26:07 2015
@@ -38,3 +38,14 @@ void test0() {
   int y = (24*60*60) * 0.25;
   int pennies = 123.45 * 100;
 }
+
+// Similarly, test floating point conversion to bool. Only float values of zero
+// are converted to false; everything else is converted to true.
+void test1() {
+  bool b1 = 0.99f; // expected-warning {{implicit conversion from 'float' to 
'bool' changes value from 0.99 to true}}
+  bool b2 = 0.99; // expected-warning {{implicit conversion from 'double' to 
'bool' changes value from 0.99 to true}}
+  // These do not warn because they can be directly converted to integral
+  // values.
+  bool b3 = 0.0f;
+  bool b4 = 0.0;
+}


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


Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-30 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks! I've commit in r256643.



Comment at: test/SemaCXX/warn-literal-conversion.cpp:49-50
@@ +48,4 @@
+  // values.
+  bool b3 = 0.0f;
+  bool b4 = 0.0;
+}

rsmith wrote:
> What about
> 
>   bool b5 = 1.0;
>   bool b6 = 2.0;
> 
> ? Arguably any `float` -> `bool` conversion changes the value (because `true` 
> and `false` are not values of type `float`), so it wouldn't be completely 
> unreasonable to warn even if the literal is `0.0`.
Except those conversions won't cause confusion to the user, so I'm not certain 
what we gain by diagnosing. Given that some mental models expect 0.99 to 
convert to 0, which converts to false (because bool is an integral type, so it 
"must" do the usual integral truncation dance), it makes sense to tell the user 
"no no no, that converts to true." I'm less convinced about the utility of 
warning on things like `bool b = 1.99f' where it changes the value from 1.99 to 
true. Perhaps this should be changed to only diagnose when converting through 
an integer would result in a different value that converting through the float?


http://reviews.llvm.org/D15814



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2015-12-30 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:4022
@@ +4021,3 @@
+/// functionProtoType()
+///   matches "int (*f)(int)" and the type of "g".
+AST_TYPE_MATCHER(FunctionProtoType, functionProtoType);

Will this match g() in C mode?


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4282
@@ +4281,3 @@
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+}

I would like to see tests using matchesC() for void f() (for both 
functionProtoType() and parameterCountIs()).


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4988
@@ +4987,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+}

Can we have a test for:
```
EXPECT_TRUE(matches("typedef int foo; typedef foo bar;", 
typedefDecl(hasUnderlyingType(asString("int")), hasName("bar";
```
(I assume that this should work?)


http://reviews.llvm.org/D8149



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


r256644 - Silencing a -Wcast-qual warning; NFC.

2015-12-30 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec 30 10:02:17 2015
New Revision: 256644

URL: http://llvm.org/viewvc/llvm-project?rev=256644&view=rev
Log:
Silencing a -Wcast-qual warning; NFC.

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

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256644&r1=256643&r2=256644&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Dec 30 10:02:17 2015
@@ -1489,7 +1489,7 @@ void MicrosoftCXXNameMangler::manglePass
   int Type = POSA->getType();
 
   auto Iter = PassObjectSizeArgs.insert(Type).first;
-  void *TypePtr = (void *)&*Iter;
+  void *TypePtr = const_cast((const void *)&*Iter);
   ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr);
 
   if (Found == TypeBackReferences.end()) {


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


Re: [PATCH] D7164: Recognize "CC" and "clang-CC" as C++ compiler aliases on FreeBSD

2015-12-30 Thread Dimitry Andric via cfe-commits
dim abandoned this revision.
dim added a comment.

Abandoning this in favor of a wrapper shell script, which will call 
`/usr/bin/c++` instead.


http://reviews.llvm.org/D7164



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


Re: r256596 - Emit a -Wmicrosoft warning when treating ^Z as EOF in MS mode.

2015-12-30 Thread Joerg Sonnenberger via cfe-commits
On Tue, Dec 29, 2015 at 11:17:28PM -, Nico Weber via cfe-commits wrote:
> Author: nico
> Date: Tue Dec 29 17:17:27 2015
> New Revision: 256596
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256596&view=rev
> Log:
> Emit a -Wmicrosoft warning when treating ^Z as EOF in MS mode.

Do they really consider it as EOF for non-interactive use?

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


Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-30 Thread Richard Smith via cfe-commits
On Dec 30, 2015 6:34 AM, "Aaron Ballman"  wrote:
>
> aaron.ballman closed this revision.
> aaron.ballman added a comment.
>
> Thanks! I've commit in r256643.
>
>
> 
> Comment at: test/SemaCXX/warn-literal-conversion.cpp:49-50
> @@ +48,4 @@
> +  // values.
> +  bool b3 = 0.0f;
> +  bool b4 = 0.0;
> +}
> 
> rsmith wrote:
> > What about
> >
> >   bool b5 = 1.0;
> >   bool b6 = 2.0;
> >
> > ? Arguably any `float` -> `bool` conversion changes the value (because
`true` and `false` are not values of type `float`), so it wouldn't be
completely unreasonable to warn even if the literal is `0.0`.
> Except those conversions won't cause confusion to the user, so I'm not
certain what we gain by diagnosing. Given that some mental models expect
0.99 to convert to 0, which converts to false (because bool is an integral
type, so it "must" do the usual integral truncation dance), it makes sense
to tell the user "no no no, that converts to true." I'm less convinced
about the utility of warning on things like `bool b = 1.99f' where it
changes the value from 1.99 to true. Perhaps this should be changed to only
diagnose when converting through an integer would result in a different
value that converting through the float?

Let me ask a slightly different question: when would it ever be reasonable
and intentional to initialize a bool from a floating-point *literal*? For
integers, people use things like

  int n = 1e6;

which is why we don't complain if the literal is exactly representable in
the integer type. I can't imagine any similar cases for bool.

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


Re: [PATCH] D12200: Add framework for iterative compilation to clang

2015-12-30 Thread Zoran Jovanovic via cfe-commits
zoran.jovanovic updated this revision to Diff 43793.
zoran.jovanovic added a comment.

New patch version that corresponds to latest version of: 
http://reviews.llvm.org/D12199


http://reviews.llvm.org/D12200

Files:
  include/clang/Driver/Compilation.h
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -50,6 +50,11 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include "llvm/Analysis/IterativeCompilation.h"
+#include "llvm/Support/Program.h"
+#include 
+#include 
+#include 
 using namespace clang;
 using namespace clang::driver;
 using namespace llvm::opt;
@@ -307,6 +312,80 @@
   return 1;
 }
 
+void initControlFiles(llvm::ModuleDecisionTrees &MDT, int CurrentIteration)
+{
+  std::string ICResultsFile;
+  std::string ICResultsFile2;
+
+  // assign control files
+  llvm::ICResultsFile results1("ic-results", CurrentIteration);
+  llvm::ICResultsFile results2("ic-results2", CurrentIteration);
+  MDT.getICResultsFile() = results1;
+  MDT.getICResultsFile2() = results2;
+
+  llvm::ICInputFile input1("ic-input", CurrentIteration);
+  llvm::ICInputFile input2("ic-input2", CurrentIteration);
+  MDT.getICInputFile() = input1;
+  MDT.getICInputFile2() = input2;
+}
+
+void writeInputFiles(llvm::ModuleDecisionTrees &MDT)
+{
+  // inits and declarations
+  llvm::ICPathsMap paths;
+  llvm::ICPathsMap pathBeforeCodegen;
+  llvm::ICPathsMap pathAfterCodegen;
+
+  // split paths
+  MDT.getPaths(paths);
+  MDT.splitPaths(paths, pathBeforeCodegen, pathAfterCodegen);
+
+  // convert paths to strings and write them to files
+  llvm::ICInputFile input1 = MDT.getICInputFile();
+  llvm::ICInputFile input2 = MDT.getICInputFile2();
+
+  input1.setPaths(pathBeforeCodegen);
+  input2.setPaths(pathAfterCodegen);
+
+  input1.write();
+  input2.write();
+}
+
+void removeControlFiles(llvm::ModuleDecisionTrees &MDT) {
+  MDT.getICResultsFile().remove();
+  MDT.getICResultsFile2().remove();
+}
+
+int loadResultFiles(llvm::ModuleDecisionTrees &MDT,
+std::vector &merged) {
+  llvm::ICResultsFile results1 = MDT.getICResultsFile();
+  llvm::ICResultsFile results2 = MDT.getICResultsFile2();
+
+  int r1 = results1.read();
+  int r2 = results2.read();
+
+  if(r1 || r2)
+return 1;
+
+  llvm::MdtResults::mergeMdtResults(merged,
+  results1.getResults(), results2.getResults());
+
+  return 0;
+}
+
+llvm::MdtResults* getModuleResults(std::vector &merged,
+   std::string name)
+{
+  llvm::MdtResults *moduleResults = NULL;
+
+  for(auto res : merged) {
+if (res.FunctionNameAndPhase.getName() == name)
+  moduleResults = new llvm::MdtResults(res);
+  }
+
+  return moduleResults;
+}
+
 int main(int argc_, const char **argv_) {
   llvm::sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram X(argc_, argv_);
@@ -429,6 +508,34 @@
 Diags.takeClient(), std::move(SerializedConsumer)));
   }
 
+  // Get number of iterations for iterative compilation.
+  // declare files and number of iterations
+  int ICNumberOfIterations = 0;
+
+  // extract number of iterations from cli args
+  std::unique_ptr CCopts(createDriverOptTable());
+  unsigned MissingArgIndex, MissingArgCount;
+  ArrayRef argv_ref(argv);
+  InputArgList Args = CCopts->ParseArgs(argv_ref.slice(1),
+MissingArgIndex, MissingArgCount);
+  if (Args.getLastArg(options::OPT_fiterative_comp_EQ)) {
+std::string Val = Args.getLastArgValue(options::OPT_fiterative_comp_EQ, "1");
+std::stringstream Convert(Val);
+Convert >> ICNumberOfIterations;
+   }
+  if (!ICNumberOfIterations)
+ICNumberOfIterations = 1; // Default value is 1.
+
+  std::string moduleName = llvm::getModuleName(argc_, argv_);
+
+  llvm::ModuleDecisionTrees moduleDecisionTrees(ICNumberOfIterations, true, moduleName);
+  int CurrentIteration = 0;
+  int Res = 0;
+
+  llvm::FnNameAndPhase::ICPhase CurrICPhase = llvm::FnNameAndPhase::ModulePhase;
+
+  // start of iterative compilation loop
+  for (; CurrentIteration < ICNumberOfIterations; CurrentIteration++) {
   ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
@@ -439,12 +546,34 @@
 
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
+  if (ICNumberOfIterations > 1) {
+TheDriver.setModuleDecisionTrees(&moduleDecisionTrees);
+
+initControlFiles(moduleDecisionTrees, CurrentIteration);
+writeInputFiles(moduleDecisionTrees);
+
+moduleDecisionTrees.startNewIteration();
+  }
+
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
   int Res = 0;
   SmallVector, 4> FailingCommands;
   if (C.get())
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
+ 

Re: [PATCH] D15726: Remove setting of inlinehint and cold attributes based on profile data

2015-12-30 Thread David Li via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D15726



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


Re: [libcxx] r250319 - [libcxx] Make it drastically simpler to link libc++.

2015-12-30 Thread Nico Weber via cfe-commits
gen_link_script.py is missing a license header.

On Thu, Oct 22, 2015 at 5:39 PM, Alexey Samsonov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Seems to work now, thanks for the quick fix!
>
> On Thu, Oct 22, 2015 at 1:57 PM, Eric Fiselier  wrote:
>
>> Hi Alexey,
>>
>> Please confirm that this works for you now after r251063. Sorry for the
>> breakage.
>>
>> /Eric
>>
>> On Thu, Oct 22, 2015 at 9:23 AM, Alexey Samsonov 
>> wrote:
>>
>>> After this change I am unable to configure libcxx as external project
>>> from compiler-rt with extra build flags.
>>> The problem is gen_link_script.py is invoked with incorrect number of
>>> arguments: LIBCXX_CXX_ABI_LIBNAME is automatically deduced to be "none",
>>> and LIBCXX_CXX_ABI_LIBRARY which is passed to gen_link_script.py is then
>>> empty.
>>>
>>> I can suppress this by using condition
>>>   if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT AND LIBCXX_CXX_ABI_LIBRARY)
>>> in libcxx/lib/CMakeLists.txt, but I don't think this fix is clean
>>> enough. I can also pass -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF when I
>>> configure libc++,
>>> but probably this should be deduced automatically...
>>>
>>>
>>> On Wed, Oct 21, 2015 at 5:44 PM, Eric Fiselier via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Thanks. I'll look to see if any other LLVM projects have bumped the
 CMake version to 3 yet. If so that's the direction I will head.




 On Oct 20, 2015 9:39 PM, "Hahnfeld, Jonas" 
 wrote:

> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> Behalf
> > Of Eric Fiselier via cfe-commits
> > Sent: Wednesday, October 14, 2015 9:54 PM
> > To: cfe-commits@lists.llvm.org
> > Subject: [libcxx] r250319 - [libcxx] Make it drastically simpler to
> link
> > libc++.
> >
> > Author: ericwf
> > Date: Wed Oct 14 14:54:03 2015
> > New Revision: 250319
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=250319&view=rev
> > Log:
> > [libcxx] Make it drastically simpler to link libc++.
> [...]
> >  if (LIBCXX_INSTALL_LIBRARY)
> >install(TARGETS cxx
> >  LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
> >  ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
> >  )
> > +  # NOTE: This install command must go after the cxx install command
> > + otherwise  # it will not be executed after the library symlinks are
> > installed.
> > +  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
> > +install(FILES "$"
> > +  DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
> > +  COMPONENT libcxx)
> > +  endif()
> >  endif()
>
> Generator expressions in install(FILES) are only allowed since CMake
> 3.0
> (https://cmake.org/cmake/help/v3.0/release/3.0.0.html#commands).
> The current minimum for libcxx is 2.8, so this should either be raised
> or we
> have to find another possibility of writing this install command...
>
> Greetings
> Jonas
>

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


>>>
>>>
>>> --
>>> Alexey Samsonov
>>> vonos...@gmail.com
>>>
>>
>>
>
>
> --
> Alexey Samsonov
> vonos...@gmail.com
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12299: [libcxx] Fix for ALL undefined behavior in .

2015-12-30 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Minor changes; other than that, LGTM.



Comment at: include/__config:43
@@ -42,1 +42,3 @@
+// Fix undefined behavior in how std::list stores it's linked nodes.
+#define _LIBCPP_ABI_LIST_NODE_FIX
 #endif

I would make this macro less generic than "fix". Maybe something like 
`_LIBCPP_ABI_LIST_REMOVE_UB_NODEPTR`


Comment at: include/list:690
@@ -662,3 +689,3 @@
 __f = __f->__next_;
-__node_alloc_traits::destroy(__na, 
_VSTD::addressof(__n->__value_));
-__node_alloc_traits::deallocate(__na, __n, 1);
+__node_pointer __np = __n->__as_node();
+__node_alloc_traits::destroy(__na, 
_VSTD::addressof(__np->__value_));

Do you really need `__n` here?
How about:
__node_pointer __np = __f->__as_node();
__f = __f->__next_;




http://reviews.llvm.org/D12299



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


Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-30 Thread Aaron Ballman via cfe-commits
On Wed, Dec 30, 2015 at 12:30 PM, Richard Smith  wrote:
> On Dec 30, 2015 6:34 AM, "Aaron Ballman"  wrote:
>>
>> aaron.ballman closed this revision.
>> aaron.ballman added a comment.
>>
>> Thanks! I've commit in r256643.
>>
>>
>> 
>> Comment at: test/SemaCXX/warn-literal-conversion.cpp:49-50
>> @@ +48,4 @@
>> +  // values.
>> +  bool b3 = 0.0f;
>> +  bool b4 = 0.0;
>> +}
>> 
>> rsmith wrote:
>> > What about
>> >
>> >   bool b5 = 1.0;
>> >   bool b6 = 2.0;
>> >
>> > ? Arguably any `float` -> `bool` conversion changes the value (because
>> > `true` and `false` are not values of type `float`), so it wouldn't be
>> > completely unreasonable to warn even if the literal is `0.0`.
>> Except those conversions won't cause confusion to the user, so I'm not
>> certain what we gain by diagnosing. Given that some mental models expect
>> 0.99 to convert to 0, which converts to false (because bool is an integral
>> type, so it "must" do the usual integral truncation dance), it makes sense
>> to tell the user "no no no, that converts to true." I'm less convinced about
>> the utility of warning on things like `bool b = 1.99f' where it changes the
>> value from 1.99 to true. Perhaps this should be changed to only diagnose
>> when converting through an integer would result in a different value that
>> converting through the float?
>
> Let me ask a slightly different question: when would it ever be reasonable
> and intentional to initialize a bool from a floating-point *literal*? For
> integers, people use things like
>
>   int n = 1e6;
>
> which is why we don't complain if the literal is exactly representable in
> the integer type. I can't imagine any similar cases for bool.

I see what you're getting at now, and I agree that it wouldn't be
particularly reasonable. However, I think that there are two things to
warn about: initializing from a literal in general, and initializing
from a literal where the resulting Boolean value may be surprising.
While we're at it: is there ever a time where it's reasonable to
initialize a bool from a literal of type other than an integer or
bool? For instance:

bool b1 = L'1';
bool b2 = '1';
bool b3 = 1.0f;
bool b4 = nullptr; // -Wnull-conversion catches this

I think it makes sense for all of these to diagnose under
-Wliteral-conversion, but drop the "changes value" clause.

bool b5 = 0.01;
bool b6 = '0';
bool b7 = L'0';

I think it makes sense for these to diagnose under
-Wliteral-conversion, but with the changes value clause.

~Aaron

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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-30 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Thank you for the review!

I'm waiting for llvm part of ifunc support because it has to be committed first.


http://reviews.llvm.org/D15524



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2015-12-30 Thread Richard via cfe-commits
LegalizeAdulthood marked an inline comment as done.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:4022
@@ +4021,3 @@
+/// functionProtoType()
+///   matches "int (*f)(int)" and the type of "g".
+AST_TYPE_MATCHER(FunctionProtoType, functionProtoType);

aaron.ballman wrote:
> Will this match g() in C mode?
No, because it doesn't declare g as a prototype.  To declare it as a prototype, 
it needs to be written

`void g(void);`



Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4988
@@ +4987,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+}

aaron.ballman wrote:
> Can we have a test for:
> ```
> EXPECT_TRUE(matches("typedef int foo; typedef foo bar;", 
> typedefDecl(hasUnderlyingType(asString("int")), hasName("bar";
> ```
> (I assume that this should work?)
This passes:

  EXPECT_TRUE(
  matches("typedef int foo; typedef foo bar;",
  typedefDecl(hasUnderlyingType(asString("foo")), hasName("bar";

but this does not:

  EXPECT_TRUE(
  matches("typedef int foo; typedef foo bar;",
  typedefDecl(hasUnderlyingType(asString("int")), hasName("bar";

I'm not really sure why; I expected that `Node.getUnderlyingType()` would 
return `int`, not `foo`.


http://reviews.llvm.org/D8149



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2015-12-30 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 43800.
LegalizeAdulthood added a comment.

Add more unit tests.


http://reviews.llvm.org/D8149

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4276,6 +4276,14 @@
   EXPECT_TRUE(matches("void f(int i) {}", functionType()));
 }
 
+TEST(TypeMatching, MatchesFunctionProtoTypes) {
+  EXPECT_TRUE(matches("int (*f)(int);", functionProtoType()));
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(
+  matchesC("void f(void);", functionProtoType(parameterCountIs(0;
+}
+
 TEST(TypeMatching, MatchesParenType) {
   EXPECT_TRUE(
   matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType());
@@ -4977,7 +4985,16 @@
   namespaceDecl(isInline(), hasName("m";
 }
 
-// FIXME: Figure out how to specify paths so the following tests pass on Windows.
+TEST(HasUnderlyingTypeMatcher, Match) {
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(
+  matches("typedef int foo; typedef foo bar;",
+  typedefDecl(hasUnderlyingType(asString("int")), hasName("bar";
+}
+
+// FIXME: Figure out how to specify paths so the following tests pass on
+// Windows.
 #ifndef LLVM_ON_WIN32
 
 TEST(Matcher, IsExpansionInMainFileMatcher) {
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -181,6 +181,7 @@
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);
+  REGISTER_MATCHER(functionProtoType);
   REGISTER_MATCHER(functionTemplateDecl);
   REGISTER_MATCHER(functionType);
   REGISTER_MATCHER(gotoStmt);
@@ -248,6 +249,7 @@
   REGISTER_MATCHER(hasTrueExpression);
   REGISTER_MATCHER(hasTypeLoc);
   REGISTER_MATCHER(hasUnaryOperand);
+  REGISTER_MATCHER(hasUnderlyingType);
   REGISTER_MATCHER(hasUnarySelector);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -168,6 +168,21 @@
 ///   matches "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches the underlying type of a typedef declaration
+///
+/// Given
+/// \code
+///   typedef int X;
+///   typedef float Y;
+/// \endcode
+/// typedefDecl(hasUnderlyingType(asString("int")))
+///   matches "typedef int X"
+AST_MATCHER_P(TypedefDecl, hasUnderlyingType, internal::Matcher,
+  InnerMatcher) {
+  QualType UnderlyingType = Node.getUnderlyingType();
+  return InnerMatcher.matches(UnderlyingType, Finder, Builder);
+}
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2889,16 +2904,24 @@
 Node.param_end(), Finder, Builder);
 }
 
-/// \brief Matches \c FunctionDecls that have a specific parameter count.
+/// \brief Matches \c FunctionDecls and FunctionProtoTypes that have a specific
+/// parameter count.
 ///
 /// Given
 /// \code
 ///   void f(int i) {}
 ///   void g(int i, int j) {}
+///   void h(int i, int j);
+///   void j(int i);
 /// \endcode
 /// functionDecl(parameterCountIs(2))
-///   matches g(int i, int j) {}
-AST_MATCHER_P(FunctionDecl, parameterCountIs, unsigned, N) {
+///   matches void g(int i, int j) {}
+/// functionProtoType(parameterCountIs(2))
+///   matches void h(int i, int j)
+AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+  FunctionProtoType),
+  unsigned, N) {
   return Node.getNumParams() == N;
 }
 
@@ -3988,6 +4011,17 @@
 ///   matches "int (*f)(int)" and the type of "g".
 AST_TYPE_MATCHER(FunctionType, functionType);
 
+/// \brief Matches \c FunctionProtoType nodes.
+///
+/// Given
+/// \code
+///   int (*f)(int);
+///   void g();
+/// \endcode
+/// functionProtoType()
+///   matches "int (*f)(int)" and the type of "g".
+AST_TYPE_MATCHER(FunctionProtoType, functionProtoType);
+
 /// \brief Matches \c ParenType nodes.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1299,6 +1299,17 @@
 
 
 

r256651 - Implement [temp.deduct.type]p6: if the nested-name-specifier of a type is

2015-12-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 30 14:56:05 2015
New Revision: 256651

URL: http://llvm.org/viewvc/llvm-project?rev=256651&view=rev
Log:
Implement [temp.deduct.type]p6: if the nested-name-specifier of a type is
dependent, the type is a non-deduced context.

Modified:
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=256651&r1=256650&r2=256651&view=diff
==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Wed Dec 30 14:56:05 2015
@@ -395,7 +395,7 @@ struct DeclarationNameLoc {
   // Locations (if any) for the tilde (destructor) or operator keyword
   // (conversion) are stored elsewhere.
   struct NT {
-TypeSourceInfo* TInfo;
+TypeSourceInfo *TInfo;
   };
 
   // The location (if any) of the operator keyword is stored elsewhere.

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=256651&r1=256650&r2=256651&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Dec 30 14:56:05 2015
@@ -4887,19 +4887,23 @@ MarkUsedTemplateParameters(ASTContext &C
 break;
 
   case Type::DependentTemplateSpecialization: {
+// C++14 [temp.deduct.type]p5:
+//   The non-deduced contexts are:
+// -- The nested-name-specifier of a type that was specified using a
+//qualified-id
+//
+// C++14 [temp.deduct.type]p6:
+//   When a type name is specified in a way that includes a non-deduced
+//   context, all of the types that comprise that type name are also
+//   non-deduced.
+if (OnlyDeduced)
+  break;
+
 const DependentTemplateSpecializationType *Spec
   = cast(T);
-if (!OnlyDeduced)
-  MarkUsedTemplateParameters(Ctx, Spec->getQualifier(),
- OnlyDeduced, Depth, Used);
 
-// C++0x [temp.deduct.type]p9:
-//   If the template argument list of P contains a pack expansion that is 
not
-//   the last template argument, the entire template argument list is a
-//   non-deduced context.
-if (OnlyDeduced &&
-hasPackExpansionBeforeEnd(Spec->getArgs(), Spec->getNumArgs()))
-  break;
+MarkUsedTemplateParameters(Ctx, Spec->getQualifier(),
+   OnlyDeduced, Depth, Used);
 
 for (unsigned I = 0, N = Spec->getNumArgs(); I != N; ++I)
   MarkUsedTemplateParameters(Ctx, Spec->getArg(I), OnlyDeduced, Depth,

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=256651&r1=256650&r2=256651&view=diff
==
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Wed Dec 30 14:56:05 2015
@@ -207,3 +207,14 @@ namespace PR18645 {
   template F Quux(F &&f);
   auto Baz = Quux(Quux);
 }
+
+namespace NonDeducedNestedNameSpecifier {
+  template struct A {
+template struct B {
+  B(int) {}
+};
+  };
+
+  template int f(A, typename A::template B);
+  int k = f(A(), 0);
+}


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


Re: [PATCH] D12299: [libcxx] Fix for ALL undefined behavior in .

2015-12-30 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 43802.
EricWF added a comment.

- Change ABI macro name to `_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB`.
- Remove unnecessary variable pointed out in review.
- Rename `__node_pointer_traits` to `__list_node_pointer_traits` to prevent 
name collisions.


http://reviews.llvm.org/D12299

Files:
  include/__config
  include/list

Index: include/list
===
--- include/list
+++ include/list
@@ -175,6 +175,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include <__undef_min_max>
 
@@ -187,25 +188,55 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template  struct __list_node;
+template  struct __list_node_base;
+
+template 
+struct __list_node_pointer_traits {
+  typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
+__node_pointer;
+  typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type
+__base_pointer;
+
+#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
+  typedef __base_pointer __link_pointer;
+#else
+  typedef typename conditional<
+  is_pointer<_VoidPtr>::value,
+  __base_pointer,
+  __node_pointer
+  >::type __link_pointer;
+#endif
+
+};
 
 template 
 struct __list_node_base
 {
-typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
-pointer;
-typedef typename __rebind_pointer<_VoidPtr, __list_node_base>::type
-__base_pointer;
+typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+typedef typename _NodeTraits::__node_pointer __node_pointer;
+typedef typename _NodeTraits::__base_pointer __base_pointer;
+typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-pointer __prev_;
-pointer __next_;
+__link_pointer __prev_;
+__link_pointer __next_;
 
 _LIBCPP_INLINE_VISIBILITY
-__list_node_base() : __prev_(__self()), __next_(__self()) {}
+__list_node_base() : __prev_(__as_link()), __next_(__as_link()) {}
 
 _LIBCPP_INLINE_VISIBILITY
-pointer __self()
-{
-return static_cast(pointer_traits<__base_pointer>::pointer_to(*this));
+__base_pointer __as_base() {
+return pointer_traits<__base_pointer>::pointer_to(*this);
+}
+
+_LIBCPP_INLINE_VISIBILITY
+__link_pointer __as_link() {
+return static_cast<__link_pointer>(static_cast<_VoidPtr>(
+__as_base()));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+__node_pointer __as_node() {
+return static_cast<__node_pointer>(__as_base());
 }
 };
 
@@ -223,21 +254,21 @@
 template 
 class _LIBCPP_TYPE_VIS_ONLY __list_iterator
 {
-typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
-__node_pointer;
+typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-__node_pointer __ptr_;
+__link_pointer __ptr_;
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_INLINE_VISIBILITY
-explicit __list_iterator(__node_pointer __p, const void* __c) _NOEXCEPT
+explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
 : __ptr_(__p)
 {
 __get_db()->__insert_ic(this, __c);
 }
 #else
 _LIBCPP_INLINE_VISIBILITY
-explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
 #endif
 
 
@@ -295,16 +326,16 @@
 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable list::iterator");
 #endif
-return __ptr_->__value_;
+return __ptr_->__as_node()->__value_;
 }
 _LIBCPP_INLINE_VISIBILITY
 pointer operator->() const
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable list::iterator");
 #endif
-return pointer_traits::pointer_to(__ptr_->__value_);
+return pointer_traits::pointer_to(__ptr_->__as_node()->__value_);
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -346,21 +377,21 @@
 template 
 class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator
 {
-typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
-__node_pointer;
+typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-__node_pointer __ptr_;
+__link_pointer __ptr_;
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_INLINE_VISIBILITY
-explicit __list_const_iterator(__node_pointer __p, const void* __c) _NOEXCEPT
+explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
 : __ptr_(__p)
 {
 __get_db()->__insert_ic(this, __c);
 }
 #else
 _LIBCPP_INLINE_VISIBILITY
-explicit __list_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(_

[libcxx] r256652 - [libcxx] Fix for ALL undefined behavior in .

2015-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 30 14:57:59 2015
New Revision: 256652

URL: http://llvm.org/viewvc/llvm-project?rev=256652&view=rev
Log:
[libcxx] Fix for ALL undefined behavior in .

Summary:
This patch fixes std::list for builtin pointer types in the current ABI version 
and fixes std::list for all fancy pointer types in the next ABI version. The 
patch was designed to minimize the amount of code needed to support both ABI 
configurations. Currently only ~5 lines of code differ.


Reviewers: danalbert, jroelofs, mclow.lists

Subscribers: dexonsmith, awi, cfe-commits

Differential Revision: http://reviews.llvm.org/D12299

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/list

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=256652&r1=256651&r2=256652&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Dec 30 14:57:59 2015
@@ -39,6 +39,8 @@
 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 // Fix deque iterator type in order to support incomplete types.
 #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+// Fix undefined behavior in how std::list stores it's linked nodes.
+#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
 #endif
 
 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y

Modified: libcxx/trunk/include/list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=256652&r1=256651&r2=256652&view=diff
==
--- libcxx/trunk/include/list (original)
+++ libcxx/trunk/include/list Wed Dec 30 14:57:59 2015
@@ -175,6 +175,7 @@ template 
 #include 
 #include 
 #include 
+#include 
 
 #include <__undef_min_max>
 
@@ -187,25 +188,55 @@ template 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template  struct __list_node;
+template  struct __list_node_base;
+
+template 
+struct __list_node_pointer_traits {
+  typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> 
>::type
+__node_pointer;
+  typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> 
>::type
+__base_pointer;
+
+#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
+  typedef __base_pointer __link_pointer;
+#else
+  typedef typename conditional<
+  is_pointer<_VoidPtr>::value,
+  __base_pointer,
+  __node_pointer
+  >::type __link_pointer;
+#endif
+
+};
 
 template 
 struct __list_node_base
 {
-typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> 
>::type
-pointer;
-typedef typename __rebind_pointer<_VoidPtr, __list_node_base>::type
-__base_pointer;
+typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+typedef typename _NodeTraits::__node_pointer __node_pointer;
+typedef typename _NodeTraits::__base_pointer __base_pointer;
+typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-pointer __prev_;
-pointer __next_;
+__link_pointer __prev_;
+__link_pointer __next_;
 
 _LIBCPP_INLINE_VISIBILITY
-__list_node_base() : __prev_(__self()), __next_(__self()) {}
+__list_node_base() : __prev_(__as_link()), __next_(__as_link()) {}
 
 _LIBCPP_INLINE_VISIBILITY
-pointer __self()
-{
-return 
static_cast(pointer_traits<__base_pointer>::pointer_to(*this));
+__base_pointer __as_base() {
+return pointer_traits<__base_pointer>::pointer_to(*this);
+}
+
+_LIBCPP_INLINE_VISIBILITY
+__link_pointer __as_link() {
+return static_cast<__link_pointer>(static_cast<_VoidPtr>(
+__as_base()));
+}
+
+_LIBCPP_INLINE_VISIBILITY
+__node_pointer __as_node() {
+return static_cast<__node_pointer>(__as_base());
 }
 };
 
@@ -223,21 +254,21 @@ template  cla
 template 
 class _LIBCPP_TYPE_VIS_ONLY __list_iterator
 {
-typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> 
>::type
-__node_pointer;
+typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
+typedef typename _NodeTraits::__link_pointer __link_pointer;
 
-__node_pointer __ptr_;
+__link_pointer __ptr_;
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_INLINE_VISIBILITY
-explicit __list_iterator(__node_pointer __p, const void* __c) _NOEXCEPT
+explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
 : __ptr_(__p)
 {
 __get_db()->__insert_ic(this, __c);
 }
 #else
 _LIBCPP_INLINE_VISIBILITY
-explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
 #endif
 
 
@@ -295,7 +326,7 @@ public:
 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable 
list::iterator");
 #endif
-return __ptr_->__value_;
+return 

Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2015-12-30 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:2908
@@ -2893,1 +2907,3 @@
+/// \brief Matches \c FunctionDecls and FunctionProtoTypes that have a specific
+/// parameter count.
 ///

Can you document the expected parameter count for:
```
void f(int i, ...);
```
(I would expect it to report 1.)


Comment at: include/clang/ASTMatchers/ASTMatchers.h:4022
@@ +4021,3 @@
+/// functionProtoType()
+///   matches "int (*f)(int)" and the type of "g".
+AST_TYPE_MATCHER(FunctionProtoType, functionProtoType);

That's what I was expecting; can you update the comment to match reality?


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4282
@@ +4281,3 @@
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(

This isn't quite what I had in mind. The test you added is a good one to add, 
but I wanted a test that functionProtoType() does *not* match f() (because it 
has no prototype), and another test for parameterCountIs() that it does't 
explode on a function without a prototype in C.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4990
@@ +4989,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(

I would expect hasUnderlyingType to look through all of the type sugar, not 
just the top layer of it (since existing matchers can implement the current 
behavior by using hasType, I believe). I think the correct approach is to get 
the underlying type, then loop to see whether that type matches, and if not, 
strip off a layer of sugar and try again. Terminate the loop when there's no 
more sugar to strip. The following should all match:
```
EXPECT_TRUE(
  matches("typedef int foo; typedef foo bar; typedef bar baz;",
  typedefDecl(hasUnderlyingType(asString("int")), hasName("bar";
EXPECT_TRUE(
  matches("typedef int foo; typedef foo bar; typedef bar baz;",
  typedefDecl(hasUnderlyingType(asString("foo")), hasName("baz";
EXPECT_TRUE(
  matches("typedef int foo; typedef foo bar; typedef bar baz;",
  typedefDecl(hasUnderlyingType(asString("int")), hasName("baz";
```
The other question I have is about qualifiers. Should this match?
```
EXPECT_TRUE(
  matches("typedef const int foo;",
  typedefDecl(hasUnderlyingType(asString("int")), hasName("foo";
```
Or should it require `asString("const int")`?
(Regardless of the answer, we should document the behavior and add a test with 
qualifiers.)


http://reviews.llvm.org/D8149



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


Re: [libcxx] r249798 - Split out of .

2015-12-30 Thread Nico Weber via cfe-commits
One problem with this patch: stdio.h can be used in .c files, and when
building .c files with -gnu99 -pedantic, clang will complain about //
comments. Not only does this stdio.h have // comments, it also pulls in
some libc++ headers (__config) that have // comments as well. I suppose all
the comments in header files pulled in by C headers need to become /* */
comments?

On Tue, Oct 13, 2015 at 7:34 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Oct 13, 2015 at 3:26 PM, Eric Fiselier  wrote:
>
>> This change LGTM. Let's hold off on the using "_Static_assert" until we
>> understand how that would work with "-pedantic" when the macro is expanded
>> in user code.
>>
>
> Committed as r250247, thanks.
>
>
>> /Eric
>>
>> On Tue, Oct 13, 2015 at 4:19 PM, Richard Smith 
>> wrote:
>>
>>> On Tue, Oct 13, 2015 at 2:12 PM, Eric Fiselier via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 I would rather not do this if possible but I understand why we need to
 do it.

 Richard is there a cost associated with the 'extern "C++"' construct?
 or by forcing the compiler to switch modes in general?

>>>
>>> Not a significant one compared to the cost of the code wrapped in the
>>> 'extern "C++"' here. (Also, this is wrapped in an #ifdef that only applies
>>> in C++98; we could further reduce the set of cases when this happens by
>>> using _Static_assert when available instead of this static_assert
>>> emulation.)
>>>
>>>
 On Mon, Oct 12, 2015 at 12:27 PM, Richard Smith 
 wrote:

> On Mon, Oct 12, 2015 at 9:41 AM, Steven Wu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi Richard
>>
>> Your splitting seems causing problem when using extern "C". Here is a
>> test case:
>>
>> $ cat test.cpp
>> #ifdef __cplusplus
>> extern "C" {
>> #endif
>> #include 
>> #ifdef __cplusplus
>> }
>> #endif
>>
>> Error:
>> clang -fsyntax-only test.cpp
>> In file included from test.cpp:4:
>> In file included from /usr/bin/../include/c++/v1/stdio.h:102:
>> /usr/bin/../include/c++/v1/__config:593:1: error:
>>   templates must have C++ linkage
>> template  struct __static_assert_test;
>> ^~~
>> /usr/bin/../include/c++/v1/__config:594:20: error:
>>   explicit specialization of non-template struct
>> '__static_assert_test'
>> template <> struct __static_assert_test {};
>>^   ~~
>> /usr/bin/../include/c++/v1/__config:595:1: error:
>>   templates must have C++ linkage
>> template  struct __static_assert_check {};
>> ^~~
>> 3 errors generated.
>>
>> Because the code is actually compiled in C++, the guard in the header
>> failed to exclude the templates. In the meantime, I don't know if there 
>> are
>> ways to detect the header is in extern "C".
>>
>
> This was supposed to work, but apparently I only tested it when
> compiling as C++11; the static_assert emulation in C++98 mode needs some
> massaging to cope with this.
>
> Eric, Marshall: Are you OK with the attached patch? The idea is to
> make <__config> be fine to include in extern "C" or extern "C++" modes 
> (and
> likewise for the  headers). This is something that comes up pretty
> often in practice (people wrap an include of a C header in 'extern "C"',
> and that C header includes a  file that libc++ provides).
>
>
>> Steven
>>
>>
>> > On Oct 8, 2015, at 6:29 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >
>> > Author: rsmith
>> > Date: Thu Oct  8 20:29:09 2015
>> > New Revision: 249798
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=249798&view=rev
>> > Log:
>> > Split  out of .
>> >
>> > As with , skip our custom header if __need_FILE or
>> __need___FILE is defined.
>> >
>> > Added:
>> >libcxx/trunk/include/stdio.h
>> >  - copied, changed from r249736, libcxx/trunk/include/cstdio
>> > Modified:
>> >libcxx/trunk/include/cstdio
>> >libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
>> >
>> > Modified: libcxx/trunk/include/cstdio
>> > URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=249798&r1=249797&r2=249798&view=diff
>> >
>> ==
>> > --- libcxx/trunk/include/cstdio (original)
>> > +++ libcxx/trunk/include/cstdio Thu Oct  8 20:29:09 2015
>> > @@ -103,16 +103,6 @@ void perror(const char* s);
>> > #pragma GCC system_header
>> > #endif
>> >
>> > -// snprintf
>> > -#if defined(_LIBCPP_MSVCRT)
>> > -#include "support/win32/support.h"
>> > -#endif
>> > -
>> > -#undef getc
>> > -#undef putc
>> > -

Re: [PATCH] D15797: [clang-tidy] Fix readability-braces-around-statements assert failure

2015-12-30 Thread Matt Stancliff via cfe-commits
mattsta added a comment.

Yeah, I fully understand the need to make sure it doesn't break again (or that 
this actually fixes it properly), but these changes are about the limit of my 
LLVM+Tidy internals understanding.  (What's missing from this diff is the 20 
hours across 4-6 months where I tried to fix it "properly" but could never 
figure out how things were getting to an Invalid state to begin with.)

I'll leave this in more capable hands than my own at this point.  It's easy to 
reproduce the assert failures on large source dirs (a freebsd checkout, an 
erlang checkout, etc), but I couldn't narrow down what triggers the failures.


Repository:
  rL LLVM

http://reviews.llvm.org/D15797



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


[PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2015-12-30 Thread Rong Xu via cfe-commits
xur created this revision.
xur added reviewers: davidxl, silvas, bogner.
xur added a subscriber: cfe-commits.

This patch introduce a new toggle option -fprofile-ir-instr that enables IR 
level instrumentation. It needs to be used in combination with current PGO 
options. Without an existing PGO options, this option alone is a null operation.
 
This patch depends on llvm patch http://reviews.llvm.org/D15828 where we 
introduce a pair of passmanagerbuilder options: 
 -profile-generate=
 -profile-use=
Note that the profile specified in driver level options 
(-fprofile-instr-generate, -fprofile-instr-use, -fprofile-generate, and 
-profile-use) overrides the profile in the passmanagerbuilder option.


http://reviews.llvm.org/D15829

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -449,8 +449,10 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
-  Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
-  Args.hasArg(OPT_fprofile_instr_generate_EQ);
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr);
+  if (!Opts.ProfileIRInstr)
+Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
+Args.hasArg(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileOutput = 
Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
   Opts.CoverageMapping =
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3223,6 +3223,8 @@
   CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
 }
   }
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }
 
 static void addPS4ProfileRTArgs(const ToolChain &TC, const ArgList &Args,
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -147,7 +147,7 @@
   if (C.getLangOpts().ObjC1)
 ObjCData = new ObjCEntrypoints();
 
-  if (!CodeGenOpts.InstrProfileInput.empty()) {
+  if (!CodeGenOpts.ProfileIRInstr && !CodeGenOpts.InstrProfileInput.empty()) {
 auto ReaderOrErr =
 llvm::IndexedInstrProfReader::create(CodeGenOpts.InstrProfileInput);
 if (std::error_code EC = ReaderOrErr.getError()) {
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -431,6 +431,14 @@
 MPM->add(createInstrProfilingPass(Options));
   }
 
+  if (CodeGenOpts.ProfileIRInstr) {
+assert (!CodeGenOpts.ProfileInstrGenerate);
+if (!CodeGenOpts.InstrProfileOutput.empty())
+  PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
+if (!CodeGenOpts.InstrProfileInput.empty())
+  PMBuilder.PGOInstrUse = CodeGenOpts.InstrProfileInput;
+  }
+
   if (!CodeGenOpts.SampleProfileFile.empty())
 MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
 
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -105,6 +105,7 @@
 
 CODEGENOPT(ProfileInstrGenerate , 1, 0) ///< Instrument code to generate
 ///< execution counts to use with PGO.
+CODEGENOPT(ProfileIRInstr, 1, 0) ///< IR level code PGO instrumentation and 
use.
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -452,6 +452,9 @@
 def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">,
 Group, Flags<[CC1Option]>,
 HelpText<"Use instrumentation data for profile-guided optimization">;
+def fprofile_ir_instr : Flag<["-"], "fprofile-ir-instr">, Group,
+Flags<[CC1Option]>,
+HelpText<"Use IR level instrumentation rather the FE implementation">;
 def fcoverage_mapping : Flag<["-"], "fcoverage-mapping">,
 Group, Flags<[CC1Option]>,
 HelpText<"Generate coverage mapping to enable code coverage analysis">;


Index: lib/Frontend/CompilerInvocation.cpp
===

[libcxx] r256654 - Use __rebind_pointer to avoid #ifdef block

2015-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 30 15:52:00 2015
New Revision: 256654

URL: http://llvm.org/viewvc/llvm-project?rev=256654&view=rev
Log:
Use __rebind_pointer to avoid #ifdef block

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__tree
libcxx/trunk/include/ext/hash_map
libcxx/trunk/include/forward_list
libcxx/trunk/include/map
libcxx/trunk/include/unordered_map

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=256654&r1=256653&r2=256654&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Wed Dec 30 15:52:00 2015
@@ -46,12 +46,7 @@ template 
 struct __hash_node
 : public __hash_node_base
  <
- typename pointer_traits<_VoidPtr>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
- rebind<__hash_node<_Tp, _VoidPtr> >
-#else
- rebind<__hash_node<_Tp, _VoidPtr> >::other
-#endif
+ typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, 
_VoidPtr> >::type
  >
 {
 typedef _Tp value_type;
@@ -98,13 +93,7 @@ public:
 typedef typename pointer_traits<__node_pointer>::element_type::value_type 
value_type;
 typedef typename pointer_traits<__node_pointer>::difference_type 
difference_type;
 typedef value_type&  reference;
-typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
- rebind
-#else
- rebind::other
-#endif
- pointer;
+typedef typename __rebind_pointer<__node_pointer, value_type>::type 
pointer;
 
 _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT
 #if _LIBCPP_STD_VER > 11
@@ -229,20 +218,8 @@ public:
 typedef typename __node::value_typevalue_type;
 typedef typename pointer_traits<__node_pointer>::difference_type 
difference_type;
 typedef const value_type&  reference;
-typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-rebind
-#else
-rebind::other
-#endif
-   pointer;
-typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-rebind<__node>
-#else
-rebind<__node>::other
-#endif
-  __non_const_node_pointer;
+typedef typename __rebind_pointer<__node_pointer, const value_type>::type 
pointer;
+typedef typename __rebind_pointer<__node_pointer, __node>::type 
__non_const_node_pointer;
 typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator;
 
 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT
@@ -376,13 +353,7 @@ public:
 typedef typename __pointer_traits::element_type::value_type value_type;
 typedef typename __pointer_traits::difference_type  
difference_type;
 typedef value_type& reference;
-typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-rebind
-#else
-rebind::other
-#endif
-pointer;
+typedef typename __rebind_pointer<__node_pointer, value_type>::type 
pointer;
 
 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT
 {
@@ -514,13 +485,9 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const
 typedef pointer_traits<__node_pointer>  __pointer_traits;
 typedef typename __pointer_traits::element_type __node;
 typedef typename remove_const<__node>::type __non_const_node;
-typedef typename pointer_traits<__node_pointer>::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-rebind<__non_const_node>
-#else
-rebind<__non_const_node>::other
-#endif
-__non_const_node_pointer;
+typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
+__non_const_node_pointer;
+
 typedef __hash_local_iterator<__non_const_node_pointer>
 __non_const_iterator;
 public:
@@ -530,13 +497,9 @@ public:
  >::type   value_type;
 typedef typename __pointer_traits::difference_type difference_type;
 typedef const value_type&  reference;
-typedef typename __pointer_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-rebind
-#else
-rebind::other
-#endif
-   pointer;
+typedef typename __rebind_pointer<__node_pointer, const value_type>::type
+

Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-30 Thread Richard Smith via cfe-commits
On Dec 30, 2015 11:53 AM, "Aaron Ballman"  wrote:
>
> On Wed, Dec 30, 2015 at 12:30 PM, Richard Smith 
wrote:
> > On Dec 30, 2015 6:34 AM, "Aaron Ballman" 
wrote:
> >>
> >> aaron.ballman closed this revision.
> >> aaron.ballman added a comment.
> >>
> >> Thanks! I've commit in r256643.
> >>
> >>
> >> 
> >> Comment at: test/SemaCXX/warn-literal-conversion.cpp:49-50
> >> @@ +48,4 @@
> >> +  // values.
> >> +  bool b3 = 0.0f;
> >> +  bool b4 = 0.0;
> >> +}
> >> 
> >> rsmith wrote:
> >> > What about
> >> >
> >> >   bool b5 = 1.0;
> >> >   bool b6 = 2.0;
> >> >
> >> > ? Arguably any `float` -> `bool` conversion changes the value
(because
> >> > `true` and `false` are not values of type `float`), so it wouldn't be
> >> > completely unreasonable to warn even if the literal is `0.0`.
> >> Except those conversions won't cause confusion to the user, so I'm not
> >> certain what we gain by diagnosing. Given that some mental models
expect
> >> 0.99 to convert to 0, which converts to false (because bool is an
integral
> >> type, so it "must" do the usual integral truncation dance), it makes
sense
> >> to tell the user "no no no, that converts to true." I'm less convinced
about
> >> the utility of warning on things like `bool b = 1.99f' where it
changes the
> >> value from 1.99 to true. Perhaps this should be changed to only
diagnose
> >> when converting through an integer would result in a different value
that
> >> converting through the float?
> >
> > Let me ask a slightly different question: when would it ever be
reasonable
> > and intentional to initialize a bool from a floating-point *literal*?
For
> > integers, people use things like
> >
> >   int n = 1e6;
> >
> > which is why we don't complain if the literal is exactly representable
in
> > the integer type. I can't imagine any similar cases for bool.
>
> I see what you're getting at now, and I agree that it wouldn't be
> particularly reasonable. However, I think that there are two things to
> warn about: initializing from a literal in general, and initializing
> from a literal where the resulting Boolean value may be surprising.
> While we're at it: is there ever a time where it's reasonable to
> initialize a bool from a literal of type other than an integer or
> bool? For instance:
>
> bool b1 = L'1';
> bool b2 = '1';
> bool b3 = 1.0f;
> bool b4 = nullptr; // -Wnull-conversion catches this
>
> I think it makes sense for all of these to diagnose under
> -Wliteral-conversion, but drop the "changes value" clause.
>
> bool b5 = 0.01;
> bool b6 = '0';
> bool b7 = L'0';
>
> I think it makes sense for these to diagnose under
> -Wliteral-conversion, but with the changes value clause.

That makes sense to me. IIRC, we have seen initialization of a bool from a
string literal "true" or -- worse -- "false" a few times.

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


Re: [libcxx] r249798 - Split out of .

2015-12-30 Thread Richard Smith via cfe-commits
On Wed, Dec 30, 2015 at 1:17 PM, Nico Weber  wrote:

> One problem with this patch: stdio.h can be used in .c files, and when
> building .c files with -gnu99 -pedantic,
>

Do you mean -std=gnu89?


> clang will complain about // comments. Not only does this stdio.h have //
> comments, it also pulls in some libc++ headers (__config) that have //
> comments as well. I suppose all the comments in header files pulled in by C
> headers need to become /* */ comments?
>

I suppose so too. Your configuration is probably somewhat broken if
libc++'s headers are in your include path while building C code, but it
doesn't seem unreasonable to properly support that mode, and my changes
were already trying to do so.

Eric, Marshall, what do you think about using only /*...*/-style comments
in these headers, to handle the case where libc++ is somehow in the include
path for a C89 compilation?


> On Tue, Oct 13, 2015 at 7:34 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Tue, Oct 13, 2015 at 3:26 PM, Eric Fiselier  wrote:
>>
>>> This change LGTM. Let's hold off on the using "_Static_assert" until we
>>> understand how that would work with "-pedantic" when the macro is expanded
>>> in user code.
>>>
>>
>> Committed as r250247, thanks.
>>
>>
>>> /Eric
>>>
>>> On Tue, Oct 13, 2015 at 4:19 PM, Richard Smith 
>>> wrote:
>>>
 On Tue, Oct 13, 2015 at 2:12 PM, Eric Fiselier via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> I would rather not do this if possible but I understand why we need to
> do it.
>
> Richard is there a cost associated with the 'extern "C++"' construct?
> or by forcing the compiler to switch modes in general?
>

 Not a significant one compared to the cost of the code wrapped in the
 'extern "C++"' here. (Also, this is wrapped in an #ifdef that only applies
 in C++98; we could further reduce the set of cases when this happens by
 using _Static_assert when available instead of this static_assert
 emulation.)


> On Mon, Oct 12, 2015 at 12:27 PM, Richard Smith  > wrote:
>
>> On Mon, Oct 12, 2015 at 9:41 AM, Steven Wu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hi Richard
>>>
>>> Your splitting seems causing problem when using extern "C". Here is
>>> a test case:
>>>
>>> $ cat test.cpp
>>> #ifdef __cplusplus
>>> extern "C" {
>>> #endif
>>> #include 
>>> #ifdef __cplusplus
>>> }
>>> #endif
>>>
>>> Error:
>>> clang -fsyntax-only test.cpp
>>> In file included from test.cpp:4:
>>> In file included from /usr/bin/../include/c++/v1/stdio.h:102:
>>> /usr/bin/../include/c++/v1/__config:593:1: error:
>>>   templates must have C++ linkage
>>> template  struct __static_assert_test;
>>> ^~~
>>> /usr/bin/../include/c++/v1/__config:594:20: error:
>>>   explicit specialization of non-template struct
>>> '__static_assert_test'
>>> template <> struct __static_assert_test {};
>>>^   ~~
>>> /usr/bin/../include/c++/v1/__config:595:1: error:
>>>   templates must have C++ linkage
>>> template  struct __static_assert_check {};
>>> ^~~
>>> 3 errors generated.
>>>
>>> Because the code is actually compiled in C++, the guard in the
>>> header failed to exclude the templates. In the meantime, I don't know if
>>> there are ways to detect the header is in extern "C".
>>>
>>
>> This was supposed to work, but apparently I only tested it when
>> compiling as C++11; the static_assert emulation in C++98 mode needs some
>> massaging to cope with this.
>>
>> Eric, Marshall: Are you OK with the attached patch? The idea is to
>> make <__config> be fine to include in extern "C" or extern "C++" modes 
>> (and
>> likewise for the  headers). This is something that comes up pretty
>> often in practice (people wrap an include of a C header in 'extern "C"',
>> and that C header includes a  file that libc++ provides).
>>
>>
>>> Steven
>>>
>>>
>>> > On Oct 8, 2015, at 6:29 PM, Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>> >
>>> > Author: rsmith
>>> > Date: Thu Oct  8 20:29:09 2015
>>> > New Revision: 249798
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=249798&view=rev
>>> > Log:
>>> > Split  out of .
>>> >
>>> > As with , skip our custom header if __need_FILE or
>>> __need___FILE is defined.
>>> >
>>> > Added:
>>> >libcxx/trunk/include/stdio.h
>>> >  - copied, changed from r249736, libcxx/trunk/include/cstdio
>>> > Modified:
>>> >libcxx/trunk/include/cstdio
>>> >libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
>>> >
>>> > Modified: libcxx/trunk/include/cstdio
>>> > URL:

r256657 - Improve diagnostic for the case where a function template candidate is rejected

2015-12-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 30 20:02:54 2015
New Revision: 256657

URL: http://llvm.org/viewvc/llvm-project?rev=256657&view=rev
Log:
Improve diagnostic for the case where a function template candidate is rejected
by overload resolution because deduction succeeds, but the substituted
parameter type for some parameter (with deduced type) doesn't exactly match the
corresponding adjusted argument type.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/TemplateDeduction.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=256657&r1=256656&r2=256657&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 30 20:02:54 
2015
@@ -3112,6 +3112,10 @@ def note_addrof_ovl_candidate_disabled_b
 def note_ovl_candidate_failed_overload_resolution : Note<
 "candidate template ignored: couldn't resolve reference to overloaded "
 "function %0">;
+def note_ovl_candidate_deduced_mismatch : Note<
+"candidate template ignored: deduced type "
+"%diff{$ of %ordinal0 parameter does not match adjusted type $ of argument"
+"|of %ordinal0 parameter does not match adjusted type of argument}1,2%3">;
 def note_ovl_candidate_non_deduced_mismatch : Note<
 "candidate template ignored: could not match %diff{$ against $|types}0,1">;
 // This note is needed because the above note would sometimes print two

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256657&r1=256656&r2=256657&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Dec 30 20:02:54 2015
@@ -6302,6 +6302,9 @@ public:
 /// \brief Substitution of the deduced template argument values
 /// resulted in an error.
 TDK_SubstitutionFailure,
+/// \brief After substituting deduced template arguments, a dependent
+/// parameter type did not match the corresponding argument.
+TDK_DeducedMismatch,
 /// \brief A non-depnedent component of the parameter did not match the
 /// corresponding component of the argument.
 TDK_NonDeducedMismatch,

Modified: cfe/trunk/include/clang/Sema/TemplateDeduction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/TemplateDeduction.h?rev=256657&r1=256656&r2=256657&view=diff
==
--- cfe/trunk/include/clang/Sema/TemplateDeduction.h (original)
+++ cfe/trunk/include/clang/Sema/TemplateDeduction.h Wed Dec 30 20:02:54 2015
@@ -140,6 +140,9 @@ public:
   ///   TDK_SubstitutionFailure: this argument is the template
   ///   argument we were instantiating when we encountered an error.
   ///
+  ///   TDK_DeducedMismatch: this is the parameter type, after substituting
+  ///   deduced arguments.
+  ///
   ///   TDK_NonDeducedMismatch: this is the component of the 'parameter'
   ///   of the deduction, directly provided in the source code.
   TemplateArgument FirstArg;
@@ -147,18 +150,32 @@ public:
   /// \brief The second template argument to which the template
   /// argument deduction failure refers.
   ///
+  ///   TDK_Inconsistent: this argument is the second value deduced
+  ///   for the corresponding template parameter.
+  ///
+  ///   TDK_DeducedMismatch: this is the (adjusted) call argument type.
+  ///
   ///   TDK_NonDeducedMismatch: this is the mismatching component of the
   ///   'argument' of the deduction, from which we are deducing arguments.
   ///
   /// FIXME: Finish documenting this.
   TemplateArgument SecondArg;
 
-  /// \brief The expression which caused a deduction failure.
-  ///
-  ///   TDK_FailedOverloadResolution: this argument is the reference to
-  ///   an overloaded function which could not be resolved to a specific
-  ///   function.
-  Expr *Expression;
+  union {
+/// \brief The expression which caused a deduction failure.
+///
+///   TDK_FailedOverloadResolution: this argument is the reference to
+///   an overloaded function which could not be resolved to a specific
+///   function.
+Expr *Expression;
+
+/// \brief The index of the function argument that caused a deduction
+/// failure.
+///
+///   TDK_DeducedMismatch: this is the index of the argument that had a
+///   different argumen

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2015-12-30 Thread David Li via cfe-commits
davidxl added a comment.

Should add a test case in test/Driver/instrprof-ld.c.



Comment at: lib/CodeGen/BackendUtil.cpp:435
@@ +434,3 @@
+  if (CodeGenOpts.ProfileIRInstr) {
+assert (!CodeGenOpts.ProfileInstrGenerate);
+if (!CodeGenOpts.InstrProfileOutput.empty())

What is this asserting about?


Comment at: lib/Frontend/CompilerInvocation.cpp:453
@@ +452,3 @@
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr);
+  if (!Opts.ProfileIRInstr)
+Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||

Add a comment here.


http://reviews.llvm.org/D15829



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


r256658 - [TrailingObjects] Convert remaining classes in Expr.h and ExprCXX.h

2015-12-30 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Wed Dec 30 22:18:25 2015
New Revision: 256658

URL: http://llvm.org/viewvc/llvm-project?rev=256658&view=rev
Log:
[TrailingObjects] Convert remaining classes in Expr.h and ExprCXX.h

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=256658&r1=256657&r2=256658&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Dec 30 22:18:25 2015
@@ -2190,7 +2190,8 @@ public:
 return reinterpret_cast(SubExprs+getNumPreArgs()+PREARGS_START);
   }
   const Expr *const *getArgs() const {
-return const_cast(this)->getArgs();
+return reinterpret_cast(SubExprs + getNumPreArgs() +
+ PREARGS_START);
   }
 
   /// getArg - Return the specified argument.
@@ -3926,7 +3927,9 @@ public:
 /// which covers @c [2].y=1.0. This DesignatedInitExpr will have two
 /// designators, one array designator for @c [2] followed by one field
 /// designator for @c .y. The initialization expression will be 1.0.
-class DesignatedInitExpr : public Expr {
+class DesignatedInitExpr final
+: public Expr,
+  private llvm::TrailingObjects {
 public:
   /// \brief Forward declaration of the Designator class.
   class Designator;
@@ -4206,12 +4209,12 @@ public:
 
   Expr *getSubExpr(unsigned Idx) const {
 assert(Idx < NumSubExprs && "Subscript out of range");
-return cast(reinterpret_cast(this + 1)[Idx]);
+return cast(getTrailingObjects()[Idx]);
   }
 
   void setSubExpr(unsigned Idx, Expr *E) {
 assert(Idx < NumSubExprs && "Subscript out of range");
-reinterpret_cast(this + 1)[Idx] = E;
+getTrailingObjects()[Idx] = E;
   }
 
   /// \brief Replaces the designator at index @p Idx with the series
@@ -4230,9 +4233,11 @@ public:
 
   // Iterators
   child_range children() {
-Stmt **begin = reinterpret_cast(this + 1);
+Stmt **begin = getTrailingObjects();
 return child_range(begin, begin + NumSubExprs);
   }
+
+  friend TrailingObjects;
 };
 
 /// \brief Represents a place-holder for an object not to be initialized by
@@ -4683,7 +4688,9 @@ public:
 /// equivalent to a particular message send, and this is very much
 /// part of the user model.  The name of this class encourages this
 /// modelling design.
-class PseudoObjectExpr : public Expr {
+class PseudoObjectExpr final
+: public Expr,
+  private llvm::TrailingObjects {
   // PseudoObjectExprBits.NumSubExprs - The number of sub-expressions.
   // Always at least two, because the first sub-expression is the
   // syntactic form.
@@ -4695,13 +4702,11 @@ class PseudoObjectExpr : public Expr {
   // in to Create, which is an index within the semantic forms.
   // Note also that ASTStmtWriter assumes this encoding.
 
-  Expr **getSubExprsBuffer() { return reinterpret_cast(this + 1); }
+  Expr **getSubExprsBuffer() { return getTrailingObjects(); }
   const Expr * const *getSubExprsBuffer() const {
-return reinterpret_cast(this + 1);
+return getTrailingObjects();
   }
 
-  friend class ASTStmtReader;
-
   PseudoObjectExpr(QualType type, ExprValueKind VK,
Expr *syntactic, ArrayRef semantic,
unsigned resultIndex);
@@ -4798,6 +4803,9 @@ public:
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == PseudoObjectExprClass;
   }
+
+  friend TrailingObjects;
+  friend class ASTStmtReader;
 };
 
 /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=256658&r1=256657&r2=256658&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Dec 30 22:18:25 2015
@@ -951,7 +951,9 @@ public:
 /// This wraps up a function call argument that was created from the
 /// corresponding parameter's default argument, when the call did not
 /// explicitly supply arguments for all of the parameters.
-class CXXDefaultArgExpr : public Expr {
+class CXXDefaultArgExpr final
+: public Expr,
+  private llvm::TrailingObjects {
   /// \brief The parameter whose default is being used.
   ///
   /// When the bit is set, the subexpression is stored after the
@@ -977,7 +979,7 @@ class CXXDefaultArgExpr : public Expr {
SubExpr->getValueKind(), SubExpr->getObjectKind(),
false, false, false, false),
   Param(param, true), Loc(Loc) {
-*reinterpret_cast(this + 1) = SubExpr;
+*getTrailingObjects() = SubExpr;
   }
 
 public:
@@ -1002,12 +1004,12 @@ pu

r256659 - [TrailingObjects] Convert classes in ExprObjC.h

2015-12-30 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Wed Dec 30 22:43:19 2015
New Revision: 256659

URL: http://llvm.org/viewvc/llvm-project?rev=256659&view=rev
Log:
[TrailingObjects] Convert classes in ExprObjC.h

Modified:
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/AST/ExprObjC.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=256659&r1=256658&r2=256659&view=diff
==
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Wed Dec 30 22:43:19 2015
@@ -141,15 +141,17 @@ public:
 
 /// ObjCArrayLiteral - used for objective-c array containers; as in:
 /// @[@"Hello", NSApp, [NSNumber numberWithInt:42]];
-class ObjCArrayLiteral : public Expr {
+class ObjCArrayLiteral final
+: public Expr,
+  private llvm::TrailingObjects {
   unsigned NumElements;
   SourceRange Range;
   ObjCMethodDecl *ArrayWithObjectsMethod;
-  
+
   ObjCArrayLiteral(ArrayRef Elements,
QualType T, ObjCMethodDecl * Method,
SourceRange SR);
-  
+
   explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements)
 : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {}
 
@@ -171,11 +173,11 @@ public:
   }
 
   /// \brief Retrieve elements of array of literals.
-  Expr **getElements() { return reinterpret_cast(this + 1); }
+  Expr **getElements() { return getTrailingObjects(); }
 
   /// \brief Retrieve elements of array of literals.
-  const Expr * const *getElements() const { 
-return reinterpret_cast(this + 1); 
+  const Expr * const *getElements() const {
+return getTrailingObjects();
   }
 
   /// getNumElements - Return number of elements of objective-c array literal.
@@ -196,11 +198,12 @@ public:
   }
 
   // Iterators
-  child_range children() { 
-return child_range((Stmt **)getElements(), 
-   (Stmt **)getElements() + NumElements);
+  child_range children() {
+return child_range(reinterpret_cast(getElements()),
+   reinterpret_cast(getElements()) + NumElements);
   }
-
+
+  friend TrailingObjects;
   friend class ASTStmtReader;
 };
 
@@ -230,32 +233,35 @@ template <> struct isPodLike {
   /// \brief The number of elements in this dictionary literal.
   unsigned NumElements : 31;
-  
+
   /// \brief Determine whether this dictionary literal has any pack expansions.
   ///
   /// If the dictionary literal has pack expansions, then there will
@@ -264,10 +270,17 @@ class ObjCDictionaryLiteral : public Exp
   /// any) and number of elements in the expansion (if known). If
   /// there are no pack expansions, we optimize away this storage.
   unsigned HasPackExpansions : 1;
-  
+
   SourceRange Range;
   ObjCMethodDecl *DictWithObjectsMethod;
-
+
+  typedef ObjCDictionaryLiteral_KeyValuePair KeyValuePair;
+  typedef ObjCDictionaryLiteral_ExpansionData ExpansionData;
+
+  size_t numTrailingObjects(OverloadToken) const {
+return NumElements;
+  }
+
   ObjCDictionaryLiteral(ArrayRef VK, 
 bool HasPackExpansions,
 QualType T, ObjCMethodDecl *method,
@@ -278,28 +291,6 @@ class ObjCDictionaryLiteral : public Exp
 : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements),
   HasPackExpansions(HasPackExpansions) {}
 
-  KeyValuePair *getKeyValues() {
-return reinterpret_cast(this + 1);
-  }
-  
-  const KeyValuePair *getKeyValues() const {
-return reinterpret_cast(this + 1);
-  }
-
-  ExpansionData *getExpansionData() {
-if (!HasPackExpansions)
-  return nullptr;
-
-return reinterpret_cast(getKeyValues() + NumElements);
-  }
-
-  const ExpansionData *getExpansionData() const {
-if (!HasPackExpansions)
-  return nullptr;
-
-return reinterpret_cast(getKeyValues()+NumElements);
-  }
-
 public:
   static ObjCDictionaryLiteral *Create(const ASTContext &C,
ArrayRef VK, 
@@ -317,10 +308,11 @@ public:
 
   ObjCDictionaryElement getKeyValueElement(unsigned Index) const {
 assert((Index < NumElements) && "Arg access out of range!");
-const KeyValuePair &KV = getKeyValues()[Index];
+const KeyValuePair &KV = getTrailingObjects()[Index];
 ObjCDictionaryElement Result = { KV.Key, KV.Value, SourceLocation(), None 
};
 if (HasPackExpansions) {
-  const ExpansionData &Expansion = getExpansionData()[Index];
+  const ExpansionData &Expansion =
+  getTrailingObjects()[Index];
   Result.EllipsisLoc = Expansion.EllipsisLoc;
   if (Expansion.NumExpansionsPlusOne > 0)
 Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1;
@@ -340,17 +332,20 @@ public:
   }
 
   // Iterators
-  child_range children() { 
+  child_range children() {
 // Note: we're taking a

r256661 - [MSVC Compat] Diagnose multiple default ctors for dllexport'd classes

2015-12-30 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Dec 30 23:36:46 2015
New Revision: 256661

URL: http://llvm.org/viewvc/llvm-project?rev=256661&view=rev
Log:
[MSVC Compat] Diagnose multiple default ctors for dllexport'd classes

The MS ABI emits a special default constructor closure thunk if a
default constructor has a weird calling convention or default arguments.

The MS ABI has a quirk: there can be only one such thunk because the
mangling scheme does not have room for distinct manglings.  We must
raise a diagnostic in this eventuality.

N.B.  MSVC sorta gets this right.  Multiple default constructors result
in the default constructor closure getting emitted but they seem to
get confused by which default constructors are reasonable to reference
from the closure.  We try to be a little more careful which results in
mild differences in behavior.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=256661&r1=256660&r2=256661&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 30 23:36:46 
2015
@@ -2400,6 +2400,8 @@ def warn_attribute_dll_instantiated_base
   "propagating dll attribute to %select{already instantiated|explicitly 
specialized}0 "
   "base class template without dll attribute is not supported">,
   InGroup>, DefaultIgnore;
+def err_attribute_dll_ambiguous_default_ctor : Error<
+  "'__declspec(dllexport)' cannot be applied to more than one default 
constructor in %0">;
 def err_attribute_weakref_not_static : Error<
   "weakref declaration must have internal linkage">;
 def err_attribute_weakref_not_global_context : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=256661&r1=256660&r2=256661&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Dec 30 23:36:46 2015
@@ -9470,6 +9470,10 @@ static void getDefaultArgExprsForConstru
   if (Class->getDescribedClassTemplate())
 return;
 
+  CallingConv ExpectedCallingConv = S.Context.getDefaultCallingConvention(
+  /*IsVariadic=*/false, /*IsCXXMethod=*/true);
+
+  CXXConstructorDecl *LastExportedDefaultCtor = nullptr;
   for (Decl *Member : Class->decls()) {
 auto *CD = dyn_cast(Member);
 if (!CD) {
@@ -9481,7 +9485,25 @@ static void getDefaultArgExprsForConstru
   continue;
 }
 
-for (unsigned I = 0, E = CD->getNumParams(); I != E; ++I) {
+CallingConv ActualCallingConv =
+CD->getType()->getAs()->getCallConv();
+
+// Skip default constructors with typical calling conventions and no 
default
+// arguments.
+unsigned NumParams = CD->getNumParams();
+if (ExpectedCallingConv == ActualCallingConv && NumParams == 0)
+  continue;
+
+if (LastExportedDefaultCtor) {
+  S.Diag(LastExportedDefaultCtor->getLocation(),
+ diag::err_attribute_dll_ambiguous_default_ctor) << Class;
+  S.Diag(CD->getLocation(), diag::note_entity_declared_at)
+  << CD->getDeclName();
+  return;
+}
+LastExportedDefaultCtor = CD;
+
+for (unsigned I = 0; I != NumParams; ++I) {
   // Skip any default arguments that we've already instantiated.
   if (S.Context.getDefaultArgExprForConstructor(CD, I))
 continue;

Modified: cfe/trunk/test/SemaCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllexport.cpp?rev=256661&r1=256660&r2=256661&view=diff
==
--- cfe/trunk/test/SemaCXX/dllexport.cpp (original)
+++ cfe/trunk/test/SemaCXX/dllexport.cpp Wed Dec 30 23:36:46 2015
@@ -730,7 +730,12 @@ __declspec(dllexport)int  Member
 __declspec(dllexport) const  int  MemberRedecl::StaticConstField = 1;  // 
expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 
'dllexport' attribute}}
 __declspec(dllexport) constexpr int MemberRedecl::ConstexprField;  // 
expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 
'dllexport' attribute}}
 
-
+#ifdef MS
+struct __declspec(dllexport) ClassWithMultipleDefaultCtors {
+  ClassWithMultipleDefaultCtors(int = 40) {} // 
expected-error{{'__declspec(dllexport)' cannot be applied to more than one 
default constructor}}
+  ClassWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared 
here}}
+};
+#endif
 
 
//===--===//
 // Class member templates


___
cfe-commits ma

r256662 - [MS ABI] Replace dead code with an assertion

2015-12-30 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Dec 30 23:36:50 2015
New Revision: 256662

URL: http://llvm.org/viewvc/llvm-project?rev=256662&view=rev
Log:
[MS ABI] Replace dead code with an assertion

As per C++ [dcl.ref]p1, cv-qualified references are not valid. As such,
change the mangler to assert that this event does not happen.

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

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256662&r1=256661&r2=256662&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Dec 30 23:36:50 2015
@@ -2215,7 +2215,8 @@ void MicrosoftCXXNameMangler::mangleType
 void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T,
  Qualifiers Quals, SourceRange Range) {
   QualType PointeeType = T->getPointeeType();
-  Out << (Quals.hasVolatile() ? 'B' : 'A');
+  assert(!Quals.hasConst() && !Quals.hasVolatile() && "unexpected qualifier!");
+  Out << 'A';
   manglePointerExtQualifiers(Quals, PointeeType);
   mangleType(PointeeType, Range);
 }
@@ -2226,7 +2227,8 @@ void MicrosoftCXXNameMangler::mangleType
 void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T,
  Qualifiers Quals, SourceRange Range) {
   QualType PointeeType = T->getPointeeType();
-  Out << (Quals.hasVolatile() ? "$$R" : "$$Q");
+  assert(!Quals.hasConst() && !Quals.hasVolatile() && "unexpected qualifier!");
+  Out << "$$Q";
   manglePointerExtQualifiers(Quals, PointeeType);
   mangleType(PointeeType, Range);
 }


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


r256664 - [MS ABI] Remove mangleCXXCatchHandlerType

2015-12-30 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Dec 30 23:36:54 2015
New Revision: 256664

URL: http://llvm.org/viewvc/llvm-project?rev=256664&view=rev
Log:
[MS ABI] Remove mangleCXXCatchHandlerType

It's dead code, no functional change is intended.

Modified:
cfe/trunk/include/clang/AST/Mangle.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=256664&r1=256663&r2=256664&view=diff
==
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Wed Dec 30 23:36:54 2015
@@ -216,9 +216,6 @@ public:
   uint32_t NVOffset, int32_t VBPtrOffset,
   uint32_t VBIndex, raw_ostream &Out) = 0;
 
-  virtual void mangleCXXCatchHandlerType(QualType T, uint32_t Flags,
- raw_ostream &Out) = 0;
-
   virtual void mangleCXXRTTIBaseClassDescriptor(
   const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset,
   uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) = 0;

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256664&r1=256663&r2=256664&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Dec 30 23:36:54 2015
@@ -127,8 +127,6 @@ public:
   CXXCtorType CT, uint32_t Size, uint32_t NVOffset,
   int32_t VBPtrOffset, uint32_t VBIndex,
   raw_ostream &Out) override;
-  void mangleCXXCatchHandlerType(QualType T, uint32_t Flags,
- raw_ostream &Out) override;
   void mangleCXXRTTI(QualType T, raw_ostream &Out) override;
   void mangleCXXRTTIName(QualType T, raw_ostream &Out) override;
   void mangleCXXRTTIBaseClassDescriptor(const CXXRecordDecl *Derived,
@@ -2622,15 +2620,6 @@ void MicrosoftMangleContextImpl::mangleC
   Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
 }
 
-void MicrosoftMangleContextImpl::mangleCXXCatchHandlerType(QualType T,
-   uint32_t Flags,
-   raw_ostream &Out) {
-  MicrosoftCXXNameMangler Mangler(*this, Out);
-  Mangler.getStream() << "llvm.eh.handlertype.";
-  Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
-  Mangler.getStream() << '.' << Flags;
-}
-
 void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap(
 const CXXRecordDecl *SrcRD, const CXXRecordDecl *DstRD, raw_ostream &Out) {
   MicrosoftCXXNameMangler Mangler(*this, Out);


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


r256663 - [MS ABI] Change the ArgBackRefMap to hold const qualified pointers

2015-12-30 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Dec 30 23:36:52 2015
New Revision: 256663

URL: http://llvm.org/viewvc/llvm-project?rev=256663&view=rev
Log:
[MS ABI] Change the ArgBackRefMap to hold const qualified pointers

Just a cleanup, no functional change is intended.

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

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256663&r1=256662&r2=256663&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Dec 30 23:36:52 2015
@@ -221,7 +221,7 @@ class MicrosoftCXXNameMangler {
   typedef llvm::SmallVector BackRefVec;
   BackRefVec NameBackReferences;
 
-  typedef llvm::DenseMap ArgBackRefMap;
+  typedef llvm::DenseMap ArgBackRefMap;
   ArgBackRefMap TypeBackReferences;
 
   typedef std::set PassObjectSizeArgsSet;
@@ -1489,7 +1489,7 @@ void MicrosoftCXXNameMangler::manglePass
   int Type = POSA->getType();
 
   auto Iter = PassObjectSizeArgs.insert(Type).first;
-  void *TypePtr = const_cast((const void *)&*Iter);
+  auto *TypePtr = (const void *)&*Iter;
   ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr);
 
   if (Found == TypeBackReferences.end()) {


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


r256665 - [TrailingObjects] Fix bug in "Convert classes in ExprObjC.h"

2015-12-30 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu Dec 31 00:01:19 2015
New Revision: 256665

URL: http://llvm.org/viewvc/llvm-project?rev=256665&view=rev
Log:
[TrailingObjects] Fix bug in "Convert classes in ExprObjC.h"

(Detected by asan)

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

Modified: cfe/trunk/lib/AST/ExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprObjC.cpp?rev=256665&r1=256664&r2=256665&view=diff
==
--- cfe/trunk/lib/AST/ExprObjC.cpp (original)
+++ cfe/trunk/lib/AST/ExprObjC.cpp Thu Dec 31 00:01:19 2015
@@ -59,7 +59,8 @@ ObjCDictionaryLiteral::ObjCDictionaryLit
   NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR),
   DictWithObjectsMethod(method) {
   KeyValuePair *KeyValues = getTrailingObjects();
-  ExpansionData *Expansions = getTrailingObjects();
+  ExpansionData *Expansions =
+  HasPackExpansions ? getTrailingObjects() : nullptr;
   for (unsigned I = 0; I < NumElements; I++) {
 if (VK[I].Key->isTypeDependent() || VK[I].Key->isValueDependent() ||
 VK[I].Value->isTypeDependent() || VK[I].Value->isValueDependent())


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


r256666 - [OPENMP 4.5] Codegen for 'schedule' clause with monotonic/nonmonotonic modifiers.

2015-12-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Dec 31 00:52:34 2015
New Revision: 25

URL: http://llvm.org/viewvc/llvm-project?rev=25&view=rev
Log:
[OPENMP 4.5] Codegen for 'schedule' clause with monotonic/nonmonotonic 
modifiers.
OpenMP 4.5 adds support for monotonic/nonmonotonic modifiers in 'schedule' 
clause. Add codegen for these modifiers.

Added:
cfe/trunk/test/OpenMP/schedule_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/for_simd_codegen.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=25&r1=256665&r2=25&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Dec 31 00:52:34 2015
@@ -1125,7 +1125,8 @@ emitPrivateLinearVars(CodeGenFunction &C
 }
 
 static void emitSimdlenSafelenClause(CodeGenFunction &CGF,
- const OMPExecutableDirective &D) {
+ const OMPExecutableDirective &D,
+ bool IsMonotonic) {
   if (!CGF.HaveInsertPoint())
 return;
   if (const auto *C = D.getSingleClause()) {
@@ -1136,7 +1137,8 @@ static void emitSimdlenSafelenClause(Cod
 // In presence of finite 'safelen', it may be unsafe to mark all
 // the memory instructions parallel, because loop-carried
 // dependences of 'safelen' iterations are possible.
-CGF.LoopStack.setParallel(!D.getSingleClause());
+if (!IsMonotonic)
+  CGF.LoopStack.setParallel(!D.getSingleClause());
   } else if (const auto *C = D.getSingleClause()) {
 RValue Len = CGF.EmitAnyExpr(C->getSafelen(), AggValueSlot::ignored(),
  /*ignoreResult=*/true);
@@ -1149,11 +1151,12 @@ static void emitSimdlenSafelenClause(Cod
   }
 }
 
-void CodeGenFunction::EmitOMPSimdInit(const OMPLoopDirective &D) {
+void CodeGenFunction::EmitOMPSimdInit(const OMPLoopDirective &D,
+  bool IsMonotonic) {
   // Walk clauses and process safelen/lastprivate.
-  LoopStack.setParallel();
+  LoopStack.setParallel(!IsMonotonic);
   LoopStack.setVectorizeEnable(true);
-  emitSimdlenSafelenClause(*this, D);
+  emitSimdlenSafelenClause(*this, D, IsMonotonic);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(const OMPLoopDirective &D) {
@@ -1255,12 +1258,10 @@ void CodeGenFunction::EmitOMPSimdDirecti
   CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_simd, CodeGen);
 }
 
-void CodeGenFunction::EmitOMPForOuterLoop(OpenMPScheduleClauseKind 
ScheduleKind,
-  const OMPLoopDirective &S,
-  OMPPrivateScope &LoopScope,
-  bool Ordered, Address LB,
-  Address UB, Address ST,
-  Address IL, llvm::Value *Chunk) {
+void CodeGenFunction::EmitOMPForOuterLoop(
+OpenMPScheduleClauseKind ScheduleKind, bool IsMonotonic,
+const OMPLoopDirective &S, OMPPrivateScope &LoopScope, bool Ordered,
+Address LB, Address UB, Address ST, Address IL, llvm::Value *Chunk) {
   auto &RT = CGM.getOpenMPRuntime();
 
   // Dynamic scheduling of the outer loop (dynamic, guided, auto, runtime).
@@ -1378,13 +1379,10 @@ void CodeGenFunction::EmitOMPForOuterLoo
 
   // Generate !llvm.loop.parallel metadata for loads and stores for loops
   // with dynamic/guided scheduling and without ordered clause.
-  if (!isOpenMPSimdDirective(S.getDirectiveKind())) {
-LoopStack.setParallel((ScheduleKind == OMPC_SCHEDULE_dynamic ||
-   ScheduleKind == OMPC_SCHEDULE_guided) &&
-  !Ordered);
-  } else {
-EmitOMPSimdInit(S);
-  }
+  if (!isOpenMPSimdDirective(S.getDirectiveKind()))
+LoopStack.setParallel(!IsMonotonic);
+  else
+EmitOMPSimdInit(S, IsMonotonic);
 
   SourceLocation Loc = S.getLocStart();
   EmitOMPInnerLoop(S, LoopScope.requiresCleanups(), S.getCond(), S.getInc(),
@@ -1425,14 +1423,30 @@ static LValue EmitOMPHelperVar(CodeGenFu
   return CGF.EmitLValue(Helper);
 }
 
-static std::pair
+namespace {
+  struct ScheduleKindModifiersTy {
+OpenMPScheduleClauseKind Kind;
+OpenMPScheduleClauseModifier M1;
+OpenMPScheduleClauseModifier M2;
+ScheduleKindModifiersTy(OpenMPScheduleClauseKind Kind,
+OpenMPScheduleClauseModifier M1,
+OpenMPScheduleClauseModifier M2)
+: Kind(Kind), M1(M1), M2(M2) {}
+  };
+} // namespace
+
+static std::pair
 emitScheduleClause(CodeGenFunction &CGF, const OMPLoopDirective &S,
bool OuterRegion) {
   // Detect the loop schedule kind and chunk.