r255625 - [OPENMP 4.5] Parsing/sema for 'hint' clause of 'critical' directive.

2015-12-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec 15 02:19:24 2015
New Revision: 255625

URL: http://llvm.org/viewvc/llvm-project?rev=255625&view=rev
Log:
[OPENMP 4.5] Parsing/sema for 'hint' clause of 'critical' directive.
OpenMP 4.5 adds 'hint' clause to critical directive. Patch adds 
parsing/semantic analysis for this clause.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/critical_ast_print.cpp
cfe/trunk/test/OpenMP/critical_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=255625&r1=255624&r2=255625&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Dec 15 02:19:24 2015
@@ -3028,6 +3028,59 @@ public:
   child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
 };
 
+/// \brief This represents 'hint' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp critical (name) hint(6)
+/// \endcode
+/// In this example directive '#pragma omp critical' has name 'name' and clause
+/// 'hint' with argument '6'.
+///
+class OMPHintClause : public OMPClause {
+  friend class OMPClauseReader;
+  /// \brief Location of '('.
+  SourceLocation LParenLoc;
+  /// \brief Hint expression of the 'hint' clause.
+  Stmt *Hint;
+
+  /// \brief Set hint expression.
+  ///
+  void setHint(Expr *H) { Hint = H; }
+
+public:
+  /// \brief Build 'hint' clause with expression \a Hint.
+  ///
+  /// \param Hint Hint expression.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  ///
+  OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc,
+SourceLocation EndLoc)
+  : OMPClause(OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
+Hint(Hint) {}
+
+  /// \brief Build an empty clause.
+  ///
+  OMPHintClause()
+  : OMPClause(OMPC_hint, SourceLocation(), SourceLocation()),
+LParenLoc(SourceLocation()), Hint(nullptr) {}
+
+  /// \brief Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+  /// \brief Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// \brief Returns number of threads.
+  Expr *getHint() const { return cast_or_null(Hint); }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_hint;
+  }
+
+  child_range children() { return child_range(&Hint, &Hint + 1); }
+};
+
 } // end namespace clang
 
 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=255625&r1=255624&r2=255625&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Dec 15 02:19:24 2015
@@ -2772,6 +2772,12 @@ bool RecursiveASTVisitor::Visit
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPHintClause(OMPHintClause *C) {
+  TRY_TO(TraverseStmt(C->getHint()));
+  return true;
+}
+
 // FIXME: look at the following tricky-seeming exprs to see if we
 // need to recurse on anything.  These are ones that have methods
 // returning decls or qualtypes or nestednamespecifier -- though I'm

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=255625&r1=255624&r2=255625&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Dec 15 02:19:24 2015
@@ -1153,18 +1153,22 @@ class OMPCriticalDirective : public OMPE
   /// \param Name Name of the directive.
   /// \param StartLoc Starting location of the directive kind.
   /// \param EndLoc Ending location of the directive.
+  /// \param NumClauses Number of clauses.
   ///
   OMPCriticalDirective(const DeclarationNameInfo &Name, SourceLocati

r255627 - Add a new matcher to match character types.

2015-12-15 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Dec 15 02:35:45 2015
New Revision: 255627

URL: http://llvm.org/viewvc/llvm-project?rev=255627&view=rev
Log:
Add a new matcher to match character types.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=255627&r1=255626&r2=255627&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Dec 15 02:35:45 2015
@@ -3533,6 +3533,20 @@ AST_MATCHER(QualType, isInteger) {
 return Node->isIntegerType();
 }
 
+/// \brief Matches QualType nodes that are of character type.
+///
+/// Given
+/// \code
+///   void a(char);
+///   void b(wchar_t);
+///   void c(double);
+/// \endcode
+/// functionDecl(hasAnyParameter(hasType(isAnyCharacter(
+/// matches "a(char)", "b(wchar_t)", but not "c(double)".
+AST_MATCHER(QualType, isAnyCharacter) {
+return Node->isAnyCharacterType();
+}
+
 /// \brief Matches QualType nodes that are const-qualified, i.e., that
 /// include "top-level" const.
 ///

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=255627&r1=255626&r2=255627&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Tue Dec 15 02:35:45 2015
@@ -1469,6 +1469,14 @@ TEST(IsInteger, ReportsNoFalsePositives)
   to(varDecl(hasType(isInteger();
 }
 
+TEST(IsAnyCharacter, MatchesCharacters) {
+  EXPECT_TRUE(matches("char i = 0;", varDecl(hasType(isAnyCharacter();
+}
+
+TEST(IsAnyCharacter, ReportsNoFalsePositives) {
+  EXPECT_TRUE(notMatches("int i;", varDecl(hasType(isAnyCharacter();
+}
+
 TEST(IsArrow, MatchesMemberVariablesViaArrow) {
   EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
   memberExpr(isArrow(;


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


Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255630: [clang-tidy] Check for suspicious string 
assignments. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D15411?vs=42710&id=42824#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15411

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-integer-assignment.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s misc-string-integer-assignment %t
+
+namespace std {
+template
+struct basic_string {
+  basic_string& operator=(T);
+  basic_string& operator=(basic_string);
+  basic_string& operator+=(T);
+  basic_string& operator+=(basic_string);
+};
+
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+typedef int MyArcaneChar;
+
+int main() {
+  std::string s;
+  std::wstring ws;
+  int x = 5;
+
+  s = 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: an integer is interpreted as a character code when assigning {{.*}} [misc-string-integer-assignment]
+// CHECK-FIXES: {{^}}  s = '6';{{$}}
+  s = 66;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: an integer is interpreted as a chara
+// CHECK-FIXES: {{^}}  s = "66";{{$}}
+  s = x;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: an integer is interpreted as a chara
+// CHECK-FIXES: {{^}}  s = std::to_string(x);{{$}}
+  s = 'c';
+  s = static_cast(6);
+
+// +=
+  ws += 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: an integer is interpreted as a chara
+// CHECK-FIXES: {{^}}  ws += L'6';{{$}}
+  ws += 66;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: an integer is interpreted as a chara
+// CHECK-FIXES: {{^}}  ws += L"66";{{$}}
+  ws += x;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: an integer is interpreted as a chara
+// CHECK-FIXES: {{^}}  ws += std::to_wstring(x);{{$}}
+  ws += L'c';
+  ws += (wchar_t)6;
+
+  std::basic_string as;
+  as = 6;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a chara
+// CHECK-FIXES: {{^}}  as = 6;{{$}}
+
+}
Index: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
@@ -17,6 +17,7 @@
   NonCopyableObjects.cpp
   SizeofContainerCheck.cpp
   StaticAssertCheck.cpp
+  StringIntegerAssignmentCheck.cpp
   SwappedArgumentsCheck.cpp
   ThrowByValueCatchByReferenceCheck.cpp
   UndelegatedConstructor.cpp
Index: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
@@ -25,6 +25,7 @@
 #include "NonCopyableObjects.h"
 #include "SizeofContainerCheck.h"
 #include "StaticAssertCheck.h"
+#include "StringIntegerAssignmentCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "ThrowByValueCatchByReferenceCheck.h"
 #include "UndelegatedConstructor.h"
@@ -68,6 +69,8 @@
 CheckFactories.registerCheck("misc-sizeof-container");
 CheckFactories.registerCheck(
 "misc-static-assert");
+CheckFactories.registerCheck(
+"misc-string-integer-assignment");
 CheckFactories.registerCheck(
 "misc-swapped-arguments");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
@@ -0,0 +1,85 @@
+//===--- StringIntegerAssignmentCheck.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 "StringIntegerAssignmentCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void StringIntegerAssignmentCheck::regis

[clang-tools-extra] r255630 - [clang-tidy] Check for suspicious string assignments.

2015-12-15 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Dec 15 02:47:20 2015
New Revision: 255630

URL: http://llvm.org/viewvc/llvm-project?rev=255630&view=rev
Log:
[clang-tidy] Check for suspicious string assignments.

It is possible to assign arbitrary integer types to strings.
Sometimes it is the result of missing to_string call or apostrophes.

Reviewers: alexfh

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-integer-assignment.rst
clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=255630&r1=255629&r2=255630&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Tue Dec 15 02:47:20 
2015
@@ -17,6 +17,7 @@ add_clang_library(clangTidyMiscModule
   NonCopyableObjects.cpp
   SizeofContainerCheck.cpp
   StaticAssertCheck.cpp
+  StringIntegerAssignmentCheck.cpp
   SwappedArgumentsCheck.cpp
   ThrowByValueCatchByReferenceCheck.cpp
   UndelegatedConstructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=255630&r1=255629&r2=255630&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Tue Dec 15 
02:47:20 2015
@@ -25,6 +25,7 @@
 #include "NonCopyableObjects.h"
 #include "SizeofContainerCheck.h"
 #include "StaticAssertCheck.h"
+#include "StringIntegerAssignmentCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "ThrowByValueCatchByReferenceCheck.h"
 #include "UndelegatedConstructor.h"
@@ -68,6 +69,8 @@ public:
 
CheckFactories.registerCheck("misc-sizeof-container");
 CheckFactories.registerCheck(
 "misc-static-assert");
+CheckFactories.registerCheck(
+"misc-string-integer-assignment");
 CheckFactories.registerCheck(
 "misc-swapped-arguments");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp?rev=255630&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp 
Tue Dec 15 02:47:20 2015
@@ -0,0 +1,85 @@
+//===--- StringIntegerAssignmentCheck.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 "StringIntegerAssignmentCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  anyOf(hasOverloadedOperatorName("="),
+hasOverloadedOperatorName("+=")),
+  callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
+  hasName("::std::basic_string"),
+  hasTemplateArgument(0, 
refersToType(qualType().bind("type"))),
+  hasArgument(1,
+  ignoringImpCasts(expr(hasType(isInteger()),
+unless(hasType(isAnyCharacter(
+   .bind("expr"))),
+  unless(isInTemplateInstantiation())),
+  this);
+}
+
+void StringIntegerAssignmentCheck::check(
+const MatchFinder::MatchResult &Result) {
+  const auto *Argument = Result.Nodes.getNodeAs("expr");
+  SourceLocation Loc = Argument->getLocStart();
+
+  auto Diag =
+  diag(Loc, "an integer is interpreted as a character code when assigning "
+"it to a string; if this is intended, cast the integer to the "
+"appropriate character type; if you want a s

Re: [PATCH] D15411: [clang-tidy] Check for suspicious string assignments.

2015-12-15 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D15411#310539, @alexfh wrote:

> Thank you for the new awesome check!


Thank you for the review. I committed the new matcher to clang as well. I went 
with isAnyCharacter name for now, but we can rename it anytime.


Repository:
  rL LLVM

http://reviews.llvm.org/D15411



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


r255635 - [libclang] Add a flag to create the precompiled preamble on the first parse.

2015-12-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Dec 15 03:30:31 2015
New Revision: 255635

URL: http://llvm.org/viewvc/llvm-project?rev=255635&view=rev
Log:
[libclang] Add a flag to create the precompiled preamble on the first parse.

Summary:
The current default is to create the preamble on the first reparse, aka
second parse. This is useful for clients that do not want to block when
opening a file because serializing the preamble takes a bit of time.
However, this makes the reparse much more expensive and that may be on the
critical path as it's the first interaction a user has with the source code.

YouCompleteMe currently optimizes for the first code interaction by parsing
the file twice when loaded. That's just unnecessarily slow and this flag
helps to avoid that.

Reviewers: doug.gregor, klimek

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/test/Index/complete-preamble.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255635&r1=255634&r2=255635&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Dec 15 03:30:31 2015
@@ -1200,7 +1200,15 @@ enum CXTranslationUnit_Flags {
* included into the set of code completions returned from this translation
* unit.
*/
-  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
+  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
+
+  /**
+   * \brief Used to indicate that the precompiled preamble should be created on
+   * the first parse. Otherwise it will be created on the first reparse. This
+   * trades runtime on the first parse (serializing the preamble takes time) 
for
+   * reduced runtime on the second parse (can now reuse the preamble).
+   */
+  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100
 };
 
 /**

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=255635&r1=255634&r2=255635&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Dec 15 03:30:31 2015
@@ -737,14 +737,15 @@ private:
   /// \brief Helper function for \c LoadFromCompilerInvocation() and
   /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation.
   ///
-  /// \param PrecompilePreamble Whether to precompile the preamble of this
-  /// translation unit, to improve the performance of reparsing.
+  /// \param PrecompilePreambleAfterNParses After how many parses the preamble
+  /// of this translation unit should be precompiled, to improve the 
performance
+  /// of reparsing. Set to zero to disable preambles.
   ///
   /// \returns \c true if a catastrophic failure occurred (which means that the
   /// \c ASTUnit itself is invalid), or \c false otherwise.
   bool LoadFromCompilerInvocation(
   std::shared_ptr PCHContainerOps,
-  bool PrecompilePreamble);
+  unsigned PrecompilePreambleAfterNParses);
 
 public:
   
@@ -783,7 +784,8 @@ public:
   ASTFrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
   bool Persistent = true, StringRef ResourceFilesPath = StringRef(),
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
-  bool PrecompilePreamble = false, bool CacheCodeCompletionResults = false,
+  unsigned PrecompilePreambleAfterNParses = 0,
+  bool CacheCodeCompletionResults = false,
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool UserFilesAreVolatile = false,
   std::unique_ptr *ErrAST = nullptr);
@@ -807,7 +809,8 @@ public:
   std::shared_ptr PCHContainerOps,
   IntrusiveRefCntPtr Diags, FileManager *FileMgr,
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
-  bool PrecompilePreamble = false, TranslationUnitKind TUKind = 
TU_Complete,
+  unsigned PrecompilePreambleAfterNParses = 0,
+  TranslationUnitKind TUKind = TU_Complete,
   bool CacheCodeCompletionResults = false,
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool UserFilesAreVolatile = false);
@@ -842,7 +845,8 @@ public:
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
   ArrayRef RemappedFiles = None,
   bool RemappedFilesKeepOriginalName = true,
-  bool PrecompilePreamble = false, TranslationUnitKind TUKind = 
TU_Complete,
+  unsigned PrecompilePreambleAfterNParses = 0,
+  TranslationUnitKind TUKind = TU_Complete,
   bool CacheCodeCompletionResults = false,
   bool IncludeBr

Re: [PATCH] D15490: [libclang] Add a flag to create the precompiled preamble on the first parse.

2015-12-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255635: [libclang] Add a flag to create the precompiled 
preamble on the first parse. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D15490?vs=42749&id=42826#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15490

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/include/clang/Frontend/ASTUnit.h
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/test/Index/complete-preamble.cpp
  cfe/trunk/tools/c-index-test/c-index-test.c
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/Indexing.cpp

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -1200,7 +1200,15 @@
* included into the set of code completions returned from this translation
* unit.
*/
-  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
+  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
+
+  /**
+   * \brief Used to indicate that the precompiled preamble should be created on
+   * the first parse. Otherwise it will be created on the first reparse. This
+   * trades runtime on the first parse (serializing the preamble takes time) for
+   * reduced runtime on the second parse (can now reuse the preamble).
+   */
+  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100
 };
 
 /**
Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -737,14 +737,15 @@
   /// \brief Helper function for \c LoadFromCompilerInvocation() and
   /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation.
   ///
-  /// \param PrecompilePreamble Whether to precompile the preamble of this
-  /// translation unit, to improve the performance of reparsing.
+  /// \param PrecompilePreambleAfterNParses After how many parses the preamble
+  /// of this translation unit should be precompiled, to improve the performance
+  /// of reparsing. Set to zero to disable preambles.
   ///
   /// \returns \c true if a catastrophic failure occurred (which means that the
   /// \c ASTUnit itself is invalid), or \c false otherwise.
   bool LoadFromCompilerInvocation(
   std::shared_ptr PCHContainerOps,
-  bool PrecompilePreamble);
+  unsigned PrecompilePreambleAfterNParses);
 
 public:
   
@@ -783,7 +784,8 @@
   ASTFrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
   bool Persistent = true, StringRef ResourceFilesPath = StringRef(),
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
-  bool PrecompilePreamble = false, bool CacheCodeCompletionResults = false,
+  unsigned PrecompilePreambleAfterNParses = 0,
+  bool CacheCodeCompletionResults = false,
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool UserFilesAreVolatile = false,
   std::unique_ptr *ErrAST = nullptr);
@@ -807,7 +809,8 @@
   std::shared_ptr PCHContainerOps,
   IntrusiveRefCntPtr Diags, FileManager *FileMgr,
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
-  bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete,
+  unsigned PrecompilePreambleAfterNParses = 0,
+  TranslationUnitKind TUKind = TU_Complete,
   bool CacheCodeCompletionResults = false,
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool UserFilesAreVolatile = false);
@@ -842,7 +845,8 @@
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
   ArrayRef RemappedFiles = None,
   bool RemappedFilesKeepOriginalName = true,
-  bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete,
+  unsigned PrecompilePreambleAfterNParses = 0,
+  TranslationUnitKind TUKind = TU_Complete,
   bool CacheCodeCompletionResults = false,
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false,
Index: cfe/trunk/test/Index/complete-preamble.cpp
===
--- cfe/trunk/test/Index/complete-preamble.cpp
+++ cfe/trunk/test/Index/complete-preamble.cpp
@@ -3,6 +3,15 @@
   std::
 }
 
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: {ResultType void}{TypedText wibble}{LeftParen (}{RightParen )} (50)
+// RUN: env CINDEXTEST_EDITING=1 LIBCLANG_TIMING=1 c-index-test -code-completion-at=%s:3:8 %s -o - 2>&1 | FileCheck -check-prefix=CHECK-CC1 -check-prefix=SECOND %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_CREATE_PREAMBLE_ON_FIRST_PARSE=1 LIBCLANG_TIMING=1 c-index-test -code-completion-at=%s:3:8 %s -o - 2>&1 | FileCheck -check-prefix=CHECK-CC1 -check-prefix=FIRST %s
+
+// FIRST: Precompilin

r255636 - clang/test/Analysis/padding_c.c: Suppress a test incompatible to i686-linux.

2015-12-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Dec 15 03:37:01 2015
New Revision: 255636

URL: http://llvm.org/viewvc/llvm-project?rev=255636&view=rev
Log:
clang/test/Analysis/padding_c.c: Suppress a test incompatible to i686-linux.

  error: 'warning' diagnostics expected but not seen:
File clang/test/Analysis/padding_c.c Line 194 (directive at 
clang/test/Analysis/padding_c.c:193): Excessive padding in 'struct 
DefaultAttrAlign'
  1 error generated.

Modified:
cfe/trunk/test/Analysis/padding_c.c

Modified: cfe/trunk/test/Analysis/padding_c.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/padding_c.c?rev=255636&r1=255635&r2=255636&view=diff
==
--- cfe/trunk/test/Analysis/padding_c.c (original)
+++ cfe/trunk/test/Analysis/padding_c.c Tue Dec 15 03:37:01 2015
@@ -190,13 +190,6 @@ void anonStructFunc() {
   } obj;
 }
 
-// expected-warning@+1{{Excessive padding in 'struct DefaultAttrAlign'}}
-struct DefaultAttrAlign {
-  char c1;
-  long long i;
-  char c2;
-} __attribute__((aligned));
-
 struct CorrectDefaultAttrAlign { // no-warning
   long long i;
   char c1;


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


Re: [Diffusion] rL255545: [PATCH] Adding checker to detect excess padding in records

2015-12-15 Thread NAKAMURA Takumi via cfe-commits
chapuni added subscribers: cfe-commits, chapuni.

/cfe/trunk/test/Analysis/padding_c.c:193 Seems it is incompatible to i686-linux.

> error: 'warning' diagnostics expected but not seen: 
>   File clang/test/Analysis/padding_c.c Line 194 (directive at 
> clang/test/Analysis/padding_c.c:193): Excessive padding in 'struct 
> DefaultAttrAlign'
> 1 error generated.

I pruned DefaultAttrAlign in r255636. Could you take a look please?

Users:
  bcraig (Author, Auditor)

http://reviews.llvm.org/rL255545



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


r255639 - [OPENMP 4.5] Codegen for 'hint' clause of 'critical' directive

2015-12-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec 15 04:55:09 2015
New Revision: 255639

URL: http://llvm.org/viewvc/llvm-project?rev=255639&view=rev
Log:
[OPENMP 4.5] Codegen for 'hint' clause of 'critical' directive
OpenMP 4.5 defines 'hint' clause for 'critical' directive. Patch adds codegen 
for this clause.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/critical_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=255639&r1=255638&r2=255639&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Dec 15 04:55:09 2015
@@ -557,6 +557,17 @@ CGOpenMPRuntime::createRuntimeFunction(O
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_critical");
 break;
   }
+  case OMPRTL__kmpc_critical_with_hint: {
+// Build void __kmpc_critical_with_hint(ident_t *loc, kmp_int32 global_tid,
+// kmp_critical_name *crit, uintptr_t hint);
+llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty,
+
llvm::PointerType::getUnqual(KmpCriticalNameTy),
+CGM.IntPtrTy};
+llvm::FunctionType *FnTy =
+llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_critical_with_hint");
+break;
+  }
   case OMPRTL__kmpc_threadprivate_register: {
 // Build void __kmpc_threadprivate_register(ident_t *, void *data,
 // kmpc_ctor ctor, kmpc_cctor cctor, kmpc_dtor dtor);
@@ -1369,22 +1380,29 @@ public:
 void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF,
  StringRef CriticalName,
  const RegionCodeGenTy &CriticalOpGen,
- SourceLocation Loc) {
-  // __kmpc_critical(ident_t *, gtid, Lock);
+ SourceLocation Loc, const Expr *Hint) 
{
+  // __kmpc_critical[_with_hint](ident_t *, gtid, Lock[, hint]);
   // CriticalOpGen();
   // __kmpc_end_critical(ident_t *, gtid, Lock);
   // Prepare arguments and build a call to __kmpc_critical
-  {
-CodeGenFunction::RunCleanupsScope Scope(CGF);
-llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
-   getCriticalRegionLock(CriticalName)};
+  CodeGenFunction::RunCleanupsScope Scope(CGF);
+  llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
+ getCriticalRegionLock(CriticalName)};
+  if (Hint) {
+llvm::SmallVector ArgsWithHint(std::begin(Args),
+ std::end(Args));
+auto *HintVal = CGF.EmitScalarExpr(Hint);
+ArgsWithHint.push_back(
+CGF.Builder.CreateIntCast(HintVal, CGM.IntPtrTy, /*isSigned=*/false));
+CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_critical_with_hint),
+ArgsWithHint);
+  } else
 CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_critical), Args);
-// Build a call to __kmpc_end_critical
-
CGF.EHStack.pushCleanup::value>>(
-NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_critical),
-llvm::makeArrayRef(Args));
-emitInlinedDirective(CGF, OMPD_critical, CriticalOpGen);
-  }
+  // Build a call to __kmpc_end_critical
+  CGF.EHStack.pushCleanup::value>>(
+  NormalAndEHCleanup, createRuntimeFunction(OMPRTL__kmpc_end_critical),
+  llvm::makeArrayRef(Args));
+  emitInlinedDirective(CGF, OMPD_critical, CriticalOpGen);
 }
 
 static void emitIfStmt(CodeGenFunction &CGF, llvm::Value *IfCond,

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=255639&r1=255638&r2=255639&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Dec 15 04:55:09 2015
@@ -62,6 +62,9 @@ private:
 // Call to void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
 // kmp_critical_name *crit);
 OMPRTL__kmpc_critical,
+// Call to void __kmpc_critical_with_hint(ident_t *loc, kmp_int32
+// global_tid, kmp_critical_name *crit, uintptr_t hint);
+OMPRTL__kmpc_critical_with_hint,
 // Call to void __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid,
 // kmp_critical_name *crit);
 OMPRTL__kmpc_end_critical,
@@ -420,9 +423,11 @@ public:
   /// \param CriticalName Name of the critical region.
   /// \param CriticalOpGen Generator for the statement associated with the 
given
   /// critical region.
+  /// \param Hint Value of the 'hint' clause (optional).
   vir

Re: [PATCH] D14441: [OpenCL] Pipe types support.

2015-12-15 Thread Alexey Bader via cfe-commits
bader added a comment.

Hi guys,

Sorry for long silence.
Unfortunately, I just can't find time to finish with this patch.
Xiuli provided a valid test case that exposed issue with type caching, so I 
decided to not commit at as is (although I applied other minor style comments 
locally).

I'm currently working on front-end part of OpenCL C -> SPIR-V compiler, which 
is developed on github: https://github.com/KhronosGroup/SPIR/tree/spirv-1.0. It 
should be fully OpenCL C 1.x and 2.0 conformant clang.

I would be really happy to see patches from that branches to be in the llvm.org 
repository and I would appreciate any help with porting them from 3.6 release 
branch.

Sorry for inconvenience,
Alexey Bader


http://reviews.llvm.org/D14441



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


r255640 - [OPENMP 4.5] Fix test compatibility with 32 bit mode.

2015-12-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec 15 05:38:29 2015
New Revision: 255640

URL: http://llvm.org/viewvc/llvm-project?rev=255640&view=rev
Log:
[OPENMP 4.5] Fix test compatibility with 32 bit mode.

Modified:
cfe/trunk/test/OpenMP/critical_codegen.cpp

Modified: cfe/trunk/test/OpenMP/critical_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/critical_codegen.cpp?rev=255640&r1=255639&r2=255640&view=diff
==
--- cfe/trunk/test/OpenMP/critical_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/critical_codegen.cpp Tue Dec 15 05:38:29 2015
@@ -33,7 +33,7 @@ int main() {
 // CHECK:   call {{.*}}void @__kmpc_end_critical([[IDENT_T_TY]]* 
[[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
 #pragma omp critical(the_name)
   foo();
-// CHECK:   call {{.*}}void @__kmpc_critical_with_hint([[IDENT_T_TY]]* 
[[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK1]], i64 23)
+// CHECK:   call {{.*}}void @__kmpc_critical_with_hint([[IDENT_T_TY]]* 
[[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK1]], i{{64|32}} 23)
 // CHECK-NEXT:  invoke {{.*}}void [[FOO]]()
 // CHECK:   call {{.*}}void @__kmpc_end_critical([[IDENT_T_TY]]* 
[[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK1]])
 #pragma omp critical(the_name1) hint(23)


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


Re: [PATCH] D14441: [OpenCL] Pipe types support.

2015-12-15 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

Hi all,
Bader had asked me to help him finished the patch set supporting the OpenCL2.0. 
His original work is based on  llvm 3.6.2, and include almost everything needed 
for 2.0. Now I am working on the rest of the pipe support, include the full 
support to complex types and built-in functions. I will update the patch as 
soon as I finished re-basing and having a simple test.
Thank you.


http://reviews.llvm.org/D14441



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


r255645 - [Microsoft][C++] Clang doesn't support a use of "this" pointer inside inline asm

2015-12-15 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Dec 15 08:04:18 2015
New Revision: 255645

URL: http://llvm.org/viewvc/llvm-project?rev=255645&view=rev
Log:
[Microsoft][C++] Clang doesn't support a use of "this" pointer inside inline asm

Clang doesn’t support a use of “this” pointer inside inline asm.
When I tried to compile a class or a struct (see example) with an inline asm 
that contains "this" pointer.
Clang returns with an error.
This patch fixes that.

error: expected unqualified-id
For example:
'''
struct A {
void f() {
  __asm mov eax, this
  // error: expected unqualified-id
  }
};
'''
Differential Revision: http://reviews.llvm.org/D15115


Added:
cfe/trunk/test/CodeGen/ms_this.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=255645&r1=255644&r2=255645&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Dec 15 08:04:18 2015
@@ -1696,7 +1696,8 @@ llvm::Value* CodeGenFunction::EmitAsmInp
   if (Info.allowsRegister() || !Info.allowsMemory())
 if (CodeGenFunction::hasScalarEvaluationKind(InputExpr->getType()))
   return EmitScalarExpr(InputExpr);
-
+  if (InputExpr->getStmtClass() == Expr::CXXThisExprClass)
+return EmitScalarExpr(InputExpr);
   InputExpr = InputExpr->IgnoreParenNoopCasts(getContext());
   LValue Dest = EmitLValue(InputExpr);
   return EmitAsmInputLValue(Info, Dest, InputExpr->getType(), ConstraintStr,

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=255645&r1=255644&r2=255645&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Tue Dec 15 08:04:18 2015
@@ -215,17 +215,22 @@ ExprResult Parser::ParseMSAsmIdentifier(
   // Require an identifier here.
   SourceLocation TemplateKWLoc;
   UnqualifiedId Id;
-  bool Invalid =
-  ParseUnqualifiedId(SS,
- /*EnteringContext=*/false,
- /*AllowDestructorName=*/false,
- /*AllowConstructorName=*/false,
- /*ObjectType=*/ParsedType(), TemplateKWLoc, Id);
-
-  // Perform the lookup.
-  ExprResult Result = Actions.LookupInlineAsmIdentifier(
-  SS, TemplateKWLoc, Id, Info, IsUnevaluatedContext);
-
+  bool Invalid = true;
+  ExprResult Result;
+  if (Tok.is(tok::kw_this)) {
+Result = ParseCXXThis();
+Invalid = false;
+  } else {
+Invalid =
+ParseUnqualifiedId(SS,
+   /*EnteringContext=*/false,
+   /*AllowDestructorName=*/false,
+   /*AllowConstructorName=*/false,
+   /*ObjectType=*/ParsedType(), TemplateKWLoc, Id);
+// Perform the lookup.
+Result = Actions.LookupInlineAsmIdentifier(SS, TemplateKWLoc, Id, Info,
+   IsUnevaluatedContext);
+  }
   // While the next two tokens are 'period' 'identifier', repeatedly parse it 
as
   // a field access. We have to avoid consuming assembler directives that look
   // like '.' 'else'.

Added: cfe/trunk/test/CodeGen/ms_this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_this.cpp?rev=255645&view=auto
==
--- cfe/trunk/test/CodeGen/ms_this.cpp (added)
+++ cfe/trunk/test/CodeGen/ms_this.cpp Tue Dec 15 08:04:18 2015
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fasm-blocks -emit-llvm %s -o - | FileCheck %s
+class t1 {
+public:
+  double a;
+  void runc();
+};
+
+class t2 {
+public:
+  double a;
+  void runc();
+};
+
+void t2::runc() {
+  double num = 0;
+  __asm {
+  mov rax,[this]
+  //CHECK: %this.addr = alloca %class.t2*
+  //CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr 
$1{{.*}}%class.t2* %this1
+  mov rbx,[rax]
+  mov num, rbx
+  };
+}
+
+void t1::runc() {
+  double num = 0;
+  __asm {
+   mov rax,[this]
+  //CHECK: %this.addr = alloca %class.t1*
+  //CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr 
$1{{.*}}%class.t1* %this1
+mov rbx,[rax]
+mov num, rbx
+  };
+}
+
+struct s {
+  int a;
+  void func() {
+__asm mov rax, [this]
+//CHECK: %this.addr = alloca %struct.s*
+//CHECK: call void asm sideeffect inteldialect "mov rax, qword ptr 
$0{{.*}}%struct.s* %this1
+  }
+} f3;
+
+int main() {
+  f3.func();
+  f3.a=1;
+  return 0;
+}


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


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

2015-12-15 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: aaron.ballman, rjmccall.
DmitryPolukhin added a subscriber: cfe-commits.

This patch add support for GCC __attribute__((ifunc("resolver"))) for targets 
that use ELF as object file format. In general ifunc is a special kind of 
function alias with type @gnu_indirect_function. LLVM patch will be sent 
separate.

http://reviews.llvm.org/D15524

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Decl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/ifunc.c
  test/Sema/attr-ifunc.c

Index: test/Sema/attr-ifunc.c
===
--- /dev/null
+++ test/Sema/attr-ifunc.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
+
+void g() {}
+
+void f() __attribute__((ifunc("g")));
+//expected-warning@-1 {{'ifunc' attribute ignored}}
Index: test/CodeGen/ifunc.c
===
--- /dev/null
+++ test/CodeGen/ifunc.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s
+
+int foo (int) __attribute__ ((ifunc("foo_ifunc")));
+
+static int f1(int i) {
+  return i + 1;
+}
+
+static int f2(int i) {
+  return i + 2;
+}
+
+typedef int (*foo_t)(int);
+
+extern int global;
+
+static foo_t foo_ifunc() {
+  return global ? f1 : f2;
+}
+
+int bar() {
+  return foo(1);
+}
+
+// CHECK: @foo = linkonce alias ifunc i32 (i32), bitcast (i32 (i32)* ()* @foo_ifunc to i32 (i32)*)
+// CHECK: call i32 @foo(i32
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1529,6 +1529,29 @@
  Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+return;
+
+  // Aliases should be on declarations, not definitions.
+  if (const auto *FD = dyn_cast(D)) {
+if (FD->isThisDeclarationADefinition()) {
+  S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 1;
+  return;
+}
+if (S.Context.getTargetInfo().getTriple().getObjectFormat() !=
+llvm::Triple::ELF) {
+  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+  return;
+}
+  } else
+llvm_unreachable("ifunc must be used for function declaration");
+
+  D->addAttr(::new (S.Context) IFuncAttr(Attr.getRange(), S.Context, Str,
+ Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   StringRef Str;
   if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
@@ -1542,13 +1565,13 @@
   // Aliases should be on declarations, not definitions.
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
-  S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD;
+  S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 0;
   return;
 }
   } else {
 const auto *VD = cast(D);
 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
-  S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << VD;
+  S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << VD << 0;
   return;
 }
   }
@@ -4975,6 +4998,9 @@
   case AttributeList::AT_IBOutletCollection:
 handleIBOutletCollection(S, D, Attr);
 break;
+  case AttributeList::AT_IFunc:
+handleIFuncAttr(S, D, Attr);
+break;
   case AttributeList::AT_Alias:
 handleAliasAttr(S, D, Attr);
 break;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2297,7 +2297,7 @@
   for (unsigned I = 0, E = NewAttributes.size(); I != E;) {
 const Attr *NewAttribute = NewAttributes[I];
 
-if (isa(NewAttribute)) {
+if (isa(NewAttribute) || isa(NewAttribute)) {
   if (FunctionDecl *FD = dyn_cast(New)) {
 Sema::SkipBodyInfo SkipBody;
 S.CheckForFunctionRedefinition(FD, cast(Def), &SkipBody);
@@ -5420,7 +5420,7 @@
   if (const auto *Attr = VD->getAttr()) {
 assert(VD->isThisDeclarationADefinition() &&
!VD->isExternallyVisible() && "Broken AliasAttr handled late!");
-S.Diag(Attr->getLocation(), diag::err_alias_is_definition) << VD;
+S.Diag(Attr->getLocation(), diag::err_alias_is_definition) << VD << 0;
 VD->dropAttr();
   }
 }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenMod

r255647 - [Microsoft][C++] Clang doesn't support a use of "this" pointer inside inline asm

2015-12-15 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Dec 15 08:35:51 2015
New Revision: 255647

URL: http://llvm.org/viewvc/llvm-project?rev=255647&view=rev
Log:
[Microsoft][C++] Clang doesn't support a use of "this" pointer inside inline 
asm 

add triple to test

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


Modified:
cfe/trunk/test/CodeGen/ms_this.cpp

Modified: cfe/trunk/test/CodeGen/ms_this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_this.cpp?rev=255647&r1=255646&r2=255647&view=diff
==
--- cfe/trunk/test/CodeGen/ms_this.cpp (original)
+++ cfe/trunk/test/CodeGen/ms_this.cpp Tue Dec 15 08:35:51 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fasm-blocks -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -fasm-blocks -emit-llvm %s -o - | 
FileCheck %s
 class t1 {
 public:
   double a;


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


Re: [PATCH] D14441: [OpenCL] Pipe types support.

2015-12-15 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen added a comment.

Nice! I will keep on trying to help by reviewing patches whenever time allows.


http://reviews.llvm.org/D14441



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


Re: [PATCH] D15222: [Patch][Profile] add “--dependent-lib= libclang_rt.profile-x86_64.a” to the CC1 command line when enabling code coverage on PS4

2015-12-15 Thread Ying Yi via cfe-commits
MaggieYi added a comment.

My patch changes 6 compiler flags, which are –coverage, -fprofile-arcs, 
-fprofile-generate, -fprofile-generate=, -fprofile-instr-generate, 
-fprofile-instr-generate=. I would like to keep line 7-10 in order to verify 
the change to using “hasFlag” instead of “hasArg”. For the other switches, I 
could simplify the tests to only check “–fx” and “–fno-x” in order to cut down 
on test proliferation.

Do you think that would be acceptable?


http://reviews.llvm.org/D15222



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


Re: [PATCH] D15195: PR4941: Add support for -fno-builtin-foo options.

2015-12-15 Thread Chad Rosier via cfe-commits
mcrosier updated this revision to Diff 42854.
mcrosier added a comment.

Remove the FIXME, per Hal and Bob's request.  I confirmed that gcc does not 
warn for invalid -fno-builtin-foo options.
Also, pass the vector by reference and insert, rather than making an 
unnecessary copy on the return in CompilerInvocation.


http://reviews.llvm.org/D15195

Files:
  include/clang/Basic/Builtins.h
  include/clang/Basic/LangOptions.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/Basic/Builtins.cpp
  lib/Basic/LangOptions.cpp
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CodeGenOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/2007-04-14-FNoBuiltin.c
  test/CodeGen/libcalls-complex.c
  test/CodeGen/libcalls-fno-builtin.c
  test/CodeGen/nobuiltin.c
  test/Sema/implicit-builtin-freestanding.c

Index: test/Sema/implicit-builtin-freestanding.c
===
--- test/Sema/implicit-builtin-freestanding.c
+++ test/Sema/implicit-builtin-freestanding.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fno-builtin %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fno-builtin-malloc %s
 // expected-no-diagnostics
 
 int malloc(int a) { return a; }
Index: test/CodeGen/nobuiltin.c
===
--- test/CodeGen/nobuiltin.c
+++ test/CodeGen/nobuiltin.c
@@ -1,8 +1,17 @@
 // RUN: %clang_cc1 -fno-builtin -O1 -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-builtin-memset -O1 -S -o - %s | FileCheck -check-prefix=MEMSET %s
 
 void PR13497() {
   char content[2];
   // make sure we don't optimize this call to strcpy()
   // CHECK: __strcpy_chk
   __builtin___strcpy_chk(content, "", 1);
 }
+
+void PR4941(char *s) {
+  // Make sure we don't optimize this loop to a memset().
+  // MEMSET-LABEL: PR4941:
+  // MEMSET-NOT: memset
+  for (unsigned i = 0; i < 8192; ++i)
+s[i] = 0;
+}
Index: test/CodeGen/libcalls-fno-builtin.c
===
--- test/CodeGen/libcalls-fno-builtin.c
+++ test/CodeGen/libcalls-fno-builtin.c
@@ -1,4 +1,11 @@
 // RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck %s
+// RUN: %clang_cc1 -S -O3 -fno-builtin-ceil -fno-builtin-copysign -fno-builtin-cos \
+// RUN:  -fno-builtin-fabs -fno-builtin-floor -fno-builtin-strcat -fno-builtin-strncat \
+// RUN:  -fno-builtin-strchr -fno-builtin-strrchr -fno-builtin-strcmp -fno-builtin-strncmp \
+// RUN:  -fno-builtin-strcpy -fno-builtin-stpcpy -fno-builtin-strncpy -fno-builtin-strlen \
+// RUN:  -fno-builtin-strpbrk -fno-builtin-strspn -fno-builtin-strtod -fno-builtin-strtof \
+// RUN:  -fno-builtin-strtold -fno-builtin-strtol -fno-builtin-strtoll -fno-builtin-strtoul \
+// RUN:  -fno-builtin-strtoull -o - %s | FileCheck %s
 // rdar://10551066
 
 typedef __SIZE_TYPE__ size_t;
Index: test/CodeGen/libcalls-complex.c
===
--- test/CodeGen/libcalls-complex.c
+++ test/CodeGen/libcalls-complex.c
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fno-builtin -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -fno-builtin-crealf -fno-builtin-creal -fno-builtin-creall \
+// RUN:  -fno-builtin-cimagf  -fno-builtin-cimag -fno-builtin-cimagl -emit-llvm \
+// RUN:  -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix CHECK-YES %s
 // RUN: %clang_cc1 -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix CHECK-NO %s
 
 extern float crealf(float _Complex);
Index: test/CodeGen/2007-04-14-FNoBuiltin.c
===
--- test/CodeGen/2007-04-14-FNoBuiltin.c
+++ test/CodeGen/2007-04-14-FNoBuiltin.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm %s -O2 -fno-builtin -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -O2 -fno-builtin-printf -o - | FileCheck %s
 // Check that -fno-builtin is honored.
 
 extern int printf(const char*, ...);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -8,13 +8,14 @@
 //===--===//
 
 #include "TestModuleFileExtension.h"
-#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Util.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/LangStandard.h"
 #includ

Re: [PATCH] D15222: [Patch][Profile] add “--dependent-lib= libclang_rt.profile-x86_64.a” to the CC1 command line when enabling code coverage on PS4

2015-12-15 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Sure! Thanks.


http://reviews.llvm.org/D15222



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


[PATCH] D15528: Teach clang-tidy how to -Werror checks.

2015-12-15 Thread Jonathan Roelofs via cfe-commits
jroelofs created this revision.
jroelofs added a reviewer: aaron.ballman.
jroelofs added a subscriber: cfe-commits.

http://reviews.llvm.org/D15528

Files:
  tools/llvm-project/extra/clang-tidy/ClangTidy.cpp
  tools/llvm-project/extra/clang-tidy/ClangTidy.h
  tools/llvm-project/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/llvm-project/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/llvm-project/extra/clang-tidy/ClangTidyOptions.cpp
  tools/llvm-project/extra/clang-tidy/ClangTidyOptions.h
  tools/llvm-project/extra/clang-tidy/tool/ClangTidyMain.cpp
  tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp
  tools/llvm-project/extra/test/clang-tidy/werrors.cpp

Index: tools/llvm-project/extra/test/clang-tidy/werrors.cpp
===
--- /dev/null
+++ tools/llvm-project/extra/test/clang-tidy/werrors.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -Werrors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR
+
+namespace i {
+}
+// CHECK-WARN: warning: namespace 'i' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'i' not terminated with a closing comment [llvm-namespace-comment, -Werrors=]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 1 warning treated as error
Index: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp
===
--- /dev/null
+++ tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -Werrors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR
+
+namespace j {
+}
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment, -Werrors=]
+
+namespace k {
+}
+// CHECK-WARN: warning: namespace 'k' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment, -Werrors=]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 2 warnings treated as errors
Index: tools/llvm-project/extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- tools/llvm-project/extra/clang-tidy/tool/ClangTidyMain.cpp
+++ tools/llvm-project/extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -64,6 +64,10 @@
cl::init(""), cl::cat(ClangTidyCategory));
 
 static cl::opt
+WErrors("Werrors", cl::desc("Upgrades warnings to errors. Same format as '-checks'."),
+cl::init(""), cl::cat(ClangTidyCategory));
+
+static cl::opt
 HeaderFilter("header-filter",
  cl::desc("Regular expression matching the names of the\n"
   "headers to output diagnostics from. Diagnostics\n"
@@ -227,6 +231,7 @@
 
   ClangTidyOptions DefaultOptions;
   DefaultOptions.Checks = DefaultChecks;
+  DefaultOptions.WErrors = "";
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
@@ -238,6 +243,8 @@
   ClangTidyOptions OverrideOptions;
   if (Checks.getNumOccurrences() > 0)
 OverrideOptions.Checks = Checks;
+  if (WErrors.getNumOccurrences() > 0)
+OverrideOptions.WErrors = WErrors;
   if (HeaderFilter.getNumOccurrences() > 0)
 OverrideOptions.HeaderFilterRegex = HeaderFilter;
   if (SystemHeaders.getNumOccurrences() > 0)
@@ -322,8 +329,10 @@
 
   const bool DisableFixes = Fix && FoundErrors && !FixErrors;
 
+  unsigned WErrorCount = 0;
+
   // -fix-errors implies -fix.
-  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes);
+  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
@@ -344,6 +353,13 @@
   if (EnableCheckProfile)
 printProfileData(Profile, llvm::errs());
 
+  if (WErrorCount) {
+StringRef Plural = WErrorCount == 1 ? "" : "s";
+llvm::errs() << WErrorCount << " warning" << Plural
+ << " treated as error" << Plural << "\n";
+return WErrorCount;
+  }
+
   return 0;
 }
 
Index: tools/llvm-project/extra/clang-tidy/ClangTidyOptions.h
===
--- tools/llvm-project/extra/clang-tidy/ClangTidyOptions.h
+++ tools/llvm-project/extra/clang-tidy/ClangTidyOptions.h
@@ -62,6 +62,9 @@
   /// \brief Checks filter.
   llvm::Optional Checks;
 
+  /// \brief WErrors filter.
+  llvm::Optional WErrors;
+
   /// \brief Output warnings from headers matching this filter. Warnings 

Re: [PATCH] D15486: [RFC] Emit note pointing to a discarded qualifier [-Wincompatible-pointer-types-discards-qualifiers]

2015-12-15 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D15486#310572, @adek05 wrote:

> @aaron.ballman I think this could be hard to achieve without an extra note if 
> you have something like:
>
>   cat test2.c
>   int main() {
>   char *c = 'a';
>  
>   char volatile** cc = &c;
>   cc = &c;
>   }
>
>
>
>
>   test2.c:2:15: warning: incompatible integer to pointer conversion 
> initializing 'char *' with an expression of type 'int' [-Wint-conversion]
>   char *c = 'a';
> ^   ~~~
>   test2.c:4:25: warning: initializing 'volatile char **' with an expression 
> of type 'char **' discards qualifiers in nested pointer types 
> [-Wincompatible-pointer-types-discards-qualifiers]
>   char volatile** cc = &c;
>   ^~~
>   test2.c:4:9: note: nested pointer type with discarded 'const' qualifier
>   char volatile** cc = &c;
>   ^~
>   test2.c:5:12: warning: assigning to 'volatile char **' from 'char **' 
> discards qualifiers in nested pointer types 
> [-Wincompatible-pointer-types-discards-qualifiers]
>   cc = &c;
>  ^ ~~
>   3 warnings generated.
>
>
> Sadly, my code doesn't print a note in the second case, which I would have to 
> debug. In case of initialization, I think we can just print one line and omit 
> note. 
>  For assignment which is not an initialization, it might be useful to point 
> to the declaration of a variable which is assigned.
>
> I will try to handle the second case and write tests for this. Let me know if 
> you feel like it is still worth proceeding.


I'm still not convinced this adds value as a note. The diagnostic has the type 
information for the destination as well as the source. A note pointing where 
the destination type lives doesn't seem to add any new information, but 
pointing out which qualifiers are discarded as part of the original diagnostic 
does add value. So I think that the idea has merit, but I don't think the note 
is the way to go. Instead, I wonder if it makes sense to just update the 
existing diagnostic to have further information when it is available.

Also, the note is currently incorrect -- it is claiming that the nested pointer 
type has a discarded const qualifier, but it has a discarded volatile 
qualifier. The code needs to figure out which qualifiers are discarded (and 
those qualifiers may be disjoint in the type specifier). Consider a type like 
"const char * volatile * const * restrict * const" -- the diagnostic would have 
to point out which qualifiers are discarded, and it could be that restrict and 
volatile are discarded but the consts are fine.

Perhaps as a first pass, you could handle the case where only a single 
qualifier is discarded, and add the qualifier and a SourceRange for that 
particular qualifier to the existing diagnostic. e.g., `Diag(Loc, 
diag::warn_incompatible_qualified_id) << FirstType << SecondType << 
DiscardedQualifier << TypeSourceRange;` Future iterations could then track 
multiple discarded qualifiers and their source ranges. (Note, I have no idea 
how easy or hard this might be.)


http://reviews.llvm.org/D15486



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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

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

Aside from two tiny nits, LGTM. Thank you for working on this, it's a great 
feature! I think we should add something to the release notes to make sure it 
gets called out.



Comment at: tools/llvm-project/extra/clang-tidy/ClangTidy.cpp:156
@@ -149,1 +155,3 @@
 
+  unsigned WErrorCount() { return WErrors; }
+

Method can be const.


Comment at: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp:7
@@ +6,3 @@
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment, -Werrors=]
+

One of these tests should complete the -Werrors= chunk just to be sure it's 
getting printed properly.


http://reviews.llvm.org/D15528



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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2015-12-15 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: tools/llvm-project/extra/clang-tidy/ClangTidy.cpp:119
@@ +118,3 @@
+  if (Error.IsWError) {
+Name += ", -Werrors=";
+Level = DiagnosticsEngine::Error;

hardcoding happens here ^


Comment at: tools/llvm-project/extra/clang-tidy/ClangTidy.cpp:156
@@ -149,1 +155,3 @@
 
+  unsigned WErrorCount() { return WErrors; }
+

aaron.ballman wrote:
> Method can be const.
ok


Comment at: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp:7
@@ +6,3 @@
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment, -Werrors=]
+

aaron.ballman wrote:
> One of these tests should complete the -Werrors= chunk just to be sure it's 
> getting printed properly.
Not sure what you mean here. Should I be printing the -Werrors argument as the 
user wrote it? (it isn't currently... this is just a hardcoded string).


http://reviews.llvm.org/D15528



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


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2015-12-15 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

I would also like to see a test case based on the following from ISO/IEC TS 
18661-3:2015:

> If both operands have floating types and neither of the sets of values of 
> their corresponding real types is a subset of (or equivalent to) the other, 
> the behavior is undefined.




  auto f(__float128 q, long double ld) {
return q + ld; // error: no common type
  }


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

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


Comment at: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp:7
@@ +6,3 @@
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment, -Werrors=]
+

jroelofs wrote:
> aaron.ballman wrote:
> > One of these tests should complete the -Werrors= chunk just to be sure it's 
> > getting printed properly.
> Not sure what you mean here. Should I be printing the -Werrors argument as 
> the user wrote it? (it isn't currently... this is just a hardcoded string).
Ah, I didn't pick up on that. What is the = for, then?


http://reviews.llvm.org/D15528



___
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-15 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Attribute implementation LGTM, but I do not know the semantics of ifunc well 
enough to comment on whether this implementation is correct or not. From what I 
can tell of GCC's documentation, it looks reasonable, but it would be good for 
Eric or John to take a look as well.


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: r255382 - [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.

2015-12-15 Thread Nico Weber via cfe-commits
Feedback on PR25563 pretty strongly suggests that users do want most of
this. It looks like llvm passes /wd4100 to suppress the corresponding cl
warning. r255655 maps that to -Wno-unused-parameter – does this fix the
problem of these bots?

On Mon, Dec 14, 2015 at 10:01 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> So, this change makes it impossible to download the build lots from the
> Windows self-hosting builders because of -Wunused-parameter errors.
>
> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/5103/steps/build%20stage%202/logs/stdio
>
> Maybe that's an indication that users don't really want /W4 to go to
> -Wextra?
>
> On Fri, Dec 11, 2015 at 2:31 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: nico
>> Date: Fri Dec 11 16:31:16 2015
>> New Revision: 255382
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=255382&view=rev
>> Log:
>> [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.
>>
>> There's no way to make a flag alias to two flags, so add a /WCL4 flag that
>> maps to the All, Extra diag groups.  Fixes PR25563.
>>
>> http://reviews.llvm.org/D15350
>>
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/test/Driver/cl-options.c
>>
>> Modified: cfe/trunk/docs/UsersManual.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=255382&r1=255381&r2=255382&view=diff
>>
>> ==
>> --- cfe/trunk/docs/UsersManual.rst (original)
>> +++ cfe/trunk/docs/UsersManual.rst Fri Dec 11 16:31:16 2015
>> @@ -2080,7 +2080,7 @@ Execute ``clang-cl /?`` to see a list of
>>/W1Enable -Wall
>>/W2Enable -Wall
>>/W3Enable -Wall
>> -  /W4Enable -Wall
>> +  /W4Enable -Wall and -Wextra
>>/Wall  Enable -Wall
>>/WX-   Do not treat warnings as errors
>>/WXTreat warnings as errors
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=255382&r1=255381&r2=255382&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Dec 11 16:31:16
>> 2015
>> @@ -663,7 +663,10 @@ def Consumed   : DiagGroup<"consumed
>>  // Note that putting warnings in -Wall will not disable them by default.
>> If a
>>  // warning should be active _only_ when -Wall is passed in, mark it as
>>  // DefaultIgnore in addition to putting it here.
>> -def : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
>> +def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
>> +
>> +// Warnings that should be in clang-cl /w4.
>> +def : DiagGroup<"CL4", [All, Extra]>;
>>
>>  // Warnings enabled by -pedantic.  This is magically filled in by
>> TableGen.
>>  def Pedantic : DiagGroup<"pedantic">;
>>
>> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=255382&r1=255381&r2=255382&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
>> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Dec 11 16:31:16
>> 2015
>> @@ -119,7 +119,7 @@ def _SLASH_W0 : CLFlag<"W0">, HelpText<"
>>  def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias;
>>  def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias;
>>  def _SLASH_W3 : CLFlag<"W3">, HelpText<"Enable -Wall">, Alias;
>> -def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall">, Alias;
>> +def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall and -Wextra">,
>> Alias;
>>  def _SLASH_Wall : CLFlag<"Wall">, HelpText<"Enable -Wall">, Alias;
>>  def _SLASH_WX : CLFlag<"WX">, HelpText<"Treat warnings as errors">,
>>Alias, AliasArgs<["error"]>;
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=255382&r1=255381&r2=255382&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Fri Dec 11 16:31:16 2015
>> @@ -295,6 +295,7 @@ def Wa_COMMA : CommaJoined<["-"], "Wa,">
>>HelpText<"Pass the comma separated arguments in  to the
>> assembler">,
>>MetaVarName<"">;
>>  def Wall : Flag<["-"], "Wall"

r255655 - clang-cl: Add an alias for /wd4100

2015-12-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Dec 15 11:07:16 2015
New Revision: 255655

URL: http://llvm.org/viewvc/llvm-project?rev=255655&view=rev
Log:
clang-cl: Add an alias for /wd4100

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=255655&r1=255654&r2=255655&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Dec 15 11:07:16 2015
@@ -128,10 +128,12 @@ def _SLASH_WX_ : CLFlag<"WX-">, HelpText
 def _SLASH_w_flag : CLFlag<"w">, HelpText<"Disable all warnings">, Alias;
 def _SLASH_wd4005 : CLFlag<"wd4005">, Alias,
   AliasArgs<["no-macro-redefined"]>;
-def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
-  AliasArgs<["no-deprecated-declarations"]>;
+def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
+  AliasArgs<["no-unused-parameter"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
+def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
+  AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=255655&r1=255654&r2=255655&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Dec 15 11:07:16 2015
@@ -216,11 +216,12 @@
 // NOSTRICT: "-relaxed-aliasing"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4996 -wd4910 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
-// Wno: "-Wno-deprecated-declarations"
+// Wno: "-Wno-unused-parameter"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
+// Wno: "-Wno-deprecated-declarations"
 
 // Ignored options. Check that we don't get "unused during compilation" errors.
 // RUN: %clang_cl /c \


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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2015-12-15 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Jonathan, can you explain what specific use case does this patch address? Why 
one severity level of native clang-tidy warnings (the current situation) is not 
enough, and two levels are enough?


http://reviews.llvm.org/D15528



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


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2015-12-15 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

In http://reviews.llvm.org/D15120#310992, @nemanjai wrote:

> I think the correct course of action would be to allow/disallow promotion 
> based on a condition that the two types are the same/different 
> (respectively). I think a comparison of the float semantics is a valid way to 
> check this. Also, should operations between long double and __float128 be 
> diagnosed as warnings or errors if the two types are distinct?


When the "two" types have the same float semantics, an additional consideration 
is whether there are indeed two types, or if there is just one (with different 
ways to name it). On x86_64 Linux systems, I believe that the latter case is 
true for `__float80` and `long double` with GCC; however, with 
`-mlong-double-128`, GCC treats `__float128` and `long double` as distinct (but 
uses the same mangling for both). That is to say, GCC is inconsistent.
With regards to the usual arithmetic conversions, I believe that an error is 
the safest course of action when the two types are distinct (between 
PPCDoubleDouble and IEEEquad). It appears that the use of 
`IsFloatingPointPromotion` for C is sketchy (see inline comments).



Comment at: lib/Sema/SemaOverload.cpp:1921-1922
@@ -1920,4 +1920,4 @@
   // C99 6.3.1.5p1:
   //   When a float is promoted to double or long double, or a
   //   double is promoted to long double [...].
   if (!getLangOpts().CPlusPlus &&

hubert.reinterpretcast wrote:
> In C99 6.3.1.5p1:
> > [...] its value is unchanged.
> 
> Allowing `long double` to promote to `__float128` violates that on at least 
> one target platform.
> For example, PPCDoubleDouble can represent (2^512) - 1 exactly.
> 
The only "promotions" in C as of C11 are the integer promotions and the default 
argument promotions. The (now removed) use of "promoted" to describe a 
//conversion// between double to long double appears to have been an 
unintentional overloading of the term. If the purpose of this function is as 
described (to implement conv.fpprom), then the use of it for C appears to be 
erroneous. At the very least, the comments are not sufficient and the naming of 
the function (given its current implementation) no longer has a basis in the C 
Standard.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2015-12-15 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D15528#311019, @alexfh wrote:

> Jonathan, can you explain what specific use case does this patch address? Why 
> one severity level of native clang-tidy warnings (the current situation) is 
> not enough, and two levels are enough?


I have out-of-tree checkers for a very strange out-of-tree target. Some of the 
checks are on the level of "this should break the build because it cannot 
possibly work on this target" and others on the level of "tell me about it, but 
don't force me to fix it". All of these checks are things that don't even 
remotely apply to other targets.

If you're wondering why I haven't hacked up Clang's sema to enforce these 
constraints, see again: out-of-tree backend... maintaining OOT changes there is 
expected to be very difficult. Clang-tidy however provides a very nice 
framework where they can be kept neatly off to the side, away from most of the 
merge hassles.

It'd be nice not to have to run clang-tidy twice & parse its output in order to 
achieve all of that, hence this patch.



Comment at: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp:7
@@ +6,3 @@
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment, -Werrors=]
+

aaron.ballman wrote:
> jroelofs wrote:
> > aaron.ballman wrote:
> > > One of these tests should complete the -Werrors= chunk just to be sure 
> > > it's getting printed properly.
> > Not sure what you mean here. Should I be printing the -Werrors argument as 
> > the user wrote it? (it isn't currently... this is just a hardcoded string).
> Ah, I didn't pick up on that. What is the = for, then?
I considered that part of the name of the flag.

I can drop that if you think it looks better. Or print out the whole thing as 
the user wrote it, if you think that's useful (though -checks= and -Werrors= 
lines are probably pretty long...).



http://reviews.llvm.org/D15528



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


Re: [PATCH] D15222: [Patch][Profile] add “--dependent-lib= libclang_rt.profile-x86_64.a” to the CC1 command line when enabling code coverage on PS4

2015-12-15 Thread Ying Yi via cfe-commits
MaggieYi updated this revision to Diff 42874.
MaggieYi added a comment.

Thanks, I have updated the test following your comments.


http://reviews.llvm.org/D15222

Files:
  lib/Driver/Tools.cpp
  test/Driver/ps4-runtime-flags.c

Index: test/Driver/ps4-runtime-flags.c
===
--- /dev/null
+++ test/Driver/ps4-runtime-flags.c
@@ -0,0 +1,19 @@
+// REQUIRES: x86-registered-target
+//
+// Test the profile runtime library to be linked for PS4 compiler.
+// Check PS4 runtime flag --dependent-lib which does not append the default library search path.
+//
+// RUN: %clang -target x86_64-scei-ps4 --coverage %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs %s -### 2>&1 | FileCheck -check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs -fno-profile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate=dir %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate=somefile.profraw %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+//
+// CHECK-PS4-PROFILE: "--dependent-lib=libclang_rt.profile-x86_64.a"
+// CHECK-PS4-NO-PROFILE-NOT: "--dependent-lib=libclang_rt.profile-x86_64.a"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3112,6 +3112,23 @@
   }
 }
 
+static void addPS4ProfileRTArgs(const ToolChain &TC, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  if ((Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
+false) ||
+   Args.hasFlag(options::OPT_fprofile_generate,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_generate_EQ,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasFlag(options::OPT_fprofile_instr_generate_EQ,
+options::OPT_fno_profile_instr_generate, false) ||
+   Args.hasArg(options::OPT_fcreate_profile) ||
+   Args.hasArg(options::OPT_coverage)))
+CmdArgs.push_back("--dependent-lib=libclang_rt.profile-x86_64.a");
+}
+
 /// Parses the various -fpic/-fPIC/-fpie/-fPIE arguments.  Then,
 /// smooshes them together with platform defaults, to decide whether
 /// this compile should be using PIC mode or not. Returns a tuple of
@@ -4047,6 +4064,10 @@
 
   addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
 
+  // Add runtime flag for PS4 when PGO or Coverage are enabled.
+  if (getToolChain().getTriple().isPS4CPU())
+addPS4ProfileRTArgs(getToolChain(), Args, CmdArgs);
+
   // Pass options for controlling the default header search paths.
   if (Args.hasArg(options::OPT_nostdinc)) {
 CmdArgs.push_back("-nostdsysteminc");
@@ -10067,21 +10088,6 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
-static void AddPS4ProfileRT(const ToolChain &TC, const ArgList &Args,
-ArgStringList &CmdArgs) {
-  if (!(Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
- false) ||
-Args.hasArg(options::OPT_fprofile_generate) ||
-Args.hasArg(options::OPT_fprofile_instr_generate) ||
-Args.hasArg(options::OPT_fcreate_profile) ||
-Args.hasArg(options::OPT_coverage)))
-return;
-
-  assert(TC.getTriple().isPS4CPU() &&
- "Profiling libraries are only implemented for the PS4 CPU");
-  CmdArgs.push_back("-lclang_rt.profile-x86_64");
-}
-
 static void AddPS4SanitizerArgs(const ToolChain &TC, ArgStringList &CmdArgs) {
   const SanitizerArgs &SanArgs = TC.getSanitizerArgs();
   if (SanArgs.needsUbsanRt()) {
@@ -10146,8 +10152,6 @@
 CmdArgs.push_back("-lpthread");
   }
 
-  AddPS4ProfileRT(ToolChain, Args, CmdArgs);
-
   const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld"));
 
   C.add

[PATCH] D15534: [CUDA] renamed cuda_runtime.h wrapper to __cuda_runtime.h

2015-12-15 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: echristo.
tra added a subscriber: cfe-commits.

Currently it's easy to break CUDA compilation by passing
"-isystem /path/to/cuda/include" to compiler which leads to
compiler including real cuda_runtime.h from there instead
of the wrapper we need.

Renaming the wrapper ensures that we can include the wrapper
regardless of user-specified include paths and files.


http://reviews.llvm.org/D15534

Files:
  lib/Driver/ToolChains.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__cuda_runtime.h
  lib/Headers/cuda_runtime.h
  test/Driver/cuda-detect.cu

Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -39,7 +39,7 @@
 // RUN:   -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
 // Verify that we don't add include paths, link with libdevice or
-// -include cuda_runtime without valid CUDA installation.
+// -include __cuda_runtime without valid CUDA installation.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
 // RUN:   --cuda-path=%S/no-cuda-there %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
@@ -59,6 +59,6 @@
 // NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
 // CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA/usr/local/cuda/include"
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
-// CUDAINC-SAME: "-include" "cuda_runtime.h"
-// NOCUDAINC-NOT: "-include" "cuda_runtime.h"
+// CUDAINC-SAME: "-include" "__cuda_runtime.h"
+// NOCUDAINC-NOT: "-include" "__cuda_runtime.h"
 // COMMON-SAME: "-x" "cuda"
Index: lib/Headers/cuda_runtime.h
===
--- /dev/null
+++ lib/Headers/cuda_runtime.h
@@ -1,179 +0,0 @@
-/*=== cuda_runtime.h - CUDA runtime support ===
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===---===
- */
-
-#ifndef __CLANG_CUDA_RUNTIME_H__
-#define __CLANG_CUDA_RUNTIME_H__
-
-#if defined(__CUDA__) && defined(__clang__)
-
-// Include some standard headers to avoid CUDA headers including them
-// while some required macros (like __THROW) are in a weird state.
-#include 
-
-// Preserve common macros that will be changed below by us or by CUDA
-// headers.
-#pragma push_macro("__THROW")
-#pragma push_macro("__CUDA_ARCH__")
-
-// WARNING: Preprocessor hacks below are based on specific of
-// implementation of CUDA-7.x headers and are expected to break with
-// any other version of CUDA headers.
-#include "cuda.h"
-#if !defined(CUDA_VERSION)
-#error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 7050
-#error "Unsupported CUDA version!"
-#endif
-
-// Make largest subset of device functions available during host
-// compilation -- SM_35 for the time being.
-#ifndef __CUDA_ARCH__
-#define __CUDA_ARCH__ 350
-#endif
-
-#include "cuda_builtin_vars.h"
-
-// No need for device_launch_parameters.h as cuda_builtin_vars.h above
-// has taken care of builtin variables declared in the file.
-#define __DEVICE_LAUNCH_PARAMETERS_H__
-
-// {math,device}_functions.h only have declarations of the
-// functions. We don't need them as we're going to pull in their
-// definitions from .hpp files.
-#define __DEVICE_FUNCTIONS_H__
-#define __MATH_FUNCTIONS_H__
-
-#undef __CUDACC__
-#define __CUDABE__
-// Disables definitions of device-side runtime support stubs in
-// cuda_device_runtime_api.h
-#define __CUDADEVRT_INTERNAL__
-#include "host_config.h"
-#include "host_defines.h"
-#include "driver_types.h"
-#include "common_functions.h"
-#undef __CUDADEVRT_INTERNAL__
-
-#undef __CUDABE__
-#define __CUDACC__
-#include_next "cuda_runtime.h"
-
-#undef __CUDACC__
-#define __CUDABE__
-
-// CUDA headers use __nvvm_memcpy and

[libclc] r255663 - AMDGPU: Add aliases for all VI targets

2015-12-15 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue Dec 15 12:37:04 2015
New Revision: 255663

URL: http://llvm.org/viewvc/llvm-project?rev=255663&view=rev
Log:
AMDGPU: Add aliases for all VI targets

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=255663&r1=255662&r2=255663&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Tue Dec 15 12:37:04 2015
@@ -96,7 +96,7 @@ available_targets = {
 {'gpu' : 'barts',   'aliases' : ['turks', 'caicos']},
 {'gpu' : 'cayman',  'aliases' : ['aruba']}]},
   'amdgcn--': { 'devices' :
-[{'gpu' : 'tahiti',  'aliases' : ['pitcairn', 'verde', 
'oland', 'hainan', 'bonaire', 'kabini', 'kaveri', 'hawaii', 'mullins', 
'tonga']}]},
+[{'gpu' : 'tahiti',  'aliases' : ['pitcairn', 'verde', 
'oland', 'hainan', 'bonaire', 'kabini', 'kaveri', 'hawaii', 'mullins', 
'tonga','carrizo','iceland','fiji','stoney']}]},
   'nvptx--'   : { 'devices' : [{'gpu' : '', 'aliases' : []}]},
   'nvptx64--'   : { 'devices' : [{'gpu' : '', 'aliases' : []}] },
   'nvptx--nvidiacl'   : { 'devices' : [{'gpu' : '', 'aliases' : []}] },


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


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2015-12-15 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

I think the correct course of action would be to allow/disallow promotion based 
on a condition that the two types are the same/different (respectively). I 
think a comparison of the float semantics is a valid way to check this. Also, 
should operations between long double and __float128 be diagnosed as warnings 
or errors if the two types are distinct?


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


[libclc] r255662 - AMDGPU: Add alias for tonga

2015-12-15 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue Dec 15 12:37:02 2015
New Revision: 255662

URL: http://llvm.org/viewvc/llvm-project?rev=255662&view=rev
Log:
AMDGPU: Add alias for tonga

Patch by: Vedran Mileti

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=255662&r1=255661&r2=255662&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Tue Dec 15 12:37:02 2015
@@ -96,7 +96,7 @@ available_targets = {
 {'gpu' : 'barts',   'aliases' : ['turks', 'caicos']},
 {'gpu' : 'cayman',  'aliases' : ['aruba']}]},
   'amdgcn--': { 'devices' :
-[{'gpu' : 'tahiti',  'aliases' : ['pitcairn', 'verde', 
'oland', 'hainan', 'bonaire', 'kabini', 'kaveri', 'hawaii','mullins']}]},
+[{'gpu' : 'tahiti',  'aliases' : ['pitcairn', 'verde', 
'oland', 'hainan', 'bonaire', 'kabini', 'kaveri', 'hawaii', 'mullins', 
'tonga']}]},
   'nvptx--'   : { 'devices' : [{'gpu' : '', 'aliases' : []}]},
   'nvptx64--'   : { 'devices' : [{'gpu' : '', 'aliases' : []}] },
   'nvptx--nvidiacl'   : { 'devices' : [{'gpu' : '', 'aliases' : []}] },


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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

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


Comment at: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp:7
@@ +6,3 @@
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment, -Werrors=]
+

jroelofs wrote:
> aaron.ballman wrote:
> > jroelofs wrote:
> > > aaron.ballman wrote:
> > > > One of these tests should complete the -Werrors= chunk just to be sure 
> > > > it's getting printed properly.
> > > Not sure what you mean here. Should I be printing the -Werrors argument 
> > > as the user wrote it? (it isn't currently... this is just a hardcoded 
> > > string).
> > Ah, I didn't pick up on that. What is the = for, then?
> I considered that part of the name of the flag.
> 
> I can drop that if you think it looks better. Or print out the whole thing as 
> the user wrote it, if you think that's useful (though -checks= and -Werrors= 
> lines are probably pretty long...).
> 
I would just drop the =; it seems like that suggests there should be more text 
there. That would also be consistent with the way clang reports -Werror 
diagnostics (error: unused variable 'i' [-Werror,-Wunused-variable])


http://reviews.llvm.org/D15528



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


r255667 - Unsupport test that should not be run on Hexagon

2015-12-15 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Tue Dec 15 13:14:24 2015
New Revision: 255667

URL: http://llvm.org/viewvc/llvm-project?rev=255667&view=rev
Log:
Unsupport test that should not be run on Hexagon

Modified:
cfe/trunk/test/CodeGen/ms_this.cpp

Modified: cfe/trunk/test/CodeGen/ms_this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_this.cpp?rev=255667&r1=255666&r2=255667&view=diff
==
--- cfe/trunk/test/CodeGen/ms_this.cpp (original)
+++ cfe/trunk/test/CodeGen/ms_this.cpp Tue Dec 15 13:14:24 2015
@@ -1,3 +1,7 @@
+// Hexagon build bot defines hexagon-unknown-elf as the default target triple,
+// which seems to trump the -triple argument for some reason.
+// UNSUPPORTED: hexagon
+
 // RUN: %clang_cc1 -triple x86_64-pc-win32 -fasm-blocks -emit-llvm %s -o - | 
FileCheck %s
 class t1 {
 public:


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


Re: [PATCH] D15534: [CUDA] renamed cuda_runtime.h wrapper to __clang_cuda_runtime_wrapper.h

2015-12-15 Thread Artem Belevich via cfe-commits
tra retitled this revision from "[CUDA] renamed cuda_runtime.h wrapper to 
__cuda_runtime.h" to "[CUDA] renamed cuda_runtime.h wrapper to 
__clang_cuda_runtime_wrapper.h".
tra updated the summary for this revision.
tra added a reviewer: chandlerc.
tra updated this revision to Diff 42882.
tra added a comment.

Changed name to __clang_cuda_runtime_wrapper.h
Added comments in the header explaining intended use.


http://reviews.llvm.org/D15534

Files:
  lib/Driver/ToolChains.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_runtime_wrapper.h
  lib/Headers/cuda_runtime.h
  test/Driver/cuda-detect.cu

Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -39,7 +39,7 @@
 // RUN:   -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
 // Verify that we don't add include paths, link with libdevice or
-// -include cuda_runtime without valid CUDA installation.
+// -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
 // RUN:   --cuda-path=%S/no-cuda-there %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
@@ -59,6 +59,6 @@
 // NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
 // CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA/usr/local/cuda/include"
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
-// CUDAINC-SAME: "-include" "cuda_runtime.h"
-// NOCUDAINC-NOT: "-include" "cuda_runtime.h"
+// CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
+// NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
 // COMMON-SAME: "-x" "cuda"
Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -1,4 +1,4 @@
-/*=== cuda_runtime.h - CUDA runtime support ===
+/*=== __clang_cuda_runtime_wrapper.h - CUDA runtime support -===
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -21,8 +21,24 @@
  *===---===
  */
 
-#ifndef __CLANG_CUDA_RUNTIME_H__
-#define __CLANG_CUDA_RUNTIME_H__
+/*
+ * WARNING: This header is intended to be directly -include'd by
+ * compiler and is not supposed to be included by users.
+ *
+ * CUDA headers are implemented in a way that currently makes it
+ * impossible to use them by clang directly. They present different
+ * view of cuda-supplied functions depending on where in nvcc's
+ * compilation pipeline the headers are included from. Neither of
+ * these modes provides function definitions with correct attributes,
+ * so we have to abuse preprocessor in order to shape CUDA headers
+ * into something clang can use.
+ *
+ * Similarly to nvcc which -include's cuda_runtime.h, clang -include's
+ * this file during every CUDA compilation.
+ */
+
+#ifndef __CLANG_CUDA_RUNTIME_WRAPPER_H__
+#define __CLANG_CUDA_RUNTIME_WRAPPER_H__
 
 #if defined(__CUDA__) && defined(__clang__)
 
@@ -35,9 +51,9 @@
 #pragma push_macro("__THROW")
 #pragma push_macro("__CUDA_ARCH__")
 
-// WARNING: Preprocessor hacks below are based on specific of
-// implementation of CUDA-7.x headers and are expected to break with
-// any other version of CUDA headers.
+// WARNING: Preprocessor hacks below are based on specific details of
+// CUDA-7.x headers and are not expected to work with any other
+// version of CUDA headers.
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
@@ -176,4 +192,4 @@
 #endif
 
 #endif // __CUDA__
-#endif // __CLANG_CUDA_RUNTIME_H__
+#endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -15,9 +15,9 @@
   avxintrin.h
   bmi2intrin.h
   bmiintrin.h
+  __clang_cuda_runtime_wrapper.h
   cpuid.h
   cuda_builtin_vars.h
-  cuda_runtime.h
   emmintrin.h
   f16cintrin.h
   float.h
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4116,7 +4116,7 @@
   if (CudaInstallation.isValid()) {
 addSystemInclude(DriverArgs, CC1Args, CudaInstallation.getIncludePath());
 CC1Args.push_back("-include");
-CC1Args.push_back("cuda_runtime.h");
+CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

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

In http://reviews.llvm.org/D15528#311053, @jroelofs wrote:

> In http://reviews.llvm.org/D15528#311019, @alexfh wrote:
>
> > Jonathan, can you explain what specific use case does this patch address? 
> > Why one severity level of native clang-tidy warnings (the current 
> > situation) is not enough, and two levels are enough?
>
>
> I have out-of-tree checkers for a very strange out-of-tree target. Some of 
> the checks are on the level of "this should break the build because it cannot 
> possibly work on this target" and others on the level of "tell me about it, 
> but don't force me to fix it". All of these checks are things that don't even 
> remotely apply to other targets.


Thank you for the explanation. One more question: do you need to define Werrors 
differently in different directories?

> If you're wondering why I haven't hacked up Clang's sema to enforce these 
> constraints, see again: out-of-tree backend... maintaining OOT changes there 
> is expected to be very difficult.


No, a sane person wouldn't suggest maintaining a local patch for Clang as a 
good solution ;)

> Clang-tidy however provides a very nice framework where they can be kept 
> neatly off to the side, away from most of the merge hassles.


It's one of the goals of clang-tidy to provide an easy way to maintain 
out-of-tree checks.

> It'd be nice not to have to run clang-tidy twice & parse its output in order 
> to achieve all of that, hence this patch.


Agreed, I want to ensure though, that this is the right approach. In 
particular, I wonder whether a way to assign labels or severities to clang-tidy 
diagnostics would be better. Another question is whether we can reuse something 
from the Clang diagnostic subsystem to map warning levels.


http://reviews.llvm.org/D15528



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


Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2015-12-15 Thread Samuel Benzaquen via cfe-commits
sbenza updated this revision to Diff 42884.
sbenza added a comment.

Add a faster version of the qualified name matcher.
It falls back to the previous version if it can't handle the name.


http://reviews.llvm.org/D15506

Files:
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/ASTMatchersInternal.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2644,6 +2644,52 @@
  recordDecl(hasName("A+B::C";
 }
 
+TEST(Matcher, HasNameSupportsInlinedNamespaces) {
+  std::string code = "namespace a { inline namespace b { class C; } }";
+  EXPECT_TRUE(matches(code, recordDecl(hasName("a::b::C";
+  EXPECT_TRUE(matches(code, recordDecl(hasName("a::C";
+  EXPECT_TRUE(matches(code, recordDecl(hasName("::a::b::C";
+  EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C";
+}
+
+TEST(Matcher, HasNameSupportsAnonymousNamespaces) {
+  std::string code = "namespace a { namespace { class C; } }";
+  EXPECT_TRUE(
+  matches(code, recordDecl(hasName("a::(anonymous namespace)::C";
+  EXPECT_TRUE(matches(code, recordDecl(hasName("a::C";
+  EXPECT_TRUE(
+  matches(code, recordDecl(hasName("::a::(anonymous namespace)::C";
+  EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C";
+}
+
+TEST(Matcher, HasNameSupportsAnonymousOuterClasses) {
+  EXPECT_TRUE(matches("class A { class { class C; } x; };",
+  recordDecl(hasName("A::(anonymous class)::C";
+  EXPECT_TRUE(matches("class A { class { class C; } x; };",
+  recordDecl(hasName("::A::(anonymous class)::C";
+  EXPECT_FALSE(matches("class A { class { class C; } x; };",
+   recordDecl(hasName("::A::C";
+  EXPECT_TRUE(matches("class A { struct { class C; } x; };",
+  recordDecl(hasName("A::(anonymous struct)::C";
+  EXPECT_TRUE(matches("class A { struct { class C; } x; };",
+  recordDecl(hasName("::A::(anonymous struct)::C";
+  EXPECT_FALSE(matches("class A { struct { class C; } x; };",
+   recordDecl(hasName("::A::C";
+}
+
+TEST(Matcher, HasNameSupportsFunctionScope) {
+  std::string code =
+  "namespace a { void F(int a) { struct S { int m; }; int i; } }";
+  EXPECT_TRUE(matches(code, varDecl(hasName("i";
+  EXPECT_FALSE(matches(code, varDecl(hasName("F()::i";
+
+  EXPECT_TRUE(matches(code, fieldDecl(hasName("m";
+  EXPECT_TRUE(matches(code, fieldDecl(hasName("S::m";
+  EXPECT_TRUE(matches(code, fieldDecl(hasName("F(int)::S::m";
+  EXPECT_TRUE(matches(code, fieldDecl(hasName("a::F(int)::S::m";
+  EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
+}
+
 TEST(Matcher, IsDefinition) {
   DeclarationMatcher DefinitionOfClassA =
   recordDecl(hasName("A"), isDefinition());
Index: lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- lib/ASTMatchers/ASTMatchersInternal.cpp
+++ lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -298,45 +298,149 @@
   assert(!Name.empty());
 }
 
-bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl &Node) const {
-  assert(UseUnqualifiedMatch);
-  if (Node.getIdentifier()) {
-// Simple name.
-return Name == Node.getName();
+namespace {
+
+bool MatchNameSuffix(StringRef &FullName, StringRef Suffix) {
+  StringRef Name = FullName;
+  if (!Name.endswith(Suffix))
+return false;
+  Name = Name.drop_back(Suffix.size());
+  if (!Name.empty()) {
+if (!Name.endswith("::"))
+  return false;
+Name = Name.drop_back(2);
   }
+  FullName = Name;
+  return true;
+}
+
+bool MatchNodeName(StringRef &Name, const NamedDecl &Node) {
+  // Simple name.
+  if (Node.getIdentifier())
+return MatchNameSuffix(Name, Node.getName());
+
   if (Node.getDeclName()) {
 // Name needs to be constructed.
 llvm::SmallString<128> NodeName;
 llvm::raw_svector_ostream OS(NodeName);
 Node.printName(OS);
-return Name == OS.str();
+return MatchNameSuffix(Name, OS.str());
   }
-  return false;
+
+  return MatchNameSuffix(Name, "(anonymous)");
 }
 
-bool HasNameMatcher::matchesNodeFull(const NamedDecl &Node) const {
-  llvm::SmallString<128> NodeName = StringRef("::");
-  llvm::raw_svector_ostream OS(NodeName);
-  Node.printQualifiedName(OS);
-  const StringRef FullName = OS.str();
+}  // namespace
+
+bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl &Node) const {
+  assert(UseUnqualifiedMatch);
+  StringRef NodeName = Name;
+  return MatchNodeName(NodeName, Node) && NodeName.empty();
+}
+
+bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const {
+  // This function is copied and adapted from NamedDecl::printQualifiedName()
+  // By matching each part individually we optimize in a couple of ways:
+  /

Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2015-12-15 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:322
@@ +321,3 @@
+  for (bool SkipUnwritten : SkipUnwrittenCases) {
+llvm::SmallString<128> NodeName = StringRef("::");
+llvm::raw_svector_ostream OS(NodeName);

yaron.keren wrote:
> StringRef not needed, simply
> 
>   llvm::SmallString<128> NodeName = "::";
> 
I tried it before. It doesn't work.

/usr/local/google/llvm_git/llvm/tools/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:321:28:
 error: no viable conversion from 'const char [3]' to
  'llvm::SmallString<128>'
llvm::SmallString<128> NodeName = "::";



http://reviews.llvm.org/D15506



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


Re: [PATCH] D15518: [WinEH] Update clang to use operand bundles on call sites

2015-12-15 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 42886.
majnemer added a comment.

- Address review comments


http://reviews.llvm.org/D15518

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenModule.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2495,6 +2495,7 @@
 
   llvm::Type *newRetTy = newFn->getReturnType();
   SmallVector newArgs;
+  SmallVector newBundles;
 
   for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
  ui != ue; ) {
@@ -2562,16 +2563,19 @@
 // over the required information.
 newArgs.append(callSite.arg_begin(), callSite.arg_begin() + argNo);
 
+// Copy over any operand bundles.
+callSite.getOperandBundlesAsDefs(newBundles);
+
 llvm::CallSite newCall;
 if (callSite.isCall()) {
-  newCall = llvm::CallInst::Create(newFn, newArgs, "",
+  newCall = llvm::CallInst::Create(newFn, newArgs, newBundles, "",
callSite.getInstruction());
 } else {
   auto *oldInvoke = cast(callSite.getInstruction());
   newCall = llvm::InvokeInst::Create(newFn,
  oldInvoke->getNormalDest(),
  oldInvoke->getUnwindDest(),
- newArgs, "",
+ newArgs, newBundles, "",
  callSite.getInstruction());
 }
 newArgs.clear(); // for the next iteration
@@ -2589,6 +2593,7 @@
 // Copy debug location attached to CI.
 if (callSite->getDebugLoc())
   newCall->setDebugLoc(callSite->getDebugLoc());
+
 callSite->eraseFromParent();
   }
 }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -3058,19 +3058,41 @@
   return call;
 }
 
+// Calls which may throw must have operand bundles indicating which funclet
+// they are nested within.
+static void
+getBundlesForFunclet(llvm::Value *Callee,
+ llvm::Instruction *CurrentFuncletPad,
+ SmallVectorImpl &BundleList) {
+  // There is no need for a funclet operand bundle if we aren't inside a funclet.
+  if (!CurrentFuncletPad)
+return;
+
+  // Skip intrinsics which cannot throw.
+  auto *CalleeFn = dyn_cast(Callee->stripPointerCasts());
+  if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
+return;
+
+  BundleList.emplace_back("funclet", CurrentFuncletPad);
+}
+
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {
+  SmallVector BundleList;
+  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+
   if (getInvokeDest()) {
 llvm::InvokeInst *invoke = 
   Builder.CreateInvoke(callee,
getUnreachableBlock(),
getInvokeDest(),
-   args);
+   args,
+   BundleList);
 invoke->setDoesNotReturn();
 invoke->setCallingConv(getRuntimeCC());
   } else {
-llvm::CallInst *call = Builder.CreateCall(callee, args);
+llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList);
 call->setDoesNotReturn();
 call->setCallingConv(getRuntimeCC());
 Builder.CreateUnreachable();
@@ -3489,12 +3511,16 @@
   }
   llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
 
+  SmallVector BundleList;
+  getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList);
+
   llvm::CallSite CS;
   if (!InvokeDest) {
-CS = Builder.CreateCall(Callee, IRCallArgs);
+CS = Builder.CreateCall(Callee, IRCallArgs, BundleList);
   } else {
 llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
-CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs);
+CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs,
+  BundleList);
 EmitBlock(Cont);
   }
   if (callOrInvoke)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r255382 - [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.

2015-12-15 Thread Nico Weber via cfe-commits
Looks like the warning is still emitted frequently. It looks like cl.exe
processes /W4 before /wd4100 even though if it's passed as "/wd4100 /W4".
clang-cl probably interprets this as "first, disable Wunused-parameter,
then turn on everything in Wall and Wextra".

I suppose we could process W1-4 before all other warning flags to be
compatible with cl.exe in this regard. However, it's less clear what to do
about /Wall -- if we process /Wall before all the other flags, then -Wall
(another spelling of /Wall) will behave differently in clang and clang-cl.
Maybe that's ok?

On Tue, Dec 15, 2015 at 12:11 PM, Nico Weber  wrote:

> Feedback on PR25563 pretty strongly suggests that users do want most of
> this. It looks like llvm passes /wd4100 to suppress the corresponding cl
> warning. r255655 maps that to -Wno-unused-parameter – does this fix the
> problem of these bots?
>
> On Mon, Dec 14, 2015 at 10:01 PM, Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> So, this change makes it impossible to download the build lots from the
>> Windows self-hosting builders because of -Wunused-parameter errors.
>>
>> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/5103/steps/build%20stage%202/logs/stdio
>>
>> Maybe that's an indication that users don't really want /W4 to go to
>> -Wextra?
>>
>> On Fri, Dec 11, 2015 at 2:31 PM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: nico
>>> Date: Fri Dec 11 16:31:16 2015
>>> New Revision: 255382
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=255382&view=rev
>>> Log:
>>> [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.
>>>
>>> There's no way to make a flag alias to two flags, so add a /WCL4 flag
>>> that
>>> maps to the All, Extra diag groups.  Fixes PR25563.
>>>
>>> http://reviews.llvm.org/D15350
>>>
>>> Modified:
>>> cfe/trunk/docs/UsersManual.rst
>>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>>> cfe/trunk/include/clang/Driver/Options.td
>>> cfe/trunk/test/Driver/cl-options.c
>>>
>>> Modified: cfe/trunk/docs/UsersManual.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=255382&r1=255381&r2=255382&view=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/UsersManual.rst (original)
>>> +++ cfe/trunk/docs/UsersManual.rst Fri Dec 11 16:31:16 2015
>>> @@ -2080,7 +2080,7 @@ Execute ``clang-cl /?`` to see a list of
>>>/W1Enable -Wall
>>>/W2Enable -Wall
>>>/W3Enable -Wall
>>> -  /W4Enable -Wall
>>> +  /W4Enable -Wall and -Wextra
>>>/Wall  Enable -Wall
>>>/WX-   Do not treat warnings as errors
>>>/WXTreat warnings as errors
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=255382&r1=255381&r2=255382&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Dec 11
>>> 16:31:16 2015
>>> @@ -663,7 +663,10 @@ def Consumed   : DiagGroup<"consumed
>>>  // Note that putting warnings in -Wall will not disable them by
>>> default. If a
>>>  // warning should be active _only_ when -Wall is passed in, mark it as
>>>  // DefaultIgnore in addition to putting it here.
>>> -def : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
>>> +def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
>>> +
>>> +// Warnings that should be in clang-cl /w4.
>>> +def : DiagGroup<"CL4", [All, Extra]>;
>>>
>>>  // Warnings enabled by -pedantic.  This is magically filled in by
>>> TableGen.
>>>  def Pedantic : DiagGroup<"pedantic">;
>>>
>>> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=255382&r1=255381&r2=255382&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
>>> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Dec 11
>>> 16:31:16 2015
>>> @@ -119,7 +119,7 @@ def _SLASH_W0 : CLFlag<"W0">, HelpText<"
>>>  def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias;
>>>  def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias;
>>>  def _SLASH_W3 : CLFlag<"W3">, HelpText<"Enable -Wall">, Alias;
>>> -def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall">, Alias;
>>> +def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall and -Wextra">,
>>> Alias;
>>>  def _SLASH_Wall : CLFlag<"Wall">, HelpText<"

Buildbot numbers for week of 12/06/2015 - 12/12/2015

2015-12-15 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 12/06/2015 -
12/12/2015.

Thanks

Galina



Top 10 fastest builders(not docs):

lldb-amd64-ninja-freebsd11
clang-bpf-build
llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
libomp-gcc-x86_64-linux-debian
sanitizer-windows
llvm-hexagon-elf
libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11
libcxx-libcxxabi-singlethreaded-x86_64-linux-debian
libcxx-libcxxabi-x86_64-linux-debian-noexceptions
libcxx-libcxxabi-x86_64-linux-debian


10 most slow builders:

clang-native-arm-lnt-perf
clang-atom-d525-fedora
clang-native-aarch64-full
clang-cmake-thumbv7-a15-full-sh
clang-cmake-armv7-a15-selfhost-neon
perf-x86_64-penryn-O3
clang-cmake-mipsel
perf-x86_64-penryn-O3-polly
llvm-mips-linux
clang-cmake-armv7-a15-selfhost



Number of commits by project:

 project   |   commits
---+---
 llvm  |   258
 lldb  |90
 cfe   |89
 compiler-rt   |45
 lld   |21
 libcxx| 6
 polly | 3
 openmp| 3
 clang-tools-extra | 3
 libcxxabi | 1
 libunwind | 1
---
   520


Number of completed builds, failed builds and average build time for
successful builds per active builder:

 buildername   | completed  |
failed | time
---+++
 clang-aarch64-lnt | 51
|  4 | 02:31:19
 clang-atom-d525-fedora| 15
|| 08:58:01
 clang-atom-d525-fedora-rel| 49
|  2 | 02:21:40
 clang-bpf-build   |272
| 12 | 00:03:10
 clang-cmake-aarch64-42vma |213
| 24 | 00:19:38
 clang-cmake-aarch64-full  | 37
| 13 | 03:28:30
 clang-cmake-aarch64-quick |168
|  9 | 00:27:25
 clang-cmake-armv7-a15 |150
| 10 | 00:31:57
 clang-cmake-armv7-a15-full|118
|  1 | 00:50:50
 clang-cmake-armv7-a15-selfhost| 28
|  2 | 04:37:24
 clang-cmake-armv7-a15-selfhost-neon   | 21
|  2 | 06:17:58
 clang-cmake-mips  | 82
| 12 | 01:32:08
 clang-cmake-mipsel| 12
|  1 | 06:00:38
 clang-cmake-thumbv7-a15   |161
|  8 | 00:31:53
 clang-cmake-thumbv7-a15-full-sh   | 11
|| 06:39:48
 clang-hexagon-elf |206
| 72 | 00:17:15
 clang-native-aarch64-full | 18
|  6 | 07:34:46
 clang-native-arm-lnt  | 44
|| 01:15:44
 clang-native-arm-lnt-perf |  7
|| 10:33:02
 clang-ppc64-elf-linux |100
|  7 | 01:04:00
 clang-ppc64-elf-linux2| 72
|  3 | 01:33:52
 clang-sphinx-docs | 97
|  1 | 00:00:22
 clang-x64-ninja-win7  |150
| 36 | 00:35:55
 clang-x86-win2008-selfhost|102
| 17 | 01:03:28
 clang-x86_64-darwin13-cross-arm   |200
|| 00:20:02
 clang-x86_64-darwin13-cross-mingw32   |186
|  1 | 00:23:37
 clang-x86_64-debian-fast  |119
|  7 | 00:12:34
 clang-x86_64-linux-abi-test   |276
|  2 | 00:16:22
 clang-x86_64-linux-selfhost-modules   |230
| 50 | 00:15:16
 clang-x86_64-ubuntu-gdb-75|102
|  7 | 00:58:02
 libcxx-libcxxabi-arm-linux|  5
|| 01:07:24
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian   |  5
|| 00:08:22
 libcxx-libcxxabi-x86_64-linux-debian  |  5
|| 00:08:45
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions |  4
|| 00:08:28
 libcxx-libcxxabi-x86_64-linux-ubunt

Re: r255382 - [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.

2015-12-15 Thread Nico Weber via cfe-commits
(...but it looks like these are all just warnings. The reason the builder
is red is

In file included from
C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\unittests\Support\ThreadPool.cpp:10:
C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\include\llvm/Support/ThreadPool.h(73,50)
:  error: no matching function for call to object of type 'const
std::_Bind, unsigned int &>'
return asyncImpl([Task] (VoidTy) -> VoidTy { Task(); return VoidTy();
});
 ^~~~

which is Mehdi's ThreadPool breakage from yesterday night. I guess his
workaround broke building clang with clang-cl?)

On Tue, Dec 15, 2015 at 2:56 PM, Nico Weber  wrote:

> Looks like the warning is still emitted frequently. It looks like cl.exe
> processes /W4 before /wd4100 even though if it's passed as "/wd4100 /W4".
> clang-cl probably interprets this as "first, disable Wunused-parameter,
> then turn on everything in Wall and Wextra".
>
> I suppose we could process W1-4 before all other warning flags to be
> compatible with cl.exe in this regard. However, it's less clear what to do
> about /Wall -- if we process /Wall before all the other flags, then -Wall
> (another spelling of /Wall) will behave differently in clang and clang-cl.
> Maybe that's ok?
>
> On Tue, Dec 15, 2015 at 12:11 PM, Nico Weber  wrote:
>
>> Feedback on PR25563 pretty strongly suggests that users do want most of
>> this. It looks like llvm passes /wd4100 to suppress the corresponding cl
>> warning. r255655 maps that to -Wno-unused-parameter – does this fix the
>> problem of these bots?
>>
>> On Mon, Dec 14, 2015 at 10:01 PM, Reid Kleckner via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> So, this change makes it impossible to download the build lots from the
>>> Windows self-hosting builders because of -Wunused-parameter errors.
>>>
>>> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/5103/steps/build%20stage%202/logs/stdio
>>>
>>> Maybe that's an indication that users don't really want /W4 to go to
>>> -Wextra?
>>>
>>> On Fri, Dec 11, 2015 at 2:31 PM, Nico Weber via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: nico
 Date: Fri Dec 11 16:31:16 2015
 New Revision: 255382

 URL: http://llvm.org/viewvc/llvm-project?rev=255382&view=rev
 Log:
 [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.

 There's no way to make a flag alias to two flags, so add a /WCL4 flag
 that
 maps to the All, Extra diag groups.  Fixes PR25563.

 http://reviews.llvm.org/D15350

 Modified:
 cfe/trunk/docs/UsersManual.rst
 cfe/trunk/include/clang/Basic/DiagnosticGroups.td
 cfe/trunk/include/clang/Driver/CLCompatOptions.td
 cfe/trunk/include/clang/Driver/Options.td
 cfe/trunk/test/Driver/cl-options.c

 Modified: cfe/trunk/docs/UsersManual.rst
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=255382&r1=255381&r2=255382&view=diff

 ==
 --- cfe/trunk/docs/UsersManual.rst (original)
 +++ cfe/trunk/docs/UsersManual.rst Fri Dec 11 16:31:16 2015
 @@ -2080,7 +2080,7 @@ Execute ``clang-cl /?`` to see a list of
/W1Enable -Wall
/W2Enable -Wall
/W3Enable -Wall
 -  /W4Enable -Wall
 +  /W4Enable -Wall and -Wextra
/Wall  Enable -Wall
/WX-   Do not treat warnings as errors
/WXTreat warnings as errors

 Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=255382&r1=255381&r2=255382&view=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Dec 11
 16:31:16 2015
 @@ -663,7 +663,10 @@ def Consumed   : DiagGroup<"consumed
  // Note that putting warnings in -Wall will not disable them by
 default. If a
  // warning should be active _only_ when -Wall is passed in, mark it as
  // DefaultIgnore in addition to putting it here.
 -def : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
 +def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
 +
 +// Warnings that should be in clang-cl /w4.
 +def : DiagGroup<"CL4", [All, Extra]>;

  // Warnings enabled by -pedantic.  This is magically filled in by
 TableGen.
  def Pedantic : DiagGroup<"pedantic">;

 Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
 URL:
 http://llvm.org/viewvc/llvm-project

cfe-commits@lists.llvm.org

2015-12-15 Thread Agustín Bergé via cfe-commits
K-ballo updated this revision to Diff 42892.
K-ballo marked 15 inline comments as done.
K-ballo added a comment.

Addressed review comments. Use `UNSUPPORTED` in `pairs.by.type.pass`.


http://reviews.llvm.org/D14839

Files:
  include/__tuple
  include/array
  include/tuple
  include/utility
  test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
  test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
  test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp

Index: test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
===
--- test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
+++ test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
@@ -7,23 +7,25 @@
 //
 //===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11
+
 #include 
 #include 
+#include 
 #include 
 
 #include 
 
 int main()
 {
-#if _LIBCPP_STD_VER > 11
 typedef std::complex cf;
 {
 auto t1 = std::make_pair ( 42, { 1,2 } );
 assert ( std::get(t1) == 42 );
 assert ( std::get(t1).real() == 1 );
 assert ( std::get(t1).imag() == 2 );
 }
-
+
 {
 const std::pair p1 { 1, 2 };
 const int &i1 = std::get(p1);
@@ -35,10 +37,48 @@
 {
 typedef std::unique_ptr upint;
 std::pair t(upint(new int(4)), 42);
-upint p = std::get<0>(std::move(t)); // get rvalue
+upint p = std::get(std::move(t)); // get rvalue
+assert(*p == 4);
+assert(std::get(t) == nullptr); // has been moved from
+}
+
+{
+typedef std::unique_ptr upint;
+const std::pair t(upint(new int(4)), 42);
+static_assert(std::is_same(std::move(t)))>::value, "");
+static_assert(noexcept(std::get(std::move(t))), "");
+static_assert(std::is_same(std::move(t)))>::value, "");
+static_assert(noexcept(std::get(std::move(t))), "");
+auto&& p = std::get(std::move(t)); // get const rvalue
+auto&& i = std::get(std::move(t)); // get const rvalue
 assert(*p == 4);
-assert(std::get<0>(t) == nullptr); // has been moved from
+assert(i == 42);
+assert(std::get(t) != nullptr);
 }
 
-#endif
+{
+int x = 42;
+int const y = 43;
+std::pair const p(x, y);
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(noexcept(std::get(std::move(p))), "");
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(noexcept(std::get(std::move(p))), "");
+}
+
+{
+int x = 42;
+int const y = 43;
+std::pair const p(std::move(x), std::move(y));
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(noexcept(std::get(std::move(p))), "");
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(noexcept(std::get(std::move(p))), "");
+}
+
+{
+constexpr const std::pair p { 1, 2 };
+static_assert(std::get(std::move(p)) == 1, "");
+static_assert(std::get(std::move(p)) == 2, "");
+}
 }
Index: test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
===
--- /dev/null
+++ test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
@@ -0,0 +1,66 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  struct pair
+
+// template
+// const typename tuple_element >::type&&
+// get(const pair&&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main()
+{
+{
+typedef std::pair, short> P;
+const P p(std::unique_ptr(new int(3)), 4);
+static_assert(std::is_same&&, decltype(std::get<0>(std::move(p)))>::value, "");
+static_assert(noexcept(std::get<0>(std::move(p))), "");
+const std::unique_ptr&& ptr = std::get<0>(std::move(p));
+assert(*ptr == 3);
+}
+
+{
+int x = 42;
+int const y = 43;
+std::pair const p(x, y);
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(noexcept(std::get<0>(std::move(p))), "");
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(noexcept(std::get<1>(std::move(p))), "");
+}
+
+{
+int x = 42;
+int const y = 43;
+std::pair const p(std::move(x), std::move(y));
+static_assert(std::is_same(std::move(p)))>::value, "");
+static_assert(

Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.

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

I prefer using the profile from the original test case where Max count is not 1.


Repository:
  rL LLVM

http://reviews.llvm.org/D15163



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


Re: [PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

2015-12-15 Thread Zachary Turner via cfe-commits
zturner updated this revision to Diff 42895.
zturner added a comment.

Attempt to address remaining issues in patch.

This is my first time touching anything having to do with clang, so there's a 
good chance I don't know what i'm doing and this needs more work.  Let me know.

`AlwaysBreakAfterDefinitionReturnType` is used only as a way to initialize 
`AlwaysBreakAfterReturnType`, and is ignored during any actual logic.


http://reviews.llvm.org/D10370

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4732,28 +4732,82 @@
"  \"c\";");
 }
 
-TEST_F(FormatTest, DefinitionReturnTypeBreakingStyle) {
+TEST_F(FormatTest, ReturnTypeBreakingStyle) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_TopLevel;
-  verifyFormat("class C {\n"
+  // No declarations or definitions should be moved to own line.
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
+  verifyFormat("class A {\n"
"  int f() { return 1; }\n"
+   "  int g();\n"
+   "};\n"
+   "int f() { return 1; }\n"
+   "int g();\n",
+   Style);
+
+  // All declarations and definitions should have the return type moved to its
+  // own
+  // line.
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+  verifyFormat("class E {\n"
+   "  int\n"
+   "  f() {\n"
+   "return 1;\n"
+   "  }\n"
+   "  int\n"
+   "  g();\n"
"};\n"
"int\n"
"f() {\n"
"  return 1;\n"
-   "}",
+   "}\n"
+   "int\n"
+   "g();\n",
Style);
-  Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+
+  // Top-level definitions, and no kinds of declarations should have the
+  // return type moved to its own line.
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_TopLevelDefinitions;
+  verifyFormat("class B {\n"
+   "  int f() { return 1; }\n"
+   "  int g();\n"
+   "};\n"
+   "int\n"
+   "f() {\n"
+   "  return 1;\n"
+   "}\n"
+   "int g();\n",
+   Style);
+
+  // Top-level definitions and declarations should have the return type moved
+  // to its own line.
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_TopLevel;
   verifyFormat("class C {\n"
+   "  int f() { return 1; }\n"
+   "  int g();\n"
+   "};\n"
+   "int\n"
+   "f() {\n"
+   "  return 1;\n"
+   "}\n"
+   "int\n"
+   "g();\n",
+   Style);
+
+  // All definitions should have the return type moved to its own line, but no
+  // kinds of declarations.
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
+  verifyFormat("class D {\n"
"  int\n"
"  f() {\n"
"return 1;\n"
"  }\n"
+   "  int g();\n"
"};\n"
"int\n"
"f() {\n"
"  return 1;\n"
-   "}",
+   "}\n"
+   "int g();\n",
Style);
   verifyFormat("const char *\n"
"f(void) {\n" // Break here.
@@ -5688,7 +5742,7 @@
   verifyFormat("a __attribute__((unused))\n"
"aaa(int i);");
   FormatStyle AfterType = getLLVMStyle();
-  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+  AfterType.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
   verifyFormat("__attribute__((nodebug)) void\n"
"foo() {}\n",
AfterType);
@@ -9829,6 +9883,19 @@
   CHECK_PARSE("BreakBeforeBraces: Custom", BreakBeforeBraces,
   FormatStyle::BS_Custom);
 
+  Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+  CHECK_PARSE("AlwaysBreakAfterReturnType: None", AlwaysBreakAfterReturnType,
+  FormatStyle::RTBS_None);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: All", AlwaysBreakAfterReturnType,
+  FormatStyle::RTBS_All);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevel",
+  AlwaysBreakAfterReturnType, FormatStyle::DRTBS_TopLevel);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: AllDefinitions",
+  AlwaysBreakAfterReturnType, FormatStyle::RTBS_AllDefinitions);
+  CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevelDefinitions",
+  AlwaysBreakAfterRe

Re: [PATCH] D15463: [Objective-c] Fix a crash

2015-12-15 Thread Justin Bogner via cfe-commits
Akira Hatanaka  writes:
> On Mon, Dec 14, 2015 at 10:39 AM, Justin Bogner 
> wrote:
>
>> Akira Hatanaka via cfe-commits  writes:
>> > ahatanak created this revision.
>> > ahatanak added a subscriber: cfe-commits.
>> >
>> > This patch fixes a crash that occurs when __kindof is incorrectly used
>> > in the type parameter list of an interface. The crash occurs because
>> > ObjCTypeParamList::back() is called in checkTypeParamListConsistency
>> > on an empty list:
>> >
>> > 00762   diagLoc =
>> S.getLocForEndOfToken(newTypeParams->back()->getLocEnd());
>> >
>> > http://reviews.llvm.org/D15463
>> >
>> > Files:
>> >   lib/Parse/ParseObjc.cpp
>> >   test/SemaObjC/kindof.m
>> >
>> > Index: test/SemaObjC/kindof.m
>> > ===
>> > --- test/SemaObjC/kindof.m
>> > +++ test/SemaObjC/kindof.m
>> > @@ -302,3 +302,13 @@
>> >void processCopyable(__typeof(getSomeCopyable()) string);
>> >processCopyable(0); // expected-warning{{null passed to a callee that
>> requires a non-null argument}}
>> >  }
>> > +
>> > +// __kinddof cannot be used in parameter list.
>> > +@interface Array1 : NSObject
>> > +@end
>> > +
>> > +@interface I1 : NSObject
>> > +@end
>> > +
>> > +@interface Array1<__kindof I1*>(extensions) // //
>> expected-error{{expected type parameter name}}
>> > +@end
>> > Index: lib/Parse/ParseObjc.cpp
>> > ===
>> > --- lib/Parse/ParseObjc.cpp
>> > +++ lib/Parse/ParseObjc.cpp
>> > @@ -603,7 +603,7 @@
>> >// whether there are any protocol references.
>> >lAngleLoc = SourceLocation();
>> >rAngleLoc = SourceLocation();
>> > -  return list;
>> > +  return invalid ? nullptr : list;
>>
>> This looks a bit suspicious to me. Since `invalid` is set *way* earlier
>> in the function, it seems like we should be able to return earlier if
>> this is correct, and not even call actOnObjCTypeParamList. OTOH, are
>> there cases where `invalid == true` but list is non-empty? If so, are we
>> doing the right thing when that happens?
>>
>>
> I'm assuming you meant it should return earlier if this is *incorrect* (but
> let me know if I misunderstood your comment).

I meant, "If `return invalid ? nullptr : list` is correct, then I
suspect returning nullptr before calling actOnObjCTypeParamList makes
more sense.

> The only downside to returning nullptr before actOnObjCTypeParamList is
> called in line 595 is that it won't print the diagnostics that are printed
> in actOnObjCTypeParamList. For example, if the following interface were
> compiled,
>
> @interface I1 NSObject
> @end
>
> actOnObjCTypeParamList could tell the user that parameter "T" was
> redeclared in addition to printing the error message about __kindof. So if
> we return before it's called, we won't see that error message.
>
> When the interface declaration of category extensions1 in the following
> piece of code is compiled, invalid is set to true and the list is not empty
> (it contains the first two parameters).
>
> @interface I1 NSObject
> @end
>
> @interface I1 (extensions1)
> @end
>
> *test3.m:6:23: **error: **expected type parameter name*
>
> @interface I6 (extensions1)
>
> *  ^*
>
> *test3.m:6:21: **error: **category has too few type parameters (expected 3,
> have 2)*
>
> @interface I6 (extensions1)
> It looks like it's doing the right thing, but the second diagnostic doesn't
> seem necessary to me.

I'm not sure I follow exactly which errors are being reported with your
patch, so maybe this is already working, but what we basically want is
to only emit errors that are helpful.

That is, if we get the `"T" is a redeclaration` error as well as the
__kindof error, that's nice, but if we get the `too few type parameters`
error that's going to be confusing and bad - the user didn't provide too
few type parameters, but our previous error caused us to see too few.

Basically, we don't ever want to report errors that are the result of
previous errors, but as long as we don't end up doing that then
gathering further errors is totally reasonable. Make sense?

>
>>  }
>> >
>> >  /// Parse an objc-type-parameter-list.
>> >
>> >
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15462: [CMake] Add support for generating profdata for clang from training files

2015-12-15 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 42891.
beanz added a comment.

Cleaning up the python helper as per Sean's suggestions.


http://reviews.llvm.org/D15462

Files:
  CMakeLists.txt
  utils/perf-training/CMakeLists.txt
  utils/perf-training/README.txt
  utils/perf-training/cxx/hello_world.cpp
  utils/perf-training/lit.cfg
  utils/perf-training/lit.site.cfg.in
  utils/perf-training/perf-helper.py

Index: utils/perf-training/perf-helper.py
===
--- /dev/null
+++ utils/perf-training/perf-helper.py
@@ -0,0 +1,46 @@
+#===- perf-helper.py - Clang Python Bindings -*- python -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#======#
+
+import sys
+import os
+import subprocess
+
+def findProfrawFiles(path):
+  profraw_files = []
+  for root, dirs, files in os.walk(path): 
+for filename in files:
+  if filename.endswith(".profraw"):
+profraw_files.append(os.path.join(root, filename))
+  return profraw_files
+
+def clean(args):
+  if len(args) != 1:
+print 'Usage: %s clean \n\tRemoves all *.profraw files from .' % __file__
+return 1
+  for profraw in findProfrawFiles(args[0]):
+os.remove(profraw)
+  return 0
+
+def merge(args):
+  if len(args) != 3:
+print 'Usage: %s clean   \n\tMerges all profraw files from path into output.' % __file__
+return 1
+  cmd = [args[0], 'merge', '-o', args[1]]
+  cmd.extend(findProfrawFiles(args[2]))
+  subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+  return 0
+
+commands = {'clean' : clean, 'merge' : merge}
+
+def main():
+  f = commands[sys.argv[1]]
+  sys.exit(f(sys.argv[2:]))
+
+if __name__ == '__main__':
+  main()
Index: utils/perf-training/lit.site.cfg.in
===
--- /dev/null
+++ utils/perf-training/lit.site.cfg.in
@@ -0,0 +1,20 @@
+import sys
+
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
+config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+
+# Support substitution of the tools and libs dirs with user parameters. This is
+# used when we can't determine the tool dir at configuration time.
+try:
+config.clang_tools_dir = config.clang_tools_dir % lit_config.params
+except KeyError:
+e = sys.exc_info()[1]
+key, = e.args
+lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/lit.cfg")
Index: utils/perf-training/lit.cfg
===
--- /dev/null
+++ utils/perf-training/lit.cfg
@@ -0,0 +1,35 @@
+# -*- Python -*-
+
+from lit import Test
+import lit.formats
+import lit.util
+
+def getSysrootFlagsOnDarwin(config, lit_config):
+# On Darwin, support relocatable SDKs by providing Clang with a
+# default system root path.
+if 'darwin' in config.target_triple:
+try:
+out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
+res = 0
+except OSError:
+res = -1
+if res == 0 and out:
+sdk_path = out
+lit_config.note('using SDKROOT: %r' % sdk_path)
+return '-isysroot %s' % sdk_path
+return ''
+
+sysroot_flags = getSysrootFlagsOnDarwin(config, lit_config)
+
+config.clang = lit.util.which('clang', config.clang_tools_dir).replace('\\', '/')
+
+config.name = 'Clang Perf Training'
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap']
+
+use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
+config.test_format = lit.formats.ShTest(use_lit_shell == "0")
+config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % (config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) )
+
+config.environment['LLVM_PROFILE_FILE'] = 'perf-training-%p.profraw'
+
Index: utils/perf-training/cxx/hello_world.cpp
===
--- /dev/null
+++ utils/perf-training/cxx/hello_world.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cpp -c %s
+#include 
+
+int main(int, char**) {
+  std::cout << "Hello, World!";
+  return 0;
+}
Index: utils/perf-training/README.txt
===
--- /dev/null
+++ utils/perf-training/README.txt
@@ -0,0 +1,6 @@
+==
+ Performance Training Data
+==
+
+This directory contains simple source files for use as training data for
+generating PGO data and linker or

Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2015-12-15 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: tools/llvm-project/extra/test/clang-tidy/werrors-plural.cpp:7
@@ +6,3 @@
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment 
[llvm-namespace-comment, -Werrors=]
+

aaron.ballman wrote:
> jroelofs wrote:
> > aaron.ballman wrote:
> > > jroelofs wrote:
> > > > aaron.ballman wrote:
> > > > > One of these tests should complete the -Werrors= chunk just to be 
> > > > > sure it's getting printed properly.
> > > > Not sure what you mean here. Should I be printing the -Werrors argument 
> > > > as the user wrote it? (it isn't currently... this is just a hardcoded 
> > > > string).
> > > Ah, I didn't pick up on that. What is the = for, then?
> > I considered that part of the name of the flag.
> > 
> > I can drop that if you think it looks better. Or print out the whole thing 
> > as the user wrote it, if you think that's useful (though -checks= and 
> > -Werrors= lines are probably pretty long...).
> > 
> I would just drop the =; it seems like that suggests there should be more 
> text there. That would also be consistent with the way clang reports -Werror 
> diagnostics (error: unused variable 'i' [-Werror,-Wunused-variable])
ok, sounds good.


http://reviews.llvm.org/D15528



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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2015-12-15 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D15528#311135, @alexfh wrote:

> In http://reviews.llvm.org/D15528#311053, @jroelofs wrote:
>
> > In http://reviews.llvm.org/D15528#311019, @alexfh wrote:
> >
> > > Jonathan, can you explain what specific use case does this patch address? 
> > > Why one severity level of native clang-tidy warnings (the current 
> > > situation) is not enough, and two levels are enough?
> >
> >
> > I have out-of-tree checkers for a very strange out-of-tree target. Some of 
> > the checks are on the level of "this should break the build because it 
> > cannot possibly work on this target" and others on the level of "tell me 
> > about it, but don't force me to fix it". All of these checks are things 
> > that don't even remotely apply to other targets.
>
>
> Thank you for the explanation. One more question: do you need to define 
> Werrors differently in different directories?


Yeah, for things like "if you do this, you will get terribad performance", it's 
useful to be able to let the user's build system control them independently 
with that kind of granularity. In some places it's acceptable to fail these 
checks (i.e. while porting code to this target), and in others it's 
mission-critical.

I could see this being useful in other contexts too. For example, 
hypothetically, one could imagine turning on the llvm-include-order check for 
all of llvm, and then making it -Werror for subdirectories where it has been 
cleaned up, ensuring monotonic progress.

> 

> 

> > If you're wondering why I haven't hacked up Clang's sema to enforce these 
> > constraints, see again: out-of-tree backend... maintaining OOT changes 
> > there is expected to be very difficult.

> 

> 

> No, a sane person wouldn't suggest maintaining a local patch for Clang as a 
> good solution ;)


:)

> 

> 

> > Clang-tidy however provides a very nice framework where they can be kept 
> > neatly off to the side, away from most of the merge hassles.

> 

> 

> It's one of the goals of clang-tidy to provide an easy way to maintain 
> out-of-tree checks.


Seems to be working out very well on my end... thanks for designing it that way!

> 

> 

> > It'd be nice not to have to run clang-tidy twice & parse its output in 
> > order to achieve all of that, hence this patch.

> 

> 

> Agreed, I want to ensure though, that this is the right approach. In 
> particular, I wonder whether a way to assign labels or severities to 
> clang-tidy diagnostics would be better. Another question is whether we can 
> reuse something from the Clang diagnostic subsystem to map warning levels.


For my purposes, this kind of trimodal { "it's definitely broken, and cannot 
possibly work", "hey, have you considered this?", "the tool didn't spot any 
problems" } granularity seems like the right fit, and lines up with Clang's 
diagnostics: notes usually stay notes, remarks stay remarks, warnings are 
sometimes errors and other times just warnings, and errors are errors.

Something else to think about: grouping a la -Wpedantic/-Wall/-Weverything 
might be useful. Some of that can be achieved by giving structure to the names 
of the checks, i.e.:

- footarget-perf-check1
- footarget-perf-check2
- footarget-correctness-check1
- footarget-correctness-check2
- footarget-portability-check1

  (pardon my vagueness here)

But that kind of breaks down when you start to talk about putting existing 
upstream checks into these groups, because then you have to write things like: 
`-checks='-*,footarget-portability-*,google-runtime-int-std' (off the cuff 
example). Not sure if that's what you meant by "labels", but I see that as 
being orthogonal to the question of what a user should be forced to take action 
on.


http://reviews.llvm.org/D15528



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


r255675 - [WinEH] Update clang to use operand bundles on call sites

2015-12-15 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 15 15:27:59 2015
New Revision: 255675

URL: http://llvm.org/viewvc/llvm-project?rev=255675&view=rev
Log:
[WinEH] Update clang to use operand bundles on call sites

This updates clang to use bundle operands to associate an invoke with
the funclet which it is contained within.

Depends on D15517.

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

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=255675&r1=255674&r2=255675&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Dec 15 15:27:59 2015
@@ -3058,19 +3058,41 @@ CodeGenFunction::EmitRuntimeCall(llvm::V
   return call;
 }
 
+// Calls which may throw must have operand bundles indicating which funclet
+// they are nested within.
+static void
+getBundlesForFunclet(llvm::Value *Callee,
+ llvm::Instruction *CurrentFuncletPad,
+ SmallVectorImpl &BundleList) {
+  // There is no need for a funclet operand bundle if we aren't inside a 
funclet.
+  if (!CurrentFuncletPad)
+return;
+
+  // Skip intrinsics which cannot throw.
+  auto *CalleeFn = dyn_cast(Callee->stripPointerCasts());
+  if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
+return;
+
+  BundleList.emplace_back("funclet", CurrentFuncletPad);
+}
+
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {
+  SmallVector BundleList;
+  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+
   if (getInvokeDest()) {
 llvm::InvokeInst *invoke = 
   Builder.CreateInvoke(callee,
getUnreachableBlock(),
getInvokeDest(),
-   args);
+   args,
+   BundleList);
 invoke->setDoesNotReturn();
 invoke->setCallingConv(getRuntimeCC());
   } else {
-llvm::CallInst *call = Builder.CreateCall(callee, args);
+llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList);
 call->setDoesNotReturn();
 call->setCallingConv(getRuntimeCC());
 Builder.CreateUnreachable();
@@ -3489,12 +3511,16 @@ RValue CodeGenFunction::EmitCall(const C
   }
   llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
 
+  SmallVector BundleList;
+  getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList);
+
   llvm::CallSite CS;
   if (!InvokeDest) {
-CS = Builder.CreateCall(Callee, IRCallArgs);
+CS = Builder.CreateCall(Callee, IRCallArgs, BundleList);
   } else {
 llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
-CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs);
+CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs,
+  BundleList);
 EmitBlock(Cont);
   }
   if (callOrInvoke)

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=255675&r1=255674&r2=255675&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Dec 15 15:27:59 2015
@@ -2495,6 +2495,7 @@ static void replaceUsesOfNonProtoConstan
 
   llvm::Type *newRetTy = newFn->getReturnType();
   SmallVector newArgs;
+  SmallVector newBundles;
 
   for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
  ui != ue; ) {
@@ -2562,16 +2563,19 @@ static void replaceUsesOfNonProtoConstan
 // over the required information.
 newArgs.append(callSite.arg_begin(), callSite.arg_begin() + argNo);
 
+// Copy over any operand bundles.
+callSite.getOperandBundlesAsDefs(newBundles);
+
 llvm::CallSite newCall;
 if (callSite.isCall()) {
-  newCall = llvm::CallInst::Create(newFn, newArgs, "",
+  newCall = llvm::CallInst::Create(newFn, newArgs, newBundles, "",
callSite.getInstruction());
 } else {
   auto *oldInvoke = cast(callSite.getInstruction());
   newCall = llvm::InvokeInst::Create(newFn,
  oldInvoke->getNormalDest(),
  oldInvoke->getUnwindDest(),
- newArgs, "",
+ newArgs, newBundles, "",
  callSite.getInstruction());
 }
 newArgs.clear(); // for the next iteration
@@ -2589,6 +2593,7 @@ static void replaceUsesOfNonProtoConstan
 // Copy debug location attached to CI.
 if 

Re: [PATCH] D15518: [WinEH] Update clang to use operand bundles on call sites

2015-12-15 Thread David Majnemer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255675: [WinEH] Update clang to use operand bundles on call 
sites (authored by majnemer).

Changed prior to commit:
  http://reviews.llvm.org/D15518?vs=42886&id=42901#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15518

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -3058,19 +3058,41 @@
   return call;
 }
 
+// Calls which may throw must have operand bundles indicating which funclet
+// they are nested within.
+static void
+getBundlesForFunclet(llvm::Value *Callee,
+ llvm::Instruction *CurrentFuncletPad,
+ SmallVectorImpl &BundleList) {
+  // There is no need for a funclet operand bundle if we aren't inside a funclet.
+  if (!CurrentFuncletPad)
+return;
+
+  // Skip intrinsics which cannot throw.
+  auto *CalleeFn = dyn_cast(Callee->stripPointerCasts());
+  if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
+return;
+
+  BundleList.emplace_back("funclet", CurrentFuncletPad);
+}
+
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {
+  SmallVector BundleList;
+  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+
   if (getInvokeDest()) {
 llvm::InvokeInst *invoke = 
   Builder.CreateInvoke(callee,
getUnreachableBlock(),
getInvokeDest(),
-   args);
+   args,
+   BundleList);
 invoke->setDoesNotReturn();
 invoke->setCallingConv(getRuntimeCC());
   } else {
-llvm::CallInst *call = Builder.CreateCall(callee, args);
+llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList);
 call->setDoesNotReturn();
 call->setCallingConv(getRuntimeCC());
 Builder.CreateUnreachable();
@@ -3489,12 +3511,16 @@
   }
   llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
 
+  SmallVector BundleList;
+  getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList);
+
   llvm::CallSite CS;
   if (!InvokeDest) {
-CS = Builder.CreateCall(Callee, IRCallArgs);
+CS = Builder.CreateCall(Callee, IRCallArgs, BundleList);
   } else {
 llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
-CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs);
+CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, IRCallArgs,
+  BundleList);
 EmitBlock(Cont);
   }
   if (callOrInvoke)
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2495,6 +2495,7 @@
 
   llvm::Type *newRetTy = newFn->getReturnType();
   SmallVector newArgs;
+  SmallVector newBundles;
 
   for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
  ui != ue; ) {
@@ -2562,16 +2563,19 @@
 // over the required information.
 newArgs.append(callSite.arg_begin(), callSite.arg_begin() + argNo);
 
+// Copy over any operand bundles.
+callSite.getOperandBundlesAsDefs(newBundles);
+
 llvm::CallSite newCall;
 if (callSite.isCall()) {
-  newCall = llvm::CallInst::Create(newFn, newArgs, "",
+  newCall = llvm::CallInst::Create(newFn, newArgs, newBundles, "",
callSite.getInstruction());
 } else {
   auto *oldInvoke = cast(callSite.getInstruction());
   newCall = llvm::InvokeInst::Create(newFn,
  oldInvoke->getNormalDest(),
  oldInvoke->getUnwindDest(),
- newArgs, "",
+ newArgs, newBundles, "",
  callSite.getInstruction());
 }
 newArgs.clear(); // for the next iteration
@@ -2589,6 +2593,7 @@
 // Copy debug location attached to CI.
 if (callSite->getDebugLoc())
   newCall->setDebugLoc(callSite->getDebugLoc());
+
 callSite->eraseFromParent();
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D8652: [libcxx] Create internal namespace that hides all symbols.

2015-12-15 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

There hasn't been much interest in this approach and it won't work with the new 
linkage attributes.


http://reviews.llvm.org/D8652



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


Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 42902.
eugenis added a comment.

added the new flag to UserManual


Repository:
  rL LLVM

http://reviews.llvm.org/D15367

Files:
  docs/ControlFlowIntegrity.rst
  docs/ControlFlowIntegrityDesign.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -291,6 +291,46 @@
 // CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
 
+// CFI by itself does not link runtime libraries.
+// RUN: %clang -fsanitize=cfi %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-LINUX %s
+// CHECK-CFI-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-LINUX-NOT: libclang_rt.
+
+// CFI with diagnostics links the UBSan runtime.
+// RUN: %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
+// RUN: %s -### -o %t.o 2>&1\
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-DIAG-LINUX %s
+// CHECK-CFI-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+// CHECK-CFI-DIAG-LINUX: libclang_rt.ubsan
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+
+// Cross-DSO CFI links the CFI runtime.
+// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
+// CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+
+// Cross-DSO CFI with diagnostics links just the CFI runtime.
+// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
+// RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
+
 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -mmacosx-version-min=10.6 \
 // RUN: -target x86_64-apple-darwin13.4.0 \
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -263,6 +263,15 @@
 // CHECK-CFI-NOTRAP-WIN: -emit-llvm-bc
 // CHECK-CFI-NOTRAP-WIN-NOT: -fsanitize-trap=cfi
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NO-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-cfi-cross-dso -fno-sanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NO-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fno-sanitize-cfi-cross-dso -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO
+// CHECK-CFI-CROSS-DSO: -emit-llvm-bc
+// CHECK-CFI-CROSS-DSO: -fsanitize-cfi-cross-dso
+// CHECK-CFI-NO-CROSS-DSO: -emit-llvm-bc
+// CHECK-CFI-NO-CROSS-DSO-NOT: -fsanitize-cfi-cross-dso
+
 // RUN: %clang_cl -fsanitize=address -c -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
Index: test/CodeGenCXX/cfi-cross-dso.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cfi-cross-dso.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
+// RUN: %clang_cc1 -triple x86_64-pc-windo

[PATCH] D15539: [libcxxabi] Reducing stack usage of test

2015-12-15 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added a reviewer: mclow.lists.
bcraig added a subscriber: cfe-commits.

This test has a lot of classes with large amounts of manually inserted padding 
in them, presumable to prevent various optimizations.  The test then creates 
lots of these objects on the stack.  On embedded targets, this was usually 
enough to overflow the stack.

I reduced the padding significantly.  I made the padding values prime to try 
and keep the evil optimizations at bay.

http://reviews.llvm.org/D15539

Files:
  test/dynamic_cast14.pass.cpp

Index: test/dynamic_cast14.pass.cpp
===
--- test/dynamic_cast14.pass.cpp
+++ test/dynamic_cast14.pass.cpp
@@ -15,7 +15,7 @@
 
 struct A1
 {
-char _[43981];
+char _[2];
 virtual ~A1() {}
 
 A1* getA1() {return this;}
@@ -23,7 +23,7 @@
 
 struct A2
 {
-char _[34981];
+char _[3];
 virtual ~A2() {}
 
 A2* getA2() {return this;}
@@ -33,7 +33,7 @@
 : public A1,
   public virtual A2
 {
-char _[93481];
+char _[5];
 virtual ~A3() {}
 
 A1* getA1_3() {return A1::getA1();}
@@ -45,7 +45,7 @@
 : public virtual A2,
   public A1
 {
-char _[13489];
+char _[7];
 virtual ~A4() {}
 
 A1* getA1_4() {return A1::getA1();}
@@ -57,7 +57,7 @@
 : public A3,
   public A4
 {
-char _[13489];
+char _[11];
 virtual ~A5() {}
 
 A1* getA1_3() {return A3::getA1();}
@@ -71,7 +71,7 @@
 struct A6
 : public A1
 {
-char _[81349];
+char _[13];
 virtual ~A6() {}
 
 A1* getA1_6() {return A1::getA1();}
@@ -82,7 +82,7 @@
 : public A5,
   public A6
 {
-char _[34819];
+char _[17];
 virtual ~A7() {}
 
 A1* getA1_3() {return A5::getA1_3();}
@@ -99,7 +99,7 @@
 struct A8
 : public A7
 {
-char _[3489];
+char _[19];
 virtual ~A8() {}
 
 A1* getA1_3() {return A7::getA1_3();}
@@ -117,7 +117,7 @@
 struct A9
 : public A1
 {
-char _[3481];
+char _[23];
 virtual ~A9() {}
 
 A1* getA1_9() {return A1::getA1();}
@@ -127,7 +127,7 @@
 struct A10
 : public virtual A8
 {
-char _[4831];
+char _[29];
 virtual ~A10() {}
 
 A1* getA1_3() {return A8::getA1_3();}
@@ -147,7 +147,7 @@
 : public virtual A8,
   public A9
 {
-char _[6483];
+char _[31];
 virtual ~A11() {}
 
 A1* getA1_3() {return A8::getA1_3();}
@@ -169,7 +169,7 @@
 : public A10,
   public A11
 {
-char _[2283];
+char _[37];
 virtual ~A12() {}
 
 A1* getA1_3() {return A10::getA1_3();}
@@ -192,7 +192,7 @@
 struct A13
 : public A12
 {
-char _[1283];
+char _[41];
 virtual ~A13() {}
 
 A1* getA1_3() {return A12::getA1_3();}
@@ -736,7 +736,7 @@
 
 struct A1
 {
-char _[43981];
+char _[2];
 virtual ~A1() {}
 
 A1* getA1() {return this;}
@@ -744,7 +744,7 @@
 
 struct A2
 {
-char _[34981];
+char _[3];
 virtual ~A2() {}
 
 A2* getA2() {return this;}
@@ -754,7 +754,7 @@
 : protected A1,
   public virtual A2
 {
-char _[93481];
+char _[5];
 virtual ~A3() {}
 
 A1* getA1_3() {return A1::getA1();}
@@ -766,7 +766,7 @@
 : public virtual A2,
   public A1
 {
-char _[13489];
+char _[7];
 virtual ~A4() {}
 
 A1* getA1_4() {return A1::getA1();}
@@ -778,7 +778,7 @@
 : public A3,
   public A4
 {
-char _[13489];
+char _[11];
 virtual ~A5() {}
 
 A1* getA1_3() {return A3::getA1();}
@@ -792,7 +792,7 @@
 struct A6
 : public A1
 {
-char _[81349];
+char _[13];
 virtual ~A6() {}
 
 A1* getA1_6() {return A1::getA1();}
@@ -803,7 +803,7 @@
 : public A5,
   public A6
 {
-char _[34819];
+char _[17];
 virtual ~A7() {}
 
 A1* getA1_3() {return A5::getA1_3();}
@@ -820,7 +820,7 @@
 struct A8
 : public A7
 {
-char _[3489];
+char _[19];
 virtual ~A8() {}
 
 A1* getA1_3() {return A7::getA1_3();}
@@ -838,7 +838,7 @@
 struct A9
 : public A1
 {
-char _[3481];
+char _[23];
 virtual ~A9() {}
 
 A1* getA1_9() {return A1::getA1();}
@@ -848,7 +848,7 @@
 struct A10
 : public virtual A8
 {
-char _[4831];
+char _[29];
 virtual ~A10() {}
 
 A1* getA1_3() {return A8::getA1_3();}
@@ -868,7 +868,7 @@
 : public virtual A8,
   public A9
 {
-char _[6483];
+char _[31];
 virtual ~A11() {}
 
 A1* getA1_3() {return A8::getA1_3();}
@@ -890,7 +890,7 @@
 : public A10,
   public A11
 {
-char _[2283];
+char _[37];
 virtual ~A12() {}
 
 A1* getA1_3() {return A10::getA1_3();}
@@ -913,7 +913,7 @@
 struct A13
 : public A12
 {
-char _[1283];
+char _[41];
 virtual ~A13() {}
 
 A1* getA1_3() {return A12::getA1_3();}
@@ -1457,7 +1457,7 @@
 
 struct A1
 {
-char _[43981];
+char _[2];
 virtual ~A1() {}
 
 A1* getA1() {return this;}
@@ -1465,7 +1465,7 @@
 
 struct A2
 {
-char _[34981];
+char _[3];
 virtual ~A2()

Re: [PATCH] D15222: [Patch][Profile] add “--dependent-lib= libclang_rt.profile-x86_64.a” to the CC1 command line when enabling code coverage on PS4

2015-12-15 Thread Vedant Kumar via cfe-commits
vsk accepted this revision.
vsk added a reviewer: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

Lgtm


http://reviews.llvm.org/D15222



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


Re: [PATCH] D15516: [libcxx] Enable noexcept for GCC 4.6 and greater

2015-12-15 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

do we even use `_NOEXCEPT_OR_FALSE` any more?


http://reviews.llvm.org/D15516



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


Re: [PATCH] D15516: [libcxx] Enable noexcept for GCC 4.6 and greater

2015-12-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D15516#311280, @mclow.lists wrote:

> do we even use `_NOEXCEPT_OR_FALSE` any more?


Doesn't look like it.


http://reviews.llvm.org/D15516



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


Re: [PATCH] D15516: [libcxx] Enable noexcept for GCC 4.6 and greater

2015-12-15 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.

Other than the `_NOEXCEPT_OR_FALSE` thing, this LGTM.


http://reviews.llvm.org/D15516



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


[libcxx] r255683 - [libcxx] Enable noexcept for GCC 4.6 and greater

2015-12-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 15 16:16:47 2015
New Revision: 255683

URL: http://llvm.org/viewvc/llvm-project?rev=255683&view=rev
Log:
[libcxx] Enable noexcept for GCC 4.6 and greater

Summary:
This patch allows GCC 4.6 and above to use `noexcept` as opposed to `throw()`. 

Is it an ABI safe change to suddenly switch on `noexcept`? I imagine it must be 
because it's disabled in w/ clang in C++03 but not C++11.


Reviewers: danalbert, jroelofs, mclow.lists

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=255683&r1=255682&r2=255683&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Dec 15 16:16:47 2015
@@ -401,14 +401,8 @@ typedef __char32_t char32_t;
 #endif // __linux__
 #endif
 
-#if (__has_feature(cxx_noexcept))
-#  define _NOEXCEPT noexcept
-#  define _NOEXCEPT_(x) noexcept(x)
-#  define _NOEXCEPT_OR_FALSE(x) noexcept(x)
-#else
-#  define _NOEXCEPT throw()
-#  define _NOEXCEPT_(x)
-#  define _NOEXCEPT_OR_FALSE(x) false
+#if !(__has_feature(cxx_noexcept))
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #endif
 
 #if __has_feature(underlying_type)
@@ -476,10 +470,6 @@ namespace std {
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#define _NOEXCEPT throw()
-#define _NOEXCEPT_(x)
-#define _NOEXCEPT_OR_FALSE(x) false
-
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
 
 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
@@ -493,6 +483,7 @@ namespace std {
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
 #define _LIBCPP_HAS_NO_STRONG_ENUMS
+#define _LIBCPP_HAS_NO_NOEXCEPT
 
 #else  // __GXX_EXPERIMENTAL_CXX0X__
 
@@ -516,6 +507,7 @@ namespace std {
 #endif  // _GNUC_VER < 404
 
 #if _GNUC_VER < 406
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR
 #endif
 
@@ -549,15 +541,14 @@ using namespace _LIBCPP_NAMESPACE __attr
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
 #define _LIBCPP_UNUSED
 #define _ALIGNAS(x) __declspec(align(x))
 #define _LIBCPP_HAS_NO_VARIADICS
 
-#define _NOEXCEPT throw ()
-#define _NOEXCEPT_(x)
-#define _NOEXCEPT_OR_FALSE(x) false
+
 
 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
 #define _LIBCPP_END_NAMESPACE_STD  }
@@ -577,14 +568,11 @@ namespace std {
 #define _LIBCPP_NORETURN __attribute__((noreturn))
 #define _LIBCPP_UNUSED
 
-#define _NOEXCEPT throw()
-#define _NOEXCEPT_(x)
-#define _NOEXCEPT_OR_FALSE(x) false
-
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_IS_BASE_OF
@@ -608,6 +596,14 @@ namespace std {
 
 #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
 
+#ifndef _LIBCPP_HAS_NO_NOEXCEPT
+#  define _NOEXCEPT noexcept
+#  define _NOEXCEPT_(x) noexcept(x)
+#else
+#  define _NOEXCEPT throw()
+#  define _NOEXCEPT_(x)
+#endif
+
 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
 typedef unsigned short char16_t;
 typedef unsigned int   char32_t;


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


[libcxx] r255686 - Remove unused _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS macro

2015-12-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 15 16:19:03 2015
New Revision: 255686

URL: http://llvm.org/viewvc/llvm-project?rev=255686&view=rev
Log:
Remove unused _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS macro

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=255686&r1=255685&r2=255686&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Dec 15 16:19:03 2015
@@ -481,14 +481,11 @@ namespace std {
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_NO_VARIADICS
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
 #define _LIBCPP_HAS_NO_STRONG_ENUMS
 #define _LIBCPP_HAS_NO_NOEXCEPT
 
 #else  // __GXX_EXPERIMENTAL_CXX0X__
 
-#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
-
 #if _GNUC_VER < 403
 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #endif
@@ -570,7 +567,6 @@ namespace std {
 
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
-#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define _LIBCPP_HAS_NO_NULLPTR


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


r255685 - Fix clang/test/CodeGen/ms_this.cpp.

2015-12-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Dec 15 16:19:00 2015
New Revision: 255685

URL: http://llvm.org/viewvc/llvm-project?rev=255685&view=rev
Log:
Fix clang/test/CodeGen/ms_this.cpp.

Modified:
cfe/trunk/test/CodeGen/ms_this.cpp

Modified: cfe/trunk/test/CodeGen/ms_this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_this.cpp?rev=255685&r1=255684&r2=255685&view=diff
==
--- cfe/trunk/test/CodeGen/ms_this.cpp (original)
+++ cfe/trunk/test/CodeGen/ms_this.cpp Tue Dec 15 16:19:00 2015
@@ -1,6 +1,4 @@
-// Hexagon build bot defines hexagon-unknown-elf as the default target triple,
-// which seems to trump the -triple argument for some reason.
-// UNSUPPORTED: hexagon
+// REQUIRES: x86-registered-target
 
 // RUN: %clang_cc1 -triple x86_64-pc-win32 -fasm-blocks -emit-llvm %s -o - | 
FileCheck %s
 class t1 {


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


Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Peter Collingbourne via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM modulo some wordsmithing in the documentation.



Comment at: docs/ControlFlowIntegrity.rst:31
@@ +30,3 @@
+enabled, and are statically linked into the program. This may preclude
+the use of shared libraries in some cases. An experimental support for
+:ref:`cross-DSO control flow integrity ` existst that

"Experimental support for". Please also mention that the ABI is unstable.


Comment at: docs/ControlFlowIntegrity.rst:32
@@ +31,3 @@
+the use of shared libraries in some cases. An experimental support for
+:ref:`cross-DSO control flow integrity ` existst that
+does not have these requirements.

"exists"


Comment at: docs/ControlFlowIntegrityDesign.rst:375
@@ +374,3 @@
+
+Basic CFI mode described above assumes that the application is a
+monolithic binary; at least that all possible virtual/indirect call

"The basic CFI mode"


Comment at: docs/ControlFlowIntegrityDesign.rst:377
@@ +376,3 @@
+monolithic binary; at least that all possible virtual/indirect call
+targets and the entire class hierarchies are known at the link
+time. The cross-DSO mode, enabled with

"hierarchy"; "at link time"


Comment at: docs/ControlFlowIntegrityDesign.rst:389
@@ +388,3 @@
+  -  Calls between different instrumented DSOs are also protected with
+ performance penalty compared to the monolithic CFI.
+  -  Calls from instrumented DSO to an uninstrumented one are unchecked

"comparable"


Comment at: docs/ControlFlowIntegrityDesign.rst:390
@@ +389,3 @@
+ performance penalty compared to the monolithic CFI.
+  -  Calls from instrumented DSO to an uninstrumented one are unchecked
+ and just work, with performance penalty.

"from an instrumented DSO"


Comment at: docs/ControlFlowIntegrityDesign.rst:392
@@ +391,3 @@
+ and just work, with performance penalty.
+  -  Calls from instrumented DSO outside of any known DSO are detected
+ as CFI violations.

same


Comment at: docs/ControlFlowIntegrityDesign.rst:426
@@ +425,3 @@
+
+Possible, but unlikely, collisions in the ``CallSiteTypeId`` hashing
+will result in weaker CFI checks that would still be conservatively

"It is possible, but unlikely, that collisions"


Comment at: docs/ControlFlowIntegrityDesign.rst:446
@@ +445,3 @@
+
+The basic implementation is be a large switch statement over all
+values of CallSiteTypeId supported by this DSO, and each case is

"is a"


Comment at: docs/ControlFlowIntegrityDesign.rst:450
@@ +449,3 @@
+
+For performance reasons (see the following section), the address of
+__cfi_check is aligned by 4096.

I wouldn't claim this is "for performance reasons" unless we have data to back 
it up. I would remove this paragraph and mention the alignment in the next 
section.


Comment at: include/clang/Driver/Options.td:628
@@ -623,1 +627,3 @@
+ Group, Flags<[CC1Option]>,
+ HelpText<"Enable control flow integrity (CFI) 
checks for cross-DSO calls.">;
 def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,

"Disable"


Repository:
  rL LLVM

http://reviews.llvm.org/D15367



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


Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test

2015-12-15 Thread Jonathan Roelofs via cfe-commits
jroelofs added subscribers: howard.hinnant, jroelofs.
jroelofs added a comment.

Could these large padding things be related to the fact that the test is used 
as a performance check for the implementation? That being said, I have no idea 
who is paying attention to the numbers that come out of this test (if anyone 
even is?). Maybe @howard.hinnant knows something about it?


http://reviews.llvm.org/D15539



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


Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 42914.
eugenis marked 10 inline comments as done.

Repository:
  rL LLVM

http://reviews.llvm.org/D15367

Files:
  docs/ControlFlowIntegrity.rst
  docs/ControlFlowIntegrityDesign.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -291,6 +291,46 @@
 // CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
 
+// CFI by itself does not link runtime libraries.
+// RUN: %clang -fsanitize=cfi %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-LINUX %s
+// CHECK-CFI-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-LINUX-NOT: libclang_rt.
+
+// CFI with diagnostics links the UBSan runtime.
+// RUN: %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
+// RUN: %s -### -o %t.o 2>&1\
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-DIAG-LINUX %s
+// CHECK-CFI-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+// CHECK-CFI-DIAG-LINUX: libclang_rt.ubsan
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+
+// Cross-DSO CFI links the CFI runtime.
+// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
+// CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+
+// Cross-DSO CFI with diagnostics links just the CFI runtime.
+// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
+// RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
+
 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -mmacosx-version-min=10.6 \
 // RUN: -target x86_64-apple-darwin13.4.0 \
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -263,6 +263,15 @@
 // CHECK-CFI-NOTRAP-WIN: -emit-llvm-bc
 // CHECK-CFI-NOTRAP-WIN-NOT: -fsanitize-trap=cfi
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NO-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-cfi-cross-dso -fno-sanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NO-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fno-sanitize-cfi-cross-dso -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO
+// CHECK-CFI-CROSS-DSO: -emit-llvm-bc
+// CHECK-CFI-CROSS-DSO: -fsanitize-cfi-cross-dso
+// CHECK-CFI-NO-CROSS-DSO: -emit-llvm-bc
+// CHECK-CFI-NO-CROSS-DSO-NOT: -fsanitize-cfi-cross-dso
+
 // RUN: %clang_cl -fsanitize=address -c -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
Index: test/CodeGenCXX/cfi-cross-dso.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cfi-cross-dso.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitiz

Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: docs/ControlFlowIntegrityDesign.rst:389
@@ +388,3 @@
+  -  Calls between different instrumented DSOs are also protected with
+ performance penalty compared to the monolithic CFI.
+  -  Calls from instrumented DSO to an uninstrumented one are unchecked

pcc wrote:
> "comparable"
That changes the meaning of the sentence. I've changed the wording in a 
different way.


Repository:
  rL LLVM

http://reviews.llvm.org/D15367



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


Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test

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

In http://reviews.llvm.org/D15539#311343, @jroelofs wrote:

> Could these large padding things be related to the fact that the test is used 
> as a performance check for the implementation? That being said, I have no 
> idea who is paying attention to the numbers that come out of this test (if 
> anyone even is?). Maybe @howard.hinnant knows something about it?


My expectation is that the only thing the padding numbers would effect with 
regards to execution time would be cache hits and misses.  If there is 
something subtle going on though, then those sizes need some comments and 
rationale.  "93481" looks like it was pulled out of a hat, and it is large 
enough on it's own to overflow many embedded stacks.


http://reviews.llvm.org/D15539



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


r255690 - clang/test/CodeGen/ms_this.cpp: Fix for -Asserts.

2015-12-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Dec 15 16:42:28 2015
New Revision: 255690

URL: http://llvm.org/viewvc/llvm-project?rev=255690&view=rev
Log:
clang/test/CodeGen/ms_this.cpp: Fix for -Asserts.

Modified:
cfe/trunk/test/CodeGen/ms_this.cpp

Modified: cfe/trunk/test/CodeGen/ms_this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_this.cpp?rev=255690&r1=255689&r2=255690&view=diff
==
--- cfe/trunk/test/CodeGen/ms_this.cpp (original)
+++ cfe/trunk/test/CodeGen/ms_this.cpp Tue Dec 15 16:42:28 2015
@@ -13,23 +13,27 @@ public:
   void runc();
 };
 
+// CHECK: define void @"\01?runc@t2@@
 void t2::runc() {
   double num = 0;
   __asm {
   mov rax,[this]
-  //CHECK: %this.addr = alloca %class.t2*
-  //CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr 
$1{{.*}}%class.t2* %this1
+  // CHECK: [[THIS_ADDR_T2:%.+]] = alloca %class.t2*
+  // CHECK: [[THIS1_T2:%.+]] = load %class.t2*, %class.t2** 
[[THIS_ADDR_T2]],
+  // CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr 
$1{{.*}}%class.t2* [[THIS1_T2]]
   mov rbx,[rax]
   mov num, rbx
   };
 }
 
+// CHECK: define void @"\01?runc@t1@@
 void t1::runc() {
   double num = 0;
   __asm {
mov rax,[this]
-  //CHECK: %this.addr = alloca %class.t1*
-  //CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr 
$1{{.*}}%class.t1* %this1
+   // CHECK: [[THIS_ADDR_T1:%.+]] = alloca %class.t1*
+   // CHECK: [[THIS1_T1:%.+]] = load %class.t1*, %class.t1** 
[[THIS_ADDR_T1]],
+   // CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr 
$1{{.*}}%class.t1* [[THIS1_T1]]
 mov rbx,[rax]
 mov num, rbx
   };
@@ -37,10 +41,12 @@ void t1::runc() {
 
 struct s {
   int a;
+  // CHECK: define linkonce_odr void @"\01?func@s@@
   void func() {
 __asm mov rax, [this]
-//CHECK: %this.addr = alloca %struct.s*
-//CHECK: call void asm sideeffect inteldialect "mov rax, qword ptr 
$0{{.*}}%struct.s* %this1
+// CHECK: [[THIS_ADDR_S:%.+]] = alloca %struct.s*
+// CHECK: [[THIS1_S:%.+]] = load %struct.s*, %struct.s** [[THIS_ADDR_S]],
+// CHECK: call void asm sideeffect inteldialect "mov rax, qword ptr 
$0{{.*}}%struct.s* [[THIS1_S]]
   }
 } f3;
 


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


Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

LGTM



Comment at: docs/ControlFlowIntegrityDesign.rst:389
@@ +388,3 @@
+  - Calls between different instrumented DSOs are also protected, with
+ performance penalty (in addition to the monolithic CFI overhead).
+  - Calls from an instrumented DSO to an uninstrumented one are

"with a performance penalty"


Repository:
  rL LLVM

http://reviews.llvm.org/D15367



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


Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
eugenis marked an inline comment as done.
eugenis added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D15367



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


Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 42918.

Repository:
  rL LLVM

http://reviews.llvm.org/D15367

Files:
  docs/ControlFlowIntegrity.rst
  docs/ControlFlowIntegrityDesign.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -291,6 +291,46 @@
 // CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
 
+// CFI by itself does not link runtime libraries.
+// RUN: %clang -fsanitize=cfi %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-LINUX %s
+// CHECK-CFI-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-LINUX-NOT: libclang_rt.
+
+// CFI with diagnostics links the UBSan runtime.
+// RUN: %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
+// RUN: %s -### -o %t.o 2>&1\
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-DIAG-LINUX %s
+// CHECK-CFI-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+// CHECK-CFI-DIAG-LINUX: libclang_rt.ubsan
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+
+// Cross-DSO CFI links the CFI runtime.
+// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
+// CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
+
+// Cross-DSO CFI with diagnostics links just the CFI runtime.
+// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
+// RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
+
 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -mmacosx-version-min=10.6 \
 // RUN: -target x86_64-apple-darwin13.4.0 \
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -263,6 +263,15 @@
 // CHECK-CFI-NOTRAP-WIN: -emit-llvm-bc
 // CHECK-CFI-NOTRAP-WIN-NOT: -fsanitize-trap=cfi
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NO-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-cfi-cross-dso -fno-sanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NO-CROSS-DSO
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fno-sanitize-cfi-cross-dso -fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-CROSS-DSO
+// CHECK-CFI-CROSS-DSO: -emit-llvm-bc
+// CHECK-CFI-CROSS-DSO: -fsanitize-cfi-cross-dso
+// CHECK-CFI-NO-CROSS-DSO: -emit-llvm-bc
+// CHECK-CFI-NO-CROSS-DSO-NOT: -fsanitize-cfi-cross-dso
+
 // RUN: %clang_cl -fsanitize=address -c -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
Index: test/CodeGenCXX/cfi-cross-dso.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cfi-cross-dso.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall  -fsanitize-cfi-cross-dso -emit

r255694 - Cross-DSO control flow integrity (Clang part).

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Dec 15 17:00:20 2015
New Revision: 255694

URL: http://llvm.org/viewvc/llvm-project?rev=255694&view=rev
Log:
Cross-DSO control flow integrity (Clang part).

Clang-side cross-DSO CFI.

* Adds a command line flag -f[no-]sanitize-cfi-cross-dso.
* Links a runtime library when enabled.
* Emits __cfi_slowpath calls is bitset test fails.
* Emits extra hash-based bitsets for external CFI checks.
* Sets a module flag to enable __cfi_check generation during LTO.

This mode does not yet support diagnostics.

Added:
cfe/trunk/test/CodeGen/cfi-icall-cross-dso.c
cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp
Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst
cfe/trunk/docs/ControlFlowIntegrityDesign.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=255694&r1=255693&r2=255694&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Tue Dec 15 17:00:20 2015
@@ -24,10 +24,14 @@ You can also enable a subset of availabl
 As currently implemented, all schemes rely on link-time optimization (LTO);
 so it is required to specify ``-flto``, and the linker used must support LTO,
 for example via the `gold plugin`_.
-To allow the checks to be implemented efficiently, the program must
-be structured such that certain object files are compiled with CFI enabled,
-and are statically linked into the program. This may preclude the use of
-shared libraries in some cases.
+
+To allow the checks to be implemented efficiently, the program must be
+structured such that certain object files are compiled with CFI
+enabled, and are statically linked into the program. This may preclude
+the use of shared libraries in some cases. Experimental support for
+:ref:`cross-DSO control flow integrity ` exists that
+does not have these requirements. This cross-DSO support has unstable
+ABI at this time.
 
 .. _gold plugin: http://llvm.org/docs/GoldPlugin.html
 
@@ -245,6 +249,16 @@ are typically defined outside of the lin
 # Ignore all types with a uuid attribute.
 type:attr:uuid
 
+.. _cfi-cross-dso:
+
+Shared library support
+==
+
+Use **-f[no-]sanitize-cfi-cross-dso** to enable the cross-DSO control
+flow integrity mode, which allows all CFI schemes listed above to
+apply across DSO boundaries. As in the regular CFI, each DSO must be
+built with ``-flto``.
+
 Design
 ==
 

Modified: cfe/trunk/docs/ControlFlowIntegrityDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrityDesign.rst?rev=255694&r1=255693&r2=255694&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrityDesign.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrityDesign.rst Tue Dec 15 17:00:20 2015
@@ -366,3 +366,134 @@ Because the addresses of ``f``, ``g``, `
 we can normally apply the `Alignment`_ and `Eliminating Bit Vector Checks
 for All-Ones Bit Vectors`_ optimizations thus simplifying the check at each
 call site to a range and alignment check.
+
+Shared library support
+==
+
+**EXPERIMENTAL**
+
+The basic CFI mode described above assumes that the application is a
+monolithic binary; at least that all possible virtual/indirect call
+targets and the entire class hierarchy are known at link time. The
+cross-DSO mode, enabled with **-f[no-]sanitize-cfi-cross-dso** relaxes
+this requirement by allowing virtual and indirect calls to cross the
+DSO boundary.
+
+Assuming the following setup: the binary consists of several
+instrumented and several uninstrumented DSOs. Some of them may be
+dlopen-ed/dlclose-d periodically, even frequently.
+
+  - Calls made from uninstrumented DSOs are not checked and just work.
+  - Calls inside any instrumented DSO are fully protected.
+  - Calls between different instrumented DSOs are also protected, with
+ a performance penalty (in addition to the monolithic CFI
+ overhead).
+  - Calls from an instrumented DSO to an uninstrumented one are
+ unchecked and just work, with performance penalty.
+  - Calls from an instrumented DSO outside of any known DSO are
+   

Re: [PATCH] D15367: Cross-DSO control flow integrity (Clang part)

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r255694


Repository:
  rL LLVM

http://reviews.llvm.org/D15367



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


Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test

2015-12-15 Thread Howard Hinnant via cfe-commits
On Dec 15, 2015, at 5:30 PM, Jonathan Roelofs  wrote:
> 
> 
> Could these large padding things be related to the fact that the test is used 
> as a performance check for the implementation? That being said, I have no 
> idea who is paying attention to the numbers that come out of this test (if 
> anyone even is?). Maybe @howard.hinnant knows something about it?

It’s been a few years since I wrote this code, but my best recollection is that 
the large buffers indicate my concern of getting the correct answer 
accidentally as the dynamic_cast code will add/subtract offsets to pointers.  
The implementation is wicked hard to get right, and so the tests are extra 
paranoid.

As I wrote this I only had to worry about OS X / iOS.  If you need to reduce 
these numbers for other platforms, I think that would be fine.  However I would 
not reduce them to double digits.  I would keep them as large as you can 
reasonably get away with.

There may have also been effort to make sure that the numbers involved were not 
even close to multiples of one another, or add up to each other, etc, I don’t 
remember for sure.  The main concern is that the offset arithmetic implemented 
under __dynamic_cast does not accidentally get the right answer.  And I suspect 
alignment is also factored in to the offset computation (I don’t recall for 
sure), and so one can not depend entirely on small primes (which may be rounded 
to alignment).

Handy link:

http://mentorembedded.github.io/cxx-abi/abi.html#dynamic_cast-algorithm

Normally I don’t write a lot of comments in code.  Code should be self 
explanatory.  The sheer volume of comments in private_typeinfo.cpp should serve 
as a signal that this code is very tricky.  So I recommend keeping the tests as 
paranoid as possible.

Howard

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


Re: [PATCH] D15463: [Objective-c] Fix a crash

2015-12-15 Thread Akira Hatanaka via cfe-commits
On Tue, Dec 15, 2015 at 12:55 PM, Justin Bogner 
wrote:

> Akira Hatanaka  writes:
> > On Mon, Dec 14, 2015 at 10:39 AM, Justin Bogner 
> > wrote:
> >
> >> Akira Hatanaka via cfe-commits  writes:
> >> > ahatanak created this revision.
> >> > ahatanak added a subscriber: cfe-commits.
> >> >
> >> > This patch fixes a crash that occurs when __kindof is incorrectly used
> >> > in the type parameter list of an interface. The crash occurs because
> >> > ObjCTypeParamList::back() is called in checkTypeParamListConsistency
> >> > on an empty list:
> >> >
> >> > 00762   diagLoc =
> >> S.getLocForEndOfToken(newTypeParams->back()->getLocEnd());
> >> >
> >> > http://reviews.llvm.org/D15463
> >> >
> >> > Files:
> >> >   lib/Parse/ParseObjc.cpp
> >> >   test/SemaObjC/kindof.m
> >> >
> >> > Index: test/SemaObjC/kindof.m
> >> > ===
> >> > --- test/SemaObjC/kindof.m
> >> > +++ test/SemaObjC/kindof.m
> >> > @@ -302,3 +302,13 @@
> >> >void processCopyable(__typeof(getSomeCopyable()) string);
> >> >processCopyable(0); // expected-warning{{null passed to a callee
> that
> >> requires a non-null argument}}
> >> >  }
> >> > +
> >> > +// __kinddof cannot be used in parameter list.
> >> > +@interface Array1 : NSObject
> >> > +@end
> >> > +
> >> > +@interface I1 : NSObject
> >> > +@end
> >> > +
> >> > +@interface Array1<__kindof I1*>(extensions) // //
> >> expected-error{{expected type parameter name}}
> >> > +@end
> >> > Index: lib/Parse/ParseObjc.cpp
> >> > ===
> >> > --- lib/Parse/ParseObjc.cpp
> >> > +++ lib/Parse/ParseObjc.cpp
> >> > @@ -603,7 +603,7 @@
> >> >// whether there are any protocol references.
> >> >lAngleLoc = SourceLocation();
> >> >rAngleLoc = SourceLocation();
> >> > -  return list;
> >> > +  return invalid ? nullptr : list;
> >>
> >> This looks a bit suspicious to me. Since `invalid` is set *way* earlier
> >> in the function, it seems like we should be able to return earlier if
> >> this is correct, and not even call actOnObjCTypeParamList. OTOH, are
> >> there cases where `invalid == true` but list is non-empty? If so, are we
> >> doing the right thing when that happens?
> >>
> >>
> > I'm assuming you meant it should return earlier if this is *incorrect*
> (but
> > let me know if I misunderstood your comment).
>
> I meant, "If `return invalid ? nullptr : list` is correct, then I
> suspect returning nullptr before calling actOnObjCTypeParamList makes
> more sense.
>
> > The only downside to returning nullptr before actOnObjCTypeParamList is
> > called in line 595 is that it won't print the diagnostics that are
> printed
> > in actOnObjCTypeParamList. For example, if the following interface were
> > compiled,
> >
> > @interface I1 NSObject
> > @end
> >
> > actOnObjCTypeParamList could tell the user that parameter "T" was
> > redeclared in addition to printing the error message about __kindof. So
> if
> > we return before it's called, we won't see that error message.
> >
> > When the interface declaration of category extensions1 in the following
> > piece of code is compiled, invalid is set to true and the list is not
> empty
> > (it contains the first two parameters).
> >
> > @interface I1 NSObject
> > @end
> >
> > @interface I1 (extensions1)
> > @end
> >
> > *test3.m:6:23: **error: **expected type parameter name*
> >
> > @interface I6 (extensions1)
> >
> > *  ^*
> >
> > *test3.m:6:21: **error: **category has too few type parameters (expected
> 3,
> > have 2)*
> >
> > @interface I6 (extensions1)
> > It looks like it's doing the right thing, but the second diagnostic
> doesn't
> > seem necessary to me.
>
> I'm not sure I follow exactly which errors are being reported with your
> patch, so maybe this is already working, but what we basically want is
> to only emit errors that are helpful.
>
> That is, if we get the `"T" is a redeclaration` error as well as the
> __kindof error, that's nice, but if we get the `too few type parameters`
> error that's going to be confusing and bad - the user didn't provide too
> few type parameters, but our previous error caused us to see too few.
>
> Basically, we don't ever want to report errors that are the result of
> previous errors, but as long as we don't end up doing that then
> gathering further errors is totally reasonable. Make sense?
>
>
Yes, that makes perfect sense.

The following shows the error messages I see when I compile test case
test3.m:

$ cat test3.m

#import 
@interface I2 : NSObject
@end

@interface I7 : NSObject
@end

@interface I7(ext2)
@end

@interface I6 : NSObject
@end

@interface I6<__kindof I2*>(ext1)
@end


### This patch: it prints the error messages we want to see.
test3.m:9:21: error: expected type parameter name
@interface I7(ext2)
^

test3.m:9:18: error: redeclaration of type parameter 'T'
@interface I7(ext2)
  ~  ^

test3.m:15:15: error: expecte

Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2015-12-15 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


http://reviews.llvm.org/D15173



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


r255710 - [SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 32bit

2015-12-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Dec 15 17:47:40 2015
New Revision: 255710

URL: http://llvm.org/viewvc/llvm-project?rev=255710&view=rev
Log:
[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 32bit

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/exceptions-seh.c
cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=255710&r1=255709&r2=255710&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Dec 15 17:47:40 2015
@@ -1548,27 +1548,32 @@ void CodeGenFunction::EmitCapturedLocals
 return;
   }
 
-  llvm::Value *EntryEBP = nullptr;
-  llvm::Value *ParentFP;
+  llvm::Value *EntryFP = nullptr;
+  CGBuilderTy Builder(CGM, AllocaInsertPt);
   if (IsFilter && CGM.getTarget().getTriple().getArch() == llvm::Triple::x86) {
 // 32-bit SEH filters need to be careful about FP recovery.  The end of the
 // EH registration is passed in as the EBP physical register.  We can
-// recover that with llvm.frameaddress(1), and adjust that to recover the
-// parent's true frame pointer.
-CGBuilderTy Builder(CGM, AllocaInsertPt);
-EntryEBP = Builder.CreateCall(
+// recover that with llvm.frameaddress(1).
+EntryFP = Builder.CreateCall(
 CGM.getIntrinsic(llvm::Intrinsic::frameaddress), 
{Builder.getInt32(1)});
-llvm::Function *RecoverFPIntrin =
-CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
-llvm::Constant *ParentI8Fn =
-llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
-ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryEBP});
   } else {
 // Otherwise, for x64 and 32-bit finally functions, the parent FP is the
 // second parameter.
 auto AI = CurFn->arg_begin();
 ++AI;
-ParentFP = &*AI;
+EntryFP = &*AI;
+  }
+
+  llvm::Value *ParentFP;
+  if (IsFilter) {
+// Given whatever FP the runtime provided us in EntryFP, recover the true
+// frame pointer of the parent function. We only need to do this in 
filters,
+// since finally funclets recover the parent FP for us.
+llvm::Function *RecoverFPIntrin =
+CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
+llvm::Constant *ParentI8Fn =
+llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
+ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});
   }
 
   // Create llvm.localrecover calls for all captures.
@@ -1602,7 +1607,7 @@ void CodeGenFunction::EmitCapturedLocals
   }
 
   if (IsFilter)
-EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryEBP);
+EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryFP);
 }
 
 /// Arrange a function prototype that can be called by Windows exception
@@ -1718,7 +1723,7 @@ CodeGenFunction::GenerateSEHFinallyFunct
 
 void CodeGenFunction::EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
llvm::Value *ParentFP,
-   llvm::Value *EntryEBP) {
+   llvm::Value *EntryFP) {
   // Get the pointer to the EXCEPTION_POINTERS struct. This is returned by the
   // __exception_info intrinsic.
   if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
@@ -1731,7 +1736,7 @@ void CodeGenFunction::EmitSEHExceptionCo
 // exception registration object. It contains 6 32-bit fields, and the info
 // pointer is stored in the second field. So, GEP 20 bytes backwards and
 // load the pointer.
-SEHInfo = Builder.CreateConstInBoundsGEP1_32(Int8Ty, EntryEBP, -20);
+SEHInfo = Builder.CreateConstInBoundsGEP1_32(Int8Ty, EntryFP, -20);
 SEHInfo = Builder.CreateBitCast(SEHInfo, Int8PtrTy->getPointerTo());
 SEHInfo = Builder.CreateAlignedLoad(Int8PtrTy, SEHInfo, getPointerAlign());
 SEHCodeSlotStack.push_back(recoverAddrOfEscapedLocal(

Modified: cfe/trunk/test/CodeGen/exceptions-seh.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh.c?rev=255710&r1=255709&r2=255710&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh.c Tue Dec 15 17:47:40 2015
@@ -89,7 +89,8 @@ int filter_expr_capture(void) {
 // CHECK: ret i32 %[[rv]]
 
 // X64-LABEL: define internal i32 @"\01?filt$0@0@filter_expr_capture@@"(i8* 
%exception_pointers, i8* %frame_pointer)
-// X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %frame_pointer, i32 0)
+// X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
+// X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_

Re: [PATCH] D15462: [CMake] Add support for generating profdata for clang from training files

2015-12-15 Thread Sean Silva via cfe-commits
silvas added a comment.

Thanks. This LGTM but I'd wait for Duncan or Justin to sign off on it; they're 
likely to have more higher-level thoughts.



Comment at: utils/perf-training/perf-helper.py:36
@@ +35,3 @@
+  cmd.extend(findProfrawFiles(args[2]))
+  subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+  return 0

I don't think you need the PIPE arguments (or maybe look into check_output if 
you want the output)


http://reviews.llvm.org/D15462



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


r255712 - Relax checks in cfi-cross-dso test.

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Dec 15 17:49:51 2015
New Revision: 255712

URL: http://llvm.org/viewvc/llvm-project?rev=255712&view=rev
Log:
Relax checks in cfi-cross-dso test.

The test is failing with unnamed labels.

Modified:
cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp

Modified: cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp?rev=255712&r1=255711&r2=255712&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp Tue Dec 15 17:49:51 2015
@@ -33,11 +33,11 @@ void g() {
 // ITANIUM:   %[[TEST:.*]] = call i1 @llvm.bitset.test(i8* %[[VT2]], metadata 
!"_ZTS1A"), !nosanitize
 // MS:   %[[TEST:.*]] = call i1 @llvm.bitset.test(i8* %[[VT2]], metadata 
!"?AUA@@"), !nosanitize
 // CHECK:   br i1 %[[TEST]], label %[[CONT:.*]], label %[[SLOW:.*]], {{.*}} 
!nosanitize
-// CHECK: [[SLOW]]:
+// CHECK: [[SLOW]]
 // ITANIUM:   call void @__cfi_slowpath(i64 7004155349499253778, i8* %[[VT2]]) 
{{.*}} !nosanitize
 // MS:   call void @__cfi_slowpath(i64 -8005289897957287421, i8* %[[VT2]]) 
{{.*}} !nosanitize
 // CHECK:   br label %[[CONT]], !nosanitize
-// CHECK: [[CONT]]:
+// CHECK: [[CONT]]
 // CHECK:   call void %{{.*}}(%struct.A* %{{.*}})
 
 // No hash-based bit set entry for (anonymous namespace)::B


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


Re: [PATCH] D15006: Driver: Better detection of mingw-gcc

2015-12-15 Thread Martell Malone via cfe-commits
martell updated this revision to Diff 42933.
martell added a comment.

Sorry I was a bit slow getting around to this.

Will do testcases if Yaron thinks this is okay


http://reviews.llvm.org/D15006

Files:
  lib/Driver/MinGWToolChain.cpp
  lib/Driver/ToolChains.h

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -662,6 +662,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -62,20 +62,27 @@
   }
 }
 
+llvm::ErrorOr MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = 
llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-  // On Windows if there is no sysroot we search for gcc on the PATH.
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+Base = getDriver().SysRoot;
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
-#endif
-  if (!Base.size())
+  else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 
   Base += llvm::sys::path::get_separator();


Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -662,6 +662,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -62,20 +62,27 @@
   }
 }
 
+llvm::ErrorOr MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-  // On Windows if there is no sysroot we search for gcc on the PATH.
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+Base = getDriver().SysRoot;
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
-#endif
-  if (!Base.size())
+  else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 
   Base += llvm::sys::path::get_separator();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255723 - These days, GCC has at least minimal documentation for its VLAIS extension.

2015-12-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 15 18:09:57 2015
New Revision: 255723

URL: http://llvm.org/viewvc/llvm-project?rev=255723&view=rev
Log:
These days, GCC has at least minimal documentation for its VLAIS extension.

Modified:
cfe/trunk/www/comparison.html

Modified: cfe/trunk/www/comparison.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=255723&r1=255722&r2=255723&view=diff
==
--- cfe/trunk/www/comparison.html (original)
+++ cfe/trunk/www/comparison.html Tue Dec 15 18:09:57 2015
@@ -55,8 +55,8 @@
 by Clang. For instance, in C mode, GCC supports
 http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html";>nested
 functions and has an
-http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37428";>undocumented
-extension allowing VLAs in structs.
+https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html";>extension
+allowing VLAs in structs.
 
 
 Pro's of clang vs GCC:


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


Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2015-12-15 Thread Argyrios Kyrtzidis via cfe-commits
LGTM.

> On Dec 12, 2015, at 5:25 PM, Bruno Cardoso Lopes  
> wrote:
> 
> bruno updated this revision to Diff 42649.
> bruno added a comment.
> 
> Thanks Duncan and Argyrios, updated a patch with the suggestions!
> 
> 
> http://reviews.llvm.org/D15173
> 
> Files:
>  lib/Lex/PPCaching.cpp
>  test/Parser/objcxx11-protocol-in-template.mm
> 
> Index: test/Parser/objcxx11-protocol-in-template.mm
> ===
> --- test/Parser/objcxx11-protocol-in-template.mm
> +++ test/Parser/objcxx11-protocol-in-template.mm
> @@ -8,3 +8,11 @@
> 
> vector> v;
> vector>> v2;
> +
> +@protocol PA;
> +@protocol PB;
> +
> +@class NSArray;
> +typedef int some_t;
> +
> +id FA(NSArray> *h, some_t group);
> Index: lib/Lex/PPCaching.cpp
> ===
> --- lib/Lex/PPCaching.cpp
> +++ lib/Lex/PPCaching.cpp
> @@ -97,8 +97,26 @@
> void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
>   assert(Tok.isAnnotation() && "Expected annotation token");
>   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
> -  assert(CachedTokens[CachedLexPos-1].getLastLoc() == 
> Tok.getAnnotationEndLoc()
> - && "The annotation should be until the most recent cached token");
> +
> +#ifndef NDEBUG
> +  Token CachedLastTok = CachedTokens[CachedLexPos - 1];
> +  SourceLocation CachedLastTokLoc = CachedLastTok.getLastLoc();
> +  SourceLocation TokAnnEndLoc = Tok.getAnnotationEndLoc();
> +
> +  // The annotation should be until the most recent cached token. Since
> +  // `Tok` length could be bigger than one (e.g. greatergreater '>>'), 
> account
> +  // for that cases before checking the assertion.
> +  if (!CachedLastTok.isAnnotation()) {
> +CachedLastTokLoc =
> +CachedLastTokLoc.getLocWithOffset(CachedLastTok.getLength());
> +unsigned TokAnnEndLocSize = Lexer::MeasureTokenLength(
> +SourceMgr.getSpellingLoc(TokAnnEndLoc), SourceMgr, LangOpts);
> +TokAnnEndLoc = TokAnnEndLoc.getLocWithOffset(TokAnnEndLocSize);
> +  }
> +
> +  assert(CachedLastTokLoc == TokAnnEndLoc &&
> + "The annotation should be until the most recent cached token");
> +#endif
> 
>   // Start from the end of the cached tokens list and look for the token
>   // that is the beginning of the annotation token.
> 
> 
> 

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


Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2015-12-15 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

LGTM.


http://reviews.llvm.org/D15173



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


r255726 - Update our claims about GCC's diagnostics quality to reflect recent improvements to GCC.

2015-12-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 15 18:18:47 2015
New Revision: 255726

URL: http://llvm.org/viewvc/llvm-project?rev=255726&view=rev
Log:
Update our claims about GCC's diagnostics quality to reflect recent 
improvements to GCC.

Modified:
cfe/trunk/www/comparison.html

Modified: cfe/trunk/www/comparison.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=255726&r1=255725&r2=255726&view=diff
==
--- cfe/trunk/www/comparison.html (original)
+++ cfe/trunk/www/comparison.html Tue Dec 15 18:18:47 2015
@@ -95,12 +95,12 @@
 that produced it (it is not a structured format).
 Clang is much faster and uses far
 less memory than GCC.
-Clang aims to provide extremely clear and concise diagnostics (error 
and
-warning messages), and includes support for expressive diagnostics.  GCC's warnings 
are 
-sometimes acceptable, but are often confusing and it does not support
-expressive diagnostics.  Clang also preserves typedefs in diagnostics
-consistently, showing macro expansions and many other features.
+Clang has been designed from the start to provide extremely clear and
+concise diagnostics (error and warning messages), and includes support
+for expressive diagnostics.
+Modern versions of GCC have made significant advances in this area,
+incorporating various Clang features such as preserving typedefs in
+diagnostics and showing macro expansions, but is still catching 
up.
 GCC is licensed under the GPL license. 
 clang uses a BSD license, which allows it to be embedded in
 software that is not GPL-licensed.


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


r255727 - Fix grammar.

2015-12-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 15 18:19:23 2015
New Revision: 255727

URL: http://llvm.org/viewvc/llvm-project?rev=255727&view=rev
Log:
Fix grammar.

Modified:
cfe/trunk/www/comparison.html

Modified: cfe/trunk/www/comparison.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=255727&r1=255726&r2=255727&view=diff
==
--- cfe/trunk/www/comparison.html (original)
+++ cfe/trunk/www/comparison.html Tue Dec 15 18:19:23 2015
@@ -100,7 +100,8 @@
 for expressive diagnostics.
 Modern versions of GCC have made significant advances in this area,
 incorporating various Clang features such as preserving typedefs in
-diagnostics and showing macro expansions, but is still catching 
up.
+diagnostics and showing macro expansions, but GCC is still catching
+up.
 GCC is licensed under the GPL license. 
 clang uses a BSD license, which allows it to be embedded in
 software that is not GPL-licensed.


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


r255728 - Revert "[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 32bit"

2015-12-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Dec 15 18:20:21 2015
New Revision: 255728

URL: http://llvm.org/viewvc/llvm-project?rev=255728&view=rev
Log:
Revert "[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 
32bit"

This reverts commit r255710.

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/exceptions-seh.c
cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=255728&r1=255727&r2=255728&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Dec 15 18:20:21 2015
@@ -1548,32 +1548,27 @@ void CodeGenFunction::EmitCapturedLocals
 return;
   }
 
-  llvm::Value *EntryFP = nullptr;
-  CGBuilderTy Builder(CGM, AllocaInsertPt);
+  llvm::Value *EntryEBP = nullptr;
+  llvm::Value *ParentFP;
   if (IsFilter && CGM.getTarget().getTriple().getArch() == llvm::Triple::x86) {
 // 32-bit SEH filters need to be careful about FP recovery.  The end of the
 // EH registration is passed in as the EBP physical register.  We can
-// recover that with llvm.frameaddress(1).
-EntryFP = Builder.CreateCall(
+// recover that with llvm.frameaddress(1), and adjust that to recover the
+// parent's true frame pointer.
+CGBuilderTy Builder(CGM, AllocaInsertPt);
+EntryEBP = Builder.CreateCall(
 CGM.getIntrinsic(llvm::Intrinsic::frameaddress), 
{Builder.getInt32(1)});
+llvm::Function *RecoverFPIntrin =
+CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
+llvm::Constant *ParentI8Fn =
+llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
+ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryEBP});
   } else {
 // Otherwise, for x64 and 32-bit finally functions, the parent FP is the
 // second parameter.
 auto AI = CurFn->arg_begin();
 ++AI;
-EntryFP = &*AI;
-  }
-
-  llvm::Value *ParentFP;
-  if (IsFilter) {
-// Given whatever FP the runtime provided us in EntryFP, recover the true
-// frame pointer of the parent function. We only need to do this in 
filters,
-// since finally funclets recover the parent FP for us.
-llvm::Function *RecoverFPIntrin =
-CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
-llvm::Constant *ParentI8Fn =
-llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
-ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});
+ParentFP = &*AI;
   }
 
   // Create llvm.localrecover calls for all captures.
@@ -1607,7 +1602,7 @@ void CodeGenFunction::EmitCapturedLocals
   }
 
   if (IsFilter)
-EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryFP);
+EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryEBP);
 }
 
 /// Arrange a function prototype that can be called by Windows exception
@@ -1723,7 +1718,7 @@ CodeGenFunction::GenerateSEHFinallyFunct
 
 void CodeGenFunction::EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
llvm::Value *ParentFP,
-   llvm::Value *EntryFP) {
+   llvm::Value *EntryEBP) {
   // Get the pointer to the EXCEPTION_POINTERS struct. This is returned by the
   // __exception_info intrinsic.
   if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
@@ -1736,7 +1731,7 @@ void CodeGenFunction::EmitSEHExceptionCo
 // exception registration object. It contains 6 32-bit fields, and the info
 // pointer is stored in the second field. So, GEP 20 bytes backwards and
 // load the pointer.
-SEHInfo = Builder.CreateConstInBoundsGEP1_32(Int8Ty, EntryFP, -20);
+SEHInfo = Builder.CreateConstInBoundsGEP1_32(Int8Ty, EntryEBP, -20);
 SEHInfo = Builder.CreateBitCast(SEHInfo, Int8PtrTy->getPointerTo());
 SEHInfo = Builder.CreateAlignedLoad(Int8PtrTy, SEHInfo, getPointerAlign());
 SEHCodeSlotStack.push_back(recoverAddrOfEscapedLocal(

Modified: cfe/trunk/test/CodeGen/exceptions-seh.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh.c?rev=255728&r1=255727&r2=255728&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh.c Tue Dec 15 18:20:21 2015
@@ -89,8 +89,7 @@ int filter_expr_capture(void) {
 // CHECK: ret i32 %[[rv]]
 
 // X64-LABEL: define internal i32 @"\01?filt$0@0@filter_expr_capture@@"(i8* 
%exception_pointers, i8* %frame_pointer)
-// X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
-// X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %[[fp]], i32 0)
+// X64: call i8* @llvm.localrecover(i

r255731 - Reland "[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 32bit"

2015-12-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Dec 15 18:26:37 2015
New Revision: 255731

URL: http://llvm.org/viewvc/llvm-project?rev=255731&view=rev
Log:
Reland "[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 
32bit"

I forgot to initialize RecoverFP.

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/exceptions-seh.c
cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=255731&r1=255730&r2=255731&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Dec 15 18:26:37 2015
@@ -1493,8 +1493,9 @@ struct CaptureFinder : ConstStmtVisitor<
 };
 } // end anonymous namespace
 
-Address CodeGenFunction::recoverAddrOfEscapedLocal(
-CodeGenFunction &ParentCGF, Address ParentVar, llvm::Value *ParentFP) {
+Address CodeGenFunction::recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
+   Address ParentVar,
+   llvm::Value *ParentFP) {
   llvm::CallInst *RecoverCall = nullptr;
   CGBuilderTy Builder(*this, AllocaInsertPt);
   if (auto *ParentAlloca = dyn_cast(ParentVar.getPointer())) 
{
@@ -1548,27 +1549,32 @@ void CodeGenFunction::EmitCapturedLocals
 return;
   }
 
-  llvm::Value *EntryEBP = nullptr;
-  llvm::Value *ParentFP;
+  llvm::Value *EntryFP = nullptr;
+  CGBuilderTy Builder(CGM, AllocaInsertPt);
   if (IsFilter && CGM.getTarget().getTriple().getArch() == llvm::Triple::x86) {
 // 32-bit SEH filters need to be careful about FP recovery.  The end of the
 // EH registration is passed in as the EBP physical register.  We can
-// recover that with llvm.frameaddress(1), and adjust that to recover the
-// parent's true frame pointer.
-CGBuilderTy Builder(CGM, AllocaInsertPt);
-EntryEBP = Builder.CreateCall(
+// recover that with llvm.frameaddress(1).
+EntryFP = Builder.CreateCall(
 CGM.getIntrinsic(llvm::Intrinsic::frameaddress), 
{Builder.getInt32(1)});
-llvm::Function *RecoverFPIntrin =
-CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
-llvm::Constant *ParentI8Fn =
-llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
-ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryEBP});
   } else {
 // Otherwise, for x64 and 32-bit finally functions, the parent FP is the
 // second parameter.
 auto AI = CurFn->arg_begin();
 ++AI;
-ParentFP = &*AI;
+EntryFP = &*AI;
+  }
+
+  llvm::Value *ParentFP = EntryFP;
+  if (IsFilter) {
+// Given whatever FP the runtime provided us in EntryFP, recover the true
+// frame pointer of the parent function. We only need to do this in 
filters,
+// since finally funclets recover the parent FP for us.
+llvm::Function *RecoverFPIntrin =
+CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
+llvm::Constant *ParentI8Fn =
+llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
+ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});
   }
 
   // Create llvm.localrecover calls for all captures.
@@ -1592,8 +1598,8 @@ void CodeGenFunction::EmitCapturedLocals
   continue;
 
 Address ParentVar = I->second;
-setAddrOfLocalVar(VD,
-  recoverAddrOfEscapedLocal(ParentCGF, ParentVar, ParentFP));
+setAddrOfLocalVar(
+VD, recoverAddrOfEscapedLocal(ParentCGF, ParentVar, ParentFP));
   }
 
   if (Finder.SEHCodeSlot.isValid()) {
@@ -1602,7 +1608,7 @@ void CodeGenFunction::EmitCapturedLocals
   }
 
   if (IsFilter)
-EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryEBP);
+EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryFP);
 }
 
 /// Arrange a function prototype that can be called by Windows exception
@@ -1718,7 +1724,7 @@ CodeGenFunction::GenerateSEHFinallyFunct
 
 void CodeGenFunction::EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
llvm::Value *ParentFP,
-   llvm::Value *EntryEBP) {
+   llvm::Value *EntryFP) {
   // Get the pointer to the EXCEPTION_POINTERS struct. This is returned by the
   // __exception_info intrinsic.
   if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
@@ -1731,7 +1737,7 @@ void CodeGenFunction::EmitSEHExceptionCo
 // exception registration object. It contains 6 32-bit fields, and the info
 // pointer is stored in the second field. So, GEP 20 bytes backwards and
 // load the pointer.
-SEHInfo = Builder.CreateConstInBoundsGEP1_32(Int8Ty, EntryEBP, -20);
+SEHInfo = Builder.CreateConstInBoundsGEP1_32(Int8Ty, EntryFP, -20);
 SEHInfo = Builder.CreateBitCast(SEHInfo, Int8PtrTy->getPointerTo());

[libcxx] r255734 - Workaround nasty GCC bug that caused testsuite to hang

2015-12-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 15 18:35:45 2015
New Revision: 255734

URL: http://llvm.org/viewvc/llvm-project?rev=255734&view=rev
Log:
Workaround nasty GCC bug that caused testsuite to hang

Modified:
libcxx/trunk/include/utility

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=255734&r1=255733&r2=255734&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Dec 15 18:35:45 2015
@@ -744,7 +744,9 @@ struct __make_integer_sequence
 static_assert(is_integral<_Tp>::value,
   "std::make_integer_sequence can only be instantiated with an 
integral type" );
 static_assert(0 <= _Ep, "std::make_integer_sequence must have a 
non-negative sequence length");
-typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
+// Workaround GCC bug by preventing bad installations when 0 <= _Ep
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
+typedef __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
 };
 
 #endif


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


r255736 - [cfi] Exclude ubsan runtime library from non-diag CFI builds (driver changes).

2015-12-15 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Dec 15 18:38:42 2015
New Revision: 255736

URL: http://llvm.org/viewvc/llvm-project?rev=255736&view=rev
Log:
[cfi] Exclude ubsan runtime library from non-diag CFI builds (driver changes).

Split the CFI runtime in two: cfi and cfi_diag. The latter includes
UBSan runtime to allow printing diagnostics.

Modified:
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=255736&r1=255735&r2=255736&view=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Tue Dec 15 18:38:42 2015
@@ -55,6 +55,7 @@ class SanitizerArgs {
 return Sanitizers.has(SanitizerKind::SafeStack);
   }
   bool needsCfiRt() const;
+  bool needsCfiDiagRt() const;
 
   bool requiresPIE() const;
   bool needsUnwindTables() const;

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=255736&r1=255735&r2=255736&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue Dec 15 18:38:42 2015
@@ -165,7 +165,11 @@ bool SanitizerArgs::needsUbsanRt() const
 }
 
 bool SanitizerArgs::needsCfiRt() const {
-  return CfiCrossDso;
+  return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
+}
+
+bool SanitizerArgs::needsCfiDiagRt() const {
+  return (Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
 }
 
 bool SanitizerArgs::requiresPIE() const {

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=255736&r1=255735&r2=255736&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Dec 15 18:38:42 2015
@@ -2794,6 +2794,8 @@ collectSanitizerRuntimes(const ToolChain
 StaticRuntimes.push_back("safestack");
   if (SanArgs.needsCfiRt())
 StaticRuntimes.push_back("cfi");
+  if (SanArgs.needsCfiDiagRt())
+StaticRuntimes.push_back("cfi_diag");
 }
 
 // Should be called before we add system libraries (C++ ABI, libstdc++/libc++,

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=255736&r1=255735&r2=255736&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Tue Dec 15 18:38:42 2015
@@ -317,7 +317,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
 // CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
-// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi-
 // CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
 
 // Cross-DSO CFI with diagnostics links just the CFI runtime.
@@ -328,7 +328,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
 // CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
-// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi_diag-
 // CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
 
 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \


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


Re: [PATCH] D15462: [CMake] Add support for generating profdata for clang from training files

2015-12-15 Thread Justin Bogner via cfe-commits
Sean Silva  writes:
> silvas added a comment.
>
> Thanks. This LGTM but I'd wait for Duncan or Justin to sign off on it;
> they're likely to have more higher-level thoughts.

I'm fine with the concept and Sean's LGTM should cover the details :)

>
> 
> Comment at: utils/perf-training/perf-helper.py:36
> @@ +35,3 @@
> +  cmd.extend(findProfrawFiles(args[2]))
> +  subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
> +  return 0
> 
> I don't think you need the PIPE arguments (or maybe look into
> check_output if you want the output)
>
>
> http://reviews.llvm.org/D15462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15463: [Objective-c] Fix a crash

2015-12-15 Thread Justin Bogner via cfe-commits
Akira Hatanaka  writes:
> On Tue, Dec 15, 2015 at 12:55 PM, Justin Bogner 
> wrote:
>
>> Akira Hatanaka  writes:
>> > On Mon, Dec 14, 2015 at 10:39 AM, Justin Bogner 
>> > wrote:
>> >
>> >> Akira Hatanaka via cfe-commits  writes:
>> >> > ahatanak created this revision.
>> >> > ahatanak added a subscriber: cfe-commits.
>> >> >
>> >> > This patch fixes a crash that occurs when __kindof is incorrectly used
>> >> > in the type parameter list of an interface. The crash occurs because
>> >> > ObjCTypeParamList::back() is called in checkTypeParamListConsistency
>> >> > on an empty list:
>> >> >
>> >> > 00762   diagLoc =
>> >> S.getLocForEndOfToken(newTypeParams->back()->getLocEnd());
>> >> >
>> >> > http://reviews.llvm.org/D15463
>> >> >
>> >> > Files:
>> >> >   lib/Parse/ParseObjc.cpp
>> >> >   test/SemaObjC/kindof.m
>> >> >
>> >> > Index: test/SemaObjC/kindof.m
>> >> > ===
>> >> > --- test/SemaObjC/kindof.m
>> >> > +++ test/SemaObjC/kindof.m
>> >> > @@ -302,3 +302,13 @@
>> >> >void processCopyable(__typeof(getSomeCopyable()) string);
>> >> >processCopyable(0); // expected-warning{{null passed to a callee
>> that
>> >> requires a non-null argument}}
>> >> >  }
>> >> > +
>> >> > +// __kinddof cannot be used in parameter list.
>> >> > +@interface Array1 : NSObject
>> >> > +@end
>> >> > +
>> >> > +@interface I1 : NSObject
>> >> > +@end
>> >> > +
>> >> > +@interface Array1<__kindof I1*>(extensions) // //
>> >> expected-error{{expected type parameter name}}
>> >> > +@end
>> >> > Index: lib/Parse/ParseObjc.cpp
>> >> > ===
>> >> > --- lib/Parse/ParseObjc.cpp
>> >> > +++ lib/Parse/ParseObjc.cpp
>> >> > @@ -603,7 +603,7 @@
>> >> >// whether there are any protocol references.
>> >> >lAngleLoc = SourceLocation();
>> >> >rAngleLoc = SourceLocation();
>> >> > -  return list;
>> >> > +  return invalid ? nullptr : list;
>> >>
>> >> This looks a bit suspicious to me. Since `invalid` is set *way* earlier
>> >> in the function, it seems like we should be able to return earlier if
>> >> this is correct, and not even call actOnObjCTypeParamList. OTOH, are
>> >> there cases where `invalid == true` but list is non-empty? If so, are we
>> >> doing the right thing when that happens?
>> >>
>> >>
>> > I'm assuming you meant it should return earlier if this is *incorrect*
>> (but
>> > let me know if I misunderstood your comment).
>>
>> I meant, "If `return invalid ? nullptr : list` is correct, then I
>> suspect returning nullptr before calling actOnObjCTypeParamList makes
>> more sense.
>>
>> > The only downside to returning nullptr before actOnObjCTypeParamList is
>> > called in line 595 is that it won't print the diagnostics that are
>> printed
>> > in actOnObjCTypeParamList. For example, if the following interface were
>> > compiled,
>> >
>> > @interface I1 NSObject
>> > @end
>> >
>> > actOnObjCTypeParamList could tell the user that parameter "T" was
>> > redeclared in addition to printing the error message about __kindof. So
>> if
>> > we return before it's called, we won't see that error message.
>> >
>> > When the interface declaration of category extensions1 in the following
>> > piece of code is compiled, invalid is set to true and the list is not
>> empty
>> > (it contains the first two parameters).
>> >
>> > @interface I1 NSObject
>> > @end
>> >
>> > @interface I1 (extensions1)
>> > @end
>> >
>> > *test3.m:6:23: **error: **expected type parameter name*
>> >
>> > @interface I6 (extensions1)
>> >
>> > *  ^*
>> >
>> > *test3.m:6:21: **error: **category has too few type parameters (expected
>> 3,
>> > have 2)*
>> >
>> > @interface I6 (extensions1)
>> > It looks like it's doing the right thing, but the second diagnostic
>> doesn't
>> > seem necessary to me.
>>
>> I'm not sure I follow exactly which errors are being reported with your
>> patch, so maybe this is already working, but what we basically want is
>> to only emit errors that are helpful.
>>
>> That is, if we get the `"T" is a redeclaration` error as well as the
>> __kindof error, that's nice, but if we get the `too few type parameters`
>> error that's going to be confusing and bad - the user didn't provide too
>> few type parameters, but our previous error caused us to see too few.
>>
>> Basically, we don't ever want to report errors that are the result of
>> previous errors, but as long as we don't end up doing that then
>> gathering further errors is totally reasonable. Make sense?
>>
>>
> Yes, that makes perfect sense.

Thanks for the detailed explanation! This LGTM then.

> The following shows the error messages I see when I compile test case
> test3.m:
>
> $ cat test3.m
>
> #import 
> @interface I2 : NSObject
> @end
>
> @interface I7 : NSObject
> @end
>
> @interface I7(ext2)
> @end
>
> @interface I6 : NSObject
> @end
>
> @interface I6<__kindof I2*>(ext1)
> @end
>
>
> ### This patch: it prints the erro

[libcxx] r255738 - Make noexcept specifications on __hash_table definitions match their declarations.

2015-12-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 15 18:53:04 2015
New Revision: 255738

URL: http://llvm.org/viewvc/llvm-project?rev=255738&view=rev
Log:
Make noexcept specifications on __hash_table definitions match their 
declarations.

Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=255738&r1=255737&r2=255738&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Tue Dec 15 18:53:04 2015
@@ -1143,6 +1143,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 _NOEXCEPT_(
 is_nothrow_default_constructible<__bucket_list>::value &&
 is_nothrow_default_constructible<__first_node>::value &&
+is_nothrow_default_constructible<__node_allocator>::value &&
 is_nothrow_default_constructible::value &&
 is_nothrow_default_constructible::value)
 : __p2_(0),
@@ -1211,6 +1212,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 _NOEXCEPT_(
 is_nothrow_move_constructible<__bucket_list>::value &&
 is_nothrow_move_constructible<__first_node>::value &&
+is_nothrow_move_constructible<__node_allocator>::value &&
 is_nothrow_move_constructible::value &&
 is_nothrow_move_constructible::value)
 : __bucket_list_(_VSTD::move(__u.__bucket_list_)),


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


Re: [PATCH] D15534: [CUDA] renamed cuda_runtime.h wrapper to __clang_cuda_runtime_wrapper.h

2015-12-15 Thread Chandler Carruth via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

The substance of the patch LGTM. My nit picking is just on the wording of the 
comment. =] Submit whenever.



Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:25-26
@@ +24,4 @@
+/*
+ * WARNING: This header is intended to be directly -include'd by
+ * compiler and is not supposed to be included by users.
+ *

"by compiler" -> "by the compiler"


Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:28-29
@@ +27,4 @@
+ *
+ * CUDA headers are implemented in a way that currently makes it
+ * impossible to use them by clang directly. They present different
+ * view of cuda-supplied functions depending on where in nvcc's

You say above that they'll be included by clang directly?

I think instead of "impossible to use them by clang directly" you want to say 
something more along the lines of "impossible for user code to #include 
directly when compiling with clang".


Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:30-34
@@ +29,7 @@
+ * impossible to use them by clang directly. They present different
+ * view of cuda-supplied functions depending on where in nvcc's
+ * compilation pipeline the headers are included from. Neither of
+ * these modes provides function definitions with correct attributes,
+ * so we have to abuse preprocessor in order to shape CUDA headers
+ * into something clang can use.
+ *

I would consistently capitalize "CUDA" when not talking about a particular 
header like cuda_runtime.h, and "Clang" and "NVCC" unless talking about running 
a command.

Some other nits:

"included from" -> "included"

"so we have to abuse preprocessor in order to" -> "so we use the preprocessor 
to"

"shape CUDA headers into something" -> "force the headers into a form that"


http://reviews.llvm.org/D15534



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


r255740 - [CMake] Add support for generating profdata for clang from training files

2015-12-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Dec 15 19:02:44 2015
New Revision: 255740

URL: http://llvm.org/viewvc/llvm-project?rev=255740&view=rev
Log:
[CMake] Add support for generating profdata for clang from training files

Summary:
This patch adds support for using LIT to drive generating PGO profile data for 
clang.

This first pass implementation should work on Linux and Unix based platforms. 
If you build clang using CMake with LLVM_BUILD_INSTRUMENTED=On the CMake build 
generates a generate-profdata target that will use the just-built clang to 
build any test files (see hello_world.cpp as an example). Each test compile 
will generate profraw files for each clang process. After all tests have run 
CMake will merge the profraw files using llvm-profdata.

Future opportunities for extension:
* Support for Build->Profile->Build bootstrapping
* Support for linker order file generation using a similar mechanism and the 
same training data
* Support for Windows

Reviewers: dexonsmith, friss, bogner, cmatthews, vsk, silvas

Subscribers: cfe-commits

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

Added:
cfe/trunk/utils/perf-training/
cfe/trunk/utils/perf-training/CMakeLists.txt
cfe/trunk/utils/perf-training/README.txt
cfe/trunk/utils/perf-training/cxx/
cfe/trunk/utils/perf-training/cxx/hello_world.cpp
cfe/trunk/utils/perf-training/lit.cfg
cfe/trunk/utils/perf-training/lit.site.cfg.in
cfe/trunk/utils/perf-training/perf-helper.py
Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=255740&r1=255739&r2=255740&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Dec 15 19:02:44 2015
@@ -570,6 +570,7 @@ if( CLANG_INCLUDE_TESTS )
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()
+  add_subdirectory(utils/perf-training)
 endif()
 
 option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."

Added: cfe/trunk/utils/perf-training/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=255740&view=auto
==
--- cfe/trunk/utils/perf-training/CMakeLists.txt (added)
+++ cfe/trunk/utils/perf-training/CMakeLists.txt Tue Dec 15 19:02:44 2015
@@ -0,0 +1,36 @@
+if(LLVM_BUILD_INSTRUMENTED)
+  if (CMAKE_CFG_INTDIR STREQUAL ".")
+set(LLVM_BUILD_MODE ".")
+  else ()
+set(LLVM_BUILD_MODE "%(build_mode)s")
+  endif ()
+
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+)
+
+  add_lit_testsuite(generate-profraw "Generating clang PGO data"
+${CMAKE_CURRENT_BINARY_DIR}
+DEPENDS clang clear-profraw
+)
+
+  add_custom_target(clear-profraw
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR}
+COMMENT "Clearing old profraw data")
+
+  if(NOT LLVM_PROFDATA)
+find_program(LLVM_PROFDATA llvm-profdata)
+  endif()
+
+  if(NOT LLVM_PROFDATA)
+message(FATAL_ERROR "Must set LLVM_PROFDATA to point to llvm-profdata to 
use for merging PGO data")
+  endif()
+
+  add_custom_target(generate-profdata
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata 
${CMAKE_CURRENT_BINARY_DIR}
+COMMENT "Merging profdata"
+DEPENDS generate-profraw)
+endif()

Added: cfe/trunk/utils/perf-training/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/README.txt?rev=255740&view=auto
==
--- cfe/trunk/utils/perf-training/README.txt (added)
+++ cfe/trunk/utils/perf-training/README.txt Tue Dec 15 19:02:44 2015
@@ -0,0 +1,6 @@
+==
+ Performance Training Data
+==
+
+This directory contains simple source files for use as training data for
+generating PGO data and linker order files for clang.

Added: cfe/trunk/utils/perf-training/cxx/hello_world.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/cxx/hello_world.cpp?rev=255740&view=auto
==
--- cfe/trunk/utils/perf-training/cxx/hello_world.cpp (added)
+++ cfe/trunk/utils/perf-training/cxx/hello_world.cpp Tue Dec 15 19:02:44 2015
@@ -0,0 +1,7 @@
+// RUN: %clang_cpp -c %s
+#include 
+
+int main(int, char**) {
+  std::cout << "Hello, World!";
+  return 0;
+}

Added: cfe/trunk/utils/perf-training/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/lit.cfg?rev=255740&view=auto
==

Re: [PATCH] D15462: [CMake] Add support for generating profdata for clang from training files

2015-12-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255740: [CMake] Add support for generating profdata for 
clang from training files (authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D15462?vs=42891&id=42943#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15462

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/utils/perf-training/CMakeLists.txt
  cfe/trunk/utils/perf-training/README.txt
  cfe/trunk/utils/perf-training/cxx/hello_world.cpp
  cfe/trunk/utils/perf-training/lit.cfg
  cfe/trunk/utils/perf-training/lit.site.cfg.in
  cfe/trunk/utils/perf-training/perf-helper.py

Index: cfe/trunk/utils/perf-training/perf-helper.py
===
--- cfe/trunk/utils/perf-training/perf-helper.py
+++ cfe/trunk/utils/perf-training/perf-helper.py
@@ -0,0 +1,46 @@
+#===- perf-helper.py - Clang Python Bindings -*- python -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#======#
+
+import sys
+import os
+import subprocess
+
+def findProfrawFiles(path):
+  profraw_files = []
+  for root, dirs, files in os.walk(path): 
+for filename in files:
+  if filename.endswith(".profraw"):
+profraw_files.append(os.path.join(root, filename))
+  return profraw_files
+
+def clean(args):
+  if len(args) != 1:
+print 'Usage: %s clean \n\tRemoves all *.profraw files from .' % __file__
+return 1
+  for profraw in findProfrawFiles(args[0]):
+os.remove(profraw)
+  return 0
+
+def merge(args):
+  if len(args) != 3:
+print 'Usage: %s clean   \n\tMerges all profraw files from path into output.' % __file__
+return 1
+  cmd = [args[0], 'merge', '-o', args[1]]
+  cmd.extend(findProfrawFiles(args[2]))
+  subprocess.check_call(cmd)
+  return 0
+
+commands = {'clean' : clean, 'merge' : merge}
+
+def main():
+  f = commands[sys.argv[1]]
+  sys.exit(f(sys.argv[2:]))
+
+if __name__ == '__main__':
+  main()
Index: cfe/trunk/utils/perf-training/lit.site.cfg.in
===
--- cfe/trunk/utils/perf-training/lit.site.cfg.in
+++ cfe/trunk/utils/perf-training/lit.site.cfg.in
@@ -0,0 +1,20 @@
+import sys
+
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
+config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+
+# Support substitution of the tools and libs dirs with user parameters. This is
+# used when we can't determine the tool dir at configuration time.
+try:
+config.clang_tools_dir = config.clang_tools_dir % lit_config.params
+except KeyError:
+e = sys.exc_info()[1]
+key, = e.args
+lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/lit.cfg")
Index: cfe/trunk/utils/perf-training/CMakeLists.txt
===
--- cfe/trunk/utils/perf-training/CMakeLists.txt
+++ cfe/trunk/utils/perf-training/CMakeLists.txt
@@ -0,0 +1,36 @@
+if(LLVM_BUILD_INSTRUMENTED)
+  if (CMAKE_CFG_INTDIR STREQUAL ".")
+set(LLVM_BUILD_MODE ".")
+  else ()
+set(LLVM_BUILD_MODE "%(build_mode)s")
+  endif ()
+
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+)
+
+  add_lit_testsuite(generate-profraw "Generating clang PGO data"
+${CMAKE_CURRENT_BINARY_DIR}
+DEPENDS clang clear-profraw
+)
+
+  add_custom_target(clear-profraw
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR}
+COMMENT "Clearing old profraw data")
+
+  if(NOT LLVM_PROFDATA)
+find_program(LLVM_PROFDATA llvm-profdata)
+  endif()
+
+  if(NOT LLVM_PROFDATA)
+message(FATAL_ERROR "Must set LLVM_PROFDATA to point to llvm-profdata to use for merging PGO data")
+  endif()
+
+  add_custom_target(generate-profdata
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+COMMENT "Merging profdata"
+DEPENDS generate-profraw)
+endif()
Index: cfe/trunk/utils/perf-training/README.txt
===
--- cfe/trunk/utils/perf-training/README.txt
+++ cfe/trunk/utils/perf-training/README.txt
@@ -0,0 +1,6 @@
+==
+ Performance Training Data
+==
+
+This directory 

Re: [PATCH] D15448: [analyzer] SVal Visitor.

2015-12-15 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Can/Should something like this be used when dumping SVals (during debugging)? 
(Possibly in addition to the debug checker.)
What are the advantages of implementing this using visitors? Can this be 
implemented similarly to SVal::dumpToStream? Do you envision other use cases 
for the visitors?

A couple of suggestions regarding the implementation of the visitors if we 
decide to keep them.
You should either use http://llvm.org/docs/TableGen/ like 
./include/clang/AST/DeclVisitor.h or even better use something similar to 
https://github.com/apple/swift/blob/master/include/swift/AST/ExprNodes.def and 
it's users.



Comment at: include/clang/StaticAnalyzer/Checkers/SValExplainer.h:88
@@ +87,3 @@
+  std::string VisitNonLocLazyCompoundVal(nonloc::LazyCompoundVal V) {
+return "frozen compound value of " + Visit(V.getRegion());
+  }

Using a different name here could lead to confusion.


http://reviews.llvm.org/D15448



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


  1   2   >