r255098 - Reformat linefeeds.

2015-12-08 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Dec  9 01:52:46 2015
New Revision: 255098

URL: http://llvm.org/viewvc/llvm-project?rev=255098&view=rev
Log:
Reformat linefeeds.

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255098&r1=255097&r2=255098&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Dec  9 01:52:46 2015
@@ -285,7 +285,6 @@ CINDEX_LINKAGE unsigned clang_CXIndex_ge
  */
 typedef void *CXFile;
 
-
 /**
  * \brief Retrieve the complete file and path name of the given file.
  */
@@ -705,7 +704,6 @@ CINDEX_LINKAGE unsigned clang_getNumDiag
 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
  unsigned Index);  
 
-
 /**
  * \brief Describes the kind of error that occurred (if any) in a call to
  * \c clang_loadDiagnostics.
@@ -2613,7 +2611,6 @@ CINDEX_LINKAGE enum CXLanguageKind clang
  */
 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
 
-
 /**
  * \brief A fast container representing a set of CXCursors.
  */
@@ -2932,7 +2929,6 @@ enum CXCallingConv {
   CXCallingConv_Unexposed = 200
 };
 
-
 /**
  * \brief The type of an element in the abstract syntax tree.
  *
@@ -3370,7 +3366,6 @@ CINDEX_LINKAGE long long clang_Cursor_ge
  */
 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
 
-
 enum CXRefQualifierKind {
   /** \brief No ref-qualifier was provided. */
   CXRefQualifier_None = 0,
@@ -3499,7 +3494,6 @@ CINDEX_LINKAGE CXCursor clang_getOverloa
  * @{
  */
 
-
 /**
  * \brief For cursors representing an iboutletcollection attribute,
  *  this function returns the collection element type.
@@ -3653,7 +3647,6 @@ CINDEX_LINKAGE CXString
 CINDEX_LINKAGE CXString
   clang_constructUSR_ObjCProtocol(const char *protocol_name);
 
-
 /**
  * \brief Construct a USR for a specified Objective-C instance variable and
  *   the USR for its containing class.
@@ -3779,7 +3772,6 @@ CINDEX_LINKAGE unsigned clang_isCursorDe
  */
 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
 
-
 /**
  * \brief If the cursor points to a selector identifier in an Objective-C
  * method or message expression, this returns the selector index.
@@ -5006,8 +4998,7 @@ enum CXCursorKind clang_codeCompleteGetC
  */
 CINDEX_LINKAGE
 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
-  
-  
+
 /**
  * \brief Returns the currently-entered selector for an Objective-C message
  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
@@ -5026,7 +5017,6 @@ CXString clang_codeCompleteGetObjCSelect
  * @}
  */
 
-
 /**
  * \defgroup CINDEX_MISC Miscellaneous utility functions
  *
@@ -5039,7 +5029,6 @@ CXString clang_codeCompleteGetObjCSelect
  */
 CINDEX_LINKAGE CXString clang_getClangVersion(void);
 
-  
 /**
  * \brief Enable/disable crash recovery.
  *
@@ -5818,7 +5807,6 @@ CINDEX_LINKAGE unsigned clang_Type_visit
CXFieldVisitor visitor,
CXClientData client_data);
 
-
 /**
  * @}
  */
@@ -5831,4 +5819,3 @@ CINDEX_LINKAGE unsigned clang_Type_visit
 }
 #endif
 #endif
-

Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=255098&r1=255097&r2=255098&view=diff
==
--- cfe/trunk/include/clang/Basic/StmtNodes.td (original)
+++ cfe/trunk/include/clang/Basic/StmtNodes.td Wed Dec  9 01:52:46 2015
@@ -221,4 +221,3 @@ def OMPCancellationPointDirective : DStm
 def OMPCancelDirective : DStmt;
 def OMPTaskLoopDirective : DStmt;
 def OMPTaskLoopSimdDirective : DStmt;
-

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=255098&r1=255097&r2=255098&view=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Wed Dec  9 01:52:46 2015
@@ -262,6 +262,7 @@ class OMPClauseProfiler : public ConstOM
   /// \brief Process clauses with list of variables.
   template 
   void VisitOMPClauseList(T *Node);
+
 public:
   OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
 #define OPENMP_CLAUSE(Name, Class) 
\
@@ -1046,7 +1047,6 @@ static Stmt::StmtClass DecodeOperatorCal
 BinaryOp = BO_Comma;
 return Stmt::BinaryOperatorClass;
 
-
   case OO_ArrowStar:
 BinaryOp = BO_PtrMemI;
 return Stmt::BinaryOperatorClass;
@@ -1058,7 +1058,6 @@ static

Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-12-08 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 42267.
RedX2501 added a comment.

Added explicit integer assignment to enum to emphasize api contract behaviour.


http://reviews.llvm.org/D10833

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  include/clang/AST/OperationKinds.h
  test/Index/binop.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3799,6 +3799,11 @@
   return cxstring::createDup(OS.str());
 }
 
+if (C.kind == CXCursor_BinaryOperator ||
+C.kind == CXCursor_CompoundAssignOperator) {
+  return clang_Cursor_getBinaryOpcodeStr(clang_Cursor_getBinaryOpcode(C));
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
@@ -6892,6 +6897,29 @@
   return 0;
 }
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpcode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return CX_BO_Invalid;
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return static_cast(BinOp->getOpcode() + 1);
+	}
+
+	return CX_BO_Invalid;
+}
+
+CXString clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op) {
+	if (Op > CX_BO_LAST) {
+		return cxstring::createEmpty();
+	}
+
+	return cxstring::createDup(
+			BinaryOperator::getOpcodeStr(static_cast(Op - 1)));
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1451,6 +1451,20 @@
   return CXChildVisit_Recurse;
 }
 
+static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
+   CXClientData d){
+  enum CXCursorKind ck = clang_getCursorKind(C);
+  if (ck != CXCursor_BinaryOperator && ck != CXCursor_CompoundAssignOperator)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  enum CX_BinaryOperatorKind bok = clang_Cursor_getBinaryOpcode(C);
+  CXString opstr = clang_Cursor_getBinaryOpcodeStr(bok);
+  printf(" BinOp=%s %d\n", clang_getCString(opstr), bok);
+
+  return CXChildVisit_Recurse;
+}
+
 /**/
 /* Mangling testing.  */
 /**/
@@ -4114,6 +4128,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-binops {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4210,6 +4225,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-binops") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintBinOps, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-mangle") == 0)
 return perform_test_load_tu(argv[2], "all", NULL, PrintMangledName, NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-manglings") == 0)
Index: test/Index/binop.cpp
===
--- /dev/null
+++ test/Index/binop.cpp
@@ -0,0 +1,90 @@
+// RUN: c-index-test -test-print-binops %s | FileCheck %s
+
+struct C {
+  int m;
+};
+
+void func(void){
+	int a, b;
+  int C::* p = &C::m;
+
+	C c;
+	c.*p;
+
+	C* pc;
+	pc->*p;
+
+	a * b;
+	a / b;
+	a % b;
+	a + b;
+	a - b;
+
+	a << b;
+	a >> b;
+
+	a < b;
+	a > b;
+
+	a <= b;
+	a >= b;
+	a == b;
+	a != b;
+	
+	a & b;
+	a ^ b;
+	a | b;
+
+	a && b;
+	a || b;
+
+	a = b;
+
+	a *= b;
+	a /= b;
+	a %= b;
+	a += b;
+	a -= b;
+	
+	a <<= b;
+	a >>= b;
+
+	a &= b;
+	a ^= b;
+	a |= b;
+	a , b;
+
+}
+
+// CHECK: BinaryOperator=.* BinOp=.* 1
+// CHECK: BinaryOperator=->* BinOp=->* 2
+// CHECK: BinaryOperator=* BinOp=* 3
+// CHECK: BinaryOperator=/ BinOp=/ 4
+// CHECK: BinaryOperator=% BinOp=% 5
+// CHECK: BinaryOperator=+ BinOp=+ 6
+// CHECK: BinaryOperator=- BinOp=- 7
+// CHECK: BinaryOperator=<< BinOp=<< 8
+// CHECK: BinaryOperator=>> BinOp=>> 9
+// CHECK: BinaryOperator=< BinOp=< 10
+// CHECK: BinaryOperator=> BinOp=> 11
+// CHECK: BinaryOperator=<= BinOp=<= 12
+// CHECK: BinaryOperator=>= BinOp=>= 13
+// CHECK: BinaryOperator=== BinOp=== 14
+// CHECK: BinaryOperator=!= BinOp=!= 15
+// CHECK: Bina

r255094 - Revert r255001, "Add parse and sema for OpenMP distribute directive and all its clauses excluding dist_schedule."

2015-12-08 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Dec  8 22:35:57 2015
New Revision: 255094

URL: http://llvm.org/viewvc/llvm-project?rev=255094&view=rev
Log:
Revert r255001, "Add parse and sema for OpenMP distribute directive and all its 
clauses excluding dist_schedule."

It causes memory leak. Some tests in test/OpenMP would fail.

Removed:
cfe/trunk/test/OpenMP/distribute_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_collapse_messages.cpp
cfe/trunk/test/OpenMP/distribute_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_private_messages.cpp
Modified:
cfe/trunk/include/clang-c/Index.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/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.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/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
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/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255094&r1=255093&r2=255094&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Dec  8 22:35:57 2015
@@ -2264,11 +2264,7 @@ enum CXCursorKind {
*/
   CXCursor_OMPTaskLoopSimdDirective  = 259,
 
-   /** \brief OpenMP distribute directive.
-   */
-  CXCursor_OMPDistributeDirective= 260,
-
-  CXCursor_LastStmt  = CXCursor_OMPDistributeDirective,
+  CXCursor_LastStmt  = CXCursor_OMPTaskLoopSimdDirective,
 
   /**
* \brief Cursor that represents the translation unit itself.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=255094&r1=255093&r2=255094&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Dec  8 22:35:57 2015
@@ -2439,9 +2439,6 @@ DEF_TRAVERSE_STMT(OMPTaskLoopDirective,
 DEF_TRAVERSE_STMT(OMPTaskLoopSimdDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 
-DEF_TRAVERSE_STMT(OMPDistributeDirective,
-  { TRY_TO(TraverseOMPExecutableDirective(S)); })
-
 // OpenMP clauses.
 template 
 bool RecursiveASTVisitor::TraverseOMPClause(OMPClause *C) {

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=255094&r1=255093&r2=255094&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Dec  8 22:35:57 2015
@@ -424,50 +424,43 @@ protected:
   void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; }
   void setIsLastIterVariable(Expr *IL) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 *std::next(child_begin(), IsLastIterVariableOffset) = IL;
   }
   void setLowerBoundVariable(Expr *LB) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 *std::next(child_begin(), LowerBoundVariableOffset) = LB;
   }
   void setUpperBoundVariable(Expr *UB) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 *std::next(child_begin(), UpperBoundVariableOffset) = UB;
   }
 

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

2015-12-08 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: kcc, pcc.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

Clang-side cross-DSO CFI.
* Enabled with -fsanitize-cfi-cross-dso
* uses a runtime library, unlike "plain" CFI
* does not yet support diagnostics
* Emits __cfi_slowpath calls if bitset test fails. This routes the check to the 
target module, which may know more about the runtime type of the object or 
function.
* Set a module flag to enable __cfi_check generation during LTO.


Repository:
  rL LLVM

http://reviews.llvm.org/D15367

Files:
  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/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  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
===
-

r255091 - [Basic] Rangify two for loops. NFC.

2015-12-08 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Dec  8 19:44:02 2015
New Revision: 255091

URL: http://llvm.org/viewvc/llvm-project?rev=255091&view=rev
Log:
[Basic] Rangify two for loops. NFC.

Modified:
cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=255091&r1=255090&r2=255091&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Dec  8 19:44:02 2015
@@ -59,10 +59,10 @@ FileManager::FileManager(const FileSyste
 }
 
 FileManager::~FileManager() {
-  for (unsigned i = 0, e = VirtualFileEntries.size(); i != e; ++i)
-delete VirtualFileEntries[i];
-  for (unsigned i = 0, e = VirtualDirectoryEntries.size(); i != e; ++i)
-delete VirtualDirectoryEntries[i];
+  for (FileEntry *FE : VirtualFileEntries)
+delete FE;
+  for (DirectoryEntry *DE : VirtualDirectoryEntries)
+delete DE;
 }
 
 void FileManager::addStatCache(std::unique_ptr statCache,


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


[PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2015-12-08 Thread Alexey Samsonov via cfe-commits
samsonov created this revision.
samsonov added reviewers: rsmith, kcc.
samsonov added a subscriber: cfe-commits.

Add the ability to suppress UBSan reports for files/functions/modules
at runtime. The user can now pass UBSAN_OPTIONS=suppressions=supp.txt
with the contents of the form:

signed-integer-overflow:file-with-known-overflow.cpp
alignment:function_doing_unaligned_access
vptr:shared_object_with_vptr_failures.so

Suppression categories match the arguments passed to -fsanitize=
flag (although, see below). There is no overhead if suppressions are
not provided. Otherwise there is extra overhead for symbolization.

Limitations:
1) sometimes suppressions need debug info / symbol table to function
   properly (although sometimes frontend generates enough info to
   do the match).
2) it's only possible to suppress recoverable UB kinds - if you've
   built the code with -fno-sanitize-recover=undefined, suppressions
   will not work.
3) categories are fine-grained check kinds, not groups like "undefined"
   or "integer", so you can't write "undefined:file_with_ub.cc".

http://reviews.llvm.org/D15363

Files:
  lib/sanitizer_common/sanitizer_suppressions.h
  lib/ubsan/ubsan_diag.cc
  lib/ubsan/ubsan_diag.h
  lib/ubsan/ubsan_handlers.cc
  lib/ubsan/ubsan_handlers_cxx.cc
  test/ubsan/TestCases/Integer/suppressions.cpp

Index: test/ubsan/TestCases/Integer/suppressions.cpp
===
--- /dev/null
+++ test/ubsan/TestCases/Integer/suppressions.cpp
@@ -0,0 +1,33 @@
+// RUN: %clangxx -fsanitize=integer -g0 %s -o %t
+
+// Fails without any suppression.
+// RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s
+
+// RUN: echo "signed-integer-overflow:%t" > %t.wrong-supp
+// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.wrong-supp" not %run %t 2>&1 | FileCheck %s
+
+// RUN: echo "unsigned-integer-overflow:do_overflow" > %t.func-supp
+// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.func-supp" %run %t
+// RUN: echo "unsigned-integer-overflow:%t" > %t.module-supp
+// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.module-supp" %run %t
+
+// Note: file-level suppressions should work even without debug info.
+// RUN: echo "unsigned-integer-overflow:%s" > %t.file-supp
+// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.file-supp" %run %t
+
+// Suppressions don't work for unrecoverable kinds.
+// RUN: %clangxx -fsanitize=integer -fno-sanitize-recover=integer %s -o %t-norecover
+// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.module-supp" not %run %t-norecover 2>&1 | FileCheck %s
+
+#include 
+
+extern "C" void do_overflow() {
+  (void)(uint64_t(1000ull) + uint64_t(900ull));
+  // CHECK: runtime error: unsigned integer overflow
+}
+
+int main() {
+  do_overflow();
+  return 0;
+}
+
Index: lib/ubsan/ubsan_handlers_cxx.cc
===
--- lib/ubsan/ubsan_handlers_cxx.cc
+++ lib/ubsan/ubsan_handlers_cxx.cc
@@ -43,10 +43,11 @@
 return false;
 
   SourceLocation Loc = Data->Loc.acquire();
-  if (Loc.isDisabled())
+  ErrorType ET = ErrorType::DynamicTypeMismatch;
+  if (ignoreReport(Loc, Opts, ET))
 return false;
 
-  ScopedReport R(Opts, Loc, ErrorType::DynamicTypeMismatch);
+  ScopedReport R(Opts, Loc, ET);
 
   Diag(Loc, DL_Error,
"%0 address %1 which does not point to an object of type %2")
@@ -89,10 +90,12 @@
 static void HandleCFIBadType(CFIBadTypeData *Data, ValueHandle Vtable,
  ReportOptions Opts) {
   SourceLocation Loc = Data->Loc.acquire();
+  ErrorType ET = ErrorType::CFIBadType;
 
-  if (ignoreReport(Loc, Opts))
+  if (ignoreReport(Loc, Opts, ET))
 return;
-  ScopedReport R(Opts, Loc, ErrorType::CFIBadType);
+
+  ScopedReport R(Opts, Loc, ET);
   DynamicTypeInfo DTI = getDynamicTypeInfoFromVtable((void*)Vtable);
 
   static const char *TypeCheckKinds[] = {
Index: lib/ubsan/ubsan_handlers.cc
===
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -22,7 +22,7 @@
 using namespace __ubsan;
 
 namespace __ubsan {
-bool ignoreReport(SourceLocation SLoc, ReportOptions Opts) {
+bool ignoreReport(SourceLocation SLoc, ReportOptions Opts, ErrorType ET) {
   // We are not allowed to skip error report: if we are in unrecoverable
   // handler, we have to terminate the program right now, and therefore
   // have to print some diagnostic.
@@ -32,7 +32,7 @@
   // thread could have acquired it, but not yet printed the report.
   if (Opts.FromUnrecoverableHandler)
 return false;
-  return SLoc.isDisabled();
+  return SLoc.isDisabled() || IsPCSuppressed(ET, Opts.pc, SLoc.getFilename());
 }
 
 const char *TypeCheckKinds[] = {
@@ -44,15 +44,6 @@
 static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer,
ReportOptions Opts) {
   Location Loc = Data->Loc.acquire();

Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-12-08 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Any more comments on this patch?

Thanks!
Samuel


http://reviews.llvm.org/D12614



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


Re: [PATCH] D9888: [OPENMP] Driver support for OpenMP offloading

2015-12-08 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Any more comments on this patch?

Thanks,
Samuel


http://reviews.llvm.org/D9888



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


Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2015-12-08 Thread Richard Smith via cfe-commits
Ping.

On Mon, Nov 23, 2015 at 6:55 PM, Richard Smith 
wrote:

> Ping.
>
> On Thu, Nov 5, 2015 at 6:32 PM, Richard Smith 
> wrote:
>
>> Ping.
>>
>> On Thu, Oct 29, 2015 at 5:21 PM, Richard Smith 
>> wrote:
>>
>>> Hi,
>>>
>>> The attached patch undoes the revert of r249929, and adds an extension
>>> to allow  (and ) to work properly even in environments
>>> such as iOS where the underlying libc does not provide C++'s const-correct
>>> overloads of strchr and friends.
>>>
>>> This works as follows:
>>>
>>>  * The macro _LIBCPP_PREFERRED_OVERLOAD is, where possible, defined by
>>> <__config> to an attribute that provides the following semantics:
>>>- A function declaration with the attribute declares a different
>>> function from a function declaration without the attribute.
>>>- Overload resolution prefers a function with the attribute over a
>>> function without.
>>>  * For each of the functions that has a "broken" signature in C, if we
>>> don't believe that the C library provided the C++ signatures, and we have a
>>> _LIBCPP_PREFERRED_OVERLOAD, then we add the C++ declarations and mark them
>>> as preferred over the C overloads.
>>>  * The overloads provided in namespace std always exactly match those in
>>> ::.
>>>
>>>
>>> This results in the following changes in cases where the underlying libc
>>> provides the C signature not the C++ one, compared to the status quo:
>>>
>>>
>>> :
>>>
>>>   char *strchr(const char*, int) // #1
>>>   char *strchr(char*, int) // #2
>>>   const char *strchr(const char*, int) // #3
>>>
>>> We used to provide #1 and #2 in namespace std (in ) and only #1
>>> in global namespace (in ).
>>>
>>> For a very old clang or non-clang compiler, we now have only #1 in both
>>> places (note that #2 is essentially useless). This is unlikely to be a
>>> visible change in real code, but it's slightly broken either way and we
>>> can't fix it.
>>>
>>> For newer clang (3.6 onwards?), we now have correct signatures (#2 and
>>> #3) in :: and std (depending on header). Taking address of strchr requires
>>> ~trunk clang (but it didn't work before either, so this is not really a
>>> regression).
>>>
>>>
>>> :
>>>
>>>   wchar_t *wcschr(const wchar_t *, wchar_t) // #1
>>>   const wchar_t *wcschr(const wchar_t *, wchar_t) // #2
>>>   wchar_t *wcschr(wchar_t *, wchar_t) // #3
>>>
>>> We used to provide #1 in global namespace, and #2 and #3 in namespace
>>> std. This broke code that uses 'using namespace std;'.
>>>
>>> For a very old clang or non-clang compiler, we now have #1 in global
>>> namespace and namespace std. This fixes the ambiguity errors, but decreases
>>> const-correctness in this case. On the whole, this seems like an
>>> improvement to me.
>>>
>>> For newer clang, we now have correct signatures (#2 and #3) in :: and
>>> std (depending on header). As above, taking address doesn't work unless
>>> you're using very recent Clang (this is not a regression in ::, but is a
>>> regression in namespace std).
>>>
>>>
>>> To summarize, we previously had ad-hoc, inconsistent, slightly broken
>>> rules for  and , and with this patch we fix the overload
>>> set to give the exact C++ semantics where possible (for all recent versions
>>> of Clang), and otherwise leave the C signatures alone.
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12840: [cfe-dev] Enabling ThreadSanitizer on PPC64(BE/LE) plarforms

2015-12-08 Thread Bill Schmidt via cfe-commits
wschmidt closed this revision.
wschmidt added a comment.

Committed as r255067.


http://reviews.llvm.org/D12840



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


r255067 - [PPC64, TSAN] Enable thread sanitizer for PPC64

2015-12-08 Thread Bill Schmidt via cfe-commits
Author: wschmidt
Date: Tue Dec  8 16:48:02 2015
New Revision: 255067

URL: http://llvm.org/viewvc/llvm-project?rev=255067&view=rev
Log:
[PPC64, TSAN] Enable thread sanitizer for PPC64

Patch by Simone Atzeni.

This enables the -fsanitize=thread flag for PPC64 and PPC64LE.


Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=255067&r1=255066&r2=255067&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Dec  8 16:48:02 2015
@@ -4169,7 +4169,7 @@ SanitizerMask Linux::getSupportedSanitiz
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64 || IsAArch64)
 Res |= SanitizerKind::Memory;


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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2015-12-08 Thread James Robinson via cfe-commits
jamesr added a comment.

Marshall - friendly ping.  If you know a way to test functionality guarded by a 
compile-time flag in the libcxx test suite I'd be happy to wire in tests for 
this, but if that doesn't exist (and I think it does not currently) then I 
think the only way to verify this is by inspection.  Let me know what you'd 
prefer when you get a chance.  Thanks!


http://reviews.llvm.org/D14731



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


r255066 - Objective-C properties: fix bogus use of "isa<>" on a QualType.

2015-12-08 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Dec  8 16:45:17 2015
New Revision: 255066

URL: http://llvm.org/viewvc/llvm-project?rev=255066&view=rev
Log:
Objective-C properties: fix bogus use of "isa<>" on a QualType.

The code used "isa" to check the type and then "getAs" to look through
sugar; we need to look through the sugar when checking, too, otherwise
any kind of sugar (nullability qualifiers in the example; or a
typedef) will thwart this semantic check. Fixes rdar://problem/23804250.


Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=255066&r1=255065&r2=255066&view=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Dec  8 16:45:17 2015
@@ -1372,12 +1372,11 @@ bool Sema::DiagnosePropertyAccessorMisma
   QualType PropertyIvarType = property->getType().getNonReferenceType();
   bool compat = Context.hasSameType(PropertyIvarType, GetterType);
   if (!compat) {
-if (isa(PropertyIvarType) && 
-isa(GetterType))
-  compat =
-Context.canAssignObjCInterfaces(
-  
GetterType->getAs(),
-  
PropertyIvarType->getAs());
+const ObjCObjectPointerType *propertyObjCPtr = nullptr;
+const ObjCObjectPointerType *getterObjCPtr = nullptr;
+if ((propertyObjCPtr = PropertyIvarType->getAs()) 
&& 
+(getterObjCPtr = GetterType->getAs()))
+  compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr);
 else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType) 
   != Compatible) {
   Diag(Loc, diag::error_property_accessor_type)

Modified: cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm?rev=255066&r1=255065&r2=255066&view=diff
==
--- cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm (original)
+++ cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm Tue Dec  8 16:45:17 2015
@@ -18,3 +18,13 @@
 @property (assign) NSObject *prop;
 @end
 
+@interface C : NSObject 
+@end
+
+@interface D
+@property (nonatomic,readonly,nonnull) C *property;
+@end
+
+@interface D ()
+@property (nonatomic, setter=_setProperty:) C *property; // okay
+@end


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


r255065 - Module file extensions: pass a Sema through to the extension writer.

2015-12-08 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Dec  8 16:43:32 2015
New Revision: 255065

URL: http://llvm.org/viewvc/llvm-project?rev=255065&view=rev
Log:
Module file extensions: pass a Sema through to the extension writer.

Module file extensions are likely to need access to
Sema/Preprocessor/ASTContext, and cannot get it through other
sources.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
cfe/trunk/lib/Frontend/TestModuleFileExtension.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=255065&r1=255064&r2=255065&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Dec  8 16:43:32 2015
@@ -551,7 +551,8 @@ private:
   void WriteObjCCategories();
   void WriteLateParsedTemplates(Sema &SemaRef);
   void WriteOptimizePragmaOptions(Sema &SemaRef);
-  void WriteModuleFileExtension(ModuleFileExtensionWriter &Writer);
+  void WriteModuleFileExtension(Sema &SemaRef,
+ModuleFileExtensionWriter &Writer);
 
   unsigned DeclParmVarAbbrev;
   unsigned DeclContextLexicalAbbrev;

Modified: cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleFileExtension.h?rev=255065&r1=255064&r2=255065&view=diff
==
--- cfe/trunk/include/clang/Serialization/ModuleFileExtension.h (original)
+++ cfe/trunk/include/clang/Serialization/ModuleFileExtension.h Tue Dec  8 
16:43:32 2015
@@ -25,7 +25,8 @@ namespace clang {
 
 class ASTReader;
 class ASTWriter;
-
+class Sema;
+  
 namespace serialization {
   class ModuleFile;
 } // end namespace serialization
@@ -79,7 +80,7 @@ public:
   /// The default implementation of this function simply returns the
   /// hash code as given, so the presence/absence of this extension
   /// does not distinguish module files.
-  virtual llvm::hash_code hashExtension(llvm::hash_code Code) const;
+  virtual llvm::hash_code hashExtension(llvm::hash_code c) const;
 
   /// Create a new module file extension writer, which will be
   /// responsible for writing the extension contents into a particular
@@ -120,7 +121,8 @@ public:
   /// Responsible for writing the contents of the extension into the
   /// given stream. All of the contents should be written into custom
   /// records with IDs >= FIRST_EXTENSION_RECORD_ID.
-  virtual void writeExtensionContents(llvm::BitstreamWriter &Stream) = 0;
+  virtual void writeExtensionContents(Sema &SemaRef,
+  llvm::BitstreamWriter &Stream) = 0;
 };
 
 /// Abstract base class that reads a module file extension block from

Modified: cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp?rev=255065&r1=255064&r2=255065&view=diff
==
--- cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp (original)
+++ cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp Tue Dec  8 16:43:32 2015
@@ -19,6 +19,7 @@ using namespace clang::serialization;
 TestModuleFileExtension::Writer::~Writer() { }
 
 void TestModuleFileExtension::Writer::writeExtensionContents(
+   Sema &SemaRef,
llvm::BitstreamWriter &Stream) {
   using namespace llvm;
 

Modified: cfe/trunk/lib/Frontend/TestModuleFileExtension.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TestModuleFileExtension.h?rev=255065&r1=255064&r2=255065&view=diff
==
--- cfe/trunk/lib/Frontend/TestModuleFileExtension.h (original)
+++ cfe/trunk/lib/Frontend/TestModuleFileExtension.h Tue Dec  8 16:43:32 2015
@@ -30,7 +30,8 @@ class TestModuleFileExtension : public M
 Writer(ModuleFileExtension *Ext) : ModuleFileExtensionWriter(Ext) { }
 ~Writer() override;
 
-void writeExtensionContents(llvm::BitstreamWriter &Stream) override;
+void writeExtensionContents(Sema &SemaRef,
+llvm::BitstreamWriter &Stream) override;
   };
 
   class Reader : public ModuleFileExtensionReader {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=255065&r1=255064&r2=255065&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Dec  8 16:43:32 2015
@@ -3880,7 +3880,8 @@ void ASTWriter::

Re: [PATCH] D15095: Accept "-Weverything" in pragma clang diagnostic ...

2015-12-08 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava added a comment.

Please see the comment about getAllDiagnostics



Comment at: lib/Basic/Diagnostic.cpp:251-257
@@ -250,2 +250,9 @@
 SourceLocation Loc) {
+  // Special handling for pragma clang diagnostic ... "-Weverything"
+  // There is no formal group named "everything", so there has to be a special
+  // case for it.
+  if (Group == "everything") {
+   setSeverityForAll(Flavor, Map, Loc);
+   return false;
+  }
   // Get the diagnostics in this group.

rsmith wrote:
> If you want to handle this at the `DiagnosticsEngine` level, please do so 
> consistently: teach `getDiagnosticsInGroup` about this special case too, and 
> remove the now-redundant code in `clang::ProcessWarningOptions`.
> 
> This is not currently setting the `EnableAllWarnings` flag correctly on the 
> `DiagnosticsEngine`.
Hi Richard, There is a problem in teaching getDiagnosticsInGroup this special 
case. 

getDiagnosticsInGroup can get the list from getAllDiagnostics, but that list 
will contain disgnostics that can not be downgraded (or those for which 
isBuiltinWarningOrExtension() is false).

Back in setSeverityForGroup, it is safe to call setSeverityForAll, because it 
checks isBuiltinWarningOrExtension before calling setSeverity, but the loop in 
setSeverityForGroup itself does not have this check. So a simplistic 
getAllDiagnostics for "everything" leads to an assertion failure "Cannot map 
errors into warnings!" in setSeverity.

In fact, ProcessWarningOptions has the same issue because it also calls 
setSeverityForGroup.

So the options are:
1) add isBuiltinWarning... test in the loop in setSeverityForGroup, similar to 
setSeverityForAll
2) have some variant of getAllDiagnostics that returns a trimmed down list.

Please advise.

The other point about EnableAllWarnings: I agree.


Comment at: test/Frontend/Peverything.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+#pragma clang diagnostic error "-Weverything" 

rsmith wrote:
> This test belongs in **test/Preprocessor/pragma_diagnostic.c**.
OK. And I will add push pop tests as well


http://reviews.llvm.org/D15095



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


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

2015-12-08 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

> There's no way to make a flag alias to two flags


Well, at least not with the alias mechanism in the option parser, but David 
pointed out we could expand it manually in MSVCToolChain::TranslateArgs.

Both alternatives are kind of annoying.. I especially don't like the idea of 
iterating over all the flags a bunch of time, so maybe this approach is better. 
lgtm.


http://reviews.llvm.org/D15350



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


Re: [PATCH] D15324: [Sema] Emit warnings when comparing result of a function with `returns_nonnull` to null

2015-12-08 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255058: [Sema] Add warning when comparing nonnull and null 
(authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D15324?vs=42204&id=42221#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15324

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/ScopeInfo.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/nonnull.c

Index: cfe/trunk/include/clang/Sema/ScopeInfo.h
===
--- cfe/trunk/include/clang/Sema/ScopeInfo.h
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h
@@ -164,7 +164,7 @@
   
   /// \brief A list of parameters which have the nonnull attribute and are
   /// modified in the function.
-  llvm::SmallPtrSet  ModifiedNonNullParams;
+  llvm::SmallPtrSet ModifiedNonNullParams;
 
 public:
   /// Represents a simple identification of a weak object.
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2727,7 +2727,7 @@
 "'true'">,
 InGroup;
 def warn_cast_nonnull_to_bool : Warning<
-"nonnull parameter '%0' will evaluate to "
+"nonnull %select{function call|parameter}0 '%1' will evaluate to "
 "'true' on first encounter">,
 InGroup;
 def warn_this_bool_conversion : Warning<
@@ -2742,9 +2742,10 @@
 "comparison of %select{address of|function|array}0 '%1' %select{not |}2"
 "equal to a null pointer is always %select{true|false}2">,
 InGroup;
-def warn_nonnull_parameter_compare : Warning<
-"comparison of nonnull parameter '%0' %select{not |}1"
-"equal to a null pointer is %select{true|false}1 on first encounter">,
+def warn_nonnull_expr_compare : Warning<
+"comparison of nonnull %select{function call|parameter}0 '%1' "
+"%select{not |}2equal to a null pointer is '%select{true|false}2' on first "
+"encounter">,
 InGroup;
 def warn_this_null_compare : Warning<
   "'this' pointer cannot be null in well-defined C++ code; comparison may be "
Index: cfe/trunk/test/Sema/nonnull.c
===
--- cfe/trunk/test/Sema/nonnull.c
+++ cfe/trunk/test/Sema/nonnull.c
@@ -89,7 +89,7 @@
 __attribute__((__nonnull__))
 int evil_nonnull_func(int* pointer, void * pv)
 {
-   if (pointer == NULL) {  // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+   if (pointer == NULL) {  // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is 'false' on first encounter}}
  return 0;
} else {
  return *pointer;
@@ -101,13 +101,13 @@
else
  return *pointer;
 
-   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is 'false' on first encounter}}
 }
 
 void set_param_to_null(int**);
 int another_evil_nonnull_func(int* pointer, char ch, void * pv) __attribute__((nonnull(1, 3)));
 int another_evil_nonnull_func(int* pointer, char ch, void * pv) {
-   if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+   if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is 'false' on first encounter}}
  return 0;
} else {
  return *pointer;
@@ -119,7 +119,7 @@
else
  return *pointer;
 
-   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is 'false' on first encounter}}
 }
 
 extern void *returns_null(void**);
@@ -153,3 +153,17 @@
   if (p) // No warning
 ;
 }
+
+__attribute__((returns_nonnull)) void *returns_nonnull_whee();
+
+void returns_nonnull_warning_tests() {
+  if (returns_nonnull_whee() == NULL) {} // expected-warning {{comparison of nonnull function call 'returns_nonnull_whee()' equal to a null pointer is 'false' on first encounter}}
+
+  if (returns_nonnull_whee() != NULL) {} // expected-warning {{comparison of nonnull function call 'returns_nonnull_whee()' not equal to a null pointer is 'true' on first encounter}}
+
+  if (returns_nonnull_whee()) {} // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+  if (!returns_nonnull_whee()) {} // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+
+  int and_again = !returns_nonnull_whee(); // expected-warning {{n

r255058 - [Sema] Add warning when comparing nonnull and null

2015-12-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Dec  8 16:02:00 2015
New Revision: 255058

URL: http://llvm.org/viewvc/llvm-project?rev=255058&view=rev
Log:
[Sema] Add warning when comparing nonnull and null

Currently, we emit warnings in some cases where nonnull function
parameters are compared against null. This patch extends this support
to warn when comparing the result of `returns_nonnull` functions
against null.

More specifically, we will now warn cases like:

int *foo() __attribute__((returns_nonnull));
int main() {
  if (foo() == NULL) {} // warning: will always evaluate to false
}

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/nonnull.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255058&r1=255057&r2=255058&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec  8 16:02:00 
2015
@@ -2727,7 +2727,7 @@ def warn_impcast_pointer_to_bool : Warni
 "'true'">,
 InGroup;
 def warn_cast_nonnull_to_bool : Warning<
-"nonnull parameter '%0' will evaluate to "
+"nonnull %select{function call|parameter}0 '%1' will evaluate to "
 "'true' on first encounter">,
 InGroup;
 def warn_this_bool_conversion : Warning<
@@ -2742,9 +2742,10 @@ def warn_null_pointer_compare : Warning<
 "comparison of %select{address of|function|array}0 '%1' %select{not |}2"
 "equal to a null pointer is always %select{true|false}2">,
 InGroup;
-def warn_nonnull_parameter_compare : Warning<
-"comparison of nonnull parameter '%0' %select{not |}1"
-"equal to a null pointer is %select{true|false}1 on first encounter">,
+def warn_nonnull_expr_compare : Warning<
+"comparison of nonnull %select{function call|parameter}0 '%1' "
+"%select{not |}2equal to a null pointer is '%select{true|false}2' on first 
"
+"encounter">,
 InGroup;
 def warn_this_null_compare : Warning<
   "'this' pointer cannot be null in well-defined C++ code; comparison may be "

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=255058&r1=255057&r2=255058&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue Dec  8 16:02:00 2015
@@ -164,7 +164,7 @@ public:
   
   /// \brief A list of parameters which have the nonnull attribute and are
   /// modified in the function.
-  llvm::SmallPtrSet  ModifiedNonNullParams;
+  llvm::SmallPtrSet ModifiedNonNullParams;
 
 public:
   /// Represents a simple identification of a weak object.

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=255058&r1=255057&r2=255058&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Dec  8 16:02:00 2015
@@ -1180,8 +1180,7 @@ bool Sema::getFormatStringInfo(const For
 /// Checks if a the given expression evaluates to null.
 ///
 /// \brief Returns true if the value evaluates to null.
-static bool CheckNonNullExpr(Sema &S,
- const Expr *Expr) {
+static bool CheckNonNullExpr(Sema &S, const Expr *Expr) {
   // If the expression has non-null type, it doesn't evaluate to null.
   if (auto nullability
 = Expr->IgnoreImplicit()->getType()->getNullability(S.Context)) {
@@ -7666,6 +7665,26 @@ void Sema::DiagnoseAlwaysNonNullPointer(
 }
   }
 
+  auto ComplainAboutNonnullParamOrCall = [&](bool IsParam) {
+std::string Str;
+llvm::raw_string_ostream S(Str);
+E->printPretty(S, nullptr, getPrintingPolicy());
+unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
+: diag::warn_cast_nonnull_to_bool;
+Diag(E->getExprLoc(), DiagID) << IsParam << S.str()
+  << E->getSourceRange() << Range << IsEqual;
+  };
+
+  // If we have a CallExpr that is tagged with returns_nonnull, we can 
complain.
+  if (auto *Call = dyn_cast(E->IgnoreParenImpCasts())) {
+if (auto *Callee = Call->getDirectCallee()) {
+  if (Callee->hasAttr()) {
+ComplainAboutNonnullParamOrCall(false);
+return;
+  }
+}
+  }
+
   // Expect to find a single Decl.  Skip anything more complicated.
   ValueDecl *D = nullptr;
   if (DeclRefExpr *R = dyn_cast(E)) {
@@ -7677,40 +7696,38 @@ void Sema::DiagnoseAlwaysNonNullPointer(
   // Weak Decls can be null.
   if (!D || D->isWeak())
 return;
-  
+
   // Check for param

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

2015-12-08 Thread Nico Weber via cfe-commits
thakis abandoned this revision.
thakis added a comment.

Forgot to add cfe-commits. I'll abandon this and send it out again.


http://reviews.llvm.org/D15349



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


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

2015-12-08 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
thakis added a subscriber: cfe-commits.

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

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

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2080,7 +2080,7 @@
   /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
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -295,6 +295,7 @@
   HelpText<"Pass the comma separated arguments in  to the assembler">,
   MetaVarName<"">;
 def Wall : Flag<["-"], "Wall">, Group, Flags<[CC1Option]>;
+def WCL4 : Flag<["-"], "WCL4">, Group, Flags<[CC1Option]>;
 def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, 
Flags<[CC1Option]>;
 def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, 
Flags<[CC1Option]>;
 def Wextra : Flag<["-"], "Wextra">, Group, Flags<[CC1Option]>;
Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -119,7 +119,7 @@
 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">, Alias;
 def _SLASH_Wall : CLFlag<"Wall">, HelpText<"Enable -Wall">, Alias;
 def _SLASH_WX : CLFlag<"WX">, HelpText<"Treat warnings as errors">,
   Alias, AliasArgs<["error"]>;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -663,8 +663,11 @@
 // 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">;
 
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -173,9 +173,10 @@
 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
-// RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
+// RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // W1: -Wall
+// W4: -WCL4
 
 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
 // WX: -Werror


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2080,7 +2080,7 @@
   /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
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -295,6 +295,7 @@
   HelpText<"Pass the comma separated arguments in  to the assembler">,
   MetaVarName<"">;
 def Wall : Flag<["-"], "Wall">, Group, Flags<[CC1Option]>;
+def WCL4 : Flag<["-"], "WCL4">, Group, Flags<[CC1Option]>;
 def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, Flags<[CC1Option]>;
 def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Flags<[CC1Option]>;
 def Wextra : Flag<["-"], "Wextra">, Group, Flags

Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.

2015-12-08 Thread Hans Wennborg via cfe-commits
hans added a comment.

Alexey & Chandler: Is there any ongoing communication here?

It would be great if we could resolve this, or at least figure out what the 
status is, before we branch for 3.8 in a month or so.


http://reviews.llvm.org/D13802



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


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Dan Austin via cfe-commits
I don't think super-fine grained control would be required, a per-binary
setting should be sufficient for debugging purposes.

If everyone is ok with it, I'll get a diff up later tonight switching the
flag to fsanitize-merge-traps/fnosanitize-merge-traps

On Tue, Dec 8, 2015 at 1:17 PM Evgeniy Stepanov  wrote:

> eugenis added a comment.
>
> I misunderstood the meaning of -fsanitize-trap, and now I prefer
> -fsanitize-merge-traps for the flag name.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D15208
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Dan Austin via cfe-commits
danielaustin added a comment.

I don't think super-fine grained control would be required, a per-binary
setting should be sufficient for debugging purposes.

If everyone is ok with it, I'll get a diff up later tonight switching the
flag to fsanitize-merge-traps/fnosanitize-merge-traps


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


r255050 - [X86][AVX2] Stripped backend codegen tests

2015-12-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Dec  8 15:16:45 2015
New Revision: 255050

URL: http://llvm.org/viewvc/llvm-project?rev=255050&view=rev
Log:
[X86][AVX2] Stripped backend codegen tests

As discussed on the ml, backend tests need to be put in llvm/test/CodeGen/X86 
as fast-isel tests using IR that is as close to what is generated here as 
possible.

The llvm tests will (re)added in a future commit.

Modified:
cfe/trunk/test/CodeGen/avx2-builtins.c

Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=255050&r1=255049&r2=255050&view=diff
==
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Tue Dec  8 15:16:45 2015
@@ -1,9 +1,5 @@
-// REQUIRES: x86-registered-target
-
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx2 
-emit-llvm -o - -Werror | FileCheck %s
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx2 
-fno-signed-char -emit-llvm -o - -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx2 -S -o 
- -Werror | FileCheck %s --check-prefix=CHECK-ASM
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx2 
-fno-signed-char -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -12,210 +8,172 @@
 
 __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
   // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i8 3)
-  // CHECK-ASM: vmpsadbw $3, %ymm{{.*}}
   return _mm256_mpsadbw_epu8(x, y, 3);
 }
 
 __m256i test_mm256_sad_epu8(__m256i x, __m256i y) {
   // CHECK: @llvm.x86.avx2.psad.bw
-  // CHECK-ASM: vpsadbw %ymm{{.*}}
   return _mm256_sad_epu8(x, y);
 }
 
 __m256i test_mm256_abs_epi8(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.b
-  // CHECK-ASM: vpabsb %ymm{{.*}}
   return _mm256_abs_epi8(a);
 }
 
 __m256i test_mm256_abs_epi16(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.w
-  // CHECK-ASM: vpabsw %ymm{{.*}}
   return _mm256_abs_epi16(a);
 }
 
 __m256i test_mm256_abs_epi32(__m256i a) {
   // CHECK: @llvm.x86.avx2.pabs.d
-  // CHECK-ASM: vpabsd %ymm{{.*}}
   return _mm256_abs_epi32(a);
 }
 
 __m256i test_mm256_packs_epi16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packsswb
-  // CHECK-ASM: vpacksswb %ymm{{.*}}
   return _mm256_packs_epi16(a, b);
 }
 
 __m256i test_mm256_packs_epi32(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packssdw
-  // CHECK-ASM: vpackssdw %ymm{{.*}}
   return _mm256_packs_epi32(a, b);
 }
 
 __m256i test_mm256_packs_epu16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packuswb
-  // CHECK-ASM: vpackuswb %ymm{{.*}}
   return _mm256_packus_epi16(a, b);
 }
 
 __m256i test_mm256_packs_epu32(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.packusdw
-  // CHECK-ASM: vpackusdw %ymm{{.*}}
   return _mm256_packus_epi32(a, b);
 }
 
 __m256i test_mm256_add_epi8(__m256i a, __m256i b) {
   // CHECK: add <32 x i8>
-  // CHECK-ASM: vpaddb %ymm{{.*}}
   return _mm256_add_epi8(a, b);
 }
 
 __m256i test_mm256_add_epi16(__m256i a, __m256i b) {
   // CHECK: add <16 x i16>
-  // CHECK-ASM: vpaddw %ymm{{.*}}
   return _mm256_add_epi16(a, b);
 }
 
 __m256i test_mm256_add_epi32(__m256i a, __m256i b) {
   // CHECK: add <8 x i32>
-  // CHECK-ASM: vpaddd %ymm{{.*}}
   return _mm256_add_epi32(a, b);
 }
 
 __m256i test_mm256_add_epi64(__m256i a, __m256i b) {
   // CHECK: add <4 x i64>
-  // CHECK-ASM: vpaddq {{.*}}, %ymm{{.*}}
   return _mm256_add_epi64(a, b);
 }
 
 __m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.padds.b
-  // CHECK-ASM: vpaddsb %ymm{{.*}}
   return _mm256_adds_epi8(a, b);
 }
 
 __m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.padds.w
-  // CHECK-ASM: vpaddsw %ymm{{.*}}
   return _mm256_adds_epi16(a, b);
 }
 
 __m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.paddus.b
-  // CHECK-ASM: vpaddusb %ymm{{.*}}
   return _mm256_adds_epu8(a, b);
 }
 
 __m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
   // CHECK: @llvm.x86.avx2.paddus.w
-  // CHECK-ASM: vpaddusw %ymm{{.*}}
   return _mm256_adds_epu16(a, b);
 }
 
 __m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
   // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> 

-  // CHECK-ASM: vpalignr $2, %ymm{{.*}}
   return _mm256_alignr_epi8(a, b, 2);
 }
 
 __m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
   // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> zeroinitializer, <32 x 
i32> 
-  // CHECK-ASM: vpsrldq $1, %ymm{{.*}}
   return _mm256_alignr_epi8(a, b, 17);
 }
 
 __m256i test_mm256_sub_epi8(__m256i a, __m256i b) {
   // CHECK: sub <32 x i8>
-  // CHECK-ASM: vpsubb %ymm{{.*}}
   return _mm256_sub_epi8(a, b);
 }
 
 __m256i test_mm256_sub_epi16(__m256i a, __m256i b) {
   // CHECK: sub <16 x i16>
-  // CHECK-ASM: vpsubw %ym

Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

I misunderstood the meaning of -fsanitize-trap, and now I prefer 
-fsanitize-merge-traps for the flag name.


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

That is, I presume it's highly unlikely user will need to have fine-grained 
setup for deciding which UBSan checks should be merged, and which should not. 
So, probably having a single `-fsanitize-merge-traps`  / 
`-fno-sanitize-merge-traps` option would be enough. I'd like to hear other 
opinions, though.

In http://reviews.llvm.org/D15208#305199, @eugenis wrote:

> Better -fsanitize-merge-checks, and it should apply to non-trap checks as 
> well (i.e. SIGILL address should uniquely correspond to the failure source 
> location).


Just to make sure I understand it, you suggest to eventually pass it down to 
ASan/MSan instrumentation passes?


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Dan Austin via cfe-commits
danielaustin added a comment.

I'm not partial to what its called, or where it is. I'm completely ok with
-fsanitize-merge-checks


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Dan Austin via cfe-commits
I'm not partial to what its called, or where it is. I'm completely ok with
-fsanitize-merge-checks

On Tue, Dec 8, 2015 at 1:07 PM Evgeniy Stepanov  wrote:

> eugenis added a comment.
>
> Better -fsanitize-merge-checks, and it should apply to non-trap checks as
> well (i.e. SIGILL address should uniquely correspond to the failure source
> location).
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D15208
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

Better -fsanitize-merge-checks, and it should apply to non-trap checks as well 
(i.e. SIGILL address should uniquely correspond to the failure source location).


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

That is, I presume it's highly unlikely user will need to have fine-grained 
setup for deciding which UBSan checks should be merged, and which should not. 
So, probably having a single `-fsanitize-merge-traps`  / 
`-fno-sanitize-merge-traps` option would be enough. I'd like to hear other 
opinions, though.


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D15208: Patch for inline abort code generation

2015-12-08 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

Sorry for the late response. Ugh, flag naming is hard, and it's far too 
complicated for sanitizers already.

However, I'm opposed to passing this down as `-fsanitize=` option =/. So far 
we're trying to make values of `-fsanitize=` correspond *only* to different 
kinds of checks, not configuration modes. For instance, we've pushed back 
against somewhat similar feature request for CFI: original plan for enabling 
"debug mode" in CFI was to pass "-fsanitize=cfi-diag", but we instead changed 
it to be "-fsanitize=cfi -fno-sanitize-trap=cfi".

And we have three possible configurations: recoverable checks, 
fatal/unrecoverable checks, trapping checks. You need, essentially 
"trapping-but-distinguishable checks". I'm afraid adding fourth configuration 
will make things incomprehensible. `-fsanitize-merge-traps` (true by default)?


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D15324: [Sema] Emit warnings when comparing result of a function with `returns_nonnull` to null

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

Thank you for this, LGTM!



Comment at: lib/Sema/SemaChecking.cpp:7682
@@ +7681,3 @@
+  if (Callee->hasAttr()) {
+ComplainAboutNonnullParamOrCall(false);
+return;

Oops, I didn't notice that the function returns void, sorry about that. I also 
didn't notice that early return here is the correct thing because we're only 
checking one expression at a time within this function.


http://reviews.llvm.org/D15324



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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-12-08 Thread Argyrios Kyrtzidis via cfe-commits
For CX_BinaryOperatorKind please change the enumerators to have an explicit 
integer assignment; this is to emphasize that they are API contract and should 
not change with subsequent changes (someone may inadvertently add a new 
enumerator in the middle which will implicitly change all the subsequent 
enumerators).

Otherwise LGTM.

> On Dec 6, 2015, at 11:45 PM, guibufolo+l...@gmail.com wrote:
> 
> RedX2501 added a comment.
> 
> Ping
> 
> 
> http://reviews.llvm.org/D10833
> 
> 
> 

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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-12-08 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a subscriber: akyrtzi.
akyrtzi added a comment.

For CX_BinaryOperatorKind please change the enumerators to have an explicit 
integer assignment; this is to emphasize that they are API contract and should 
not change with subsequent changes (someone may inadvertently add a new 
enumerator in the middle which will implicitly change all the subsequent 
enumerators).

Otherwise LGTM.


http://reviews.llvm.org/D10833



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


Re: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Richard Smith via cfe-commits
On Tue, Dec 8, 2015 at 11:18 AM, Richard Smith 
wrote:

> On Tue, Dec 8, 2015 at 10:59 AM, Robinson, Paul <
> paul_robin...@playstation.sony.com> wrote:
>
>> Okay, I'll bite:  so what *does* UINT128_MAX actually convert to?
>>
>
> $ echo 'unsigned __int128 max = -1; float f = max;' |
> ~/clang-8/build/bin/clang -x c++ - -emit-llvm -S -o - -O3 | grep @f
> @f = global float undef, align 4
>

And at runtime, on some targets, we use this:


https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/builtins/floatuntisf.c

... which gives a NaN in this case.

*From:* cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] *On Behalf
>> Of *Richard Smith via cfe-commits
>> *Sent:* Tuesday, December 08, 2015 10:52 AM
>> *To:* Joerg Sonnenberger; cfe-commits
>> *Subject:* Re: r254574 - PR17381: Treat undefined behavior during
>> expression evaluation as an unmodeled
>>
>>
>>
>> On Tue, Dec 8, 2015 at 2:13 AM, Joerg Sonnenberger via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> On Mon, Dec 07, 2015 at 01:32:14PM -0800, Richard Smith via cfe-commits
>> wrote:
>> > C11 6.3.1.5/1: "If the value being converted is outside the range of
>> values
>> > that can be represented, the behavior is undefined."
>>
>> The value of 1e100 can be represented as +inf, even if not precisely.
>>
>>
>>
>> Only if +inf is in the range of representable values, which, as already
>> noted, is problematic.
>>
>>
>>
>> This is a bit different from non-IEEE math like VAX, that doesn't have
>> infinities.
>>
>>
>> Joerg
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15324: [Sema] Emit warnings when comparing result of a function with `returns_nonnull` to null

2015-12-08 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/Sema/SemaChecking.cpp:7674
@@ +7673,3 @@
+: diag::warn_cast_nonnull_to_bool;
+Diag(E->getExprLoc(), DiagID) << int(IsParam) << S.str()
+  << E->getSourceRange() << Range << IsEqual;

aaron.ballman wrote:
> No need to cast IsParam to int; the diagnostic builder already does the right 
> thing here.
Neat. Thanks!


Comment at: lib/Sema/SemaChecking.cpp:7682
@@ +7681,3 @@
+  if (Callee->hasAttr())
+return ComplainAboutNonnullParamOrCall(false);
+

aaron.ballman wrote:
> I think this should be:
> ```
> if (Callee->hasAttr() &&
> ComplainAboutNonnullParamOrCall(false))
>   return;
> ```
> Otherwise, we skip out on the rest of the checking in the presence of 
> ReturnsNonNullAttr.
The function this is in returns `void`, not `bool`. I've separated the return 
from the function call in order to hopefully make things a bit more clear. :)


Comment at: lib/Sema/SemaChecking.cpp:7716
@@ -7711,1 +7715,3 @@
+  (AttrNonNull[i] || PV->hasAttr()))
+return ComplainAboutNonnullParamOrCall(true);
   }

aaron.ballman wrote:
> Same here as above. The return should only be on failure.
Separated into two lines, like above.


http://reviews.llvm.org/D15324



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


Re: [PATCH] D15324: [Sema] Emit warnings when comparing result of a function with `returns_nonnull` to null

2015-12-08 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 42204.
george.burgess.iv marked 4 inline comments as done.
george.burgess.iv added a comment.

- Addressed all feedback
- Refactored a loop to make its intent more clear


http://reviews.llvm.org/D15324

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/ScopeInfo.h
  lib/Sema/SemaChecking.cpp
  test/Sema/nonnull.c

Index: test/Sema/nonnull.c
===
--- test/Sema/nonnull.c
+++ test/Sema/nonnull.c
@@ -89,7 +89,7 @@
 __attribute__((__nonnull__))
 int evil_nonnull_func(int* pointer, void * pv)
 {
-   if (pointer == NULL) {  // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+   if (pointer == NULL) {  // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is 'false' on first encounter}}
  return 0;
} else {
  return *pointer;
@@ -101,13 +101,13 @@
else
  return *pointer;
 
-   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is 'false' on first encounter}}
 }
 
 void set_param_to_null(int**);
 int another_evil_nonnull_func(int* pointer, char ch, void * pv) __attribute__((nonnull(1, 3)));
 int another_evil_nonnull_func(int* pointer, char ch, void * pv) {
-   if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+   if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is 'false' on first encounter}}
  return 0;
} else {
  return *pointer;
@@ -119,7 +119,7 @@
else
  return *pointer;
 
-   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is 'false' on first encounter}}
 }
 
 extern void *returns_null(void**);
@@ -153,3 +153,17 @@
   if (p) // No warning
 ;
 }
+
+__attribute__((returns_nonnull)) void *returns_nonnull_whee();
+
+void returns_nonnull_warning_tests() {
+  if (returns_nonnull_whee() == NULL) {} // expected-warning {{comparison of nonnull function call 'returns_nonnull_whee()' equal to a null pointer is 'false' on first encounter}}
+
+  if (returns_nonnull_whee() != NULL) {} // expected-warning {{comparison of nonnull function call 'returns_nonnull_whee()' not equal to a null pointer is 'true' on first encounter}}
+
+  if (returns_nonnull_whee()) {} // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+  if (!returns_nonnull_whee()) {} // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+
+  int and_again = !returns_nonnull_whee(); // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+  and_again = !returns_nonnull_whee(); // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1180,8 +1180,7 @@
 /// Checks if a the given expression evaluates to null.
 ///
 /// \brief Returns true if the value evaluates to null.
-static bool CheckNonNullExpr(Sema &S,
- const Expr *Expr) {
+static bool CheckNonNullExpr(Sema &S, const Expr *Expr) {
   // If the expression has non-null type, it doesn't evaluate to null.
   if (auto nullability
 = Expr->IgnoreImplicit()->getType()->getNullability(S.Context)) {
@@ -7666,6 +7665,26 @@
 }
   }
 
+  auto ComplainAboutNonnullParamOrCall = [&](bool IsParam) {
+std::string Str;
+llvm::raw_string_ostream S(Str);
+E->printPretty(S, nullptr, getPrintingPolicy());
+unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
+: diag::warn_cast_nonnull_to_bool;
+Diag(E->getExprLoc(), DiagID) << IsParam << S.str()
+  << E->getSourceRange() << Range << IsEqual;
+  };
+
+  // If we have a CallExpr that is tagged with returns_nonnull, we can complain.
+  if (auto *Call = dyn_cast(E->IgnoreParenImpCasts())) {
+if (auto *Callee = Call->getDirectCallee()) {
+  if (Callee->hasAttr()) {
+ComplainAboutNonnullParamOrCall(false);
+return;
+  }
+}
+  }
+
   // Expect to find a single Decl.  Skip anything more complicated.
   ValueDecl *D = nullptr;
   if (DeclRefExpr *R = dyn_cast(E)) {
@@ -7677,40 +7696,38 @@
   // Weak Decls can be null.
   if (!D || D->isWeak())
 return;
-  
+
  

Re: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Richard Smith via cfe-commits
On Tue, Dec 8, 2015 at 10:59 AM, Robinson, Paul <
paul_robin...@playstation.sony.com> wrote:

> Okay, I'll bite:  so what *does* UINT128_MAX actually convert to?
>

$ echo 'unsigned __int128 max = -1; float f = max;' |
~/clang-8/build/bin/clang -x c++ - -emit-llvm -S -o - -O3 | grep @f
@f = global float undef, align 4


> *From:* cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] *On
> Behalf Of *Richard Smith via cfe-commits
> *Sent:* Tuesday, December 08, 2015 10:52 AM
> *To:* Joerg Sonnenberger; cfe-commits
> *Subject:* Re: r254574 - PR17381: Treat undefined behavior during
> expression evaluation as an unmodeled
>
>
>
> On Tue, Dec 8, 2015 at 2:13 AM, Joerg Sonnenberger via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> On Mon, Dec 07, 2015 at 01:32:14PM -0800, Richard Smith via cfe-commits
> wrote:
> > C11 6.3.1.5/1: "If the value being converted is outside the range of
> values
> > that can be represented, the behavior is undefined."
>
> The value of 1e100 can be represented as +inf, even if not precisely.
>
>
>
> Only if +inf is in the range of representable values, which, as already
> noted, is problematic.
>
>
>
> This is a bit different from non-IEEE math like VAX, that doesn't have
> infinities.
>
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15338: [Clang] Use autos in lib/AST/ASTContext.cpp

2015-12-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: lib/AST/ASTContext.cpp:429
@@ -432,2 +428,3 @@
+  auto *CFC = new (*this) comments::FullComment(FC->getBlocks(), ThisDeclInfo);
   return CFC;
 }

jroelofs wrote:
> return new ...
Will fix in commit.


Repository:
  rL LLVM

http://reviews.llvm.org/D15338



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


Re: [PATCH] D15338: [Clang] Use autos in lib/AST/ASTContext.cpp

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


Comment at: lib/AST/ASTContext.cpp:299
@@ -299,3 +298,3 @@
 // specialization?
-if (const ClassTemplateSpecializationDecl *CTSD =
+if (const auto *CTSD =
 dyn_cast(CRD)) {

Can this now fit onto one line? If not, I don't think this is an improvement.


Comment at: lib/AST/ASTContext.cpp:2478
@@ -2485,4 +2477,3 @@
 
-  LValueReferenceType *New
-= new (*this, TypeAlignment) LValueReferenceType(T, Canonical,
- SpelledAsLValue);
+  auto *New = new (*this, TypeAlignment)
+LValueReferenceType(T, Canonical, SpelledAsLValue);

I'm not convinced this one is better than the previous incarnation due to the 
type being on a separate line.


Comment at: lib/AST/ASTContext.cpp:2772
@@ -2782,6 +2771,3 @@
   if (!numElements) {
-DependentSizedArrayType *newType
-  = new (*this, TypeAlignment)
-  DependentSizedArrayType(*this, elementType, QualType(),
-  numElements, ASM, elementTypeQuals,
-  brackets);
+auto *newType = new (*this, TypeAlignment)
+  DependentSizedArrayType(*this, elementType, QualType(), numElements, ASM,

Same here.


Comment at: lib/AST/ASTContext.cpp:2816
@@ -2828,5 +2815,3 @@
   // of the element type.
-  DependentSizedArrayType *sugaredType
-= new (*this, TypeAlignment)
-DependentSizedArrayType(*this, elementType, canon, numElements,
-ASM, elementTypeQuals, brackets);
+  auto *sugaredType = new (*this, TypeAlignment)
+DependentSizedArrayType(*this, elementType, canon, numElements, ASM,

And here as well. (I'll stop commenting on these unless I have something new to 
add.)


Comment at: lib/AST/ASTContext.cpp:3270
@@ -3284,3 +3269,3 @@
 
-  SubstTemplateTypeParmPackType *SubstParm
+  auto *SubstParm
 = new (*this, TypeAlignment) SubstTemplateTypeParmPackType(Parm, Canon,

Here as well, but with stronger feelings due to there being no indication of 
initialization until the next line. This applies elsewhere in this patch as 
well.


Repository:
  rL LLVM

http://reviews.llvm.org/D15338



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


RE: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Robinson, Paul via cfe-commits
Okay, I'll bite:  so what *does* UINT128_MAX actually convert to?

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Richard Smith via cfe-commits
Sent: Tuesday, December 08, 2015 10:52 AM
To: Joerg Sonnenberger; cfe-commits
Subject: Re: r254574 - PR17381: Treat undefined behavior during expression 
evaluation as an unmodeled

On Tue, Dec 8, 2015 at 2:13 AM, Joerg Sonnenberger via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
On Mon, Dec 07, 2015 at 01:32:14PM -0800, Richard Smith via cfe-commits wrote:
> C11 6.3.1.5/1: "If the value being converted is outside the 
> range of values
> that can be represented, the behavior is undefined."

The value of 1e100 can be represented as +inf, even if not precisely.

Only if +inf is in the range of representable values, which, as already noted, 
is problematic.

This is a bit different from non-IEEE math like VAX, that doesn't have
infinities.

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

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


Re: [PATCH] D15338: [Clang] Use autos in lib/AST/ASTContext.cpp

2015-12-08 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.


Comment at: lib/AST/ASTContext.cpp:429
@@ -432,2 +428,3 @@
+  auto *CFC = new (*this) comments::FullComment(FC->getBlocks(), ThisDeclInfo);
   return CFC;
 }

return new ...


Repository:
  rL LLVM

http://reviews.llvm.org/D15338



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


Re: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Richard Smith via cfe-commits
On Tue, Dec 8, 2015 at 2:13 AM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Dec 07, 2015 at 01:32:14PM -0800, Richard Smith via cfe-commits
> wrote:
> > C11 6.3.1.5/1: "If the value being converted is outside the range of
> values
> > that can be represented, the behavior is undefined."
>
> The value of 1e100 can be represented as +inf, even if not precisely.
>

Only if +inf is in the range of representable values, which, as already
noted, is problematic.


> This is a bit different from non-IEEE math like VAX, that doesn't have
> infinities.
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255042 - Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp and generated code.

2015-12-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Dec  8 12:49:01 2015
New Revision: 255042

URL: http://llvm.org/viewvc/llvm-project?rev=255042&view=rev
Log:
Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp and generated 
code.

Differential revision: http://reviews.llvm.org/D15313

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=255042&r1=255041&r2=255042&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Dec  8 12:49:01 2015
@@ -619,7 +619,7 @@ namespace {
 std::vector uniques;
 std::set unique_set(enums.begin(), enums.end());
 for (const auto &i : enums) {
-  std::set::iterator set_i = unique_set.find(i);
+  auto set_i = unique_set.find(i);
   if (set_i != unique_set.end()) {
 uniques.push_back(i);
 unique_set.erase(set_i);
@@ -665,8 +665,7 @@ namespace {
   OS << type << " " << getUpperName();
 }
 void writeDeclarations(raw_ostream &OS) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -771,8 +770,7 @@ namespace {
 bool isVariadicEnumArg() const override { return true; }
 
 void writeDeclarations(raw_ostream &OS) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -958,7 +956,7 @@ namespace {
 }
 
 void writeTemplateInstantiation(raw_ostream &OS) const override {
-  OS << "  " << getType() << " *tempInst" << getUpperName()
+  OS << "  auto *tempInst" << getUpperName()
  << " = new (C, 16) " << getType()
  << "[A->" << getLowerName() << "_size()];\n";
   OS << "  {\n";
@@ -1537,7 +1535,7 @@ void EmitClangAttrClass(RecordKeeper &Re
   }
   OS << ", SourceRange Loc = SourceRange()";
   OS << ") {\n";
-  OS << "" << R.getName() << "Attr *A = new (Ctx) " << R.getName();
+  OS << "auto *A = new (Ctx) " << R.getName();
   OS << "Attr(Loc, Ctx, ";
   for (auto const &ai : Args) {
 if (ai->isFake() && !emitFake) continue;
@@ -1654,7 +1652,7 @@ void EmitClangAttrClass(RecordKeeper &Re
 OS << "};\n\n";
   }
 
-  OS << "#endif\n";
+  OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n";
 }
 
 // Emits the class method definitions for attributes.
@@ -1729,7 +1727,7 @@ void EmitClangAttrImpl(RecordKeeper &Rec
 
 static void EmitAttrList(raw_ostream &OS, StringRef Class,
  const std::vector &AttrList) {
-  std::vector::const_iterator i = AttrList.begin(), e = 
AttrList.end();
+  auto i = AttrList.cbegin(), e = AttrList.cend();
 
   if (i != e) {
 // Move the end iterator back to emit the last attribute.
@@ -1881,7 +1879,7 @@ void EmitClangAttrPCHWrite(RecordKeeper
 OS << "  case attr::" << R.getName() << ": {\n";
 Args = R.getValueAsListOfDefs("Args");
 if (R.isSubClassOf(InhClass) || !Args.empty())
-  OS << "const " << R.getName() << "Attr *SA = cast<" << R.getName()
+  OS << "const auto *SA = cast<" << R.getName()
  << "Attr>(A);\n";
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
@@ -2045,9 +2043,7 @@ void EmitClangAttrHasAttrImpl(RecordKeep
   GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
   OS << "case AttrSyntax::CXX: {\n";
   // C++11-style attributes are further split out based on the Scope.
-  for (std::map>::iterator I = CXX.begin(),
-  E = CXX.end();
-   I != E; ++I) {
+  for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) {
 if (I != CXX.begin())
   OS << " else ";
 if (I->first.empty())
@@ -2197,7 +2193,7 @@ void EmitClangAttrTemplateInstantiate(Re
   continue;
 }
 
-OS << "  const " << R.getName() << "Attr *A = cast<"
+OS << "  const auto *A = cast<"
<< R.getName() << "Attr>(At);\n";
 bool TDependent = R.getValueAsBit("TemplateDependent");
 
@@ -2405,7 +2401,7 @@ static std::string GenerateCustomApperta
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomSubjectSet;
-  std::set::iterator I = CustomSubjectSet.find(FnName);
+  auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())
 return *I;
 
@@ -2419,7 +2415,7 @@ static std::string GenerateCustomApperta
   }
 
   OS << "static bool " << FnName << "(const

Re: [PATCH] D15313: [Clang] Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp

2015-12-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255042: Use range loops and autos in 
utils/TableGen/ClangAttrEmitter.cpp and… (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D15313?vs=42192&id=42197#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15313

Files:
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -619,7 +619,7 @@
 std::vector uniques;
 std::set unique_set(enums.begin(), enums.end());
 for (const auto &i : enums) {
-  std::set::iterator set_i = unique_set.find(i);
+  auto set_i = unique_set.find(i);
   if (set_i != unique_set.end()) {
 uniques.push_back(i);
 unique_set.erase(set_i);
@@ -665,8 +665,7 @@
   OS << type << " " << getUpperName();
 }
 void writeDeclarations(raw_ostream &OS) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -771,8 +770,7 @@
 bool isVariadicEnumArg() const override { return true; }
 
 void writeDeclarations(raw_ostream &OS) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -958,7 +956,7 @@
 }
 
 void writeTemplateInstantiation(raw_ostream &OS) const override {
-  OS << "  " << getType() << " *tempInst" << getUpperName()
+  OS << "  auto *tempInst" << getUpperName()
  << " = new (C, 16) " << getType()
  << "[A->" << getLowerName() << "_size()];\n";
   OS << "  {\n";
@@ -1537,7 +1535,7 @@
   }
   OS << ", SourceRange Loc = SourceRange()";
   OS << ") {\n";
-  OS << "" << R.getName() << "Attr *A = new (Ctx) " << R.getName();
+  OS << "auto *A = new (Ctx) " << R.getName();
   OS << "Attr(Loc, Ctx, ";
   for (auto const &ai : Args) {
 if (ai->isFake() && !emitFake) continue;
@@ -1654,7 +1652,7 @@
 OS << "};\n\n";
   }
 
-  OS << "#endif\n";
+  OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n";
 }
 
 // Emits the class method definitions for attributes.
@@ -1729,7 +1727,7 @@
 
 static void EmitAttrList(raw_ostream &OS, StringRef Class,
  const std::vector &AttrList) {
-  std::vector::const_iterator i = AttrList.begin(), e = AttrList.end();
+  auto i = AttrList.cbegin(), e = AttrList.cend();
 
   if (i != e) {
 // Move the end iterator back to emit the last attribute.
@@ -1881,7 +1879,7 @@
 OS << "  case attr::" << R.getName() << ": {\n";
 Args = R.getValueAsListOfDefs("Args");
 if (R.isSubClassOf(InhClass) || !Args.empty())
-  OS << "const " << R.getName() << "Attr *SA = cast<" << R.getName()
+  OS << "const auto *SA = cast<" << R.getName()
  << "Attr>(A);\n";
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
@@ -2045,9 +2043,7 @@
   GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
   OS << "case AttrSyntax::CXX: {\n";
   // C++11-style attributes are further split out based on the Scope.
-  for (std::map>::iterator I = CXX.begin(),
-  E = CXX.end();
-   I != E; ++I) {
+  for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) {
 if (I != CXX.begin())
   OS << " else ";
 if (I->first.empty())
@@ -2197,7 +2193,7 @@
   continue;
 }
 
-OS << "  const " << R.getName() << "Attr *A = cast<"
+OS << "  const auto *A = cast<"
<< R.getName() << "Attr>(At);\n";
 bool TDependent = R.getValueAsBit("TemplateDependent");
 
@@ -2405,7 +2401,7 @@
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomSubjectSet;
-  std::set::iterator I = CustomSubjectSet.find(FnName);
+  auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())
 return *I;
 
@@ -2419,7 +2415,7 @@
   }
 
   OS << "static bool " << FnName << "(const Decl *D) {\n";
-  OS << "  if (const " << GetSubjectWithSuffix(Base) << " *S = dyn_cast<";
+  OS << "  if (const auto *S = dyn_cast<";
   OS << GetSubjectWithSuffix(Base);
   OS << ">(D))\n";
   OS << "return " << Subject.getValueAsString("CheckCode") << ";\n";
@@ -2519,7 +2515,7 @@
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomLangOptsSet;
-  std::set::iterator I = CustomLangOptsSet.find(FnName);
+  auto I = CustomLangOp

Re: [PATCH] D15313: [Clang] Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp

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

LGTM, thank you!


http://reviews.llvm.org/D15313



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


[PATCH] D15338: [Clang] Use autos in lib/AST/ASTContext.cpp

2015-12-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: hans, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

I fixed Clang-tidy modernize-use-auto warnings. Autos are also used for pointer 
variables assigned via casts. Patch includes other minor cleanups.

Build and regressions were fine on RHEL 6.

Repository:
  rL LLVM

http://reviews.llvm.org/D15338

Files:
  lib/AST/ASTContext.cpp

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -80,35 +80,34 @@
 return nullptr;
 
   // User can not attach documentation to implicit instantiations.
-  if (const FunctionDecl *FD = dyn_cast(D)) {
+  if (const auto *FD = dyn_cast(D)) {
 if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return nullptr;
   }
 
-  if (const VarDecl *VD = dyn_cast(D)) {
+  if (const auto *VD = dyn_cast(D)) {
 if (VD->isStaticDataMember() &&
 VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return nullptr;
   }
 
-  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+  if (const auto *CRD = dyn_cast(D)) {
 if (CRD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return nullptr;
   }
 
-  if (const ClassTemplateSpecializationDecl *CTSD =
-  dyn_cast(D)) {
+  if (const auto *CTSD = dyn_cast(D)) {
 TemplateSpecializationKind TSK = CTSD->getSpecializationKind();
 if (TSK == TSK_ImplicitInstantiation ||
 TSK == TSK_Undeclared)
   return nullptr;
   }
 
-  if (const EnumDecl *ED = dyn_cast(D)) {
+  if (const auto *ED = dyn_cast(D)) {
 if (ED->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return nullptr;
   }
-  if (const TagDecl *TD = dyn_cast(D)) {
+  if (const auto *TD = dyn_cast(D)) {
 // When tag declaration (but not definition!) is part of the
 // decl-specifier-seq of some other declaration, it doesn't get comment
 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
@@ -151,7 +150,7 @@
 // declared via a macro. Try using declaration's starting location as
 // the "declaration location".
 DeclLoc = D->getLocStart();
-  } else if (const TagDecl *TD = dyn_cast(D)) {
+  } else if (const auto *TD = dyn_cast(D)) {
 // If location of the tag decl is inside a macro, but the spelling of
 // the tag name comes from a macro argument, it looks like a special
 // macro like NS_ENUM is being used to define the tag decl.  In that
@@ -261,7 +260,7 @@
 /// refer to the actual template.
 /// If we have an implicit instantiation, adjust 'D' to refer to template.
 const Decl *adjustDeclToTemplate(const Decl *D) {
-  if (const FunctionDecl *FD = dyn_cast(D)) {
+  if (const auto *FD = dyn_cast(D)) {
 // Is this function declaration part of a function template?
 if (const FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate())
   return FTD;
@@ -281,7 +280,7 @@
 
 return D;
   }
-  if (const VarDecl *VD = dyn_cast(D)) {
+  if (const auto *VD = dyn_cast(D)) {
 // Static data member is instantiated from a member definition of a class
 // template?
 if (VD->isStaticDataMember())
@@ -290,14 +289,14 @@
 
 return D;
   }
-  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+  if (const auto *CRD = dyn_cast(D)) {
 // Is this class declaration part of a class template?
 if (const ClassTemplateDecl *CTD = CRD->getDescribedClassTemplate())
   return CTD;
 
 // Class is an implicit instantiation of a class template or partial
 // specialization?
-if (const ClassTemplateSpecializationDecl *CTSD =
+if (const auto *CTSD =
 dyn_cast(CRD)) {
   if (CTSD->getSpecializationKind() != TSK_ImplicitInstantiation)
 return D;
@@ -317,7 +316,7 @@
 
 return D;
   }
-  if (const EnumDecl *ED = dyn_cast(D)) {
+  if (const auto *ED = dyn_cast(D)) {
 // Enum is instantiated from a member definition of a class template?
 if (const EnumDecl *MemberDecl = ED->getInstantiatedFromMemberEnum())
   return MemberDecl;
@@ -403,7 +402,7 @@
 static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod,
SmallVectorImpl &Redeclared) {
   const DeclContext *DC = ObjCMethod->getDeclContext();
-  if (const ObjCImplDecl *IMD = dyn_cast(DC)) {
+  if (const auto *IMD = dyn_cast(DC)) {
 const ObjCInterfaceDecl *ID = IMD->getClassInterface();
 if (!ID)
   return;
@@ -419,16 +418,14 @@
 
 comments::FullComment *ASTContext::cloneFullComment(comments::FullComment *FC,
 const Decl *D) const {
-  comments::DeclInfo *ThisDeclInfo = new (*this) comments::DeclInfo;
+  auto *ThisDeclInfo = new (*this) comments::DeclInfo;
   ThisDeclInfo->CommentDecl = D;
   ThisDeclInfo->IsFilled = false;
   ThisDeclInfo->fill();
 

Re: [PATCH] D15313: [Clang] Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp

2015-12-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko removed rL LLVM as the repository for this revision.
Eugene.Zelenko updated this revision to Diff 42192.
Eugene.Zelenko added a comment.

Replaced const auto with auto as suggested by Aaron.


http://reviews.llvm.org/D15313

Files:
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -619,7 +619,7 @@
 std::vector uniques;
 std::set unique_set(enums.begin(), enums.end());
 for (const auto &i : enums) {
-  std::set::iterator set_i = unique_set.find(i);
+  auto set_i = unique_set.find(i);
   if (set_i != unique_set.end()) {
 uniques.push_back(i);
 unique_set.erase(set_i);
@@ -665,8 +665,7 @@
   OS << type << " " << getUpperName();
 }
 void writeDeclarations(raw_ostream &OS) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -771,8 +770,7 @@
 bool isVariadicEnumArg() const override { return true; }
 
 void writeDeclarations(raw_ostream &OS) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -958,7 +956,7 @@
 }
 
 void writeTemplateInstantiation(raw_ostream &OS) const override {
-  OS << "  " << getType() << " *tempInst" << getUpperName()
+  OS << "  auto *tempInst" << getUpperName()
  << " = new (C, 16) " << getType()
  << "[A->" << getLowerName() << "_size()];\n";
   OS << "  {\n";
@@ -1537,7 +1535,7 @@
   }
   OS << ", SourceRange Loc = SourceRange()";
   OS << ") {\n";
-  OS << "" << R.getName() << "Attr *A = new (Ctx) " << R.getName();
+  OS << "auto *A = new (Ctx) " << R.getName();
   OS << "Attr(Loc, Ctx, ";
   for (auto const &ai : Args) {
 if (ai->isFake() && !emitFake) continue;
@@ -1654,7 +1652,7 @@
 OS << "};\n\n";
   }
 
-  OS << "#endif\n";
+  OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n";
 }
 
 // Emits the class method definitions for attributes.
@@ -1729,7 +1727,7 @@
 
 static void EmitAttrList(raw_ostream &OS, StringRef Class,
  const std::vector &AttrList) {
-  std::vector::const_iterator i = AttrList.begin(), e = AttrList.end();
+  auto i = AttrList.cbegin(), e = AttrList.cend();
 
   if (i != e) {
 // Move the end iterator back to emit the last attribute.
@@ -1881,7 +1879,7 @@
 OS << "  case attr::" << R.getName() << ": {\n";
 Args = R.getValueAsListOfDefs("Args");
 if (R.isSubClassOf(InhClass) || !Args.empty())
-  OS << "const " << R.getName() << "Attr *SA = cast<" << R.getName()
+  OS << "const auto *SA = cast<" << R.getName()
  << "Attr>(A);\n";
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
@@ -2045,9 +2043,7 @@
   GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
   OS << "case AttrSyntax::CXX: {\n";
   // C++11-style attributes are further split out based on the Scope.
-  for (std::map>::iterator I = CXX.begin(),
-  E = CXX.end();
-   I != E; ++I) {
+  for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) {
 if (I != CXX.begin())
   OS << " else ";
 if (I->first.empty())
@@ -2197,7 +2193,7 @@
   continue;
 }
 
-OS << "  const " << R.getName() << "Attr *A = cast<"
+OS << "  const auto *A = cast<"
<< R.getName() << "Attr>(At);\n";
 bool TDependent = R.getValueAsBit("TemplateDependent");
 
@@ -2405,7 +2401,7 @@
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomSubjectSet;
-  std::set::iterator I = CustomSubjectSet.find(FnName);
+  auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())
 return *I;
 
@@ -2419,7 +2415,7 @@
   }
 
   OS << "static bool " << FnName << "(const Decl *D) {\n";
-  OS << "  if (const " << GetSubjectWithSuffix(Base) << " *S = dyn_cast<";
+  OS << "  if (const auto *S = dyn_cast<";
   OS << GetSubjectWithSuffix(Base);
   OS << ">(D))\n";
   OS << "return " << Subject.getValueAsString("CheckCode") << ";\n";
@@ -2519,7 +2515,7 @@
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomLangOptsSet;
-  std::set::iterator I = CustomLangOptsSet.find(FnName);
+  auto I = CustomLangOptsSet.find(FnName);
   if (I != CustomLangOptsSet.end())
 return *I;
 
@@ -2582,7 +2578,7 @@
   // If this code has already been gener

Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2015-12-08 Thread Chris Bieneman via cfe-commits
beanz added inline comments.


Comment at: test/Driver/fsanitize.c:221
@@ +220,3 @@
+// RUN: %clang -target x86_64-apple-darwin10 
-resource-dir=%S/Inputs/resource_dir -fsanitize=memory -fsanitize=thread,memory 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-TSAN-MSAN-DARWIN1
+// CHECK-MSAN-TSAN-MSAN-DARWIN1: unsupported option '-fsanitize=thread,memory' 
for target 'x86_64-apple-darwin10'
+// CHECK-MSAN-TSAN-MSAN-DARWIN1-NOT: unsupported option

kubabrecka wrote:
> samsonov wrote:
> > Again, I feel like we're lying to users here: `-fsanitize=thread` *is* 
> > supported for this target, it just requires building a runtime.
> I'd like to see this from the point-of-view of a binary distribution.  If the 
> binary distribution (e.g. the one from llvm.org or Apple's Clang in Xcode) 
> doesn't contain a runtime library, then the sanitizer is *not* supported in 
> that distribution.  Also, see http://reviews.llvm.org/D14846, we'd like to 
> have CMake options to select which runtimes will be built.  If you 
> deliberately choose not to build ThreadSanitizer, then that sanitizer is 
> *not* supported in your version of Clang.  If you're experimenting and 
> porting a runtime to a new platform, then this sanitizer *is* supported in 
> your version of Clang.
Maybe the point is we should have a different error message for cases where the 
runtime is just missing. Something like "runtime components for 
'-fsanitize=thread' not available"


http://reviews.llvm.org/D15225



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


Re: [PATCH] D15174: [MSVC] Fix for http://llvm.org/PR25636: indexed accessor property not supported correctly.

2015-12-08 Thread John McCall via cfe-commits
rjmccall added a comment.

Thanks!



Comment at: lib/Sema/SemaPseudoObject.cpp:249
@@ -248,1 +248,3 @@
+virtual bool useSetterResultAsExprResult(Expr *) const { return false; }
+virtual bool captureSetValueAsResult() const { return true; }
   };

I think you just need one of these.  If useSetterResultAsExprResult() returns 
true, buildAssignmentOperation and buildIncDecOperation should try to capture 
the setter result; otherwise, they should try to capture the set value.  And it 
doesn't need to take an Expr* anymore.

Please add a comment explaining that; something like this:

  /// Should the result of an assignment be the formal result of the setter
  /// call or the value that was passed to the setter?
  ///
  /// Different pseudo-object language features use different language rules 
for this.
  /// The default is to use the set value.  Currently, this affects the 
behavior of simple
  /// assignments, compound assignments, and prefix increment and decrement.
  /// Postfix increment and decrement always use the getter result as the 
expression
  /// result.
  ///
  /// If this method returns false, and the set value isn't capturable for some
  /// reason, the result of the expression will be void.


http://reviews.llvm.org/D15174



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


Re: [PATCH] D15311: [Clang] Use range loops and autos in lib/Serialization/ASTWriter.cpp

2015-12-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255033: Use range loops and autos in 
lib/Serialization/ASTWriter.cpp. (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D15311?vs=42112&id=42190#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15311

Files:
  cfe/trunk/lib/Serialization/ASTWriter.cpp

Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -1,4 +1,4 @@
-//===--- ASTWriter.cpp - AST File Writer --===//
+//===--- ASTWriter.cpp - AST File Writer *- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+
 using namespace clang;
 using namespace clang::serialization;
 
@@ -102,7 +103,7 @@
 #define ABSTRACT_TYPE(Class, Base)
 #include "clang/AST/TypeNodes.def"
   };
-}
+} // end anonymous namespace
 
 void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
   llvm_unreachable("Built-in types are never serialized");
@@ -333,9 +334,8 @@
   Record.push_back(T->isDependentType());
   Writer.AddTemplateName(T->getTemplateName(), Record);
   Record.push_back(T->getNumArgs());
-  for (TemplateSpecializationType::iterator ArgI = T->begin(), ArgE = T->end();
- ArgI != ArgE; ++ArgI)
-Writer.AddTemplateArgument(*ArgI, Record);
+  for (const auto &ArgI : *T)
+Writer.AddTemplateArgument(ArgI, Record);
   Writer.AddTypeRef(T->isTypeAlias() ? T->getAliasedType() :
 T->isCanonicalUnqualified() ? QualType()
 : T->getCanonicalTypeInternal(),
@@ -385,9 +385,8 @@
   Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
   Writer.AddIdentifierRef(T->getIdentifier(), Record);
   Record.push_back(T->getNumArgs());
-  for (DependentTemplateSpecializationType::iterator
- I = T->begin(), E = T->end(); I != E; ++I)
-Writer.AddTemplateArgument(*I, Record);
+  for (const auto &I : *T)
+Writer.AddTemplateArgument(I, Record);
   Code = TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION;
 }
 
@@ -466,7 +465,7 @@
   void VisitFunctionTypeLoc(FunctionTypeLoc TyLoc);
 };
 
-}
+} // end anonymous namespace
 
 void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
@@ -1182,7 +1181,7 @@
   RecordData Record;
   
   // Metadata
-  BitCodeAbbrev *MetadataAbbrev = new BitCodeAbbrev();
+  auto *MetadataAbbrev = new BitCodeAbbrev();
   MetadataAbbrev->Add(BitCodeAbbrevOp(METADATA));
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Major
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Minor
@@ -1215,7 +1214,7 @@
 }
 
 // Module name
-BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+auto *Abbrev = new BitCodeAbbrev();
 Abbrev->Add(BitCodeAbbrevOp(MODULE_NAME));
 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1235,7 +1234,7 @@
  .ModuleMapFileHomeIsCwd ||
 WritingModule->Directory->getName() != StringRef(".")) {
   // Module directory.
-  BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+  auto *Abbrev = new BitCodeAbbrev();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Directory
   unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1319,11 +1318,8 @@
 
   // Comment options.
   Record.push_back(LangOpts.CommentOpts.BlockCommandNames.size());
-  for (CommentOptions::BlockCommandNamesTy::const_iterator
-   I = LangOpts.CommentOpts.BlockCommandNames.begin(),
-   IEnd = LangOpts.CommentOpts.BlockCommandNames.end();
-   I != IEnd; ++I) {
-AddString(*I, Record);
+  for (const auto &I : LangOpts.CommentOpts.BlockCommandNames) {
+AddString(I, Record);
   }
   Record.push_back(LangOpts.CommentOpts.ParseAllComments);
 
@@ -1441,7 +1437,7 @@
   // Original file name and file ID
   SourceManager &SM = Context.getSourceManager();
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-BitCodeAbbrev *FileAbbrev = new BitCodeAbbrev();
+auto *FileAbbrev = new BitCodeAbbrev();
 FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
@@ -1459,7 +1455,7 @@
 
   // Original PCH directory
   if (!OutputFile.empty() && OutputFile != "-") {
-BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+auto *Abbrev = new BitCodeAbbrev();
 Abbrev->Add(BitCodeAbbrevOp(ORIGINAL_PCH_DIR));
 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1488,16 +1484,16 @@
 b

r255033 - Use range loops and autos in lib/Serialization/ASTWriter.cpp.

2015-12-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Dec  8 12:00:11 2015
New Revision: 255033

URL: http://llvm.org/viewvc/llvm-project?rev=255033&view=rev
Log:
Use range loops and autos in lib/Serialization/ASTWriter.cpp.

Differential revision: http://reviews.llvm.org/D15311

Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=255033&r1=255032&r2=255033&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Dec  8 12:00:11 2015
@@ -1,4 +1,4 @@
-//===--- ASTWriter.cpp - AST File Writer 
--===//
+//===--- ASTWriter.cpp - AST File Writer *- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+
 using namespace clang;
 using namespace clang::serialization;
 
@@ -102,7 +103,7 @@ namespace {
 #define ABSTRACT_TYPE(Class, Base)
 #include "clang/AST/TypeNodes.def"
   };
-}
+} // end anonymous namespace
 
 void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
   llvm_unreachable("Built-in types are never serialized");
@@ -333,9 +334,8 @@ ASTTypeWriter::VisitTemplateSpecializati
   Record.push_back(T->isDependentType());
   Writer.AddTemplateName(T->getTemplateName(), Record);
   Record.push_back(T->getNumArgs());
-  for (TemplateSpecializationType::iterator ArgI = T->begin(), ArgE = T->end();
- ArgI != ArgE; ++ArgI)
-Writer.AddTemplateArgument(*ArgI, Record);
+  for (const auto &ArgI : *T)
+Writer.AddTemplateArgument(ArgI, Record);
   Writer.AddTypeRef(T->isTypeAlias() ? T->getAliasedType() :
 T->isCanonicalUnqualified() ? QualType()
 : 
T->getCanonicalTypeInternal(),
@@ -385,9 +385,8 @@ ASTTypeWriter::VisitDependentTemplateSpe
   Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
   Writer.AddIdentifierRef(T->getIdentifier(), Record);
   Record.push_back(T->getNumArgs());
-  for (DependentTemplateSpecializationType::iterator
- I = T->begin(), E = T->end(); I != E; ++I)
-Writer.AddTemplateArgument(*I, Record);
+  for (const auto &I : *T)
+Writer.AddTemplateArgument(I, Record);
   Code = TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION;
 }
 
@@ -466,7 +465,7 @@ public:
   void VisitFunctionTypeLoc(FunctionTypeLoc TyLoc);
 };
 
-}
+} // end anonymous namespace
 
 void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
@@ -1182,7 +1181,7 @@ uint64_t ASTWriter::WriteControlBlock(Pr
   RecordData Record;
   
   // Metadata
-  BitCodeAbbrev *MetadataAbbrev = new BitCodeAbbrev();
+  auto *MetadataAbbrev = new BitCodeAbbrev();
   MetadataAbbrev->Add(BitCodeAbbrevOp(METADATA));
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Major
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Minor
@@ -1215,7 +1214,7 @@ uint64_t ASTWriter::WriteControlBlock(Pr
 }
 
 // Module name
-BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+auto *Abbrev = new BitCodeAbbrev();
 Abbrev->Add(BitCodeAbbrevOp(MODULE_NAME));
 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1235,7 +1234,7 @@ uint64_t ASTWriter::WriteControlBlock(Pr
  .ModuleMapFileHomeIsCwd ||
 WritingModule->Directory->getName() != StringRef(".")) {
   // Module directory.
-  BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+  auto *Abbrev = new BitCodeAbbrev();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Directory
   unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1319,11 +1318,8 @@ uint64_t ASTWriter::WriteControlBlock(Pr
 
   // Comment options.
   Record.push_back(LangOpts.CommentOpts.BlockCommandNames.size());
-  for (CommentOptions::BlockCommandNamesTy::const_iterator
-   I = LangOpts.CommentOpts.BlockCommandNames.begin(),
-   IEnd = LangOpts.CommentOpts.BlockCommandNames.end();
-   I != IEnd; ++I) {
-AddString(*I, Record);
+  for (const auto &I : LangOpts.CommentOpts.BlockCommandNames) {
+AddString(I, Record);
   }
   Record.push_back(LangOpts.CommentOpts.ParseAllComments);
 
@@ -1441,7 +1437,7 @@ uint64_t ASTWriter::WriteControlBlock(Pr
   // Original file name and file ID
   SourceManager &SM = Context.getSourceManager();
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-BitCodeAbbrev *FileAbbrev = new BitCodeAbbrev();
+auto *FileAbbrev = new BitCodeAbbrev();
 FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)

r255029 - Update clang-format-vs README

2015-12-08 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Dec  8 11:54:27 2015
New Revision: 255029

URL: http://llvm.org/viewvc/llvm-project?rev=255029&view=rev
Log:
Update clang-format-vs README

VS2013 is requried after r231084.

Modified:
cfe/trunk/tools/clang-format-vs/README.txt

Modified: cfe/trunk/tools/clang-format-vs/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/README.txt?rev=255029&r1=255028&r2=255029&view=diff
==
--- cfe/trunk/tools/clang-format-vs/README.txt (original)
+++ cfe/trunk/tools/clang-format-vs/README.txt Tue Dec  8 11:54:27 2015
@@ -2,9 +2,10 @@ This directory contains a VSPackage proj
 for clang-format.
 
 Build prerequisites are:
-- Visual Studio 2012 Professional
-- Visual Studio 2010 Professional
-- Visual Studio 2010 SDK.
+- Visual Studio 2013 Professional
+- Visual Studio 2013 SDK
+- Visual Studio 2010 Professional (?)
+- Visual Studio 2010 SDK (?)
 
 The extension is built using CMake by setting BUILD_CLANG_FORMAT_VS_PLUGIN=ON
 when configuring a Clang build, and building the clang_format_vsix target.


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


Re: [PATCH] D15087: [PATCH] Add CERT license clarification

2015-12-08 Thread Daniel Berlin via cfe-commits
dberlin added a comment.

The license  looks fine to me


http://reviews.llvm.org/D15087



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


Re: [PATCH] D15087: [PATCH] Add CERT license clarification

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

Daniel, is the proposed solution fine?


http://reviews.llvm.org/D15087



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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2015-12-08 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:20
@@ +19,3 @@
+void NonConstParameterCheck::registerMatchers(MatchFinder *Finder) {
+  // TODO: This checker doesn't handle C++ to start with. There are problems
+  // for example with parameters to template functions.

I'd prefer the problem to be fixed right away instead of disabling this check 
for C++. The specific issue of parameters of template functions can probably be 
addressed by disabling matches in template instantiations (add 
`unless(isInTemplateInstantiation())` or `unless(isInstantiated())` depending 
on what kind of node is being matched).


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:83
@@ +82,3 @@
+void NonConstParameterCheck::ref(const DeclRefExpr *Ref) {
+  struct ParInfo *PI = getParInfo(Ref->getDecl());
+  if (PI)

Use the `if (T *x = ...) {...}` pattern, please.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:89
@@ +88,3 @@
+struct ParInfo *NonConstParameterCheck::getParInfo(const Decl *D) {
+  for (struct ParInfo &ParamInfo : Params) {
+if (ParamInfo.Par == D)

aaron.ballman wrote:
> This loop can be replaced with std::find_if().
While I agree with similar comments in general, it seems that here it wouldn't 
make the code any better.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:168
@@ +167,3 @@
+  if (auto *Par = dyn_cast(D->getDecl())) {
+struct ParInfo *PI = getParInfo(Par);
+if (PI)

`if (ParInfo *PI = ...) ...`


Comment at: docs/clang-tidy/checks/readability-non-const-parameter.rst:14
@@ +13,3 @@
+  // warning here; p should be const
+  char f1(char *p)
+  {

Let's format the code examples in LLVM style.


Comment at: test/clang-tidy/readability-non-const-parameter.c:211
@@ +210,3 @@
+// avoid fp for const pointer array
+void constPointerArray(const char *remapped[][2])
+{

clang-format?


http://reviews.llvm.org/D15332



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


Re: [PATCH] D15087: [PATCH] Add CERT license clarification

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

Ping


http://reviews.llvm.org/D15087



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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

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


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:43
@@ +42,3 @@
+  Finder->addMatcher(returnStmt().bind("return"), this);
+}
+

I think it may be an improvement to unify all of the matchers that will 
eventually be used to call markCanNotBeConst() from check() into a single 
matcher. e.g.,
```
Finder->addMatcher(
  anyOf(stmt(anyOf(binaryOperator(...), callExpr(), returnStmt(), 
unaryOperator(...))).bind("mark"),
 varDecl(...).bind("mark")), this); 
```
The implementation of check() won't have to change too much, but this reduces 
the number of individual matchers required which I think may be a performance 
win (gut feeling, not based on evidence) and does not reduce clarity.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:48
@@ +47,3 @@
+diagnoseNonConstParameters();
+Params.clear();
+  } else if (auto *Par = Result.Nodes.getNodeAs("par")) {

What will this do with code like:
```
int f(int *p) {
  void g();
  return *p;
}
```
or
```
int f(int *p) {
  struct S {
void g();
  };
  return *p;
}
```


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:63
@@ +62,3 @@
+  } else if (auto *CE = Result.Nodes.getNodeAs("call")) {
+// TODO: Handle function calls better
+for (auto *Arg : CE->arguments()) {

Better how?


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:89
@@ +88,3 @@
+struct ParInfo *NonConstParameterCheck::getParInfo(const Decl *D) {
+  for (struct ParInfo &ParamInfo : Params) {
+if (ParamInfo.Par == D)

This loop can be replaced with std::find_if().


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:124
@@ +123,3 @@
+void NonConstParameterCheck::markCanNotBeConst(const Expr *E, bool Addr) {
+  if (auto *Cast = dyn_cast(E)) {
+// If expression is const then ignore usage.

These should all be const auto * because E is a const Expr *.


Comment at: clang-tidy/readability/NonConstParameterCheck.h:19
@@ +18,3 @@
+
+struct ParInfo {
+  /// Function parameter

I think this struct can be local to NonConstParameterCheck.


Comment at: clang-tidy/readability/NonConstParameterCheck.h:43
@@ +42,3 @@
+private:
+  SmallVector Params;
+  void addPar(const ParmVarDecl *Par);

No need for the struct keyword, here and elsewhere.


Comment at: clang-tidy/readability/NonConstParameterCheck.h:44
@@ +43,3 @@
+  SmallVector Params;
+  void addPar(const ParmVarDecl *Par);
+  void ref(const DeclRefExpr *Ref);

addParm instead of addPar, for clarity?


Comment at: clang-tidy/readability/NonConstParameterCheck.h:45
@@ +44,3 @@
+  void addPar(const ParmVarDecl *Par);
+  void ref(const DeclRefExpr *Ref);
+  void markCanNotBeConst(const Expr *E, bool Addr);

I haven't gotten to the function definition yet, but I have no idea what this 
function would do. ;-) A more clear identifier would be appreciated.


http://reviews.llvm.org/D15332



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-12-08 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 42178.
rmaprath added a comment.

Added a header guard to the `noexcept.h` test support header (review comment by 
@jroelofs).


http://reviews.llvm.org/D14653

Files:
  include/__config
  include/array
  test/std/containers/sequences/array/at.pass.cpp
  test/support/noexcept.h

Index: test/support/noexcept.h
===
--- /dev/null
+++ test/support/noexcept.h
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//===- noexcept.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef NOEXCEPT_H
+#define NOEXCEPT_H
+
+#ifdef _LIBCPP_NO_EXCEPTIONS
+
+#include 
+#include 
+#include "test_macros.h"
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# if TEST_STD_VER >= 11
+#   define TLS_SPEC thread_local
+# elif defined(_LIBCPP_MSVC)
+#   define TLS_SPEC __declspec(thread)
+# else
+#   define TLS_SPEC __thread
+# endif
+#else
+# define TLS_SPEC
+#endif
+
+// Some tests launch multiple threads, in which case we need to make sure that
+// try_buf is maintained per-thread, otherwise setjmp()/longjmp() will attempt
+// to jump between threads!
+TLS_SPEC jmp_buf try_buf;
+#undef TLS_SPEC
+
+// Re-write try/catch with if/else to mimic a similar control flow when testing
+// the no-exceptions library variant. The idea is to save as much of the usual
+// with-exceptions assertions as possible. This of course does not work when
+// there are multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro as appropriate; such cases are rare.
+#define try if(!setjmp(try_buf))
+#define catch(ex) else
+
+// Jump back to the catch (now else) clause.
+void __libcxx_noexceptions_abort(const char *msg) {
+  fprintf(stderr, "%s\n", msg);
+  longjmp(try_buf, 1);
+}
+
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+#endif // NOEXCEPT_H
Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -19,6 +18,7 @@
 #include 
 
 #include "test_macros.h"
+#include "noexcept.h"
 
 // std::array is explicitly allowed to be initialized with A a = { init-list };.
 // Disable the missing braces warning for this reason.
Index: include/array
===
--- include/array
+++ include/array
@@ -201,11 +201,7 @@
 array<_Tp, _Size>::at(size_type __n)
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+   __throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
@@ -215,11 +211,7 @@
 array<_Tp, _Size>::at(size_type __n) const
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -281,7 +281,7 @@
 typedef __char32_t char32_t;
 #endif
 
-#if !(__has_feature(cxx_exceptions))
+#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
@@ -825,6 +825,29 @@
 #define _LIBCPP_HAS_NO_ATOMIC_HEADER
 #endif
 
+#ifdef _LIBCPP_NO_EXCEPTIONS
+void _LIBCPP_WEAK __libcxx_noexceptions_abort(const char *msg);
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+extern "C++" {
+template
+inline void __throw_helper(T t, const char *msg = nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+throw t;
+#else
+if (__libcxx_noexceptions_abort) {
+  if (msg)
+__libcxx_noexceptions_abort(msg);
+  else if (t.what())
+__libcxx_noexceptions_abort(t.what());
+  else
+__libcxx_noexceptions_abort("Exception raised, cannot propagate.\n");
+}
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+}
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Robinson, Paul via cfe-commits
| I've amended this change to permit constant-foldable UB in C variable 
initializers again in r254992.
Works for us, thanks!

| | (2) Shouldn't it diagnose each bad expression in an initializer?
| That change would be unrelated to the one at hand -- this is the way we've 
always behaved.
If it's consistent with past practice, that's fine.
Thanks,
--paulr

From: meta...@gmail.com [mailto:meta...@gmail.com] On Behalf Of Richard Smith
Sent: Monday, December 07, 2015 7:25 PM
To: Robinson, Paul
Cc: cfe-commits (cfe-commits@lists.llvm.org)
Subject: Re: r254574 - PR17381: Treat undefined behavior during expression 
evaluation as an unmodeled

I've amended this change to permit constant-foldable UB in C variable 
initializers again in r254992.

On Mon, Dec 7, 2015 at 6:45 PM, Robinson, Paul via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Two more questions:

(1) Commit message implied this is only for C, but I see it with C++11
(but not C++03).
$ cat t.cpp
enum { foo = 123456 * 234567 };
$ clang -c t.cpp -std=c++03
$ clang -c t.cpp -std=c++11
t.cpp:1:14: error: expression is not an integral constant expression

That is the behavior required by the C++11 standard, but we used to accept GNU 
constant folding here as an extension.



(2) Shouldn't it diagnose each bad expression in an initializer?
I see the error only for the first such expression.

$ cat t.c
int foo[2] = { 123456 * 234567, 654321 * 765432 };
$ clang -c t.c
t.c:1:23: error: initializer element is not a compile-time constant
int foo[2] = { 123456 * 234567, 654321 * 765432 };
   ~~~^~~~

That change would be unrelated to the one at hand -- this is the way we've 
always behaved. Consider for instance:

  int n;
  int foo[2] = { n, n };

If you wanted to make us report the other ones, the relevant code is in 
Expr::isConstantInitializer and Sema::CheckForConstantInitializer.

1 error generated.

Thanks,
--paulr

> -Original Message-
> From: cfe-commits 
> [mailto:cfe-commits-boun...@lists.llvm.org]
>  On Behalf Of
> Richard Smith via cfe-commits
> Sent: Wednesday, December 02, 2015 5:36 PM
> To: cfe-commits@lists.llvm.org
> Subject: r254574 - PR17381: Treat undefined behavior during expression
> evaluation as an unmodeled
>
> Author: rsmith
> Date: Wed Dec  2 19:36:22 2015
> New Revision: 254574
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254574&view=rev
> Log:
> PR17381: Treat undefined behavior during expression evaluation as an
> unmodeled
> side-effect, so that we don't allow speculative evaluation of such
> expressions
> during code generation.
>
> This caused a diagnostic quality regression, so fix constant expression
> diagnostics to prefer either the first "can't be constant folded"
> diagnostic or
> the first "not a constant expression" diagnostic depending on the kind of
> evaluation we're doing. This was always the intent, but didn't quite work
> correctly before.
>
> This results in certain initializers that used to be constant initializers
> to
> no longer be; in particular, things like:
>
>   float f = 1e100;
>
> are no longer accepted in C. This seems appropriate, as such constructs
> would
> lead to code being executed if sanitizers are enabled.
>
> Added:
> cfe/trunk/test/CodeGen/ubsan-conditional.c
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
> cfe/trunk/test/CodeGen/complex-init-list.c
> cfe/trunk/test/PCH/floating-literal.c
> cfe/trunk/test/Sema/const-eval.c
> cfe/trunk/test/Sema/integer-overflow.c
> cfe/trunk/test/Sema/switch-1.c
> cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
> cfe/trunk/test/SemaCXX/constexpr-printing.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=254574&r1=254573&r2=254574&
> view=diff
> ==
> 
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Dec  2 19:36:22 2015
> @@ -473,6 +473,10 @@ namespace {
>  /// notes attached to it will also be stored, otherwise they will not
> be.
>  bool HasActiveDiagnostic;
>
> +/// \brief Have we emitted a diagnostic explaining why we couldn't
> constant
> +/// fold (not just why it's not strictly a constant expression)?
> +bool HasFoldFailureDiagnostic;
> +
>  enum EvaluationMode {
>/// Evaluate as a constant expression. Stop if we find that the
> expression
>/// is not a constant expression.
> @@ -537,7 +541,7 @@ namespace {
>  BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
>  EvaluatingDecl((const ValueDecl *)nullptr),
>  EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
> -EvalMode(Mode) {}
> +HasFoldFa

Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

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


Comment at: test/support/noexcept.h:10
@@ +9,3 @@
+//===--===//
+#ifdef _LIBCPP_NO_EXCEPTIONS
+

You should also add a header guard so that this doesn't get confused with one.


http://reviews.llvm.org/D14653



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-12-08 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 42175.
rmaprath added a comment.

Addressing review comments by @mclow.lists:

Got rid of the `__noexcept` header by moving the `__throw_helper` function into 
the `__config` header. The `__libcxx_noexceptions_abort` function now takes in 
an extra parameter containing the error message.

I removed the default call to `abort()` as it would be unwise (and impossible?) 
to call it from `__config` given its use across many headers. The current 
expectation is that the users of the no-exceptions library need to provide an 
implementation of '__libcxx_noexceptions_abort' if they wish to handle 
exceptional situations occurring within the no-exceptions library, otherwise 
such states will be simply ignored by the library.


http://reviews.llvm.org/D14653

Files:
  include/__config
  include/array
  test/std/containers/sequences/array/at.pass.cpp
  test/support/noexcept.h

Index: test/support/noexcept.h
===
--- /dev/null
+++ test/support/noexcept.h
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===- noexcept.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifdef _LIBCPP_NO_EXCEPTIONS
+
+#include 
+#include 
+#include "test_macros.h"
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# if TEST_STD_VER >= 11
+#   define TLS_SPEC thread_local
+# elif defined(_LIBCPP_MSVC)
+#   define TLS_SPEC __declspec(thread)
+# else
+#   define TLS_SPEC __thread
+# endif
+#else
+# define TLS_SPEC
+#endif
+
+// Some tests launch multiple threads, in which case we need to make sure that
+// try_buf is maintained per-thread, otherwise setjmp()/longjmp() will attempt
+// to jump between threads!
+TLS_SPEC jmp_buf try_buf;
+#undef TLS_SPEC
+
+// Re-write try/catch with if/else to mimic a similar control flow when testing
+// the no-exceptions library variant. The idea is to save as much of the usual
+// with-exceptions assertions as possible. This of course does not work when
+// there are multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro as appropriate; such cases are rare.
+#define try if(!setjmp(try_buf))
+#define catch(ex) else
+
+// Jump back to the catch (now else) clause.
+void __libcxx_noexceptions_abort(const char *msg) {
+  fprintf(stderr, "%s\n", msg);
+  longjmp(try_buf, 1);
+}
+
+#endif // _LIBCPP_NO_EXCEPTIONS
Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -19,6 +18,7 @@
 #include 
 
 #include "test_macros.h"
+#include "noexcept.h"
 
 // std::array is explicitly allowed to be initialized with A a = { init-list };.
 // Disable the missing braces warning for this reason.
Index: include/array
===
--- include/array
+++ include/array
@@ -201,11 +201,7 @@
 array<_Tp, _Size>::at(size_type __n)
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+   __throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
@@ -215,11 +211,7 @@
 array<_Tp, _Size>::at(size_type __n) const
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -281,7 +281,7 @@
 typedef __char32_t char32_t;
 #endif
 
-#if !(__has_feature(cxx_exceptions))
+#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
 #define _LIBCPP_NO_EXCEPTIONS
 #endif
 
@@ -825,6 +825,29 @@
 #define _LIBCPP_HAS_NO_ATOMIC_HEADER
 #endif
 
+#ifdef _LIBCPP_NO_EXCEPTIONS
+void _LIBCPP_WEAK __libcxx_noexceptions_abort(const char *msg);
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+extern "C++" {
+template
+inline void __throw_helper(T t, const char *msg = nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+throw t;
+#else
+if (__libcxx_noexceptions_abort) {
+  if (msg)
+__libcxx_noexceptions_abort(msg);
+  else if (t.what())
+__libcxx_noexceptions_abort(t.what());
+  else
+__libcxx_noexceptions_abort("Exception raised, cannot propagate.\n");
+}
+#e

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

2015-12-08 Thread Chad Rosier via cfe-commits
mcrosier added a comment.

Ping.


http://reviews.llvm.org/D15195



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


Re: [PATCH] D15311: [Clang] Use range loops and autos in lib/Serialization/ASTWriter.cpp

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

LGTM, thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D15311



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


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-12-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki abandoned this revision.
danielmarjamaki added a comment.

I have created a new revision: http://reviews.llvm.org/D15332


http://reviews.llvm.org/D12359



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


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2015-12-08 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Ah ok, I wasn't aware that clang-tidy is not restricted to checks which verify 
stylistic issues.
What makes it more convenient to integrate the checks in clang-tidy?  Is it how 
the AST-Matcher
functionality can be accessed?

> I'm not an expert in the static analyzer code, so I'm not the one to review 
> even AST-based checks there.


The AST-based checks basically use zero functionality from the static analyzer 
codebase
except the entry callback and the functionality to generate bug reports.

> There's nothing that prevents adding more error-detecting checks to 
> clang-tidy.


Wrt. to the checks being part of this patch I have some concerns:

The first problem I see is that some functionlity is shared between the 
AST-based 
and path-sensitive checks. But I think this should be restricted to the 
`MPIFunctionClassifier` class.

Another question I have is how this would affect the usability. At the moment
all detected bugs (AST-based and path-sensitive) appear in a single report,
generated by `scan-build`. Is there still a way to get the results in a single 
report 
if the checks get moved to `clang-tidy`?

Would the implementation need to change to AST-Matcher based?
The point about the current implementation is that the AST-based checks
are also already backed by a range of tests defined in 
`tools/clang/test/Analysis/MPIChecker.cpp`.


http://reviews.llvm.org/D12761



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


[PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2015-12-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added reviewers: alexfh, aaron.ballman, rsmith.
danielmarjamaki added subscribers: cfe-commits, sberg.

This is a new clang-tidy checker that will warn when function parameters should 
be const.

See also related discussions in http://reviews.llvm.org/D12359

As usual, I am testing this checker on the debian projects. I have so far 
triaged 20 warnings from this clang-tidy checker and they were all true 
positives.

http://reviews.llvm.org/D15332

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/NonConstParameterCheck.cpp
  clang-tidy/readability/NonConstParameterCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-non-const-parameter.rst
  test/clang-tidy/readability-non-const-parameter.c

Index: test/clang-tidy/readability-non-const-parameter.c
===
--- test/clang-tidy/readability-non-const-parameter.c
+++ test/clang-tidy/readability-non-const-parameter.c
@@ -0,0 +1,215 @@
+// RUN: %check_clang_tidy %s readability-non-const-parameter %t
+
+// Currently the checker only warns about pointer arguments.
+//
+// It can be defined both that the data is const and that the pointer is const,
+// the checker only checks if the data can be const-specified.
+//
+// It does not warn about pointers to records or function pointers.
+
+// Some external function where first argument is nonconst and second is const.
+char* strcpy1(char *dest, const char *src);
+unsigned my_strcpy(char *buf, const char *s);
+unsigned my_strlen(const char *buf);
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:29: warning: parameter 'last' can be const [readability-non-const-parameter]
+void warn1(int *first, int *last) {
+// CHECK-FIXES: {{^}}void warn1(int *first, const int *last) {{{$}}
+  *first = 0;
+  if (first < last) {} // <- last can be const
+}
+
+// TODO: warning should be written here
+void warn2(char *p) {
+  char buf[10];
+  strcpy1(buf, p);
+}
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const [readability-non-const-parameter]
+void assign1(int *p) {
+// CHECK-FIXES: {{^}}void assign1(const int *p) {{{$}}
+  const int *q;
+  q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const [readability-non-const-parameter]
+void assign2(int *p) {
+// CHECK-FIXES: {{^}}void assign2(const int *p) {{{$}}
+  const int *q;
+  q = p + 1;
+}
+
+void assign3(int *p) {
+  *p = 0;
+}
+
+void assign4(int *p) {
+  *p += 2;
+}
+
+void assign5(char *p) {
+  p[0] = 0;
+}
+
+void assign6(int *p) {
+  int *q;
+  q = p++;
+}
+
+void assign7(char *p) {
+  char *a, *b;
+  a = b = p;
+}
+
+void assign8(char *a, char *b) {
+  char *x;
+  x = (a ? a : b);
+}
+
+void assign9(unsigned char *str, const unsigned int i) {
+  unsigned char *p;
+  for (p = str + i; *p;) {}
+}
+
+void assign10(int *buf) {
+  int i, *p;
+  for (i = 0, p = buf; i<10; i++, p++) {
+*p = 1;
+  }
+}
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const [readability-non-const-parameter]
+void init1(int *p) {
+// CHECK-FIXES: {{^}}void init1(const int *p) {{{$}}
+  const int *q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const [readability-non-const-parameter]
+void init2(int *p) {
+// CHECK-FIXES: {{^}}void init2(const int *p) {{{$}}
+  const int *q = p + 1;
+}
+
+void init3(int *p) {
+  int *q = p;
+}
+
+void init4(float *p) {
+  int *q = (int *)p;
+}
+
+void init5(int *p) {
+  int *i = p ? p : 0;
+}
+
+void init6(int *p) {
+  int *a[] = { p, p, 0 };
+}
+
+void init7(int *p, int x) {
+  for (int *q = p + x - 1; 0; q++);
+}
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const [readability-non-const-parameter]
+int return1(int *p) {
+// CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const [readability-non-const-parameter]
+const int *return2(int *p) {
+// CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const [readability-non-const-parameter]
+const int *return3(int *p) {
+// CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const [readability-non-const-parameter]
+const char *return4(char *p) {
+// CHECK-FIXES: {{^}}const char *return4(const char *p) {{{$}}
+  return p ? p : "";
+}
+
+char *return5(char *s) {
+  return s;
+}
+
+char *return6(char *s) {
+  return s + 1;
+}
+
+char *return7(char *a, char *b) {
+  return a ? a : b;
+}
+
+char return8(int *p) {
+  return ++(*p);
+}
+
+
+void dontwarn1(int *p) {
+  ++(*p);
+}
+
+int dontwarn2(_Atomic(int) *p) {
+  return *p;
+}
+
+
+
+void callFunction1(char *p) {
+  strcpy1(p, "abc");
+}
+
+void callFunction2(char *p) {
+  strcpy

Re: [PATCH] D15324: [Sema] Emit warnings when comparing result of a function with `returns_nonnull` to null

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


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2747
@@ +2746,3 @@
+"comparison of nonnull %select{function call|parameter}0 '%1' "
+"%select{not |}2equal to a null pointer is %select{true|false}2 on first "
+"encounter">,

I know this is existing behavior, but can you quote true and false in this 
diagnostic, similar to the way true is quoted above?


Comment at: lib/Sema/SemaChecking.cpp:7674
@@ +7673,3 @@
+: diag::warn_cast_nonnull_to_bool;
+Diag(E->getExprLoc(), DiagID) << int(IsParam) << S.str()
+  << E->getSourceRange() << Range << IsEqual;

No need to cast IsParam to int; the diagnostic builder already does the right 
thing here.


Comment at: lib/Sema/SemaChecking.cpp:7682
@@ +7681,3 @@
+  if (Callee->hasAttr())
+return ComplainAboutNonnullParamOrCall(false);
+

I think this should be:
```
if (Callee->hasAttr() &&
ComplainAboutNonnullParamOrCall(false))
  return;
```
Otherwise, we skip out on the rest of the checking in the presence of 
ReturnsNonNullAttr.


Comment at: lib/Sema/SemaChecking.cpp:7716
@@ -7711,1 +7715,3 @@
+  (AttrNonNull[i] || PV->hasAttr()))
+return ComplainAboutNonnullParamOrCall(true);
   }

Same here as above. The return should only be on failure.


http://reviews.llvm.org/D15324



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


Re: [PATCH] D15313: [Clang] Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp

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

A few small nits, but mostly looks good. Thank you for this!



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2404
@@ -2407,3 +2403,3 @@
   static std::set CustomSubjectSet;
-  std::set::iterator I = CustomSubjectSet.find(FnName);
+  const auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())

I don't think this is the correct change (a const std::foo::iterator is 
often different than a std::foo::const_iterator). I would drop the const 
since the original is an iterator instead of a const_iterator anyway.


Comment at: utils/TableGen/ClangAttrEmitter.cpp:2518
@@ -2521,3 +2517,3 @@
   static std::set CustomLangOptsSet;
-  std::set::iterator I = CustomLangOptsSet.find(FnName);
+  const auto I = CustomLangOptsSet.find(FnName);
   if (I != CustomLangOptsSet.end())

Same here.


Comment at: utils/TableGen/ClangAttrEmitter.cpp:2581
@@ -2584,3 +2580,3 @@
   static std::set CustomTargetSet;
-  std::set::iterator I = CustomTargetSet.find(FnName);
+  const auto I = CustomTargetSet.find(FnName);
   if (I != CustomTargetSet.end())

And here.


Repository:
  rL LLVM

http://reviews.llvm.org/D15313



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


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

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

Wow, that's a patch with history ;)

My first comment is that the `misc` module mostly consists of checks that are 
safe to turn on by default. This check does not necessarily meet this bar, so 
I'd better move it to `readability`. You could also send a new patch, since the 
concept has totally changed.


http://reviews.llvm.org/D12359



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


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-12-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

In http://reviews.llvm.org/D12359#304772, @danielmarjamaki wrote:

> Moved warning to clang-tidy.
>
> In this patch I am more careful about function calls. Sometimes when it is 
> technically possible to use const it's still not a good idea.
>
> For instance when using the standard strstr C function:
>
>   char * strstr ( const char *, const char * ); 
>   
>   void f(char *p) {  // <- p should not be const
> char *a = strstr(p, "a");
> *a = 0;
>   }


I intend to fix this also later. But I would prefer to commit this checker 
first.

Right now there are not FP.


http://reviews.llvm.org/D12359



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


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-12-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a subscriber: alexfh.
danielmarjamaki added a reviewer: alexfh.
danielmarjamaki added a comment.

Alexander: I add you as reviewer since this was moved to clang-tidy.


http://reviews.llvm.org/D12359



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


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

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

In http://reviews.llvm.org/D12761#304651, @Alexander_Droste wrote:

> @Anna 
>  Thanks for having a look once more! I will submit these parts as separate 
> patches.
>
> @Alexander
>  This should be only about the AST-based checks, as Anna takes care of the 
> path-sensitive ones.
>  I think this is not about moving the checks to clang-tidy because they are 
> not linters but detect
>  errors.


Well, many clang-tidy checks have a close to 100% true positive rate and also 
detect errors of different kinds (as opposed to purely stylistic issues). See 
http://clang.llvm.org/extra/clang-tidy/checks/misc-undelegated-constructor.html 
for an example. There's nothing that prevents adding more error-detecting 
checks to clang-tidy.

I also think, that true power of the static analyzer is the path-based analysis 
capability, but clang-tidy provides a more convenient way to implement AST- or 
preprocessor-based checks, so most of the AST-based checks should live there 
(unless they are generic and high-quality enough to be a compiler diagnostic).

> The AST-based functionality is roughly structured as followed:


I'm not an expert in the static analyzer code, so I'm not the one to review 
even AST-based checks there. However, if you decide to move them to clang-tidy, 
I'll be happy to review that (I suggest introducing a top-level module for 
MPI-related checks and putting all relevant AST-based checks there).

> `MPIChecker.cpp` : This is the entry point class where `checkASTDecl` is the 
> only callback for AST-based

>  checks. There the `TranslationUnitVisitor` is used which traverses the 
> complete TU passed.

>  During the traversal each check is executed in the course of the 
> `VisitCallExpr` callback. 

>  The AST-based checks are implemented in `MPICheckerAST.(cpp|h)`. The 
> `TypeVisitor `, contained

>  in `TypeVisitor.h`, is used as a helper class, in order to detect type 
> properties.

> 

> This patch contains 3 AST-based checks (type mismatch, incorrect buffer 
> referencing, invalid argument type)

>  which are described here in detail (see 3.1 AST-Based Checks) :

>  
> https://dl.acm.org/ft_gateway.cfm?id=2833159&ftid=1644251&dwn=1&CFID=566596797&CFTOKEN=98261226



http://reviews.llvm.org/D12761



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


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-12-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 42164.
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

Moved warning to clang-tidy.

In this patch I am more careful about function calls. Sometimes when it is 
technically possible to use const it's still not a good idea.

For instance when using the standard strstr C function:

  char * strstr ( const char *, const char * ); 
  
  void f(char *p) {  // <- p should not be const
char *a = strstr(p, "a");
*a = 0;
  }


http://reviews.llvm.org/D12359

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/NonConstParameterCheck.cpp
  clang-tidy/misc/NonConstParameterCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-non-const-parameter.rst
  test/clang-tidy/misc-non-const-parameter.c

Index: test/clang-tidy/misc-non-const-parameter.c
===
--- test/clang-tidy/misc-non-const-parameter.c
+++ test/clang-tidy/misc-non-const-parameter.c
@@ -0,0 +1,215 @@
+// RUN: %check_clang_tidy %s misc-non-const-parameter %t
+
+// Currently the -Wnonconst-parameter only warns about pointer arguments.
+//
+// It can be defined both that the data is const and that the pointer is const,
+// the -Wnonconst-parameter only checks if the data can be const-specified.
+//
+// It does not warn about pointers to records or function pointers.
+
+// Some external function where first argument is nonconst and second is const.
+char* strcpy1(char *dest, const char *src);
+unsigned my_strcpy(char *buf, const char *s);
+unsigned my_strlen(const char *buf);
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:29: warning: parameter 'last' can be const [misc-non-const-parameter]
+void warn1(int *first, int *last) {
+// CHECK-FIXES: {{^}}void warn1(int *first, const int *last) {{{$}}
+  *first = 0;
+  if (first < last) {} // <- last can be const
+}
+
+// TODO: warning should be written here
+void warn2(char *p) {
+  char buf[10];
+  strcpy1(buf, p);
+}
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const [misc-non-const-parameter]
+void assign1(int *p) {
+// CHECK-FIXES: {{^}}void assign1(const int *p) {{{$}}
+  const int *q;
+  q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const [misc-non-const-parameter]
+void assign2(int *p) {
+// CHECK-FIXES: {{^}}void assign2(const int *p) {{{$}}
+  const int *q;
+  q = p + 1;
+}
+
+void assign3(int *p) {
+  *p = 0;
+}
+
+void assign4(int *p) {
+  *p += 2;
+}
+
+void assign5(char *p) {
+  p[0] = 0;
+}
+
+void assign6(int *p) {
+  int *q;
+  q = p++;
+}
+
+void assign7(char *p) {
+  char *a, *b;
+  a = b = p;
+}
+
+void assign8(char *a, char *b) {
+  char *x;
+  x = (a ? a : b);
+}
+
+void assign9(unsigned char *str, const unsigned int i) {
+  unsigned char *p;
+  for (p = str + i; *p;) {}
+}
+
+void assign10(int *buf) {
+  int i, *p;
+  for (i = 0, p = buf; i<10; i++, p++) {
+*p = 1;
+  }
+}
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const [misc-non-const-parameter]
+void init1(int *p) {
+// CHECK-FIXES: {{^}}void init1(const int *p) {{{$}}
+  const int *q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const [misc-non-const-parameter]
+void init2(int *p) {
+// CHECK-FIXES: {{^}}void init2(const int *p) {{{$}}
+  const int *q = p + 1;
+}
+
+void init3(int *p) {
+  int *q = p;
+}
+
+void init4(float *p) {
+  int *q = (int *)p;
+}
+
+void init5(int *p) {
+  int *i = p ? p : 0;
+}
+
+void init6(int *p) {
+  int *a[] = { p, p, 0 };
+}
+
+void init7(int *p, int x) {
+  for (int *q = p + x - 1; 0; q++);
+}
+
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const [misc-non-const-parameter]
+int return1(int *p) {
+// CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const [misc-non-const-parameter]
+const int *return2(int *p) {
+// CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const [misc-non-const-parameter]
+const int *return3(int *p) {
+// CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const [misc-non-const-parameter]
+const char *return4(char *p) {
+// CHECK-FIXES: {{^}}const char *return4(const char *p) {{{$}}
+  return p ? p : "";
+}
+
+char *return5(char *s) {
+  return s;
+}
+
+char *return6(char *s) {
+  return s + 1;
+}
+
+char *return7(char *a, char *b) {
+  return a ? a : b;
+}
+
+char return8(int *p) {
+  return ++(*p);
+}
+
+
+void dontwarn1(int *p) {
+  ++(*p);
+}
+
+int dontwarn2(_Atomic(int) *p) {
+  return *p;
+}
+
+
+
+void callFunction1(char *p) {
+  strcpy1(p, "abc");
+}
+
+void callFunction2(char *p) {
+  strcpy1(&p[0], "abc");
+}
+
+void callFunction3(char *p) {
+  strcpy1(p + 2

r255012 - [x86][avx512] more changes in intrinsics to be align with gcc format

2015-12-08 Thread Asaf Badouh via cfe-commits
Author: abadouh
Date: Tue Dec  8 06:34:38 2015
New Revision: 255012

URL: http://llvm.org/viewvc/llvm-project?rev=255012&view=rev
Log:
[x86][avx512] more changes in intrinsics to be align with gcc format

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512erintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=255012&r1=255011&r2=255012&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Dec  8 06:34:38 2015
@@ -921,23 +921,23 @@ BUILTIN(__builtin_ia32_rdtscp, "ULLiUi*"
 // AVX-512
 TARGET_BUILTIN(__builtin_ia32_sqrtpd512_mask, "V8dV8dV8dUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_sqrtps512_mask, "V16fV16fV16fUsIi", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_rsqrt14sd_mask, "V2dV2dV2dV2dUc", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_rsqrt14ss_mask, "V4fV4fV4fV4fUc", "", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_rsqrt14sd, "V2dV2dV2dV2dUc", "", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_rsqrt14ss, "V4fV4fV4fV4fUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_rsqrt14pd512_mask, "V8dV8dV8dUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_rsqrt14ps512_mask, "V16fV16fV16fUs", "", 
"avx512f")
 
-TARGET_BUILTIN(__builtin_ia32_rsqrt28sd_mask, "V2dV2dV2dV2dUcIi", "", 
"avx512er")
-TARGET_BUILTIN(__builtin_ia32_rsqrt28ss_mask, "V4fV4fV4fV4fUcIi", "", 
"avx512er")
+TARGET_BUILTIN(__builtin_ia32_rsqrt28sd_round, "V2dV2dV2dV2dUcIi", "", 
"avx512er")
+TARGET_BUILTIN(__builtin_ia32_rsqrt28ss_round, "V4fV4fV4fV4fUcIi", "", 
"avx512er")
 TARGET_BUILTIN(__builtin_ia32_rsqrt28pd_mask, "V8dV8dV8dUcIi", "", "avx512er")
 TARGET_BUILTIN(__builtin_ia32_rsqrt28ps_mask, "V16fV16fV16fUsIi", "", 
"avx512er")
 
-TARGET_BUILTIN(__builtin_ia32_rcp14sd_mask, "V2dV2dV2dV2dUc", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_rcp14ss_mask, "V4fV4fV4fV4fUc", "", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_rcp14sd, "V2dV2dV2dV2dUc", "", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_rcp14ss, "V4fV4fV4fV4fUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_rcp14pd512_mask, "V8dV8dV8dUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_rcp14ps512_mask, "V16fV16fV16fUs", "", "avx512f")
 
-TARGET_BUILTIN(__builtin_ia32_rcp28sd_mask, "V2dV2dV2dV2dUcIi", "", "avx512er")
-TARGET_BUILTIN(__builtin_ia32_rcp28ss_mask, "V4fV4fV4fV4fUcIi", "", "avx512er")
+TARGET_BUILTIN(__builtin_ia32_rcp28sd_round, "V2dV2dV2dV2dUcIi", "", 
"avx512er")
+TARGET_BUILTIN(__builtin_ia32_rcp28ss_round, "V4fV4fV4fV4fUcIi", "", 
"avx512er")
 TARGET_BUILTIN(__builtin_ia32_rcp28pd_mask, "V8dV8dV8dUcIi", "", "avx512er")
 TARGET_BUILTIN(__builtin_ia32_rcp28ps_mask, "V16fV16fV16fUsIi", "", "avx512er")
 TARGET_BUILTIN(__builtin_ia32_exp2pd_mask, "V8dV8dV8dUcIi", "", "avx512er")

Modified: cfe/trunk/lib/Headers/avx512erintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512erintrin.h?rev=255012&r1=255011&r2=255012&view=diff
==
--- cfe/trunk/lib/Headers/avx512erintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512erintrin.h Tue Dec  8 06:34:38 2015
@@ -126,19 +126,19 @@
   _mm512_maskz_rsqrt28_round_ps((M), (A), _MM_FROUND_CUR_DIRECTION)
 
 #define _mm_rsqrt28_round_ss(A, B, R) __extension__ ({ \
-  (__m128)__builtin_ia32_rsqrt28ss_mask((__v4sf)(__m128)(A), \
+  (__m128)__builtin_ia32_rsqrt28ss_round((__v4sf)(__m128)(A), \
 (__v4sf)(__m128)(B), \
 (__v4sf)_mm_setzero_ps(), \
 (__mmask8)-1, (R)); })
 
 #define _mm_mask_rsqrt28_round_ss(S, M, A, B, R) __extension__ ({ \
-  (__m128)__builtin_ia32_rsqrt28ss_mask((__v4sf)(__m128)(A), \
+  (__m128)__builtin_ia32_rsqrt28ss_round((__v4sf)(__m128)(A), \
 (__v4sf)(__m128)(B), \
 (__v4sf)(__m128)(S), \
 (__mmask8)(M), (R)); })
 
 #define _mm_maskz_rsqrt28_round_ss(M, A, B, R) __extension__ ({ \
-  (__m128)__builtin_ia32_rsqrt28ss_mask((__v4sf)(__m128)(A), \
+  (__m128)__builtin_ia32_rsqrt28ss_round((__v4sf)(__m128)(A), \
 (__v4sf)(__m128)(B), \
 (__v4sf)_mm_setzero_ps(), \
 (__mmask8)(M), (R)); })
@@ -153,19 +153,19 @@
   _mm_maskz_rsqrt28_round_ss((M), (A), (B), _MM_FROUND_CUR_DIRECTION)
 
 #define _mm_rsqrt28_round_sd(A, B, R) __extension__ ({ \
-  (__m128d)__builtin_ia32_rsqrt28sd_mask((__v2df)(__m128d)(A), \
+  (__m128d)__builtin_ia32_rsqrt28sd_round((__v2df)(__m128d)(A), \
   

r255008 - [OPENMP 4.5] Parsing/sema for 'num_tasks' clause.

2015-12-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec  8 06:06:20 2015
New Revision: 255008

URL: http://llvm.org/viewvc/llvm-project?rev=255008&view=rev
Log:
[OPENMP 4.5] Parsing/sema for 'num_tasks' clause.
OpenMP 4.5 adds directives 'taskloop' and 'taskloop simd'. These directives 
support clause 'num_tasks'. Patch adds parsing/semantic analysis for this 
clause.

Added:
cfe/trunk/test/OpenMP/taskloop_num_tasks_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_num_tasks_messages.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.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/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/taskloop_ast_print.cpp
cfe/trunk/test/OpenMP/taskloop_grainsize_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp
cfe/trunk/test/OpenMP/taskloop_simd_grainsize_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=255008&r1=255007&r2=255008&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Dec  8 06:06:20 2015
@@ -2976,6 +2976,58 @@ public:
   }
 };
 
+/// \brief This represents 'num_tasks' clause in the '#pragma omp ...'
+/// directive.
+///
+/// \code
+/// #pragma omp taskloop num_tasks(4)
+/// \endcode
+/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
+/// with single expression '4'.
+///
+class OMPNumTasksClause : public OMPClause {
+  friend class OMPClauseReader;
+  /// \brief Location of '('.
+  SourceLocation LParenLoc;
+  /// \brief Safe iteration space distance.
+  Stmt *NumTasks;
+
+  /// \brief Set safelen.
+  void setNumTasks(Expr *Size) { NumTasks = Size; }
+
+public:
+  /// \brief Build 'num_tasks' clause.
+  ///
+  /// \param Size Expression associated with this clause.
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  ///
+  OMPNumTasksClause(Expr *Size, SourceLocation StartLoc,
+SourceLocation LParenLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc),
+NumTasks(Size) {}
+
+  /// \brief Build an empty clause.
+  ///
+  explicit OMPNumTasksClause()
+  : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()),
+LParenLoc(SourceLocation()), NumTasks(nullptr) {}
+
+  /// \brief Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+  /// \brief Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// \brief Return safe iteration space distance.
+  Expr *getNumTasks() const { return cast_or_null(NumTasks); }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_num_tasks;
+  }
+
+  child_range children() { return child_range(&NumTasks, &NumTasks + 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=255008&r1=255007&r2=255008&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Dec  8 06:06:20 2015
@@ -2765,6 +2765,13 @@ bool RecursiveASTVisitor::Visit
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPNumTasksClause(
+OMPNumTasksClause *C) {
+  TRY_TO(TraverseStmt(C->getNumTasks()));
+  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/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255008&r1=255007&r2=255008&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec  8 06:06:20 
2015
@@ -7927,6 +7927,10 @@ def err_omp_firstprivate_and_lastprivate
   "lastprivate variable cannot be first

Re: [PATCH] D15223: [ARM] [AARCH64] Add CodeGen IR tests for {VS}QRDML{AS}H v8.1a intrinsics.

2015-12-08 Thread Alexandros Lamprineas via cfe-commits
labrinea added inline comments.


Comment at: test/CodeGen/aarch64-v8.1a-neon-intrinsics.c:4
@@ -3,4 +3,3 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon \
-// RUN:  -target-feature +v8.1a -O3 -S -o - %s \
-// RUN:  | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64
+// RUN:  -target-feature +v8.1a -O1 -S -emit-llvm -o - %s | FileCheck %s
 

echristo wrote:
> Why do you need to enable the optimizers?
Our intention with these tests is to check that we are generating a sequence of 
{v/s}qrdmulh, {v/s}q{add/sub}{s}, shufflevector, {insert/extract}element IR 
instructions. Using -O1 promotes memory to registers, combines instructions, 
and therefore decreases the context of IR that we need to check.


http://reviews.llvm.org/D15223



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


Re: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Joerg Sonnenberger via cfe-commits
On Mon, Dec 07, 2015 at 01:32:14PM -0800, Richard Smith via cfe-commits wrote:
> Worse, it seems
> > even using __builtin_nan() for example doesn't work.
> >
> 
> __builtin_nan() works fine for me, can you provide a testcase?

I take this part back, pilot error.

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


Re: r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-08 Thread Joerg Sonnenberger via cfe-commits
On Mon, Dec 07, 2015 at 01:32:14PM -0800, Richard Smith via cfe-commits wrote:
> C11 6.3.1.5/1: "If the value being converted is outside the range of values
> that can be represented, the behavior is undefined."

The value of 1e100 can be represented as +inf, even if not precisely.
This is a bit different from non-IEEE math like VAX, that doesn't have
infinities.

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


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2015-12-08 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

@Anna 
Thanks for having a look once more! I will submit these parts as separate 
patches.

@Alexander
This should be only about the AST-based checks, as Anna takes care of the 
path-sensitive ones.
I think this is not about moving the checks to clang-tidy because they are not 
linters but detect
errors. The AST-based functionality is roughly structured as followed:

`MPIChecker.cpp` : This is the entry point class where `checkASTDecl` is the 
only callback for AST-based
checks. There the `TranslationUnitVisitor` is used which traverses the complete 
TU passed.
During the traversal each check is executed in the course of the 
`VisitCallExpr` callback. 
The AST-based checks are implemented in `MPICheckerAST.(cpp|h)`. The 
`TypeVisitor `, contained
in `TypeVisitor.h`, is used as a helper class, in order to detect type 
properties.

This patch contains 3 AST-based checks (type mismatch, incorrect buffer 
referencing, invalid argument type)
which are described here in detail (see 3.1 AST-Based Checks) :
https://dl.acm.org/ft_gateway.cfm?id=2833159&ftid=1644251&dwn=1&CFID=566596797&CFTOKEN=98261226


http://reviews.llvm.org/D12761



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