[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2017-03-30 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 93591.
ddcc added a comment.

Rebase


https://reviews.llvm.org/D28955

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/dead-stores.m
  test/Analysis/explain-svals.cpp
  test/Analysis/malloc.c
  test/Analysis/misc-ps-eager-assume.m
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -146,7 +146,7 @@
 void test_isgraph_isprint(int x) {
   char y = x;
   if (isgraph(y))
-clang_analyzer_eval(isprint(x)); // expected-warning{{TRUE}}
+clang_analyzer_eval(isprint(y)); // expected-warning{{TRUE}}
 }
 
 int isdigit(int);
Index: test/Analysis/misc-ps-eager-assume.m
===
--- test/Analysis/misc-ps-eager-assume.m
+++ test/Analysis/misc-ps-eager-assume.m
@@ -1,5 +1,4 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s -analyzer-eagerly-assume
-// expected-no-diagnostics
 
 // Delta-reduced header stuff (needed for test cases).
 typedef signed char BOOL;
@@ -56,7 +55,7 @@
 void handle_symbolic_cast_in_condition(void) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
-  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"];
+  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"]; // expected-warning {{Assignment of a non-Boolean value}}
   NSMutableArray* array = needsAnArray ? [[NSMutableArray alloc] init] : 0;
   if(needsAnArray)
 [array release];
Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1656,13 +1656,13 @@
 void testOffsetPassedToStrlen() {
   char * string = malloc(sizeof(char)*10);
   string += 1;
-  int length = strlen(string); // expected-warning {{Potential leak of memory pointed to by 'string'}}
+  size_t length = strlen(string); // expected-warning {{Potential leak of memory pointed to by 'string'}}
 }
 
 void testOffsetPassedToStrlenThenFree() {
   char * string = malloc(sizeof(char)*10);
   string += 1;
-  int length = strlen(string);
+  size_t length = strlen(string);
   free(string); // expected-warning {{Argument to free() is offset by 1 byte from the start of memory allocated by malloc()}}
 }
 
@@ -1705,7 +1705,7 @@
 }
 
 char *dupstrNoWarn(const char *s) {
-  const int len = strlen(s);
+  const size_t len = strlen(s);
   char *p = (char*) smallocNoWarn(len + 1);
   strcpy(p, s); // no-warning
   return p;
@@ -1721,7 +1721,7 @@
 }
 
 char *dupstrWarn(const char *s) {
-  const int len = strlen(s);
+  const size_t len = strlen(s);
   char *p = (char*) smallocWarn(len + 1);
   strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}}
   return p;
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -41,11 +41,11 @@
 
 void test_2(char *ptr, int ext) {
   clang_analyzer_explain((void *) "asdf"); // expected-warning-re^pointer to element of type 'char' with index 0 of string literal "asdf"$
-  clang_analyzer_explain(strlen(ptr)); // expected-warning-re^metadata of type 'unsigned long' tied to pointee of argument 'ptr'$
+  clang_analyzer_explain(strlen(ptr)); // expected-warning-re^cast of type 'int' of metadata of type 'unsigned long' tied to pointee of argument 'ptr'$
   clang_analyzer_explain(conjure()); // expected-warning-re^symbol of type 'int' conjured at statement 'conjure\(\)'$
   clang_analyzer_explain(glob); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob'$
   clang_analyzer_explain(glob_ptr); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob_ptr'$
-  clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^extent of pointee of argument 'ptr'$
+  clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^cast of type 'int' of extent of pointee of argument 'ptr'$
   int *x = new int[ext];
   clang_analyzer_explain(x); // expected-warning-re^pointer to element of type 'int' with index 0 of heap segment that starts at symbol of type 'int \*' conjured at statement 'new int \[ext\]'$
   // Sic! What gets computed is the extent of the element-region.
Index: test/Analysis/dead-stores.m

[PATCH] D28954: [analyzer] Add support for symbolic float expressions

2017-03-30 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 93590.
ddcc added a comment.

Rebase, update tests, fix bugs


https://reviews.llvm.org/D28954

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def
  lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/FloatingPointMath.cpp
  lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/diagnostics/macros.cpp
  test/Analysis/float-rules.c
  test/Analysis/float.c
  test/Analysis/inline.cpp
  test/Analysis/lit.local.cfg
  test/Analysis/operator-calls.cpp

Index: test/Analysis/operator-calls.cpp
===
--- test/Analysis/operator-calls.cpp
+++ test/Analysis/operator-calls.cpp
@@ -81,8 +81,8 @@
   void test(int coin) {
 // Force a cache-out when we try to conjure a temporary region for the operator call.
 // ...then, don't crash.
-clang_analyzer_eval(+(coin ? getSmallOpaque() : getSmallOpaque())); // expected-warning{{UNKNOWN}}
-clang_analyzer_eval(+(coin ? getLargeOpaque() : getLargeOpaque())); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(+(coin ? getSmallOpaque() : getSmallOpaque())); // expected-warning{{TRUE}}
+clang_analyzer_eval(+(coin ? getLargeOpaque() : getLargeOpaque())); // expected-warning{{TRUE}}
   }
 }
 
Index: test/Analysis/lit.local.cfg
===
--- test/Analysis/lit.local.cfg
+++ test/Analysis/lit.local.cfg
@@ -1,20 +1,35 @@
+import lit.Test
 import lit.TestRunner
 import sys
 
 # Custom format class for static analyzer tests
 class AnalyzerTest(lit.formats.ShTest, object):
 
 def execute(self, test, litConfig):
-result = self.executeWithAnalyzeSubstitution(test, litConfig, '-analyzer-constraints=range')
+results = []
 
-if result.code == lit.Test.FAIL:
-return result
+# Parse any test requirements ('REQUIRES: ')
+saved_test = test
+lit.TestRunner.parseIntegratedTestScript(test)
+
+if 'z3' not in test.requires:
+results.append(self.executeWithAnalyzeSubstitution(saved_test, litConfig, '-analyzer-constraints=range'))
+
+if results[-1].code == lit.Test.FAIL:
+return results[-1]
 
 # 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')
+results.append(self.executeWithAnalyzeSubstitution(saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3'))
 
-return result
+# Combine all result outputs into the last element
+for x in results:
+if x != results[-1]:
+results[-1].output = x.output + results[-1].output
+
+if results:
+return results[-1]
+return lit.Test.Result(lit.Test.UNSUPPORTED, "Test requires the following unavailable features: z3")
 
 def executeWithAnalyzeSubstitution(self, test, litConfig, substitution):
 saved_substitutions = list(test.config.substitutions)
Index: test/Analysis/inline.cpp
===
--- test/Analysis/inline.cpp
+++ test/Analysis/inline.cpp
@@ -285,11 +285,11 @@
   }
 
   void testFloatReference() {
-clang_analyzer_eval(defaultFloatReference(1) == -1); // expected-warning{{UNKNOWN}}
-clang_analyzer_eval(defaultFloatReference() == -42); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(defaultFloatReference(1) == -1); // expected-warning{{TRUE}}
+clang_analyzer_eval(defaultFloatReference() == -42); // expected-warning{{TRUE}}
 
-clang_analyzer_eval(defaultFloatReferenceZero(1) == -1); // expected-warning{{UNKNOWN}}
-clang_analyzer_eval(defaultFloatReferenceZero() == 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval(defaultFloatReferenceZero(1) == -1); // expected-warning{{TRUE}}
+clang_analyzer_eval(defaultFloatReferenceZero() == 0); // expected-warning{{TRUE}}
   }
 
 

[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

2017-03-30 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 93589.
ddcc added a comment.

Rebase


https://reviews.llvm.org/D28953

Files:
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/bitwise-ops.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
   size_t z = fwrite(buf, sizeof(int), y, fp);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -69,7 +69,7 @@
   static int stat;
   clang_analyzer_explain(x + 1); // expected-warning-re^\(argument 'x'\) \+ 1$
   clang_analyzer_explain(1 + y); // expected-warning-re^\(argument 'y'\) \+ 1$
-  clang_analyzer_explain(x + y); // expected-warning-re^unknown value$
+  clang_analyzer_explain(x + y); // expected-warning-re^\(argument 'x'\) \+ \(argument 'y'\)$
   clang_analyzer_explain(z); // expected-warning-re^undefined value$
   clang_analyzer_explain(); // expected-warning-re^pointer to local variable 'z'$
   clang_analyzer_explain(stat); // expected-warning-re^signed 32-bit integer '0'$
Index: test/Analysis/conditional-path-notes.c
===
--- test/Analysis/conditional-path-notes.c
+++ test/Analysis/conditional-path-notes.c
@@ -77,7 +77,8 @@
 
 void testNonDiagnosableBranchArithmetic(int a, int b) {
   if (a - b) {
-// expected-note@-1 {{Taking true branch}}
+// expected-note@-1 {{Assuming the condition is true}}
+// expected-note@-2 {{Taking true branch}}
 *(volatile int *)0 = 1; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1 {{Dereference of null pointer}}
   }
@@ -1573,12 +1574,75 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
-// CHECK-NEXT:line81
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line79
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line79
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line79
+// CHECK-NEXT:  col11
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line82
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
-// CHECK-NEXT:line81
+// CHECK-NEXT:line82
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
@@ -1594,25 +1658,25 @@
 // CHECK-NEXT: start
 // CHECK-NEXT:  
 // CHECK-NEXT:   
-// CHECK-NEXT:line81
+// CHECK-NEXT:line82
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // 

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

2017-03-30 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 93588.
ddcc added a comment.

Fix erroneous comment


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
@@ -10,6 +10,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,1606 @@
+//== 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"
+
+#include "clang/Config/config.h"
+

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

2017-03-30 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 93587.
ddcc marked 4 inline comments as done.
ddcc added a comment.

Use direct bitcasting instead of string conversion for APFloat casting, add 
reference counting for Z3_sort, eliminate some duplicate code


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
@@ -10,6 +10,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,1606 @@
+//== 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 

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

2017-03-30 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

Thanks for the feedback! My main constraint is that the results from the 
floating-point analysis weren't very interesting (see #652894 <#652894>), so 
I'm not actively working on further development.

> FYI I've been working on floating point support in KLEE and have extended it 
> to support floating point (note however only the Z3 backend actually supports 
> consuming floating point constraints). I've not yet open sourced what I've 
> done as I'm not entirely happy with the design but if there is interest we 
> could see if we could figure out a way of pulling klee::Expr (and the solver 
> bits) out of KLEE to make a standalone library. Note there is a project 
> called metaSMT that uses template meta programming to give the same interface 
> to multiple solvers. KLEE does support it but I'm not familiar with it.

I agree that it'd be useful to move to a more generic SMT interface, 
potentially SMT-LIB instead of something specific to a solver, but this is more 
of a long-term goal at the moment.

> KLEE has a few optimization ideas that you could consider implementing that 
> certainly help in the context of symbolic execution...

Likewise, I think adding a constraint cache and implementing performance 
optimizations would be the next step to getting this enabled by default, and 
perhaps deprecating the range constraint manager, but the implementation is a 
little tricky because there's state also being stored in the `ProgramState` 
object. Since those are reference counted, there's a little more work involved 
than just adding an intermediate layer with e.g. an `std::map`. But again, it's 
not something I have the time for at the moment.




Comment at: CMakeLists.txt:188
 
+find_package(Z3 4.5)
+

delcypher wrote:
> delcypher wrote:
> > @ddcc It is of course up to you but I recently [[ added support for using 
> > `libz3` directly | added support for using `libz3` directly ]] from CMake. 
> > via it's own CMake config package. You only get this if Z3 was built with 
> > CMake so you might not want this restriction.  This feature has only just 
> > landed though and might not be sufficient for your needs.  If you take a 
> > look at Z3's example projects they are now built with this mechanism when 
> > building with CMake.
> > 
> > If you are interested I'd be more than happy to work with you to get this 
> > feature ready for your needs in upstream Z3 so you can use it here.
> Sorry that URL should be https://github.com/Z3Prover/z3/pull/926
I think this is useful, and upstream z3 has been in need of better packaging. 
But until it's used by default over the current python script and the z3 folks 
actively maintain it, I'm a little hesitant to depend on it.



Comment at: include/clang/Config/config.h.cmake:42
+/* Define if we have z3 and want to build it */
+#cmakedefine CLANG_ANALYZER_WITH_Z3 ${CLANG_ANALYZER_WITH_Z3}
+

delcypher wrote:
> Do you really want such a specific name? How about 
> `CLANG_ANALYSER_HAS_SMT_SOLVER`?
There's been a bit of back and forth over this name in previous revisions, so 
I'm a little hesitant to change it. In essence, there are two CMake variables, 
one for whether z3 is present, and another for whether the user requested to 
build with z3, which are exported to a single C-level definition that is true 
iff both CMake variables are true.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:70
+public:
+  static Z3_context ZC;
+

delcypher wrote:
> @ddc
> This decision of having a global context might come back to bite you. 
> Especially if you switch to doing parallel solving in the future. This is why 
> KLEE's `Z3ASTHandle` and `Z3SortHandle` store the context so it's possible to 
> use different context.
I agree that it is an inherent limitation, but since the static analyzer itself 
is only single-threaded anyway, the entire analyzer will need significant 
changes before this becomes a problem.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:81
+
+class Z3Expr {
+  friend class Z3Model;

delcypher wrote:
> @ddcc 
> [[ 
> https://github.com/klee/klee/blob/1f13e9dbf9db2095b6612a47717c2b86e4aaba72/lib/Solver/Z3Builder.h#L20
>  | In KLEE I have something similar to represent Z3Expr ]] called Z3ASTHandle 
> and Z3SortHandle for doing manual reference counting. You might want to take 
> a look at. I don't see you doing reference counting on sorts here so I think 
> you might be leaking memory.
> 
> We also have a handy `dump()` method on `Z3ASTHandle` and `Z3SortHandle` for 
> debugging.
Originally, my understanding was that reference counting wasn't necessary for 
`Z3_sort` objects, based on the API documentation, and the lack of 
`Z3_sort_inc_ref()`/`Z3_sort_dec_ref()` functions. But, taking another look at 
the z3 source code, it seems that `Z3_sort` is casted directly to `Z3_ast`,  so 
I 

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D31404#714244, @Anastasia wrote:

> I can't see clearly why the alloca has to be extended to accommodate the 
> address space too? Couldn't  the address space for alloca just be taken 
> directly from the data layout?
>
> In fact is seems from the LLVM review, an address space for alloca doesn't go 
> into the bitcode.


In the latest comments of the LLVM review, reviewers have agreed that address 
space of alloca goes into the bitcode.

I am not quite get your first question. Do you mean why the API of alloca has 
to have an address space parameter? Or do you question the necessity to let 
alloca returning a pointer pointing to non-zero address space?




Comment at: include/clang/Basic/AddressSpaces.h:28
 enum ID {
-  Offset = 0x7FFF00,
+  Default = 0,
 

Anastasia wrote:
> Somehow I wish that opencl_private would be represented explicitly instead 
> and then an absence of an address space attribute would signify the default 
> one to be used. But since opencl_private has always been represented as an 
> absence of an address space attribute not only in AST but in IR as well, I 
> believe it might be a bigger change now. However, how does this default 
> address space align with default AS we put during type parsing in 
> processTypeAttrs (https://reviews.llvm.org/D13168). I think after this step 
> we shouldn't need default AS explicitly any longer? 
Currently in Clang having an address space qualifier value of 0 is equivalent 
to having no address space qualifier. This is due to the internal 
representation of address space qualifier as bits in a mask. Therefore although 
there are separate API's for hasAddressSpace() and getAddressSpace(), in many 
many places people just do not use hasAddressSpace() and only use 
getAddressSpace(). In a way, this is convenient, since it allows people to use 
just one unsigned to represent that whether a type has an address space 
qualifier and the value of the qualifier if it has one. That's why value 0 of 
address space qualifier is called `Default`, since it indicates `no address 
space qualifier`, which is the default situation. Here we give it the name 
`Default`, just to emphasise the existing reality, that is, 0 is truely the 
default value of address space qualifier. This also matches most languages' 
view of address space, that is, if not explicitly specified, 0 is the default 
address space qualifier since it means `no address space qualifier`.

For OpenCL 1.2, this matches perfectly to private address space, since if no 
address space qualifier implies private address space. For OpenCL 2.0, things 
become complicated. 'no address space qualifier' in the source code no longer 
ends up with a fixed address space qualifier in AST. What address space 
qualifier we get in AST depends on scope of the variable. To be consistent with 
the AST of OpenCL 1.2, we continue to use 'no address space qualifier (or 0 
value address space qualifier)' in AST to represent private address space in 
OpenCL source language. This is non-ideal but it works fine. Therefore although 
it is not written, in fact opencl_private is 0.

Since address space 0 in AST always represents the private address space in 
OpenCL and the default address space in other languages, it cannot be used for 
other address spaces of OpenCL. Also, when mapped to target address space, for 
OpenCL, address space 0 in AST should map to target private address space or 
alloca address space; for other languages, address space 0 in AST should map to 
target generic address space. It would be clearer to have an enum value for 0 
instead of using 0 directly.



Comment at: include/clang/Basic/AddressSpaces.h:41
+
+  target_first = Count
 };

Anastasia wrote:
> I don't entirely understand the motivation for this. I think the idea of 
> LangAS is to represent the source ASes while target ASes are reflected in the 
> Map of Targets.cpp.
There are two types of address spaces in languages end up as address spaces in 
AST:

1. language defined address spaces, e.g. global in OpenCL => mapped to target 
address space
2. `__attribute__((address_space(n)))` => directly used as target address space 
with the same value

Since address space 0 in AST represents the default address space (no address 
space), it must be part of language address spaces and be mapped. Then it may 
be mapped to a target address space which is not 0.

Here is the problem: a user may use `__attribute__((address_space(0)))` to 
specify target address space 0, but he/she cannot, since address space 0 is 
always mapped as a language address space.

To solve this issue, address spaces from `__attribute__((address_space(n)))` is 
added to by Count when stored in AST. When mapped to target address space, 
their value is deducted by Count. Therefore, 
`__attribute__((address_space(0)))` becomes representable in AST.



Comment 

r299181 - Revert test added in r299152

2017-03-30 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 30 23:29:07 2017
New Revision: 299181

URL: http://llvm.org/viewvc/llvm-project?rev=299181=rev
Log:
Revert test added in r299152

Removing the test until I can figure out how to get the ThinLTO backend
invocation of clang to use the correct target.

Modified:
cfe/trunk/test/CodeGen/function-sections.c

Modified: cfe/trunk/test/CodeGen/function-sections.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-sections.c?rev=299181=299180=299181=diff
==
--- cfe/trunk/test/CodeGen/function-sections.c (original)
+++ cfe/trunk/test/CodeGen/function-sections.c Thu Mar 30 23:29:07 2017
@@ -9,12 +9,6 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fdata-sections -o - < %s | 
FileCheck %s --check-prefix=DATA_SECT
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections 
-fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 
-// Try again through a clang invocation of the ThinLTO backend.
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -emit-llvm-bc 
-o %t.o
-// RUN: llvm-lto -thinlto -o %t %t.o
-// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -Xclang -target-cpu 
-Xclang x86-64 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S 
-ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
-// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -Xclang -target-cpu 
-Xclang x86-64 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections 
-o - | FileCheck %s --check-prefix=DATA_SECT
-
 const int hello = 123;
 void world() {}
 


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


[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-03-30 Thread Ahmed Asadi via Phabricator via cfe-commits
ahmedasadi added a comment.

Thanks for reviewing. Would you be able to commit this patch for me, as I do 
not have commit access?


https://reviews.llvm.org/D31235



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


[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-03-30 Thread Ahmed Asadi via Phabricator via cfe-commits
ahmedasadi updated this revision to Diff 93583.
ahmedasadi marked an inline comment as done.
ahmedasadi added a comment.

Re-ordered the checks in shouldWarnIfShadowedDecl as suggested by rnk.


https://reviews.llvm.org/D31235

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -1,20 +1,27 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow-all %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -Wshadow-all %s
 
 namespace {
   int i; // expected-note {{previous declaration is here}}
 }
 
 namespace one {
 namespace two {
   int j; // expected-note {{previous declaration is here}}
+  typedef int jj; // expected-note 2 {{previous declaration is here}}
+  using jjj=int; // expected-note 2 {{previous declaration is here}}
 }
 }
 
 namespace xx {
   int m;
+  typedef int mm;
+  using mmm=int;
+
 }
 namespace yy {
   int m;
+  typedef char mm;
+  using mmm=char;
 }
 
 using namespace one::two;
@@ -25,14 +32,19 @@
   int i; // expected-warning {{declaration shadows a variable in namespace '(anonymous)'}}
   int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}}
   int m;
+  int mm;
+  int mmm;
 }
 
 class A {
-  static int data; // expected-note {{previous declaration}}
-  // expected-note@+1 {{previous declaration}}
+  static int data; // expected-note 1 {{previous declaration}}
+  // expected-note@+1 1 {{previous declaration}}
   int field;
   int f1, f2, f3, f4; // expected-note 8 {{previous declaration is here}}
 
+  typedef int a1; // expected-note 2 {{previous declaration}}
+  using a2=int; // expected-note 2 {{previous declaration}}
+
   // The initialization is safe, but the modifications are not.
   A(int f1, int f2, int f3, int f4) // expected-note-re 4 {{variable 'f{{[0-4]}}' is declared here}}
 	  : f1(f1) {
@@ -50,6 +62,28 @@
   void test() {
 char *field; // expected-warning {{declaration shadows a field of 'A'}}
 char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+char *a1; // no warning 
+char *a2; // no warning
+char *jj; // no warning
+char *jjj; // no warning
+  }
+
+  void test2() {
+typedef char field; // no warning
+typedef char data; // no warning
+typedef char a1; // expected-warning {{declaration shadows a typedef in 'A'}}
+typedef char a2; // expected-warning {{declaration shadows a type alias in 'A'}}
+typedef char jj; // expected-warning {{declaration shadows a typedef in namespace 'one::two'}}
+typedef char jjj; // expected-warning {{declaration shadows a type alias in namespace 'one::two'}}
+  }
+
+  void test3() {
+using field=char; // no warning
+using data=char; // no warning
+using a1=char; // expected-warning {{declaration shadows a typedef in 'A'}}
+using a2=char; // expected-warning {{declaration shadows a type alias in 'A'}}
+using jj=char; // expected-warning {{declaration shadows a typedef in namespace 'one::two'}}
+using jjj=char; // expected-warning {{declaration shadows a type alias in namespace 'one::two'}}
   }
 };
 
@@ -63,13 +97,23 @@
 namespace rdar8900456 {
 struct Foo {
   static void Baz();
+  static void Baz1();
+  static void Baz2();
 private:
   int Bar;
 };
 
 void Foo::Baz() {
   double Bar = 12; // Don't warn.
 }
+
+void Foo::Baz1() {
+  typedef int Bar; // Don't warn.
+}
+
+void Foo::Baz2() {
+  using Bar=int; // Don't warn.
+}
 }
 
 // http://llvm.org/PR9160
@@ -87,23 +131,68 @@
 };
 }
 
-extern int bob; // expected-note {{previous declaration is here}}
+extern int bob; // expected-note 1 {{previous declaration is here}}
+typedef int bob1; // expected-note 2 {{previous declaration is here}}
+using bob2=int; // expected-note 2 {{previous declaration is here}}
 
 // rdar://8883302
 void rdar8883302() {
   extern int bob; // don't warn for shadowing.
 }
 
 void test8() {
   int bob; // expected-warning {{declaration shadows a variable in the global namespace}}
+  int bob1; //no warning
+  int bob2; // no warning
+}
+
+void test9() {
+  typedef int bob; // no warning
+  typedef int bob1; // expected-warning {{declaration shadows a typedef in the global namespace}}
+  typedef int bob2; // expected-warning {{declaration shadows a type alias in the global namespace}}
+}
+
+void test10() {
+  using bob=int; // no warning
+  using bob1=int; // expected-warning {{declaration shadows a typedef in the global namespace}}
+  using bob2=int; // expected-warning {{declaration shadows a type alias in the global namespace}}
 }
 
 namespace rdar29067894 {
 
 void avoidWarningWhenRedefining(int b) { // expected-note {{previous definition is here}}
   int a = 0; // expected-note {{previous definition is here}}
   int a = 1; // expected-error {{redefinition of 'a'}}
   int b = 2; 

r299178 - Add target-cpu

2017-03-30 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 30 22:49:52 2017
New Revision: 299178

URL: http://llvm.org/viewvc/llvm-project?rev=299178=rev
Log:
Add target-cpu

Sigh, another follow-on fix needed for test in r299152 causing bot
failures. We also need the target-cpu for the ThinLTO BE clang
invocation.

Modified:
cfe/trunk/test/CodeGen/function-sections.c

Modified: cfe/trunk/test/CodeGen/function-sections.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-sections.c?rev=299178=299177=299178=diff
==
--- cfe/trunk/test/CodeGen/function-sections.c (original)
+++ cfe/trunk/test/CodeGen/function-sections.c Thu Mar 30 22:49:52 2017
@@ -12,8 +12,8 @@
 // Try again through a clang invocation of the ThinLTO backend.
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -emit-llvm-bc 
-o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
-// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -O2 -x ir %t.o 
-fthinlto-index=%t.thinlto.bc -S -ffunction-sections -o - | FileCheck %s 
--check-prefix=FUNC_SECT
-// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -O2 -x ir %t.o 
-fthinlto-index=%t.thinlto.bc -S -fdata-sections -o - | FileCheck %s 
--check-prefix=DATA_SECT
+// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -Xclang -target-cpu 
-Xclang x86-64 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S 
-ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
+// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -Xclang -target-cpu 
-Xclang x86-64 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections 
-o - | FileCheck %s --check-prefix=DATA_SECT
 
 const int hello = 123;
 void world() {}


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


r299176 - Add more target triples to test

2017-03-30 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 30 22:27:47 2017
New Revision: 299176

URL: http://llvm.org/viewvc/llvm-project?rev=299176=rev
Log:
Add more target triples to test

Third and hopefully final fix to test for r299152 that is causing bot
failures: make sure the target triple specified for the ThinLTO backend
clang invocations as well.

Modified:
cfe/trunk/test/CodeGen/function-sections.c

Modified: cfe/trunk/test/CodeGen/function-sections.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-sections.c?rev=299176=299175=299176=diff
==
--- cfe/trunk/test/CodeGen/function-sections.c (original)
+++ cfe/trunk/test/CodeGen/function-sections.c Thu Mar 30 22:27:47 2017
@@ -12,8 +12,8 @@
 // Try again through a clang invocation of the ThinLTO backend.
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -emit-llvm-bc 
-o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
-// RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S 
-ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
-// RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections 
-o - | FileCheck %s --check-prefix=DATA_SECT
+// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -O2 -x ir %t.o 
-fthinlto-index=%t.thinlto.bc -S -ffunction-sections -o - | FileCheck %s 
--check-prefix=FUNC_SECT
+// RUN: %clang -Xclang -triple -Xclang x86_64-pc-linux-gnu -O2 -x ir %t.o 
-fthinlto-index=%t.thinlto.bc -S -fdata-sections -o - | FileCheck %s 
--check-prefix=DATA_SECT
 
 const int hello = 123;
 void world() {}


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


r299174 - [asan] Turn -fsanitize-address-use-after-scope on by default [clang part]

2017-03-30 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Thu Mar 30 22:00:09 2017
New Revision: 299174

URL: http://llvm.org/viewvc/llvm-project?rev=299174=rev
Log:
[asan] Turn -fsanitize-address-use-after-scope on by default [clang part]

AddressSanitizer has an optional compile-time flag, 
-fsanitize-address-use-after-scope, which enables detection of use-after-scope 
bugs. We'd like to have this feature on by default, because it is already very 
well tested, it's used in several projects already (LLVM automatically enables 
it when using -DLLVM_USE_SANITIZER=Address), it's low overhead and there are no 
known issues or incompatibilities.

This patch enables use-after-scope by default via the Clang driver, where we 
set true as the default value for AsanUseAfterScope. This also causes the 
lifetime markers to be generated whenever fsanitize=address is used. This has 
some nice consequences, e.g. we now have line numbers for all local variables.

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


Modified:
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=299174=299173=299174=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Thu Mar 30 22:00:09 2017
@@ -34,7 +34,7 @@ class SanitizerArgs {
   bool CfiCrossDso = false;
   int AsanFieldPadding = 0;
   bool AsanSharedRuntime = false;
-  bool AsanUseAfterScope = false;
+  bool AsanUseAfterScope = true;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
   bool Stats = false;

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=299174=299173=299174=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Thu Mar 30 22:00:09 2017
@@ -121,7 +121,7 @@
 // CHECK-USE-AFTER-SCOPE-BOTH-OFF-NOT: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
-// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
+// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: 
'-fsanitize-memory-track-origins'


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


r299173 - Fix new compile command in test

2017-03-30 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 30 21:55:31 2017
New Revision: 299173

URL: http://llvm.org/viewvc/llvm-project?rev=299173=rev
Log:
Fix new compile command in test

My previous attempt to fix bot failures from r299152 didn't add the
necessary option to get bitcode out of the cc1 step.

Modified:
cfe/trunk/test/CodeGen/function-sections.c

Modified: cfe/trunk/test/CodeGen/function-sections.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-sections.c?rev=299173=299172=299173=diff
==
--- cfe/trunk/test/CodeGen/function-sections.c (original)
+++ cfe/trunk/test/CodeGen/function-sections.c Thu Mar 30 21:55:31 2017
@@ -10,7 +10,7 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections 
-fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 
 // Try again through a clang invocation of the ThinLTO backend.
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -o %t.o
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -emit-llvm-bc 
-o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
 // RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S 
-ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
 // RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections 
-o - | FileCheck %s --check-prefix=DATA_SECT


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


r299170 - Add triple to new test

2017-03-30 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 30 21:36:47 2017
New Revision: 299170

URL: http://llvm.org/viewvc/llvm-project?rev=299170=rev
Log:
Add triple to new test

Attempt to fix bot errors from r299152 by using clang_cc1 and specifying
target triple to compile step.

Modified:
cfe/trunk/test/CodeGen/function-sections.c

Modified: cfe/trunk/test/CodeGen/function-sections.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-sections.c?rev=299170=299169=299170=diff
==
--- cfe/trunk/test/CodeGen/function-sections.c (original)
+++ cfe/trunk/test/CodeGen/function-sections.c Thu Mar 30 21:36:47 2017
@@ -10,7 +10,7 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections 
-fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 
 // Try again through a clang invocation of the ThinLTO backend.
-// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
 // RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S 
-ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
 // RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections 
-o - | FileCheck %s --check-prefix=DATA_SECT


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


r299152 - [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends

2017-03-30 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 30 21:05:15 2017
New Revision: 299152

URL: http://llvm.org/viewvc/llvm-project?rev=299152=rev
Log:
[ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends

Summary:
This involved refactoring out pieces of
EmitAssemblyHelper::CreateTargetMachine for use in runThinLTOBackend.

Subsumes D31114.

Reviewers: mehdi_amini, pcc

Subscribers: Prazek, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/function-sections.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=299152=299151=299152=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Mar 30 21:05:15 2017
@@ -294,6 +294,139 @@ static void addSymbolRewriterPass(const
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
+static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions ) {
+  switch (CodeGenOpts.OptimizationLevel) {
+  default:
+llvm_unreachable("Invalid optimization level!");
+  case 0:
+return CodeGenOpt::None;
+  case 1:
+return CodeGenOpt::Less;
+  case 2:
+return CodeGenOpt::Default; // O2/Os/Oz
+  case 3:
+return CodeGenOpt::Aggressive;
+  }
+}
+
+static llvm::CodeModel::Model getCodeModel(const CodeGenOptions ) {
+  unsigned CodeModel =
+  llvm::StringSwitch(CodeGenOpts.CodeModel)
+  .Case("small", llvm::CodeModel::Small)
+  .Case("kernel", llvm::CodeModel::Kernel)
+  .Case("medium", llvm::CodeModel::Medium)
+  .Case("large", llvm::CodeModel::Large)
+  .Case("default", llvm::CodeModel::Default)
+  .Default(~0u);
+  assert(CodeModel != ~0u && "invalid code model!");
+  return static_cast(CodeModel);
+}
+
+static llvm::Reloc::Model getRelocModel(const CodeGenOptions ) {
+  // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
+  llvm::Optional RM;
+  RM = llvm::StringSwitch(CodeGenOpts.RelocationModel)
+  .Case("static", llvm::Reloc::Static)
+  .Case("pic", llvm::Reloc::PIC_)
+  .Case("ropi", llvm::Reloc::ROPI)
+  .Case("rwpi", llvm::Reloc::RWPI)
+  .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+  .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
+  assert(RM.hasValue() && "invalid PIC model!");
+  return *RM;
+}
+
+static TargetMachine::CodeGenFileType getCodeGenFileType(BackendAction Action) 
{
+  if (Action == Backend_EmitObj)
+return TargetMachine::CGFT_ObjectFile;
+  else if (Action == Backend_EmitMCNull)
+return TargetMachine::CGFT_Null;
+  else {
+assert(Action == Backend_EmitAssembly && "Invalid action!");
+return TargetMachine::CGFT_AssemblyFile;
+  }
+}
+
+static void initTargetOptions(llvm::TargetOptions ,
+  const CodeGenOptions ,
+  const clang::TargetOptions ,
+  const LangOptions ,
+  const HeaderSearchOptions ) {
+  Options.ThreadModel =
+  llvm::StringSwitch(CodeGenOpts.ThreadModel)
+  .Case("posix", llvm::ThreadModel::POSIX)
+  .Case("single", llvm::ThreadModel::Single);
+
+  // Set float ABI type.
+  assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
+  CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
+ "Invalid Floating Point ABI!");
+  Options.FloatABIType =
+  llvm::StringSwitch(CodeGenOpts.FloatABI)
+  .Case("soft", llvm::FloatABI::Soft)
+  .Case("softfp", llvm::FloatABI::Soft)
+  .Case("hard", llvm::FloatABI::Hard)
+  .Default(llvm::FloatABI::Default);
+
+  // Set FP fusion mode.
+  switch (LangOpts.getDefaultFPContractMode()) {
+  case LangOptions::FPC_Off:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
+break;
+  case LangOptions::FPC_On:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
+break;
+  case LangOptions::FPC_Fast:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
+break;
+  }
+
+  Options.UseInitArray = CodeGenOpts.UseInitArray;
+  Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
+  Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+  Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
+
+  // Set EABI version.
+  Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)
+.Case("4", llvm::EABI::EABI4)
+.Case("5", llvm::EABI::EABI5)
+.Case("gnu", llvm::EABI::GNU)
+.Default(llvm::EABI::Default);
+
+  if (LangOpts.SjLjExceptions)
+Options.ExceptionModel = llvm::ExceptionHandling::SjLj;
+
+  Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
+  Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
+  Options.NoZerosInBSS = 

[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299152: [ThinLTO] Set up lto::Config properly for codegen in 
ThinLTO backends (authored by tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D31508?vs=93536=93577#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31508

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/function-sections.c

Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -294,6 +294,139 @@
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
+static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions ) {
+  switch (CodeGenOpts.OptimizationLevel) {
+  default:
+llvm_unreachable("Invalid optimization level!");
+  case 0:
+return CodeGenOpt::None;
+  case 1:
+return CodeGenOpt::Less;
+  case 2:
+return CodeGenOpt::Default; // O2/Os/Oz
+  case 3:
+return CodeGenOpt::Aggressive;
+  }
+}
+
+static llvm::CodeModel::Model getCodeModel(const CodeGenOptions ) {
+  unsigned CodeModel =
+  llvm::StringSwitch(CodeGenOpts.CodeModel)
+  .Case("small", llvm::CodeModel::Small)
+  .Case("kernel", llvm::CodeModel::Kernel)
+  .Case("medium", llvm::CodeModel::Medium)
+  .Case("large", llvm::CodeModel::Large)
+  .Case("default", llvm::CodeModel::Default)
+  .Default(~0u);
+  assert(CodeModel != ~0u && "invalid code model!");
+  return static_cast(CodeModel);
+}
+
+static llvm::Reloc::Model getRelocModel(const CodeGenOptions ) {
+  // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
+  llvm::Optional RM;
+  RM = llvm::StringSwitch(CodeGenOpts.RelocationModel)
+  .Case("static", llvm::Reloc::Static)
+  .Case("pic", llvm::Reloc::PIC_)
+  .Case("ropi", llvm::Reloc::ROPI)
+  .Case("rwpi", llvm::Reloc::RWPI)
+  .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+  .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
+  assert(RM.hasValue() && "invalid PIC model!");
+  return *RM;
+}
+
+static TargetMachine::CodeGenFileType getCodeGenFileType(BackendAction Action) {
+  if (Action == Backend_EmitObj)
+return TargetMachine::CGFT_ObjectFile;
+  else if (Action == Backend_EmitMCNull)
+return TargetMachine::CGFT_Null;
+  else {
+assert(Action == Backend_EmitAssembly && "Invalid action!");
+return TargetMachine::CGFT_AssemblyFile;
+  }
+}
+
+static void initTargetOptions(llvm::TargetOptions ,
+  const CodeGenOptions ,
+  const clang::TargetOptions ,
+  const LangOptions ,
+  const HeaderSearchOptions ) {
+  Options.ThreadModel =
+  llvm::StringSwitch(CodeGenOpts.ThreadModel)
+  .Case("posix", llvm::ThreadModel::POSIX)
+  .Case("single", llvm::ThreadModel::Single);
+
+  // Set float ABI type.
+  assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
+  CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
+ "Invalid Floating Point ABI!");
+  Options.FloatABIType =
+  llvm::StringSwitch(CodeGenOpts.FloatABI)
+  .Case("soft", llvm::FloatABI::Soft)
+  .Case("softfp", llvm::FloatABI::Soft)
+  .Case("hard", llvm::FloatABI::Hard)
+  .Default(llvm::FloatABI::Default);
+
+  // Set FP fusion mode.
+  switch (LangOpts.getDefaultFPContractMode()) {
+  case LangOptions::FPC_Off:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
+break;
+  case LangOptions::FPC_On:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
+break;
+  case LangOptions::FPC_Fast:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
+break;
+  }
+
+  Options.UseInitArray = CodeGenOpts.UseInitArray;
+  Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
+  Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+  Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
+
+  // Set EABI version.
+  Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)
+.Case("4", llvm::EABI::EABI4)
+.Case("5", llvm::EABI::EABI5)
+.Case("gnu", llvm::EABI::GNU)
+.Default(llvm::EABI::Default);
+
+  if (LangOpts.SjLjExceptions)
+Options.ExceptionModel = llvm::ExceptionHandling::SjLj;
+
+  Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
+  Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
+  Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
+  Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
+  Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;
+  Options.FunctionSections = CodeGenOpts.FunctionSections;
+  Options.DataSections = CodeGenOpts.DataSections;
+  Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
+  Options.EmulatedTLS = 

r299151 - Update x86-64 ABI link with the one from linuxbase.org since the other

2017-03-30 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Mar 30 20:59:40 2017
New Revision: 299151

URL: http://llvm.org/viewvc/llvm-project?rev=299151=rev
Log:
Update x86-64 ABI link with the one from linuxbase.org since the other
seems to be down.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=299151=299150=299151=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Mar 30 20:59:40 2017
@@ -168,7 +168,7 @@ public:
 PowerABIBuiltinVaList,
 
 /// __builtin_va_list as defined by the x86-64 ABI:
-/// http://www.x86-64.org/documentation/abi.pdf
+/// http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf
 X86_64ABIBuiltinVaList,
 
 /// __builtin_va_list as defined by ARM AAPCS ABI


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


r299148 - Fix typo, defind -> defined.

2017-03-30 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Mar 30 20:45:39 2017
New Revision: 299148

URL: http://llvm.org/viewvc/llvm-project?rev=299148=rev
Log:
Fix typo, defind -> defined.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=299148=299147=299148=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Mar 30 20:45:39 2017
@@ -154,7 +154,7 @@ public:
 /// typedef void* __builtin_va_list;
 VoidPtrBuiltinVaList,
 
-/// __builtin_va_list as defind by the AArch64 ABI
+/// __builtin_va_list as defined by the AArch64 ABI
 /// 
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
 AArch64ABIBuiltinVaList,
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=299148=299147=299148=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Mar 30 20:45:39 2017
@@ -5810,7 +5810,7 @@ ExprResult Sema::CheckTemplateArgument(N
   // -- a temporary object
   // -- a string literal
   // -- the result of a typeid expression, or
-  // -- a predefind __func__ variable
+  // -- a predefined __func__ variable
   if (auto *E = Value.getLValueBase().dyn_cast()) {
 if (isa(E)) {
   Converted = TemplateArgument(const_cast(E));


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


[clang-tools-extra] r299146 - [clang-tidy] Revert D31406 (Reuse FileID in getLocation)

2017-03-30 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Thu Mar 30 20:11:11 2017
New Revision: 299146

URL: http://llvm.org/viewvc/llvm-project?rev=299146=rev
Log:
[clang-tidy] Revert D31406 (Reuse FileID in getLocation)

Somehow the change failed test clang-tidy/llvm-include-order.cpp
on Windows platform.

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


Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299146=299145=299146=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Mar 30 20:11:11 2017
@@ -238,7 +238,7 @@ private:
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
+FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


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


Re: [clang-tools-extra] r299119 - [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-hung Hsieh via cfe-commits
I don't know why this test failed only on Windows, but will revert my
change soon.


On Thu, Mar 30, 2017 at 6:07 PM, Yung, Douglas 
wrote:

> Hi, this change seems to be causing the test clang-tidy/llvm-include-order.cpp
> to fail with a crash on the PS4 Windows bot:
>
> (From http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/7487)
>
>  TEST 'Clang Tools :: clang-tidy/llvm-include-order.cpp'
> FAILED 
> Script:
> --
> C:/Python27/python.exe C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast/llvm.src/tools/clang/tools/extra/test/.
> ./test\clang-tidy\check_clang_tidy.py C:\Buildbot\Slave\llvm-clang-
> lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\
> tools\clang\tools\extra\test\clang-tidy\llvm-include-order.cpp
> llvm-include-order C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\
> clang-tidy\Output\llvm-include-order.cpp.tmp -- -- -isystem
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\tools\extra\test\
> clang-tidy/Inputs/Headers
> --
> Exit Code: 1
>
> Command Output (stdout):
> --
> $ "C:/Python27/python.exe" "C:/Buildbot/Slave/llvm-clang-
> lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/
> tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py"
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\tools\extra\test\
> clang-tidy\llvm-include-order.cpp" "llvm-include-order"
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\
> clang-tidy\Output\llvm-include-order.cpp.tmp" "--" "--" "-isystem"
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\tools\extra\test\
> clang-tidy/Inputs/Headers"
> # command output:
> Running ['clang-tidy', 'C:\\Buildbot\\Slave\\llvm-
> clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\
> tools\\clang\\tools\\extra\\test\\clang-tidy\\Output\\
> llvm-include-order.cpp.tmp.cpp', '-fix', '--checks=-*,llvm-include-order',
> '--', '-isystem', 'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\\llvm.src\\tools\\clang\\tools\\extra\\
> test\\clang-tidy/Inputs/Headers', '-nostdinc++']...
> clang-tidy failed:
> 2 warnings generated.
>
> Assertion failed: EndColNo <= map.getSourceLine().size() && "Invalid
> range!", file C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\lib\Frontend\TextDiagnostic.cpp,
> line 999
>
>
>
> # command stderr:
> Traceback (most recent call last):
>
>   File "C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast/llvm.src/tools/clang/tools/extra/test/.
> ./test\clang-tidy\check_clang_tidy.py", line 140, in 
>
> main()
>
>   File "C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast/llvm.src/tools/clang/tools/extra/test/.
> ./test\clang-tidy\check_clang_tidy.py", line 96, in main
>
> subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
>
>   File "C:\Python27\lib\subprocess.py", line 573, in check_output
>
> raise CalledProcessError(retcode, cmd, output=output)
>
> subprocess.CalledProcessError: Command '['clang-tidy',
> 'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\\llvm.obj\\tools\\clang\\tools\\extra\\
> test\\clang-tidy\\Output\\llvm-include-order.cpp.tmp.cpp', '-fix',
> '--checks=-*,llvm-include-order', '--', '-isystem',
> 'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\\llvm.src\\tools\\clang\\tools\\extra\\
> test\\clang-tidy/Inputs/Headers', '-nostdinc++']' returned non-zero exit
> status 255
>
>
> error: command failed with exit status: 1
>
> --
>
> 
>
> Can you take a look?
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Chih-Hung Hsieh via cfe-commits
> > Sent: Thursday, March 30, 2017 15:09
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r299119 - [clang-tidy] Reuse FileID in
> > getLocation
> >
> > Author: chh
> > Date: Thu Mar 30 17:09:17 2017
> > New Revision: 299119
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=299119=rev
> > Log:
> > [clang-tidy] Reuse FileID in getLocation
> >
> > One FileID per warning will increase and overflow NextLocalOffset when
> input
> > file is large with many warnings.
> > Reusing FileID avoids this problem.
> >
> > Differential Revision: http://reviews.llvm.org/D31406
> >
> >
> > Modified:
> > clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
> > tidy/ClangTidy.cpp?rev=299119=299118=299119=diff
> > 
> ==
> > 

RE: [clang-tools-extra] r299119 - [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Yung, Douglas via cfe-commits
Hi, this change seems to be causing the test clang-tidy/llvm-include-order.cpp 
to fail with a crash on the PS4 Windows bot:

(From 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7487)

 TEST 'Clang Tools :: clang-tidy/llvm-include-order.cpp' 
FAILED 
Script:
--
C:/Python27/python.exe 
C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py
 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\llvm-include-order.cpp
 llvm-include-order 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\clang-tidy\Output\llvm-include-order.cpp.tmp
 -- -- -isystem 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy/Inputs/Headers
--
Exit Code: 1

Command Output (stdout):
--
$ "C:/Python27/python.exe" 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py"
 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\llvm-include-order.cpp"
 "llvm-include-order" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\clang-tidy\Output\llvm-include-order.cpp.tmp"
 "--" "--" "-isystem" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy/Inputs/Headers"
# command output:
Running ['clang-tidy', 
'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\tools\\extra\\test\\clang-tidy\\Output\\llvm-include-order.cpp.tmp.cpp',
 '-fix', '--checks=-*,llvm-include-order', '--', '-isystem', 
'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.src\\tools\\clang\\tools\\extra\\test\\clang-tidy/Inputs/Headers',
 '-nostdinc++']...
clang-tidy failed:
2 warnings generated.

Assertion failed: EndColNo <= map.getSourceLine().size() && "Invalid range!", 
file 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\lib\Frontend\TextDiagnostic.cpp,
 line 999



# command stderr:
Traceback (most recent call last):

  File 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py",
 line 140, in 

main()

  File 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py",
 line 96, in main

subprocess.check_output(args, stderr=subprocess.STDOUT).decode()

  File "C:\Python27\lib\subprocess.py", line 573, in check_output

raise CalledProcessError(retcode, cmd, output=output)

subprocess.CalledProcessError: Command '['clang-tidy', 
'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\tools\\extra\\test\\clang-tidy\\Output\\llvm-include-order.cpp.tmp.cpp',
 '-fix', '--checks=-*,llvm-include-order', '--', '-isystem', 
'C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.src\\tools\\clang\\tools\\extra\\test\\clang-tidy/Inputs/Headers',
 '-nostdinc++']' returned non-zero exit status 255


error: command failed with exit status: 1

--



Can you take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Chih-Hung Hsieh via cfe-commits
> Sent: Thursday, March 30, 2017 15:09
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r299119 - [clang-tidy] Reuse FileID in
> getLocation
> 
> Author: chh
> Date: Thu Mar 30 17:09:17 2017
> New Revision: 299119
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=299119=rev
> Log:
> [clang-tidy] Reuse FileID in getLocation
> 
> One FileID per warning will increase and overflow NextLocalOffset when input
> file is large with many warnings.
> Reusing FileID avoids this problem.
> 
> Differential Revision: http://reviews.llvm.org/D31406
> 
> 
> Modified:
> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> 
> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
> tidy/ClangTidy.cpp?rev=299119=299118=299119=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Mar 30 17:09:17
> +++ 2017
> @@ -238,7 +238,7 @@ private:
>return SourceLocation();
> 
>  const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
> -FileID ID = SourceMgr.createFileID(File, SourceLocation(),
> SrcMgr::C_User);
> +FileID ID 

[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-03-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good to me




Comment at: lib/Sema/SemaDecl.cpp:6710-6711
+
+  // Return false if warning is ignored.
+  if (Diags.isIgnored(diag::warn_decl_shadow, R.getNameLoc()))
+return false;

I would recommend reordering these checks. Examining our name lookup result is 
going to be way faster than asking the diagnostic machinery if a warning is 
enabled. That code is unfortunately quite slow.


https://reviews.llvm.org/D31235



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


[PATCH] D31518: Try to fix the libcxx build with mingw64

2017-03-30 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299144: Try to fix the libcxx build with mingw64 (authored 
by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D31518?vs=93568=93570#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31518

Files:
  libcxx/trunk/cmake/config-ix.cmake


Index: libcxx/trunk/cmake/config-ix.cmake
===
--- libcxx/trunk/cmake/config-ix.cmake
+++ libcxx/trunk/cmake/config-ix.cmake
@@ -35,6 +35,11 @@
   elseif (LIBCXX_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+list(APPEND CMAKE_REQUIRED_LIBRARIES mingw32 gcc gcc_eh mingwex msvcrt gcc)
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()


Index: libcxx/trunk/cmake/config-ix.cmake
===
--- libcxx/trunk/cmake/config-ix.cmake
+++ libcxx/trunk/cmake/config-ix.cmake
@@ -35,6 +35,11 @@
   elseif (LIBCXX_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+list(APPEND CMAKE_REQUIRED_LIBRARIES mingw32 gcc gcc_eh mingwex msvcrt gcc)
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r299144 - Try to fix the libcxx build with mingw64

2017-03-30 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Mar 30 19:34:05 2017
New Revision: 299144

URL: http://llvm.org/viewvc/llvm-project?rev=299144=rev
Log:
Try to fix the libcxx build with mingw64

Summary:
mingw64 has lots of default libs that libc++ and its test programs
should link against.

With this patch, cmake now runs successfully with GCC on Windows.

Reviewers: mati865, EricWF

Subscribers: mgorny, cfe-commits

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

Modified:
libcxx/trunk/cmake/config-ix.cmake

Modified: libcxx/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/config-ix.cmake?rev=299144=299143=299144=diff
==
--- libcxx/trunk/cmake/config-ix.cmake (original)
+++ libcxx/trunk/cmake/config-ix.cmake Thu Mar 30 19:34:05 2017
@@ -35,6 +35,11 @@ if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
   elseif (LIBCXX_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+list(APPEND CMAKE_REQUIRED_LIBRARIES mingw32 gcc gcc_eh mingwex msvcrt gcc)
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()


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


[libcxxabi] r299143 - [libc++abi] Remove missed use of config.h

2017-03-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Mar 30 19:29:25 2017
New Revision: 299143

URL: http://llvm.org/viewvc/llvm-project?rev=299143=rev
Log:
[libc++abi] Remove missed use of config.h

Modified:
libcxxabi/trunk/src/cxa_noexception.cpp

Modified: libcxxabi/trunk/src/cxa_noexception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_noexception.cpp?rev=299143=299142=299143=diff
==
--- libcxxabi/trunk/src/cxa_noexception.cpp (original)
+++ libcxxabi/trunk/src/cxa_noexception.cpp Thu Mar 30 19:29:25 2017
@@ -13,7 +13,6 @@
 
 // Support functions for the no-exceptions libc++ library
 
-#include "config.h"
 #include "cxxabi.h"
 
 #include // for std::terminate


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


[PATCH] D31518: Try to fix the libcxx build with mingw64

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

LGTM. CMake's behavior here is unfortunate but this seems like a reasonable 
workaround.


https://reviews.llvm.org/D31518



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


[PATCH] D31518: Try to fix the libcxx build with mingw64

2017-03-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
Herald added a subscriber: mgorny.

mingw64 has lots of default libs that libc++ and its test programs
should link against.

With this patch, cmake now runs successfully with GCC on Windows.


https://reviews.llvm.org/D31518

Files:
  libcxx/cmake/config-ix.cmake


Index: libcxx/cmake/config-ix.cmake
===
--- libcxx/cmake/config-ix.cmake
+++ libcxx/cmake/config-ix.cmake
@@ -35,6 +35,11 @@
   elseif (LIBCXX_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+list(APPEND CMAKE_REQUIRED_LIBRARIES mingw32 gcc gcc_eh mingwex msvcrt gcc)
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()


Index: libcxx/cmake/config-ix.cmake
===
--- libcxx/cmake/config-ix.cmake
+++ libcxx/cmake/config-ix.cmake
@@ -35,6 +35,11 @@
   elseif (LIBCXX_HAS_GCC_S_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
   endif ()
+  if (MINGW)
+# Mingw64 requires quite a few "C" runtime libraries in order for basic
+# programs to link successfully with -nodefaultlibs.
+list(APPEND CMAKE_REQUIRED_LIBRARIES mingw32 gcc gcc_eh mingwex msvcrt gcc)
+  endif()
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends

2017-03-30 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D31508



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


[PATCH] D31502: [libc++abi] Delete config.h

2017-03-30 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299129: [libc++abi] Delete config.h (authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D31502?vs=93496=93565#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31502

Files:
  libcxxabi/trunk/src/config.h
  libcxxabi/trunk/src/cxa_default_handlers.cpp
  libcxxabi/trunk/src/cxa_exception.cpp
  libcxxabi/trunk/src/cxa_exception_storage.cpp
  libcxxabi/trunk/src/cxa_guard.cpp
  libcxxabi/trunk/src/cxa_handlers.cpp
  libcxxabi/trunk/src/cxa_personality.cpp
  libcxxabi/trunk/src/fallback_malloc.cpp
  libcxxabi/trunk/test/test_exception_storage.pass.cpp
  libcxxabi/trunk/test/test_guard.pass.cpp

Index: libcxxabi/trunk/test/test_exception_storage.pass.cpp
===
--- libcxxabi/trunk/test/test_exception_storage.pass.cpp
+++ libcxxabi/trunk/test/test_exception_storage.pass.cpp
@@ -11,7 +11,6 @@
 // This breaks this test when compiled in C++17. For now fix this by manually
 // re-enabling the STL functions.
 #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-#include "../src/config.h"
 
 #include 
 #include 
Index: libcxxabi/trunk/test/test_guard.pass.cpp
===
--- libcxxabi/trunk/test/test_guard.pass.cpp
+++ libcxxabi/trunk/test/test_guard.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "../src/config.h"
 #include "cxxabi.h"
 
 #include 
Index: libcxxabi/trunk/src/cxa_guard.cpp
===
--- libcxxabi/trunk/src/cxa_guard.cpp
+++ libcxxabi/trunk/src/cxa_guard.cpp
@@ -10,7 +10,6 @@
 #include "__cxxabi_config.h"
 
 #include "abort_message.h"
-#include "config.h"
 #include <__threading_support>
 
 #include 
Index: libcxxabi/trunk/src/cxa_handlers.cpp
===
--- libcxxabi/trunk/src/cxa_handlers.cpp
+++ libcxxabi/trunk/src/cxa_handlers.cpp
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h"
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
Index: libcxxabi/trunk/src/cxa_exception.cpp
===
--- libcxxabi/trunk/src/cxa_exception.cpp
+++ libcxxabi/trunk/src/cxa_exception.cpp
@@ -11,7 +11,6 @@
 //  
 //===--===//
 
-#include "config.h"
 #include "cxxabi.h"
 
 #include // for std::terminate
Index: libcxxabi/trunk/src/fallback_malloc.cpp
===
--- libcxxabi/trunk/src/fallback_malloc.cpp
+++ libcxxabi/trunk/src/fallback_malloc.cpp
@@ -9,7 +9,6 @@
 
 #include "fallback_malloc.h"
 
-#include "config.h"
 #include <__threading_support>
 
 #include  // for malloc, calloc, free
Index: libcxxabi/trunk/src/cxa_exception_storage.cpp
===
--- libcxxabi/trunk/src/cxa_exception_storage.cpp
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp
@@ -13,7 +13,6 @@
 
 #include "cxa_exception.hpp"
 
-#include "config.h"
 #include <__threading_support>
 
 #if defined(_LIBCXXABI_HAS_NO_THREADS)
Index: libcxxabi/trunk/src/cxa_personality.cpp
===
--- libcxxabi/trunk/src/cxa_personality.cpp
+++ libcxxabi/trunk/src/cxa_personality.cpp
@@ -18,7 +18,6 @@
 #include 
 
 #include "__cxxabi_config.h"
-#include "config.h"
 #include "cxa_exception.hpp"
 #include "cxa_handlers.hpp"
 #include "private_typeinfo.h"
Index: libcxxabi/trunk/src/cxa_default_handlers.cpp
===
--- libcxxabi/trunk/src/cxa_default_handlers.cpp
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h" // For __sync_swap
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
Index: libcxxabi/trunk/src/config.h
===
--- libcxxabi/trunk/src/config.h
+++ libcxxabi/trunk/src/config.h
@@ -1,17 +0,0 @@
-//===- config.h ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//
-//  Defines macros used within the libc++abi project.
-//
-//===--===//
-
-
-#ifndef LIBCXXABI_CONFIG_H
-#define LIBCXXABI_CONFIG_H
-
-#endif // LIBCXXABI_CONFIG_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[libcxxabi] r299129 - [libc++abi] Delete config.h

2017-03-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Mar 30 18:31:33 2017
New Revision: 299129

URL: http://llvm.org/viewvc/llvm-project?rev=299129=rev
Log:
[libc++abi] Delete config.h

Summary: It's now completely empty, so we can remove it entirely.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

Removed:
libcxxabi/trunk/src/config.h
Modified:
libcxxabi/trunk/src/cxa_default_handlers.cpp
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception_storage.cpp
libcxxabi/trunk/src/cxa_guard.cpp
libcxxabi/trunk/src/cxa_handlers.cpp
libcxxabi/trunk/src/cxa_personality.cpp
libcxxabi/trunk/src/fallback_malloc.cpp
libcxxabi/trunk/test/test_exception_storage.pass.cpp
libcxxabi/trunk/test/test_guard.pass.cpp

Removed: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=299128=auto
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h (removed)
@@ -1,17 +0,0 @@
-//===- config.h 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//
-//  Defines macros used within the libc++abi project.
-//
-//===--===//
-
-
-#ifndef LIBCXXABI_CONFIG_H
-#define LIBCXXABI_CONFIG_H
-
-#endif // LIBCXXABI_CONFIG_H

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=299129=299128=299129=diff
==
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Thu Mar 30 18:31:33 2017
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h" // For __sync_swap
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=299129=299128=299129=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Thu Mar 30 18:31:33 2017
@@ -11,7 +11,6 @@
 //  
 
//===--===//
 
-#include "config.h"
 #include "cxxabi.h"
 
 #include // for std::terminate

Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception_storage.cpp?rev=299129=299128=299129=diff
==
--- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp Thu Mar 30 18:31:33 2017
@@ -13,7 +13,6 @@
 
 #include "cxa_exception.hpp"
 
-#include "config.h"
 #include <__threading_support>
 
 #if defined(_LIBCXXABI_HAS_NO_THREADS)

Modified: libcxxabi/trunk/src/cxa_guard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp?rev=299129=299128=299129=diff
==
--- libcxxabi/trunk/src/cxa_guard.cpp (original)
+++ libcxxabi/trunk/src/cxa_guard.cpp Thu Mar 30 18:31:33 2017
@@ -10,7 +10,6 @@
 #include "__cxxabi_config.h"
 
 #include "abort_message.h"
-#include "config.h"
 #include <__threading_support>
 
 #include 

Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=299129=299128=299129=diff
==
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Thu Mar 30 18:31:33 2017
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h"
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"

Modified: libcxxabi/trunk/src/cxa_personality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=299129=299128=299129=diff
==
--- libcxxabi/trunk/src/cxa_personality.cpp (original)
+++ libcxxabi/trunk/src/cxa_personality.cpp Thu Mar 30 18:31:33 2017
@@ -18,7 +18,6 @@
 #include 
 
 #include "__cxxabi_config.h"
-#include "config.h"
 #include "cxa_exception.hpp"
 #include "cxa_handlers.hpp"
 #include "private_typeinfo.h"

Modified: libcxxabi/trunk/src/fallback_malloc.cpp
URL: 

[PATCH] D31502: [libc++abi] Delete config.h

2017-03-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D31502#714341, @EricWF wrote:

> Thanks. I'm surprised this wasn't done earlier.


I removed the `unistd.h` include this morning (r299087 
), which is what made the file empty.


https://reviews.llvm.org/D31502



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


r299127 - fixup: use CHECK for non-atttribute sets

2017-03-30 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Mar 30 17:46:49 2017
New Revision: 299127

URL: http://llvm.org/viewvc/llvm-project?rev=299127=rev
Log:
fixup: use CHECK for non-atttribute sets

Modified:
cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp

Modified: cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp?rev=299127=299126=299127=diff
==
--- cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp Thu Mar 30 17:46:49 
2017
@@ -8,7 +8,7 @@ int foo() {
   return 2;
 }
 
-// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
-// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
 // CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} 
"xray-instruction-threshold"="1" {{.*}}
 // CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} 
"function-instrument"="xray-never" {{.*}}


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


r299126 - [XRay][clang] Fix the -fxray-instruction-threshold flag processing

2017-03-30 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Mar 30 17:46:45 2017
New Revision: 299126

URL: http://llvm.org/viewvc/llvm-project?rev=299126=rev
Log:
[XRay][clang] Fix the -fxray-instruction-threshold flag processing

Summary:
The refactoring introduced a regression in the flag processing for
-fxray-instruction-threshold which causes it to not get passed properly.
This change should restore the previous behaviour.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
Modified:
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=299126=299125=299126=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Mar 30 17:46:45 2017
@@ -16,8 +16,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SpecialCaseList.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,8 +91,8 @@ void XRayArgs::addArgs(const ToolChain &
 return;
 
   CmdArgs.push_back(XRayInstrumentOption);
-  CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-   llvm::to_string(InstructionThreshold)));
+  CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
+   Twine(InstructionThreshold)));
 
   for (const auto  : AlwaysInstrumentFiles) {
 SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=299126=299125=299126=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Mar 30 17:46:45 2017
@@ -721,7 +721,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
-  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
@@ -2308,9 +2308,11 @@ static void ParseLangArgs(LangOptions 
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
 
-  // -fxray-{always,never}-instrument= filenames.
+  // -fxray-instrument
   Opts.XRayInstrument =
   Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument, false);
+
+  // -fxray-{always,never}-instrument= filenames.
   Opts.XRayAlwaysInstrumentFiles =
   Args.getAllArgValues(OPT_fxray_always_instrument);
   Opts.XRayNeverInstrumentFiles =

Added: cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp?rev=299126=auto
==
--- cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp Thu Mar 30 17:46:45 
2017
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -x c++ 
-std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int bar() {
+  return 2;
+}
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} 
"xray-instruction-threshold"="1" {{.*}}
+// CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} 
"function-instrument"="xray-never" {{.*}}


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


[PATCH] D31491: [XRay][clang] Fix the -fxray-instruction-threshold flag processing

2017-03-30 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added inline comments.



Comment at: test/CodeGen/xray-instruction-threshold.cpp:11
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {

rnk wrote:
> Any reason to use -DAG on the decls? The IR should be in source order, with 
> the attributes always at the end. The attribute sets need -DAG, of course.
Good question. I hadn't thought that through, I was just thinking that the 
attribute set -DAG needed to depend on variables captured from a -DAG earlier. 
Changed this now since it seems it's unnecessary. :)


Repository:
  rL LLVM

https://reviews.llvm.org/D31491



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


[PATCH] D31491: [XRay][clang] Fix the -fxray-instruction-threshold flag processing

2017-03-30 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dberris marked an inline comment as done.
Closed by commit rL299126: [XRay][clang] Fix the -fxray-instruction-threshold 
flag processing (authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D31491?vs=93454=93560#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31491

Files:
  cfe/trunk/lib/Driver/XRayArgs.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp


Index: cfe/trunk/lib/Driver/XRayArgs.cpp
===
--- cfe/trunk/lib/Driver/XRayArgs.cpp
+++ cfe/trunk/lib/Driver/XRayArgs.cpp
@@ -16,8 +16,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SpecialCaseList.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,8 +91,8 @@
 return;
 
   CmdArgs.push_back(XRayInstrumentOption);
-  CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-   llvm::to_string(InstructionThreshold)));
+  CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
+   Twine(InstructionThreshold)));
 
   for (const auto  : AlwaysInstrumentFiles) {
 SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -721,7 +721,7 @@
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
-  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
@@ -2308,9 +2308,11 @@
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
 
-  // -fxray-{always,never}-instrument= filenames.
+  // -fxray-instrument
   Opts.XRayInstrument =
   Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument, false);
+
+  // -fxray-{always,never}-instrument= filenames.
   Opts.XRayAlwaysInstrumentFiles =
   Args.getAllArgValues(OPT_fxray_always_instrument);
   Opts.XRayNeverInstrumentFiles =
Index: cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
===
--- cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
+++ cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -x c++ 
-std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int bar() {
+  return 2;
+}
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} 
"xray-instruction-threshold"="1" {{.*}}
+// CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} 
"function-instrument"="xray-never" {{.*}}


Index: cfe/trunk/lib/Driver/XRayArgs.cpp
===
--- cfe/trunk/lib/Driver/XRayArgs.cpp
+++ cfe/trunk/lib/Driver/XRayArgs.cpp
@@ -16,8 +16,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SpecialCaseList.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,8 +91,8 @@
 return;
 
   CmdArgs.push_back(XRayInstrumentOption);
-  CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-   llvm::to_string(InstructionThreshold)));
+  CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
+   Twine(InstructionThreshold)));
 
   for (const auto  : AlwaysInstrumentFiles) {
 SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -721,7 +721,7 @@
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
 

[PATCH] D29644: [OpenMP] Pass -v to PTXAS if it was passed to the driver.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93559.
gtbercea added a comment.

Change prefix name in test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29644

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -595,3 +595,11 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
 
 // CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that CLANG forwards the -v flag to PTXAS.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
+
+// CHK-PTXAS-VERBOSE: ptxas{{.*}}" "-v"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -262,6 +262,10 @@
 CmdArgs.push_back("-O0");
   }
 
+  // Pass -v to ptxas if it was passed to the driver.
+  if (Args.hasArg(options::OPT_v))
+CmdArgs.push_back("-v");
+
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch)));
   CmdArgs.push_back("--output-file");


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -595,3 +595,11 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
 
 // CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that CLANG forwards the -v flag to PTXAS.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
+
+// CHK-PTXAS-VERBOSE: ptxas{{.*}}" "-v"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -262,6 +262,10 @@
 CmdArgs.push_back("-O0");
   }
 
+  // Pass -v to ptxas if it was passed to the driver.
+  if (Args.hasArg(options::OPT_v))
+CmdArgs.push_back("-v");
+
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch)));
   CmdArgs.push_back("--output-file");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31515: [libc++] Implement LWG 2911 - add an is_aggregate type-trait

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch implements http://cplusplus.github.io/LWG/lwg-defects.html#2911.

I'm putting this up for review until __is_aggregate is added to clang (See 
https://reviews.llvm.org/D31513)


https://reviews.llvm.org/D31515

Files:
  include/__config
  include/type_traits
  
test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp
  test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -480,7 +480,7 @@
 	http://wg21.link/LWG2904;>2904Make variant move-assignment more exception safeKona
 	http://wg21.link/LWG2905;>2905is_constructible_vunique_ptrP, D, P, D const  should be false when D is not copy constructibleKona
 	http://wg21.link/LWG2908;>2908The less-than operator for shared pointers could do moreKona
-	http://wg21.link/LWG2911;>2911An is_aggregate type trait is neededKona
+	http://wg21.link/LWG2911;>2911An is_aggregate type trait is neededKonaComplete
 	http://wg21.link/LWG2921;>2921packaged_task and type-erased allocatorsKona
 	http://wg21.link/LWG2934;>2934optionalconst T doesn't compare with TKonaComplete
 

[PATCH] D29642: [OpenMP] Make OpenMP generated code for the NVIDIA device relocatable by default

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93557.
gtbercea added a comment.

Change prefix name in test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29642

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" 
"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
 "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" 
"-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using 
OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29904: [OpenMP] Prevent emission of exception handling code when using OpenMP to offload to NVIDIA devices.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:2167-2172
+// Set the flag to prevent the implementation from emitting device 
exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}

ABataev wrote:
> I'm not sure this is the right place for this code.
Alexey, any suggestion where this code should be moved to?


Repository:
  rL LLVM

https://reviews.llvm.org/D29904



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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93555.
EricWF added a comment.

- Move test to correct file.


https://reviews.llvm.org/D31513

Files:
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/PCH/cxx-traits.cpp
  test/PCH/cxx-traits.h
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1,20 +1,37 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
 
+#if __cplusplus <= 201103L
+#define T_AFTER_CPP11(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP11(...) T(__VA_ARGS__)
+#endif
+
+#if __cplusplus <= 201402L
+#define T_AFTER_CPP14(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP14(...) T(__VA_ARGS__)
+#endif
+
 struct NonPOD { NonPOD(int); };
 
 // PODs
 enum Enum { EV };
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 typedef Empty EmptyAr[10];
+typedef Empty EmptyArNB[];
+typedef Empty EmptyArMB[1][2];
 typedef int Int;
 typedef Int IntAr[10];
 typedef Int IntArNB[];
 class Statics { static int priv; static NonPOD np; };
 union EmptyUnion {};
-union IncompleteUnion;
+union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
 union Union { int i; float f; };
 struct HasFunc { void f (); };
 struct HasOp { void operator *(); };
@@ -38,6 +55,10 @@
 typedef Derives DerivesArNB[];
 struct DerivesEmpty : Empty {};
 struct HasCons { HasCons(int); };
+struct HasDefaultCons { HasDefaultCons() = default; };
+struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
+struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
+struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
 struct HasNoThrowMoveAssign { 
@@ -48,8 +69,15 @@
 const HasNoExceptNoThrowMoveAssign&&) noexcept; 
 };
 struct HasThrowMoveAssign { 
-  HasThrowMoveAssign& operator=(
-const HasThrowMoveAssign&&) throw(POD); };
+  HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
+#if __cplusplus <= 201402L
+  throw(POD);
+#else
+  noexcept(false);
+#endif
+};
+
+
 struct HasNoExceptFalseMoveAssign { 
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
@@ -81,6 +109,7 @@
 class  HasPriv { int priv; };
 class  HasProt { protected: int prot; };
 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
+struct HasRefAggregate { int i; int& ref; };
 struct HasNonPOD { NonPOD np; };
 struct HasVirt { virtual void Virt() {}; };
 typedef NonPOD NonPODAr[10];
@@ -152,7 +181,12 @@
 };
 
 struct ThrowingDtor {
-  ~ThrowingDtor() throw(int);
+  ~ThrowingDtor()
+#if __cplusplus <= 201402L
+  throw(int);
+#else
+  noexcept(false);
+#endif
 };
 
 struct NoExceptDtor {
@@ -163,6 +197,20 @@
   ~NoThrowDtor() throw();
 };
 
+struct ACompleteType {};
+struct AnIncompleteType; // expected-note 4 {{forward declaration of 'AnIncompleteType'}}
+typedef AnIncompleteType AnIncompleteTypeAr[42];
+typedef AnIncompleteType AnIncompleteTypeArNB[];
+typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
+
+struct HasInClassInit {
+  int x = 42;
+};
+
+struct HasPrivateBase : private ACompleteType {};
+struct HasProtectedBase : protected ACompleteType {};
+struct HasVirtBase : virtual ACompleteType {};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -452,6 +500,68 @@
   int t31[F(__is_floating_point(IntArNB))];
 }
 
+template 
+struct AggregateTemplate {
+  T value;
+};
+
+template 
+struct NonAggregateTemplate {
+  T value;
+  NonAggregateTemplate();
+};
+
+void is_aggregate()
+{
+  int t01[F(__is_aggregate(NonPOD))];
+  int t02[F(__is_aggregate(Enum))];
+  int t03[T(__is_aggregate(POD))];
+  int t04[T(__is_aggregate(Empty))];
+  int t05[T(__is_aggregate(EmptyAr))];
+  int t06[T(__is_aggregate(EmptyArNB))];
+  int t07[T(__is_aggregate(EmptyArMB))];
+  int t08[F(__is_aggregate(AnIncompleteType))]; // expected-error {{incomplete type 'AnIncompleteType' used in type trait expression}}
+  int t09[F(__is_aggregate(AnIncompleteTypeAr))]; // expected-error {{incomplete type 'AnIncompleteType' used in type trait expression}}
+  int t10[F(__is_aggregate(AnIncompleteTypeArNB))]; // expected-error {{incomplete type 'AnIncompleteType' used in type trait expression}}
+  int t11[F(__is_aggregate(AnIncompleteTypeArMB))]; // expected-error {{incomplete type 'AnIncompleteType' 

[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299119: [clang-tidy] Reuse FileID in getLocation (authored 
by chh).

Changed prior to commit:
  https://reviews.llvm.org/D31406?vs=93499=93554#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31406

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r299119 - [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Thu Mar 30 17:09:17 2017
New Revision: 299119

URL: http://llvm.org/viewvc/llvm-project?rev=299119=rev
Log:
[clang-tidy] Reuse FileID in getLocation

One FileID per warning will increase and overflow NextLocalOffset
when input file is large with many warnings.
Reusing FileID avoids this problem.

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


Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299119=299118=299119=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Mar 30 17:09:17 2017
@@ -238,7 +238,7 @@ private:
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


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


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

LWG 2911  adds 
`std::is_aggregate` to the library, which requires a new builtin trait. This 
patch implements `__is_aggregate`.

Additionally this patch implements LWG 2015 
, which requires than 
arrays used with [meta.unary.prop] traits have a complete element type.


https://reviews.llvm.org/D31513

Files:
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/PCH/cxx-traits.cpp
  test/PCH/cxx-traits.h
  test/SemaCXX/type-traits.cpp
  test/SemaTemplate/instantiate-method.cpp

Index: test/SemaTemplate/instantiate-method.cpp
===
--- test/SemaTemplate/instantiate-method.cpp
+++ test/SemaTemplate/instantiate-method.cpp
@@ -49,6 +49,18 @@
 // the code below should probably instantiate by itself.
 int abstract_destructor[__is_abstract(HasDestructor)? 1 : -1];
 
+template 
+class IsAggregate {
+};
+
+template 
+class IsNotAggregate {
+  T value;
+public:
+  IsNotAggregate() {}
+};
+int test_is_aggregate[__is_aggregate(IsAggregate) ? 1 : -1];
+int test_is_not_aggregate[__is_aggregate(IsNotAggregate) ? -1 : 1];
 
 template
 class Constructors {
Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
 
@@ -9,12 +12,14 @@
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 typedef Empty EmptyAr[10];
+typedef Empty EmptyArNB[];
+typedef Empty EmptyArMB[1][2];
 typedef int Int;
 typedef Int IntAr[10];
 typedef Int IntArNB[];
 class Statics { static int priv; static NonPOD np; };
 union EmptyUnion {};
-union IncompleteUnion;
+union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
 union Union { int i; float f; };
 struct HasFunc { void f (); };
 struct HasOp { void operator *(); };
@@ -38,6 +43,10 @@
 typedef Derives DerivesArNB[];
 struct DerivesEmpty : Empty {};
 struct HasCons { HasCons(int); };
+struct HasDefaultCons { HasDefaultCons() = default; };
+struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
+struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
+struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
 struct HasNoThrowMoveAssign { 
@@ -48,8 +57,15 @@
 const HasNoExceptNoThrowMoveAssign&&) noexcept; 
 };
 struct HasThrowMoveAssign { 
-  HasThrowMoveAssign& operator=(
-const HasThrowMoveAssign&&) throw(POD); };
+  HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
+#if __cplusplus <= 201402L
+  throw(POD);
+#else
+  noexcept(false);
+#endif
+};
+
+
 struct HasNoExceptFalseMoveAssign { 
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
@@ -81,6 +97,7 @@
 class  HasPriv { int priv; };
 class  HasProt { protected: int prot; };
 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
+struct HasRefAggregate { int i; int& ref; };
 struct HasNonPOD { NonPOD np; };
 struct HasVirt { virtual void Virt() {}; };
 typedef NonPOD NonPODAr[10];
@@ -152,7 +169,12 @@
 };
 
 struct ThrowingDtor {
-  ~ThrowingDtor() throw(int);
+  ~ThrowingDtor()
+#if __cplusplus <= 201402L
+  throw(int);
+#else
+  noexcept(false);
+#endif
 };
 
 struct NoExceptDtor {
@@ -163,6 +185,20 @@
   ~NoThrowDtor() throw();
 };
 
+struct ACompleteType {};
+struct AnIncompleteType; // expected-note 4 {{forward declaration of 'AnIncompleteType'}}
+typedef AnIncompleteType AnIncompleteTypeAr[42];
+typedef AnIncompleteType AnIncompleteTypeArNB[];
+typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
+
+struct HasInClassInit {
+  int x = 42;
+};
+
+struct HasPrivateBase : private ACompleteType {};
+struct HasProtectedBase : protected ACompleteType {};
+struct HasVirtBase : virtual ACompleteType {};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -452,6 +488,66 @@
   int t31[F(__is_floating_point(IntArNB))];
 }
 
+#if __cplusplus <= 201103L
+#define T_AFTER_CPP11(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP11(...) T(__VA_ARGS__)
+#endif
+
+#if __cplusplus <= 201402L
+#define T_AFTER_CPP14(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP14(...) T(__VA_ARGS__)
+#endif
+
+void 

[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299117: Clang changes for alloc_align attribute  (authored 
by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D29599?vs=93537=93549#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29599

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/CodeGen/alloc-align-attr.c
  cfe/trunk/test/Sema/alloc-align-attr.c
  cfe/trunk/test/SemaCXX/alloc-align-attr.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -8176,6 +8176,11 @@
   void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
 unsigned SpellingListIndex);
 
+  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
+  /// declaration.
+  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
+ unsigned SpellingListIndex);
+
   /// AddAlignValueAttr - Adds an align_value attribute to a particular
   /// declaration.
   void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -244,6 +244,36 @@
   }];
 }
 
+def AllocAlignDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use ``__attribute__((alloc_align())`` on a function
+declaration to specify that the return value of the function (which must be a
+pointer type) is at least as aligned as the value of the indicated parameter. The 
+parameter is given by its index in the list of formal parameters; the first
+parameter has index 1 unless the function is a C++ non-static member function,
+in which case the first parameter has index 2 to account for the implicit ``this``
+parameter.
+
+.. code-block:: c++
+
+  // The returned pointer has the alignment specified by the first parameter.
+  void *a(size_t align) __attribute__((alloc_align(1)));
+
+  // The returned pointer has the alignment specified by the second parameter.
+  void *b(void *v, size_t align) __attribute__((alloc_align(2)));
+
+  // The returned pointer has the alignment specified by the second visible
+  // parameter, however it must be adjusted for the implicit 'this' parameter.
+  void *Foo::b(void *v, size_t align) __attribute__((alloc_align(3)));
+
+Note that this attribute merely informs the compiler that a function always
+returns a sufficiently aligned pointer. It does not cause the compiler to 
+emit code to enforce that alignment.  The behavior is undefined if the returned
+poitner is not sufficiently aligned.
+  }];
+}
+
 def EnableIfDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1225,6 +1225,14 @@
   let Documentation = [AssumeAlignedDocs];
 }
 
+def AllocAlign : InheritableAttr {
+  let Spellings = [GCC<"alloc_align">];
+  let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
+ "ExpectedFunctionWithProtoType">;
+  let Args = [IntArgument<"ParamIndex">];
+  let Documentation = [AllocAlignDocs];
+}
+
 def NoReturn : InheritableAttr {
   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
   // FIXME: Does GCC allow this on the function instead?
Index: cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
===
--- cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
+++ cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct param_num {
+  void* Foo(int a) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute is invalid for the implicit this argument}}
+};
+
+
+template 
+struct dependent_ret {
+  T* Foo(int a) __attribute__((alloc_align(2)));// no-warning, ends up being int**.
+  T Foo2(int a) __attribute__((alloc_align(2)));// expected-warning {{'alloc_align' attribute only applies to return values that are pointers or references}}
+};
+
+// Following 2 errors associated only with the 'float' versions below.
+template 
+struct dependent_param_struct {
+  void* Foo(T param) __attribute__((alloc_align(2))); // expected-error {{'alloc_align' attribute argument may only refer to a function parameter of integer type}}
+};
+
+template 
+void* dependent_param_func(T param) 

[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thanks guys.  I THINK I properly removed the svn properties properly, though, I 
actually didn't know they existed until just now!


Repository:
  rL LLVM

https://reviews.llvm.org/D29599



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


[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

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

LG
Do you have commit rights?


https://reviews.llvm.org/D31406



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!

Can you drop the svn props on the new files when you commit? I don't think we 
usually set them, and I've seen commits specifically removing the eol-style 
props before.


https://reviews.llvm.org/D29599



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks.  With that, LGTM.


https://reviews.llvm.org/D29599



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 93537.
erichkeane added a comment.

Added tests as requested by John.


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c
  test/SemaCXX/alloc-align-attr.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4348,6 +4348,10 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal =
+  CallArgs[AA->getParamIndex() - 1].RV.getScalarVal();
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
   }
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2465,6 +2465,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -168,6 +168,16 @@
 Aligned->getSpellingListIndex());
 }
 
+static void instantiateDependentAllocAlignAttr(
+Sema , const MultiLevelTemplateArgumentList ,
+const AllocAlignAttr *Align, Decl *New) {
+  Expr *Param = IntegerLiteral::Create(
+  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext().UnsignedLongLongTy, Align->getLocation());
+  S.AddAllocAlignAttr(Align->getLocation(), New, Param,
+  Align->getSpellingListIndex());
+}
+
 static Expr *instantiateDependentFunctionAttrCondition(
 Sema , const MultiLevelTemplateArgumentList ,
 const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) {
@@ -380,6 +390,12 @@
   continue;
 }
 
+if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
+  instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New);
+  continue;
+}
+
+
 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
   instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl,
cast(New));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -218,21 +218,45 @@
std::greater());
 }
 
+/// \brief A helper function to provide Attribute Location for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   SourceLocation>::type
+getAttrLoc(const AttrInfo ) {
+  return Attr.getLocation();
+}
+static SourceLocation getAttrLoc(const clang::AttributeList ) {
+  return Attr.getLoc();
+}
+
+/// \brief A helper function to provide Attribute Name for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   const AttrInfo *>::type
+getAttrName(const AttrInfo ) {
+  return 
+}
+const IdentifierInfo *getAttrName(const clang::AttributeList ) {
+  return Attr.getName();
+}
+
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-static bool checkUInt32Argument(Sema , const AttributeList ,
-const Expr *Expr, uint32_t ,
-unsigned Idx = UINT_MAX) {
+template
+static bool checkUInt32Argument(Sema , const AttrInfo& Attr, const Expr *Expr,
+uint32_t , unsigned Idx = UINT_MAX) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
 if (Idx != UINT_MAX)
-  S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-<< Attr.getName() << Idx << 

[PATCH] D31114: Refactor `initTargetOptions` out of `EmitAssemblyHelper::CreateTargetMachine` and use it to initialize TargetOptions for ThinLTO Backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

As discussed with Mehdi offline, I am taking this one over. I just mailed 
https://reviews.llvm.org/D31508 which supersedes this one.


https://reviews.llvm.org/D31114



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


[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
Herald added a subscriber: Prazek.

This involved refactoring out pieces of
EmitAssemblyHelper::CreateTargetMachine for use in runThinLTOBackend.

Subsumes https://reviews.llvm.org/D31114.


https://reviews.llvm.org/D31508

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/function-sections.c

Index: test/CodeGen/function-sections.c
===
--- test/CodeGen/function-sections.c
+++ test/CodeGen/function-sections.c
@@ -9,6 +9,12 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 
+// Try again through a clang invocation of the ThinLTO backend.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
+// RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections -o - | FileCheck %s --check-prefix=DATA_SECT
+
 const int hello = 123;
 void world() {}
 
@@ -22,7 +28,7 @@
 // FUNC_SECT: section .rodata,
 // FUNC_SECT: hello:
 
-// DATA_SECT-NOT: section
+// DATA_SECT-NOT: .section
 // DATA_SECT: world:
 // DATA_SECT: .section .rodata.hello,
 // DATA_SECT: hello:
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -294,6 +294,139 @@
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
+static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions ) {
+  switch (CodeGenOpts.OptimizationLevel) {
+  default:
+llvm_unreachable("Invalid optimization level!");
+  case 0:
+return CodeGenOpt::None;
+  case 1:
+return CodeGenOpt::Less;
+  case 2:
+return CodeGenOpt::Default; // O2/Os/Oz
+  case 3:
+return CodeGenOpt::Aggressive;
+  }
+}
+
+static llvm::CodeModel::Model getCodeModel(const CodeGenOptions ) {
+  unsigned CodeModel =
+  llvm::StringSwitch(CodeGenOpts.CodeModel)
+  .Case("small", llvm::CodeModel::Small)
+  .Case("kernel", llvm::CodeModel::Kernel)
+  .Case("medium", llvm::CodeModel::Medium)
+  .Case("large", llvm::CodeModel::Large)
+  .Case("default", llvm::CodeModel::Default)
+  .Default(~0u);
+  assert(CodeModel != ~0u && "invalid code model!");
+  return static_cast(CodeModel);
+}
+
+static llvm::Reloc::Model getRelocModel(const CodeGenOptions ) {
+  // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
+  llvm::Optional RM;
+  RM = llvm::StringSwitch(CodeGenOpts.RelocationModel)
+  .Case("static", llvm::Reloc::Static)
+  .Case("pic", llvm::Reloc::PIC_)
+  .Case("ropi", llvm::Reloc::ROPI)
+  .Case("rwpi", llvm::Reloc::RWPI)
+  .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+  .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
+  assert(RM.hasValue() && "invalid PIC model!");
+  return *RM;
+}
+
+static TargetMachine::CodeGenFileType getCodeGenFileType(BackendAction Action) {
+  if (Action == Backend_EmitObj)
+return TargetMachine::CGFT_ObjectFile;
+  else if (Action == Backend_EmitMCNull)
+return TargetMachine::CGFT_Null;
+  else {
+assert(Action == Backend_EmitAssembly && "Invalid action!");
+return TargetMachine::CGFT_AssemblyFile;
+  }
+}
+
+static void initTargetOptions(llvm::TargetOptions ,
+  const CodeGenOptions ,
+  const clang::TargetOptions ,
+  const LangOptions ,
+  const HeaderSearchOptions ) {
+  Options.ThreadModel =
+  llvm::StringSwitch(CodeGenOpts.ThreadModel)
+  .Case("posix", llvm::ThreadModel::POSIX)
+  .Case("single", llvm::ThreadModel::Single);
+
+  // Set float ABI type.
+  assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
+  CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
+ "Invalid Floating Point ABI!");
+  Options.FloatABIType =
+  llvm::StringSwitch(CodeGenOpts.FloatABI)
+  .Case("soft", llvm::FloatABI::Soft)
+  .Case("softfp", llvm::FloatABI::Soft)
+  .Case("hard", llvm::FloatABI::Hard)
+  .Default(llvm::FloatABI::Default);
+
+  // Set FP fusion mode.
+  switch (CodeGenOpts.getFPContractMode()) {
+  case CodeGenOptions::FPC_Off:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
+break;
+  case CodeGenOptions::FPC_On:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
+break;
+  case CodeGenOptions::FPC_Fast:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
+break;
+  }
+
+  Options.UseInitArray = CodeGenOpts.UseInitArray;
+  Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
+  Options.CompressDebugSections = 

[PATCH] D31101: [ThinLTO] Use clang's existing code gen handling for ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 93535.
tejohnson added a comment.

Use LTO to emit LLVM IR


https://reviews.llvm.org/D31101

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/thinlto-emit-llvm.c


Index: test/CodeGen/thinlto-emit-llvm.c
===
--- /dev/null
+++ test/CodeGen/thinlto-emit-llvm.c
@@ -0,0 +1,10 @@
+// Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
+// ThinLTO backend path.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o 
- | FileCheck %s
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm-bc 
-o - | llvm-dis -o - | FileCheck %s
+
+// CHECK: define void @foo()
+void foo() {
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -902,7 +902,7 @@
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   std::unique_ptr OS,
-  std::string SampleProfile) {
+  std::string SampleProfile, BackendAction Action) 
{
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -954,6 +954,20 @@
   };
   lto::Config Conf;
   Conf.SampleProfile = std::move(SampleProfile);
+  switch (Action) {
+  case Backend_EmitNothing:
+Conf.IROutputType = lto::Config::EIRT_Nothing;
+break;
+  case Backend_EmitLL:
+Conf.IROutputType = lto::Config::EIRT_LL;
+break;
+  case Backend_EmitBC:
+Conf.IROutputType = lto::Config::EIRT_BC;
+break;
+  default:
+Conf.IROutputType = lto::Config::EIRT_CodeGen;
+break;
+  }
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -990,7 +1004,7 @@
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
   runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
-CGOpts.SampleProfileFile);
+CGOpts.SampleProfileFile, Action);
   return;
 }
   }


Index: test/CodeGen/thinlto-emit-llvm.c
===
--- /dev/null
+++ test/CodeGen/thinlto-emit-llvm.c
@@ -0,0 +1,10 @@
+// Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
+// ThinLTO backend path.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm-bc -o - | llvm-dis -o - | FileCheck %s
+
+// CHECK: define void @foo()
+void foo() {
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -902,7 +902,7 @@
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   std::unique_ptr OS,
-  std::string SampleProfile) {
+  std::string SampleProfile, BackendAction Action) {
   StringMap>
   ModuleToDefinedGVSummaries;
   CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -954,6 +954,20 @@
   };
   lto::Config Conf;
   Conf.SampleProfile = std::move(SampleProfile);
+  switch (Action) {
+  case Backend_EmitNothing:
+Conf.IROutputType = lto::Config::EIRT_Nothing;
+break;
+  case Backend_EmitLL:
+Conf.IROutputType = lto::Config::EIRT_LL;
+break;
+  case Backend_EmitBC:
+Conf.IROutputType = lto::Config::EIRT_BC;
+break;
+  default:
+Conf.IROutputType = lto::Config::EIRT_CodeGen;
+break;
+  }
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -990,7 +1004,7 @@
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
   runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
-CGOpts.SampleProfileFile);
+CGOpts.SampleProfileFile, Action);
   return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31101: [ThinLTO] Use clang's existing code gen handling for ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:1007
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 

tejohnson wrote:
> I just noticed that EmitAssembly does a lot more than just emission - it is 
> also setting up an optimization pipeline in CreatePasses, which we don't want 
> to do in the ThinLTO backend case as we already do the opt in LTO. Which 
> makes me think that the simplest and most consistent solution, especially if 
> as in discussed in D31114 we'll be using the LTO API for emitting object and 
> assembly code, is to use LTO for all file emission in the ThinLTO backend 
> case. It would mean extending lto::Config to be able to flag when we want to 
> emit-llvm or emit-llvm-bc, and invoke the appropriate module writer/printer 
> instead of normal codegen. That way -emit-llvm* will always get output 
> corresponding to the native object/assembly in the ThinLTO backend case. WDYT?
I have a new patch set that will do just this that I am uploading momentarily


https://reviews.llvm.org/D31101



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


Re: [PATCH] Use the correct ObjC++ personality

2017-03-30 Thread Jonathan Schleifer via cfe-commits
> Testcase?

Shouldn't be necessary for such a simple and extremely obvious one-liner.

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


[libcxx] r299105 - Fix LWG 2934 - optional doesn't compare with T

2017-03-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar 30 15:06:52 2017
New Revision: 299105

URL: http://llvm.org/viewvc/llvm-project?rev=299105=rev
Log:
Fix LWG 2934 - optional doesn't compare with T

Modified:
libcxx/trunk/include/optional
libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.relops/greater_than.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/less_equal.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/less_than.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/not_equal.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=299105=299104=299105=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Thu Mar 30 15:06:52 2017
@@ -921,14 +921,14 @@ private:
 };
 
 // Comparisons between optionals
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v,
+_VSTD::declval()), bool>,
 bool
 >
-operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (static_cast(__x) != static_cast(__y))
 return false;
@@ -937,14 +937,14 @@ operator==(const optional<_Tp>& __x, con
 return *__x == *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v,
+_VSTD::declval()), bool>,
 bool
 >
-operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (static_cast(__x) != static_cast(__y))
 return true;
@@ -953,14 +953,14 @@ operator!=(const optional<_Tp>& __x, con
 return *__x != *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v,
+_VSTD::declval()), bool>,
 bool
 >
-operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__y))
 return false;
@@ -969,14 +969,14 @@ operator<(const optional<_Tp>& __x, cons
 return *__x < *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__x))
 return false;
@@ -985,14 +985,14 @@ operator>(const optional<_Tp>& __x, cons
 return *__x > *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v,
+_VSTD::declval()), bool>,
 bool
 >
-operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__x))
 return true;
@@ -1001,14 +1001,14 @@ operator<=(const optional<_Tp>& __x, con
 return *__x <= *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v=
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__y))
 return true;
@@ -1115,146 +1115,146 @@ operator>=(nullopt_t, const optional<_Tp
 }
 
 // Comparisons with T
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v,
+_VSTD::declval()), bool>,
 bool
 >
-operator==(const optional<_Tp>& __x, const _Tp& __v)
+operator==(const optional<_Tp>& __x, const _Up& __v)
 {
 return static_cast(__x) ? *__x == __v : false;
 }
 
-template 
+template 
 

[libcxx] r299100 - Implement LWG 2842 - optional(U&&) needs to SFINAE on decay_t

2017-03-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar 30 14:43:50 2017
New Revision: 299100

URL: http://llvm.org/viewvc/llvm-project?rev=299100=rev
Log:
Implement LWG 2842 - optional(U&&) needs to SFINAE on decay_t

Modified:
libcxx/trunk/include/optional

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=299100=299099=299100=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Thu Mar 30 14:43:50 2017
@@ -531,7 +531,7 @@ private:
 };
 template 
 using _CheckOptionalArgsCtor = conditional_t<
-!is_same_v &&
+!is_same_v, in_place_t> &&
 !is_same_v, optional>,
 _CheckOptionalArgsConstructor,
 __check_tuple_constructor_fail

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp?rev=299100=299099=299100=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
 Thu Mar 30 14:43:50 2017
@@ -35,6 +35,11 @@ struct ExplicitThrow
 constexpr explicit ExplicitThrow(int x) { if (x != -1) TEST_THROW(6);}
 };
 
+struct ImplicitAny {
+  template 
+  constexpr ImplicitAny(U&&) {}
+};
+
 
 template 
 constexpr bool implicit_conversion(optional&& opt, const From& v)
@@ -79,6 +84,15 @@ void test_implicit()
 using T = TestTypes::TestType;
 assert(implicit_conversion(3, T(3)));
 }
+  {
+using O = optional;
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+
+  }
 #ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try {

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=299100=299099=299100=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Mar 30 14:43:50 2017
@@ -460,7 +460,7 @@
http://wg21.link/LWG2835;>2835LWG 2536 
seems to misspecify tgmath.hKona
http://wg21.link/LWG2837;>2837gcd and lcm 
should support a wider range of input 
valuesKonaComplete
http://wg21.link/LWG2838;>2838is_literal_type specification 
needs a little cleanupKonaComplete
-   http://wg21.link/LWG2842;>2842in_place_t 
check for optional::optional(U) should decay 
UKona
+   http://wg21.link/LWG2842;>2842in_place_t 
check for optional::optional(U) should decay 
UKonaComplete
http://wg21.link/LWG2850;>2850std::function move constructor 
does unnecessary workKona
http://wg21.link/LWG2853;>2853Possible 
inconsistency in specification of erase in 
[vector.modifiers]Kona
http://wg21.link/LWG2855;>2855std::throw_with_nested("string_literal")Kona


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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:4363
+} else if (AllocAlignParam && TargetDecl->hasAttr())
+  EmitAlignmentAssumption(Ret.getScalarVal(), AllocAlignParam);
   }

rjmccall wrote:
> Your old code was fine, you just needed to get the value with 
> CallArgs[index].second.getScalarVal() instead of IRCallArgs[index].
Please add the test cases I suggested here.  You might have to make part of the 
test target-specific.


https://reviews.llvm.org/D29599



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


[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/CoroutineBuilder.h:53
+assert(this->IsValid && "coroutine already invalid");
+this->IsValid = makeReturnObject() && makeParamMoves();
+if (this->IsValid && !IsPromiseDependentType)

GorNishanov wrote:
> makeReturnObject is built as $promise.get_return_object() should it be put 
> into buildDependentStatements?
> 
I don't think so because the statement is required, so we can build it right 
away and transform it later. The "dependent" statements are ones built 
different depending on the results of name lookup.


https://reviews.llvm.org/D31487



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


[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93510.
EricWF added a comment.

- Remove incorrect comments.


https://reviews.llvm.org/D31487

Files:
  include/clang/AST/StmtCXX.h
  lib/AST/StmtCXX.cpp
  lib/Sema/CoroutineBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -534,6 +534,12 @@
   co_await a;
 }
 
+template 
+coro bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+template coro bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
+
 struct bad_promise_7 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -544,25 +550,38 @@
   co_await a;
 }
 
+template 
+coro no_unhandled_exception_dependent(T) { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+template coro no_unhandled_exception_dependent(bad_promise_7); // expected-note {{in instantiation}}
+
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
-  void unhandled_exception() const;// expected-note {{candidate}}
-  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note 2 {{made unavailable}}
+  void unhandled_exception() const;// expected-note 2 {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note 2 {{requires 1 argument, but 0 were provided}}
 };
 coro calls_unhandled_exception() {
   // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
   // FIXME: also warn about private 'return_void' here. Even though building
   // the call to unhandled_exception has already failed.
   co_await a;
 }
 
+template 
+coro calls_unhandled_exception_dependent(T) {
+  // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
+  co_await a;
+}
+template coro calls_unhandled_exception_dependent(bad_promise_8); // expected-note {{in instantiation}}
+
 struct bad_promise_9 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -652,3 +671,26 @@
 extern "C" int f(promise_on_alloc_failure_tag) {
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
+
+struct bad_promise_11 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+
+private:
+  static coro get_return_object_on_allocation_failure(); // expected-note 2 {{declared private here}}
+};
+coro private_alloc_failure_handler() {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+
+template 
+coro dependent_private_alloc_failure_handler(T) {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+template coro dependent_private_alloc_failure_handler(bad_promise_11);
+// expected-note@-1 {{requested here}}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 
+#include "CoroutineBuilder.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
@@ -6847,13 +6848,9 @@
 template
 StmtResult
 TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // The coroutine body should be re-formed by the caller if necessary.
-  // FIXME: The coroutine body is always rebuilt by ActOnFinishFunctionBody
-  CoroutineBodyStmt::CtorArgs BodyArgs;
-
   auto *ScopeInfo = SemaRef.getCurFunction();
   auto *FD = cast(SemaRef.CurContext);
-  assert(ScopeInfo && !ScopeInfo->CoroutinePromise &&
+  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
  ScopeInfo->NeedsCoroutineSuspends &&
  ScopeInfo->CoroutineSuspends.first == nullptr &&
  ScopeInfo->CoroutineSuspends.second == nullptr &&
@@ -6865,17 +6862,11 @@
 
   // The new CoroutinePromise object needs to be built and put into the current
   // FunctionScopeInfo before any transformations or rebuilding occurs.
-  auto *Promise = S->getPromiseDecl();
-  auto *NewPromise = 

[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93519.
mgehre added a comment.

only check C++ code; only match operators that can have alternative 
representations


https://reviews.llvm.org/D31308

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OperatorsRepresentationCheck.cpp
  clang-tidy/readability/OperatorsRepresentationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-operators-representation.rst
  test/clang-tidy/readability-operators-representation.cpp

Index: test/clang-tidy/readability-operators-representation.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-operators-representation.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s readability-operators-representation %t
+
+void f() {
+  bool a, b, c;
+
+  c = a and b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'and' is an alternative token spelling; consider using '&&' [readability-operators-representation]
+  // CHECK-FIXES: c = a && b;
+  c and_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'and_eq' is an alternative
+  // CHECK-FIXES: c &= a;
+  c = a bitand b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'bitand' is an alternative
+  // CHECK-FIXES: c = a & b;
+  c = a bitor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'bitor' is an alternative
+  // CHECK-FIXES: c = a | b;
+  c = compl a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'compl' is an alternative
+  // CHECK-FIXES: c = ~ a;
+  c = not a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'not' is an alternative
+  // CHECK-FIXES: c = ! a;
+  c = a not_eq b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'not_eq' is an alternative
+  // CHECK-FIXES: c = a != b;
+  c = a or b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'or' is an alternative
+  // CHECK-FIXES: c = a || b;
+  c or_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'or_eq' is an alternative
+  // CHECK-FIXES: c |= a;
+  c = a xor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'xor' is an alternative
+  // CHECK-FIXES: c = a ^ b;
+  c xor_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'xor_eq' is an alternative
+  // CHECK-FIXES: c ^= a;
+
+#define M a xor
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 'xor' is an alternative
+  // CHECK-FIXES: #define M a ^
+  c = M b;
+
+  int arr[2];
+  for (int i : arr) // OK (Here is an implicit != operator.)
+;
+
+  auto ptr =  // OK
+  auto i = -1;   // OK
+  c = a && b;// OK
+  c &= a;// OK
+  c = !a;// OK
+}
+
+struct S {
+  friend S  and(const S &, const S &);
+};
+
+int g() {
+  S s1, s2;
+  S s3 = s1 and s2; // OK
+}
Index: docs/clang-tidy/checks/readability-operators-representation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-operators-representation.rst
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - readability-operators-representation
+
+readability-operators-representation
+
+
+Flags (and replaces) the alternative tokens for binary and unary operators by
+their primary ones for consistency.
+
+=== ===
+Primary Alternative
+=== ===
+``&&``  ``and``
+``&=``  ``and_eq``
+``&``   ``bitand``
+``|``   ``bitor``
+``~``   ``compl``
+``!``   ``not``
+``!=``  ``not_eq``
+``||``  ``or``
+``|=``  ``or_eq``
+``^``   ``xor``
+``^=``  ``xor_eq``
+=== ===
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -145,6 +145,7 @@
readability-misleading-indentation
readability-misplaced-array-index
readability-named-parameter
+   readability-operators-representation
readability-non-const-parameter
readability-redundant-control-flow
readability-redundant-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -72,6 +72,12 @@
 
   Finds misleading indentation where braces should be introduced or the code should be reformatted.
 
+- New `readability-operators-representation
+  `_ check
+
+  Flags (and replaces) the alternative tokens for binary and unary operators,
+  such as ``not`` (for ``!``) and ``or`` (for ``||``).
+
 - Added `ParameterThreshold` to `readability-function-size`.
 
   Finds functions that have more then `ParameterThreshold` parameters and emits a warning.
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -24,6 +24,7 @@
 #include "MisplacedArrayIndexCheck.h"
 #include 

Re: r298913 - Added `applyAtomicChanges` function.

2017-03-30 Thread Adrian Prantl via cfe-commits
Note that the green dragon bot doesn't use local submodule visibility, so every 
#include pulls in the entire clang module that header belongs to. Does this 
explain what you are seeing? (You should be able to reproduce with cmake 
-DLLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY=0)

-- adrian

> On Mar 30, 2017, at 11:44 AM, Juergen Ributzka  wrote:
> 
> [+ Adrian]
> 
> Adrian knows more about the bot setup.
> 
> On Wed, Mar 29, 2017 at 8:04 AM, Eric Liu  > wrote:
> Hi Juergen, thanks for taking care of this, but I'm wondering if this build 
> bot is using a different set of build rules? The error message says 
> "Clang_Tooling -> Clang_Format -> Clang_Tooling"; however, the actual 
> dependency is clangToolingRefactor -> clangFormat -> clangToolingCore, which 
> seems fine for me. I guess the module build uses build rules with lower 
> granularity. 
> 
> - Eric
> 
> On Wed, Mar 29, 2017 at 2:39 AM Juergen Ributzka  > wrote:
> I reverted the commit in r298967. Please fix the cyclic dependency issue 
> found here:
> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-modulesRDA_build/4776/ 
> 
> 
> Cheers,
> Juergen
> 
> On Tue, Mar 28, 2017 at 6:05 AM, Eric Liu via cfe-commits 
> > wrote:
> Author: ioeric
> Date: Tue Mar 28 08:05:32 2017
> New Revision: 298913
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=298913=rev 
> 
> Log:
> Added `applyAtomicChanges` function.
> 
> Summary: ... which applies a set of `AtomicChange`s on code.
> 
> Reviewers: klimek, djasper
> 
> Reviewed By: djasper
> 
> Subscribers: cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D30777 
> 
> 
> Modified:
> cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
> cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
> 
> Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=298913=298912=298913=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
> +++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar 28 
> 08:05:32 2017
> @@ -16,6 +16,7 @@
>  #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
> 
>  #include "clang/Basic/SourceManager.h"
> +#include "clang/Format/Format.h"
>  #include "clang/Tooling/Core/Replacement.h"
>  #include "llvm/ADT/StringRef.h"
>  #include "llvm/Support/Error.h"
> @@ -123,6 +124,39 @@ private:
>tooling::Replacements Replaces;
>  };
> 
> +// Defines specs for applying changes.
> +struct ApplyChangesSpec {
> +  // If true, cleans up redundant/erroneous code around changed code with
> +  // clang-format's cleanup functionality, e.g. redundant commas around 
> deleted
> +  // parameter or empty namespaces introduced by deletions.
> +  bool Cleanup = true;
> +
> +  format::FormatStyle Style = format::getNoStyle();
> +
> +  // Options for selectively formatting changes with clang-format:
> +  // kAll: Format all changed lines.
> +  // kNone: Don't format anything.
> +  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
> +  enum FormatOption { kAll, kNone, kViolations };
> +
> +  FormatOption Format = kNone;
> +};
> +
> +/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
> +///
> +/// This completely ignores the file path in each change and replaces them 
> with
> +/// \p FilePath, i.e. callers are responsible for ensuring all changes are 
> for
> +/// the same file.
> +///
> +/// \returns The changed code if all changes are applied successfully;
> +/// otherwise, an llvm::Error carrying llvm::StringError is returned (the 
> Error
> +/// message can be converted to string with `llvm::toString()` and the
> +/// error_code should be ignored).
> +llvm::Expected
> +applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
> +   llvm::ArrayRef Changes,
> +   const ApplyChangesSpec );
> +
>  } // end namespace tooling
>  } // end namespace clang
> 
> 
> Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=298913=298912=298913=diff
>  
> 
> ==
> --- 

[PATCH] D29904: [OpenMP] Prevent emission of exception handling code when using OpenMP to offload to NVIDIA devices.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93513.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Clean-up test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29904

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/target_parallel_no_exceptions.cpp


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,27 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CHK-EXCEPTION %s
+
+int inc(int a) {
+  return a + 1;
+}
+
+int test_increment() {
+  int a;
+#pragma omp target
+  {
+#pragma omp parallel
+{
+  a = inc(a);
+}
+  }
+  return a;
+}
+
+int main() {
+  return test_increment();
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLESTART__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLEEND__ openmp-nvptx64-nvidia-cuda
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2224,6 +2224,13 @@
 break;
   }
 }
+
+// Set the flag to prevent the implementation from emitting device 
exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}
   }
 
   // Get the OpenMP target triples if any.


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,27 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CHK-EXCEPTION %s
+
+int inc(int a) {
+  return a + 1;
+}
+
+int test_increment() {
+  int a;
+#pragma omp target
+  {
+#pragma omp parallel
+{
+  a = inc(a);
+}
+  }
+  return a;
+}
+
+int main() {
+  return test_increment();
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLESTART__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLEEND__ openmp-nvptx64-nvidia-cuda
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2224,6 +2224,13 @@
 break;
   }
 }
+
+// Set the flag to prevent the implementation from emitting device exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}
   }
 
   // Get the OpenMP target triples if any.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r298913 - Added `applyAtomicChanges` function.

2017-03-30 Thread Juergen Ributzka via cfe-commits
[+ Adrian]

Adrian knows more about the bot setup.

On Wed, Mar 29, 2017 at 8:04 AM, Eric Liu  wrote:

> Hi Juergen, thanks for taking care of this, but I'm wondering if this
> build bot is using a different set of build rules? The error message says 
> "Clang_Tooling
> -> Clang_Format -> Clang_Tooling"; however, the actual dependency is
> clangToolingRefactor -> clangFormat -> clangToolingCore, which seems fine
> for me. I guess the module build uses build rules with lower granularity.
>
> - Eric
>
> On Wed, Mar 29, 2017 at 2:39 AM Juergen Ributzka 
> wrote:
>
>> I reverted the commit in r298967. Please fix the cyclic dependency issue
>> found here:
>> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-
>> modulesRDA_build/4776/
>>
>> Cheers,
>> Juergen
>>
>> On Tue, Mar 28, 2017 at 6:05 AM, Eric Liu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: ioeric
>> Date: Tue Mar 28 08:05:32 2017
>> New Revision: 298913
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298913=rev
>> Log:
>> Added `applyAtomicChanges` function.
>>
>> Summary: ... which applies a set of `AtomicChange`s on code.
>>
>> Reviewers: klimek, djasper
>>
>> Reviewed By: djasper
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D30777
>>
>> Modified:
>> cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
>> cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
>> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>>
>> Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
>> clang/Tooling/Refactoring/AtomicChange.h?rev=298913=
>> 298912=298913=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
>> +++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar
>> 28 08:05:32 2017
>> @@ -16,6 +16,7 @@
>>  #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
>>
>>  #include "clang/Basic/SourceManager.h"
>> +#include "clang/Format/Format.h"
>>  #include "clang/Tooling/Core/Replacement.h"
>>  #include "llvm/ADT/StringRef.h"
>>  #include "llvm/Support/Error.h"
>> @@ -123,6 +124,39 @@ private:
>>tooling::Replacements Replaces;
>>  };
>>
>> +// Defines specs for applying changes.
>> +struct ApplyChangesSpec {
>> +  // If true, cleans up redundant/erroneous code around changed code with
>> +  // clang-format's cleanup functionality, e.g. redundant commas around
>> deleted
>> +  // parameter or empty namespaces introduced by deletions.
>> +  bool Cleanup = true;
>> +
>> +  format::FormatStyle Style = format::getNoStyle();
>> +
>> +  // Options for selectively formatting changes with clang-format:
>> +  // kAll: Format all changed lines.
>> +  // kNone: Don't format anything.
>> +  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
>> +  enum FormatOption { kAll, kNone, kViolations };
>> +
>> +  FormatOption Format = kNone;
>> +};
>> +
>> +/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
>> +///
>> +/// This completely ignores the file path in each change and replaces
>> them with
>> +/// \p FilePath, i.e. callers are responsible for ensuring all changes
>> are for
>> +/// the same file.
>> +///
>> +/// \returns The changed code if all changes are applied successfully;
>> +/// otherwise, an llvm::Error carrying llvm::StringError is returned
>> (the Error
>> +/// message can be converted to string with `llvm::toString()` and the
>> +/// error_code should be ignored).
>> +llvm::Expected
>> +applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
>> +   llvm::ArrayRef Changes,
>> +   const ApplyChangesSpec );
>> +
>>  } // end namespace tooling
>>  } // end namespace clang
>>
>>
>> Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
>> Refactoring/AtomicChange.cpp?rev=298913=298912=298913=diff
>> 
>> ==
>> --- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
>> +++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Tue Mar 28
>> 08:05:32 2017
>> @@ -84,6 +84,116 @@ template <> struct MappingTraits>
>>  namespace clang {
>>  namespace tooling {
>> +namespace {
>> +
>> +// Returns true if there is any line that violates \p ColumnLimit in
>> range
>> +// [Start, End].
>> +bool violatesColumnLimit(llvm::StringRef Code, unsigned ColumnLimit,
>> + unsigned Start, unsigned End) {
>> +  auto StartPos = Code.rfind('\n', Start);
>> +  StartPos = (StartPos == llvm::StringRef::npos) ? 0 : StartPos + 1;
>> +
>> +  auto EndPos = Code.find("\n", End);
>> +  if (EndPos == llvm::StringRef::npos)
>> +EndPos = Code.size();
>> +
>> +  llvm::SmallVector Lines;
>> +  

[PATCH] D31167: Use FPContractModeKind universally

2017-03-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.h:217
   /// Adjust BinaryOperator::FPFeatures to match the bit-field size of this.
-  unsigned fp_contract : 1;
+  LangOptions::FPContractModeKind fp_contract : 2;
 };

anemet wrote:
> rnk wrote:
> > Please do not use bitfields with enum types, it's a good way to break the 
> > build on Windows. This change triggered this clang-cl warning:
> > ```
> > C:\src\llvm-project\clang\include\clang/Basic/LangOptions.h(208,17):  
> > warning: implicit truncation from 'clang::LangOptions::FPContractModeKind' 
> > to bit-field changes value from 2 to -2 [-Wbitfield-constant-conversion]
> > fp_contract = LangOptions::FPC_Fast;
> > ^ ~
> > ```
> Noted and thanks for the fix!  Unfortunately the warning wasn't showing up on 
> my host.  I'll take a look why.
Clang doesn't emit that warning on Posix because it wouldn't be true. The 
implicit underlying type of the enum on non-Windows is 'unsigned', not 'int'. 
We could issue a portability warning, but we wouldn't be able to turn it on by 
default because many users don't care about Windows portability.

Anyway, sorry about the bother. This is one of the reasons we just use 
'unsigned' for all our bitfields. =/


Repository:
  rL LLVM

https://reviews.llvm.org/D31167



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


[PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked an inline comment as done.
mgehre added a comment.

Friendly ping


https://reviews.llvm.org/D15031



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


[PATCH] D24892: [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93511.
mgehre added a comment.

Put 'u' and 'l' on integer literals


https://reviews.llvm.org/D24892

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  
test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp
@@ -0,0 +1,40 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -config="{CheckOptions: [{key: "cppcoreguidelines-pro-type-member-init.LiteralInitializers", value: 1}]}" -- -std=c++11
+
+struct T {
+  int i;
+};
+
+struct S {
+  bool b;
+  // CHECK-FIXES: bool b = false;
+  char c;
+  // CHECK-FIXES: char c = 0;
+  signed char sc;
+  // CHECK-FIXES: signed char sc = 0;
+  unsigned char uc;
+  // CHECK-FIXES: unsigned char uc = 0u;
+  int i;
+  // CHECK-FIXES: int i = 0;
+  unsigned u;
+  // CHECK-FIXES: unsigned u = 0u;
+  long l;
+  // CHECK-FIXES: long l = 0l;
+  unsigned long ul;
+  // CHECK-FIXES: unsigned long ul = 0ul;
+  long long ll;
+  // CHECK-FIXES: long long ll = 0ll;
+  unsigned long long ull;
+  // CHECK-FIXES: unsigned long long ull = 0ull;
+  float f;
+  // CHECK-FIXES: float f = 0.0f;
+  double d;
+  // CHECK-FIXES: double d = 0.0;
+  long double ld;
+  // CHECK-FIXES: double ld = 0.0l;
+  int *ptr;
+  // CHECK-FIXES: int *ptr = nullptr;
+  T t;
+  // CHECK-FIXES: T t{};
+  S() {};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields:
+};
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
@@ -33,6 +33,10 @@
zero-initialized during construction. For performance critical code, it may
be important to not initialize fixed-size array members. Default is `0`.
 
+.. option:: LiteralInitializers
+   If set to non-zero, the check will provide fix-its with literal initializers
+   (``int i = 0;``) instead of curly braces (``int i{};``).
+
 This rule is part of the "Type safety" profile of the C++ Core
 Guidelines, corresponding to rule Type.6. See
 https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-memberinit.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -67,6 +67,10 @@
 
   Allow custom memory management functions to be considered as well.
 
+- Added `LiteralInitializers` option to `cppcoreguidelines-pro-type-member-init`
+   If set to true, the check will provide fix-its with literal initializers
+   (``int i = 0;``) instead of curly braces (``int i{};``).
+
 - New `readability-misleading-indentation
   `_ check
 
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -65,6 +65,9 @@
 
   // Whether arrays need to be initialized or not. Default is false.
   bool IgnoreArrays;
+  // Whether fix-its for initializers of fundamental type use literals. Only
+  // effective in C++11 mode. Default is false.
+  bool LiteralInitializers;
 };
 
 } // namespace cppcoreguidelines
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -255,7 +255,8 @@
 ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreArrays(Options.get("IgnoreArrays", false)) {}
+  IgnoreArrays(Options.get("IgnoreArrays", false)),
+  LiteralInitializers(Options.get("LiteralInitializers", false)) {}
 
 void ProTypeMemberInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
@@ -319,6 +320,7 @@
 
 void ProTypeMemberInitCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
+  Options.store(Opts, "LiteralInitializers", LiteralInitializers);
 }
 
 // FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
@@ -343,6 +345,56 @@
   return isIncompleteOrZeroLengthArrayType(Context, Type);
 }
 
+static const char *getInitializer(QualType type, bool 

[PATCH] D31491: [XRay][clang] Fix the -fxray-instruction-threshold flag processing

2017-03-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: test/CodeGen/xray-instruction-threshold.cpp:11
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {

Any reason to use -DAG on the decls? The IR should be in source order, with the 
attributes always at the end. The attribute sets need -DAG, of course.


https://reviews.llvm.org/D31491



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


r299094 - Correcting a typo; NFC.

2017-03-30 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Mar 30 13:11:20 2017
New Revision: 299094

URL: http://llvm.org/viewvc/llvm-project?rev=299094=rev
Log:
Correcting a typo; NFC.

Modified:
cfe/trunk/test/Analysis/simple-stream-checks.c

Modified: cfe/trunk/test/Analysis/simple-stream-checks.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/simple-stream-checks.c?rev=299094=299093=299094=diff
==
--- cfe/trunk/test/Analysis/simple-stream-checks.c (original)
+++ cfe/trunk/test/Analysis/simple-stream-checks.c Thu Mar 30 13:11:20 2017
@@ -65,7 +65,7 @@ void SymbolEscapedThroughFunctionCall()
 }
 
 FILE *GlobalF;
-void SymbolEscapedThroughAssignmentToGloabl() {
+void SymbolEscapedThroughAssignmentToGlobal() {
   FILE *F = fopen("myfile.txt", "w");
   GlobalF = F;
   return; // no warning


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


[PATCH] D31502: [libc++abi] Delete config.h

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

Thanks. I'm surprised this wasn't done earlier.


https://reviews.llvm.org/D31502



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


[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93508.
EricWF added a comment.

- Fix insane definition of `hasDependentPromiseType()`


https://reviews.llvm.org/D31487

Files:
  include/clang/AST/StmtCXX.h
  lib/AST/StmtCXX.cpp
  lib/Sema/CoroutineBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -534,6 +534,12 @@
   co_await a;
 }
 
+template 
+coro bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+template coro bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
+
 struct bad_promise_7 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -544,25 +550,38 @@
   co_await a;
 }
 
+template 
+coro no_unhandled_exception_dependent(T) { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+template coro no_unhandled_exception_dependent(bad_promise_7); // expected-note {{in instantiation}}
+
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
-  void unhandled_exception() const;// expected-note {{candidate}}
-  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note 2 {{made unavailable}}
+  void unhandled_exception() const;// expected-note 2 {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note 2 {{requires 1 argument, but 0 were provided}}
 };
 coro calls_unhandled_exception() {
   // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
   // FIXME: also warn about private 'return_void' here. Even though building
   // the call to unhandled_exception has already failed.
   co_await a;
 }
 
+template 
+coro calls_unhandled_exception_dependent(T) {
+  // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
+  co_await a;
+}
+template coro calls_unhandled_exception_dependent(bad_promise_8); // expected-note {{in instantiation}}
+
 struct bad_promise_9 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -652,3 +671,26 @@
 extern "C" int f(promise_on_alloc_failure_tag) {
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
+
+struct bad_promise_11 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+
+private:
+  static coro get_return_object_on_allocation_failure(); // expected-note 2 {{declared private here}}
+};
+coro private_alloc_failure_handler() {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+
+template 
+coro dependent_private_alloc_failure_handler(T) {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+template coro dependent_private_alloc_failure_handler(bad_promise_11);
+// expected-note@-1 {{requested here}}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 
+#include "CoroutineBuilder.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
@@ -6849,11 +6850,10 @@
 TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
   // The coroutine body should be re-formed by the caller if necessary.
   // FIXME: The coroutine body is always rebuilt by ActOnFinishFunctionBody
-  CoroutineBodyStmt::CtorArgs BodyArgs;
 
   auto *ScopeInfo = SemaRef.getCurFunction();
   auto *FD = cast(SemaRef.CurContext);
-  assert(ScopeInfo && !ScopeInfo->CoroutinePromise &&
+  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
  ScopeInfo->NeedsCoroutineSuspends &&
  ScopeInfo->CoroutineSuspends.first == nullptr &&
  ScopeInfo->CoroutineSuspends.second == nullptr &&
@@ -6865,17 +6865,11 @@
 
   // The new CoroutinePromise object needs to be built and put into the current
   // FunctionScopeInfo before any transformations or rebuilding occurs.
-  auto *Promise = S->getPromiseDecl();
-  auto *NewPromise = 

[PATCH] D31441: [clang-format] fix crash in NamespaceEndCommentsFixer (PR32438)

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93507.
mgehre added a comment.

Updated for comments


https://reviews.llvm.org/D31441

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -582,6 +582,21 @@
 "} // namespace\n"
 "}"));
 }
+
+TEST_F(NamespaceEndCommentsFixerTest, HandlesInlineAtEndOfLine_PR32438) {
+  EXPECT_EQ("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n",
+fixNamespaceEndComments("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n"));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -133,7 +133,7 @@
 // Detect "(inline)? namespace" in the beginning of a line.
 if (NamespaceTok->is(tok::kw_inline))
   NamespaceTok = NamespaceTok->getNextNonComment();
-if (NamespaceTok->isNot(tok::kw_namespace))
+if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
   continue;
 FormatToken *RBraceTok = EndLine->First;
 if (RBraceTok->Finalized)


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -582,6 +582,21 @@
 "} // namespace\n"
 "}"));
 }
+
+TEST_F(NamespaceEndCommentsFixerTest, HandlesInlineAtEndOfLine_PR32438) {
+  EXPECT_EQ("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n",
+fixNamespaceEndComments("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n"));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -133,7 +133,7 @@
 // Detect "(inline)? namespace" in the beginning of a line.
 if (NamespaceTok->is(tok::kw_inline))
   NamespaceTok = NamespaceTok->getNextNonComment();
-if (NamespaceTok->isNot(tok::kw_namespace))
+if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
   continue;
 FormatToken *RBraceTok = EndLine->First;
 if (RBraceTok->Finalized)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-03-30 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 93503.
teemperor added a comment.

- Remove the mysterious unicode-character at the start of CloneDetection.cpp
- Fixed formatting of the comment in CloneDetectionTest.cpp
- Fixed comment in StmtSequence::contains that was still talking about checking 
for translation units even though we compared declarations.

I think this is everything from my side for now :)


https://reviews.llvm.org/D23418

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  unittests/Analysis/CMakeLists.txt
  unittests/Analysis/CloneDetectionTest.cpp

Index: unittests/Analysis/CloneDetectionTest.cpp
===
--- /dev/null
+++ unittests/Analysis/CloneDetectionTest.cpp
@@ -0,0 +1,110 @@
+//===- unittests/Analysis/CloneDetectionTest.cpp - Clone detection tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Analysis/CloneDetection.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace analysis {
+namespace {
+
+class CloneDetectionVisitor
+: public RecursiveASTVisitor {
+
+  CloneDetector 
+
+public:
+  explicit CloneDetectionVisitor(CloneDetector ) : Detector(D) {}
+
+  bool VisitFunctionDecl(FunctionDecl *D) {
+Detector.analyzeCodeBody(D);
+return true;
+  }
+};
+
+/// Example constraint for testing purposes.
+/// Filters out all statements that are in a function which name starts with
+/// "bar".
+class NoBarFunctionConstraint {
+public:
+  void constrain(std::vector ) {
+CloneConstraint::splitCloneGroups(
+CloneGroups, [](const StmtSequence , const StmtSequence ) {
+  // Check if one of the sequences is in a function which name starts
+  // with "bar".
+  for (const StmtSequence  : {A, B}) {
+if (const auto *D =
+dyn_cast(Arg.getContainingDecl())) {
+  if (D->getNameAsString().find("bar") == 0)
+return false;
+}
+  }
+  return true;
+});
+  }
+};
+
+TEST(CloneDetector, NoPostOrderTraversal) {
+  auto ASTUnit =
+  clang::tooling::buildASTFromCode("void foo1(int ) { a1++; }\n"
+   "void foo2(int ) { a2++; }\n"
+   "void bar1(int ) { a3++; }\n"
+   "void bar2(int ) { a4++; }\n");
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+
+  CloneDetector Detector;
+  // Push all the function bodies into the detector.
+  CloneDetectionVisitor Visitor(Detector);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  // Find clones with the usual settings, but but we want to filter out
+  // all statements from functions which names start with "bar".
+  std::vector CloneGroups;
+  Detector.findClones(CloneGroups, NoBarFunctionConstraint(),
+  RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 2u);
+
+  for (auto  : CloneGroups.front()) {
+const auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// Check that no function name starting with "bar" is in the results...
+ASSERT_TRUE(ND->getNameAsString().find("bar") != 0);
+  }
+
+  // Retry above's example without the filter...
+  CloneGroups.clear();
+
+  Detector.findClones(CloneGroups, RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 4u);
+
+  // Count how many functions with the bar prefix we have in the results.
+  int FoundFunctionsWithBarPrefix = 0;
+  for (auto  : CloneGroups.front()) {
+const auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// This time check that we picked up the bar functions from above
+if (ND->getNameAsString().find("bar") == 0) {
+  FoundFunctionsWithBarPrefix++;
+}
+  }
+  // We should have found the two functions bar1 and bar2.
+  ASSERT_EQ(FoundFunctionsWithBarPrefix, 2);
+}
+} // namespace
+} // namespace analysis
+} // namespace clang
Index: unittests/Analysis/CMakeLists.txt
===
--- unittests/Analysis/CMakeLists.txt
+++ unittests/Analysis/CMakeLists.txt
@@ -2,11 +2,12 @@
   Support
   )
 
-add_clang_unittest(CFGTests

[PATCH] D29644: [OpenMP] Pass -v to PTXAS if it was passed to the driver.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93502.
gtbercea added a comment.

Remove redundant check.


Repository:
  rL LLVM

https://reviews.llvm.org/D29644

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -595,3 +595,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
 
 // CHK-PTXAS: ptxas{{.*}}" "-c"
+// CHK-PTXAS-NEXT: /bin/cp
+
+/// ###
+
+/// Check that CLANG forwards the -v flag to PTXAS.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
+
+// CHK-VERBOSE: ptxas{{.*}}" "-v"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -262,6 +262,10 @@
 CmdArgs.push_back("-O0");
   }
 
+  // Pass -v to ptxas if it was passed to the driver.
+  if (Args.hasArg(options::OPT_v))
+CmdArgs.push_back("-v");
+
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch)));
   CmdArgs.push_back("--output-file");


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -595,3 +595,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
 
 // CHK-PTXAS: ptxas{{.*}}" "-c"
+// CHK-PTXAS-NEXT: /bin/cp
+
+/// ###
+
+/// Check that CLANG forwards the -v flag to PTXAS.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
+
+// CHK-VERBOSE: ptxas{{.*}}" "-v"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -262,6 +262,10 @@
 CmdArgs.push_back("-O0");
   }
 
+  // Pass -v to ptxas if it was passed to the driver.
+  if (Args.hasArg(options::OPT_v))
+CmdArgs.push_back("-v");
+
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch)));
   CmdArgs.push_back("--output-file");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29642: [OpenMP] Make OpenMP generated code for the NVIDIA device relocatable by default

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93501.
gtbercea added a comment.

Remove redundant check.


Repository:
  rL LLVM

https://reviews.llvm.org/D29642

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" 
"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
 "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" 
"-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using 
OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator

2017-03-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Is this still necessary? The bug is marked fixed


https://reviews.llvm.org/D16682



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


[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization

2017-03-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/atomic-init.cl:6
+kernel void test_atomic_initialization() {
+  a1 = 1; // expected-error {{atomic variable can only be assigned to a 
compile time constant and to variables in global adress space}}
+  atomic_int a2 = 0; // expected-error {{atomic variable can only be assigned 
to a compile time constant and to variables in global adress space}}

Anastasia wrote:
> Btw, you could keep "initialized" here by using 'select' in the diagnostic 
> message. 
Btw you still keep "assigned" in the error message. What I mean is that we 
could put "initialized" instead in this case.


https://reviews.llvm.org/D30643



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


[PATCH] D31321: [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer args

2017-03-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: test/CodeGenOpenCL/kernel-arg-info.cl:66
 // CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*"}
-// CHECK: ![[MD14]] = !{!"restrict", !"const", !"volatile", !"restrict const"}
 // ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z"}

echuraev wrote:
> Anastasia wrote:
> > Could we modify the test to check that const and volatile are added for the 
> > pointers though?
> Added test case only for volatile pointer because const is checked in the Z 
> argument of foo function.
I think it would still be nice to add an argument with explicit const because 
the current test doesn't have it explicitly.


https://reviews.llvm.org/D31321



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I can't see clearly why the alloca has to be extended to accommodate the 
address space too? Couldn't  the address space for alloca just be taken 
directly from the data layout?

In fact is seems from the LLVM review, an address space for alloca doesn't go 
into the bitcode.




Comment at: include/clang/Basic/AddressSpaces.h:28
 enum ID {
-  Offset = 0x7FFF00,
+  Default = 0,
 

Somehow I wish that opencl_private would be represented explicitly instead and 
then an absence of an address space attribute would signify the default one to 
be used. But since opencl_private has always been represented as an absence of 
an address space attribute not only in AST but in IR as well, I believe it 
might be a bigger change now. However, how does this default address space 
align with default AS we put during type parsing in processTypeAttrs 
(https://reviews.llvm.org/D13168). I think after this step we shouldn't need 
default AS explicitly any longer? 



Comment at: include/clang/Basic/AddressSpaces.h:41
+
+  target_first = Count
 };

I don't entirely understand the motivation for this. I think the idea of LangAS 
is to represent the source ASes while target ASes are reflected in the Map of 
Targets.cpp.



Comment at: lib/AST/ASTContext.cpp:9553
+  // alloca.
+  if (AS == LangAS::Default && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();

Here it seems that LangAS::Default is indeed opencl_private?



Comment at: test/Sema/invalid-assignment-constant-address-space.c:4
-#define OPENCL_CONSTANT 8388354
-int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
 

Is this test even correct? I don't think we can assume that C address spaces 
inherit the same restrictions as OpenCL. Especially that the notion of 
private/local/constant/global is an OpenCL specific thing.

I feel like Clang doesn't behave correctly for C address spaces now.

As for OpenCL I don't see why would anyone use __attribute__((address_space())) 
for constant AS. Especially that it's not part of the spec.


https://reviews.llvm.org/D31404



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


LLVM buildmaster will be updated and restarted tonight

2017-03-30 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 5 PM Pacific time
today.

Thanks

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


[PATCH] D30837: [libcxx] Support for shared_ptr<T()>

2017-03-30 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 93488.
erik.pilkington marked 2 inline comments as done.
erik.pilkington added a comment.

In this new patch, use an explicit specialization of std::allocator that 
specifically only performs a rebind. This needs to be a specialization of 
std::allocator so we can use allocator's `allocator(const allocator &)` ctor 
from `shared_ptr_pointer::__on_zero_shared_weak()`.
Thanks,
Erik


https://reviews.llvm.org/D30837

Files:
  include/memory
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp

Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -45,6 +45,13 @@
 virtual ~Foo() = default;
 };
 
+struct Result {};
+static Result theFunction() { return Result(); }
+static int resultDeletorCount;
+static void resultDeletor(Result (*pf)()) {
+  assert(pf == theFunction);
+  ++resultDeletorCount;
+}
 
 int main()
 {
@@ -65,7 +72,11 @@
 std::shared_ptr p2 = std::make_shared();
 assert(p2.get());
 }
-
+{ // https://bugs.llvm.org/show_bug.cgi?id=27566
+  std::shared_ptr x(, );
+  std::shared_ptr y(theFunction, resultDeletor);
+}
+assert(resultDeletorCount == 2);
 #if TEST_STD_VER >= 11
 nc = globalMemCounter.outstanding_new;
 {
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -3601,6 +3601,17 @@
 __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
+struct __shared_ptr_dummy_rebind_allocator_type;
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{
+template 
+struct rebind
+{
+typedef allocator<_Other> other;
+};
+};
+
 template class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
 
 template
@@ -3869,6 +3880,17 @@
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 private:
+template ::value>
+struct __shared_ptr_default_allocator
+{
+typedef allocator<_Yp> type;
+};
+
+template 
+struct __shared_ptr_default_allocator<_Yp, true>
+{
+typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type;
+};
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3884,8 +3906,7 @@
 }
 }
 
-_LIBCPP_INLINE_VISIBILITY
-void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {}
+_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}
 
 template  friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
 template  friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
@@ -3916,8 +3937,9 @@
 : __ptr_(__p)
 {
 unique_ptr<_Yp> __hold(__p);
-typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT());
 __hold.release();
 __enable_weak_this(__p, __p);
 }
@@ -3932,8 +3954,9 @@
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
 __enable_weak_this(__p, __p);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 }
@@ -3954,8 +3977,9 @@
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-typedef __shared_ptr_pointer > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>());
+typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
+typedef __shared_ptr_pointer _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
 #ifndef _LIBCPP_NO_EXCEPTIONS
 }
 catch (...)
@@ -4123,8 +4147,9 @@
 else
 #endif
 {
-typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT());
 __enable_weak_this(__r.get(), __r.get());
 }
 

[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 93499.
chh marked an inline comment as done.
chh added a comment.

Use getOrCreateFileID.


https://reviews.llvm.org/D31406

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 
___
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-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: CMakeLists.txt:188
 
+find_package(Z3 4.5)
+

delcypher wrote:
> @ddcc It is of course up to you but I recently [[ added support for using 
> `libz3` directly | added support for using `libz3` directly ]] from CMake. 
> via it's own CMake config package. You only get this if Z3 was built with 
> CMake so you might not want this restriction.  This feature has only just 
> landed though and might not be sufficient for your needs.  If you take a look 
> at Z3's example projects they are now built with this mechanism when building 
> with CMake.
> 
> If you are interested I'd be more than happy to work with you to get this 
> feature ready for your needs in upstream Z3 so you can use it here.
Sorry that URL should be https://github.com/Z3Prover/z3/pull/926


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] D31502: [libc++abi] Delete config.h

2017-03-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.

It's now completely empty, so we can remove it entirely.


https://reviews.llvm.org/D31502

Files:
  src/config.h
  src/cxa_default_handlers.cpp
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/cxa_handlers.cpp
  src/cxa_personality.cpp
  src/fallback_malloc.cpp
  test/test_exception_storage.pass.cpp
  test/test_guard.pass.cpp

Index: test/test_guard.pass.cpp
===
--- test/test_guard.pass.cpp
+++ test/test_guard.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "../src/config.h"
 #include "cxxabi.h"
 
 #include 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -11,7 +11,6 @@
 // This breaks this test when compiled in C++17. For now fix this by manually
 // re-enabling the STL functions.
 #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-#include "../src/config.h"
 
 #include 
 #include 
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -9,7 +9,6 @@
 
 #include "fallback_malloc.h"
 
-#include "config.h"
 #include <__threading_support>
 
 #include  // for malloc, calloc, free
Index: src/cxa_personality.cpp
===
--- src/cxa_personality.cpp
+++ src/cxa_personality.cpp
@@ -18,7 +18,6 @@
 #include 
 
 #include "__cxxabi_config.h"
-#include "config.h"
 #include "cxa_exception.hpp"
 #include "cxa_handlers.hpp"
 #include "private_typeinfo.h"
Index: src/cxa_handlers.cpp
===
--- src/cxa_handlers.cpp
+++ src/cxa_handlers.cpp
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h"
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -10,7 +10,6 @@
 #include "__cxxabi_config.h"
 
 #include "abort_message.h"
-#include "config.h"
 #include <__threading_support>
 
 #include 
Index: src/cxa_exception_storage.cpp
===
--- src/cxa_exception_storage.cpp
+++ src/cxa_exception_storage.cpp
@@ -13,7 +13,6 @@
 
 #include "cxa_exception.hpp"
 
-#include "config.h"
 #include <__threading_support>
 
 #if defined(_LIBCXXABI_HAS_NO_THREADS)
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -11,7 +11,6 @@
 //  
 //===--===//
 
-#include "config.h"
 #include "cxxabi.h"
 
 #include // for std::terminate
Index: src/cxa_default_handlers.cpp
===
--- src/cxa_default_handlers.cpp
+++ src/cxa_default_handlers.cpp
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h" // For __sync_swap
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
Index: src/config.h
===
--- src/config.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//===- config.h ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//
-//  Defines macros used within the libc++abi project.
-//
-//===--===//
-
-
-#ifndef LIBCXXABI_CONFIG_H
-#define LIBCXXABI_CONFIG_H
-
-#endif // LIBCXXABI_CONFIG_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r299087 - [libc++abi] Remove unistd.h include

2017-03-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Mar 30 11:27:09 2017
New Revision: 299087

URL: http://llvm.org/viewvc/llvm-project?rev=299087=rev
Log:
[libc++abi] Remove unistd.h include

This was originally there for the _POSIX_THREADS define, to detect the
presence of pthreads. That went away with the externalized threading
support, so the include can go away too.

config.h is now completely empty. A follow-up commit will remove it
entirely.

Modified:
libcxxabi/trunk/src/config.h

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=299087=299086=299087=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Thu Mar 30 11:27:09 2017
@@ -14,6 +14,4 @@
 #ifndef LIBCXXABI_CONFIG_H
 #define LIBCXXABI_CONFIG_H
 
-#include 
-
 #endif // LIBCXXABI_CONFIG_H


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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34
+
+  if (const auto *B = Result.Nodes.getNodeAs("binary")) {
+switch (B->getOpcode()) {

aaron.ballman wrote:
> mgehre wrote:
> > aaron.ballman wrote:
> > > alexfh wrote:
> > > > aaron.ballman wrote:
> > > > > I think this would make more sense lifted into an AST matcher -- 
> > > > > there are bound to be a *lot* of binary operators, so letting the 
> > > > > matcher memoize things is likely to give better performance.
> > > > Any reasons not to do this on the lexer level?
> > > Technical reasons? None.
> > > User-experience reasons? We wouldn't want this to be on by default (I 
> > > don't think) and we usually don't implement off-by-default diagnostics in 
> > > Clang. I think a case could be made for doing it in the Lexer if the 
> > > performance is really that bad with a clang-tidy check and we couldn't 
> > > improve it here, though.
> > Do I correctly understand that "doing this on lexer level" would mean to 
> > implement this as a warning directly into clang? If yes, would it be 
> > possible to generate fixits and have them possibly applied automatically 
> > (as it is the case for clang-tidy)?
> You are correct, that means implementing it as a warning in Clang. I believe 
> you can still generate those fixits from lexer-level diagnostics, but have 
> not verified it.
> 
> However, I don't think this diagnostic would be appropriate for Clang because 
> it would have to be off by default.
Actually, I was thinking about changing this clang-tidy check to analyze token 
stream somehow (probably by handling `PPCallbacks` to detect ranges that need 
to be re-lexed) instead of matching the AST. I didn't intend to propose a new 
Clang warning (but it looks like the wording was misleading).


https://reviews.llvm.org/D31308



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


[PATCH] D31501: [RFC] Integrate clang -cc1as diagnostics into DiagnosticsEngine

2017-03-30 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 created this revision.
Herald added a subscriber: aemerson.

Add initial support for printing assembly diagnostics using the
DiagnosticsEngine infrastructure.  Add support for -w (no warnings) and
-Werror (warnings are errors) and print a summary with the number of
errors and warnings. -fcolor-diagnostics handling is implemented as
well.

I am looking for feedback on the overall approach and suggestions for a
way to split it up into manageable pieces (if necessary).

---

The approach is to teach DiagnosticsEngine and underlying classes to
emit diagnostics using llvm::SMLocs.  Converting from llvm::SMLoc to
clang::SourceLocation (and the associated SourceManager and FileManager)
is quite infeasible.  With these changes in place, it will be relatively
easy to convert inline assembly diagnostics to this infrastructure as
well.

Unfortunately, there is still quite a lot of code duplication which I
hope to factor out (or leave as FIXMEs).  The plan is to leave the
emit*() functions as they are in this patch, but factor common bits into
private methods. Some of the diagnostics options handling has already
been factored out.

Currently missing is support for ranges and hits, but the assembly
diagnostics don't seem to generate many of those anyway.

Some examples with test.s:
.thumb

ADD r0, r0, #0xF001
LDM r0, {r1, r0}

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xF001
^

test.s:3:14: warning: register list not in ascending order

  LDM r0, {r1, r0}
   ^

1 warning and 1 error generated.

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s -Werror

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xF001
^

test.s:3:14: error: register list not in ascending order

  LDM r0, {r1, r0}
   ^

2 errors generated.

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s -w

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xF001
^

1 error generated.


https://reviews.llvm.org/D31501

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Driver/Options.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CompilerInvocation.h
  include/clang/Frontend/DiagnosticRenderer.h
  include/clang/Frontend/TextDiagnostic.h
  lib/Driver/DriverOptions.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/DiagnosticRenderer.cpp
  lib/Frontend/TextDiagnostic.cpp
  lib/Frontend/TextDiagnosticPrinter.cpp
  tools/driver/cc1as_main.cpp

Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -14,6 +14,10 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -45,6 +49,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -209,6 +214,8 @@
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
   Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
 
+  ParseDiagnosticArgs(Diags.getDiagnosticOptions(), Args, , false, false);
+
   // Frontend Options
   if (Args.hasArg(OPT_INPUT)) {
 bool First = true;
@@ -281,6 +288,29 @@
   return Out;
 }
 
+struct DiagsHandlerContext {
+  DiagnosticsEngine 
+  const SourceMgr *SrcMgr;
+};
+
+static void AssemblerDiagsHandler(const SMDiagnostic , void *Context) {
+  auto  = *static_cast(Context);
+  unsigned DiagID;
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+DiagID = diag::err_fe_inline_asm;
+break;
+  case llvm::SourceMgr::DK_Warning:
+DiagID = diag::warn_fe_inline_asm;
+break;
+  case llvm::SourceMgr::DK_Note:
+DiagID = diag::note_fe_inline_asm;
+break;
+  }
+
+  Diags.Report(D.getSourceMgr(), D.getLoc(), DiagID) << D.getMessage();
+}
+
 static bool ExecuteAssembler(AssemblerInvocation ,
  DiagnosticsEngine ) {
   // Get the target specific parser.
@@ -306,6 +336,8 @@
   // it later.
   SrcMgr.setIncludeDirs(Opts.IncludePaths);
 
+  SrcMgr.setDiagHandler(AssemblerDiagsHandler, );
+
   std::unique_ptr MRI(TheTarget->createMCRegInfo(Opts.Triple));
   assert(MRI && "Unable to create target register info!");
 
@@ -472,7 +504,7 @@
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   TextDiagnosticPrinter *DiagClient
 = new TextDiagnosticPrinter(errs(), 

[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 93491.
erichkeane marked 3 inline comments as done.
erichkeane added a comment.

Thanks for the feedback John!


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c
  test/SemaCXX/alloc-align-attr.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4348,6 +4348,10 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal =
+  CallArgs[AA->getParamIndex() - 1].RV.getScalarVal();
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
   }
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2465,6 +2465,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -168,6 +168,16 @@
 Aligned->getSpellingListIndex());
 }
 
+static void instantiateDependentAllocAlignAttr(
+Sema , const MultiLevelTemplateArgumentList ,
+const AllocAlignAttr *Align, Decl *New) {
+  Expr *Param = IntegerLiteral::Create(
+  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext().UnsignedLongLongTy, Align->getLocation());
+  S.AddAllocAlignAttr(Align->getLocation(), New, Param,
+  Align->getSpellingListIndex());
+}
+
 static Expr *instantiateDependentFunctionAttrCondition(
 Sema , const MultiLevelTemplateArgumentList ,
 const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) {
@@ -380,6 +390,12 @@
   continue;
 }
 
+if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
+  instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New);
+  continue;
+}
+
+
 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
   instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl,
cast(New));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -218,21 +218,45 @@
std::greater());
 }
 
+/// \brief A helper function to provide Attribute Location for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   SourceLocation>::type
+getAttrLoc(const AttrInfo ) {
+  return Attr.getLocation();
+}
+static SourceLocation getAttrLoc(const clang::AttributeList ) {
+  return Attr.getLoc();
+}
+
+/// \brief A helper function to provide Attribute Name for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   const AttrInfo *>::type
+getAttrName(const AttrInfo ) {
+  return 
+}
+const IdentifierInfo *getAttrName(const clang::AttributeList ) {
+  return Attr.getName();
+}
+
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-static bool checkUInt32Argument(Sema , const AttributeList ,
-const Expr *Expr, uint32_t ,
-unsigned Idx = UINT_MAX) {
+template
+static bool checkUInt32Argument(Sema , const AttrInfo& Attr, const Expr *Expr,
+uint32_t , unsigned Idx = UINT_MAX) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
 if (Idx != UINT_MAX)
-  S.Diag(Attr.getLoc(), 

[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Thank you for finding out the root cause here!




Comment at: clang-tidy/ClangTidy.cpp:241
 
-const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+if (Path2FileID.find(FilePath) == Path2FileID.end()) {
+  const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);

Repeating lookup three times is not necessary:

  FileID  = Path2FileID[FilePath];
  if (!ID.isValid()) {
const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
  }

But even this seems to be unnecessary, since SourceManager provides a better 
API that we should have used here:

  FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);



Comment at: clang-tidy/ClangTidy.cpp:256
 
+  DenseMap Path2FileID;
   FileManager Files;

`llvm::StringMap` would be a better container, if we needed it (see the 
comment above).


https://reviews.llvm.org/D31406



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


[PATCH] D31168: Set FMF for -ffp-contract=fast

2017-03-30 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 93487.
anemet added a comment.

Also add 'contract' for CompoundAssignOperator (+= and -=).  For l-values,
these don't go through the expr-visitor in ScalarExprEmitter::Visit.  This
again piggybacks on how debug-locations are added.


https://reviews.llvm.org/D31168

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ffp-contract-fast-option.cpp


Index: test/CodeGen/ffp-contract-fast-option.cpp
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple 
-emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_1fff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_2fff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_3Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_4Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  a[0] -= b * c;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3822,6 +3822,25 @@
   }
 };
 
+/// A RAII to apply the FP features from the expression to the IRBuilder.
+struct ApplyFPFeatures : public CGBuilderTy::FastMathFlagGuard {
+  static Optional getFPFeatures(const Expr *E) {
+if (const auto *BO = dyn_cast(E))
+  return BO->getFPFeatures();
+else if (const auto *CE = dyn_cast(E))
+  return CE->getFPFeatures();
+return None;
+  }
+
+  ApplyFPFeatures(llvm::IRBuilderBase , const Expr *E)
+  : CGBuilderTy::FastMathFlagGuard(Builder) {
+if (Optional FPFeatures = getFPFeatures(E)) {
+  llvm::FastMathFlags FMF = Builder.getFastMathFlags();
+  FMF.setAllowContract(FPFeatures->allowFPContractAcrossStatement());
+  Builder.setFastMathFlags(FMF);
+}
+  }
+};
 }  // end namespace CodeGen
 }  // end namespace clang
 
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -258,6 +258,7 @@
 
   Value *Visit(Expr *E) {
 ApplyDebugLocation DL(CGF, E);
+ApplyFPFeatures FPF(Builder, E);
 return StmtVisitor::Visit(E);
   }
 
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1013,6 +1013,7 @@
 ///
 LValue CodeGenFunction::EmitLValue(const Expr *E) {
   ApplyDebugLocation DL(*this, E);
+  ApplyFPFeatures FPF(Builder, E);
   switch (E->getStmtClass()) {
   default: return EmitUnsupportedLValue(E, "l-value expression");
 


Index: test/CodeGen/ffp-contract-fast-option.cpp
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_1fff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_2fff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_3Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_4Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  a[0] -= b * c;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3822,6 +3822,25 @@
   }
 };
 
+/// A RAII to apply the FP features from the expression to the IRBuilder.
+struct ApplyFPFeatures : public CGBuilderTy::FastMathFlagGuard {
+  static Optional getFPFeatures(const Expr *E) {
+if (const auto *BO = dyn_cast(E))
+  return BO->getFPFeatures();
+else if (const auto *CE = dyn_cast(E))
+  return CE->getFPFeatures();
+return None;
+  }
+
+  ApplyFPFeatures(llvm::IRBuilderBase , const Expr *E)
+  : CGBuilderTy::FastMathFlagGuard(Builder) {
+if (Optional FPFeatures = getFPFeatures(E)) {
+  llvm::FastMathFlags FMF = 

[PATCH] D19979: [analyzer] ScopeContext - initial implementation

2017-03-30 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

What is the status of this?
Aleksei, could you upload a new patch with the context available?
(And also with a testcase added for jumps/gotos and VLA.)

You modified the malloc checker but I did not see a test for that.


https://reviews.llvm.org/D19979



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1882
+TakeNextArg = true;
   }
   } else {

salari01 wrote:
> rogfer01 wrote:
> > I wonder if you should `break;` here if validation fails like the original 
> > code did?
> The reason for removing it is that this way, all erroneous `-defsym` options 
> specified can be listed during the same invocation. This provides a better 
> user experience than tackling them one at a time, as with the original code.
Ah, I see, thanks!


https://reviews.llvm.org/D31496



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Salman Arif via Phabricator via cfe-commits
salari01 added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1882
+TakeNextArg = true;
   }
   } else {

rogfer01 wrote:
> I wonder if you should `break;` here if validation fails like the original 
> code did?
The reason for removing it is that this way, all erroneous `-defsym` options 
specified can be listed during the same invocation. This provides a better user 
experience than tackling them one at a time, as with the original code.


https://reviews.llvm.org/D31496



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1882
+TakeNextArg = true;
   }
   } else {

I wonder if you should `break;` here if validation fails like the original code 
did?


https://reviews.llvm.org/D31496



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

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



Comment at: include/clang/AST/Type.h:336-342
+  /// Get the address space value used in diagnostics.
+  unsigned getAddressSpacePrintValue() const {
+unsigned AS = getAddressSpace();
+if (AS >= LangAS::target_first)
+  return AS - LangAS::target_first;
+return AS;
+  }

yaxunl wrote:
> t-tye wrote:
> > Is this the right thing to do? This is making the CLANG named address 
> > spaces have the same numbers as the target-specific address space numbers 
> > which would seem rather confusing.
> > 
> > What do the diagnostics want to display? For example, they could display 
> > the address space as a human readable form such as "Default", 
> > "OpenCL-global", CUDA-device", "target-specific(5)", etc. To do that this 
> > function could take an iostream and a LangAS value and use << to write to 
> > the iostream.
> This function is used by diagnostics for address spaces specified by 
> `__attribute__((address_space(n)))`. There are several lit tests for that, 
> e.g. 
> 
> https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-newdelete.cpp
> https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-references.cpp
> 
> It is desirable to use the same value as specified by the attribute, 
> otherwise it may confuse the user.
I can change it to

```
  unsigned getAddressSpacePrintValue() const {
return getAddressSpace() - LangAS::target_first;
  }
```
Since the value is only used for `__attribute__((address_space(n)))`, in case 
the user specifies negative value to achieve language specific addr space, the 
diag msg will just show the same negative value they used in  
`__attribute__((address_space(n)))`


https://reviews.llvm.org/D31404



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Salman Arif via Phabricator via cfe-commits
salari01 created this revision.

Extended the integrated assembler -Wa,-defsym option to be usable with the 
Clang driver. Both options arehandled in the same way. Using -defsym when 
not assembling files shows an unused argument warning.


https://reviews.llvm.org/D31496

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/defsym.c
  test/Driver/defsym.s

Index: test/Driver/defsym.s
===
--- test/Driver/defsym.s
+++ test/Driver/defsym.s
@@ -1,37 +1,73 @@
 // RUN: %clang -### -c -integrated-as %s \
 // RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+// RUN: %clang -### -c -integrated-as %s \
+// RUN: -defsym abc=5 -defsym xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
 
 // RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
 // RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+// RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
+// RUN: -defsym abc=5 -defsym xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-UNUSED
 
 // CHECK-DEFSYM1: "-defsym"
 // CHECK-DEFSYM1: "abc=5"
 // CHECK-DEFSYM1: "-defsym"
 // CHECK-DEFSYM1: "xyz=0xa"
+// CHECK-UNUSED:  warning: argument unused during compilation: '-defsym abc=5' [-Wunused-command-line-argument]
+// CHECK-UNUSED:  warning: argument unused during compilation: '-defsym xyz=0xa' [-Wunused-command-line-argument]
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc= \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym abc= \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
 // CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc=
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
-// RUN: -Wa,-defsym,=123 \
+// RUN: -Wa,-defsym,abc \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
-// CHECK-DEFSYM-ERR2: error: defsym must be of the form: sym=value: =123
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym abc \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
+// CHECK-DEFSYM-ERR2: error: defsym must be of the form: sym=value: abc
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
-// RUN: -Wa,-defsym,abc=1a2b3c \
+// RUN: -Wa,-defsym,=123 \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR3
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym =123 \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR3
-// CHECK-DEFSYM-ERR3: error: Value is not an integer: 1a2b3c
+// CHECK-DEFSYM-ERR3: error: defsym must be of the form: sym=value: =123
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
-// RUN: -Wa,-defsym \
+// RUN: -Wa,-defsym,123 \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR4
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym 123 \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR4
+// CHECK-DEFSYM-ERR4: error: defsym must be of the form: sym=value: 123
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -Wa,-defsym,abc=1a2b3c \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR5
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym abc=1a2b3c \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR5
+// CHECK-DEFSYM-ERR5: error: Value is not an integer: 1a2b3c
+
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -Wa,-defsym \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR6
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym, \
-// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR4
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR6
+// CHECK-DEFSYM-ERR6: error: defsym must be of the form: sym=value: -defsym
 
-// CHECK-DEFSYM-ERR4: error: defsym must be of the form: sym=value: -defsym
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR7
+// CHECK-DEFSYM-ERR7: error: argument to '-defsym' is missing (expected 1 value)
\ No newline at end of file
Index: test/Driver/defsym.c
===
--- /dev/null
+++ test/Driver/defsym.c
@@ -0,0 +1,13 @@
+// RUN: not %clang -c -o /dev/null %s \
+// RUN: -defsym \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR
+// CHECK-DEFSYM-ERR: error: argument to '-defsym' is missing (expected 1 value)
+
+// RUN: %clang -c -o /dev/null %s \
+// RUN: -defsym bar=1 \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-WARN
+// CHECK-DEFSYM-WARN: warning: argument unused during compilation: '-defsym bar=1'
+
+int 

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

2017-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: CMakeLists.txt:188
 
+find_package(Z3 4.5)
+

@ddcc It is of course up to you but I recently [[ added support for using 
`libz3` directly | added support for using `libz3` directly ]] from CMake. via 
it's own CMake config package. You only get this if Z3 was built with CMake so 
you might not want this restriction.  This feature has only just landed though 
and might not be sufficient for your needs.  If you take a look at Z3's example 
projects they are now built with this mechanism when building with CMake.

If you are interested I'd be more than happy to work with you to get this 
feature ready for your needs in upstream Z3 so you can use it here.



Comment at: include/clang/Config/config.h.cmake:42
+/* Define if we have z3 and want to build it */
+#cmakedefine CLANG_ANALYZER_WITH_Z3 ${CLANG_ANALYZER_WITH_Z3}
+

Do you really want such a specific name? How about 
`CLANG_ANALYSER_HAS_SMT_SOLVER`?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:70
+public:
+  static Z3_context ZC;
+

@ddc
This decision of having a global context might come back to bite you. 
Especially if you switch to doing parallel solving in the future. This is why 
KLEE's `Z3ASTHandle` and `Z3SortHandle` store the context so it's possible to 
use different context.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:81
+
+class Z3Expr {
+  friend class Z3Model;

@ddcc 
[[ 
https://github.com/klee/klee/blob/1f13e9dbf9db2095b6612a47717c2b86e4aaba72/lib/Solver/Z3Builder.h#L20
 | In KLEE I have something similar to represent Z3Expr ]] called Z3ASTHandle 
and Z3SortHandle for doing manual reference counting. You might want to take a 
look at. I don't see you doing reference counting on sorts here so I think you 
might be leaking memory.

We also have a handy `dump()` method on `Z3ASTHandle` and `Z3SortHandle` for 
debugging.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:113
+  // Determine whether two float semantics are equivalent
+  static bool areEquivalent(const llvm::fltSemantics ,
+const llvm::fltSemantics ) {

@ddcc Of course this is fine for now but I think we really need to fix the 
APFloat API. I use it heavily myself and I've come across problems with it such 
as this one.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:160
+  return llvm::APFloat::IEEEdouble();
+case 128:
+  return llvm::APFloat::IEEEquad();

128 is actually ambiguous. It could also be `ppc_fp128`. I had the same problem 
in KLEE and for now I just assumed IEEEQuad like you have done but at the very 
least we should leave a comment here noting that this should be fixed some how.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:438
+// Logical operators
+case BO_LAnd: {
+  Z3_ast Args[] = {LHS.AST, RHS.AST};

@ddcc Isn't this repeating some of the logic in `fromBinOp()`?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:559
+  Float.toString(Chars, 0, 0);
+  AST = Z3_mk_numeral(Z3Context::ZC, Chars.c_str(), Sort);
+  break;

@ddcc I'm not convinced this is a good idea. Printing as a decimal string could 
lead to rounding errors. I think you're better of getting an APInt from the 
APFloat, constructing a bitvector constant from those bits and then using 
`Z3_mk_fpa_to_fp_bv()` to get a Z3Expr of the right sort. That was we are being 
bit-wise accurate.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:581
+  /// Construct an APFloat from a Z3Expr, given the AST representation
+  static bool toAPFloat(const Z3_sort , const Z3_ast ,
+llvm::APFloat , bool useSemantics = true) {

@ddcc Again I don't think the use of strings here is a good idea. You can do 
this in a bit-precise way by getting the bits, making an APInt from that and 
then making an APFloat from that.


https://reviews.llvm.org/D28952



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


Re: r299058 - [APInt] Remove references to integerPartWidth and integerPart outside of APFloat implentation.

2017-03-30 Thread David Majnemer via cfe-commits
On Thu, Mar 30, 2017 at 7:48 AM, Craig Topper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ctopper
> Date: Thu Mar 30 00:48:58 2017
> New Revision: 299058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299058=rev
> Log:
> [APInt] Remove references to integerPartWidth and integerPart outside of
> APFloat implentation.
>
> Turns out integerPartWidth only explicitly defines the width of the tc
> functions in the APInt class. Functions that aren't used by APInt
> implementation itself. Many places in the code base already assume APInt is
> made up of 64-bit pieces. Explicitly assuming 64-bit here doesn't make that
> situation much worse. A full audit would need to be done if it ever changes.
>
> Modified:
> cfe/trunk/lib/AST/ItaniumMangle.cpp
>
> Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ItaniumMangle.cpp?rev=299058=299057=299058=diff
> 
> ==
> --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
> +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Mar 30 00:48:58 2017
> @@ -982,9 +982,8 @@ void CXXNameMangler::mangleFloat(const l
>  unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
>
>  // Project out 4 bits starting at 'digitIndex'.
> -llvm::integerPart hexDigit
> -  = valueBits.getRawData()[digitBitIndex / llvm::integerPartWidth];
> -hexDigit >>= (digitBitIndex % llvm::integerPartWidth);
> +uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
> +hexDigit >>= (digitBitIndex % 64);
>

Would be nice to use APINT_BITS_PER_WORD to make this coupling more
explicit.


>  hexDigit &= 0xF;
>
>  // Map that over to a lowercase hex digit.
>
>
> ___
> 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] D28952: [analyzer] Add new Z3 constraint manager backend

2017-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added a comment.

In https://reviews.llvm.org/D28952#655337, @dcoughlin wrote:

> In https://reviews.llvm.org/D28952#655278, @ddcc wrote:
>
> > > - That said, I think there are still significant optimization 
> > > opportunities. It looks like when performing a query you create a new 
> > > solver for each set of constraints. My understanding (and perhaps @nlopes 
> > > can correct me here) is that these days Z3 is quite good at incremental 
> > > solves so you may be leaving a lot of performance on the table. For 
> > > example, in `getSymVal()` you create one solver to query for a satisfying 
> > > assignment and then later create a completely new one to determine 
> > > whether it is the only satisfying assignment. Since those two queries 
> > > share all of their conjuncts but one it might be faster to reuse the 
> > > first solver and add the new assertion for the second. Similarly, since 
> > > analyzer exploration is a DFS, you could imagine building up the path 
> > > condition incrementally. Z3 has solver APIs for pushing and popping 
> > > assertions. (Again, @nlopes may have a better idea of whether this would 
> > > pay off in practice.)
> >
> > I agree that the performance is the main problem, and that there are still 
> > a lot of performance optimizations available. I've separated the Z3 solver 
> > and model into separate classes, and reuse the solver now in `getSymVal()` 
> > and `checkNull()`. I looked at using the push/pop approach briefly when I 
> > started writing the solver, but since the static analyzer itself seems to 
> > have an internal worklist, I wasn't sure if the state traversal order is 
> > deterministic and predictable, so I didn't try to reuse a single solver 
> > across all program states. This is the new timing:
> >
> > Z3ConstraintManager (built-in, previous changes and solver state reuse): 
> > 202.37 sec
>
>
> The improvement here (200s vs. 250s) makes me think that some form of 
> caching/incrementalization could pay off.


KLEE has a few optimization ideas that you could consider implementing that 
certainly help in the context of symbolic execution.

- Constraint independence. This splits a set of constraints into independent 
constraints and solves them separately. This can be useful for further 
processing (e.g. increases the likely hood of a cache hit)
- "CounterExampleCache" . The naming is rather unfortunate and confusing 
(because KLEE works in terms of validity rather than satisfiability). The idea 
is to cache models for solver queries that are SAT (i.e. maintain a mapping 
from models to satisfying assignments with a sentinel to indicate when a query 
does not have a satisfying assignment) and when handling future queries
- If the new query is in the existing cache if it has a model it is SAT 
otherwise it is UNSAT.
- If the new query is a superset of an existing query in the cache then: If 
there was no model for the cached query then the super set query is also UNSAT. 
If there is a model for the original query try substituting it into the query 
(along with a deterministic values for symbolic values in the new query that 
aren't in the model) to try to quickly check if the cached model also satisfies 
the superset. If this fails then call the real solver
- If the new query is a subset of an existing query in the cache then: If there 
is a model for the cached query then that model will also satisfying the new 
query. If there is no model then the new query is UNSAT.

KLEE also does very aggressive constant folding and expression canonicalization 
to try to get more cache hits and have smaller constraints.


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] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added inline comments.



Comment at: lib/Sema/CoroutineBuilder.h:53
+assert(this->IsValid && "coroutine already invalid");
+this->IsValid = makeReturnObject() && makeParamMoves();
+if (this->IsValid && !IsPromiseDependentType)

makeReturnObject is built as $promise.get_return_object() should it be put into 
buildDependentStatements?



https://reviews.llvm.org/D31487



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


  1   2   >