r296248 - Weaken test/Profile/c-ternary.c

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Sat Feb 25 01:21:23 2017
New Revision: 296248

URL: http://llvm.org/viewvc/llvm-project?rev=296248=rev
Log:
Weaken test/Profile/c-ternary.c

There is a bot which doesn't use '%1' as the IR name of the first
argument to a function:

http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/2050/steps/test-stage1-compiler/logs/stdio

Modified:
cfe/trunk/test/Profile/c-ternary.c

Modified: cfe/trunk/test/Profile/c-ternary.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-ternary.c?rev=296248=296247=296248=diff
==
--- cfe/trunk/test/Profile/c-ternary.c (original)
+++ cfe/trunk/test/Profile/c-ternary.c Sat Feb 25 01:21:23 2017
@@ -5,7 +5,7 @@
 // condition when the condition evaluates to true.
 // CHECK-LABEL: define i32 @f1
 int f1(int x) {
-// CHECK: [[TOBOOL:%.*]] = icmp ne i32 %1, 0
+// CHECK: [[TOBOOL:%.*]] = icmp ne i32 %{{.*}}, 0
 // CHECK-NEXT: [[STEP:%.*]] = zext i1 [[TOBOOL]] to i64
 // CHECK-NEXT: [[COUNTER:%.*]] = load i64, i64* getelementptr inbounds ([2 x 
i64], [2 x i64]* @__profc_f1, i64 0, i64 1)
 // CHECK-NEXT: add i64 [[COUNTER]], [[STEP]]


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


r296247 - Suppress uninteresting warnings in test/CoverageMapping, NFC.

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Sat Feb 25 01:05:41 2017
New Revision: 296247

URL: http://llvm.org/viewvc/llvm-project?rev=296247=rev
Log:
Suppress uninteresting warnings in test/CoverageMapping, NFC.

Modified:
cfe/trunk/test/CoverageMapping/implicit-def-in-macro.m
cfe/trunk/test/CoverageMapping/macro-expressions.cpp
cfe/trunk/test/CoverageMapping/objc.m

Modified: cfe/trunk/test/CoverageMapping/implicit-def-in-macro.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/implicit-def-in-macro.m?rev=296247=296246=296247=diff
==
--- cfe/trunk/test/CoverageMapping/implicit-def-in-macro.m (original)
+++ cfe/trunk/test/CoverageMapping/implicit-def-in-macro.m Sat Feb 25 01:05:41 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin 
-fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin 
-fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc -w %s | FileCheck %s
 
 @interface Foo
 @end

Modified: cfe/trunk/test/CoverageMapping/macro-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/macro-expressions.cpp?rev=296247=296246=296247=diff
==
--- cfe/trunk/test/CoverageMapping/macro-expressions.cpp (original)
+++ cfe/trunk/test/CoverageMapping/macro-expressions.cpp Sat Feb 25 01:05:41 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp %s 
| FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp -w 
%s | FileCheck %s
 
 #define EXPR(x) (x)
 #define NEXPR(x) (!x)

Modified: cfe/trunk/test/CoverageMapping/objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/objc.m?rev=296247=296246=296247=diff
==
--- cfe/trunk/test/CoverageMapping/objc.m (original)
+++ cfe/trunk/test/CoverageMapping/objc.m Sat Feb 25 01:05:41 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple 
x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple 
x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -w %s | FileCheck %s
 
 @interface A
 - (void)bork:(int)msg;


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


r296246 - Fix -Wparentheses warning

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Sat Feb 25 00:47:00 2017
New Revision: 296246

URL: http://llvm.org/viewvc/llvm-project?rev=296246=rev
Log:
Fix -Wparentheses warning

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

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296246=296245=296246=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Feb 25 00:47:00 2017
@@ -81,8 +81,8 @@ static bool IsWidenedIntegerOp(const AST
 
 /// Check if we can skip the overflow check for \p Op.
 static bool CanElideOverflowCheck(const ASTContext , const BinOpInfo ) {
-  assert(isa(Op.E) ||
- isa(Op.E) && "Expected a unary or binary operator");
+  assert((isa(Op.E) || isa(Op.E)) &&
+ "Expected a unary or binary operator");
 
   if (const auto *UO = dyn_cast(Op.E))
 return IsWidenedIntegerOp(Ctx, UO->getSubExpr());


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


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

2017-02-24 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 89777.
ddcc added a comment.

Drop tests, move to https://reviews.llvm.org/D30373


https://reviews.llvm.org/D28952

Files:
  CMakeLists.txt
  cmake/modules/FindZ3.cmake
  include/clang/Config/config.h.cmake
  include/clang/StaticAnalyzer/Core/Analyses.def
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/expr-inspection.c
  test/Analysis/lit.local.cfg
  test/Analysis/unsupported-types.c
  test/lit.cfg
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -18,6 +18,7 @@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
+config.clang_staticanalyzer_z3 = "@CLANG_ANALYZER_WITH_Z3@"
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -361,6 +361,9 @@
 if config.clang_staticanalyzer:
 config.available_features.add("staticanalyzer")
 
+if config.clang_staticanalyzer_z3 == '1':
+config.available_features.add("z3")
+
 # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
 if platform.system() not in ['FreeBSD']:
 config.available_features.add('crash-recovery')
Index: test/Analysis/unsupported-types.c
===
--- /dev/null
+++ test/Analysis/unsupported-types.c
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-unknown-linux -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple powerpc64-linux-gnu -verify %s
+
+#define _Complex_I  (__extension__ 1.0iF)
+
+void clang_analyzer_eval(int);
+
+void complex_float(double _Complex x, double _Complex y) {
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  if (x != 1.0 + 3.0 * _Complex_I && y != 1.0 - 4.0 * _Complex_I)
+return
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x + y == 2.0 - 1.0 * _Complex_I); // expected-warning{{UNKNOWN}}
+}
+
+void complex_int(int _Complex x, int _Complex y) {
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  if (x != 1.0 + 3.0 * _Complex_I && y != 1.0 - 4.0 * _Complex_I)
+return
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x + y == 2.0 - 1.0 * _Complex_I); // expected-warning{{UNKNOWN}}
+}
+
+void longdouble_float(long double x, long double y) {
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  if (x != 0.0L && y != 1.0L)
+return
+  clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x + y == 1.0L); // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/lit.local.cfg
===
--- test/Analysis/lit.local.cfg
+++ test/Analysis/lit.local.cfg
@@ -8,6 +8,10 @@
 if result.code == lit.Test.FAIL:
 return result
 
+# If z3 backend available, add an additional run line for it
+if test.config.clang_staticanalyzer_z3 == '1':
+result = self.executeWithAnalyzeSubstitution(test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')
+
 return result
 
 def executeWithAnalyzeSubstitution(self, test, litConfig, substitution):
Index: test/Analysis/expr-inspection.c
===
--- test/Analysis/expr-inspection.c
+++ test/Analysis/expr-inspection.c
@@ -19,4 +19,4 @@
 
 // CHECK: Expressions:
 // CHECK-NEXT: clang_analyzer_printState : {clang_analyzer_printState}
-// CHECK-NEXT: Ranges are empty.
+// CHECK-NEXT: {{(Ranges are empty.)|(Constraints:[[:space:]]*$)}}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -0,0 +1,1556 @@
+//== Z3ConstraintManager.cpp *- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
+

r296245 - Retry: [profiling] Fix profile counter increment when emitting selects (PR32019)

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Sat Feb 25 00:35:45 2017
New Revision: 296245

URL: http://llvm.org/viewvc/llvm-project?rev=296245=rev
Log:
Retry: [profiling] Fix profile counter increment when emitting selects (PR32019)

2nd attempt: the first was in r296231, but it had a use after lifetime
bug.

Clang has logic to lower certain conditional expressions directly into llvm
select instructions. However, it does not emit the correct profile counter
increment as it does this: it emits an unconditional increment of the counter
for the 'then branch', even if the value selected is from the 'else branch'
(this is PR32019).

That means, given the following snippet, we would report that "0" is selected
twice, and that "1" is never selected:

  int f1(int x) {
return x ? 0 : 1;
   ^2  ^0
  }

  f1(0);
  f1(1);

Fix the problem by using the instrprof_increment_step intrinsic to do the
proper increment.

Added:
cfe/trunk/test/Profile/c-ternary.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296245=296244=296245=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Feb 25 00:35:45 2017
@@ -3414,9 +3414,11 @@ VisitAbstractConditionalOperator(const A
   // safe to evaluate the LHS and RHS unconditionally.
   if (isCheapEnoughToEvaluateUnconditionally(lhsExpr, CGF) &&
   isCheapEnoughToEvaluateUnconditionally(rhsExpr, CGF)) {
-CGF.incrementProfileCounter(E);
-
 llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
+llvm::Value *StepV = Builder.CreateZExtOrBitCast(CondV, CGF.Int64Ty);
+
+CGF.incrementProfileCounter(E, StepV);
+
 llvm::Value *LHS = Visit(lhsExpr);
 llvm::Value *RHS = Visit(rhsExpr);
 if (!LHS) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296245=296244=296245=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Feb 25 00:35:45 2017
@@ -1127,10 +1127,11 @@ private:
 uint64_t LoopCount);
 
 public:
-  /// Increment the profiler's counter for the given statement.
-  void incrementProfileCounter(const Stmt *S) {
+  /// Increment the profiler's counter for the given statement by \p StepV.
+  /// If \p StepV is null, the default increment is 1.
+  void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
 if (CGM.getCodeGenOpts().hasProfileClangInstr())
-  PGO.emitCounterIncrement(Builder, S);
+  PGO.emitCounterIncrement(Builder, S, StepV);
 PGO.setCurrentStmt(S);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=296245=296244=296245=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Sat Feb 25 00:35:45 2017
@@ -739,7 +739,8 @@ CodeGenPGO::applyFunctionAttributes(llvm
   Fn->setEntryCount(FunctionCount);
 }
 
-void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S) {
+void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S,
+  llvm::Value *StepV) {
   if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap)
 return;
   if (!Builder.GetInsertBlock())
@@ -747,11 +748,18 @@ void CodeGenPGO::emitCounterIncrement(CG
 
   unsigned Counter = (*RegionCounterMap)[S];
   auto *I8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
-  Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
- {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
-  Builder.getInt64(FunctionHash),
-  Builder.getInt32(NumRegionCounters),
-  Builder.getInt32(Counter)});
+
+  llvm::Value *Args[] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+ Builder.getInt64(FunctionHash),
+ Builder.getInt32(NumRegionCounters),
+ Builder.getInt32(Counter), StepV};
+  if (!StepV)
+Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
+   makeArrayRef(Args, 4));
+  else
+Builder.CreateCall(
+CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step),
+makeArrayRef(Args));
 }
 
 // This method either inserts a call to the profile run-time during

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: 

[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D28278



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


[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> Firstly I uploaded Glib-MallocChecker-single-size-value.patch for code 
> review, if submitted to UPSTREAM, then upload another one, correct?

Yes. By the way, you can model XXX_n variants similarly to how calloc is 
modeled (see CallocMem).




Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:785
 
-if (FunI == II_malloc) {
+if (FunI == II_malloc || FunI == II_g_malloc || FunI == II_g_malloc0 ||
+FunI == II_g_try_malloc || FunI == II_g_try_malloc0) {

g_malloc0 needs to be initialized with zeros, not UndefinedVal(). See the 
relevant part in MallocChecker::CallocMem:

  SVal zeroVal = svalBuilder.makeZeroVal(svalBuilder.getContext().CharTy);
  return MallocMemAux(C, CE, TotalSize, zeroVal, State);


Repository:
  rL LLVM

https://reviews.llvm.org/D28348



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


[PATCH] D29419: [Analyzer] Checker for mismatched iterators

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

>   So it would be a wast of resources to duplicate these data. So now I am 
> also working on the merged version.

Would it make sense to just resume the review on the merged patch?


https://reviews.llvm.org/D29419



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


[PATCH] D30289: [Analyzer] Add bug visitor for taint checker

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Looks great!


https://reviews.llvm.org/D30289



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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

I agree this can clarify the error message quite a bit!




Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:160
   if (ParamDecl->getType()->isPointerType()) {
-Message = "Function call argument is a pointer to uninitialized value";
+Message = "Function call argument number '" +
+  std::to_string(ArgumentNumber+1) +

Let's use llvm::getOrdinalSuffix() so that we write "1st argument" instead of 
"argument number '1'".



Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:211
   // Generate a report for this bug.
-  StringRef Desc =
-  describeUninitializedArgumentInCall(Call, IsFirstArgument);
+  std::string Desc =
+  describeUninitializedArgumentInCall(Call, ArgumentNumber);

Have you considered using  llvm::raw_svector_ostream here as well as passing it 
an argument to describeUninitializedArgumentInCall? For example, see  
MallocChecker.cpp.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341



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


[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager

2017-02-24 Thread Dominic Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296242: [analyzer] Refactor and simplify 
SimpleConstraintManager (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26061?vs=89054=89773#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26061

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
  cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
@@ -20,8 +20,8 @@
 
 static DefinedSVal getLocFromSymbol(const ProgramStateRef ,
 SymbolRef Sym) {
-  const MemRegion *R = State->getStateManager().getRegionManager()
-   .getSymbolicRegion(Sym);
+  const MemRegion *R =
+  State->getStateManager().getRegionManager().getSymbolicRegion(Sym);
   return loc::MemRegionVal(R);
 }
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
@@ -0,0 +1,102 @@
+//== RangedConstraintManager.h --*- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Ranged constraint manager, built on SimpleConstraintManager.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
+#define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
+
+namespace clang {
+
+namespace ento {
+
+class RangedConstraintManager : public SimpleConstraintManager {
+public:
+  RangedConstraintManager(SubEngine *SE, SValBuilder )
+  : SimpleConstraintManager(SE, SB) {}
+
+  ~RangedConstraintManager() override;
+
+  //===--===//
+  // Implementation for interface from SimpleConstraintManager.
+  //===--===//
+
+  ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym,
+bool Assumption) override;
+
+  ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ,
+  bool InRange) override;
+
+  ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym,
+   bool Assumption) override;
+
+protected:
+  /// Assume a constraint between a symbolic expression and a concrete integer.
+  virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym,
+   BinaryOperator::Opcode op,
+   const llvm::APSInt );
+
+  //===--===//
+  // Interface that subclasses must implement.
+  //===--===//
+
+  // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison
+  // operation for the method being invoked.
+
+  virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) = 0;
+
+  virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) = 0;
+
+  virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) = 0;
+
+  virtual ProgramStateRef assumeSymGT(ProgramStateRef State, 

r296242 - [analyzer] Refactor and simplify SimpleConstraintManager

2017-02-24 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Fri Feb 24 22:51:31 2017
New Revision: 296242

URL: http://llvm.org/viewvc/llvm-project?rev=296242=rev
Log:
[analyzer] Refactor and simplify SimpleConstraintManager

Summary: SimpleConstraintManager is difficult to use, and makes assumptions 
about capabilities of the constraint manager. This patch refactors out those 
portions into a new RangedConstraintManager, and also fixes some issues with 
camel case, formatting, and confusing naming.

Reviewers: zaks.anna, dcoughlin

Subscribers: mgorny, xazax.hun, NoQ, rgov, cfe-commits

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

Added:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
  - copied, changed from r296241, 
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
Removed:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=296242=296241=296242=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
Fri Feb 24 22:51:31 2017
@@ -139,6 +139,8 @@ public:
 return nullptr;
   }
 
+  /// Scan all symbols referenced by the constraints. If the symbol is not
+  /// alive, remove it.
   virtual ProgramStateRef removeDeadBindings(ProgramStateRef state,
  SymbolReaper& SymReaper) = 0;
 

Added: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h?rev=296242=auto
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
 (added)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
 Fri Feb 24 22:51:31 2017
@@ -0,0 +1,92 @@
+//== SimpleConstraintManager.h --*- C++ 
-*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Simplified constraint manager backend.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SIMPLECONSTRAINTMANAGER_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SIMPLECONSTRAINTMANAGER_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+
+namespace clang {
+
+namespace ento {
+
+class SimpleConstraintManager : public ConstraintManager {
+  SubEngine *SU;
+  SValBuilder 
+
+public:
+  SimpleConstraintManager(SubEngine *subengine, SValBuilder )
+  : SU(subengine), SVB(SB) {}
+
+  ~SimpleConstraintManager() override;
+
+  //===--===//
+  // Implementation for interface from ConstraintManager.
+  //===--===//
+
+  /// Ensures that the DefinedSVal conditional is expressed as a NonLoc by
+  /// creating boolean casts to handle Loc's.
+  ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond,
+ bool Assumption) override;
+
+  ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value,
+   const llvm::APSInt ,
+   const llvm::APSInt ,
+   bool InRange) override;
+
+protected:
+  //===--===//
+  // Interface that subclasses must implement.
+  //===--===//
+
+  /// Given a symbolic expression that can be reasoned about, assume that it is
+  /// true/false and generate the new program state.
+  virtual ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym,
+

r296241 - AMDGPU: export s_sendmsg{halt} instrinsics

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 22:20:24 2017
New Revision: 296241

URL: http://llvm.org/viewvc/llvm-project?rev=296241=rev
Log:
AMDGPU: export s_sendmsg{halt} instrinsics

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=296241=296240=296241=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Feb 24 22:20:24 2017
@@ -37,6 +37,8 @@ BUILTIN(__builtin_amdgcn_workitem_id_z,
 
//===--===//
 BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
 BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
+BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
+BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=296241=296240=296241=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Feb 24 22:20:24 2017
@@ -284,6 +284,34 @@ void test_s_waitcnt()
   __builtin_amdgcn_s_waitcnt(0);
 }
 
+// CHECK-LABEL: @test_s_sendmsg
+// CHECK: call void @llvm.amdgcn.s.sendmsg(
+void test_s_sendmsg()
+{
+  __builtin_amdgcn_s_sendmsg(1, 0);
+}
+
+// CHECK-LABEL: @test_s_sendmsg_var
+// CHECK: call void @llvm.amdgcn.s.sendmsg(
+void test_s_sendmsg_var(int in)
+{
+  __builtin_amdgcn_s_sendmsg(1, in);
+}
+
+// CHECK-LABEL: @test_s_sendmsghalt
+// CHECK: call void @llvm.amdgcn.s.sendmsghalt(
+void test_s_sendmsghalt()
+{
+  __builtin_amdgcn_s_sendmsghalt(1, 0);
+}
+
+// CHECK-LABEL: @test_s_sendmsghalt
+// CHECK: call void @llvm.amdgcn.s.sendmsghalt(
+void test_s_sendmsghalt_var(int in)
+{
+  __builtin_amdgcn_s_sendmsghalt(1, in);
+}
+
 // CHECK-LABEL: @test_s_barrier
 // CHECK: call void @llvm.amdgcn.s.barrier(
 void test_s_barrier()

Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl?rev=296241=296240=296241=diff
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl (original)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Fri Feb 24 22:20:24 2017
@@ -23,6 +23,26 @@ void test_s_waitcnt(int x)
   __builtin_amdgcn_s_waitcnt(x); // expected-error {{argument to 
'__builtin_amdgcn_s_waitcnt' must be a constant integer}}
 }
 
+void test_s_sendmsg(int in)
+{
+  __builtin_amdgcn_s_sendmsg(in, 1); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsg' must be a constant integer}}
+}
+
+void test_s_sendmsg_var(int in1, int in2)
+{
+  __builtin_amdgcn_s_sendmsg(in1, in2); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsg' must be a constant integer}}
+}
+
+void test_s_sendmsghalt(int in)
+{
+  __builtin_amdgcn_s_sendmsghalt(in, 1); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsghalt' must be a constant integer}}
+}
+
+void test_s_sendmsghalt_var(int in1, int in2)
+{
+  __builtin_amdgcn_s_sendmsghalt(in1, in2); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsghalt' must be a constant integer}}
+}
+
 void test_s_incperflevel(int x)
 {
   __builtin_amdgcn_s_incperflevel(x); // expected-error {{argument to 
'__builtin_amdgcn_s_incperflevel' must be a constant integer}}


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


r296239 - AMDGPU: export s_waitcnt builtin

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 22:20:20 2017
New Revision: 296239

URL: http://llvm.org/viewvc/llvm-project?rev=296239=rev
Log:
AMDGPU: export s_waitcnt builtin

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=296239=296238=296239=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Feb 24 22:20:20 2017
@@ -36,6 +36,7 @@ BUILTIN(__builtin_amdgcn_workitem_id_z,
 // Instruction builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
+BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=296239=296238=296239=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Feb 24 22:20:20 2017
@@ -263,6 +263,13 @@ void test_class_f64(global double* out,
   *out = __builtin_amdgcn_class(a, b);
 }
 
+// CHECK-LABEL: @test_s_waitcnt
+// CHECK: call void @llvm.amdgcn.s.waitcnt(
+void test_s_waitcnt()
+{
+  __builtin_amdgcn_s_waitcnt(0);
+}
+
 // CHECK-LABEL: @test_s_barrier
 // CHECK: call void @llvm.amdgcn.s.barrier(
 void test_s_barrier()

Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl?rev=296239=296238=296239=diff
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl (original)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Fri Feb 24 22:20:20 2017
@@ -18,6 +18,11 @@ void test_s_sleep(int x)
   __builtin_amdgcn_s_sleep(x); // expected-error {{argument to 
'__builtin_amdgcn_s_sleep' must be a constant integer}}
 }
 
+void test_s_waitcnt(int x)
+{
+  __builtin_amdgcn_s_waitcnt(x); // expected-error {{argument to 
'__builtin_amdgcn_s_waitcnt' must be a constant integer}}
+}
+
 void test_s_incperflevel(int x)
 {
   __builtin_amdgcn_s_incperflevel(x); // expected-error {{argument to 
'__builtin_amdgcn_s_incperflevel' must be a constant integer}}


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


r296240 - AMDGPU: export l1 cache invalidation intrinsics

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 22:20:22 2017
New Revision: 296240

URL: http://llvm.org/viewvc/llvm-project?rev=296240=rev
Log:
AMDGPU: export l1 cache invalidation intrinsics

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=296240=296239=296240=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Feb 24 22:20:22 2017
@@ -39,6 +39,8 @@ BUILTIN(__builtin_amdgcn_s_getreg, "UiIi
 BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
+BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
+BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
 BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
 BUILTIN(__builtin_amdgcn_div_fmas, "b", "nc")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=296240=296239=296240=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Feb 24 22:20:22 2017
@@ -263,6 +263,20 @@ void test_class_f64(global double* out,
   *out = __builtin_amdgcn_class(a, b);
 }
 
+// CHECK-LABEL: @test_buffer_wbinvl1
+// CHECK: call void @llvm.amdgcn.buffer.wbinvl1(
+void test_buffer_wbinvl1()
+{
+  __builtin_amdgcn_buffer_wbinvl1();
+}
+
+// CHECK-LABEL: @test_s_dcache_inv
+// CHECK: call void @llvm.amdgcn.s.dcache.inv(
+void test_s_dcache_inv()
+{
+  __builtin_amdgcn_s_dcache_inv();
+}
+
 // CHECK-LABEL: @test_s_waitcnt
 // CHECK: call void @llvm.amdgcn.s.waitcnt(
 void test_s_waitcnt()


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


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

2017-02-24 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

Sounds good, I will commit https://reviews.llvm.org/D26061 and split out the 
tests from this (https://reviews.llvm.org/D28952).


https://reviews.llvm.org/D28952



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


r296237 - Revert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows, PR26125", and r296171.

2017-02-24 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Feb 24 21:45:49 2017
New Revision: 296237

URL: http://llvm.org/viewvc/llvm-project?rev=296237=rev
Log:
Revert r296166, "clang-format: Don't leave behind temp files in -i mode on 
Windows, PR26125", and r296171.

(MemoryBuffer)Code.reset() was too early.

  ==26912== Invalid read of size 1
  ==26912==at 0x437E1D: llvm::MemoryBuffer::init(char const*, char const*, 
bool) (MemoryBuffer.cpp:47)
  ==26912==by 0x438013: (anonymous 
namespace)::MemoryBufferMem::MemoryBufferMem(llvm::StringRef, bool) 
(MemoryBuffer.cpp:86)
  ==26912==by 0x438128: llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, 
llvm::StringRef, bool) (MemoryBuffer.cpp:112)
  ==26912==by 0x4E189D: clang::vfs::detail::(anonymous 
namespace)::InMemoryFileAdaptor::getBuffer(llvm::Twine const&, long, bool, 
bool) (VirtualFileSystem.cpp:443)
  ==26912==by 0x4DF5BA: 
clang::vfs::FileSystem::getBufferForFile(llvm::Twine const&, long, bool, bool) 
(VirtualFileSystem.cpp:94)
  ==26912==by 0x4B72EC: 
clang::FileManager::getBufferForFile(clang::FileEntry const*, bool, bool) 
(FileManager.cpp:443)
  ==26912==by 0x4C1F81: 
clang::SrcMgr::ContentCache::getBuffer(clang::DiagnosticsEngine&, 
clang::SourceManager const&, clang::SourceLocation, bool*) const 
(SourceManager.cpp:98)
  ==26912==by 0x4C50E5: clang::SourceManager::getBufferData(clang::FileID, 
bool*) const (SourceManager.cpp:689)
  ==26912==by 0x58E794: clang::Rewriter::getEditBuffer(clang::FileID) 
(Rewriter.cpp:230)
  ==26912==by 0x407297: clang::format::format(llvm::StringRef) 
(ClangFormat.cpp:311)
  ==26912==by 0x4078D7: main (ClangFormat.cpp:363)

Removed:
cfe/trunk/test/Format/inplace.cpp
Modified:
cfe/trunk/tools/clang-format/ClangFormat.cpp

Removed: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296236=auto
==
--- cfe/trunk/test/Format/inplace.cpp (original)
+++ cfe/trunk/test/Format/inplace.cpp (removed)
@@ -1,263 +0,0 @@
-// Regression test to check that clang-format does not leave behind temporary
-// files on Windows when doing in-place formatting.
-// RUN: rm %T/inplace*
-// RUN: cp %s %T/inplace.cpp
-// RUN: clang-format -style=LLVM -i %T/inplace.cpp
-// RUN: ls %T > %T/files.txt
-// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
-
-// CHECK-NOT: RF{{.*}}.TMP
-
-// The file needs to be larger than 16kiB so that Windows creates a real file
-// mapping object for it.
- int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int 

r296234 - Revert "[profiling] Fix profile counter increment when emitting selects (PR32019)"

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 20:59:47 2017
New Revision: 296234

URL: http://llvm.org/viewvc/llvm-project?rev=296234=rev
Log:
Revert "[profiling] Fix profile counter increment when emitting selects 
(PR32019)"

This reverts commit r296231. It causes an assertion failure on 32-bit
machines

clang: 
/export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/lib/IR/Instructions.cpp:263:
 void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
llvm::ArrayRef, 
llvm::ArrayRef >, const llvm::Twine&): 
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5fbfa)
llvm::sys::RunSignalHandlers() 
(/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5dc7e)
SignalHandler(int) 
(/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5dde2)
__restore_rt (/lib64/libpthread.so.0+0x3f1d00efa0)
__GI_raise 
/home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
__GI_abort 
/home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/stdlib/abort.c:92:0
__assert_fail_base 
/home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/assert/assert.c:92:0
(/lib64/libc.so.6+0x3f1c82e622)
llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
llvm::ArrayRef, 
llvm::ArrayRef >, llvm::Twine const&) 
(/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1804e3a)
clang::CodeGen::CodeGenPGO::emitCounterIncrement(clang::CodeGen::CGBuilderTy&, 
clang::Stmt const*, llvm::Value*) 
(/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1ec7891)

Removed:
cfe/trunk/test/Profile/c-ternary.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296234=296233=296234=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 20:59:47 2017
@@ -3414,11 +3414,9 @@ VisitAbstractConditionalOperator(const A
   // safe to evaluate the LHS and RHS unconditionally.
   if (isCheapEnoughToEvaluateUnconditionally(lhsExpr, CGF) &&
   isCheapEnoughToEvaluateUnconditionally(rhsExpr, CGF)) {
-llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
-llvm::Value *StepV = Builder.CreateZExtOrBitCast(CondV, CGF.Int64Ty);
-
-CGF.incrementProfileCounter(E, StepV);
+CGF.incrementProfileCounter(E);
 
+llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
 llvm::Value *LHS = Visit(lhsExpr);
 llvm::Value *RHS = Visit(rhsExpr);
 if (!LHS) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296234=296233=296234=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Feb 24 20:59:47 2017
@@ -1127,11 +1127,10 @@ private:
 uint64_t LoopCount);
 
 public:
-  /// Increment the profiler's counter for the given statement by \p StepV.
-  /// If \p StepV is null, the default increment is 1.
-  void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
+  /// Increment the profiler's counter for the given statement.
+  void incrementProfileCounter(const Stmt *S) {
 if (CGM.getCodeGenOpts().hasProfileClangInstr())
-  PGO.emitCounterIncrement(Builder, S, StepV);
+  PGO.emitCounterIncrement(Builder, S);
 PGO.setCurrentStmt(S);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=296234=296233=296234=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Feb 24 20:59:47 2017
@@ -739,8 +739,7 @@ CodeGenPGO::applyFunctionAttributes(llvm
   Fn->setEntryCount(FunctionCount);
 }
 
-void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S,
-  llvm::Value *StepV) {
+void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S) {
   if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap)
 return;
   if (!Builder.GetInsertBlock())
@@ -748,17 +747,11 @@ void CodeGenPGO::emitCounterIncrement(CG
 
   unsigned Counter = (*RegionCounterMap)[S];
   auto *I8PtrTy = 

[libclc] r296233 - math: Implement sinh function

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 20:46:53 2017
New Revision: 296233

URL: http://llvm.org/viewvc/llvm-project?rev=296233=rev
Log:
math: Implement sinh function

mostly copied form amd_builtins

Added:
libclc/trunk/generic/include/clc/math/sinh.h
libclc/trunk/generic/include/clc/math/sinh.inc
libclc/trunk/generic/lib/math/sinh.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=296233=296232=296233=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Feb 24 20:46:53 2017
@@ -86,6 +86,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/sinh.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/sinh.h?rev=296233=auto
==
--- libclc/trunk/generic/include/clc/math/sinh.h (added)
+++ libclc/trunk/generic/include/clc/math/sinh.h Fri Feb 24 20:46:53 2017
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014, 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/include/clc/math/sinh.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/sinh.inc?rev=296233=auto
==
--- libclc/trunk/generic/include/clc/math/sinh.inc (added)
+++ libclc/trunk/generic/include/clc/math/sinh.inc Fri Feb 24 20:46:53 2017
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2014, 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sinh(__CLC_GENTYPE x);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=296233=296232=296233=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Feb 24 20:46:53 2017
@@ -116,6 +116,7 @@ math/pown.cl
 math/sin.cl
 math/sincos.cl
 math/sincos_helpers.cl
+math/sinh.cl
 math/sinpi.cl
 math/clc_sqrt.cl
 math/sqrt.cl

Added: libclc/trunk/generic/lib/math/sinh.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/sinh.cl?rev=296233=auto
==
--- libclc/trunk/generic/lib/math/sinh.cl (added)
+++ libclc/trunk/generic/lib/math/sinh.cl Fri Feb 24 20:46:53 2017
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * 

r296231 - [profiling] Fix profile counter increment when emitting selects (PR32019)

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 20:30:03 2017
New Revision: 296231

URL: http://llvm.org/viewvc/llvm-project?rev=296231=rev
Log:
[profiling] Fix profile counter increment when emitting selects (PR32019)

Clang has logic to lower certain conditional expressions directly into
llvm select instructions. However, it does not emit the correct profile
counter increment as it does this: it emits an unconditional increment
of the counter for the 'then branch', even if the value selected is from
the 'else branch' (this is PR32019).

That means, given the following snippet, we would report that "0" is
selected twice, and that "1" is never selected:

  int f1(int x) {
return x ? 0 : 1;
   ^2  ^0
  }

  f1(0);
  f1(1);

Fix the problem by using the instrprof_increment_step intrinsic to do
the proper increment.

Added:
cfe/trunk/test/Profile/c-ternary.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296231=296230=296231=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 20:30:03 2017
@@ -3414,9 +3414,11 @@ VisitAbstractConditionalOperator(const A
   // safe to evaluate the LHS and RHS unconditionally.
   if (isCheapEnoughToEvaluateUnconditionally(lhsExpr, CGF) &&
   isCheapEnoughToEvaluateUnconditionally(rhsExpr, CGF)) {
-CGF.incrementProfileCounter(E);
-
 llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
+llvm::Value *StepV = Builder.CreateZExtOrBitCast(CondV, CGF.Int64Ty);
+
+CGF.incrementProfileCounter(E, StepV);
+
 llvm::Value *LHS = Visit(lhsExpr);
 llvm::Value *RHS = Visit(rhsExpr);
 if (!LHS) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296231=296230=296231=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Feb 24 20:30:03 2017
@@ -1127,10 +1127,11 @@ private:
 uint64_t LoopCount);
 
 public:
-  /// Increment the profiler's counter for the given statement.
-  void incrementProfileCounter(const Stmt *S) {
+  /// Increment the profiler's counter for the given statement by \p StepV.
+  /// If \p StepV is null, the default increment is 1.
+  void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
 if (CGM.getCodeGenOpts().hasProfileClangInstr())
-  PGO.emitCounterIncrement(Builder, S);
+  PGO.emitCounterIncrement(Builder, S, StepV);
 PGO.setCurrentStmt(S);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=296231=296230=296231=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Feb 24 20:30:03 2017
@@ -739,7 +739,8 @@ CodeGenPGO::applyFunctionAttributes(llvm
   Fn->setEntryCount(FunctionCount);
 }
 
-void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S) {
+void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S,
+  llvm::Value *StepV) {
   if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap)
 return;
   if (!Builder.GetInsertBlock())
@@ -747,11 +748,17 @@ void CodeGenPGO::emitCounterIncrement(CG
 
   unsigned Counter = (*RegionCounterMap)[S];
   auto *I8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
-  Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
- {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
-  Builder.getInt64(FunctionHash),
-  Builder.getInt32(NumRegionCounters),
-  Builder.getInt32(Counter)});
+
+  ArrayRef Args = {
+  llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+  Builder.getInt64(FunctionHash), Builder.getInt32(NumRegionCounters),
+  Builder.getInt32(Counter), StepV};
+  if (!StepV)
+Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
+   Args.drop_back(1));
+  else
+Builder.CreateCall(
+CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args);
 }
 
 // This method either inserts a call to the profile run-time during

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=296231=296230=296231=diff
==

r296221 - [ODRHash] Move inherited visitor call to end of function.

2017-02-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 24 19:29:34 2017
New Revision: 296221

URL: http://llvm.org/viewvc/llvm-project?rev=296221=rev
Log:
[ODRHash] Move inherited visitor call to end of function.

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

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296221=296220=296221=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 19:29:34 2017
@@ -182,8 +182,6 @@ public:
   }
 
   void VisitFieldDecl(const FieldDecl *D) {
-Inherited::VisitFieldDecl(D);
-
 const bool IsBitfield = D->isBitField();
 Hash.AddBoolean(IsBitfield);
 
@@ -193,6 +191,8 @@ public:
 
 Hash.AddBoolean(D->isMutable());
 AddStmt(D->getInClassInitializer());
+
+Inherited::VisitFieldDecl(D);
   }
 };
 


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


RE: r296171 - Try to unbreak tests after r296166

2017-02-24 Thread Yung, Douglas via cfe-commits
Hi Nico,

The test you added is causing a failure on the PS4 Windows bot. The root of the 
cause is that the Windows version of rm does not accept wildcards 
unfortunately. To fix make it work on Windows, you likely need to specify 
exactly what files/directories you want to delete without using a wildcard:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6030:

$ "rm" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Format\Output/*"
# command stderr:
rm: cannot remove 
`C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\test\\Format\\Output/*':
 Invalid argument

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6031:

$ "rm" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Format\Output/inplace*"
# command stderr:
rm: cannot remove 
`C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\test\\Format\\Output/inplace*':
 Invalid argument

Can you fix the test?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Nico Weber via cfe-commits
> Sent: Friday, February 24, 2017 13:02
> To: cfe-commits@lists.llvm.org
> Subject: r296171 - Try to unbreak tests after r296166
> 
> Author: nico
> Date: Fri Feb 24 15:01:43 2017
> New Revision: 296171
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296171=rev
> Log:
> Try to unbreak tests after r296166
> 
> Looks like %T isn't per-test but per-test-directory, and the rm was deleting
> temp files written by other tests in test/Format.  Limit the rm's scope a bit.
> 
> Modified:
> cfe/trunk/test/Format/inplace.cpp
> 
> Modified: cfe/trunk/test/Format/inplace.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/Format/inplace.cpp?rev=296171=296170=296171=
> diff
> ==
> --- cfe/trunk/test/Format/inplace.cpp (original)
> +++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 15:01:43 2017
> @@ -1,6 +1,6 @@
>  // Regression test to check that clang-format does not leave behind temporary
> // files on Windows when doing in-place formatting.
> -// RUN: rm %T/*
> +// RUN: rm %T/inplace*
>  // RUN: cp %s %T/inplace.cpp
>  // RUN: clang-format -style=LLVM -i %T/inplace.cpp  // RUN: ls %T >
> %T/files.txt
> 
> 
> ___
> 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


r296216 - Revert r296209, still one more test to go.

2017-02-24 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb 24 18:50:34 2017
New Revision: 296216

URL: http://llvm.org/viewvc/llvm-project?rev=296216=rev
Log:
Revert r296209, still one more test to go.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=296216=296215=296216=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb 24 18:50:34 2017
@@ -1582,11 +1582,7 @@ void CompilerInvocation::setLangDefaults
 case IK_PreprocessedCXX:
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
-  // The PS4 uses C++11 as the default C++ standard.
-  if (T.isPS4())
-LangStd = LangStandard::lang_gnucxx11;
-  else
-LangStd = LangStandard::lang_gnucxx98;
+  LangStd = LangStandard::lang_gnucxx98;
   break;
 case IK_RenderScript:
   LangStd = LangStandard::lang_c99;


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


[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296214: [ubsan] Detect signed overflow UB in remainder 
operations (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29437?vs=89734=89753#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29437

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope();
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())
Index: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
+++ cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope();
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())
Index: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
+++ cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296213: [ubsan] Omit superflous overflow checks for promoted 
arithmetic (PR20193) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29369?vs=89733=89752#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29369

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/compound-assign-overflow.c
  cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
  cfe/trunk/test/CodeGen/unsigned-promotion.c

Index: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
+++ cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=signed-integer-overflow,unsigned-integer-overflow | FileCheck %s
+
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+
+enum E1 : int {
+  a
+};
+
+enum E2 : char {
+  b
+};
+
+// CHECK-LABEL: define signext i8 @_Z4add1
+// CHECK-NOT: sadd.with.overflow
+char add1(char c) { return c + c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4add2
+// CHECK-NOT: uadd.with.overflow
+uchar add2(uchar uc) { return uc + uc; }
+
+// CHECK-LABEL: define i32 @_Z4add3
+// CHECK: sadd.with.overflow
+int add3(E1 e) { return e + a; }
+
+// CHECK-LABEL: define signext i8 @_Z4add4
+// CHECK-NOT: sadd.with.overflow
+char add4(E2 e) { return e + b; }
+
+// CHECK-LABEL: define signext i8 @_Z4sub1
+// CHECK-NOT: ssub.with.overflow
+char sub1(char c) { return c - c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4sub2
+// CHECK-NOT: usub.with.overflow
+uchar sub2(uchar uc) { return uc - uc; }
+
+// CHECK-LABEL: define signext i8 @_Z4sub3
+// CHECK-NOT: ssub.with.overflow
+char sub3(char c) { return -c; }
+
+// Note: -INT_MIN can overflow.
+//
+// CHECK-LABEL: define i32 @_Z4sub4
+// CHECK: ssub.with.overflow
+int sub4(int i) { return -i; }
+
+// CHECK-LABEL: define signext i8 @_Z4mul1
+// CHECK-NOT: smul.with.overflow
+char mul1(char c) { return c * c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4mul2
+// CHECK-NOT: smul.with.overflow
+uchar mul2(uchar uc) { return uc * uc; }
+
+// Note: USHRT_MAX * USHRT_MAX can overflow.
+//
+// CHECK-LABEL: define zeroext i16 @_Z4mul3
+// CHECK: smul.with.overflow
+ushort mul3(ushort us) { return us * us; }
+
+// CHECK-LABEL: define i32 @_Z4mul4
+// CHECK: smul.with.overflow
+int mul4(int i, char c) { return i * c; }
+
+// CHECK-LABEL: define i32 @_Z4mul5
+// CHECK: smul.with.overflow
+int mul5(int i, char c) { return c * i; }
+
+// CHECK-LABEL: define signext i16 @_Z4mul6
+// CHECK-NOT: smul.with.overflow
+short mul6(short s) { return s * s; }
+
+// CHECK-LABEL: define signext i8 @_Z4div1
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char div1(char c) { return c / c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4div2
+// CHECK-NOT: ubsan_handle_divrem_overflow
+uchar div2(uchar uc) { return uc / uc; }
+
+// CHECK-LABEL: define signext i8 @_Z4div3
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char div3(char c, int i) { return c / i; }
+
+// CHECK-LABEL: define signext i8 @_Z4div4
+// CHECK: ubsan_handle_divrem_overflow
+char div4(int i, char c) { return i / c; }
+
+// Note: INT_MIN / -1 can overflow.
+//
+// CHECK-LABEL: define signext i8 @_Z4div5
+// CHECK: ubsan_handle_divrem_overflow
+char div5(int i, char c) { return i / c; }
+
+// CHECK-LABEL: define signext i8 @_Z4rem1
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem1(char c) { return c % c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4rem2
+// CHECK-NOT: ubsan_handle_divrem_overflow
+uchar rem2(uchar uc) { return uc % uc; }
+
+// FIXME: This is a long-standing false negative.
+//
+// CHECK-LABEL: define signext i8 @_Z4rem3
+// rdar30301609: ubsan_handle_divrem_overflow
+char rem3(int i, char c) { return i % c; }
+
+// CHECK-LABEL: define signext i8 @_Z4inc1
+// CHECK-NOT: sadd.with.overflow
+char inc1(char c) { return c++ + (char)0; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4inc2
+// CHECK-NOT: uadd.with.overflow
+uchar inc2(uchar uc) { return uc++ + (uchar)0; }
+
+// CHECK-LABEL: define void @_Z4inc3
+// CHECK-NOT: sadd.with.overflow
+void inc3(char c) { c++; }
+
+// CHECK-LABEL: define void @_Z4inc4
+// CHECK-NOT: uadd.with.overflow
+void inc4(uchar uc) { uc++; }
Index: cfe/trunk/test/CodeGen/unsigned-promotion.c
===
--- cfe/trunk/test/CodeGen/unsigned-promotion.c
+++ cfe/trunk/test/CodeGen/unsigned-promotion.c
@@ -7,53 +7,6 @@
 // RUN:   -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=CHECKU
 
 unsigned short si, sj, sk;
-unsigned char ci, cj, ck;
-
-extern void opaqueshort(unsigned short);
-extern void opaquechar(unsigned char);
-
-// CHECKS-LABEL:   define void @testshortadd()
-// CHECKU-LABEL: define void @testshortadd()
-void testshortadd() {
-  // CHECKS:load i16, i16* @sj
-  // CHECKS:  

r296214 - [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 18:43:39 2017
New Revision: 296214

URL: http://llvm.org/viewvc/llvm-project?rev=296214=rev
Log:
[ubsan] Detect signed overflow UB in remainder operations

Teach ubsan to diagnose remainder operations which have undefined
behavior due to signed overflow (e.g INT_MIN % -1).

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

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296214=296213=296214=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 18:43:39 2017
@@ -2403,12 +2403,12 @@ Value *ScalarExprEmitter::EmitDiv(const
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope();
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())

Modified: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp?rev=296214=296213=296214=diff
==
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp (original)
+++ cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp Fri Feb 24 18:43:39 2017
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@ char rem1(char c) { return c % c; }
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@ void inc3(char c) { c++; }
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }


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


r296213 - [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 18:43:36 2017
New Revision: 296213

URL: http://llvm.org/viewvc/llvm-project?rev=296213=rev
Log:
[ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

C requires the operands of arithmetic expressions to be promoted if
their types are smaller than an int. Ubsan emits overflow checks when
this sort of type promotion occurs, even if there is no way to actually
get an overflow with the promoted type.

This patch teaches clang how to omit the superflous overflow checks
(addressing PR20193).

Testing: check-clang and check-ubsan.

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

Added:
cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/compound-assign-overflow.c
cfe/trunk/test/CodeGen/unsigned-promotion.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296213=296212=296213=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 18:43:36 2017
@@ -24,6 +24,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
@@ -58,6 +59,59 @@ static bool MustVisitNullValue(const Exp
   return E->getType()->isNullPtrType();
 }
 
+/// If \p E is a widened promoted integer, get its base (unpromoted) type.
+static llvm::Optional getUnwidenedIntegerType(const ASTContext ,
+const Expr *E) {
+  const Expr *Base = E->IgnoreImpCasts();
+  if (E == Base)
+return llvm::None;
+
+  QualType BaseTy = Base->getType();
+  if (!BaseTy->isPromotableIntegerType() ||
+  Ctx.getTypeSize(BaseTy) >= Ctx.getTypeSize(E->getType()))
+return llvm::None;
+
+  return BaseTy;
+}
+
+/// Check if \p E is a widened promoted integer.
+static bool IsWidenedIntegerOp(const ASTContext , const Expr *E) {
+  return getUnwidenedIntegerType(Ctx, E).hasValue();
+}
+
+/// Check if we can skip the overflow check for \p Op.
+static bool CanElideOverflowCheck(const ASTContext , const BinOpInfo ) {
+  assert(isa(Op.E) ||
+ isa(Op.E) && "Expected a unary or binary operator");
+
+  if (const auto *UO = dyn_cast(Op.E))
+return IsWidenedIntegerOp(Ctx, UO->getSubExpr());
+
+  const auto *BO = cast(Op.E);
+  auto OptionalLHSTy = getUnwidenedIntegerType(Ctx, BO->getLHS());
+  if (!OptionalLHSTy)
+return false;
+
+  auto OptionalRHSTy = getUnwidenedIntegerType(Ctx, BO->getRHS());
+  if (!OptionalRHSTy)
+return false;
+
+  QualType LHSTy = *OptionalLHSTy;
+  QualType RHSTy = *OptionalRHSTy;
+
+  // We usually don't need overflow checks for binary operations with widened
+  // operands. Multiplication with promoted unsigned operands is a special 
case.
+  if ((Op.Opcode != BO_Mul && Op.Opcode != BO_MulAssign) ||
+  !LHSTy->isUnsignedIntegerType() || !RHSTy->isUnsignedIntegerType())
+return true;
+
+  // The overflow check can be skipped if either one of the unpromoted types
+  // are less than half the size of the promoted type.
+  unsigned PromotedSize = Ctx.getTypeSize(Op.E->getType());
+  return (2 * Ctx.getTypeSize(LHSTy)) < PromotedSize ||
+ (2 * Ctx.getTypeSize(RHSTy)) < PromotedSize;
+}
+
 class ScalarExprEmitter
   : public StmtVisitor {
   CodeGenFunction 
@@ -482,12 +536,15 @@ public:
   return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
 // Fall through.
   case LangOptions::SOB_Trapping:
+if (CanElideOverflowCheck(CGF.getContext(), Ops))
+  return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
 return EmitOverflowCheckedBinOp(Ops);
   }
 }
 
 if (Ops.Ty->isUnsignedIntegerType() &&
-CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow))
+CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow) &&
+!CanElideOverflowCheck(CGF.getContext(), Ops))
   return EmitOverflowCheckedBinOp(Ops);
 
 if (Ops.LHS->getType()->isFPOrFPVectorTy())
@@ -1663,6 +1720,8 @@ llvm::Value *ScalarExprEmitter::EmitIncD
   return Builder.CreateNSWAdd(InVal, Amount, Name);
 // Fall through.
   case LangOptions::SOB_Trapping:
+if (IsWidenedIntegerOp(CGF.getContext(), E->getSubExpr()))
+  return Builder.CreateNSWAdd(InVal, Amount, Name);
 return EmitOverflowCheckedBinOp(createBinOpInfoFromIncDec(E, InVal, 
IsInc));
   }
   llvm_unreachable("Unknown SignedOverflowBehaviorTy");
@@ -2281,8 +2340,10 @@ void ScalarExprEmitter::EmitUndefinedBeh
 SanitizerKind::IntegerDivideByZero));
   }
 
+  const auto *BO = cast(Ops.E);
   if (CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow) &&
- 

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Will Dietz via Phabricator via cfe-commits
dtzWill accepted this revision.
dtzWill added a comment.
This revision is now accepted and ready to land.

Sorry for the delay!

LGTM, thanks!


https://reviews.llvm.org/D29369



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


r296209 - [PS4] Set our default dialect to C++11. NFC for other targets.

2017-02-24 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb 24 18:15:45 2017
New Revision: 296209

URL: http://llvm.org/viewvc/llvm-project?rev=296209=rev
Log:
[PS4] Set our default dialect to C++11. NFC for other targets.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=296209=296208=296209=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb 24 18:15:45 2017
@@ -1582,7 +1582,11 @@ void CompilerInvocation::setLangDefaults
 case IK_PreprocessedCXX:
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
-  LangStd = LangStandard::lang_gnucxx98;
+  // The PS4 uses C++11 as the default C++ standard.
+  if (T.isPS4())
+LangStd = LangStandard::lang_gnucxx11;
+  else
+LangStd = LangStandard::lang_gnucxx98;
   break;
 case IK_RenderScript:
   LangStd = LangStandard::lang_c99;


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


r296198 - [ODRHash] Finish FieldDecl support by handling mutable and initializers.

2017-02-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 24 17:35:37 2017
New Revision: 296198

URL: http://llvm.org/viewvc/llvm-project?rev=296198=rev
Log:
[ODRHash] Finish FieldDecl support by handling mutable and initializers.

https://reviews.llvm.org/rL296170

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296198=296197=296198=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Feb 24 
17:35:37 2017
@@ -136,7 +136,10 @@ def err_module_odr_violation_mismatch_de
   "field %4|"
   "field %4 with type %5|"
   "%select{non-|}5bitfield %4|"
-  "bitfield %4 with one width expression}3">;
+  "bitfield %4 with one width expression|"
+  "%select{non-|}5mutable field %4|"
+  "field %4 with %select{no|an}5 initalizer|"
+  "field %4 with an initializer}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -146,7 +149,10 @@ def note_module_odr_violation_mismatch_d
   "field %2|"
   "field %2 with type %3|"
   "%select{non-|}3bitfield %2|"
-  "bitfield %2 with different width expression}1">;
+  "bitfield %2 with different width expression|"
+  "%select{non-|}3mutable field %2|"
+  "field %2 with %select{no|an}3 initializer|"
+  "field %2 with a different initializer}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296198=296197=296198=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 17:35:37 2017
@@ -190,6 +190,9 @@ public:
 if (IsBitfield) {
   AddStmt(D->getBitWidth());
 }
+
+Hash.AddBoolean(D->isMutable());
+AddStmt(D->getInClassInitializer());
   }
 };
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296198=296197=296198=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Feb 24 17:35:37 2017
@@ -9064,7 +9064,10 @@ void ASTReader::diagnoseOdrViolations()
 FieldName,
 FieldTypeName,
 FieldSingleBitField,
-FieldDifferentWidthBitField
+FieldDifferentWidthBitField,
+FieldSingleMutable,
+FieldSingleInitializer,
+FieldDifferentInitializers,
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9239,6 +9242,50 @@ void ASTReader::diagnoseOdrViolations()
   break;
 }
 
+const bool IsFirstMutable = FirstField->isMutable();
+const bool IsSecondMutable = SecondField->isMutable();
+if (IsFirstMutable != IsSecondMutable) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldSingleMutable)
+  << FirstII << IsFirstMutable;
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldSingleMutable)
+  << SecondII << IsSecondMutable;
+  Diagnosed = true;
+  break;
+}
+
+const Expr *FirstInitializer = FirstField->getInClassInitializer();
+const Expr *SecondInitializer = SecondField->getInClassInitializer();
+if ((!FirstInitializer && SecondInitializer) ||
+(FirstInitializer && !SecondInitializer)) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldSingleInitializer)
+  << FirstII << (FirstInitializer != nullptr);
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldSingleInitializer)
+  << SecondII << (SecondInitializer != nullptr);
+  Diagnosed = true;
+  break;
+}
+
+if (FirstInitializer && SecondInitializer) {
+  unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
+  unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
+  if (FirstInitHash != SecondInitHash) {
+ODRDiagError(FirstField->getLocation(),
+ FirstField->getSourceRange(),
+ FieldDifferentInitializers)
+<< FirstII << FirstInitializer->getSourceRange();
+

[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

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

LGTM.


https://reviews.llvm.org/D29437



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


[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge closed this revision.
tigerleapgorge added a comment.

warn-thread-safety-parsing.cpp has been commited in 
https://reviews.llvm.org/rL296193.
The following FIXME has been added to track this bug.

//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect


https://reviews.llvm.org/D29685



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


[PATCH] D21626: Lit C++11 Compatibility Patch #10

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296193: [Test] Make Lit tests C++11 compatible #10 (authored 
by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D21626?vs=89736=89737#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21626

Files:
  cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h
  cfe/trunk/test/Modules/merge-using-decls.cpp
  cfe/trunk/test/SemaCXX/PR9572.cpp
  cfe/trunk/test/SemaCXX/default-assignment-operator.cpp
  cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
  cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Index: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,11 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1466,24 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+// expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
===
--- cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
+++ cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
@@ -1,26 +1,59 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct X1 { // has no implicit default constructor
X1(int);
 };
 
-struct X2  : X1 {  // expected-note 2 {{'X2' declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
-};
-X3 x3; // expected-note {{first required here}}
+struct X2  : X1 {
+#if __cplusplus <= 199711L
+// expected-note@-2 2 {{'X2' declared here}}
+#endif
 
-
-struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
-// expected-error {{must explicitly initialize the reference member 'rx2'}}
-  X2 x2; 	// expected-note {{member is declared here}}
-  X2 & rx2; // expected-note {{declared here}}
+   X2(int);
 };
 
-X4 x4; // expected-note {{first required here}}
-
+struct X3 : public X2 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+#else
+// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
+#endif
+};
+
+X3 x3;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}}
+#endif
+
+struct X4 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{must explicitly initialize the member 'x2'}}
+// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}}
+#endif
+
+  X2 x2;
+#if 

[PATCH] D21626: Lit C++11 Compatibility Patch #10

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge marked 2 inline comments as done.
tigerleapgorge added inline comments.



Comment at: test/SemaCXX/PR9572.cpp:34
+// expected-error@-2 {{non-deleted function '~Bar' cannot override a deleted 
function}}
+// expected-note@-3 {{while declaring the implicit destructor for 'Bar'}}
+#endif

Clang added this note quite recently.


https://reviews.llvm.org/D21626



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


[PATCH] D21626: Lit C++11 Compatibility Patch #10

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 89736.
tigerleapgorge added a comment.

Updated patch in accordance to Richard Smith's comments.


https://reviews.llvm.org/D21626

Files:
  test/Modules/Inputs/merge-using-decls/b.h
  test/Modules/merge-using-decls.cpp
  test/SemaCXX/PR9572.cpp
  test/SemaCXX/default-assignment-operator.cpp
  test/SemaCXX/default-constructor-initializers.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,11 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1466,24 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+// expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: test/SemaCXX/default-constructor-initializers.cpp
===
--- test/SemaCXX/default-constructor-initializers.cpp
+++ test/SemaCXX/default-constructor-initializers.cpp
@@ -1,26 +1,59 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct X1 { // has no implicit default constructor
X1(int);
 };
 
-struct X2  : X1 {  // expected-note 2 {{'X2' declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
-};
-X3 x3; // expected-note {{first required here}}
+struct X2  : X1 {
+#if __cplusplus <= 199711L
+// expected-note@-2 2 {{'X2' declared here}}
+#endif
 
-
-struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
-// expected-error {{must explicitly initialize the reference member 'rx2'}}
-  X2 x2; 	// expected-note {{member is declared here}}
-  X2 & rx2; // expected-note {{declared here}}
+   X2(int);
 };
 
-X4 x4; // expected-note {{first required here}}
-
+struct X3 : public X2 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+#else
+// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
+#endif
+};
+
+X3 x3;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}}
+#endif
+
+struct X4 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{must explicitly initialize the member 'x2'}}
+// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}}
+#endif
+
+  X2 x2;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{member is declared here}}
+#else
+  // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}}
+#endif
+
+  X2 & rx2;
+#if __cplusplus <= 

[PATCH] D29972: Make Lit tests C++11 compatible - accessible destructors

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge abandoned this revision.
tigerleapgorge added a comment.

https://reviews.llvm.org/D20710 is a superset of this patch.
https://reviews.llvm.org/D20710 has been committed in 
https://reviews.llvm.org/rL296184.
No need for this patch.


https://reviews.llvm.org/D29972



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


[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 89734.
vsk added a comment.

- Add a small test that shows why the 'isIntegerType' check is required (we'd 
crash otherwise).


https://reviews.llvm.org/D29437

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ubsan-promoted-arith.cpp


Index: test/CodeGen/ubsan-promoted-arith.cpp
===
--- test/CodeGen/ubsan-promoted-arith.cpp
+++ test/CodeGen/ubsan-promoted-arith.cpp
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope();
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())


Index: test/CodeGen/ubsan-promoted-arith.cpp
===
--- test/CodeGen/ubsan-promoted-arith.cpp
+++ test/CodeGen/ubsan-promoted-arith.cpp
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope();
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 89733.
vsk added a comment.

- Make the suggested readability improvements, and fix a comment in the test 
case.


https://reviews.llvm.org/D29369

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/compound-assign-overflow.c
  test/CodeGen/ubsan-promoted-arith.cpp
  test/CodeGen/unsigned-promotion.c

Index: test/CodeGen/unsigned-promotion.c
===
--- test/CodeGen/unsigned-promotion.c
+++ test/CodeGen/unsigned-promotion.c
@@ -7,53 +7,6 @@
 // RUN:   -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=CHECKU
 
 unsigned short si, sj, sk;
-unsigned char ci, cj, ck;
-
-extern void opaqueshort(unsigned short);
-extern void opaquechar(unsigned char);
-
-// CHECKS-LABEL:   define void @testshortadd()
-// CHECKU-LABEL: define void @testshortadd()
-void testshortadd() {
-  // CHECKS:load i16, i16* @sj
-  // CHECKS:load i16, i16* @sk
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_add_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i16, i16* @sj
-  // CHECKU:  [[T2:%.*]] = zext i16 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i16, i16* @sk
-  // CHECKU:  [[T4:%.*]] = zext i16 [[T3]]
-  // CHECKU-NOT:  llvm.sadd
-  // CHECKU-NOT:  llvm.uadd
-  // CHECKU:  [[T5:%.*]] = add nsw i32 [[T2]], [[T4]]
-
-  si = sj + sk;
-}
-
-// CHECKS-LABEL:   define void @testshortsub()
-// CHECKU-LABEL: define void @testshortsub()
-void testshortsub() {
-
-  // CHECKS:load i16, i16* @sj
-  // CHECKS:load i16, i16* @sk
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_sub_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i16, i16* @sj
-  // CHECKU:  [[T2:%.*]] = zext i16 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i16, i16* @sk
-  // CHECKU:  [[T4:%.*]] = zext i16 [[T3]]
-  // CHECKU-NOT:  llvm.ssub
-  // CHECKU-NOT:  llvm.usub
-  // CHECKU:  [[T5:%.*]] = sub nsw i32 [[T2]], [[T4]]
-
-  si = sj - sk;
-}
 
 // CHECKS-LABEL:   define void @testshortmul()
 // CHECKU-LABEL: define void @testshortmul()
@@ -75,69 +28,3 @@
   // CHECKU:  [[T5:%.*]] = mul nsw i32 [[T2]], [[T4]]
   si = sj * sk;
 }
-
-// CHECKS-LABEL:   define void @testcharadd()
-// CHECKU-LABEL: define void @testcharadd()
-void testcharadd() {
-
-  // CHECKS:load i8, i8* @cj
-  // CHECKS:load i8, i8* @ck
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_add_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i8, i8* @cj
-  // CHECKU:  [[T2:%.*]] = zext i8 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i8, i8* @ck
-  // CHECKU:  [[T4:%.*]] = zext i8 [[T3]]
-  // CHECKU-NOT:  llvm.sadd
-  // CHECKU-NOT:  llvm.uadd
-  // CHECKU:  [[T5:%.*]] = add nsw i32 [[T2]], [[T4]]
-
-  ci = cj + ck;
-}
-
-// CHECKS-LABEL:   define void @testcharsub()
-// CHECKU-LABEL: define void @testcharsub()
-void testcharsub() {
-
-  // CHECKS:load i8, i8* @cj
-  // CHECKS:load i8, i8* @ck
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_sub_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i8, i8* @cj
-  // CHECKU:  [[T2:%.*]] = zext i8 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i8, i8* @ck
-  // CHECKU:  [[T4:%.*]] = zext i8 [[T3]]
-  // CHECKU-NOT:  llvm.ssub
-  // CHECKU-NOT:  llvm.usub
-  // CHECKU:  [[T5:%.*]] = sub nsw i32 [[T2]], [[T4]]
-
-  ci = cj - ck;
-}
-
-// CHECKS-LABEL:   define void @testcharmul()
-// CHECKU-LABEL: define void @testcharmul()
-void testcharmul() {
-
-  // CHECKS:load i8, i8* @cj
-  // CHECKS:load i8, i8* @ck
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_mul_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i8, i8* @cj
-  // CHECKU:  [[T2:%.*]] = zext i8 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i8, 

[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-24 Thread Julian Bangert via Phabricator via cfe-commits
jbangert added inline comments.



Comment at: lib/Tooling/RefactoringCallbacks.cpp:213
+llvm::errs() << "Node " << Element.Value
+ << " used in replacement template not bound in Matcher 
\n";
+llvm_unreachable("Unbound node in replacement template.");

sbenza wrote:
> I don't know if stderr is the best place for this error output.
> Maybe we should take a sink of some sort in the constructor.
There's a FIXME: above that addresses the need for better error handling, and 
this one just duplicated their workaround. 
Ultimately, clang::tooling:: should probably provide infrastructure for 
reporting problems (I would imagine all refactoring tools have errors 
occassionally, and they need some way of reporting/handling them). 



Comment at: lib/Tooling/RefactoringCallbacks.cpp:214
+ << " used in replacement template not bound in Matcher 
\n";
+llvm_unreachable("Unbound node in replacement template.");
+  }

sbenza wrote:
> I don't think this is ok.
> afaik, llvm_unreachable leads to undefined behavior if it is reached in opt 
> mode.
> This error can be triggered from user input. We should not fail that way.
Using llvm::report_fatal_error for now. See the above for better error 
handling. 


https://reviews.llvm.org/D29621



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


[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-24 Thread Julian Bangert via Phabricator via cfe-commits
jbangert updated this revision to Diff 89730.
jbangert marked an inline comment as done.
jbangert added a comment.

use llvm::report_fatal_error instead of unreachable.


https://reviews.llvm.org/D29621

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

Index: unittests/Tooling/RefactoringCallbacksTest.cpp
===
--- unittests/Tooling/RefactoringCallbacksTest.cpp
+++ unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -7,31 +7,30 @@
 //
 //===--===//
 
-#include "clang/Tooling/RefactoringCallbacks.h"
 #include "RewriterTestContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/RefactoringCallbacks.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 
 using namespace ast_matchers;
 
 template 
-void expectRewritten(const std::string ,
- const std::string ,
- const T ,
- RefactoringCallback ) {
-  MatchFinder Finder;
+void expectRewritten(const std::string , const std::string ,
+ const T , RefactoringCallback ) {
+  std::map FileToReplace;
+  ASTMatchRefactorer Finder(FileToReplace);
   Finder.addMatcher(AMatcher, );
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory());
   ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code))
   << "Parsing error in \"" << Code << "\"";
   RewriterTestContext Context;
   FileID ID = Context.createInMemoryFile("input.cc", Code);
-  EXPECT_TRUE(tooling::applyAllReplacements(Callback.getReplacements(),
+  EXPECT_TRUE(tooling::applyAllReplacements(FileToReplace["input.cc"],
 Context.Rewrite));
   EXPECT_EQ(Expected, Context.getRewrittenText(ID));
 }
@@ -61,40 +60,94 @@
   std::string Code = "void f() { int i = 1; }";
   std::string Expected = "void f() { int i = 2; }";
   ReplaceStmtWithText Callback("id", "2");
-  expectRewritten(Code, Expected, id("id", expr(integerLiteral())),
-  Callback);
+  expectRewritten(Code, Expected, id("id", expr(integerLiteral())), Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesStmtWithStmt) {
   std::string Code = "void f() { int i = false ? 1 : i * 2; }";
   std::string Expected = "void f() { int i = i * 2; }";
   ReplaceStmtWithStmt Callback("always-false", "should-be");
-  expectRewritten(Code, Expected,
-  id("always-false", conditionalOperator(
-  hasCondition(cxxBoolLiteral(equals(false))),
-  hasFalseExpression(id("should-be", expr(),
+  expectRewritten(
+  Code, Expected,
+  id("always-false",
+ conditionalOperator(hasCondition(cxxBoolLiteral(equals(false))),
+ hasFalseExpression(id("should-be", expr(),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesIfStmt) {
   std::string Code = "bool a; void f() { if (a) f(); else a = true; }";
   std::string Expected = "bool a; void f() { f(); }";
   ReplaceIfStmtWithItsBody Callback("id", true);
-  expectRewritten(Code, Expected,
-  id("id", ifStmt(
-  hasCondition(implicitCastExpr(hasSourceExpression(
-  declRefExpr(to(varDecl(hasName("a"),
+  expectRewritten(
+  Code, Expected,
+  id("id", ifStmt(hasCondition(implicitCastExpr(hasSourceExpression(
+   declRefExpr(to(varDecl(hasName("a"),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, RemovesEntireIfOnEmptyElse) {
   std::string Code = "void f() { if (false) int i = 0; }";
   std::string Expected = "void f() {  }";
   ReplaceIfStmtWithItsBody Callback("id", false);
   expectRewritten(Code, Expected,
-  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
-  Callback);
+  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
+  Callback);
 }
 
+TEST(RefactoringCallbacksTest, TemplateJustText) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { FOO }";
+  auto Callback = ReplaceNodeWithTemplate::create("id", "FOO");
+  EXPECT_FALSE(Callback.takeError());
+  expectRewritten(Code, Expected, id("id", declStmt()), **Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateSimpleSubst) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { long x = 1; }";
+  auto Callback = ReplaceNodeWithTemplate::create("decl", "long x = ${init}");
+  EXPECT_FALSE(Callback.takeError());
+  expectRewritten(Code, Expected,
+  id("decl", varDecl(hasInitializer(id("init", expr(),
+  **Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateLiteral) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { string x = 

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

2017-02-24 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Dominic, this (https://reviews.llvm.org/D28952) and  
https://reviews.llvm.org/D26061 look get to me! Let's get these two committed! 
We'd like to get to a place where in-tree incremental development can be done 
on the Z3 constraint manager.

On my machine total Analysis test time increases from 25s to 90s when the Z3 
tests are enabled using a static Z3 library. Testing time when Z3 is not 
enabled does not change measurably.

Here's how I suggest staging these in. Please give the bots time to settle 
after each commit.

1. Apply the refactoring changes from https://reviews.llvm.org/D26061. This is 
NFC (no functional change).
2. Split out the test changes from https://reviews.llvm.org/D28952. This would 
change the tests to use 'clang_analyze_cc1' and change the lit.cfg to add a 
normal substitution for it. (But not call the analyzer twice). This is also NFC.
3. Add the new constraint solver and the lit/CMake changes for for the rest of 
https://reviews.llvm.org/D28952.

This will separate the stuff that is unlikely to break from the build system 
changes, which might need to be reverted quickly.

Once this is done, we (I) will add a bot that automatically runs the Z3 tests 
to make sure we catch regressions that affect the Z3 solver.

With the bot in place we will review  https://reviews.llvm.org/D28953,  
https://reviews.llvm.org/D28954, and https://reviews.llvm.org/D28955 separately.

Does that sound good to you?


https://reviews.llvm.org/D28952



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


[PATCH] D20710: Lit C++11 Compatibility Patch #9

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296184: [Test] Make Lit tests C++11 compatible #9 (authored 
by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D20710?vs=87309=89728#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20710

Files:
  cfe/trunk/test/CodeGenCXX/debug-info-use-after-free.cpp
  cfe/trunk/test/CodeGenCXX/dynamic-cast-hint.cpp
  cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp
  cfe/trunk/test/SemaCXX/new-delete.cpp
  cfe/trunk/test/SemaCXX/no-wchar.cpp
  cfe/trunk/test/SemaCXX/virtual-member-functions-key-function.cpp
  cfe/trunk/test/SemaCXX/warn-bool-conversion.cpp
  cfe/trunk/test/SemaCXX/zero-length-arrays.cpp
  cfe/trunk/test/SemaTemplate/instantiate-c99.cpp
  cfe/trunk/test/SemaTemplate/temp_explicit.cpp
  cfe/trunk/test/SemaTemplate/value-dependent-null-pointer-constant.cpp

Index: cfe/trunk/test/SemaTemplate/instantiate-c99.cpp
===
--- cfe/trunk/test/SemaTemplate/instantiate-c99.cpp
+++ cfe/trunk/test/SemaTemplate/instantiate-c99.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // Test template instantiation for C99-specific features.
 
@@ -9,8 +11,13 @@
 struct DesigInit0 {
   void f(XType x, YType y) {
 T agg = { 
+#if __cplusplus <= 199711L
   .y = y, // expected-error{{does not refer}}
   .x = x  // expected-error{{does not refer}}
+#else
+  .y = static_cast(y), // expected-error{{does not refer}}
+  .x = static_cast(x)  // expected-error{{does not refer}}
+#endif
 };
   }
 };
@@ -44,7 +51,11 @@
 struct DesigArrayInit0 {
   void f(Val1 val1, Val2 val2) {
 T array = {
+#if __cplusplus <= 199711L
   [Subscript1] = val1,
+#else
+  [Subscript1] = static_cast(val1),
+#endif
   [Subscript2] = val2 // expected-error{{exceeds array bounds}}
 };
 
@@ -60,7 +71,11 @@
 struct DesigArrayRangeInit0 {
   void f(Val1 val1) {
 T array = {
+#if __cplusplus <= 199711L
   [Subscript1...Subscript2] = val1 // expected-error{{exceeds}}
+#else
+  [Subscript1...Subscript2] = static_cast(val1) // expected-error{{exceeds}}
+#endif
 };
   }
 };
@@ -74,7 +89,11 @@
 template
 struct CompoundLiteral0 {
   T f(Arg1 a1, Arg2 a2) {
+#if __cplusplus <= 199711L
 return (T){a1, a2};
+#else
+return (T){static_cast(a1), a2};
+#endif
   }
 };
 
Index: cfe/trunk/test/SemaTemplate/temp_explicit.cpp
===
--- cfe/trunk/test/SemaTemplate/temp_explicit.cpp
+++ cfe/trunk/test/SemaTemplate/temp_explicit.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
 //
 // Tests explicit instantiation of templates.
 template class X0 { };
@@ -98,7 +100,12 @@
 template struct X5::Inner2; // expected-note{{instantiation}}
 
 namespace N3 {
-  template struct N2::X5::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+  template struct N2::X5::Inner2;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+#else
+// expected-error@-4 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+#endif
 }
 
 struct X6 {
@@ -145,7 +152,17 @@
 namespace N2 {
   using namespace N1;
 
-  template struct X7; // expected-warning{{must occur in namespace}}
-
-  template struct X9; // expected-warning{{must occur at global scope}}
+  template struct X7;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}}
+#else
+// expected-error@-4 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}}
+#endif
+
+  template struct X9;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{explicit instantiation of 'X9' must occur at global scope}}
+#else
+// expected-error@-4 {{explicit instantiation of 'X9' must occur at global scope}}
+#endif
 }
Index: cfe/trunk/test/SemaTemplate/value-dependent-null-pointer-constant.cpp
===
--- cfe/trunk/test/SemaTemplate/value-dependent-null-pointer-constant.cpp
+++ cfe/trunk/test/SemaTemplate/value-dependent-null-pointer-constant.cpp
@@ -1,17 +1,30 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 template
 struct X0 {
   const char *f0(bool Cond) {
 return Cond? "honk" : N;
+#if __cplusplus >= 201103L
+// expected-error@-2 {{incompatible operand types ('const char *' and 'int')}}
+#else
+// expected-no-diagnostics
+#endif
   }
 
  

Re: r296166 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

2017-02-24 Thread Renato Golin via cfe-commits
On 24 February 2017 at 20:49, Nico Weber via cfe-commits
 wrote:
> Author: nico
> Date: Fri Feb 24 14:49:00 2017
> New Revision: 296166
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296166=rev
> Log:
> clang-format: Don't leave behind temp files in -i mode on Windows, PR26125
>
> Fix and analysis by Wei Mao  (see bug), test by me.

Hi Nico,

This one looks yours:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/5005

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/4075

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/4386

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/4439

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/4450

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


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

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Looks NFC to me.




Comment at: lib/CodeGen/CGBlocks.cpp:1414
+
+} // end anonymous namespace
+

I don't see the need for two GenericInfo types (although it's plausible it'll 
make sense with your upcoming changes!). I had in mind a single 'enum 
BlockCaptureOperationType' with 8 entries, and a 'struct BlockCaptureOperation'.



Comment at: lib/CodeGen/CGBlocks.cpp:1478
+  }
+}
+

Ditto (re: removing continue statements where possible).



Comment at: lib/CodeGen/CGBlocks.cpp:1666
+  }
+}
+

It looks like there are 4 paths which prep some part of a DestroyInfo and then 
fall through to the emplace_back. I think this logic would be easier to follow 
if the emplace_backs occurred right after the DestroyInfo is prepped (i.e, have 
4 emplace_backs, and none at the end of the for loop). That should let you get 
rid of 3 continue statements (imo those were hard to follow).


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

2017-02-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In https://reviews.llvm.org/D30316#686174, @yaxunl wrote:

>   AMDGPUTargetMachine::getNullPointerValue needs also be changed to match 
> this, otherwise the static initializer will be incorrect for null pointer to 
> private addr space. Do you plan to change that?


Yes, that came after I posted the initial version. I need to update to re-use 
that


https://reviews.llvm.org/D30316



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


[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

2017-02-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

AMDGPUTargetMachine::getNullPointerValue needs also be changed to match this, 
otherwise the static initializer will be incorrect for null pointer to private 
addr space. Do you plan to change that?


https://reviews.llvm.org/D30316



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


r296173 - Factor out more commonality between handling of deletion and exception specifications for special member functions.

2017-02-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 24 15:18:47 2017
New Revision: 296173

URL: http://llvm.org/viewvc/llvm-project?rev=296173=rev
Log:
Factor out more commonality between handling of deletion and exception 
specifications for special member functions.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=296173=296172=296173=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 24 15:18:47 2017
@@ -6371,11 +6371,28 @@ struct SpecialMemberVisitor {
   Sema::CXXSpecialMember CSM;
   Sema::InheritedConstructorInfo *ICI;
 
-  bool ConstArg = false;
+  // Properties of the special member, computed for convenience.
+  bool IsConstructor = false, IsAssignment = false, ConstArg = false;
 
   SpecialMemberVisitor(Sema , CXXMethodDecl *MD, Sema::CXXSpecialMember CSM,
Sema::InheritedConstructorInfo *ICI)
   : S(S), MD(MD), CSM(CSM), ICI(ICI) {
+switch (CSM) {
+case Sema::CXXDefaultConstructor:
+case Sema::CXXCopyConstructor:
+case Sema::CXXMoveConstructor:
+  IsConstructor = true;
+  break;
+case Sema::CXXCopyAssignment:
+case Sema::CXXMoveAssignment:
+  IsAssignment = true;
+  break;
+case Sema::CXXDestructor:
+  break;
+case Sema::CXXInvalid:
+  llvm_unreachable("invalid special member kind");
+}
+
 if (MD->getNumParams()) {
   if (const ReferenceType *RT =
   MD->getParamDecl(0)->getType()->getAs())
@@ -6383,6 +6400,13 @@ struct SpecialMemberVisitor {
 }
   }
 
+  Derived () { return static_cast(*this); }
+
+  /// Is this a "move" special member?
+  bool isMove() const {
+return CSM == Sema::CXXMoveConstructor || CSM == Sema::CXXMoveAssignment;
+  }
+
   /// Look up the corresponding special member in the given class.
   Sema::SpecialMemberOverloadResult lookupIn(CXXRecordDecl *Class,
  unsigned Quals, bool IsMutable) {
@@ -6390,16 +6414,68 @@ struct SpecialMemberVisitor {
ConstArg && !IsMutable);
   }
 
+  /// Look up the constructor for the specified base class to see if it's
+  /// overridden due to this being an inherited constructor.
+  Sema::SpecialMemberOverloadResult lookupInheritedCtor(CXXRecordDecl *Class) {
+if (!ICI)
+  return {};
+assert(CSM == Sema::CXXDefaultConstructor);
+auto *BaseCtor =
+  cast(MD)->getInheritedConstructor().getConstructor();
+if (auto *MD = ICI->findConstructorForBase(Class, BaseCtor).first)
+  return MD;
+return {};
+  }
+
   /// A base or member subobject.
   typedef llvm::PointerUnion Subobject;
 
+  /// Get the location to use for a subobject in diagnostics.
   static SourceLocation getSubobjectLoc(Subobject Subobj) {
+// FIXME: For an indirect virtual base, the direct base leading to
+// the indirect virtual base would be a more useful choice.
 if (auto *B = Subobj.dyn_cast())
   return B->getBaseTypeLoc();
 else
   return Subobj.get()->getLocation();
   }
 
+  enum BasesToVisit {
+/// Visit all non-virtual (direct) bases.
+VisitNonVirtualBases,
+/// Visit all direct bases, virtual or not.
+VisitDirectBases,
+/// Visit all non-virtual bases, and all virtual bases if the class
+/// is not abstract.
+VisitPotentiallyConstructedBases,
+/// Visit all direct or virtual bases.
+VisitAllBases
+  };
+
+  // Visit the bases and members of the class.
+  bool visit(BasesToVisit Bases) {
+CXXRecordDecl *RD = MD->getParent();
+
+if (Bases == VisitPotentiallyConstructedBases)
+  Bases = RD->isAbstract() ? VisitNonVirtualBases : VisitAllBases;
+
+for (auto  : RD->bases())
+  if ((Bases == VisitDirectBases || !B.isVirtual()) &&
+  getDerived().visitBase())
+return true;
+
+if (Bases == VisitAllBases)
+  for (auto  : RD->vbases())
+if (getDerived().visitBase())
+  return true;
+
+for (auto *F : RD->fields())
+  if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
+  getDerived().visitField(F))
+return true;
+
+return false;
+  }
 };
 }
 
@@ -6408,8 +6484,6 @@ struct SpecialMemberDeletionInfo
 : SpecialMemberVisitor {
   bool Diagnose;
 
-  // Properties of the special member, computed for convenience.
-  bool IsConstructor, IsAssignment, IsMove;
   SourceLocation Loc;
 
   bool AllFieldsAreConst;
@@ -6418,30 +6492,7 @@ struct SpecialMemberDeletionInfo
 Sema::CXXSpecialMember CSM,
 Sema::InheritedConstructorInfo *ICI, bool Diagnose)
   : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
-IsConstructor(false), 

[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

2017-02-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In https://reviews.llvm.org/D30316#686089, @yaxunl wrote:

> LGTM. Thanks! I assume you will make corresponding changes in backend.


This is to match r295891, so then https://reviews.llvm.org/D28937 is required 
to fix addrspacecast


https://reviews.llvm.org/D30316



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


[PATCH] D21626: Lit C++11 Compatibility Patch #10

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

LGTM with a couple of changes.




Comment at: test/Modules/Inputs/merge-using-decls/a.h:25
 
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
 template struct E : X, T {

I don't see a reason to `#ifdef` this portion, which should work either way, 
and likewise for the other change to this file. (The changes to the other 
header and to the cpp file look fine and appropriate, though.)



Comment at: test/SemaCXX/warn-thread-safety-parsing.cpp:1273
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif

Please add FIXMEs to this test. These cases are not supposed to be permitted.


https://reviews.llvm.org/D21626



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


Re: [PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via cfe-commits



On 2/24/17 1:48 PM, Eric Fiselier wrote:
Inserting arbitrary feature macros into CMake should not be a 
supported scenario because it results is macros, such as this one, 
which are seemingly dead.


Good point.


Jon



/Eric

On Fri, Feb 24, 2017 at 1:44 PM, Jonathan Roelofs 
> wrote:




On 2/24/17 1:30 PM, Eric Fiselier via Phabricator wrote:

EricWF added a comment.

In https://reviews.llvm.org/D30339#685921
, @jroelofs wrote:

In https://reviews.llvm.org/D30339#685919
, @rmaprath wrote:

Perhaps change `config.h` and remove the definition
there and adjust other places accordingly?

The current form is very easy to trip over.


Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag,
not a defined/not-defined flag. Please don't change from
one form to the other... it's disruptive to build systems.


I actually think it's better to maintain consistency between
libc++ and libc++abi. And libc++ never uses 0/1 flags. So I
would rather see a fix in `config.h`.

Frankly I don't care that it is disruptive to build systems
unless it's the build system owned by LLVM.


What I really care about is the interface between the build system
owned by LLVM, and the one driving it.


Jon




Repository:
   rL LLVM

https://reviews.llvm.org/D30339 




-- 
Jon Roelofs

jonat...@codesourcery.com 
CodeSourcery / Mentor Embedded




--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


[PATCH] D20710: Lit C++11 Compatibility Patch #9

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

LGTM


https://reviews.llvm.org/D20710



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


r296171 - Try to unbreak tests after r296166

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 15:01:43 2017
New Revision: 296171

URL: http://llvm.org/viewvc/llvm-project?rev=296171=rev
Log:
Try to unbreak tests after r296166

Looks like %T isn't per-test but per-test-directory, and
the rm was deleting temp files written by other tests in
test/Format.  Limit the rm's scope a bit.

Modified:
cfe/trunk/test/Format/inplace.cpp

Modified: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296171=296170=296171=diff
==
--- cfe/trunk/test/Format/inplace.cpp (original)
+++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 15:01:43 2017
@@ -1,6 +1,6 @@
 // Regression test to check that clang-format does not leave behind temporary
 // files on Windows when doing in-place formatting.
-// RUN: rm %T/*
+// RUN: rm %T/inplace*
 // RUN: cp %s %T/inplace.cpp
 // RUN: clang-format -style=LLVM -i %T/inplace.cpp
 // RUN: ls %T > %T/files.txt


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


r296170 - [ODRHash] Add handling of bitfields

2017-02-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 24 14:59:28 2017
New Revision: 296170

URL: http://llvm.org/viewvc/llvm-project?rev=296170=rev
Log:
[ODRHash] Add handling of bitfields

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296170=296169=296170=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Feb 24 
14:59:28 2017
@@ -133,14 +133,20 @@ def err_module_odr_violation_mismatch_de
   "static assert with condition|"
   "static assert with message|"
   "static assert with %select{|no }4message|"
-  "field %4|field %4 with type %5}3">;
+  "field %4|"
+  "field %4 with type %5|"
+  "%select{non-|}5bitfield %4|"
+  "bitfield %4 with one width expression}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
   "static assert with different condition|"
   "static assert with different message|"
   "static assert with %select{|no }2message|"
-  "field %2|field %2 with type %3}1">;
+  "field %2|"
+  "field %2 with type %3|"
+  "%select{non-|}3bitfield %2|"
+  "bitfield %2 with different width expression}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296170=296169=296170=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 14:59:28 2017
@@ -183,6 +183,13 @@ public:
 
   void VisitFieldDecl(const FieldDecl *D) {
 Inherited::VisitFieldDecl(D);
+
+const bool IsBitfield = D->isBitField();
+Hash.AddBoolean(IsBitfield);
+
+if (IsBitfield) {
+  AddStmt(D->getBitWidth());
+}
   }
 };
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296170=296169=296170=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Feb 24 14:59:28 2017
@@ -9063,6 +9063,8 @@ void ASTReader::diagnoseOdrViolations()
 StaticAssertOnlyMessage,
 FieldName,
 FieldTypeName,
+FieldSingleBitField,
+FieldDifferentWidthBitField
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9213,6 +9215,30 @@ void ASTReader::diagnoseOdrViolations()
   }
 }
 
+const bool IsFirstBitField = FirstField->isBitField();
+const bool IsSecondBitField = SecondField->isBitField();
+if (IsFirstBitField != IsSecondBitField) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldSingleBitField)
+  << FirstII << IsFirstBitField;
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldSingleBitField)
+  << SecondII << IsSecondBitField;
+  Diagnosed = true;
+  break;
+}
+
+if (IsFirstBitField && IsSecondBitField) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldDifferentWidthBitField)
+  << FirstII << FirstField->getBitWidth()->getSourceRange();
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldDifferentWidthBitField)
+  << SecondII << SecondField->getBitWidth()->getSourceRange();
+  Diagnosed = true;
+  break;
+}
+
 break;
   }
   }

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=296170=296169=296170=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Feb 24 14:59:28 2017
@@ -191,6 +191,47 @@ S5 s5;
 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 
'A' (aka 'int')}}
 #endif
 
+#if defined(FIRST)
+struct S6 {
+  unsigned x;
+};
+#elif defined(SECOND)
+struct S6 {
+  unsigned x : 1;
+};
+#else
+S6 s6;
+// expected-error@second.h:* {{'Field::S6' has different definitions in 
different modules; first difference is definition in module 'SecondModule' 

[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge accepted this revision.
tigerleapgorge added a comment.
This revision is now accepted and ready to land.

Of the 3 tests.
format-strings.cpp and printf-cstr.cpp have been commited in r294979
For warn-thread-safety-parsing.cpp, bug 32066 has been filed to track the lack 
of thread safety errors in C++11

Closing out this code review.


https://reviews.llvm.org/D29685



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


r296166 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 14:49:00 2017
New Revision: 296166

URL: http://llvm.org/viewvc/llvm-project?rev=296166=rev
Log:
clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

Fix and analysis by Wei Mao  (see bug), test by me.

Added:
cfe/trunk/test/Format/inplace.cpp
Modified:
cfe/trunk/tools/clang-format/ClangFormat.cpp

Added: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296166=auto
==
--- cfe/trunk/test/Format/inplace.cpp (added)
+++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 14:49:00 2017
@@ -0,0 +1,263 @@
+// Regression test to check that clang-format does not leave behind temporary
+// files on Windows when doing in-place formatting.
+// RUN: rm %T/*
+// RUN: cp %s %T/inplace.cpp
+// RUN: clang-format -style=LLVM -i %T/inplace.cpp
+// RUN: ls %T > %T/files.txt
+// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
+
+// CHECK-NOT: RF{{.*}}.TMP
+
+// The file needs to be larger than 16kiB so that Windows creates a real file
+// mapping object for it.
+ int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int 

Re: [PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Eric Fiselier via cfe-commits
Inserting arbitrary feature macros into CMake should not be a supported
scenario because it results is macros, such as this one, which are
seemingly dead.

/Eric

On Fri, Feb 24, 2017 at 1:44 PM, Jonathan Roelofs  wrote:

>
>
> On 2/24/17 1:30 PM, Eric Fiselier via Phabricator wrote:
>
>> EricWF added a comment.
>>
>> In https://reviews.llvm.org/D30339#685921, @jroelofs wrote:
>>
>> In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:
>>>
>>> Perhaps change `config.h` and remove the definition there and adjust
 other places accordingly?

 The current form is very easy to trip over.

>>>
>>> Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a
>>> defined/not-defined flag. Please don't change from one form to the other...
>>> it's disruptive to build systems.
>>>
>>
>> I actually think it's better to maintain consistency between libc++ and
>> libc++abi. And libc++ never uses 0/1 flags. So I would rather see a fix in
>> `config.h`.
>>
>> Frankly I don't care that it is disruptive to build systems unless it's
>> the build system owned by LLVM.
>>
>
> What I really care about is the interface between the build system owned
> by LLVM, and the one driving it.
>
>
> Jon
>
>
>
>>
>> Repository:
>>rL LLVM
>>
>> https://reviews.llvm.org/D30339
>>
>>
>>
>>
> --
> Jon Roelofs
> jonat...@codesourcery.com
> CodeSourcery / Mentor Embedded
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via cfe-commits



On 2/24/17 1:30 PM, Eric Fiselier via Phabricator wrote:

EricWF added a comment.

In https://reviews.llvm.org/D30339#685921, @jroelofs wrote:


In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:


Perhaps change `config.h` and remove the definition there and adjust other 
places accordingly?

The current form is very easy to trip over.


Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a 
defined/not-defined flag. Please don't change from one form to the other... 
it's disruptive to build systems.


I actually think it's better to maintain consistency between libc++ and 
libc++abi. And libc++ never uses 0/1 flags. So I would rather see a fix in 
`config.h`.

Frankly I don't care that it is disruptive to build systems unless it's the 
build system owned by LLVM.


What I really care about is the interface between the build system owned 
by LLVM, and the one driving it.



Jon




Repository:
   rL LLVM

https://reviews.llvm.org/D30339





--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


[libclc] r296164 - .gitignore: Ignore amdgcn-mesa object directory

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 14:32:18 2017
New Revision: 296164

URL: http://llvm.org/viewvc/llvm-project?rev=296164=rev
Log:
.gitignore: Ignore amdgcn-mesa object directory

Modified:
libclc/trunk/.gitignore

Modified: libclc/trunk/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.gitignore?rev=296164=296163=296164=diff
==
--- libclc/trunk/.gitignore (original)
+++ libclc/trunk/.gitignore Fri Feb 24 14:32:18 2017
@@ -1,6 +1,7 @@
 Makefile
 amdgcn--
 amdgcn--amdhsa
+amdgcn-mesa-mesa3d
 build/*.pyc
 built_libs/
 generic--


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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D30339#685921, @jroelofs wrote:

> In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:
>
> > Perhaps change `config.h` and remove the definition there and adjust other 
> > places accordingly?
> >
> > The current form is very easy to trip over.
>
>
> Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a 
> defined/not-defined flag. Please don't change from one form to the other... 
> it's disruptive to build systems.


I actually think it's better to maintain consistency between libc++ and 
libc++abi. And libc++ never uses 0/1 flags. So I would rather see a fix in 
`config.h`.

Frankly I don't care that it is disruptive to build systems unless it's the 
build system owned by LLVM.


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

This works for me, but the idiomatic macro usage in libc++, and (hopefully) 
libc++abi should always use `defined(FOO)` as opposed to `!FOO`. I'll clean 
this up in the next week if nobody else wants to.


Repository:
  rL LLVM

https://reviews.llvm.org/D30343



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


RE: [clang-tools-extra] r296110 - [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Yung, Douglas via cfe-commits
Hi Eric,

I don't know if you are aware, but one of the tests you added in this change is 
failing on the PS4 Windows bot. The test is " Clang Tools :: 
change-namespace/white-list.cpp". Can you please take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Eric Liu via cfe-commits
> Sent: Friday, February 24, 2017 3:55
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r296110 - [change-namepsace] make it possible to
> whitelist symbols so they don't get updated.
> 
> Author: ioeric
> Date: Fri Feb 24 05:54:45 2017
> New Revision: 296110
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296110=rev
> Log:
> [change-namepsace] make it possible to whitelist symbols so they don't get
> updated.
> 
> Reviewers: hokein
> 
> Reviewed By: hokein
> 
> Subscribers: cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D30328
> 
> Added:
> clang-tools-extra/trunk/test/change-namespace/Inputs/
> clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
> clang-tools-extra/trunk/test/change-namespace/white-list.cpp
> Modified:
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> clang-tools-extra/trunk/unittests/change-
> namespace/ChangeNamespaceTests.cpp
> 
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-
> namespace/ChangeNamespace.cpp?rev=296110=296109=296110=diff
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Fri Feb
> +++ 24 05:54:45 2017
> @@ -290,6 +290,7 @@ AST_MATCHER(EnumDecl, isScoped) {
> 
>  ChangeNamespaceTool::ChangeNamespaceTool(
>  llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +llvm::ArrayRef WhiteListedSymbolPatterns,
>  std::map *FileToReplacements,
>  llvm::StringRef FallbackStyle)
>  : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
> @@ -308,6 +309,9 @@ ChangeNamespaceTool::ChangeNamespaceTool
>}
>DiffOldNamespace = joinNamespaces(OldNsSplitted);
>DiffNewNamespace = joinNamespaces(NewNsSplitted);
> +
> +  for (const auto  : WhiteListedSymbolPatterns)
> +WhiteListedSymbolRegexes.emplace_back(Pattern);
>  }
> 
>  void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder)
> { @@ -736,6 +740,9 @@ void ChangeNamespaceTool::replaceQualifi
>Result.SourceManager->getSpellingLoc(End)),
>*Result.SourceManager, Result.Context->getLangOpts());
>std::string FromDeclName = FromDecl->getQualifiedNameAsString();
> +  for (llvm::Regex  : WhiteListedSymbolRegexes)
> +if (RE.match(FromDeclName))
> +  return;
>std::string ReplaceName =
>getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
>// Checks if there is any using namespace declarations that can shorten the
> 
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-
> namespace/ChangeNamespace.h?rev=296110=296109=296110=diff
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Fri Feb
> +++ 24 05:54:45 2017
> @@ -50,6 +50,7 @@ public:
>// files matching `FilePattern`.
>ChangeNamespaceTool(
>llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +  llvm::ArrayRef WhiteListedSymbolPatterns,
>std::map *FileToReplacements,
>llvm::StringRef FallbackStyle = "LLVM");
> 
> @@ -164,6 +165,9 @@ private:
>// CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
>// been processed so that we don't handle them twice.
>llvm::SmallPtrSet ProcessedFuncRefs;
> +  // Patterns of symbol names whose references are not expected to be
> + updated  // when changing namespaces around them.
> +  std::vector WhiteListedSymbolRegexes;
>  };
> 
>  } // namespace change_namespace
> 
> Modified: clang-tools-extra/trunk/change-
> namespace/tool/ClangChangeNamespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-
> namespace/tool/ClangChangeNamespace.cpp?rev=296110=296109=296110=di
> ff
> ==
> --- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> (original)
> +++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.c
> +++ 

[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:2380
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope();

I don't think you need the isIntegerType check here?


https://reviews.llvm.org/D29437



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


[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

2017-02-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks! I assume you will make corresponding changes in backend.


https://reviews.llvm.org/D30316



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

aaron.ballman wrote:
> arphaman wrote:
> > aaron.ballman wrote:
> > > arphaman wrote:
> > > > aaron.ballman wrote:
> > > > > I have strong reservations about this -- users are going to have no 
> > > > > idea what attributes are and are not supported because they're not 
> > > > > going to know whether the attribute has a subject list or requires 
> > > > > delayed parsing. We have a considerable number of attributes for 
> > > > > which the Subjects line is currently commented out simply because no 
> > > > > one has bothered to fix that. This means those attributes can't be 
> > > > > used with this pragma until someone fixes that, but when it happens, 
> > > > > they magically can be used, which is a good thing. But the converse 
> > > > > is more problematic -- if there's an existing Subjects line that gets 
> > > > > removed because a subject is added that is difficult to express in 
> > > > > TableGen it may break user code.
> > > > > 
> > > > > We can fix the discoverability issues somewhat by updating the 
> > > > > documentation emitter to spit out some wording that says when an 
> > > > > attribute is/is not supported by this feature, but that only works 
> > > > > for attributes which have documentation and so it's not a 
> > > > > particularly reliable workaround.
> > > > > I have strong reservations about this -- users are going to have no 
> > > > > idea what attributes are and are not supported because they're not 
> > > > > going to know whether the attribute has a subject list or requires 
> > > > > delayed parsing. We have a considerable number of attributes for 
> > > > > which the Subjects line is currently commented out simply because no 
> > > > > one has bothered to fix that. This means those attributes can't be 
> > > > > used with this pragma until someone fixes that, but when it happens, 
> > > > > they magically can be used, which is a good thing. But the converse 
> > > > > is more problematic -- if there's an existing Subjects line that gets 
> > > > > removed because a subject is added that is difficult to express in 
> > > > > TableGen it may break user code.
> > > > 
> > > > That's a good point. I think we can address this problem by creating a 
> > > > test that verifies the list of attributes that support the pragma. This 
> > > > would allow us to ensure that no attributes loose the ability to use 
> > > > the pragma.
> > > > 
> > > > > We can fix the discoverability issues somewhat by updating the 
> > > > > documentation emitter to spit out some wording that says when an 
> > > > > attribute is/is not supported by this feature, but that only works 
> > > > > for attributes which have documentation and so it's not a 
> > > > > particularly reliable workaround.
> > > > 
> > > > We can enforce the rule that the attributes can only be used with 
> > > > '#pragma clang attribute' when they're documented. This way we can 
> > > > ensure that all attributes that can be used with the pragma are 
> > > > explicitly documented.
> > > > That's a good point. I think we can address this problem by creating a 
> > > > test that verifies the list of attributes that support the pragma. This 
> > > > would allow us to ensure that no attributes loose the ability to use 
> > > > the pragma.
> > > 
> > > That would be good.
> > > 
> > > > We can enforce the rule that the attributes can only be used with 
> > > > '#pragma clang attribute' when they're documented. This way we can 
> > > > ensure that all attributes that can be used with the pragma are 
> > > > explicitly documented.
> > > 
> > > This addresses the concern about discoverability, but it worsens the 
> > > concerns about fragility. The biggest problem is: the user has very 
> > > little hope of understanding what attributes will apply to what 
> > > declarations with which version of the compiler they're using. With this 
> > > sort of thing, the act of us adding documentation can impact the behavior 
> > > of a user's program from one release to the next.
> > > 
> > > While I can imagine this pragma reducing some amount of code clutter, it 
> > > is far too "magical" for me to feel comfortable with it (at least in the 
> > > proposed form). I cannot read the user's source code and understand what 
> > > attributes are going to be applied to which declarations, and that's not 
> > > a good story for usability of the feature.
> > What about the following idea:
> > 
> > The user has to include a **strict** set of declarations that receive the 
> > attribute explicitly, e.g.:
> > 
> > ```
> > #pragma clang attribute push([[noreturn]], apply_to={ function })
> > ``` 
> > 
> > The compiler then would verify 

[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a reviewer: doug.gregor.
mgorny added a subscriber: doug.gregor.
mgorny added a comment.

If I read the git correctly, the change that forbid defining builtins was 
initially made in https://reviews.llvm.org/rL64639. @doug.gregor, any chance 
you could help us over here? Is clang supposed to unconditionally reject those 
definitions, and are we supposed to always work-around it in compiler-rt, or 
should we consider adding some additional switch to allow them in clang?


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


r296161 - clang-format: Enable include sorting for style=Chromium

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 13:13:59 2017
New Revision: 296161

URL: http://llvm.org/viewvc/llvm-project?rev=296161=rev
Log:
clang-format: Enable include sorting for style=Chromium

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296161=296160=296161=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Feb 24 13:13:59 2017
@@ -656,7 +656,6 @@ FormatStyle getChromiumStyle(FormatStyle
 if (Language == FormatStyle::LK_ObjC)
   ChromiumStyle.ColumnLimit = 80;
   }
-  ChromiumStyle.SortIncludes = false;
   return ChromiumStyle;
 }
 


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


r296160 - clang-format: Fix many Objective-C formatting regressions from r289428

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 13:10:12 2017
New Revision: 296160

URL: http://llvm.org/viewvc/llvm-project?rev=296160=rev
Log:
clang-format: Fix many Objective-C formatting regressions from r289428

r289428 added a separate language kind for Objective-C, but kept many
"Language == LK_Cpp" checks untouched.  This introduced a "IsCpp()"
method that returns true for both C++ and Objective-C++, and replaces
all comparisons of Language with LK_Cpp with calls to this new method.

Also add a lot more test coverge for formatting things in LK_ObjC mode,
by having FormatTest's verifyFormat() test for LK_ObjC everything that's
being tested for LK_Cpp at the moment.

Fixes PR32060 and many other things.

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=296160=296159=296160=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri Feb 24 13:10:12 2017
@@ -465,7 +465,7 @@ struct FormatStyle {
 LK_Java,
 /// Should be used for JavaScript.
 LK_JavaScript,
-/// Should be used for ObjectiveC, ObjectiveC++.
+/// Should be used for Objective-C, Objective-C++.
 LK_ObjC,
 /// Should be used for Protocol Buffers
 /// (https://developers.google.com/protocol-buffers/).
@@ -473,6 +473,7 @@ struct FormatStyle {
 /// Should be used for TableGen code.
 LK_TableGen
   };
+  bool IsCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
 
   /// \brief Language, this format style is targeted at.
   LanguageKind Language;
@@ -872,6 +873,8 @@ inline StringRef getLanguageName(FormatS
   switch (Language) {
   case FormatStyle::LK_Cpp:
 return "C++";
+  case FormatStyle::LK_ObjC:
+return "Objective-C";
   case FormatStyle::LK_Java:
 return "Java";
   case FormatStyle::LK_JavaScript:

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=296160=296159=296160=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Feb 24 13:10:12 2017
@@ -156,7 +156,7 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
-Style.Language == FormatStyle::LK_Cpp &&
+Style.IsCpp() &&
 // FIXME: This is a temporary workaround for the case where 
clang-format
 // sets BreakBeforeParameter to avoid bin packing and this creates a
 // completely unnecessary line break after a template type that isn't
@@ -598,9 +598,7 @@ unsigned ContinuationIndenter::addTokenO
   // Any break on this level means that the parent level has been broken
   // and we need to avoid bin packing there.
   bool NestedBlockSpecialCase =
-  Style.Language != FormatStyle::LK_Cpp &&
-  Style.Language != FormatStyle::LK_ObjC &&
-  Current.is(tok::r_brace) && State.Stack.size() > 1 &&
+  !Style.IsCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 &&
   State.Stack[State.Stack.size() - 2].NestedBlockInlined;
   if (!NestedBlockSpecialCase)
 for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i)

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296160=296159=296160=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Feb 24 13:10:12 2017
@@ -1662,7 +1662,7 @@ bool isDeletedHeader(llvm::StringRef Hea
 tooling::Replacements
 fixCppIncludeInsertions(StringRef Code, const tooling::Replacements ,
 const FormatStyle ) {
-  if (Style.Language != FormatStyle::LanguageKind::LK_Cpp)
+  if (!Style.IsCpp())
 return Replaces;
 
   tooling::Replacements HeaderInsertions;
@@ -1864,7 +1864,7 @@ LangOptions getFormattingLangOpts(const
   LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
   LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
   LangOpts.LineComment = 1;
-  bool AlternativeOperators = Style.Language == FormatStyle::LK_Cpp;
+  bool AlternativeOperators = Style.IsCpp();
   LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;
   LangOpts.Bool = 1;
   LangOpts.ObjC1 = 1;

Modified: 

Re: r293604 - In VirtualCallChecker, handle indirect calls

2017-02-24 Thread Hans Wennborg via cfe-commits
On Mon, Jan 30, 2017 at 9:23 PM, Sam McCall via cfe-commits
 wrote:
> Author: sammccall
> Date: Mon Jan 30 23:23:20 2017
> New Revision: 293604
>
> URL: http://llvm.org/viewvc/llvm-project?rev=293604=rev
> Log:
> In VirtualCallChecker, handle indirect calls
>
> Summary:
> In VirtualCallChecker, handle indirect calls.
>
> getDirectCallee() can be nullptr, and dyn_cast(nullptr) is UB
>
> Reviewers: bkramer
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D29303
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
> cfe/trunk/test/Analysis/virtualcall.cpp

Merged to 4.0 in r296154 as suggested in the code review email thread.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29303: In VirtualCallChecker, handle indirect calls

2017-02-24 Thread Hans Wennborg via cfe-commits
Yes, this looks very straight-forward. Merged in r296154.

On Fri, Feb 24, 2017 at 4:29 AM, Sam McCall via cfe-commits
 wrote:
> Thanks Anna, I'm new to the release process here.
>
> Hans: this is a simple fix for a null-dereference in the static analyzer.
> Does it make sense to cherrypick?
>
> On Sat, Feb 18, 2017 at 2:46 AM, Anna Zaks via Phabricator
>  wrote:
>>
>> zaks.anna added a comment.
>>
>> Has this been cherry-picked into the clang 4.0 release branch? If not, we
>> should definitely do that!
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D29303
>>
>>
>>
>
>
> ___
> 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: r296063 - Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin"

2017-02-24 Thread Hans Wennborg via cfe-commits
Merged to 4.0 in r296152.

On Thu, Feb 23, 2017 at 5:16 PM, Hans Wennborg via cfe-commits
 wrote:
> Author: hans
> Date: Thu Feb 23 19:16:34 2017
> New Revision: 296063
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296063=rev
> Log:
> Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match 
> builtin"
>
> It caused PR31864. There is a patch in progress to fix that, but let's
> revert in the meantime.
>
> Modified:
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/test/Sema/atomic-ops.c
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=296063=296062=296063=diff
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Feb 23 19:16:34 2017
> @@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned T
>
>  /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
>  /// the specified properties.
> -static const char *getLockFreeValue(unsigned TypeWidth, unsigned 
> InlineWidth) {
> +static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
> +unsigned InlineWidth) {
>// Fully-aligned, power-of-2 sizes no larger than the inline
>// width will be inlined as lock-free operations.
> -  // Note: we do not need to check alignment since _Atomic(T) is always
> -  // appropriately-aligned in clang.
> -  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
> +  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
> +  TypeWidth <= InlineWidth)
>  return "2"; // "always lock free"
>// We cannot be certain what operations the lib calls might be
>// able to implement as lock-free on future processors.
> @@ -886,6 +886,7 @@ static void InitializePredefinedMacros(c
>  #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
>  Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
>  getLockFreeValue(TI.get##Type##Width(), \
> + TI.get##Type##Align(), \
>   InlineWidthBits));
>  DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
>  DEFINE_LOCK_FREE_MACRO(CHAR, Char);
> @@ -898,6 +899,7 @@ static void InitializePredefinedMacros(c
>  DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
>  Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
>  getLockFreeValue(TI.getPointerWidth(0),
> + TI.getPointerAlign(0),
>   InlineWidthBits));
>  #undef DEFINE_LOCK_FREE_MACRO
>}
>
> Modified: cfe/trunk/test/Sema/atomic-ops.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=296063=296062=296063=diff
> ==
> --- cfe/trunk/test/Sema/atomic-ops.c (original)
> +++ cfe/trunk/test/Sema/atomic-ops.c Thu Feb 23 19:16:34 2017
> @@ -14,7 +14,11 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK
>  _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
>  _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
>  _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
> +#ifdef __i386__
> +_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
> +#else
>  _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
> +#endif
>  _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
>
>  _Static_assert(__c11_atomic_is_lock_free(1), "");
>
>
> ___
> 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


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

2017-02-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch refactors the code figures out which block captures need to be 
copied/destroyed using special copy/destroy code.
This is a preparation patch for work on merging block copy/destroy routines.

Thanks for taking a look!


Repository:
  rL LLVM

https://reviews.llvm.org/D30345

Files:
  lib/CodeGen/CGBlocks.cpp

Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1373,6 +1373,110 @@
   return fn;
 }
 
+namespace {
+
+/// Represents a type of copy operation that should be performed for an entity
+/// that's captured by a block.
+enum class BlockCaptureCopyType {
+  CXXCopyCtor,
+  ARCWeak,
+  ARCStrong,
+  BlockObjectAssign
+};
+
+/// Represents a type of destroy operation that should be performed on an
+/// entity that's captured by a block.
+enum class BlockCaptureDestroyType {
+  CXXDtor,
+  ARCWeak,
+  ARCStrong,
+  BlockRelease
+};
+
+template  struct BlockCaptureCopyDestroyGenericInfo {
+  T Type;
+  BlockFieldFlags Flags;
+  const BlockDecl::Capture 
+  const CGBlockInfo::Capture 
+
+  BlockCaptureCopyDestroyGenericInfo(T Type, BlockFieldFlags Flags,
+ const BlockDecl::Capture ,
+ const CGBlockInfo::Capture )
+  : Type(Type), Flags(Flags), CI(CI), Capture(Capture) {}
+};
+
+using BlockCaptureCopyInfo =
+BlockCaptureCopyDestroyGenericInfo;
+
+using BlockCaptureDestroyInfo =
+BlockCaptureCopyDestroyGenericInfo;
+
+} // end anonymous namespace
+
+/// Find the set of block captures that need to be explicitly copied.
+static void
+computeBlockCopyEntries(const CGBlockInfo ,
+const LangOptions ,
+SmallVectorImpl ) {
+  for (const auto  : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+QualType Type = Variable->getType();
+const CGBlockInfo::Capture  = BlockInfo.getCapture(Variable);
+if (Capture.isConstant())
+  continue;
+
+if (CI.getCopyExpr()) {
+  assert(!CI.isByRef());
+  // don't bother computing flags
+  CopiedCaptures.emplace_back(BlockCaptureCopyType::CXXCopyCtor,
+  BlockFieldFlags(), CI, Capture);
+  continue;
+}
+BlockFieldFlags Flags;
+BlockCaptureCopyType CopyType = BlockCaptureCopyType::BlockObjectAssign;
+if (CI.isByRef()) {
+  Flags = BLOCK_FIELD_IS_BYREF;
+  if (Type.isObjCGCWeak())
+Flags |= BLOCK_FIELD_IS_WEAK;
+} else if (Type->isObjCRetainableType()) {
+  Flags = BLOCK_FIELD_IS_OBJECT;
+  bool isBlockPointer = Type->isBlockPointerType();
+  if (isBlockPointer)
+Flags = BLOCK_FIELD_IS_BLOCK;
+
+  // Special rules for ARC captures:
+  Qualifiers QS = Type.getQualifiers();
+
+  // We need to register __weak direct captures with the runtime.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Weak) {
+CopyType = BlockCaptureCopyType::ARCWeak;
+
+// We need to retain the copied value for __strong direct captures.
+  } else if (QS.getObjCLifetime() == Qualifiers::OCL_Strong) {
+// If it's a block pointer, we have to copy the block and
+// assign that to the destination pointer, so we might as
+// well use _Block_object_assign.  Otherwise we can avoid that.
+if (!isBlockPointer)
+  CopyType = BlockCaptureCopyType::ARCStrong;
+
+// Non-ARC captures of retainable pointers are strong and
+// therefore require a call to _Block_object_assign.
+  } else if (!QS.getObjCLifetime() && !LangOpts.ObjCAutoRefCount) {
+// fall through
+
+// Otherwise the memcpy is fine.
+  } else {
+continue;
+  }
+
+  // For all other types, the memcpy is fine.
+} else {
+  continue;
+}
+CopiedCaptures.emplace_back(CopyType, Flags, CI, Capture);
+  }
+}
+
 /// Generate the copy-helper function for a block closure object:
 ///   static void block_copy_helper(block_t *dst, block_t *src);
 /// The runtime will have previously initialized 'dst' by doing a
@@ -1431,78 +1535,27 @@
   dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
   dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
 
-  const BlockDecl *blockDecl = blockInfo.getBlockDecl();
-
-  for (const auto  : blockDecl->captures()) {
-const VarDecl *variable = CI.getVariable();
-QualType type = variable->getType();
-
-const CGBlockInfo::Capture  = blockInfo.getCapture(variable);
-if (capture.isConstant()) continue;
-
-const Expr *copyExpr = CI.getCopyExpr();
-BlockFieldFlags flags;
-
-bool useARCWeakCopy = false;
-bool useARCStrongCopy = false;
-
-if (copyExpr) {
-  assert(!CI.isByRef());
-  // don't bother computing flags
-
-} else if (CI.isByRef()) {
-  flags = BLOCK_FIELD_IS_BYREF;
-  if 

[libcxxabi] r296146 - [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Fri Feb 24 12:22:59 2017
New Revision: 296146

URL: http://llvm.org/viewvc/llvm-project?rev=296146=rev
Log:
[libcxxabi] Fix condition typo in rL296136

Made a mistake in the condition typo because LIBCXXABI_BAREMETAL is always
defined, I should have been checking the contents to see if it's enabled.

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


Modified:
libcxxabi/trunk/src/abort_message.cpp

Modified: libcxxabi/trunk/src/abort_message.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=296146=296145=296146=diff
==
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Fri Feb 24 12:22:59 2017
@@ -35,7 +35,7 @@ __attribute__((visibility("hidden"), nor
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif


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


[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296146: [libcxxabi] Fix condition typo in rL296136 (authored 
by rsingh).

Changed prior to commit:
  https://reviews.llvm.org/D30343?vs=89687=89693#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30343

Files:
  libcxxabi/trunk/src/abort_message.cpp


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs added a comment.

Going for post-commit.


https://reviews.llvm.org/D30343



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


[PATCH] D28772: [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma in macro argument pre-expansion mode when skipping a function body

2017-02-24 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296140: [Preprocessor] Fix incorrect token caching that 
occurs when lexing _Pragma (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D28772?vs=87801=89688#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28772

Files:
  cfe/trunk/include/clang/Lex/Preprocessor.h
  cfe/trunk/lib/Lex/PPCaching.cpp
  cfe/trunk/lib/Lex/Pragma.cpp
  cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c

Index: cfe/trunk/include/clang/Lex/Preprocessor.h
===
--- cfe/trunk/include/clang/Lex/Preprocessor.h
+++ cfe/trunk/include/clang/Lex/Preprocessor.h
@@ -1077,6 +1077,24 @@
   /// \brief Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
 
+  struct CachedTokensRange {
+CachedTokensTy::size_type Begin, End;
+  };
+
+private:
+  /// \brief A range of cached tokens that should be erased after lexing
+  /// when backtracking requires the erasure of such cached tokens.
+  Optional CachedTokenRangeToErase;
+
+public:
+  /// \brief Returns the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  CachedTokensRange LastCachedTokenRange();
+
+  /// \brief Erase the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  void EraseCachedTokens(CachedTokensRange TokenRange);
+
   /// \brief Make Preprocessor re-lex the tokens that were lexed since
   /// EnableBacktrackAtThisPos() was previously called.
   void Backtrack();
Index: cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
===
--- cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
+++ cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
@@ -0,0 +1,18 @@
+
+#define Outer(action) action
+
+void completeParam(int param) {
+;
+Outer(__extension__({ _Pragma("clang diagnostic push") }));
+param;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:1 %s | FileCheck %s
+// CHECK: param : [#int#]param
+
+void completeParamPragmaError(int param) {
+Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a parenthesized string literal}}
+param;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:16:1 %s | FileCheck %s
Index: cfe/trunk/lib/Lex/PPCaching.cpp
===
--- cfe/trunk/lib/Lex/PPCaching.cpp
+++ cfe/trunk/lib/Lex/PPCaching.cpp
@@ -35,6 +35,29 @@
   BacktrackPositions.pop_back();
 }
 
+Preprocessor::CachedTokensRange Preprocessor::LastCachedTokenRange() {
+  assert(isBacktrackEnabled());
+  auto PrevCachedLexPos = BacktrackPositions.back();
+  return CachedTokensRange{PrevCachedLexPos, CachedLexPos};
+}
+
+void Preprocessor::EraseCachedTokens(CachedTokensRange TokenRange) {
+  assert(TokenRange.Begin <= TokenRange.End);
+  if (CachedLexPos == TokenRange.Begin && TokenRange.Begin != TokenRange.End) {
+// We have backtracked to the start of the token range as we want to consume
+// them again. Erase the tokens only after consuming then.
+assert(!CachedTokenRangeToErase);
+CachedTokenRangeToErase = TokenRange;
+return;
+  }
+  // The cached tokens were committed, so they should be erased now.
+  assert(TokenRange.End == CachedLexPos);
+  CachedTokens.erase(CachedTokens.begin() + TokenRange.Begin,
+ CachedTokens.begin() + TokenRange.End);
+  CachedLexPos = TokenRange.Begin;
+  ExitCachingLexMode();
+}
+
 // Make Preprocessor re-lex the tokens that were lexed since
 // EnableBacktrackAtThisPos() was previously called.
 void Preprocessor::Backtrack() {
@@ -51,6 +74,13 @@
 
   if (CachedLexPos < CachedTokens.size()) {
 Result = CachedTokens[CachedLexPos++];
+// Erase the some of the cached tokens after they are consumed when
+// asked to do so.
+if (CachedTokenRangeToErase &&
+CachedTokenRangeToErase->End == CachedLexPos) {
+  EraseCachedTokens(*CachedTokenRangeToErase);
+  CachedTokenRangeToErase = None;
+}
 return;
   }
 
Index: cfe/trunk/lib/Lex/Pragma.cpp
===
--- cfe/trunk/lib/Lex/Pragma.cpp
+++ cfe/trunk/lib/Lex/Pragma.cpp
@@ -160,12 +160,23 @@
 
   ~LexingFor_PragmaRAII() {
 if (InMacroArgPreExpansion) {
+  // When committing/backtracking the cached pragma tokens in a macro
+  // argument pre-expansion we want to ensure that either the tokens which
+  // have been committed will be removed from the cache or that the tokens
+  // over which we just backtracked won't remain in the cache after they're
+  // consumed and that the caching will stop after consuming them.
+  // Otherwise the caching will interfere with the way macro expansion
+  // works, because we will continue to cache 

[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs added a comment.

Ah sorry for the mistake. Fix is here https://reviews.llvm.org/D30343


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


r296140 - [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma

2017-02-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Feb 24 11:45:16 2017
New Revision: 296140

URL: http://llvm.org/viewvc/llvm-project?rev=296140=rev
Log:
[Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma
in macro argument pre-expansion mode when skipping a function body

This commit fixes a token caching problem that currently occurs when clang is
skipping a function body (e.g. when looking for a code completion token) and at
the same time caching the tokens for _Pragma when lexing it in macro argument
pre-expansion mode.

When _Pragma is being lexed in macro argument pre-expansion mode, it caches the
tokens so that it can avoid interpreting the pragma immediately (as the macro
argument may not be used in the macro body), and then either backtracks over or
commits these tokens. The problem is that, when we're backtracking/committing in
such a scenario, there's already a previous backtracking position stored in
BacktrackPositions (as we're skipping the function body), and this leads to a
situation where the cached tokens from the pragma (like '(' 'string_literal'
and ')') will remain in the cached tokens array incorrectly even after they're
consumed (in the case of backtracking) or just ignored (in the case when they're
committed). Furthermore, what makes it even worse, is that because of a previous
backtracking position, the logic that deals with when should we call
ExitCachingLexMode in CachingLex no longer works for us in this situation, and
more tokens in the macro argument get cached, to the point where the EOF token
that corresponds to the macro argument EOF is cached. This problem leads to all
sorts of issues in code completion mode, where incorrect errors get presented
and code completion completely fails to produce completion results.

rdar://28523863

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

Added:
cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPCaching.cpp
cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=296140=296139=296140=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Feb 24 11:45:16 2017
@@ -1077,6 +1077,24 @@ public:
   /// \brief Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
 
+  struct CachedTokensRange {
+CachedTokensTy::size_type Begin, End;
+  };
+
+private:
+  /// \brief A range of cached tokens that should be erased after lexing
+  /// when backtracking requires the erasure of such cached tokens.
+  Optional CachedTokenRangeToErase;
+
+public:
+  /// \brief Returns the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  CachedTokensRange LastCachedTokenRange();
+
+  /// \brief Erase the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  void EraseCachedTokens(CachedTokensRange TokenRange);
+
   /// \brief Make Preprocessor re-lex the tokens that were lexed since
   /// EnableBacktrackAtThisPos() was previously called.
   void Backtrack();

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=296140=296139=296140=diff
==
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Fri Feb 24 11:45:16 2017
@@ -35,6 +35,29 @@ void Preprocessor::CommitBacktrackedToke
   BacktrackPositions.pop_back();
 }
 
+Preprocessor::CachedTokensRange Preprocessor::LastCachedTokenRange() {
+  assert(isBacktrackEnabled());
+  auto PrevCachedLexPos = BacktrackPositions.back();
+  return CachedTokensRange{PrevCachedLexPos, CachedLexPos};
+}
+
+void Preprocessor::EraseCachedTokens(CachedTokensRange TokenRange) {
+  assert(TokenRange.Begin <= TokenRange.End);
+  if (CachedLexPos == TokenRange.Begin && TokenRange.Begin != TokenRange.End) {
+// We have backtracked to the start of the token range as we want to 
consume
+// them again. Erase the tokens only after consuming then.
+assert(!CachedTokenRangeToErase);
+CachedTokenRangeToErase = TokenRange;
+return;
+  }
+  // The cached tokens were committed, so they should be erased now.
+  assert(TokenRange.End == CachedLexPos);
+  CachedTokens.erase(CachedTokens.begin() + TokenRange.Begin,
+ CachedTokens.begin() + TokenRange.End);
+  CachedLexPos = TokenRange.Begin;
+  ExitCachingLexMode();
+}
+
 // Make Preprocessor re-lex the tokens that were lexed since
 // EnableBacktrackAtThisPos() was previously called.
 void Preprocessor::Backtrack() {
@@ -51,6 +74,13 @@ void Preprocessor::CachingLex(Token 
 
   if (CachedLexPos < 

[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.

Made a mistake in the condition typo because LIBCXXABI_BAREMETAL is always 
defined, I should have been checking the contents to see if it's enabled


https://reviews.llvm.org/D30343

Files:
  src/abort_message.cpp


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:

> Perhaps change `config.h` and remove the definition there and adjust other 
> places accordingly?
>
> The current form is very easy to trip over.


Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a 
defined/not-defined flag. Please don't change from one form to the other... 
it's disruptive to build systems.


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

Perhaps change `config.h` and remove the definition there and adjust other 
places accordingly?

The current form is very easy to trip over.


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


Re: r295474 - [OpenMP] Fix cancellation point in task with no cancel

2017-02-24 Thread Hans Wennborg via cfe-commits
Merged to 4.0 in r296139 as requested on the r295473 commit thread.

On Fri, Feb 17, 2017 at 10:32 AM, Jonas Hahnfeld via cfe-commits
 wrote:
> Author: hahnfeld
> Date: Fri Feb 17 12:32:58 2017
> New Revision: 295474
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295474=rev
> Log:
> [OpenMP] Fix cancellation point in task with no cancel
>
> With tasks, the cancel may happen in another task. This has a different
> region info which means that we can't find it here.
>
> Differential Revision: https://reviews.llvm.org/D30091
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295474=295473=295474=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Feb 17 12:32:58 2017
> @@ -4716,7 +4716,9 @@ void CGOpenMPRuntime::emitCancellationPo
>// global_tid, kmp_int32 cncl_kind);
>if (auto *OMPRegionInfo =
>dyn_cast_or_null(CGF.CapturedStmtInfo)) {
> -if (OMPRegionInfo->hasCancel()) {
> +// For 'cancellation point taskgroup', the task region info may not have 
> a
> +// cancel. This may instead happen in another adjacent task.
> +if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
>llvm::Value *Args[] = {
>emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
>CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
>
> Modified: cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp?rev=295474=295473=295474=diff
> ==
> --- cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp Fri Feb 17 12:32:58 
> 2017
> @@ -78,6 +78,12 @@ for (int i = 0; i < argc; ++i) {
>  }
>  // CHECK: call i8* @__kmpc_omp_task_alloc(
>  // CHECK: call i32 @__kmpc_omp_task(
> +#pragma omp task
> +{
> +#pragma omp cancellation point taskgroup
> +}
> +// CHECK: call i8* @__kmpc_omp_task_alloc(
> +// CHECK: call i32 @__kmpc_omp_task(
>  #pragma omp parallel sections
>  {
>{
> @@ -118,6 +124,15 @@ for (int i = 0; i < argc; ++i) {
>
>  // CHECK: define internal i32 @{{[^(]+}}(i32
>  // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
> {{[^,]+}}, i32 {{[^,]+}}, i32 4)
> +// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
> +// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
> +// CHECK: [[EXIT]]
> +// CHECK: br label %[[RETURN:.+]]
> +// CHECK: [[RETURN]]
> +// CHECK: ret i32 0
> +
> +// CHECK: define internal i32 @{{[^(]+}}(i32
> +// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
> {{[^,]+}}, i32 {{[^,]+}}, i32 4)
>  // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
>  // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
>  // CHECK: [[EXIT]]
>
>
> ___
> 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: r295473 - [OpenMP] Remove barriers at cancel and cancellation point

2017-02-24 Thread Hans Wennborg via cfe-commits
Oops, it did. Thanks for reminding me; I've merged that in r296139.

On Thu, Feb 23, 2017 at 11:13 PM, Hahnfeld, Jonas
 wrote:
> Hi Hans,
>
> Did r295474 fall off your radar? Sorry that I asked for both commits in one 
> email, should I reply to the other original commit?
>
> Thanks,
> Jonas
>
>> -Original Message-
>> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf
>> Of Hans Wennborg
>> Sent: Thursday, February 23, 2017 7:46 PM
>> To: Alexey Bataev
>> Cc: Hahnfeld, Jonas; cfe-commits@lists.llvm.org
>> Subject: Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation
>> point
>>
>> Thanks! r296000.
>>
>> On Wed, Feb 22, 2017 at 8:15 PM, Alexey Bataev 
>> wrote:
>> > Yes, approved
>> >
>> > Best regards,
>> > Alexey Bataev
>> >
>> >> 23 февр. 2017 г., в 1:00, Hans Wennborg 
>> написал(а):
>> >>
>> >> Alexey: ping?
>> >>
>> >>> On Tue, Feb 21, 2017 at 11:07 AM, Hans Wennborg
>>  wrote:
>> >>> I'm Ok with it if Alexey approves.
>> >>>
>> >>> On Fri, Feb 17, 2017 at 10:52 AM, Hahnfeld, Jonas
>> >>>  wrote:
>>  Hi Hans, Alexey,
>> 
>>  can we merge this commit and r295474 for the 4.0 release or is it
>>  already too late for that? I will totally understand that and can
>>  apply these commits locally prior to installing.
>>  However, I think that these changes are quite focussed and bear
>>  minimal possibility of introducing regressions.
>> 
>>  Thanks,
>>  Jonas
>> 
>>  Am Freitag, den 17.02.2017, 18:32 + schrieb Jonas Hahnfeld via
>>  cfe-commits:
>> 
>>  Author: hahnfeld
>>  Date: Fri Feb 17 12:32:51 2017
>>  New Revision: 295473
>> 
>>  URL: http://llvm.org/viewvc/llvm-project?rev=295473=rev
>>  Log:
>>  [OpenMP] Remove barriers at cancel and cancellation point
>> 
>>  This resolves a deadlock with the cancel directive when there is no
>>  explicit cancellation point. In that case, the implicit barrier
>>  acts as cancellation point. After removing the barrier after
>>  cancel, the now unmatched barrier for the explicit cancellation
>>  point has to go as well.
>> 
>>  This has probably worked before rL255992: With the calls for the
>>  explicit barrier, it was sure that all threads passed a barrier before
>> exiting.
>> 
>>  Reported by Simon Convent and Joachim Protze!
>> 
>>  Differential Revision: https://reviews.llvm.org/D30088
>> 
>>  Modified:
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>> cfe/trunk/test/OpenMP/cancel_codegen.cpp
>> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D30339#685888, @EricWF wrote:

> isn't this incorrect because `config.h` always defines LIBCXX_BAREMETAL?


Oh, right, it needs to be:

  #if !LIBCXXABI_BAREMETAL || !defined(NDEBUG)


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

isn't this incorrect because `config.h` always defines LIBCXX_BAREMETAL?


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D30340: [libunwind] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296135: [libunwind] Disable calls to fprintf for baremetal 
targets. (authored by rsingh).

Changed prior to commit:
  https://reviews.llvm.org/D30340?vs=89676=89679#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30340

Files:
  libunwind/trunk/src/config.h


Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  
\
+  do { 
\
+abort();   
\
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
 __LINE__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   
\
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds


Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  \
+  do { \
+abort();   \
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  \
 __LINE__, msg);\
 fflush(stderr);\
 abort();   \
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   \
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r296135 - [libunwind] Disable calls to fprintf for baremetal targets.

2017-02-24 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Fri Feb 24 10:38:05 2017
New Revision: 296135

URL: http://llvm.org/viewvc/llvm-project?rev=296135=rev
Log:
[libunwind] Disable calls to fprintf for baremetal targets.

We've been having issues with using libcxxabi and libunwind for baremetal
targets because fprintf is dependent on io functions, this patch disables calls
to fprintf when building for baremetal in release mode.

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


Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=296135=296134=296135=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Fri Feb 24 10:38:05 2017
@@ -78,6 +78,12 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  
\
+  do { 
\
+abort();   
\
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
@@ -85,9 +91,14 @@
 fflush(stderr);
\
 abort();   
\
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   
\
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds


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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296136: [libcxxabi] Disable calls to fprintf for baremetal 
targets. (authored by rsingh).

Changed prior to commit:
  https://reviews.llvm.org/D30339?vs=89674=89681#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30339

Files:
  libcxxabi/trunk/src/abort_message.cpp


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r296136 - [libcxxabi] Disable calls to fprintf for baremetal targets.

2017-02-24 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Fri Feb 24 10:43:36 2017
New Revision: 296136

URL: http://llvm.org/viewvc/llvm-project?rev=296136=rev
Log:
[libcxxabi] Disable calls to fprintf for baremetal targets.

We've been having issues with using libcxxabi and libunwind for baremetal
targets because fprintf is dependent on io functions, this patch disables calls
to fprintf when building for baremetal in release mode.

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


Modified:
libcxxabi/trunk/src/abort_message.cpp

Modified: libcxxabi/trunk/src/abort_message.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=296136=296135=296136=diff
==
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Fri Feb 24 10:43:36 2017
@@ -35,6 +35,7 @@ __attribute__((visibility("hidden"), nor
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
@@ -43,6 +44,7 @@ void abort_message(const char* format, .
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report


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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-24 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision.

This patch clarify the error messages about uninitialized function arguments.

It can be really hard to see the problem if there are 10-20 arguments like:

  printf("debug:", a, b.c, d, e, ...);

with no info about which argument is uninitialized and with a complicated path 
to investigate it's hard to see the bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341

Files:
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/diagnostics/undef-value-param.m
  test/Analysis/malloc.m
  test/Analysis/misc-ps-region-store.m
  test/Analysis/misc-ps.m
  test/Analysis/null-deref-ps.c
  test/Analysis/nullptr.cpp
  test/Analysis/uninit-const.c
  test/Analysis/uninit-const.cpp
  test/Analysis/uninit-msg-expr.m
  test/Analysis/uninit-vals-ps.c
  test/Analysis/uninit-vals.cpp

Index: test/Analysis/uninit-vals.cpp
===
--- test/Analysis/uninit-vals.cpp
+++ test/Analysis/uninit-vals.cpp
@@ -27,7 +27,7 @@
   // case with undefined values, too.
   c1.b.a = c2->b.a;
 #else
-  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}}
+  c1.b.a = c2->b.a; // expected-warning{{Function call argument number '1' is an uninitialized value}}
 #endif
 }
 }
Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -14,7 +14,7 @@
 
 int f1_b() {
   int x;
-  return bar(x)+1;  // expected-warning{{Function call argument is an uninitialized value}}
+  return bar(x)+1;  // expected-warning{{Function call argument number '1' is an uninitialized value}}
 }
 
 int f2() {
Index: test/Analysis/uninit-msg-expr.m
===
--- test/Analysis/uninit-msg-expr.m
+++ test/Analysis/uninit-msg-expr.m
@@ -52,5 +52,5 @@
 void f3() {
   NSMutableArray *aArray = [NSArray array];
   NSString *aString;
-  [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}}
+  [aArray addObject:aString]; // expected-warning {{Argument number '1' in message expression is an uninitialized value}}
 }
Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -66,8 +66,8 @@
   int  = t;
   int  = p;
   int  = s;  //expected-note {{'q' initialized here}}
-  doStuff6(q); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(q); //expected-warning {{Function call argument number '1' is an uninitialized value}}
+   //expected-note@-1 {{Function call argument number '1' is an uninitialized value}}
 }
 
 void doStuff6_3(int& q_, int *ptr_) {}
@@ -78,32 +78,32 @@
   int  = t;
   int  = p;
   int  = s;
-  doStuff6_3(q,ptr); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6_3(q,ptr); //expected-warning {{Function call argument number '2' is an uninitialized value}}
+   //expected-note@-1 {{Function call argument number '2' is an uninitialized value}}
 
 }
 
 void f6(void) {
   int k;   // expected-note {{'k' declared without an initial value}}
-  doStuff6(k); // expected-warning {{Function call argument is an uninitialized value}}
-   // expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(k); // expected-warning {{Function call argument number '1' is an uninitialized value}}
+   // expected-note@-1 {{Function call argument number '1' is an uninitialized value}}
 
 }
 
 
 
 void f5(void) {
   int t;
   int* tp = // expected-note {{'tp' initialized here}}
-  doStuff_uninit(tp);  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit(tp);  // expected-warning {{Function call argument number '1' is a pointer to uninitialized value}}
+   // expected-note@-1 {{Function call argument number '1' is a pointer to uninitialized value}}
 }
 
 
 void f4(void) {
   int y;// expected-note {{'y' declared without an initial value}}
-  doStuff4(y);  // expected-warning {{Function call argument is an uninitialized value}}
-// expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff4(y);  // expected-warning {{Function call argument number '1' is an uninitialized value}}
+// expected-note@-1 {{Function call argument number '1' is an uninitialized value}}
 }
 
 void f3(void) {

[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D30339



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


[PATCH] D30340: [libunwind] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D30340



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


[PATCH] D30340: [libunwind] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.

We've been having issues with using libcxxabi and libunwind for baremetal 
targets because fprintf is dependent on io functions, this patch disable calls 
to fprintf when building for baremetal targets in release mode.


https://reviews.llvm.org/D30340

Files:
  src/config.h


Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  
\
+  do { 
\
+abort();   
\
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
 __LINE__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   
\
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds


Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  \
+  do { \
+abort();   \
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  \
 __LINE__, msg);\
 fflush(stderr);\
 abort();   \
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   \
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30339: Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.

We've been having issues with using libcxxabi and libunwind for baremetal 
targets because fprintf is dependent on io functions, this patch disable calls 
to fprintf when building for baremetal targets in release mode.


https://reviews.llvm.org/D30339

Files:
  src/abort_message.cpp


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg


https://reviews.llvm.org/D30337



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


Multiple versions of VS

2017-02-24 Thread Ammarguellat, Zahira via cfe-commits
Hello,

Is there any plan from the community to have clang support multiple versions of 
VS?
Thanks.
-Zahira

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


[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-24 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 89665.
rmaprath added a comment.

Different approach: Externalize these functions only for the 
external-thread-api library variant.

(Similar to https://reviews.llvm.org/D29757)


https://reviews.llvm.org/D29818

Files:
  src/chrono.cpp


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,6 +12,8 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
+#include "__threading_support"
+
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime())
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __libcpp_clock_monotonic())
+__throw_system_error(errno, "__libcpp_clock_monotonic() failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
 
 // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
 #if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,6 +12,8 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
+#include "__threading_support"
+
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime())
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __libcpp_clock_monotonic())
+__throw_system_error(errno, "__libcpp_clock_monotonic() failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
 
 // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
 #if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29757: [libcxx] Threading support: Externalize hardware_concurrency()

2017-02-24 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 89664.
rmaprath added a comment.

Different take on the patch: Externalize this function only for the 
externally-thread-api variant.

This is much less intrusive. Note that I haven't added the declaration of 
`__libcpp_thread_hw_concurrency()` into `__threading_support` because it 
doesn't belong there (needs to be provided through a custom 
`__external_threading` header instead).

There is no easy way to test this apart from building an actual 
external-thread-api libc++ variant. We could do some form of testing with the 
external-thread-library configuration, but it still requires some not-so-pretty 
changes that is probably best avoided.


https://reviews.llvm.org/D29757

Files:
  src/thread.cpp


Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -77,7 +77,10 @@
 unsigned
 thread::hardware_concurrency() _NOEXCEPT
 {
-#if defined(CTL_HW) && defined(HW_NCPU)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+// Defer to the external threading implementation
+return __libcpp_thread_hw_concurrency();
+#elif defined(CTL_HW) && defined(HW_NCPU)
 unsigned n;
 int mib[2] = {CTL_HW, HW_NCPU};
 std::size_t s = sizeof(n);


Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -77,7 +77,10 @@
 unsigned
 thread::hardware_concurrency() _NOEXCEPT
 {
-#if defined(CTL_HW) && defined(HW_NCPU)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+// Defer to the external threading implementation
+return __libcpp_thread_hw_concurrency();
+#elif defined(CTL_HW) && defined(HW_NCPU)
 unsigned n;
 int mib[2] = {CTL_HW, HW_NCPU};
 std::size_t s = sizeof(n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 89659.
hokein added a comment.

No accident changes.


https://reviews.llvm.org/D30337

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/var_test.cpp
  test/clang-move/Inputs/var_test.h
  test/clang-move/move-var.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -539,6 +539,8 @@
 "enum class E2 { Red };\n"
 "typedef int Int2;\n"
 "using Int = int;\n"
+"extern int kGlobalInt;\n"
+"extern const char* const kGlobalStr;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -553,7 +555,8 @@
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
   {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
-  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"},
+  {"a::b::kGlobalInt", "Variable"}, {"a::b::kGlobalStr", "Variable"}};
   runClangMoveOnCode(Spec, TestHeader, TestCode, );
   std::set Results;
   for (const auto& DelPair : Reporter.getDeclarationList())
Index: test/clang-move/move-var.cpp
===
--- /dev/null
+++ test/clang-move/move-var.cpp
@@ -0,0 +1,46 @@
+// RUN: mkdir -p %T/move-var
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: cd %T/move-var
+// RUN: clang-move -names="a::kGlobalInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE1 %s
+
+// CHECK-OLD-VAR-H-CASE1-NOT: extern int kGlobalInt;
+// CHECK-OLD-VAR-H-CASE1: int kGlobalInt = 3;
+
+// CHECK-OLD-VAR-CPP-CASE1-NOT: int kGlobalInt = 1;
+
+// CHECK-NEW-VAR-H-CASE1: extern int kGlobalInt;
+// CHECK-NEW-VAR-H-CASE1-NOT: int kGlobalInt = 3;
+
+// CHECK-NEW-VAR-CPP-CASE1: int kGlobalInt = 1;
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="a::kGlobalStr" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE2 %s
+
+// CHECK-OLD-VAR-H-CASE2-NOT: extern const char *const kGlobalStr;
+// CHECK-OLD-VAR-H-CASE2: const char *const kGlobalStr = "Hello2";
+
+// CHECK-OLD-VAR-CPP-CASE2-NOT: const char *const kGlobalStr = "Hello";
+
+// CHECK-NEW-VAR-H-CASE2: extern const char *const kGlobalStr;
+// CHECK-NEW-VAR-H-CASE2-NOT: const char *const kGlobalStr = "Hello2";
+
+// CHECK-NEW-VAR-CPP-CASE2: const char *const kGlobalStr = "Hello";
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="kEvilInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE3 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE3 %s
+
+// CHECK-OLD-VAR-H-CASE3-NOT: int kEvilInt = 2;
+
+// CHECK-NEW-VAR-H-CASE3: int kEvilInt = 2;
Index: test/clang-move/Inputs/var_test.h
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.h
@@ -0,0 +1,11 @@
+namespace a {
+extern int kGlobalInt;
+extern const char *const kGlobalStr;
+}
+
+int kEvilInt = 2;
+
+inline void f1() {
+  int kGlobalInt = 3;
+  const char *const kGlobalStr = "Hello2";
+}
Index: test/clang-move/Inputs/var_test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.cpp
@@ -0,0 +1,6 @@
+#include "var_test.h"
+
+namespace a{
+int kGlobalInt = 1;
+const char *const 

[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.

Also support dumping global variables.


https://reviews.llvm.org/D30337

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/var_test.cpp
  test/clang-move/Inputs/var_test.h
  test/clang-move/move-var.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -539,6 +539,8 @@
 "enum class E2 { Red };\n"
 "typedef int Int2;\n"
 "using Int = int;\n"
+"extern int kGlobalInt;\n"
+"extern const char* const kGlobalStr;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -553,7 +555,8 @@
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
   {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
-  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"},
+  {"a::b::kGlobalInt", "Variable"}, {"a::b::kGlobalStr", "Variable"}};
   runClangMoveOnCode(Spec, TestHeader, TestCode, );
   std::set Results;
   for (const auto& DelPair : Reporter.getDeclarationList())
Index: test/clang-move/move-var.cpp
===
--- /dev/null
+++ test/clang-move/move-var.cpp
@@ -0,0 +1,47 @@
+// RUN: mkdir -p %T/move-var
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: cd %T/move-var
+// RUN: clang-move -names="a::kGlobalInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE1 %s
+
+// CHECK-OLD-VAR-H-CASE1-NOT: extern int kGlobalInt;
+// CHECK-OLD-VAR-H-CASE1: int kGlobalInt = 3;
+
+// CHECK-OLD-VAR-CPP-CASE1-NOT: int kGlobalInt = 1;
+
+// CHECK-NEW-VAR-H-CASE1: extern int kGlobalInt;
+// CHECK-NEW-VAR-H-CASE1-NOT: int kGlobalInt = 3;
+
+// CHECK-NEW-VAR-CPP-CASE1: int kGlobalInt = 1;
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="a::kGlobalStr" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE2 %s
+
+// CHECK-OLD-VAR-H-CASE2-NOT: extern const char *const kGlobalStr;
+// CHECK-OLD-VAR-H-CASE2: const char *const kGlobalStr = "Hello2";
+
+// CHECK-OLD-VAR-CPP-CASE2-NOT: const char *const kGlobalStr = "Hello";
+
+// CHECK-NEW-VAR-H-CASE2: extern const char *const kGlobalStr;
+// CHECK-NEW-VAR-H-CASE2-NOT: const char *const kGlobalStr = "Hello2";
+
+// CHECK-NEW-VAR-CPP-CASE2: const char *const kGlobalStr = "Hello";
+
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="kEvilInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE3 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE3 %s
+
+// CHECK-OLD-VAR-H-CASE3-NOT: int kEvilInt = 2;
+
+// CHECK-NEW-VAR-H-CASE3: int kEvilInt = 2;
Index: test/clang-move/Inputs/var_test.h
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.h
@@ -0,0 +1,11 @@
+namespace a {
+extern int kGlobalInt;
+extern const char *const kGlobalStr;
+}
+
+int kEvilInt = 2;
+
+inline void f1() {
+  int kGlobalInt = 3;
+  const char *const kGlobalStr = "Hello2";
+}
Index: test/clang-move/Inputs/var_test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.cpp
@@ -0,0 +1,6 @@
+#include "var_test.h"
+
+namespace a{
+int kGlobalInt = 1;
+const char *const kGlobalStr = "Hello";

r296116 - Made test more target agnostic

2017-02-24 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Fri Feb 24 07:15:08 2017
New Revision: 296116

URL: http://llvm.org/viewvc/llvm-project?rev=296116=rev
Log:
Made test more target agnostic

Recommits r295975 (Added regression tests), reverted in r295975,
because it did not work on non-X86 targets.

Added:
cfe/trunk/test/SemaCXX/friend3.cpp

Added: cfe/trunk/test/SemaCXX/friend3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend3.cpp?rev=296116=auto
==
--- cfe/trunk/test/SemaCXX/friend3.cpp (added)
+++ cfe/trunk/test/SemaCXX/friend3.cpp Fri Feb 24 07:15:08 2017
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -S -triple %itanium_abi_triple -std=c++11 -emit-llvm %s -o 
- | FileCheck %s
+
+namespace pr8852 {
+void foo();
+struct S {
+  friend void foo() {}
+};
+
+void main() {
+  foo();
+}
+// CHECK: define {{.*}} @_ZN6pr88523fooEv
+}
+
+namespace pr9518 {
+template
+struct provide {
+  friend T f() { return T(); }
+};
+
+void g() {
+  void f();
+  provide p;
+  f();
+}
+// CHECK: define {{.*}} @_ZN6pr95181fEv
+}


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


  1   2   >