Re: r334160 - Change return value of trivial visibility check.

2018-06-06 Thread Aaron Ballman via cfe-commits
On Wed, Jun 6, 2018 at 11:24 PM Richard Trieu via cfe-commits
 wrote:
>
> Author: rtrieu
> Date: Wed Jun  6 20:20:30 2018
> New Revision: 334160
>
> URL: http://llvm.org/viewvc/llvm-project?rev=334160=rev
> Log:
> Change return value of trivial visibility check.
>
> Previous, if no Decl's were checked, visibility was set to false.  Switch it
> so that in cases of no Decl's, return true.  These are the Decl's after being
> filtered.  Also remove an unreachable return statement since it is directly
> after another return statement.
>
> Added:
> cfe/trunk/test/Modules/local-visibility.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaLookup.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=334160=334159=334160=diff
> ==
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Jun  6 20:20:30 2018
> @@ -1452,6 +1452,8 @@ template
>  static bool hasVisibleDeclarationImpl(Sema , const NamedDecl *D,
>llvm::SmallVectorImpl 
> *Modules,
>Filter F) {
> +  bool HasFilteredRedecls = false;
> +
>for (auto *Redecl : D->redecls()) {
>  auto *R = cast(Redecl);
>  if (!F(R))
> @@ -1460,6 +1462,8 @@ static bool hasVisibleDeclarationImpl(Se
>  if (S.isVisible(R))
>return true;
>
> +HasFilteredRedecls = true;
> +
>  if (Modules) {
>Modules->push_back(R->getOwningModule());
>const auto  = S.Context.getModulesWithMergedDefinition(R);
> @@ -1467,7 +1471,11 @@ static bool hasVisibleDeclarationImpl(Se
>  }
>}
>
> -  return false;
> +  // Only return false if there is at least one redecl that is not filtered 
> out.
> +  if (HasFilteredRedecls)
> +return false;
> +
> +  return true;

How about:

return !HasFilteredRedecls;

instead?

>  }
>
>  bool Sema::hasVisibleExplicitSpecialization(
> @@ -1497,8 +1505,6 @@ bool Sema::hasVisibleMemberSpecializatio
>  //class definition?
>  return D->getLexicalDeclContext()->isFileContext();
>});
> -
> -  return false;
>  }
>
>  /// Determine whether a declaration is visible to name lookup.
>
> Added: cfe/trunk/test/Modules/local-visibility.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/local-visibility.cpp?rev=334160=auto
> ==
> --- cfe/trunk/test/Modules/local-visibility.cpp (added)
> +++ cfe/trunk/test/Modules/local-visibility.cpp Wed Jun  6 20:20:30 2018
> @@ -0,0 +1,15 @@
> +// RUN: %clang_cc1 -fsyntax-only -fmodules %s -verify
> +// RUN: %clang_cc1 -fsyntax-only %s -verify
> +
> +// expected-no-diagnostics
> +template 
> +struct S {
> +  template 
> +  struct Inner { };
> +
> +  template <>
> +  struct Inner<0> { };
> +};
> +
> +S::Inner<1> I1;
> +S::Inner<0> I0;
>
>
> ___
> 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] D47687: fix: [Bug 18971] - Missing -Wparentheses warning

2018-06-06 Thread Xing via Phabricator via cfe-commits
Higuoxing updated this revision to Diff 150253.
Higuoxing added a reviewer: echristo.
Higuoxing added a comment.

update with comments & remove some useless blank lines.


https://reviews.llvm.org/D47687

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/parentheses.c


Index: test/Sema/parentheses.c
===
--- test/Sema/parentheses.c
+++ test/Sema/parentheses.c
@@ -14,6 +14,11 @@
   if ((i = 4)) {}
 }
 
+#define macro_parentheses_check(x) \
+  ( \
+( (void)(x) ) \
+  )
+
 void bitwise_rel(unsigned i) {
   (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} 
\
 // expected-note{{place parentheses around the '==' 
expression to silence this warning}} \
@@ -96,6 +101,21 @@
 
   (void)(i && i || 0); // no warning.
   (void)(0 || i && i); // no warning.
+
+  macro_parentheses_check(i || i && i); // expected-warning {{'&&' within 
'||'}} \
+// expected-note {{place parentheses 
around the '&&' expression to silence this warning}}
+  
+  macro_parentheses_check(i || i && "I love LLVM"); // no warning.
+  macro_parentheses_check("I love LLVM" && i || i); // no warning.
+
+  macro_parentheses_check(i || i && "I love LLVM" || i); // expected-warning 
{{'&&' within '||'}} \
+ // expected-note 
{{place parentheses around the '&&' expression to silence this warning}}
+  
+  macro_parentheses_check(i || "I love LLVM" && i || i); // expected-warning 
{{'&&' within '||'}} \
+ // expected-note 
{{place parentheses around the '&&' expression to silence this warning}}
+  
+  macro_parentheses_check(i && i || 0); // no warning.
+  macro_parentheses_check(0 || i && i); // no warning.
 }
 
 _Bool someConditionFunc();
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -12205,6 +12205,7 @@
   if (EvaluatesAsFalse(S, RHSExpr))
 return;
   // If it's "1 && a || b" don't warn since the precedence doesn't matter.
+  // And 'assert("some message" && a || b)' don't warn as well.
   if (!EvaluatesAsTrue(S, Bop->getLHS()))
 return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, Bop);
 } else if (Bop->getOpcode() == BO_LOr) {
@@ -12227,6 +12228,7 @@
   if (EvaluatesAsFalse(S, LHSExpr))
 return;
   // If it's "a || b && 1" don't warn since the precedence doesn't matter.
+  // And 'assert(a || b && "some message")' don't warn as well.
   if (!EvaluatesAsTrue(S, Bop->getRHS()))
 return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, Bop);
 }
@@ -12309,8 +12311,11 @@
   }
 
   // Warn about arg1 || arg2 && arg3, as GCC 4.3+ does.
-  // We don't warn for 'assert(a || b && "bad")' since this is safe.
-  if (Opc == BO_LOr && !OpLoc.isMacroID()/* Don't warn in macros. */) {
+  // Here we will not skip 'logical and in logical or' checking
+  // in macros, since 'assert(a || b && "some message")' is equal
+  // to '(a || b && 1)' and 'assert("some message" && a || b)' is
+  // equal to '(1 && a || b)'.
+  if (Opc == BO_LOr) {
 DiagnoseLogicalAndInLogicalOrLHS(Self, OpLoc, LHSExpr, RHSExpr);
 DiagnoseLogicalAndInLogicalOrRHS(Self, OpLoc, LHSExpr, RHSExpr);
   }


Index: test/Sema/parentheses.c
===
--- test/Sema/parentheses.c
+++ test/Sema/parentheses.c
@@ -14,6 +14,11 @@
   if ((i = 4)) {}
 }
 
+#define macro_parentheses_check(x) \
+  ( \
+( (void)(x) ) \
+  )
+
 void bitwise_rel(unsigned i) {
   (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \
 // expected-note{{place parentheses around the '==' expression to silence this warning}} \
@@ -96,6 +101,21 @@
 
   (void)(i && i || 0); // no warning.
   (void)(0 || i && i); // no warning.
+
+  macro_parentheses_check(i || i && i); // expected-warning {{'&&' within '||'}} \
+// expected-note {{place parentheses around the '&&' expression to silence this warning}}
+  
+  macro_parentheses_check(i || i && "I love LLVM"); // no warning.
+  macro_parentheses_check("I love LLVM" && i || i); // no warning.
+
+  macro_parentheses_check(i || i && "I love LLVM" || i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+  
+  macro_parentheses_check(i || "I love LLVM" && i || i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+  
+  macro_parentheses_check(i && i || 0); // no warning.
+  macro_parentheses_check(0 || i && i); // no warning.
 }
 

[PATCH] D47864: [python] Fix most Python binding unittests on Windows

2018-06-06 Thread Ethan via Phabricator via cfe-commits
ethanhs created this revision.
ethanhs added a reviewer: bkramer.
Herald added a subscriber: cfe-commits.

This fixes all but one of the test cases for Windows. TestCDB will
take more work to debug, as CompilationDatabase seems not to work correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D47864

Files:
  bindings/python/tests/cindex/test_cdb.py
  bindings/python/tests/cindex/test_cursor.py
  bindings/python/tests/cindex/test_translation_unit.py

Index: bindings/python/tests/cindex/test_translation_unit.py
===
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -1,3 +1,4 @@
+from contextlib import contextmanager
 import gc
 import os
 import tempfile
@@ -19,15 +20,15 @@
 kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
 
 
+@contextmanager
 def save_tu(tu):
 """Convenience API to save a TranslationUnit to a file.
 
 Returns the filename it was saved to.
 """
-_, path = tempfile.mkstemp()
-tu.save(path)
-
-return path
+with tempfile.NamedTemporaryFile() as t:
+tu.save(t.name)
+yield t.name
 
 
 class TestTranslationUnit(unittest.TestCase):
@@ -125,10 +126,9 @@
 
 tu = get_tu('int foo();')
 
-path = save_tu(tu)
-self.assertTrue(os.path.exists(path))
-self.assertGreater(os.path.getsize(path), 0)
-os.unlink(path)
+with save_tu(tu) as path:
+self.assertTrue(os.path.exists(path))
+self.assertGreater(os.path.getsize(path), 0)
 
 def test_save_translation_errors(self):
 """Ensure that saving to an invalid directory raises."""
@@ -149,21 +149,18 @@
 
 tu = get_tu('int foo();')
 self.assertEqual(len(tu.diagnostics), 0)
-path = save_tu(tu)
-
-self.assertTrue(os.path.exists(path))
-self.assertGreater(os.path.getsize(path), 0)
-
-tu2 = TranslationUnit.from_ast_file(filename=path)
-self.assertEqual(len(tu2.diagnostics), 0)
+with save_tu(tu) as path:
+self.assertTrue(os.path.exists(path))
+self.assertGreater(os.path.getsize(path), 0)
 
-foo = get_cursor(tu2, 'foo')
-self.assertIsNotNone(foo)
+tu2 = TranslationUnit.from_ast_file(filename=path)
+self.assertEqual(len(tu2.diagnostics), 0)
 
-# Just in case there is an open file descriptor somewhere.
-del tu2
+foo = get_cursor(tu2, 'foo')
+self.assertIsNotNone(foo)
 
-os.unlink(path)
+# Just in case there is an open file descriptor somewhere.
+del tu2
 
 def test_index_parse(self):
 path = os.path.join(kInputsDir, 'hello.cpp')
Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -335,7 +335,7 @@
 
 self.assertEqual(enum.kind, CursorKind.ENUM_DECL)
 enum_type = enum.enum_type
-self.assertEqual(enum_type.kind, TypeKind.UINT)
+self.assertIn(enum_type.kind, (TypeKind.UINT, TypeKind.INT))
 
 def test_enum_type_cpp(self):
 tu = get_tu('enum TEST : long long { FOO=1, BAR=2 };', lang="cpp")
@@ -561,4 +561,4 @@
 # all valid manglings.
 # [c-index-test handles this by running the source through clang, emitting
 #  an AST file and running libclang on that AST file]
-self.assertIn(foo.mangled_name, ('_Z3fooii', '__Z3fooii', '?foo@@YAHHH'))
+self.assertIn(foo.mangled_name, ('_Z3fooii', '__Z3fooii', '?foo@@YAHHH', '?foo@@YAHHH@Z'))
Index: bindings/python/tests/cindex/test_cdb.py
===
--- bindings/python/tests/cindex/test_cdb.py
+++ bindings/python/tests/cindex/test_cdb.py
@@ -5,11 +5,13 @@
 import os
 import gc
 import unittest
+import sys
 
 
 kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
 
 
+@unittest.skipIf(sys.platform == 'win32', "TODO: Fix these tests on Windows")
 class TestCDB(unittest.TestCase):
 def test_create_fail(self):
 """Check we fail loading a database with an assertion"""
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334160 - Change return value of trivial visibility check.

2018-06-06 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jun  6 20:20:30 2018
New Revision: 334160

URL: http://llvm.org/viewvc/llvm-project?rev=334160=rev
Log:
Change return value of trivial visibility check.

Previous, if no Decl's were checked, visibility was set to false.  Switch it
so that in cases of no Decl's, return true.  These are the Decl's after being
filtered.  Also remove an unreachable return statement since it is directly
after another return statement.

Added:
cfe/trunk/test/Modules/local-visibility.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=334160=334159=334160=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Jun  6 20:20:30 2018
@@ -1452,6 +1452,8 @@ template
 static bool hasVisibleDeclarationImpl(Sema , const NamedDecl *D,
   llvm::SmallVectorImpl *Modules,
   Filter F) {
+  bool HasFilteredRedecls = false;
+
   for (auto *Redecl : D->redecls()) {
 auto *R = cast(Redecl);
 if (!F(R))
@@ -1460,6 +1462,8 @@ static bool hasVisibleDeclarationImpl(Se
 if (S.isVisible(R))
   return true;
 
+HasFilteredRedecls = true;
+
 if (Modules) {
   Modules->push_back(R->getOwningModule());
   const auto  = S.Context.getModulesWithMergedDefinition(R);
@@ -1467,7 +1471,11 @@ static bool hasVisibleDeclarationImpl(Se
 }
   }
 
-  return false;
+  // Only return false if there is at least one redecl that is not filtered 
out.
+  if (HasFilteredRedecls)
+return false;
+
+  return true;
 }
 
 bool Sema::hasVisibleExplicitSpecialization(
@@ -1497,8 +1505,6 @@ bool Sema::hasVisibleMemberSpecializatio
 //class definition?
 return D->getLexicalDeclContext()->isFileContext();
   });
-
-  return false;
 }
 
 /// Determine whether a declaration is visible to name lookup.

Added: cfe/trunk/test/Modules/local-visibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/local-visibility.cpp?rev=334160=auto
==
--- cfe/trunk/test/Modules/local-visibility.cpp (added)
+++ cfe/trunk/test/Modules/local-visibility.cpp Wed Jun  6 20:20:30 2018
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fmodules %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+// expected-no-diagnostics
+template 
+struct S {
+  template 
+  struct Inner { };
+
+  template <>
+  struct Inner<0> { };
+};
+
+S::Inner<1> I1;
+S::Inner<0> I0;


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


[PATCH] D46915: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

2018-06-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: lib/AST/ExprConstant.cpp:9323
+  if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow() &&
+  !HandleOverflow(Info, E, -Value.extend(Value.getBitWidth() + 1),
+  E->getType()))

ebevhan wrote:
> Is signed fixed-point overflow actually considered undefined behavior? I'm 
> not familiar with what Embedded-C says about this.
> 
> Also, this routine will likely print the wrong number for fixed-point values.
I believe clause 4.1.3 states that if `FX_FRACT_OVERFLOW` or 
`FX_ACCUM_OVERFLOW` are set to `SAT` then overflow behavior on the respective 
types is saturation. Otherwise, overflow has undefined behavior by default or 
if the pragma is set to `DEFAULT`.



Comment at: lib/Sema/SemaExpr.cpp:3407
+
+if (Literal.fixedPointType == FPT_ACCUM) {
+  if (isSigned) {

ebevhan wrote:
> It should be possible to do this in a much more concise manner. In our port 
> we do this with a table lookup indexed by the type selection bits.
Replaced with getters for corresponding type followed by getters for 
information about the bits.



Comment at: lib/Sema/SemaExpr.cpp:3483
+  assert(
+  (fbits + ibits + 1 <= bit_width) &&
+  "The total fractional, integral, and sign bits exceed the bit 
width");

ebevhan wrote:
> It does not feel like verifying this is the responsibility of the literal 
> parser.
Right, this is taken care of in the target creation.


Repository:
  rC Clang

https://reviews.llvm.org/D46915



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


[PATCH] D46915: [Fixed Point Arithmetic] Set Fixed Point Precision Bits and Create Fixed Point Literals

2018-06-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 150248.
leonardchan marked 20 inline comments as done.
leonardchan added a comment.

- Moved definition of the fractional/integral bits to TargetInfo. Checks are 
also performed to make sure any target specific definitions of the F/IBits 
follow the restrictions set in clause 6.2.6.3 in N1169.
- Added flag `-fsame-fbits` to force the number of fractional bits in unsigned 
types to be the same as those of their their corresponding signed types. The 
default values for all fractional bits is of signed fixed point types are one 
less than the default values for their unsigned counterparts.
- Implemented custom parsing for fixed point literals and added tests for them. 
Both decimal and hexadecimal exponentiation are supported.
- I do not have many examples involving assignment to saturated types because 
this patch does not include conversions yet between fixed point types. This 
will be in a future patch. The same goes for testing the minimum values for 
each type because I have not yet implemented folding on binary expressions 
involving fixed point types.


Repository:
  rC Clang

https://reviews.llvm.org/D46915

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Expr.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TargetInfo.h
  include/clang/Driver/Options.td
  include/clang/Lex/LiteralSupport.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/Type.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Index/USRGeneration.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_declarations.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_same_fbits.c
  test/Frontend/fixed_point_validation.c
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -305,6 +305,10 @@
 K = CXCursor_IntegerLiteral;
 break;
 
+  case Stmt::FixedPointLiteralClass:
+llvm_unreachable("No cursor for FixedPointLiteralClass");
+break;
+
   case Stmt::FloatingLiteralClass:
 K = CXCursor_FloatingLiteral;
 break;
Index: test/Frontend/fixed_point_validation.c
===
--- /dev/null
+++ test/Frontend/fixed_point_validation.c
@@ -0,0 +1,19 @@
+// RUN: %clang -ffixed-point -S -emit-llvm -o - %s | lli -force-interpreter=true
+
+// Run simple validation tests
+
+#define assert(b) if (!(b)) { return 1; }
+
+int main(){
+  short _Accum s_accum = 0.0hk;
+  short _Accum s_accum2 = 2.0hk;
+  short _Fract s_fract = 0.999hr;
+  short _Fract s_fract2 = -0.999hr;
+
+  assert(s_accum == 0);
+
+  s_accum = s_accum2;
+
+  assert(s_accum == s_accum2);
+  assert(s_accum == 2);
+}
Index: test/Frontend/fixed_point_same_fbits.c
===
--- /dev/null
+++ test/Frontend/fixed_point_same_fbits.c
@@ -0,0 +1,28 @@
+// RUN: %clang -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang -ffixed-point -fsame-fbits -S -emit-llvm -o - %s | FileCheck %s -check-prefix=SAME
+
+/* The scale for unsigned fixed point types should be the same as that of signed
+ * fixed point types when -fsame-fbits is enabled. */
+
+void func() {
+  unsigned short _Accum u_short_accum = 0.5uhk;
+  unsigned _Accum u_accum = 0.5uk;
+  unsigned long _Accum u_long_accum = 0.5ulk;
+  unsigned short _Fract u_short_fract = 0.5uhr;
+  unsigned _Fract u_fract = 0.5ur;
+  unsigned long _Fract u_long_fract = 0.5ulr;
+
+// DEFAULT: store i16 128, i16* %u_short_accum, align 2
+// DEFAULT: store i32 32768, i32* %u_accum, align 4
+// DEFAULT: store i64 2147483648, i64* %u_long_accum, align 8
+// DEFAULT: store i16 128, i16* %u_short_fract, align 2
+// DEFAULT: store i32 32768, i32* %u_fract, align 4
+// DEFAULT: store i64 2147483648, i64* %u_long_fract, align 8
+
+// SAME: store i16 64, i16* %u_short_accum, align 2
+// SAME: store i32 16384, i32* %u_accum, align 4
+// SAME: store i64 1073741824, i64* 

[PATCH] D47724: [X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmaddsub/fmsubadd builtins.

2018-06-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334159: [X86] Add back _mask, _maskz, and _mask3 builtins 
for some 512-bit… (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47724

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGen/avx512f-builtins.c

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -8555,79 +8555,110 @@
 
 // Lowers X86 FMA intrinsics to IR.
 static Value *EmitX86FMAExpr(CodeGenFunction , ArrayRef Ops,
- unsigned BuiltinID) {
+ unsigned BuiltinID, bool IsAddSub) {
 
-  bool IsAddSub = false;
-  bool IsScalar = false;
-
-  // 4 operands always means rounding mode without a mask here.
-  bool IsRound = Ops.size() == 4;
-
-  Intrinsic::ID ID;
+  bool Subtract = false;
+  Intrinsic::ID IID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {
   default: break;
-  case clang::X86::BI__builtin_ia32_vfmaddss3: IsScalar = true; break;
-  case clang::X86::BI__builtin_ia32_vfmaddsd3: IsScalar = true; break;
-  case clang::X86::BI__builtin_ia32_vfmaddps512:
-ID = llvm::Intrinsic::x86_avx512_vfmadd_ps_512; break;
-  case clang::X86::BI__builtin_ia32_vfmaddpd512:
-ID = llvm::Intrinsic::x86_avx512_vfmadd_pd_512; break;
-  case clang::X86::BI__builtin_ia32_vfmaddsubps: IsAddSub = true; break;
-  case clang::X86::BI__builtin_ia32_vfmaddsubpd: IsAddSub = true; break;
-  case clang::X86::BI__builtin_ia32_vfmaddsubps256: IsAddSub = true; break;
-  case clang::X86::BI__builtin_ia32_vfmaddsubpd256: IsAddSub = true; break;
-  case clang::X86::BI__builtin_ia32_vfmaddsubps512: {
-ID = llvm::Intrinsic::x86_avx512_vfmaddsub_ps_512;
-IsAddSub = true;
+  case clang::X86::BI__builtin_ia32_vfmsubps512_mask3:
+Subtract = true;
+LLVM_FALLTHROUGH;
+  case clang::X86::BI__builtin_ia32_vfmaddps512_mask:
+  case clang::X86::BI__builtin_ia32_vfmaddps512_maskz:
+  case clang::X86::BI__builtin_ia32_vfmaddps512_mask3:
+IID = llvm::Intrinsic::x86_avx512_vfmadd_ps_512; break;
+  case clang::X86::BI__builtin_ia32_vfmsubpd512_mask3:
+Subtract = true;
+LLVM_FALLTHROUGH;
+  case clang::X86::BI__builtin_ia32_vfmaddpd512_mask:
+  case clang::X86::BI__builtin_ia32_vfmaddpd512_maskz:
+  case clang::X86::BI__builtin_ia32_vfmaddpd512_mask3:
+IID = llvm::Intrinsic::x86_avx512_vfmadd_pd_512; break;
+  case clang::X86::BI__builtin_ia32_vfmsubaddps512_mask3:
+Subtract = true;
+LLVM_FALLTHROUGH;
+  case clang::X86::BI__builtin_ia32_vfmaddsubps512_mask:
+  case clang::X86::BI__builtin_ia32_vfmaddsubps512_maskz:
+  case clang::X86::BI__builtin_ia32_vfmaddsubps512_mask3:
+IID = llvm::Intrinsic::x86_avx512_vfmaddsub_ps_512;
 break;
-  }
-  case clang::X86::BI__builtin_ia32_vfmaddsubpd512: {
-ID = llvm::Intrinsic::x86_avx512_vfmaddsub_pd_512;
-IsAddSub = true;
+  case clang::X86::BI__builtin_ia32_vfmsubaddpd512_mask3:
+Subtract = true;
+LLVM_FALLTHROUGH;
+  case clang::X86::BI__builtin_ia32_vfmaddsubpd512_mask:
+  case clang::X86::BI__builtin_ia32_vfmaddsubpd512_maskz:
+  case clang::X86::BI__builtin_ia32_vfmaddsubpd512_mask3:
+IID = llvm::Intrinsic::x86_avx512_vfmaddsub_pd_512;
 break;
   }
-  }
-
-  // Only handle in case of _MM_FROUND_CUR_DIRECTION/4 (no rounding).
-  if (IsRound) {
-Function *Intr = CGF.CGM.getIntrinsic(ID);
-if (cast(Ops[3])->getZExtValue() != (uint64_t)4)
-  return CGF.Builder.CreateCall(Intr, Ops);
-  }
 
   Value *A = Ops[0];
   Value *B = Ops[1];
   Value *C = Ops[2];
 
-  if (IsScalar) {
-A = CGF.Builder.CreateExtractElement(A, (uint64_t)0);
-B = CGF.Builder.CreateExtractElement(B, (uint64_t)0);
-C = CGF.Builder.CreateExtractElement(C, (uint64_t)0);
-  }
-
-  llvm::Type *Ty = A->getType();
-  Function *FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ty);
-  Value *Res = CGF.Builder.CreateCall(FMA, {A, B, C} );
-
-  if (IsScalar)
-return CGF.Builder.CreateInsertElement(Ops[0], Res, (uint64_t)0);
-
-  if (IsAddSub) {
-// Negate even elts in C using a mask.
-unsigned NumElts = Ty->getVectorNumElements();
-SmallVector NMask;
-Constant *Zero = ConstantInt::get(CGF.Builder.getInt1Ty(), 0);
-Constant *One = ConstantInt::get(CGF.Builder.getInt1Ty(), 1);
-for (unsigned i = 0; i < NumElts; ++i) {
-  NMask.push_back(i % 2 == 0 ? One : Zero);
-}
-Value *NegMask = ConstantVector::get(NMask);
-
-Value *NegC = CGF.Builder.CreateFNeg(C);
-Value *FMSub = CGF.Builder.CreateCall(FMA, {A, B, NegC} );
-Res = CGF.Builder.CreateSelect(NegMask, FMSub, Res);
+  if (Subtract)
+C = CGF.Builder.CreateFNeg(C);
+
+  Value *Res;
+
+  // 

r334159 - [X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmaddsub/fmsubadd builtins.

2018-06-06 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jun  6 19:46:02 2018
New Revision: 334159

URL: http://llvm.org/viewvc/llvm-project?rev=334159=rev
Log:
[X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit 
fmadd/fmsub/fmaddsub/fmsubadd builtins.

Summary:
We recently switch to using a selects in the intrinsics header files for FMA 
instructions. But the 512-bit versions support flavors with rounding mode which 
must be an Integer Constant Expression. This has forced those intrinsics to be 
implemented as macros. As it stands now the mask and mask3 intrinsics evaluate 
one of their macro arguments twice. If that argument itself is another 
intrinsic macro, we can end up over expanding macros. Or if its something we 
can CSE later it would show up multiple times when it shouldn't.

I tried adding __extension__ around the macro and making it an expression 
statement and declaring a local variable. But whatever name you choose for the 
local variable can never be used as the name of an input to the macro in user 
code. If that happens you would end up with the same name on the LHS and RHS of 
an assignment after expansion. We might be safe if we use __ in front of the 
variable names because those names are reserved and user code shouldn't use 
that, but I wasn't sure I wanted to make that claim.

The other option which I've chosen here, is to add back _mask, _maskz, and 
_mask3 flavors of the builtin which we will expand in CGBuiltin.cpp to 
replicate the argument as needed and insert any fneg needed on the third 
operand to make a subtract. The _maskz isn't truly necessary if we have an 
unmasked version or if we use the masked version with a -1 mask and wrap a 
select around it. But I've chosen to make things more uniform.

I separated out the scalar builtin handling to avoid too many things going on 
in EmitX86FMAExpr. It was different enough due to the extract and insert that 
the minor duplication of the CreateCall was probably worth it.

Reviewers: tkrupa, RKSimon, spatel, GBuella

Reviewed By: tkrupa

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334159=334158=334159=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jun  6 19:46:02 2018
@@ -731,10 +731,22 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddpd25
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubps256, "V8fV8fV8fV8f", "nc", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd256, "V4dV4dV4dV4d", "nc", "fma|fma4")
 
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd512, "V8dV8dV8dV8dIi", "nc", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_vfmaddps512, "V16fV16fV16fV16fIi", "nc", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd512, "V8dV8dV8dV8dIi", "nc", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubps512, "V16fV16fV16fV16fIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd512_mask, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd512_maskz, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd512_mask3, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmsubpd512_mask3, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps512_mask, "V16fV16fV16fV16fUsIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps512_maskz, "V16fV16fV16fV16fUsIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps512_mask3, "V16fV16fV16fV16fUsIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmsubps512_mask3, "V16fV16fV16fV16fUsIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd512_mask, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd512_maskz, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd512_mask3, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmsubaddpd512_mask3, "V8dV8dV8dV8dUcIi", "nc", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubps512_mask, "V16fV16fV16fV16fUsIi", 
"nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubps512_maskz, "V16fV16fV16fV16fUsIi", 
"nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubps512_mask3, "V16fV16fV16fV16fUsIi", 
"nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmsubaddps512_mask3, "V16fV16fV16fV16fUsIi", 
"nc", "avx512f")
 
 // XOP
 TARGET_BUILTIN(__builtin_ia32_vpmacssww, "V8sV8sV8sV8s", "nc", "xop")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334159=334158=334159=diff

[PATCH] D47862: [CodeGen] Always use MSVC personality for windows-msvc targets

2018-06-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, DHowett-MSFT, rnk.

The windows-msvc target is meant to be ABI compatible with MSVC,
including the exception handling. Ensure that a windows-msvc triple
always equates to the MSVC personality being used.

This mostly affects the GNUStep and ObjFW Obj-C runtimes. To the best of
my knowledge, those are normally not used with windows-msvc triples. I
believe WinObjC is based on GNUStep (or it at least uses libobjc2), but
that also takes the approach of wrapping Obj-C exceptions in C++
exceptions, so the MSVC personality function is the right one to use
there as well.


Repository:
  rC Clang

https://reviews.llvm.org/D47862

Files:
  lib/CodeGen/CGException.cpp
  test/CodeGenObjC/personality.m
  test/CodeGenObjCXX/personality.mm

Index: test/CodeGenObjCXX/personality.mm
===
--- test/CodeGenObjCXX/personality.mm
+++ test/CodeGenObjCXX/personality.mm
@@ -25,14 +25,14 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fseh-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW-SEH
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fsjlj-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW-SJLJ
 
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=ios -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=watchos -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=gnustep-1.7 -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-GNUSTEP-1_7
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=gnustep -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-GNUSTEP
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=gcc -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-GCC
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=ios -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=watchos -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=gnustep-1.7 -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=gnustep -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=gcc -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
 
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MACOSX-FRAGILE
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions -fdwarf-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MACOSX-FRAGILE
@@ -80,8 +80,7 @@
 // CHECK-OBJFW-SEH: personality i8* bitcast (i32 (...)* 

r334155 - ClangTidy fix - 'clang::Sema::checkAllowedCUDAInitializer' has a definition with different parameter names.

2018-06-06 Thread Han Shen via cfe-commits
Author: shenhan
Date: Wed Jun  6 17:55:54 2018
New Revision: 334155

URL: http://llvm.org/viewvc/llvm-project?rev=334155=rev
Log:
ClangTidy fix - 'clang::Sema::checkAllowedCUDAInitializer' has a definition 
with different parameter names.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=334155=334154=334155=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jun  6 17:55:54 2018
@@ -10174,7 +10174,7 @@ public:
   // __shared__ variables whether they are local or not (they all are 
implicitly
   // static in CUDA). One exception is that CUDA allows constant initializers
   // for __constant__ and __device__ variables.
-  void checkAllowedCUDAInitializer(VarDecl *Var);
+  void checkAllowedCUDAInitializer(VarDecl *VD);
 
   /// Check whether NewFD is a valid overload for CUDA. Emits
   /// diagnostics and invalidates NewFD if not.


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


Re: r333978 - Reimplement the bittest intrinsic family as builtins with inline asm

2018-06-06 Thread Grang, Mandeep Singh via cfe-commits
@rnk I tried building spec2000/eon for Windows ARM64 and ran into these 
errors:


use of undeclared identifier '_interlockedbittestandset_acq'
use of undeclared identifier '_interlockedbittestandset_rel'
use of undeclared identifier '_interlockedbittestandset_nf'

I see that you have removed them in your patch. Apparently they are 
needed (at least for ARM64 Win).


--Mandeep

On 6/5/2018 11:01 AM, Reid Kleckner via cfe-commits wrote:
On Tue, Jun 5, 2018 at 2:33 AM Martin Storsjö > wrote:


> // Many of MSVC builtins are on both x64 and ARM; to avoid
repeating code, we
> // handle them here.

This doesn't seem thought through wrt non-x86 architectures. I'm
not sure
if there's any similar suitable instruction to use on ARM/AArch64,
but we
should at the very least fall back to doing whatever we did before
this
change for anything not x86.


 I'll go back and take a look, but I'm not convinced that what we did 
before was correct for ARM either. I'm installing the Visual C++ 
aarch64 compiler now so I can make sure we get it right.



___
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


r334153 - Change the wording of RTTI errors to make them more generic.

2018-06-06 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Wed Jun  6 17:42:59 2018
New Revision: 334153

URL: http://llvm.org/viewvc/llvm-project?rev=334153=rev
Log:
Change the wording of RTTI errors to make them more generic.

An attempt to use dynamic_cast while rtti is disabled, used to emit the error:

  cannot use dynamic_cast with -fno-rtti

and a similar one for typeid.

This patch changes that to:

  use of dynamic_cast requires -frtti

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaCXX/no-rtti.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=334153=334152=334153=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun  6 17:42:59 
2018
@@ -6607,9 +6607,9 @@ def err_not_tag_in_scope : Error<
   "no %select{struct|interface|union|class|enum}0 named %1 in %2">;
 
 def err_no_typeid_with_fno_rtti : Error<
-  "cannot use typeid with -fno-rtti">;
+  "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
-  "cannot use dynamic_cast with -fno-rtti">;
+  "use of dynamic_cast requires -frtti">;
 
 def err_cannot_form_pointer_to_member_of_reference_type : Error<
   "cannot form a pointer-to-member to member %0 of reference type %1">;

Modified: cfe/trunk/test/SemaCXX/no-rtti.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/no-rtti.cpp?rev=334153=334152=334153=diff
==
--- cfe/trunk/test/SemaCXX/no-rtti.cpp (original)
+++ cfe/trunk/test/SemaCXX/no-rtti.cpp Wed Jun  6 17:42:59 2018
@@ -6,7 +6,7 @@ namespace std {
 
 void f()
 {
-  (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}}
+  (void)typeid(int); // expected-error {{use of typeid requires -frtti}}
 }
 
 namespace {
@@ -20,7 +20,7 @@ struct B : public A {
 }
 
 bool isa_B(A *a) {
-  return dynamic_cast(a) != 0; // expected-error {{cannot use 
dynamic_cast with -fno-rtti}}
+  return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast 
requires -frtti}}
 }
 
 void* getMostDerived(A* a) {


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


[PATCH] D47291: Proposal to make rtti errors more generic.

2018-06-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334153: Change the wording of RTTI errors to make them more 
generic. (authored by ssrivastava, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D47291

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  test/SemaCXX/no-rtti.cpp


Index: test/SemaCXX/no-rtti.cpp
===
--- test/SemaCXX/no-rtti.cpp
+++ test/SemaCXX/no-rtti.cpp
@@ -6,7 +6,7 @@
 
 void f()
 {
-  (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}}
+  (void)typeid(int); // expected-error {{use of typeid requires -frtti}}
 }
 
 namespace {
@@ -20,7 +20,7 @@
 }
 
 bool isa_B(A *a) {
-  return dynamic_cast(a) != 0; // expected-error {{cannot use 
dynamic_cast with -fno-rtti}}
+  return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast 
requires -frtti}}
 }
 
 void* getMostDerived(A* a) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6607,9 +6607,9 @@
   "no %select{struct|interface|union|class|enum}0 named %1 in %2">;
 
 def err_no_typeid_with_fno_rtti : Error<
-  "cannot use typeid with -fno-rtti">;
+  "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
-  "cannot use dynamic_cast with -fno-rtti">;
+  "use of dynamic_cast requires -frtti">;
 
 def err_cannot_form_pointer_to_member_of_reference_type : Error<
   "cannot form a pointer-to-member to member %0 of reference type %1">;


Index: test/SemaCXX/no-rtti.cpp
===
--- test/SemaCXX/no-rtti.cpp
+++ test/SemaCXX/no-rtti.cpp
@@ -6,7 +6,7 @@
 
 void f()
 {
-  (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}}
+  (void)typeid(int); // expected-error {{use of typeid requires -frtti}}
 }
 
 namespace {
@@ -20,7 +20,7 @@
 }
 
 bool isa_B(A *a) {
-  return dynamic_cast(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}}
+  return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast requires -frtti}}
 }
 
 void* getMostDerived(A* a) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6607,9 +6607,9 @@
   "no %select{struct|interface|union|class|enum}0 named %1 in %2">;
 
 def err_no_typeid_with_fno_rtti : Error<
-  "cannot use typeid with -fno-rtti">;
+  "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
-  "cannot use dynamic_cast with -fno-rtti">;
+  "use of dynamic_cast requires -frtti">;
 
 def err_cannot_form_pointer_to_member_of_reference_type : Error<
   "cannot form a pointer-to-member to member %0 of reference type %1">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334151 - [ODRHash] Adjust info stored for FunctionTemplateDecl.

2018-06-06 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jun  6 17:20:58 2018
New Revision: 334151

URL: http://llvm.org/viewvc/llvm-project?rev=334151=rev
Log:
[ODRHash] Adjust info stored for FunctionTemplateDecl.

Avoid storing information for definitions since those can be out-of-line and
vary between modules even when the declarations are the same.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=334151=334150=334151=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Jun  6 17:20:58 2018
@@ -427,7 +427,7 @@ public:
 
   void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
 Visit(D->getTemplatedDecl());
-ID.AddInteger(D->getTemplatedDecl()->getODRHash());
+AddDecl(D->getTemplatedDecl());
 Inherited::VisitFunctionTemplateDecl(D);
   }
 };

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=334151=334150=334151=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Jun  6 17:20:58 2018
@@ -3617,6 +3617,20 @@ int I10 = F10();
 #endif
 // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions 
in different modules; definition in module 'SecondModule' first difference is 
function body}}
 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
+
+#if defined(FIRST)
+struct S11 {
+  template  void foo();
+};
+#elif defined(SECOND)
+struct S11 {
+  template  void foo();
+};
+template  void S11::foo() {}
+#else
+S11 s11;
+#endif
+
 }  // namespace FunctionDecl
 
 namespace DeclTemplateArguments {


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


[PATCH] D47853: [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, mstorsjo, rnk.

The windows-msvc target is used for MSVC ABI compatibility, including
the exceptions model. It doesn't make sense to pair a windows-msvc
target with a non-MSVC exception model. This would previously cause an
assertion failure; explicitly error out for it in the frontend instead.
This also allows us to reduce the matrix of target/exception models a
bit (see the modified tests), and we can possibly simplify some of the
personality code in a follow-up.


Repository:
  rC Clang

https://reviews.llvm.org/D47853

Files:
  include/clang/Basic/DiagnosticFrontendKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/personality.c
  test/CodeGenCXX/ms-eh-personality.cpp
  test/CodeGenCXX/personality.cpp
  test/CodeGenObjC/personality.m
  test/CodeGenObjCXX/personality.mm
  test/Frontend/windows-exceptions.cpp

Index: test/Frontend/windows-exceptions.cpp
===
--- /dev/null
+++ test/Frontend/windows-exceptions.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fsyntax-only %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-DWARF %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SEH %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SJLJ %s
+
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-DWARF %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SEH %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SJLJ %s
+
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fdwarf-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fseh-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fdwarf-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fseh-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+
+// MSVC-X86-DWARF: error: invalid exception model 'fdwarf-exceptions' for target 'i686--windows-msvc'
+// MSVC-X86-SEH: error: invalid exception model 'fseh-exceptions' for target 'i686--windows-msvc'
+// MSVC-X86-SJLJ: error: invalid exception model 'fsjlj-exceptions' for target 'i686--windows-msvc'
+
+// MSVC-X64-DWARF: error: invalid exception model 'fdwarf-exceptions' for target 'x86_64--windows-msvc'
+// MSVC-X64-SEH: error: invalid exception model 'fseh-exceptions' for target 'x86_64--windows-msvc'
+// MSVC-X64-SJLJ: error: invalid exception model 'fsjlj-exceptions' for target 'x86_64--windows-msvc'
Index: test/CodeGenObjCXX/personality.mm
===
--- test/CodeGenObjCXX/personality.mm
+++ test/CodeGenObjCXX/personality.mm
@@ -26,31 +26,13 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fsjlj-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW-SJLJ
 
 // RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fdwarf-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE-DWARF
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fseh-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE-SEH
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fsjlj-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE-SJLJ
 // RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fdwarf-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS-DWARF
-// RUN: 

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-06-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Add tests for C++ and move OpenMP specific tests to OpenMP directory




Comment at: lib/Headers/__clang_cuda_device_functions.h:28
+#if defined(_OPENMP)
+#include <__clang_cuda_libdevice_declares.h>
+#include 

Do we really need to include all that stuff here? Will it work with C++, 
especially with the latest versions of the standard?



Comment at: lib/Headers/__clang_cuda_device_functions.h:44
+#elif defined(_OPENMP)
+#define __DEVICE__ static __inline__ __attribute__((always_inline))
+#endif

Do you really need "__inline__" if you are using 'alwsys_inline' attribute 
already? Will it work on Windows?


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-06-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:7117
+if (E && S.checkNonNullExpr(E))
+  return NullabilityKind::Nullable;
+

jordan_rose wrote:
> This isn't quite correct, unfortunately. `(_Nonnull id)nil` should be 
> considered non-nullable, since it's the canonical way to avoid all these 
> warnings. It might just be good enough to move this check below the 
> `getNullability` one, though.
Sema::CheckNonNullExpr checks the nullability of the type of the expression 
first and returns false if there is a cast to `_Nonnull`.


Repository:
  rC Clang

https://reviews.llvm.org/D22391



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


[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-06-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 150218.
ahatanak marked an inline comment as done.
ahatanak added a reviewer: dcoughlin.
ahatanak set the repository for this revision to rC Clang.
ahatanak added a comment.

Sorry for the delay in responding. I've addressed Jordan's review comments.

I had to make changes to a couple of tests in Analysis. In particular, I'm not 
sure whether we should try to avoid producing extra diagnostics in 
test/Analysis/nullability_nullonly.mm or whether it's possible to do so in Sema.


Repository:
  rC Clang

https://reviews.llvm.org/D22391

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/Analysis/nullability-no-arc.mm
  test/Analysis/nullability.mm
  test/Analysis/nullability_nullonly.mm
  test/Sema/conditional-expr.c
  test/Sema/null_constant_to_nonnull.c

Index: test/Sema/null_constant_to_nonnull.c
===
--- /dev/null
+++ test/Sema/null_constant_to_nonnull.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnullable-to-nonnull-conversion %s -verify
+
+void null_const_to_nonnull(int c) {
+  int * _Nonnull p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  p0 = (int * _Nonnull)0; // explicit cast silences warnings
+  int * _Nonnull p1;
+  int * _Nonnull p2 = c ? p1 : 0; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
+  p2 = c ? p1 : (int * _Nonnull)0; // explicit cast silences warnings
+}
Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -17,7 +17,7 @@
   dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}}
   dp = 0 ? (double *)0 : (void *)0;
   vp = 0 ? (double *)0 : (void *)0;
-  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
+  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double * _Nullable'}}
 
   const int *cip;
   vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
@@ -90,7 +90,7 @@
 
 int f0(int a) {
   // GCC considers this a warning.
-  return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
+  return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void * _Nullable' from a function with result type 'int'}}
 }
 
 int f2(int x) {
Index: test/Analysis/nullability_nullonly.mm
===
--- test/Analysis/nullability_nullonly.mm
+++ test/Analysis/nullability_nullonly.mm
@@ -100,7 +100,7 @@
 }
 
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'TestObject * _Nonnull __strong'}}
 }
 
 // Under ARC, returned expressions of ObjC objects types are are implicitly
Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -180,7 +180,7 @@
 
   // Since we've already had an invariant violation along this path,
   // we shouldn't warn here.
-  nonnullLocalWithAssignmentInInitializer = 0;
+  nonnullLocalWithAssignmentInInitializer = 0; // expected-warning {{implicitly casting a null constant to non-nullable pointer type}}
   (void)nonnullLocalWithAssignmentInInitializer;
 
 }
@@ -192,7 +192,7 @@
 
   // Since we've already had an invariant violation along this path,
   // we shouldn't warn here.
-  nonnullLocalWithAssignment = 0;
+  nonnullLocalWithAssignment = 0; // expected-warning {{implicitly casting a null constant to non-nullable pointer type}}
   (void)nonnullLocalWithAssignment;
 }
 
Index: test/Analysis/nullability-no-arc.mm
===
--- test/Analysis/nullability-no-arc.mm
+++ test/Analysis/nullability-no-arc.mm
@@ -43,7 +43,7 @@
 }
 
 void 

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-06-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: Hahnfeld, tra, hfinkel, carlo.bertolli, caomhin, 
ABataev.
Herald added subscribers: cfe-commits, guansong, mgorny.

In current Clang, on the OpenMP NVPTX toolchain, math functions are resolved as 
math functions for the host. For example, a call to sqrt() in a target region 
will result in an LLVM-IR call which looks like this:

  call double sqrt(double %1)

This patch allows for math functions in OpenMP NVPTX target regions to call the 
same math functions that CUDA code calls. For example, for sqrt we get:

  call double @llvm.nvvm.sqrt.rn.d(double %1)

This is necessary for both correctness and performance.


Repository:
  rC Clang

https://reviews.llvm.org/D47849

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  test/CodeGen/nvptx_device_math_functions.c

Index: test/CodeGen/nvptx_device_math_functions.c
===
--- /dev/null
+++ test/CodeGen/nvptx_device_math_functions.c
@@ -0,0 +1,20 @@
+// Test calling of device math functions.
+///==///
+
+// RUN: %clang -fmath-errno -S -emit-llvm -o - %s -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda | FileCheck -check-prefix CHECK-YES %s
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @llvm.nvvm.sqrt.rn.d(double
+double l1 = sqrt(a1);
+  }
+}
+
+void test_pow(float a0, double a1, long double a2) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__internal_accurate_pow(double
+double l1 = pow(a1, a1);
+  }
+}
Index: lib/Headers/__clang_cuda_libdevice_declares.h
===
--- lib/Headers/__clang_cuda_libdevice_declares.h
+++ lib/Headers/__clang_cuda_libdevice_declares.h
@@ -24,442 +24,452 @@
 #ifndef __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 #define __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 
+#if defined(_OPENMP)
+#define __DEVICE__
+#elif defined(__CUDA__)
+#define __DEVICE__ __device__
+#endif
+
+#if defined(__cplusplus)
 extern "C" {
+#endif
 
-__device__ int __nv_abs(int __a);
-__device__ double __nv_acos(double __a);
-__device__ float __nv_acosf(float __a);
-__device__ double __nv_acosh(double __a);
-__device__ float __nv_acoshf(float __a);
-__device__ double __nv_asin(double __a);
-__device__ float __nv_asinf(float __a);
-__device__ double __nv_asinh(double __a);
-__device__ float __nv_asinhf(float __a);
-__device__ double __nv_atan2(double __a, double __b);
-__device__ float __nv_atan2f(float __a, float __b);
-__device__ double __nv_atan(double __a);
-__device__ float __nv_atanf(float __a);
-__device__ double __nv_atanh(double __a);
-__device__ float __nv_atanhf(float __a);
-__device__ int __nv_brev(int __a);
-__device__ long long __nv_brevll(long long __a);
-__device__ int __nv_byte_perm(int __a, int __b, int __c);
-__device__ double __nv_cbrt(double __a);
-__device__ float __nv_cbrtf(float __a);
-__device__ double __nv_ceil(double __a);
-__device__ float __nv_ceilf(float __a);
-__device__ int __nv_clz(int __a);
-__device__ int __nv_clzll(long long __a);
-__device__ double __nv_copysign(double __a, double __b);
-__device__ float __nv_copysignf(float __a, float __b);
-__device__ double __nv_cos(double __a);
-__device__ float __nv_cosf(float __a);
-__device__ double __nv_cosh(double __a);
-__device__ float __nv_coshf(float __a);
-__device__ double __nv_cospi(double __a);
-__device__ float __nv_cospif(float __a);
-__device__ double __nv_cyl_bessel_i0(double __a);
-__device__ float __nv_cyl_bessel_i0f(float __a);
-__device__ double __nv_cyl_bessel_i1(double __a);
-__device__ float __nv_cyl_bessel_i1f(float __a);
-__device__ double __nv_dadd_rd(double __a, double __b);
-__device__ double __nv_dadd_rn(double __a, double __b);
-__device__ double __nv_dadd_ru(double __a, double __b);
-__device__ double __nv_dadd_rz(double __a, double __b);
-__device__ double __nv_ddiv_rd(double __a, double __b);
-__device__ double __nv_ddiv_rn(double __a, double __b);
-__device__ double __nv_ddiv_ru(double __a, double __b);
-__device__ double __nv_ddiv_rz(double __a, double __b);
-__device__ double __nv_dmul_rd(double __a, double __b);
-__device__ double __nv_dmul_rn(double __a, double __b);
-__device__ double __nv_dmul_ru(double __a, double __b);
-__device__ double __nv_dmul_rz(double __a, double __b);
-__device__ float __nv_double2float_rd(double __a);
-__device__ float __nv_double2float_rn(double __a);
-__device__ float __nv_double2float_ru(double __a);
-__device__ float __nv_double2float_rz(double __a);
-__device__ int __nv_double2hiint(double __a);
-__device__ int __nv_double2int_rd(double __a);
-__device__ int __nv_double2int_rn(double __a);
-__device__ int 

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/CMakeLists.txt:28
   protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_loop_proto.proto)
   set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})

I think it makes sense to use separate SRCS and HDRS variables for 
cxx_loop_proto.proto.  Otherwise each proto-fuzzer will be compiled with 
//both// protobufs even though each only uses one.



Comment at: tools/clang-fuzzer/CMakeLists.txt:58
   add_clang_subdirectory(fuzzer-initialize)
 
   # Build the protobuf fuzzer

Why is this here twice?



Comment at: tools/clang-fuzzer/CMakeLists.txt:90
+clangLoopProtoToCXX
+)
 endif()

Maybe you can cut down on some LOC here by creating a 
`COMMON_PROTO_FUZZ_LIBRARIES` variable with the dependencies that overlap 
between the proto-fuzzers.



Comment at: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h:22
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
+}

morehouse wrote:
> Instead of making a whole new header for this, can we simply add  
> `LoopProtoToCxx()` and `LoopFunctionToString()` to proto_to_cxx.h?  Then 
> implement them in `loop_proto_to_cxx.cpp`?
Can we remove this file completely?


Repository:
  rC Clang

https://reviews.llvm.org/D47843



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


[PATCH] D47850: [Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc

2018-06-06 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334145: [Driver] Stop passing -fseh-exceptions for 
x86_64-windows-msvc (authored by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47850

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/windows-exceptions.cpp


Index: cfe/trunk/test/Driver/windows-exceptions.cpp
===
--- cfe/trunk/test/Driver/windows-exceptions.cpp
+++ cfe/trunk/test/Driver/windows-exceptions.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang -target i686-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
+// RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
+
+MSVC-NOT: -fdwarf-exceptions
+MSVC-NOT: -fseh-exceptions
+MINGW-DWARF: -fdwarf-exceptions
+MINGW-SEH: -fseh-exceptions
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -471,8 +471,6 @@
 
 llvm::ExceptionHandling
 ToolChain::GetExceptionModel(const llvm::opt::ArgList ) const {
-  if (Triple.isOSWindows() && Triple.getArch() != llvm::Triple::x86)
-return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::None;
 }
 


Index: cfe/trunk/test/Driver/windows-exceptions.cpp
===
--- cfe/trunk/test/Driver/windows-exceptions.cpp
+++ cfe/trunk/test/Driver/windows-exceptions.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang -target i686-windows-msvc -c %s -### 2>&1 | FileCheck -check-prefix=MSVC %s
+// RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck -check-prefix=MSVC %s
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
+
+MSVC-NOT: -fdwarf-exceptions
+MSVC-NOT: -fseh-exceptions
+MINGW-DWARF: -fdwarf-exceptions
+MINGW-SEH: -fseh-exceptions
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -471,8 +471,6 @@
 
 llvm::ExceptionHandling
 ToolChain::GetExceptionModel(const llvm::opt::ArgList ) const {
-  if (Triple.isOSWindows() && Triple.getArch() != llvm::Triple::x86)
-return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::None;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334145 - [Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc

2018-06-06 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Jun  6 16:09:02 2018
New Revision: 334145

URL: http://llvm.org/viewvc/llvm-project?rev=334145=rev
Log:
[Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc

-fseh-exceptions is only meaningful for MinGW targets, and that driver
already has logic to pass either -fdwarf-exceptions or -fseh-exceptions
as appropriate. -fseh-exceptions is just a no-op for MSVC triples, and
passing it to cc1 causes unnecessary confusion.

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

Added:
cfe/trunk/test/Driver/windows-exceptions.cpp
Modified:
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=334145=334144=334145=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Jun  6 16:09:02 2018
@@ -471,8 +471,6 @@ ObjCRuntime ToolChain::getDefaultObjCRun
 
 llvm::ExceptionHandling
 ToolChain::GetExceptionModel(const llvm::opt::ArgList ) const {
-  if (Triple.isOSWindows() && Triple.getArch() != llvm::Triple::x86)
-return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::None;
 }
 

Added: cfe/trunk/test/Driver/windows-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-exceptions.cpp?rev=334145=auto
==
--- cfe/trunk/test/Driver/windows-exceptions.cpp (added)
+++ cfe/trunk/test/Driver/windows-exceptions.cpp Wed Jun  6 16:09:02 2018
@@ -0,0 +1,9 @@
+// RUN: %clang -target i686-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
+// RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
+
+MSVC-NOT: -fdwarf-exceptions
+MSVC-NOT: -fseh-exceptions
+MINGW-DWARF: -fdwarf-exceptions
+MINGW-SEH: -fseh-exceptions


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


[PATCH] D47757: [Sema] Produce diagnostics when unavailable aligned allocation/deallocation functions are called

2018-06-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 150211.
ahatanak marked an inline comment as done.
ahatanak retitled this revision from "[Sema] Diagnose unavailable aligned 
deallocation functions called from deleting destructors." to "[Sema] Produce 
diagnostics when unavailable aligned allocation/deallocation functions are 
called".
ahatanak added a comment.

Sink diagnoseUnavailableAlignedAllocation into DiagnoseUseOfDecl and add calls 
to it in a few other places so that diagnostics are produced for calls to 
aligned operator and builtin operator new/delete in addition to aligned 
deallocation functions called from deleting destructors.

I had to make changes to two test cases (dr2xx.cpp and 
call-host-fn-from-device.cu) that have nothing to do with aligned 
allocation/deallocation functions. The warning in dr2xx.cpp seems correct to me 
judging from the comment left few lines above it ("We're also missing the 
-Wused-but-marked-unused ").  I'm not sure about the   diagnostic in 
call-host-fn-from-device.cu. The original comment says the sized delete 
function annotated with `__device__` is called, but it seems that the non-sized 
`__host__` function is being called, in which case I think the diagnostic is 
correct.


Repository:
  rC Clang

https://reviews.llvm.org/D47757

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CXX/drs/dr2xx.cpp
  test/SemaCUDA/call-host-fn-from-device.cu
  test/SemaCXX/unavailable_aligned_allocation.cpp

Index: test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- test/SemaCXX/unavailable_aligned_allocation.cpp
+++ test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -124,7 +124,73 @@
 // expected-note@-20 2 {{if you supply your own aligned allocation functions}}
 #endif
 
-// No errors if user-defined aligned allocation functions are available.
+// Test that diagnostics are produced when an unavailable aligned deallocation
+// function is called from a deleting destructor.
+struct alignas(256) OveralignedS2 {
+  int a[4];
+  virtual ~OveralignedS2();
+};
+
+OveralignedS2::~OveralignedS2() {}
+
+#ifdef NO_ERRORS
+// expected-no-diagnostics
+#else
+#if defined(IOS)
+// expected-error@-6 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on iOS 11 or newer}}}
+// expected-note@-7 {{if you supply your own aligned allocation functions}}
+#elif defined(TVOS)
+// expected-error@-9 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on tvOS 11 or newer}}}
+// expected-note@-10 {{if you supply your own aligned allocation functions}}
+#elif defined(WATCHOS)
+// expected-error@-12 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
+// expected-note@-13 {{if you supply your own aligned allocation functions}}
+#else
+// expected-error@-15 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
+// expected-note@-16 {{if you supply your own aligned allocation functions}}
+#endif
+#endif
+
+void testExplicitOperatorNewDelete() {
+  void *p = operator new(128);
+  operator delete(p);
+  p = operator new[](128);
+  operator delete[](p);
+  p = __builtin_operator_new(128);
+  __builtin_operator_delete(p);
+}
+
+void testExplicitOperatorNewDeleteOveraligned() {
+  void *p = operator new(128, (std::align_val_t)64);
+  operator delete(p, (std::align_val_t)64);
+  p = operator new[](128, (std::align_val_t)64);
+  operator delete[](p, (std::align_val_t)64);
+  p = __builtin_operator_new(128, (std::align_val_t)64);
+  __builtin_operator_delete(p, (std::align_val_t)64);
+}
+
+#ifdef NO_ERRORS
+// expected-no-diagnostics
+#else
+// expected-error@-11 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-note@-12 {{if you supply your own aligned allocation functions}}
+
+// expected-error@-13 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-note@-14 {{if you supply your own aligned allocation functions}}
+
+// expected-error@-15 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-note@-16 {{if you supply your own aligned allocation functions}}
+
+// expected-error@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-note@-18 {{if you supply your own aligned allocation functions}}
+
+// expected-error@-19 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-note@-20 {{if you supply your own aligned allocation functions}}
+
+// expected-error@-21 {{aligned deallocation 

[PATCH] D47850: [Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc

2018-06-06 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


Repository:
  rC Clang

https://reviews.llvm.org/D47850



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


[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 150213.
emmettneyman added a comment.

- Combined two header files into one


Repository:
  rC Clang

https://reviews.llvm.org/D47843

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
  tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,33 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::LoopProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
+++ tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -17,6 +17,10 @@
 
 namespace clang_fuzzer {
 class Function;
+class LoopFunction;
+
 std::string FunctionToString(const Function );
 std::string ProtoToCxx(const uint8_t *data, size_t size);
+std::string LoopFunctionToString(const LoopFunction );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
 }
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
===
--- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
@@ -1,22 +1,20 @@
-//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//==-- loop_proto_to_cxx.h - Protobuf-C++ conversion ==//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 //
-// Defines functions for converting between protobufs and C++.
+// Defines functions for converting between protobufs with loops and C++.
 //
 //===--===//
 
 #include 
 #include 
 #include 
 
 namespace clang_fuzzer {
-class Function;
-std::string FunctionToString(const Function );
-std::string ProtoToCxx(const uint8_t *data, size_t size);
+class LoopFunction;
 }
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -0,0 +1,115 @@
+//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++. Extends
+// proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
+// loop. Also coutputs a different function signature that includes a 
+// size_t parameter for the loop to use.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_loop_proto.pb.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  if (x.is_loop_var()) {
+return os << "a[loop_ctr]";
+  } else {
+

[PATCH] D47850: [Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc

2018-06-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, mstorsjo, rnk.
Herald added subscribers: JDevlieghere, aprantl.

-fseh-exceptions is only meaningful for MinGW targets, and that driver
already has logic to pass either -fdwarf-exceptiosn or -fseh-exceptions
as appropriate. -fseh-exceptions is just a no-op for MSVC triples, and
passing it to cc1 causes unnecessary confusion.


Repository:
  rC Clang

https://reviews.llvm.org/D47850

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/windows-exceptions.cpp


Index: test/Driver/windows-exceptions.cpp
===
--- /dev/null
+++ test/Driver/windows-exceptions.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang -target i686-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
+// RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
+
+MSVC-NOT: -fdwarf-exceptions
+MSVC-NOT: -fseh-exceptions
+MINGW-DWARF: -fdwarf-exceptions
+MINGW-SEH: -fseh-exceptions
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -471,8 +471,6 @@
 
 llvm::ExceptionHandling
 ToolChain::GetExceptionModel(const llvm::opt::ArgList ) const {
-  if (Triple.isOSWindows() && Triple.getArch() != llvm::Triple::x86)
-return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::None;
 }
 


Index: test/Driver/windows-exceptions.cpp
===
--- /dev/null
+++ test/Driver/windows-exceptions.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang -target i686-windows-msvc -c %s -### 2>&1 | FileCheck -check-prefix=MSVC %s
+// RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck -check-prefix=MSVC %s
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
+
+MSVC-NOT: -fdwarf-exceptions
+MSVC-NOT: -fseh-exceptions
+MINGW-DWARF: -fdwarf-exceptions
+MINGW-SEH: -fseh-exceptions
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -471,8 +471,6 @@
 
 llvm::ExceptionHandling
 ToolChain::GetExceptionModel(const llvm::opt::ArgList ) const {
-  if (Triple.isOSWindows() && Triple.getArch() != llvm::Triple::x86)
-return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::None;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334143 - [CUDA] Check initializers of instantiated template variables.

2018-06-06 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Jun  6 15:37:25 2018
New Revision: 334143

URL: http://llvm.org/viewvc/llvm-project?rev=334143=rev
Log:
[CUDA] Check initializers of instantiated template variables.

We were already performing checks on non-template variables,
but the checks on templated ones were missing.

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCUDA/device-var-init.cu

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=334143=334142=334143=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jun  6 15:37:25 2018
@@ -10166,6 +10166,16 @@ public:
   bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
   bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
 
+  // \brief Checks that initializers of \p Var satisfy CUDA restrictions. In
+  // case of error emits appropriate diagnostic and invalidates \p Var.
+  //
+  // \details CUDA allows only empty constructors as initializers for global
+  // variables (see E.2.3.1, CUDA 7.5). The same restriction also applies to 
all
+  // __shared__ variables whether they are local or not (they all are 
implicitly
+  // static in CUDA). One exception is that CUDA allows constant initializers
+  // for __constant__ and __device__ variables.
+  void checkAllowedCUDAInitializer(VarDecl *Var);
+
   /// Check whether NewFD is a valid overload for CUDA. Emits
   /// diagnostics and invalidates NewFD if not.
   void checkCUDATargetOverload(FunctionDecl *NewFD,

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=334143=334142=334143=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Wed Jun  6 15:37:25 2018
@@ -472,6 +472,59 @@ bool Sema::isEmptyCudaDestructor(SourceL
   return true;
 }
 
+void Sema::checkAllowedCUDAInitializer(VarDecl *VD) {
+  if (VD->isInvalidDecl() || !VD->hasInit() || !VD->hasGlobalStorage())
+return;
+  const Expr *Init = VD->getInit();
+  if (VD->hasAttr() || VD->hasAttr() ||
+  VD->hasAttr()) {
+assert(!VD->isStaticLocal() || VD->hasAttr());
+bool AllowedInit = false;
+if (const CXXConstructExpr *CE = dyn_cast(Init))
+  AllowedInit =
+  isEmptyCudaConstructor(VD->getLocation(), CE->getConstructor());
+// We'll allow constant initializers even if it's a non-empty
+// constructor according to CUDA rules. This deviates from NVCC,
+// but allows us to handle things like constexpr constructors.
+if (!AllowedInit &&
+(VD->hasAttr() || VD->hasAttr()))
+  AllowedInit = VD->getInit()->isConstantInitializer(
+  Context, VD->getType()->isReferenceType());
+
+// Also make sure that destructor, if there is one, is empty.
+if (AllowedInit)
+  if (CXXRecordDecl *RD = VD->getType()->getAsCXXRecordDecl())
+AllowedInit =
+isEmptyCudaDestructor(VD->getLocation(), RD->getDestructor());
+
+if (!AllowedInit) {
+  Diag(VD->getLocation(), VD->hasAttr()
+  ? diag::err_shared_var_init
+  : diag::err_dynamic_var_init)
+  << Init->getSourceRange();
+  VD->setInvalidDecl();
+}
+  } else {
+// This is a host-side global variable.  Check that the initializer is
+// callable from the host side.
+const FunctionDecl *InitFn = nullptr;
+if (const CXXConstructExpr *CE = dyn_cast(Init)) {
+  InitFn = CE->getConstructor();
+} else if (const CallExpr *CE = dyn_cast(Init)) {
+  InitFn = CE->getDirectCallee();
+}
+if (InitFn) {
+  CUDAFunctionTarget InitFnTarget = IdentifyCUDATarget(InitFn);
+  if (InitFnTarget != CFT_Host && InitFnTarget != CFT_HostDevice) {
+Diag(VD->getLocation(), diag::err_ref_bad_target_global_initializer)
+<< InitFnTarget << InitFn;
+Diag(InitFn->getLocation(), diag::note_previous_decl) << InitFn;
+VD->setInvalidDecl();
+  }
+}
+  }
+}
+
 // With -fcuda-host-device-constexpr, an unattributed constexpr function is
 // treated as implicitly __host__ __device__, unless:
 //  * it is a variadic function (device-side variadic functions are not

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=334143=334142=334143=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun  6 15:37:25 2018
@@ -11675,58 

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/cxx_loop_proto.proto:93
+
+message Function {
+  required StatementSeq statements = 1;

Maybe call this `LoopFunction` to distinguish from the other protobuf.



Comment at: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp:14
+/// the fuzzer with the correct command line arguments. 
 ///
 
//===--===//

Nit:  Try not to introduce whitespace at end of lines.  Depending on your 
configuration, this causes git to complain.



Comment at: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp:115
+
+} // namespace clang_fuzzer

Right now this file duplicates a lot of code from `proto_to_cxx.cpp`.  But 
assuming this file will continue to diverge from `proto_to_cxx.cpp`, I'm fine 
with the duplication for now.



Comment at: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h:22
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
+}

Instead of making a whole new header for this, can we simply add  
`LoopProtoToCxx()` and `LoopFunctionToString()` to proto_to_cxx.h?  Then 
implement them in `loop_proto_to_cxx.cpp`?


Repository:
  rC Clang

https://reviews.llvm.org/D47843



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


[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

It looks like gcc implements additional bits that can be passed to 
_atomic_exchange and friends, __ATOMIC_HLE_ACQUIRE(1 << 16) and 
__ATOMIC_HLE_RELEASE(1 << 17). Basically they're using bits above bit 16 in the 
order/memory_model as target specific flags. These constants are only defined 
when targeting X86 and they are validated to ensure they are only paired with 
the appropriate __ATOMIC_ACQUIRE or __ATOMIC_RELEASE or a stronger memory model.

As Reid said, its technically safe to drop the hints sometimes so we could use 
SubClassOptiionalData or metadata. But losing them could have performance 
implications. If you lose an XACQUIRE, the lock won't be elided as the user 
expected. And if you keep an XACQUIRE, but lose an XRELEASE the processor will 
keep trying to speculate farther than it should until it eventually hits some 
random abort trigger and has to rollback to really acquiring the lock. Both of 
these would be surprising to the user so we should make an effort not to lose 
the information as much as possible.

Here's a start at an implementation proposal with some embedded questions.
-Add the X86 __ATOMIC_HLE_ACQUIRE/__ATOMIC_HLE_RELEASE matching the gcc 
encoding value.
-Write these intrinsics to pass these flags.
-Teach CGAtomic.cpp to lower those hints to whatever IR representation we 
choose. If we choose SubclassOptionalData, we'll also need to add bitcode, LL 
parsing, and printing support. Not sure what we would need for metadata.
-Add an HLE_ACQUIRE and HLE_RELEASE prefixed version of every instruction that 
can be prefixed to the X86Instr*.td files with appropriate isel patterns. This 
matches what we do for LOCK already. This is probably somewhere between 130-150 
instructions after tblgen expansion for operand sizes, immediate vs register, 
etc. Ideally we'd devise some way to tag MachineInstr* with a lock, hle 
acquire, and hle release so that we didn't need separate instruction opcodes 
for each permutation. But this would just make things scale better is not 
required for functionality.
-Need a way to represent this in SelectionDAG so X86 specific code can create 
the right target specific nodes. Do we have a metadata infrastructure there? Or 
should we store it with the ordering MachineMemOperand? Or in SDNodeFlags?

Obviously a lot of that will take some time. I wonder if it makes sense to add 
the __ATOMIC_HLE_ACQUIRE/__ATOMIC_HLE_RELEASE constants, but ignore them in 
CGAtomics.cpp for now? We could then implement these intrinsics with the code 
we ultimately want to see there, but not implement the hints yet. Thoughts?


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


LLVM buildmaster will be restarted tonight

2018-06-06 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM 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] D47578: Do not enforce absolute path argv0 in windows

2018-06-06 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

So the best practice is, when you get a UTF-16 string from an Windows API, you 
should convert it to UTF-8 as soon as you can so that you can always process 
strings as UTF-8. Likewise, you should always keep all string in UTF-8 in 
memory and convert them to UTF-16 just before passing them to an Windows API if 
necessary. If you find yourself writing UTF-8 ↔ UTF-16 conversion code too 
frequently, that's like a signal that you are not doing text processing in 
UTF-8. Basically you need to do coding conversion up to only once for each new 
string.


https://reviews.llvm.org/D47578



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


[PATCH] D47846: [clangd] Implementation of textDocument/documentSymbol

2018-06-06 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: unittests/clangd/FindSymbolsTests.cpp:39
 }
+MATCHER_P(QName, Name, "") {
+  if (arg.containerName.empty())

I updated the other tests to use this in https://reviews.llvm.org/D47847


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47846



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


[PATCH] D47393: [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 

2018-06-06 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added reviewers: benhamilton, jolesiak, djasper.
stephanemoore added a comment.

I believe I have consensus that this is the correct change for Google 
Objective-C style.


Repository:
  rC Clang

https://reviews.llvm.org/D47393



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


[PATCH] D47578: Do not enforce absolute path argv0 in windows

2018-06-06 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

It seems you converted the same string back and forth between UTF-8 and UTF-16 
to call Windows functions and LLVM functions. That's not only a waste of time 
(which is not a big problem) but complicates the code.

I'd define `std::error GetExecutableName(std::string )` which returns a 
filename (fully expanded but not a fullpath) of the current executable in 
UTF-8. Then, add something like this at the *end* of 
`GetCommandLineArguments()`:

  SmallVector Arg0(Args[0], strlen(Args[0]);
  sys::path::remove_filename(Arg0);
  GetExecutableName(Filename);
  sys::path::append(Arg0, Filename);
  Args[0] = AllocateString(Arg0, Alloc);


https://reviews.llvm.org/D47578



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


[PATCH] D47847: [clangd] Simplify matches in FindSymbols tests

2018-06-06 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle created this revision.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov.

Instead of checking symbol name and container (scope) separately, check the
qualified name instead. This is much shorter and similar to how it is done
in the SymbolCollector tests.

Signed-off-by: Marc-Andre Laperle 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47847

Files:
  unittests/clangd/FindSymbolsTests.cpp

Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -31,9 +31,10 @@
 };
 
 // GMock helpers for matching SymbolInfos items.
-MATCHER_P(Named, Name, "") { return arg.name == Name; }
-MATCHER_P(InContainer, ContainerName, "") {
-  return arg.containerName == ContainerName;
+MATCHER_P(QName, Name, "") {
+  if (arg.containerName.empty())
+return arg.name == Name;
+  return (arg.containerName + "::" + arg.name) == Name;
 }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
 
@@ -101,12 +102,10 @@
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("global"),
-  UnorderedElementsAre(AllOf(Named("GlobalStruct"), InContainer(""),
- WithKind(SymbolKind::Struct)),
-   AllOf(Named("global_func"), InContainer(""),
- WithKind(SymbolKind::Function)),
-   AllOf(Named("global_var"), InContainer(""),
- WithKind(SymbolKind::Variable;
+  UnorderedElementsAre(
+  AllOf(QName("GlobalStruct"), WithKind(SymbolKind::Struct)),
+  AllOf(QName("global_func"), WithKind(SymbolKind::Function)),
+  AllOf(QName("global_var"), WithKind(SymbolKind::Variable;
 }
 
 TEST_F(WorkspaceSymbolsTest, Unnamed) {
@@ -118,12 +117,11 @@
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("UnnamedStruct"),
-  ElementsAre(AllOf(Named("UnnamedStruct"),
+  ElementsAre(AllOf(QName("UnnamedStruct"),
 WithKind(SymbolKind::Variable;
-  EXPECT_THAT(
-  getSymbols("InUnnamed"),
-  ElementsAre(AllOf(Named("InUnnamed"), InContainer("(anonymous struct)"),
-WithKind(SymbolKind::Field;
+  EXPECT_THAT(getSymbols("InUnnamed"),
+  ElementsAre(AllOf(QName("(anonymous struct)::InUnnamed"),
+WithKind(SymbolKind::Field;
 }
 
 TEST_F(WorkspaceSymbolsTest, InMainFile) {
@@ -146,28 +144,20 @@
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
-  EXPECT_THAT(
-  getSymbols("a"),
-  UnorderedElementsAre(AllOf(Named("ans1"), InContainer("")),
-   AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1")),
-   AllOf(Named("ai2"), InContainer("ans1::ans2";
-  EXPECT_THAT(getSymbols("::"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
-  EXPECT_THAT(getSymbols("::a"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
+  EXPECT_THAT(getSymbols("a"),
+  UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"),
+   QName("ans1::ans2"),
+   QName("ans1::ans2::ai2")));
+  EXPECT_THAT(getSymbols("::"), ElementsAre(QName("ans1")));
+  EXPECT_THAT(getSymbols("::a"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols("ans1::"),
-  UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1";
-  EXPECT_THAT(getSymbols("::ans1"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  EXPECT_THAT(getSymbols("::ans1"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols("::ans1::"),
-  UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1";
-  EXPECT_THAT(getSymbols("::ans1::ans2"),
-  ElementsAre(AllOf(Named("ans2"), InContainer("ans1";
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  EXPECT_THAT(getSymbols("::ans1::ans2"), ElementsAre(QName("ans1::ans2")));
   EXPECT_THAT(getSymbols("::ans1::ans2::"),
-  ElementsAre(AllOf(Named("ai2"), InContainer("ans1::ans2";
+  ElementsAre(QName("ans1::ans2::ai2")));
 }
 
 TEST_F(WorkspaceSymbolsTest, AnonymousNamespace) {
@@ -196,8 +186,7 @@
   #include "foo2.h"
   )cpp");
   EXPECT_THAT(getSymbols("foo"),
-  UnorderedElementsAre(AllOf(Named("foo"), InContainer("")),
-   

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 150200.
emmettneyman added a comment.

Hopefully rebased correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D47843

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
  tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,33 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "loop_proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::LoopProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- loop_proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs with loops and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
+}
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -0,0 +1,115 @@
+//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++. Extends
+// proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
+// loop. Also coutputs a different function signature that includes a 
+// size_t parameter for the loop to use.
+//
+//===--===//
+
+#include "loop_proto_to_cxx.h"
+#include "cxx_loop_proto.pb.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  if (x.is_loop_var()) {
+return os << "a[loop_ctr]";
+  } else {
+return os << "a[" << static_cast(x.varnum()) << " % s]";
+  }
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+

[PATCH] D47821: [clangd] Make workspace/symbols actually rank its results.

2018-06-06 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

This works much better! Just a nit.




Comment at: clangd/FindSymbols.cpp:20
 
+#define DEBUG_TYPE "FindSymbols"
+

nit: I don't think this is used. Remove?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47821



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


[PATCH] D47846: [clangd] Implementation of textDocument/documentSymbol

2018-06-06 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle created this revision.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov.

An AST-based approach is used to retrieve the document symbols rather than an
in-memory index query. The index is not an ideal fit to achieve this because of
the file-centric query being done here whereas the index is suited for
project-wide queries. Document symbols also includes more symbols and need to
keep the order as seen in the file.

Signed-off-by: Marc-Andre Laperle 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47846

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/symbols.test
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -44,6 +44,9 @@
 llvm::Expected>
 runWorkspaceSymbols(ClangdServer , StringRef Query, int Limit);
 
+llvm::Expected>
+runDocumentSymbols(ClangdServer , PathRef File);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -117,5 +117,12 @@
   return std::move(*Result);
 }
 
+llvm::Expected>
+runDocumentSymbols(ClangdServer , PathRef File) {
+  llvm::Optional>> Result;
+  Server.documentSymbols(File, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -22,6 +22,7 @@
 using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::ElementsAre;
+using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
 using ::testing::UnorderedElementsAre;
 
@@ -35,7 +36,13 @@
 MATCHER_P(InContainer, ContainerName, "") {
   return arg.containerName == ContainerName;
 }
+MATCHER_P(QName, Name, "") {
+  if (arg.containerName.empty())
+return arg.name == Name;
+  return (arg.containerName + "::" + arg.name) == Name;
+}
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+MATCHER_P(SymRange, Range, "") { return arg.location.range == Range; }
 
 ClangdServer::Options optsForTests() {
   auto ServerOpts = ClangdServer::optsForTest();
@@ -284,5 +291,244 @@
 AllOf(Named("foo2"), InContainer("");
 }
 
+namespace {
+class DocumentSymbolsTest : public ::testing::Test {
+public:
+  DocumentSymbolsTest()
+  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {}
+
+protected:
+  MockFSProvider FSProvider;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server;
+
+  std::vector getSymbols(PathRef File) {
+EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runDocumentSymbols(Server, File);
+EXPECT_TRUE(bool(SymbolInfos)) << "documentSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FilePath, StringRef Contents) {
+FSProvider.Files[FilePath] = Contents;
+Server.addDocument(FilePath, Contents);
+  }
+};
+} // namespace
+
+TEST_F(DocumentSymbolsTest, BasicSymbols) {
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath, R"(
+class Foo;
+class Foo {
+  Foo() {}
+  Foo(int a) {}
+  void f();
+  friend void f1();
+  friend class Friend;
+  Foo& operator=(const Foo&);
+  ~Foo();
+  class Nested {
+  void f();
+  };
+};
+class Friend {
+};
+
+void f1();
+inline void f2() {}
+static const int KInt = 2;
+const char* kStr = "123";
+
+void f1() {}
+
+namespace foo {
+// Type alias
+typedef int int32;
+using int32_t = int32;
+
+// Variable
+int v1;
+
+// Namespace
+namespace bar {
+int v2;
+}
+// Namespace alias
+namespace baz = bar;
+
+// FIXME: using declaration is not supported as the IndexAction will ignore
+// implicit declarations (the implicit using shadow declaration) by default,
+// and there is no way to customize this behavior at the moment.
+using bar::v2;
+} // namespace foo
+  )");
+  EXPECT_THAT(getSymbols(FilePath),
+  ElementsAreArray(
+  {AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo::Foo"), 

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

This contains changes from previous patch.  Please rebase.


Repository:
  rC Clang

https://reviews.llvm.org/D47843



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


[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka requested changes to this revision.
vitalybuka added inline comments.
This revision now requires changes to proceed.



Comment at: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp:23
+
+namespace clang_fuzzer {
+

I guess you already committed this patch.
Could you please try rebase to upstream, e.g. "git pull -r" and re-upload the 
review



Repository:
  rC Clang

https://reviews.llvm.org/D47843



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


[PATCH] D47845: [CUDA] Removed unused __nvvm_* builtins with non-generic pointers.

2018-06-06 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: jlebar, arsenm.
Herald added subscribers: bixia, wdng, sanjoy, jholewinski.

They were hot even hooked into CGBuiltin's machinery. Even if they were,
CUDA does not support AS-specific pointers, so there would be no legal way
no way to call these builtins.

This came up in https://reviews.llvm.org/D47154.


https://reviews.llvm.org/D47845

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def

Index: clang/include/clang/Basic/BuiltinsNVPTX.def
===
--- clang/include/clang/Basic/BuiltinsNVPTX.def
+++ clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -475,191 +475,117 @@
 // - they are used in address space analysis and optimization
 // So it does not hurt to expose them as builtins.
 //
-BUILTIN(__nvvm_atom_add_g_i, "iiD*1i", "n")
-BUILTIN(__nvvm_atom_add_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_add_gen_i, "iiD*i", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_i, "iiD*i", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_i, "iiD*i", "n", SM_60)
-BUILTIN(__nvvm_atom_add_g_l, "LiLiD*1Li", "n")
-BUILTIN(__nvvm_atom_add_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_add_gen_l, "LiLiD*Li", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_l, "LiLiD*Li", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_l, "LiLiD*Li", "n", SM_60)
-BUILTIN(__nvvm_atom_add_g_ll, "LLiLLiD*1LLi", "n")
-BUILTIN(__nvvm_atom_add_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_add_gen_ll, "LLiLLiD*LLi", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_ll, "LLiLLiD*LLi", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_ll, "LLiLLiD*LLi", "n", SM_60)
-BUILTIN(__nvvm_atom_add_g_f, "ffD*1f", "n")
-BUILTIN(__nvvm_atom_add_s_f, "ffD*3f", "n")
 BUILTIN(__nvvm_atom_add_gen_f, "ffD*f", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_f, "ffD*f", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", SM_60)
-BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n")
-BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n")
 TARGET_BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", SM_60)
 
-BUILTIN(__nvvm_atom_sub_g_i, "iiD*1i", "n")
-BUILTIN(__nvvm_atom_sub_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_sub_gen_i, "iiD*i", "n")
-BUILTIN(__nvvm_atom_sub_g_l, "LiLiD*1Li", "n")
-BUILTIN(__nvvm_atom_sub_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_sub_gen_l, "LiLiD*Li", "n")
-BUILTIN(__nvvm_atom_sub_g_ll, "LLiLLiD*1LLi", "n")
-BUILTIN(__nvvm_atom_sub_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_sub_gen_ll, "LLiLLiD*LLi", "n")
 
-BUILTIN(__nvvm_atom_xchg_g_i, "iiD*1i", "n")
-BUILTIN(__nvvm_atom_xchg_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_xchg_gen_i, "iiD*i", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_i, "iiD*i", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_i, "iiD*i", "n", SM_60)
-BUILTIN(__nvvm_atom_xchg_g_l, "LiLiD*1Li", "n")
-BUILTIN(__nvvm_atom_xchg_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_xchg_gen_l, "LiLiD*Li", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_l, "LiLiD*Li", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_l, "LiLiD*Li", "n", SM_60)
-BUILTIN(__nvvm_atom_xchg_g_ll, "LLiLLiD*1LLi", "n")
-BUILTIN(__nvvm_atom_xchg_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_xchg_gen_ll, "LLiLLiD*LLi", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_ll, "LLiLLiD*LLi", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_ll, "LLiLLiD*LLi", "n", SM_60)
 
-BUILTIN(__nvvm_atom_max_g_i, "iiD*1i", "n")
-BUILTIN(__nvvm_atom_max_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_max_gen_i, "iiD*i", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_max_gen_i, "iiD*i", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_max_gen_i, "iiD*i", "n", SM_60)
-BUILTIN(__nvvm_atom_max_g_ui, "UiUiD*1Ui", "n")
-BUILTIN(__nvvm_atom_max_s_ui, "UiUiD*3Ui", "n")
 BUILTIN(__nvvm_atom_max_gen_ui, "UiUiD*Ui", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ui, "UiUiD*Ui", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ui, "UiUiD*Ui", "n", SM_60)
-BUILTIN(__nvvm_atom_max_g_l, "LiLiD*1Li", "n")
-BUILTIN(__nvvm_atom_max_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_max_gen_l, "LiLiD*Li", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_max_gen_l, "LiLiD*Li", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_max_gen_l, "LiLiD*Li", "n", SM_60)
-BUILTIN(__nvvm_atom_max_g_ul, "ULiULiD*1ULi", "n")
-BUILTIN(__nvvm_atom_max_s_ul, "ULiULiD*3ULi", "n")
 BUILTIN(__nvvm_atom_max_gen_ul, "ULiULiD*ULi", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ul, "ULiULiD*ULi", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ul, "ULiULiD*ULi", "n", SM_60)
-BUILTIN(__nvvm_atom_max_g_ll, "LLiLLiD*1LLi", "n")
-BUILTIN(__nvvm_atom_max_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_max_gen_ll, "LLiLLiD*LLi", "n")
 TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ll, "LLiLLiD*LLi", "n", SM_60)
 TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ll, "LLiLLiD*LLi", "n", SM_60)
-BUILTIN(__nvvm_atom_max_g_ull, "ULLiULLiD*1ULLi", "n")
-BUILTIN(__nvvm_atom_max_s_ull, 

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 150192.
emmettneyman added a comment.

Took out typo'd comment


Repository:
  rC Clang

https://reviews.llvm.org/D47843

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
  tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,33 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "loop_proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::LoopProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- loop_proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs with loops and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
+}
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -0,0 +1,115 @@
+//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++. Extends
+// proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
+// loop. Also coutputs a different function signature that includes a 
+// size_t parameter for the loop to use.
+//
+//===--===//
+
+#include "loop_proto_to_cxx.h"
+#include "cxx_loop_proto.pb.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  if (x.is_loop_var()) {
+return os << "a[loop_ctr]";
+  } else {
+return os << "a[" << static_cast(x.varnum()) << " % s]";
+  }
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case 

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman created this revision.
emmettneyman added reviewers: kcc, vitalybuka, morehouse.
Herald added subscribers: cfe-commits, mgorny.

Created a new protobuf and protobuf-to-C++ "converter" that wraps the entire 
C++ code in a single for loop.

- Slightly changed cxx_proto.proto -> cxx_loop_proto.proto
- Made some changes to proto_to_cxx files to handle the new kind of protobuf
- Created ExampleClangLoopProtoFuzzer to test new protobuf and "converter"


Repository:
  rC Clang

https://reviews.llvm.org/D47843

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
  tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,33 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "loop_proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::LoopProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- loop_proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs with loops and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
+}
Index: tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
+++ tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -1,3 +1,4 @@
+//M
 //==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
 //
 // The LLVM Compiler Infrastructure
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -1,18 +1,25 @@
-//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion -==//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 //
-// Implements functions for converting between protobufs and C++.
+// Implements functions for converting between protobufs and C++. Extends
+// proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
+// loop. Also coutputs a different function signature that includes a 
+// size_t parameter for the loop to use.
 //
 //===--===//
 
-#include "proto_to_cxx.h"
-#include "cxx_proto.pb.h"
+#include "loop_proto_to_cxx.h"
+#include "cxx_loop_proto.pb.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
 
 #include 
 #include 
@@ -28,7 +35,11 @@
   return os << "(" << x.val() << ")";
 }
 std::ostream <<(std::ostream , const VarRef ) {
-  return os << "a[" << 

[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Ethan via Phabricator via cfe-commits
ethanhs added inline comments.



Comment at: lib/Headers/immintrin.h:387
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedExchange_HLEAcquire(long volatile *_Target, long _Value) {

craig.topper wrote:
> what is __DEFAULT_FN_ATTRS defined to here? Its not defined in this file and 
> should have been undeffed before leaving any other file. If its still defined 
> here, it's a bug.
When I added the _MSC_VER guard I realized this too. Not sure how this still 
compiled, as when I grepped [#|#un]def.*__DEFAULT_FN_ATTRS, every define had a 
matching undef.


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Ethan via Phabricator via cfe-commits
ethanhs updated this revision to Diff 150189.
ethanhs added a comment.

Guard to be used only under MSVC, define default FN attrs


Repository:
  rC Clang

https://reviews.llvm.org/D47672

Files:
  lib/Headers/immintrin.h
  lib/Headers/intrin.h

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -174,12 +174,6 @@
 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
 unsigned char _interlockedbittestandreset(long volatile *, long);
 unsigned char _interlockedbittestandset(long volatile *, long);
-long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
-long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
-__int64 _InterlockedcompareExchange64_HLEAcquire(__int64 volatile *, __int64,
- __int64);
-__int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64,
- __int64);
 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
 void *);
 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
@@ -287,10 +281,6 @@
 __int64 *_ComparandResult);
 short _InterlockedCompareExchange16_np(short volatile *_Destination,
short _Exchange, short _Comparand);
-__int64 _InterlockedCompareExchange64_HLEAcquire(__int64 volatile *, __int64,
- __int64);
-__int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64,
- __int64);
 __int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination,
  __int64 _Exchange, __int64 _Comparand);
 void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination,
Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -380,4 +380,76 @@
 #include 
 #endif
 
+#ifdef _MSC_VER
+/* Define the default attributes for these intrinsics */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**\
+|* Interlocked Exchange HLE
+\**/
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedExchange_HLEAcquire(long volatile *_Target, long _Value) {
+  __atomic_exchange(_Target, &_Value, &_Value, __ATOMIC_ACQUIRE);
+  return _Value;
+}
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedExchange_HLERelease(long volatile *_Target, long _Value) {
+  __atomic_exchange(_Target, &_Value, &_Value, __ATOMIC_RELEASE);
+  return _Value;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedExchange64_HLEAcquire(__int64 volatile *_Target, __int64 _Value) {
+  __atomic_exchange(_Target, &_Value, &_Value, __ATOMIC_ACQUIRE);
+  return _Value;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedExchange64_HLERelease(__int64 volatile *_Target, __int64 _Value) {
+  __atomic_exchange(_Target, &_Value, &_Value, __ATOMIC_RELEASE);
+  return _Value;
+}
+#endif
+/**\
+|* Interlocked Compare Exchange HLE
+\**/
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange_HLEAcquire(long volatile *_Destination,
+  long _Exchange, long _Comparand) {
+  __atomic_compare_exchange(_Destination, &_Comparand, &_Exchange, 0,
+__ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
+  return _Comparand;
+}
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange_HLERelease(long volatile *_Destination,
+  long _Exchange, long _Comparand) {
+  __atomic_compare_exchange(_Destination, &_Comparand, &_Exchange, 0,
+__ATOMIC_SEQ_CST, __ATOMIC_RELEASE);
+  return _Comparand;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange64_HLEAcquire(__int64 volatile *_Destination,
+  __int64 _Exchange, __int64 _Comparand) {
+  __atomic_compare_exchange(_Destination, &_Comparand, &_Exchange, 0,
+__ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
+  return _Comparand;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange64_HLERelease(__int64 volatile *_Destination,
+  __int64 _Exchange, __int64 _Comparand) {
+  

[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Headers/immintrin.h:387
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedExchange_HLEAcquire(long volatile *_Target, long _Value) {

what is __DEFAULT_FN_ATTRS defined to here? Its not defined in this file and 
should have been undeffed before leaving any other file. If its still defined 
here, it's a bug.


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


[PATCH] D47829: [Driver] Accept the -fno-shrink-wrap option for GCC compatibility

2018-06-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Is this something which is actually useful to control?  From your description, 
you want to add the flag to clang not because you actually want to use it, but 
just because you can't figure out how to pass the right flags to your clang 
build.

If it is useful, it should be implemented as a function attribute, not a global 
flag.


Repository:
  rC Clang

https://reviews.llvm.org/D47829



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


[PATCH] D47555: [HIP] Fix unbundling

2018-06-06 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 3 inline comments as done.
Closed by commit rC334128: [HIP] Fix unbundling (authored by yaxunl, committed 
by ).

Changed prior to commit:
  https://reviews.llvm.org/D47555?vs=149191=150188#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47555

Files:
  lib/Driver/Driver.cpp
  test/Driver/hip-binding.hip


Index: test/Driver/hip-binding.hip
===
--- test/Driver/hip-binding.hip
+++ test/Driver/hip-binding.hip
@@ -0,0 +1,15 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o\
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"] 
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64--linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"[[IMG2]]", "[[IMG3]]"], output: "a.out"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2808,7 +2808,7 @@
   C.MakeAction(HostAction);
   UnbundlingHostAction->registerDependentActionInfo(
   C.getSingleOffloadToolChain(),
-  /*BoundArch=*/StringRef(), Action::OFK_Host);
+  /*BoundArch=*/"all", Action::OFK_Host);
   HostAction = UnbundlingHostAction;
 }
 
@@ -3880,9 +3880,18 @@
 
   // Get the unique string identifier for this dependence and cache the
   // result.
-  CachedResults[{A, GetTriplePlusArchString(
-UI.DependentToolChain, BoundArch,
-UI.DependentOffloadKind)}] = CurI;
+  StringRef Arch;
+  if (TargetDeviceOffloadKind == Action::OFK_HIP) {
+if (UI.DependentOffloadKind == Action::OFK_Host)
+  Arch = "all";
+else
+  Arch = UI.DependentBoundArch;
+  } else
+Arch = BoundArch;
+
+  CachedResults[{A, GetTriplePlusArchString(UI.DependentToolChain, Arch,
+UI.DependentOffloadKind)}] =
+  CurI;
 }
 
 // Now that we have all the results generated, select the one that should 
be


Index: test/Driver/hip-binding.hip
===
--- test/Driver/hip-binding.hip
+++ test/Driver/hip-binding.hip
@@ -0,0 +1,15 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o\
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"] 
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64--linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2808,7 +2808,7 @@
   C.MakeAction(HostAction);
   UnbundlingHostAction->registerDependentActionInfo(
   C.getSingleOffloadToolChain(),
-  /*BoundArch=*/StringRef(), Action::OFK_Host);
+  /*BoundArch=*/"all", Action::OFK_Host);
   HostAction = UnbundlingHostAction;
 }
 
@@ -3880,9 +3880,18 @@
 
   // Get the unique string identifier for this dependence and cache the
   // result.
-  CachedResults[{A, GetTriplePlusArchString(
-UI.DependentToolChain, BoundArch,
-UI.DependentOffloadKind)}] = CurI;
+  StringRef Arch;
+  if (TargetDeviceOffloadKind == Action::OFK_HIP) {
+if (UI.DependentOffloadKind == Action::OFK_Host)
+  Arch = "all";
+else
+  Arch = UI.DependentBoundArch;
+  } else
+Arch = BoundArch;
+
+  CachedResults[{A, GetTriplePlusArchString(UI.DependentToolChain, Arch,
+UI.DependentOffloadKind)}] =
+  CurI;
 }
 
 // Now that we have all the results generated, select the one that should be

r334128 - [HIP] Fix unbundling

2018-06-06 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Jun  6 12:44:10 2018
New Revision: 334128

URL: http://llvm.org/viewvc/llvm-project?rev=334128=rev
Log:
[HIP] Fix unbundling

HIP uses clang-offload-bundler to bundle intermediate files for host
and different gpu archs together. When a file is unbundled,
clang-offload-bundler should be called only once, and the objects
for host and different gpu archs should be passed to the next
jobs. This is because Driver maintains CachedResults which maps
triple-arch string to output files for each job.

This patch fixes a bug in Driver::BuildJobsForActionNoCache which
uses incorrect key for CachedResults for HIP which causes
clang-offload-bundler being called mutiple times and incorrect
output files being used.

It only affects HIP.

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

Added:
cfe/trunk/test/Driver/hip-binding.hip
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=334128=334127=334128=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jun  6 12:44:10 2018
@@ -2808,7 +2808,7 @@ public:
   C.MakeAction(HostAction);
   UnbundlingHostAction->registerDependentActionInfo(
   C.getSingleOffloadToolChain(),
-  /*BoundArch=*/StringRef(), Action::OFK_Host);
+  /*BoundArch=*/"all", Action::OFK_Host);
   HostAction = UnbundlingHostAction;
 }
 
@@ -3880,9 +3880,18 @@ InputInfo Driver::BuildJobsForActionNoCa
 
   // Get the unique string identifier for this dependence and cache the
   // result.
-  CachedResults[{A, GetTriplePlusArchString(
-UI.DependentToolChain, BoundArch,
-UI.DependentOffloadKind)}] = CurI;
+  StringRef Arch;
+  if (TargetDeviceOffloadKind == Action::OFK_HIP) {
+if (UI.DependentOffloadKind == Action::OFK_Host)
+  Arch = "all";
+else
+  Arch = UI.DependentBoundArch;
+  } else
+Arch = BoundArch;
+
+  CachedResults[{A, GetTriplePlusArchString(UI.DependentToolChain, Arch,
+UI.DependentOffloadKind)}] =
+  CurI;
 }
 
 // Now that we have all the results generated, select the one that should 
be

Added: cfe/trunk/test/Driver/hip-binding.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-binding.hip?rev=334128=auto
==
--- cfe/trunk/test/Driver/hip-binding.hip (added)
+++ cfe/trunk/test/Driver/hip-binding.hip Wed Jun  6 12:44:10 2018
@@ -0,0 +1,15 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o\
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"] 
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64--linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"[[IMG2]]", "[[IMG3]]"], output: "a.out"


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


[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Fair enough, Then I think we should have a #ifdef _MSC_VER around them so they 
are only available when pretending to be MSVC. I believe intrin.h does that 
check very early in the file.


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


[clang-tools-extra] r334122 - Fix MSVC 'not all control paths return a value' warning. NFCI.

2018-06-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jun  6 12:31:39 2018
New Revision: 334122

URL: http://llvm.org/viewvc/llvm-project?rev=334122=rev
Log:
Fix MSVC 'not all control paths return a value' warning. NFCI.

Modified:
clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp

Modified: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp?rev=334122=334121=334122=diff
==
--- clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp Wed Jun  6 12:31:39 
2018
@@ -139,6 +139,7 @@ std::string getFormatString(OutputFormat
   case yaml:
 return "yaml";
   }
+  llvm_unreachable("Unknown OutputFormatTy");
 }
 
 int main(int argc, const char **argv) {


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


[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Ethan via Phabricator via cfe-commits
ethanhs marked an inline comment as done.
ethanhs added a comment.

In https://reviews.llvm.org/D47672#1123953, @craig.topper wrote:

> We (Intel) have discussed this a little internally. I'll be responding more 
> shortly.


Great!

FWIW, re intrin.h vs immintrin.h, the documentation for these put them in 
immintrin.h.

https://docs.microsoft.com/en-us/cpp/intrinsics/interlockedcompareexchange-intrinsic-functions#requirements
https://docs.microsoft.com/en-us/cpp/intrinsics/interlockedexchange-intrinsic-functions#requirements


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


[PATCH] D47154: Try to make builtin address space declarations not useless

2018-06-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 150179.
arsenm added a comment.

Rebase and add comment


https://reviews.llvm.org/D47154

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/BuiltinsAMDGPU.def
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenCUDA/builtins-amdgcn.cu
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/CodeGenOpenCL/numbered-address-space.cl

Index: test/CodeGenOpenCL/numbered-address-space.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/numbered-address-space.cl
@@ -0,0 +1,47 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -target-cpu tonga -S -emit-llvm -O0 -o - %s | FileCheck %s
+
+// Make sure using numbered address spaces doesn't trigger crashes when a
+// builtin has an address space parameter.
+
+// CHECK-LABEL: @test_numbered_as_to_generic(
+// CHECK: addrspacecast i32 addrspace(42)* %0 to i32*
+void test_numbered_as_to_generic(__attribute__((address_space(42))) int *arbitary_numbered_ptr) {
+  generic int* generic_ptr = arbitary_numbered_ptr;
+  *generic_ptr = 4;
+}
+
+// CHECK-LABEL: @test_numbered_as_to_builtin(
+// CHECK: addrspacecast i32 addrspace(42)* %0 to float addrspace(3)*
+void test_numbered_as_to_builtin(__attribute__((address_space(42))) int *arbitary_numbered_ptr, float src) {
+  volatile float result = __builtin_amdgcn_ds_fmaxf(arbitary_numbered_ptr, src, 0, 0, false);
+}
+
+// CHECK-LABEL: @test_generic_as_to_builtin_parameter_explicit_cast(
+// CHECK: addrspacecast i32 addrspace(3)* %0 to i32*
+void test_generic_as_to_builtin_parameter_explicit_cast(__local int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+  volatile float result = __builtin_amdgcn_ds_fmaxf((__local float*) generic_ptr, src, 0, 0, false);
+}
+
+// CHECK-LABEL: @test_generic_as_to_builtin_parameter_implicit_cast(
+// CHECK: addrspacecast i32* %2 to float addrspace(3)*
+void test_generic_as_to_builtin_parameter_implicit_cast(__local int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+
+  volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false);
+}
+
+#if 0
+// XXX: Should this compile?
+void test_generic_as_to_builtin_parameter_explicit_cast_numeric(__attribute__((address_space(3))) int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+  volatile float result = __builtin_amdgcn_ds_fmaxf((__attribute__((address_space(3))) float*) generic_ptr, src, 0, 0, false);
+}
+
+// XXX: Should this compile?
+void test_generic_as_to_builtin_parameterimplicit_cast_numeric(__attribute__((address_space(3))) int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+  volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false);
+}
+#endif
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -1,6 +1,6 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-unknown-opencl -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck -enable-var-scope %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown-opencl -S -emit-llvm -o - %s | FileCheck -enable-var-scope %s
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
@@ -20,19 +20,42 @@
   *flagout = flag;
 }
 
-// CHECK-LABEL: @test_div_scale_f32
+// CHECK-LABEL: @test_div_scale_f32(
 // CHECK: call { float, i1 } @llvm.amdgcn.div.scale.f32(float %a, float %b, i1 true)
 // CHECK-DAG: [[FLAG:%.+]] = extractvalue { float, i1 } %{{.+}}, 1
 // CHECK-DAG: [[VAL:%.+]] = extractvalue { float, i1 } %{{.+}}, 0
-// CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i32
-// CHECK: store i32 [[FLAGEXT]]
-void test_div_scale_f32(global float* out, global int* flagout, float a, float b)
+// CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i8
+// CHECK: store i8 [[FLAGEXT]]
+void test_div_scale_f32(global float* out, global bool* flagout, float a, float b)
 {
   bool flag;
   *out = __builtin_amdgcn_div_scalef(a, b, true, );
   *flagout = flag;
 }
 
+// CHECK-LABEL: @test_div_scale_f32_global_ptr(
+// CHECK: call { float, i1 } @llvm.amdgcn.div.scale.f32(float %a, float %b, i1 true)
+// CHECK-DAG: [[FLAG:%.+]] = extractvalue { float, i1 } %{{.+}}, 1
+// CHECK-DAG: [[VAL:%.+]] = extractvalue { float, i1 } %{{.+}}, 0
+// CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i8
+// CHECK: store i8 [[FLAGEXT]]
+void test_div_scale_f32_global_ptr(global float* out, global int* flagout, float a, float b, global bool* flag)
+{
+  *out = __builtin_amdgcn_div_scalef(a, b, true, flag);
+}
+
+// CHECK-LABEL: 

[PATCH] D47154: Try to make builtin address space declarations not useless

2018-06-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: include/clang/Basic/BuiltinsAMDGPU.def:49
+
+// FIXME: Need to disallow constant address space.
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")

Anastasia wrote:
> Do you plan to provide the support for it later? Or if else perhaps we should 
> elaborate more what's to be done.
I'm not sure. I don't know how to best enforce this



Comment at: lib/AST/ASTContext.cpp:9093
   unsigned AddrSpace = strtoul(Str, , 10);
-  if (End != Str && AddrSpace != 0) {
-Type = Context.getAddrSpaceQualType(Type,
-getLangASFromTargetAS(AddrSpace));
+  if (End != Str) {
+// Note AddrSpace == 0 is not the same as an unspecified address space.

Anastasia wrote:
> Could we check against LangAS::Default instead of removing this completely.
I don't think that really make sense, since that would be leaving this the 
same. I don't really need it for this patch, but I fundamentally think 
specifying address space 0 is different from an unspecified address space. 
According to the description for builtins, if no address space is specified 
than any address space will be accepted. This is different from a builtin 
requiring address space 0



Comment at: lib/CodeGen/CGBuiltin.cpp:3500
+if (auto *PtrTy = dyn_cast(PTy)) {
+  if (PtrTy->getAddressSpace() !=
+  ArgValue->getType()->getPointerAddressSpace()) {

Anastasia wrote:
> Would this be correct for OpenCL? Should we use  `isAddressSpaceSupersetOf` 
> helper instead? Would it also sort the issue with constant AS (at least for 
> OpenCL)? 
The issue I mentioned for the other builtin is that it modifies the memory, and 
doesn't have to do with the casting.

At this point the AddrSpaceCast has to be emitted. The checking if the cast is 
legal I guess would be in the SemaExpr part. I know at one point I was trying 
to use isAddressSpaceSupersetOf in rewriteBuiltinFunctionDecl, but there was 
some problem with that. I think it didn't make sense with the magic where the 
builtin without an address space is supposed to accept any address space or 
something along those lines.



Comment at: test/CodeGenOpenCL/numbered-address-space.cl:36
+#if 0
+// XXX: Should this compile?
+void 
test_generic_as_to_builtin_parameter_explicit_cast_numeric(__attribute__((address_space(3)))
 int *local_ptr, float src) {

Anastasia wrote:
> `__attribute__((address_space(N)))` is not an OpenCL feature and I think it's 
> not specified in C either? But I think generally non matching address spaces 
> don't compile in Clang. So it might be useful to disallow this?
I'm pretty sure it's a C extension. The way things seem to work now is address 
spaces are accepted anywhere and everywhere.


https://reviews.llvm.org/D47154



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


[PATCH] D47555: [HIP] Fix unbundling

2018-06-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Driver/Driver.cpp:3895
+if (UI.DependentOffloadKind == Action::OFK_Host)
+  Arch = StringRef();
+else

tra wrote:
> Should it be something more descriptive? E.g. "all" or "combined".
> 
will use "all"



Comment at: test/Driver/hip-binding.hip:5-7
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o\

tra wrote:
> Nit: you could probably just use /dev/null instead of a real temp file.
I tried /dev/null but I got 

error: no input files

I think we need a real input file here, even though an empty one.



Comment at: test/Driver/hip-binding.hip:11-12
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"] 
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler

tra wrote:
> There's currently a bundler invocation in-between these two linker commands. 
> I think you need a negative check for bundler here, too.
will do


https://reviews.llvm.org/D47555



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


[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-06-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: hans, joerg.
aaron.ballman added a comment.

In https://reviews.llvm.org/D47290#1115352, @jfb wrote:

> Hopefully this makes sense? I'm not sure I summarize my context very well. 
> I'm happy to talk about it in-person next week too.


I appreciate the in-person conversation, it helped me to understand your goals 
better.

That said, I still see this as changing the portability aspects of -Wformat 
(because we'd be changing the behavior based on the target, but this is perhaps 
different from the portability concerns @rjmccall raised) and I don't see where 
to get off that train. For instance, do we also silence -Wformat when targeting 
Windows with %ld and %d because long and int have the same size and alignment 
requirements for x86 and x86-64 (at least, I don't know about other Windows 
targets) and that is effectively baked into the platform requirements? If we 
don't, how is that situation different than the one motivating your changes?

As a user, I very much appreciate that -Wformat gives me the same diagnostics 
no matter what platform I target, so these changes make me a bit uncomfortable 
-- those warnings are not useless to me. You (rightly) asked for a concrete 
explanation of why. My reason is: the user's code here is UB and there is a 
long history demonstrating that "it's UB, but it works and does what I want!" 
suddenly changing into "it's not what I want" silently, perhaps many years down 
the line, because the optimizer suddenly got smarter and it results in 
exploitable security vulnerabilities. However, I'm no longer as scared that the 
optimizer is going to start making type-based decisions based on this format 
specifier string. I can imagine the optimizer making value-based decisions 
based on a format specifier string (like seeing a value matches a %s specifier 
and assuming the value cannot be null), but that's not this. However, I have 
had users for which UB is verboten. Period. Full stop. I doubt these users care 
at all about Apple's platform, so *this* change isn't likely to impact them, 
but the *precedent* from this change certainly could. However, perhaps making 
this pedantic as in this patch will be reasonable (I believe these folks 
already pass -pedantic when they realize that's a thing). I have to do my 
homework on that (and can't do that homework this week).


Repository:
  rC Clang

https://reviews.llvm.org/D47290



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


r334116 - [PATCH 2/2] [test] Add support for Samsung Exynos M4 (NFC)

2018-06-06 Thread Evandro Menezes via cfe-commits
Author: evandro
Date: Wed Jun  6 11:58:01 2018
New Revision: 334116

URL: http://llvm.org/viewvc/llvm-project?rev=334116=rev
Log:
[PATCH 2/2] [test] Add support for Samsung Exynos M4 (NFC)

Add test cases for Exynos M4.

Modified:
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/Driver/aarch64-cpus.c
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Preprocessor/aarch64-target-features.c
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=334116=334115=334116=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Wed Jun  6 11:58:01 2018
@@ -28,6 +28,7 @@
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m1 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m3 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m4 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // CHECK-BASIC-V8: 
"target-features"="+armv8-a,+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,+thumb-mode"
 
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8-ARM

Modified: cfe/trunk/test/Driver/aarch64-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=334116=334115=334116=diff
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (original)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Wed Jun  6 11:58:01 2018
@@ -155,6 +155,15 @@
 // M3: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "exynos-m3"
 // M3-TUNE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic"
 
+// RUN: %clang -target aarch64_be -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck 
-check-prefix=M4 %s
+// RUN: %clang -target aarch64 -mbig-endian -mcpu=exynos-m4 -### -c %s 2>&1 | 
FileCheck -check-prefix=M4 %s
+// RUN: %clang -target aarch64_be -mbig-endian -mcpu=exynos-m4 -### -c %s 2>&1 
| FileCheck -check-prefix=M4 %s
+// RUN: %clang -target aarch64_be -mtune=exynos-m4 -### -c %s 2>&1 | FileCheck 
-check-prefix=M4-TUNE %s
+// RUN: %clang -target aarch64 -mbig-endian -mtune=exynos-m4 -### -c %s 2>&1 | 
FileCheck -check-prefix=M4-TUNE %s
+// RUN: %clang -target aarch64_be -mbig-endian -mtune=exynos-m4 -### -c %s 
2>&1 | FileCheck -check-prefix=M4-TUNE %s
+// M4: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "exynos-m4"
+// M4-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+
 // RUN: %clang -target arm64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-M1 %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=exynos-m1 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-M1 %s
 // RUN: %clang -target arm64 -mtune=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-M1-TUNE %s
@@ -176,6 +185,13 @@
 // ARM64-M3: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "exynos-m3"
 // ARM64-M3-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"
 
+// RUN: %clang -target arm64 -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-M4 %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=exynos-m4 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-M4 %s
+// RUN: %clang -target arm64 -mtune=exynos-m4 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-M4-TUNE %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=exynos-m4 -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-M4-TUNE %s
+// ARM64-M4: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "exynos-m4"
+// ARM64-M4-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"
+
 // RUN: %clang -target aarch64 -mcpu=falkor -### -c %s 2>&1 | FileCheck 
-check-prefix=FALKOR %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=falkor -### -c %s 2>&1 | 
FileCheck -check-prefix=FALKOR %s
 // RUN: %clang -target aarch64 -mtune=falkor -### -c %s 2>&1 | FileCheck 
-check-prefix=FALKOR-TUNE %s
@@ -308,6 +324,15 @@
 // M3-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "exynos-m3"
 // M3-BE-TUNE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic"
 
+// RUN: %clang -target aarch64_be -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck 
-check-prefix=M4-BE %s
+// RUN: %clang -target aarch64 -mbig-endian -mcpu=exynos-m4 -### -c %s 2>&1 | 
FileCheck -check-prefix=M4-BE %s
+// RUN: %clang -target aarch64_be -mbig-endian -mcpu=exynos-m4 -### -c %s 2>&1 
| FileCheck -check-prefix=M4-BE %s
+// RUN: 

[PATCH] D47840: Make -Wgcc-compat complain about declarations in for loop init statements

2018-06-06 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added reviewers: rsmith, aaron.ballman.

The following code is invalid before C99, since we try to declare `i` inside 
the first clause of the for loop:

  void foo() {
for (int i = 0; i < 10; i++);
  }

GCC does not accept this code in c89 or gnu89, but clang does: 
https://godbolt.org/g/ZWr3nA .

If the user cares about GCC compatibility, we should probably warn about this 
if we're not in C99.

I'm not 100% thrilled that we're emitting two warnings about the same thing for 
slightly different reasons; alternatives welcome. :)


Repository:
  rC Clang

https://reviews.llvm.org/D47840

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseStmt.cpp
  test/Parser/gcc-for-loop-init-compatibility.c


Index: test/Parser/gcc-for-loop-init-compatibility.c
===
--- /dev/null
+++ test/Parser/gcc-for-loop-init-compatibility.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c89 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=gnu89 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s -DC99
+
+#ifdef C99
+// expected-no-diagnostics
+#endif
+
+void foo() {
+#ifndef C99
+  // expected-warning@+2{{GCC does not allow variable declarations in for loop 
initializers before C99}}
+#endif
+  for (int i = 0; i < 10; i++)
+;
+}
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1622,8 +1622,10 @@
 ForRange = true;
   } else if (isForInitDeclaration()) {  // for (int X = 4;
 // Parse declaration, which eats the ';'.
-if (!C99orCXXorObjC)   // Use of C99-style for loops in C90 mode?
+if (!C99orCXXorObjC) {   // Use of C99-style for loops in C90 mode?
   Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
+  Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
+}
 
 // In C++0x, "for (T NS:a" might not be a typo for ::
 bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -173,6 +173,9 @@
 def warn_gcc_attribute_location : Warning<
   "GCC does not allow an attribute in this position on a function 
declaration">, 
   InGroup;
+def warn_gcc_variable_decl_in_for_loop : Warning<
+  "GCC does not allow variable declarations in for loop initializers before "
+  "C99">, InGroup;
 def warn_attribute_no_decl : Warning<
   "attribute %0 ignored, because it is not attached to a declaration">, 
   InGroup;


Index: test/Parser/gcc-for-loop-init-compatibility.c
===
--- /dev/null
+++ test/Parser/gcc-for-loop-init-compatibility.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c89 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=gnu89 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s -DC99
+
+#ifdef C99
+// expected-no-diagnostics
+#endif
+
+void foo() {
+#ifndef C99
+  // expected-warning@+2{{GCC does not allow variable declarations in for loop initializers before C99}}
+#endif
+  for (int i = 0; i < 10; i++)
+;
+}
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1622,8 +1622,10 @@
 ForRange = true;
   } else if (isForInitDeclaration()) {  // for (int X = 4;
 // Parse declaration, which eats the ';'.
-if (!C99orCXXorObjC)   // Use of C99-style for loops in C90 mode?
+if (!C99orCXXorObjC) {   // Use of C99-style for loops in C90 mode?
   Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
+  Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
+}
 
 // In C++0x, "for (T NS:a" might not be a typo for ::
 bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -173,6 +173,9 @@
 def warn_gcc_attribute_location : Warning<
   "GCC does not allow an attribute in this position on a function declaration">, 
   InGroup;
+def warn_gcc_variable_decl_in_for_loop : Warning<
+  "GCC does not allow variable declarations in for loop initializers before "
+  "C99">, InGroup;
 def warn_attribute_no_decl : Warning<
   "attribute %0 ignored, because it is not attached to a declaration">, 
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

We (Intel) have discussed this a little internally. I'll be responding more 
shortly.




Comment at: lib/Headers/immintrin.h:386
+\**/
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS

Shouldn't these still be in intrin.h? immintrin.h is for intrinsics defined by 
Intel which these arent'.


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


[PATCH] D47784: [MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcruntime.lib

2018-06-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks for the patch!


Repository:
  rC Clang

https://reviews.llvm.org/D47784



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


[PATCH] D47784: [MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcruntime.lib

2018-06-06 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334112: [MS][ARM64]: Promote _setjmp to_setjmpex as there is 
no _setjmp in the ARM64… (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47784?vs=149984=150171#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47784

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/ms-setjmp.c

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -643,6 +643,52 @@
   ShiftedByte, llvm::ConstantInt::get(CGF.Int8Ty, 1), "bittest.res"));
 }
 
+namespace {
+enum class MSVCSetJmpKind {
+  _setjmpex,
+  _setjmp3,
+  _setjmp
+};
+}
+
+/// MSVC handles setjmp a bit differently on different platforms. On every
+/// architecture except 32-bit x86, the frame address is passed. On x86, extra
+/// parameters can be passed as variadic arguments, but we always pass none.
+static RValue EmitMSVCRTSetJmp(CodeGenFunction , MSVCSetJmpKind SJKind,
+   const CallExpr *E) {
+  llvm::Value *Arg1 = nullptr;
+  llvm::Type *Arg1Ty = nullptr;
+  StringRef Name;
+  bool IsVarArg = false;
+  if (SJKind == MSVCSetJmpKind::_setjmp3) {
+Name = "_setjmp3";
+Arg1Ty = CGF.Int32Ty;
+Arg1 = llvm::ConstantInt::get(CGF.IntTy, 0);
+IsVarArg = true;
+  } else {
+Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
+Arg1Ty = CGF.Int8PtrTy;
+Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
+  llvm::ConstantInt::get(CGF.Int32Ty, 0));
+  }
+
+  // Mark the call site and declaration with ReturnsTwice.
+  llvm::Type *ArgTypes[2] = {CGF.Int8PtrTy, Arg1Ty};
+  llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get(
+  CGF.getLLVMContext(), llvm::AttributeList::FunctionIndex,
+  llvm::Attribute::ReturnsTwice);
+  llvm::Constant *SetJmpFn = CGF.CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(CGF.IntTy, ArgTypes, IsVarArg), Name,
+  ReturnsTwiceAttr, /*Local=*/true);
+
+  llvm::Value *Buf = CGF.Builder.CreateBitOrPointerCast(
+  CGF.EmitScalarExpr(E->getArg(0)), CGF.Int8PtrTy);
+  llvm::Value *Args[] = {Buf, Arg1};
+  llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(SetJmpFn, Args);
+  CS.setAttributes(ReturnsTwiceAttr);
+  return RValue::get(CS.getInstruction());
+}
+
 // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we
 // handle them here.
 enum class CodeGenFunction::MSVCIntrin {
@@ -2957,59 +3003,19 @@
   case Builtin::BI__abnormal_termination:
   case Builtin::BI_abnormal_termination:
 return RValue::get(EmitSEHAbnormalTermination());
-  case Builtin::BI_setjmpex: {
-if (getTarget().getTriple().isOSMSVCRT()) {
-  llvm::Type *ArgTypes[] = {Int8PtrTy, Int8PtrTy};
-  llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get(
-  getLLVMContext(), llvm::AttributeList::FunctionIndex,
-  llvm::Attribute::ReturnsTwice);
-  llvm::Constant *SetJmpEx = CGM.CreateRuntimeFunction(
-  llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/false),
-  "_setjmpex", ReturnsTwiceAttr, /*Local=*/true);
-  llvm::Value *Buf = Builder.CreateBitOrPointerCast(
-  EmitScalarExpr(E->getArg(0)), Int8PtrTy);
-  llvm::Value *FrameAddr =
-  Builder.CreateCall(CGM.getIntrinsic(Intrinsic::frameaddress),
- ConstantInt::get(Int32Ty, 0));
-  llvm::Value *Args[] = {Buf, FrameAddr};
-  llvm::CallSite CS = EmitRuntimeCallOrInvoke(SetJmpEx, Args);
-  CS.setAttributes(ReturnsTwiceAttr);
-  return RValue::get(CS.getInstruction());
-}
+  case Builtin::BI_setjmpex:
+if (getTarget().getTriple().isOSMSVCRT())
+  return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmpex, E);
 break;
-  }
-  case Builtin::BI_setjmp: {
+  case Builtin::BI_setjmp:
 if (getTarget().getTriple().isOSMSVCRT()) {
-  llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get(
-  getLLVMContext(), llvm::AttributeList::FunctionIndex,
-  llvm::Attribute::ReturnsTwice);
-  llvm::Value *Buf = Builder.CreateBitOrPointerCast(
-  EmitScalarExpr(E->getArg(0)), Int8PtrTy);
-  llvm::CallSite CS;
-  if (getTarget().getTriple().getArch() == llvm::Triple::x86) {
-llvm::Type *ArgTypes[] = {Int8PtrTy, IntTy};
-llvm::Constant *SetJmp3 = CGM.CreateRuntimeFunction(
-llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/true),
-"_setjmp3", ReturnsTwiceAttr, /*Local=*/true);
-llvm::Value *Count = ConstantInt::get(IntTy, 0);
-llvm::Value *Args[] = {Buf, Count};
-CS = EmitRuntimeCallOrInvoke(SetJmp3, Args);
-  } else {
-llvm::Type *ArgTypes[] = {Int8PtrTy, Int8PtrTy};
-llvm::Constant *SetJmp = CGM.CreateRuntimeFunction(
-

r334112 - [MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcruntime.lib

2018-06-06 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Jun  6 11:39:47 2018
New Revision: 334112

URL: http://llvm.org/viewvc/llvm-project?rev=334112=rev
Log:
[MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 
libvcruntime.lib

Factor out the common setjmp call emission code.

Based on a patch by Chris January

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/ms-setjmp.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334112=334111=334112=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jun  6 11:39:47 2018
@@ -643,6 +643,52 @@ static RValue EmitBitTestIntrinsic(CodeG
   ShiftedByte, llvm::ConstantInt::get(CGF.Int8Ty, 1), "bittest.res"));
 }
 
+namespace {
+enum class MSVCSetJmpKind {
+  _setjmpex,
+  _setjmp3,
+  _setjmp
+};
+}
+
+/// MSVC handles setjmp a bit differently on different platforms. On every
+/// architecture except 32-bit x86, the frame address is passed. On x86, extra
+/// parameters can be passed as variadic arguments, but we always pass none.
+static RValue EmitMSVCRTSetJmp(CodeGenFunction , MSVCSetJmpKind SJKind,
+   const CallExpr *E) {
+  llvm::Value *Arg1 = nullptr;
+  llvm::Type *Arg1Ty = nullptr;
+  StringRef Name;
+  bool IsVarArg = false;
+  if (SJKind == MSVCSetJmpKind::_setjmp3) {
+Name = "_setjmp3";
+Arg1Ty = CGF.Int32Ty;
+Arg1 = llvm::ConstantInt::get(CGF.IntTy, 0);
+IsVarArg = true;
+  } else {
+Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
+Arg1Ty = CGF.Int8PtrTy;
+Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
+  llvm::ConstantInt::get(CGF.Int32Ty, 0));
+  }
+
+  // Mark the call site and declaration with ReturnsTwice.
+  llvm::Type *ArgTypes[2] = {CGF.Int8PtrTy, Arg1Ty};
+  llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get(
+  CGF.getLLVMContext(), llvm::AttributeList::FunctionIndex,
+  llvm::Attribute::ReturnsTwice);
+  llvm::Constant *SetJmpFn = CGF.CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(CGF.IntTy, ArgTypes, IsVarArg), Name,
+  ReturnsTwiceAttr, /*Local=*/true);
+
+  llvm::Value *Buf = CGF.Builder.CreateBitOrPointerCast(
+  CGF.EmitScalarExpr(E->getArg(0)), CGF.Int8PtrTy);
+  llvm::Value *Args[] = {Buf, Arg1};
+  llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(SetJmpFn, Args);
+  CS.setAttributes(ReturnsTwiceAttr);
+  return RValue::get(CS.getInstruction());
+}
+
 // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we
 // handle them here.
 enum class CodeGenFunction::MSVCIntrin {
@@ -2957,59 +3003,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__abnormal_termination:
   case Builtin::BI_abnormal_termination:
 return RValue::get(EmitSEHAbnormalTermination());
-  case Builtin::BI_setjmpex: {
-if (getTarget().getTriple().isOSMSVCRT()) {
-  llvm::Type *ArgTypes[] = {Int8PtrTy, Int8PtrTy};
-  llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get(
-  getLLVMContext(), llvm::AttributeList::FunctionIndex,
-  llvm::Attribute::ReturnsTwice);
-  llvm::Constant *SetJmpEx = CGM.CreateRuntimeFunction(
-  llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/false),
-  "_setjmpex", ReturnsTwiceAttr, /*Local=*/true);
-  llvm::Value *Buf = Builder.CreateBitOrPointerCast(
-  EmitScalarExpr(E->getArg(0)), Int8PtrTy);
-  llvm::Value *FrameAddr =
-  Builder.CreateCall(CGM.getIntrinsic(Intrinsic::frameaddress),
- ConstantInt::get(Int32Ty, 0));
-  llvm::Value *Args[] = {Buf, FrameAddr};
-  llvm::CallSite CS = EmitRuntimeCallOrInvoke(SetJmpEx, Args);
-  CS.setAttributes(ReturnsTwiceAttr);
-  return RValue::get(CS.getInstruction());
-}
+  case Builtin::BI_setjmpex:
+if (getTarget().getTriple().isOSMSVCRT())
+  return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmpex, E);
 break;
-  }
-  case Builtin::BI_setjmp: {
+  case Builtin::BI_setjmp:
 if (getTarget().getTriple().isOSMSVCRT()) {
-  llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get(
-  getLLVMContext(), llvm::AttributeList::FunctionIndex,
-  llvm::Attribute::ReturnsTwice);
-  llvm::Value *Buf = Builder.CreateBitOrPointerCast(
-  EmitScalarExpr(E->getArg(0)), Int8PtrTy);
-  llvm::CallSite CS;
-  if (getTarget().getTriple().getArch() == llvm::Triple::x86) {
-llvm::Type *ArgTypes[] = {Int8PtrTy, IntTy};
-llvm::Constant *SetJmp3 = CGM.CreateRuntimeFunction(
-llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/true),
-"_setjmp3", ReturnsTwiceAttr, /*Local=*/true);
-llvm::Value 

[PATCH] D47804: [CUDA] Replace 'nv_weak' attributes in CUDA headers with 'weak'.

2018-06-06 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334108: [CUDA] Replace nv_weak attributes in 
CUDA headers with weak. (authored by tra, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47804?vs=150055=150166#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47804

Files:
  lib/Headers/__clang_cuda_runtime_wrapper.h


Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -100,11 +100,17 @@
 #include "host_config.h"
 #include "host_defines.h"
 
+// Temporarily replace "nv_weak" with weak, so __attribute__((nv_weak)) in
+// cuda_device_runtime_api.h ends up being __attribute__((weak)) which is the
+// functional equivalent of what we need.
+#pragma push_macro("nv_weak")
+#define nv_weak weak
 #undef __CUDABE__
 #undef __CUDA_LIBDEVICE__
 #define __CUDACC__
 #include "cuda_runtime.h"
 
+#pragma pop_macro("nv_weak")
 #undef __CUDACC__
 #define __CUDABE__
 


Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -100,11 +100,17 @@
 #include "host_config.h"
 #include "host_defines.h"
 
+// Temporarily replace "nv_weak" with weak, so __attribute__((nv_weak)) in
+// cuda_device_runtime_api.h ends up being __attribute__((weak)) which is the
+// functional equivalent of what we need.
+#pragma push_macro("nv_weak")
+#define nv_weak weak
 #undef __CUDABE__
 #undef __CUDA_LIBDEVICE__
 #define __CUDACC__
 #include "cuda_runtime.h"
 
+#pragma pop_macro("nv_weak")
 #undef __CUDACC__
 #define __CUDABE__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334108 - [CUDA] Replace 'nv_weak' attributes in CUDA headers with 'weak'.

2018-06-06 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Jun  6 10:52:55 2018
New Revision: 334108

URL: http://llvm.org/viewvc/llvm-project?rev=334108=rev
Log:
[CUDA] Replace 'nv_weak' attributes in CUDA headers with 'weak'.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=334108=334107=334108=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Jun  6 10:52:55 
2018
@@ -100,11 +100,17 @@
 #include "host_config.h"
 #include "host_defines.h"
 
+// Temporarily replace "nv_weak" with weak, so __attribute__((nv_weak)) in
+// cuda_device_runtime_api.h ends up being __attribute__((weak)) which is the
+// functional equivalent of what we need.
+#pragma push_macro("nv_weak")
+#define nv_weak weak
 #undef __CUDABE__
 #undef __CUDA_LIBDEVICE__
 #define __CUDACC__
 #include "cuda_runtime.h"
 
+#pragma pop_macro("nv_weak")
 #undef __CUDACC__
 #define __CUDABE__
 


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


[PATCH] D47555: [HIP] Fix unbundling

2018-06-06 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Few minor nits/suggestions. LGTM otherwise.




Comment at: lib/Driver/Driver.cpp:3895
+if (UI.DependentOffloadKind == Action::OFK_Host)
+  Arch = StringRef();
+else

Should it be something more descriptive? E.g. "all" or "combined".




Comment at: test/Driver/hip-binding.hip:5-7
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o\

Nit: you could probably just use /dev/null instead of a real temp file.



Comment at: test/Driver/hip-binding.hip:11-12
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"] 
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler

There's currently a bundler invocation in-between these two linker commands. 
I think you need a negative check for bundler here, too.


https://reviews.llvm.org/D47555



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


[PATCH] D47724: [X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmaddsub/fmsubadd builtins.

2018-06-06 Thread Tomasz Krupa via Phabricator via cfe-commits
tkrupa accepted this revision.
tkrupa added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D47724



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


[PATCH] D47733: [CUDA][HIP] Set kernel calling convention before arrange function

2018-06-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

@rsmith - Richard, can you take a look?




Comment at: test/CodeGenCUDA/kernel-args.cu:1-2
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o 
- | FileCheck -check-prefix=AMDGCN %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda- -fcuda-is-device -emit-llvm %s 
-o - | FileCheck -check-prefix=NVPTX %s
+#include "Inputs/cuda.h"

Please wrap the long RUN lines.


https://reviews.llvm.org/D47733



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


[PATCH] D47267: [UnrollAndJam] Add unroll_and_jam pragma handling

2018-06-06 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

In https://reviews.llvm.org/D47267#1123318, @hfinkel wrote:

> I have a preference for using the underscores as our primary spelling. I 
> think that it's easier to read.


I agree with it being easier to read.

> I prefer we have a different syntax that we can use consistently within the 
> 'clang loop' pragmas. How about 'unroll_and_jam disable' or similar?

The code I had for #pragma clang loop (now in https://reviews.llvm.org/D47320, 
although I may not have split all the relevant parts into there) was doing the 
same thing as the unroll code. So worked the same way, I think looking like 
"#pragma clang loop unroll_and_jam(disable)" vs enable. It sounds sensible to 
me to have these look the same way as unroll clang loop pragmas, for both the 
old syntax and the new from the RFC.


https://reviews.llvm.org/D47267



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


r334106 - PR37680: fix faulty assertion condition.

2018-06-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jun  6 09:36:56 2018
New Revision: 334106

URL: http://llvm.org/viewvc/llvm-project?rev=334106=rev
Log:
PR37680: fix faulty assertion condition.

When looking up a template name, we can find an overload set containing a
function template and an unresolved non-type using declaration.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaTemplate/dependent-names.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=334106=334105=334106=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jun  6 09:36:56 2018
@@ -7292,6 +7292,7 @@ ASTContext::getOverloadedTemplateName(Un
   for (UnresolvedSetIterator I = Begin; I != End; ++I) {
 NamedDecl *D = *I;
 assert(isa(D) ||
+   isa(D) ||
(isa(D) &&
 isa(D->getUnderlyingDecl(;
 *Storage++ = D;

Modified: cfe/trunk/test/SemaTemplate/dependent-names.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-names.cpp?rev=334106=334105=334106=diff
==
--- cfe/trunk/test/SemaTemplate/dependent-names.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-names.cpp Wed Jun  6 09:36:56 2018
@@ -447,3 +447,15 @@ namespace DependentUnresolvedUsingTempla
 xb.h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace PR37680 {
+  template  struct b : a {
+using a::add;
+template int add() { return this->template add(0); }
+  };
+  struct a {
+template int add(...);
+void add(int);
+  };
+  int f(b ba) { return ba.add<0>(); }
+}


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


[PATCH] D47291: Proposal to make rtti errors more generic.

2018-06-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D47291



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


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-06 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett closed this revision.
juliehockett added a comment.

Closed in r334103 .


https://reviews.llvm.org/D43667



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


[clang-tools-extra] r334103 - [clang-doc] Implement a YAML generator

2018-06-06 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Jun  6 09:13:17 2018
New Revision: 334103

URL: http://llvm.org/viewvc/llvm-project?rev=334103=rev
Log:
[clang-doc] Implement a YAML generator

Implmenting a YAML generator from the emitted bitcode summary of
declarations. Emits one YAML file for each declaration information.

For a more detailed overview of the tool, see the design document on the 
mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html

Added:
clang-tools-extra/trunk/clang-doc/Generators.cpp
clang-tools-extra/trunk/clang-doc/Generators.h
clang-tools-extra/trunk/clang-doc/YAMLGenerator.cpp
clang-tools-extra/trunk/test/clang-doc/yaml-comments.cpp
clang-tools-extra/trunk/test/clang-doc/yaml-namespace.cpp
clang-tools-extra/trunk/test/clang-doc/yaml-record.cpp
Modified:
clang-tools-extra/trunk/clang-doc/CMakeLists.txt
clang-tools-extra/trunk/clang-doc/Representation.h
clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp

Modified: clang-tools-extra/trunk/clang-doc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/CMakeLists.txt?rev=334103=334102=334103=diff
==
--- clang-tools-extra/trunk/clang-doc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-doc/CMakeLists.txt Wed Jun  6 09:13:17 2018
@@ -8,9 +8,11 @@ add_clang_library(clangDoc
   BitcodeReader.cpp
   BitcodeWriter.cpp
   ClangDoc.cpp
+  Generators.cpp
   Mapper.cpp
   Representation.cpp
   Serialize.cpp
+  YAMLGenerator.cpp
 
   LINK_LIBS
   clangAnalysis

Added: clang-tools-extra/trunk/clang-doc/Generators.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Generators.cpp?rev=334103=auto
==
--- clang-tools-extra/trunk/clang-doc/Generators.cpp (added)
+++ clang-tools-extra/trunk/clang-doc/Generators.cpp Wed Jun  6 09:13:17 2018
@@ -0,0 +1,36 @@
+//=== Generator.cpp - Generator Registry -*- 
C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Generators.h"
+
+LLVM_INSTANTIATE_REGISTRY(clang::doc::GeneratorRegistry)
+
+namespace clang {
+namespace doc {
+
+llvm::Expected>
+findGeneratorByName(llvm::StringRef Format) {
+  for (auto I = GeneratorRegistry::begin(), E = GeneratorRegistry::end();
+   I != E; ++I) {
+if (I->getName() != Format)
+  continue;
+return I->instantiate();
+  }
+  return llvm::make_error("Can't find generator: " + Format,
+ llvm::inconvertibleErrorCode());
+}
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the generators.
+extern volatile int YAMLGeneratorAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED YAMLGeneratorAnchorDest =
+YAMLGeneratorAnchorSource;
+
+} // namespace doc
+} // namespace clang

Added: clang-tools-extra/trunk/clang-doc/Generators.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Generators.h?rev=334103=auto
==
--- clang-tools-extra/trunk/clang-doc/Generators.h (added)
+++ clang-tools-extra/trunk/clang-doc/Generators.h Wed Jun  6 09:13:17 2018
@@ -0,0 +1,41 @@
+//===-- Generators.h - ClangDoc Generator --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Generator classes for converting declaration information into documentation
+// in a specified format.
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
+
+#include "Representation.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Registry.h"
+
+namespace clang {
+namespace doc {
+
+// Abstract base class for generators.
+// This is expected to be implemented and exposed via the GeneratorRegistry.
+class Generator {
+public:
+  virtual ~Generator() = default;
+
+  // Write out the decl info in the specified format.
+  virtual bool generateDocForInfo(Info *I, llvm::raw_ostream ) = 0;
+};
+
+typedef llvm::Registry GeneratorRegistry;
+
+llvm::Expected>
+findGeneratorByName(llvm::StringRef Format);
+
+} // namespace doc
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H

Modified: clang-tools-extra/trunk/clang-doc/Representation.h
URL: 

[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments

2018-06-06 Thread Momchil Velikov via Phabricator via cfe-commits
chill updated this revision to Diff 150148.
chill added a comment.

Update: refactor a bit to not impose size overhead on targets, which don't use 
natural alignment.


https://reviews.llvm.org/D46013

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecordLayout.h
  lib/AST/ASTContext.cpp
  lib/AST/RecordLayout.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/aapcs-align.cc
  test/CodeGen/aapcs64-align.cc
  test/CodeGen/arm-arguments.c

Index: test/CodeGen/arm-arguments.c
===
--- test/CodeGen/arm-arguments.c
+++ test/CodeGen/arm-arguments.c
@@ -211,10 +211,13 @@
 // APCS-GNU: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align {{[0-9]+}} %[[b]], i8* align {{[0-9]+}} %[[c]]
 // APCS-GNU: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
 // APCS-GNU: load <4 x float>, <4 x float>* %[[d]], align 16
-// AAPCS-LABEL: define arm_aapcscc <4 x float> @f35(i32 %i, %struct.s35* byval align 8, %struct.s35* byval align 8)
-// AAPCS: %[[a:.*]] = alloca %struct.s35, align 16
-// AAPCS: %[[b:.*]] = bitcast %struct.s35* %[[a]] to i8*
-// AAPCS: %[[c:.*]] = bitcast %struct.s35* %0 to i8*
-// AAPCS: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %[[b]], i8* align 8 %[[c]]
-// AAPCS: %[[d:.*]] = bitcast %struct.s35* %[[a]] to <4 x float>*
-// AAPCS: load <4 x float>, <4 x float>* %[[d]], align 16
+
+// AAPCS-LABEL: define arm_aapcscc <4 x float> @f35(i32 %i, %struct.s35* byval align 4 %s1, %struct.s35* byval align 4 %s2)
+// AAPCS: %[[a_addr:.*]] = alloca <4 x float>, align 16
+// AAPCS: %[[b_addr:.*]] = alloca <4 x float>, align 16
+// AAPCS: %[[p1:.*]] = bitcast %struct.s35* %s1 to <4 x float>*
+// AAPCS: %[[a:.*]] = load <4 x float>, <4 x float>* %[[p1]], align 4
+// AAPCS: %[[p2:.*]] = bitcast %struct.s35* %s2 to <4 x float>*
+// AAPCS: %[[b:.*]] = load <4 x float>, <4 x float>* %[[p2]], align 4
+// AAPCS: store <4 x float> %[[a]], <4 x float>* %[[a_addr]], align 16
+// AAPCS: store <4 x float> %[[b]], <4 x float>* %[[b_addr]], align 16
Index: test/CodeGen/aapcs64-align.cc
===
--- /dev/null
+++ test/CodeGen/aapcs64-align.cc
@@ -0,0 +1,103 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-none-eabi \
+// RUN:   -O2 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+extern "C" {
+
+// Base case, nothing interesting.
+struct S {
+  long x, y;
+};
+
+void f0(long, S);
+void f0m(long, long, long, long, long, S);
+void g0() {
+  S s = {6, 7};
+  f0(1, s);
+  f0m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g0
+// CHECK: call void @f0(i64 1, [2 x i64] [i64 6, i64 7]
+// CHECK: call void @f0m{{.*}}[2 x i64] [i64 6, i64 7]
+// CHECK: declare void @f0(i64, [2 x i64])
+// CHECK: declare void @f0m(i64, i64, i64, i64, i64, [2 x i64])
+
+// Aligned struct, passed according to its natural alignment.
+struct __attribute__((aligned(16))) S16 {
+  long x, y;
+} s16;
+
+void f1(long, S16);
+void f1m(long, long, long, long, long, S16);
+void g1() {
+  S16 s = {6, 7};
+  f1(1, s);
+  f1m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g1
+// CHECK: call void @f1{{.*}}[2 x i64] [i64 6, i64 7]
+// CHECK: call void @f1m{{.*}}[2 x i64] [i64 6, i64 7]
+// CHECK: declare void @f1(i64, [2 x i64])
+// CHECK: declare void @f1m(i64, i64, i64, i64, i64, [2 x i64])
+
+// Increased natural alignment.
+struct SF16 {
+  long x __attribute__((aligned(16)));
+  long y;
+};
+
+void f3(long, SF16);
+void f3m(long, long, long, long, long, SF16);
+void g3() {
+  SF16 s = {6, 7};
+  f3(1, s);
+  f3m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g3
+// CHECK: call void @f3(i64 1, i128 129127208515966861318)
+// CHECK: call void @f3m(i64 1, i64 2, i64 3, i64 4, i64 5, i128 129127208515966861318)
+// CHECK: declare void @f3(i64, i128)
+// CHECK: declare void @f3m(i64, i64, i64, i64, i64, i128)
+
+
+// Packed structure.
+struct  __attribute__((packed)) P {
+  int x;
+  long u;
+};
+
+void f4(int, P);
+void f4m(int, int, int, int, int, P);
+void g4() {
+  P s = {6, 7};
+  f4(1, s);
+  f4m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g4()
+// CHECK: call void @f4(i32 1, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: declare void @f4(i32, [2 x i64])
+// CHECK: declare void @f4m(i32, i32, i32, i32, i32, [2 x i64])
+
+
+// Packed structure, overaligned, same as above.
+struct  __attribute__((packed, aligned(16))) P16 {
+  int x;
+  long y;
+};
+
+void f5(int, P16);
+void f5m(int, int, int, int, int, P16);
+  void g5() {
+P16 s = {6, 7};
+f5(1, s);
+f5m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define void @g5()
+// CHECK: call void @f5(i32 1, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: void @f5m(i32 1, i32 2, i32 3, i32 4, i32 5, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: declare void @f5(i32, [2 x i64])
+// CHECK: declare void @f5m(i32, i32, i32, i32, i32, [2 x i64])

[PATCH] D47829: [Driver] Accept the -fno-shrink-wrap option for GCC compatibility

2018-06-06 Thread Simon Dardis via Phabricator via cfe-commits
sdardis created this revision.
sdardis added a reviewer: rsmith.
Herald added a reviewer: javed.absar.
Herald added subscribers: atanasyan, kristof.beyls, arichardson.

As reported in GCC bug #86069, LLVM currently provokes a bug in GCC where
objects compiled for MIPS with PIC and optimizations where shrink wrapped
functions can attempt to access the global pointer's spill slot before the 
global
pointer is spilled. This bug is present in GCC since at least 4.9.2, and 
affects the
AArch64 backend when LLVM is built for a MIPS host.

However, setting CMAKE_C_FLAGS and CMAKE_CXX_FLAGS affects the compiler-rt
tests which rely on the just built clang rather than the host or cross GCC.
Since Clang doesn't support this flag, so the tests spuriously fail.

Unfortunately, not all targets support shrink wrapping in LLVM at this time,
so providing -fshrink-wrap would expose users to any number of wrong-codegen
issues.

For targets that do support shrink wrapping, this option performs as expected.


Repository:
  rC Clang

https://reviews.llvm.org/D47829

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/shrink-wrap.c


Index: test/Driver/shrink-wrap.c
===
--- /dev/null
+++ test/Driver/shrink-wrap.c
@@ -0,0 +1,12 @@
+// RUN: %clang -### %s -fno-shrink-wrap 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO < %t %s
+
+// The below case should be handled when shrink wrapping is available for all
+// targets.
+
+// FIXME: %clang -### %s -fshrink-wrap 2> %t
+// FIXME: FileCheck --check-prefix=CHECK-YES < %t %s
+
+// CHECK-NO: "-mllvm" "-enable-shrink-wrap=false"
+
+// CHECK-YES: "-mllvm" "-enable-shrink-wrap=true"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4047,6 +4047,11 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ);
 
+  if (Args.hasArg(options::OPT_fno_shrink_wrap)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-enable-shrink-wrap=false");
+  }
+
   // -fno-strict-overflow implies -fwrapv if it isn't disabled, but
   // -fstrict-overflow won't turn off an explicitly enabled -fwrapv.
   if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1388,6 +1388,8 @@
   HelpText<"Do not include column number on diagnostics">;
 def fno_show_source_location : Flag<["-"], "fno-show-source-location">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not include source location information 
with diagnostics">;
+def fno_shrink_wrap : Flag<["-"], "fno-shrink-wrap">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable shrink wrapping">;
 def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, 
Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in 
diagnostics">;
 def fno_spell_checking : Flag<["-"], "fno-spell-checking">, Group,


Index: test/Driver/shrink-wrap.c
===
--- /dev/null
+++ test/Driver/shrink-wrap.c
@@ -0,0 +1,12 @@
+// RUN: %clang -### %s -fno-shrink-wrap 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO < %t %s
+
+// The below case should be handled when shrink wrapping is available for all
+// targets.
+
+// FIXME: %clang -### %s -fshrink-wrap 2> %t
+// FIXME: FileCheck --check-prefix=CHECK-YES < %t %s
+
+// CHECK-NO: "-mllvm" "-enable-shrink-wrap=false"
+
+// CHECK-YES: "-mllvm" "-enable-shrink-wrap=true"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4047,6 +4047,11 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ);
 
+  if (Args.hasArg(options::OPT_fno_shrink_wrap)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-enable-shrink-wrap=false");
+  }
+
   // -fno-strict-overflow implies -fwrapv if it isn't disabled, but
   // -fstrict-overflow won't turn off an explicitly enabled -fwrapv.
   if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1388,6 +1388,8 @@
   HelpText<"Do not include column number on diagnostics">;
 def fno_show_source_location : Flag<["-"], "fno-show-source-location">, Group,
   Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">;
+def fno_shrink_wrap : Flag<["-"], "fno-shrink-wrap">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable shrink wrapping">;
 def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, 

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-06-06 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: docs/clang-tidy/checks/bugprone-exception-escape.rst:6
+
+Finds functions which should not throw exceptions:
+* Destructors

I don't think the check just finds functions that should not throw exceptions. 
I suppose, it finds `throw` statements inside them (or maybe it goes slightly 
deeper - the documentation should explain this in more detail). See also the 
comment @dberris left below.



Comment at: docs/clang-tidy/checks/bugprone-exception-escape.rst:31
+   ``WinMain()`` in the Windows API to the list of the funcions which should
+   not throw.. Default value is empty string.
+

nit: Double period after `throw`.



Comment at: docs/clang-tidy/checks/bugprone-exception-escape.rst:31
+   ``WinMain()`` in the Windows API to the list of the funcions which should
+   not throw.. Default value is empty string.
+

alexfh wrote:
> nit: Double period after `throw`.
nit: "an empty string"
Same below.



Comment at: test/clang-tidy/bugprone-exception-escape.cpp:178
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' 
throws
+  implicit_int_thrower();

baloghadamsoftware wrote:
> lebedev.ri wrote:
> > baloghadamsoftware wrote:
> > > dberris wrote:
> > > > How deep does this go? Say we have a call to a function that's extern 
> > > > which doesn't have 'noexcept' nor a dynamic exception specifier -- do 
> > > > we assume that the call to an extern function may throw? Does that 
> > > > warn? What does the warning look like? Should it warn? How about when 
> > > > you call a function through a function pointer?
> > > > 
> > > > The documentation should cover these cases and/or more explicitly say 
> > > > in the warning that an exception may throw in a noexcept function 
> > > > (rather than just "function <...> throws").
> > > We take the most conservative way here. We assume that a function throws 
> > > if and only if its body has a throw statement or its header has the (old) 
> > > throw() exception specification. We do not follow function pointers.
> > While i realize it may have more noise, it may be nice to have a more 
> > pedantic mode (guarded by an option?).
> > E.g. `noexcept` propagation, much like `const` on methods propagation.
> > Or at least a test that shows that it does not happen, unless i simply did 
> > not notice it :)
> This could be an enhancement in the future, yes.
Please address the original comment here. In particular, the warning message 
should be clearer (that an exception may be thrown in a function that should 
not throw exceptions).


https://reviews.llvm.org/D33537



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


[PATCH] D46602: [clang-tidy] Store checks profiling info as JSON files

2018-06-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334101: [clang-tidy] Store checks profiling info as JSON 
files (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46602?vs=149933=150142#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46602

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidy.h
  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.h
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/index.rst
  
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
  
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
  
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-store-check-profile-one-tu.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
@@ -363,7 +363,8 @@
 
   std::unique_ptr Profiling;
   if (Context.getEnableProfiling()) {
-Profiling = llvm::make_unique();
+Profiling = llvm::make_unique(
+Context.getProfileStorageParams());
 FinderOptions.CheckProfiling.emplace(Profiling->Records);
   }
 
@@ -492,7 +493,7 @@
   const CompilationDatabase ,
   ArrayRef InputFiles,
   llvm::IntrusiveRefCntPtr BaseFS,
-  bool EnableCheckProfile) {
+  bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
 
@@ -533,6 +534,7 @@
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
   Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
   Context.setEnableProfiling(EnableCheckProfile);
+  Context.setProfileStoragePrefix(StoreCheckProfile);
 
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
 
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H
 
 #include "ClangTidyOptions.h"
+#include "ClangTidyProfiling.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Core/Diagnostic.h"
@@ -169,6 +170,11 @@
   void setEnableProfiling(bool Profile);
   bool getEnableProfiling() const { return Profile; }
 
+  /// \brief Control storage of profile date.
+  void setProfileStoragePrefix(StringRef ProfilePrefix);
+  llvm::Optional
+  getProfileStorageParams() const;
+
   /// \brief Should be called when starting to process new translation unit.
   void setCurrentBuildDirectory(StringRef BuildDirectory) {
 CurrentBuildDirectory = BuildDirectory;
@@ -216,6 +222,7 @@
   llvm::DenseMap CheckNamesByDiagnosticID;
 
   bool Profile;
+  std::string ProfilePrefix;
 
   bool AllowEnablingAnalyzerAlphaCheckers;
 };
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.cpp
@@ -9,56 +9,84 @@
 
 #include "ClangTidyProfiling.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
 
 #define DEBUG_TYPE "clang-tidy-profiling"
 
 namespace clang {
 namespace tidy {
 
-void ClangTidyProfiling::preprocess() {
-  // Convert from a insertion-friendly map to sort-friendly vector.
-  Timers.clear();
-  Timers.reserve(Records.size());
-  for (const auto  : Records) {
-Timers.emplace_back(P.getValue(), P.getKey());
-Total += P.getValue();
-  }
-  assert(Timers.size() == Records.size() && "Size mismatch after processing");
+ClangTidyProfiling::StorageParams::StorageParams(llvm::StringRef ProfilePrefix,
+ llvm::StringRef SourceFile)
+: Timestamp(std::chrono::system_clock::now()), SourceFilename(SourceFile) {
+  llvm::SmallString<32> TimestampStr;
+  llvm::raw_svector_ostream OS(TimestampStr);
+  llvm::format_provider::format(Timestamp, OS,
+ "%Y%m%d%H%M%S%N");
+
+  llvm::SmallString<256> FinalPrefix(ProfilePrefix);
+  

[clang-tools-extra] r334101 - [clang-tidy] Store checks profiling info as JSON files

2018-06-06 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Jun  6 08:07:51 2018
New Revision: 334101

URL: http://llvm.org/viewvc/llvm-project?rev=334101=rev
Log:
[clang-tidy] Store checks profiling info as JSON files

Summary:
Continuation of D46504.

Example output:
```
  $ clang-tidy -enable-check-profile -store-check-profile=. 
-checks=-*,readability-function-size source.cpp
  $ # Note that there won't be timings table printed to the console.
  $ cat *.json
  {
  "file": "/path/to/source.cpp",
  "timestamp": "2018-05-16 16:13:18.717446360",
  "profile": {
"time.clang-tidy.readability-function-size.wall": 1.0421266555786133e+00,
"time.clang-tidy.readability-function-size.user": 9.208840005421e-01,
"time.clang-tidy.readability-function-size.sys": 1.24188974e-01
  }
  }
```

There are two arguments that control profile storage:

* `-store-check-profile=`

  By default reports are printed in tabulated format to stderr. When this option
  is passed, these per-TU profiles are instead stored as JSON.
  If the prefix is not an absolute path, it is considered to be relative to the
  directory from where you have run :program:`clang-tidy`. All `.` and `..`
  patterns in the path are collapsed, and symlinks are resolved.

  Example:
  Let's suppose you have a source file named `example.cpp`, located in
  `/source` directory.

  * If you specify `-store-check-profile=/tmp`, then the profile will be saved
to `/tmp/-example.cpp.json`

  * If you run :program:`clang-tidy` from within `/foo` directory, and specify
`-store-check-profile=.`, then the profile will still be saved to
`/foo/-example.cpp.json`

Reviewers: alexfh, sbenza, george.karpenkov, NoQ, aaron.ballman

Reviewed By: alexfh, george.karpenkov, aaron.ballman

Subscribers: Quuxplusone, JonasToth, aaron.ballman, llvm-commits, rja, 
Eugene.Zelenko, xazax.hun, mgrang, cfe-commits

Tags: #clang-tools-extra

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

Added:

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.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=334101=334100=334101=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Jun  6 08:07:51 2018
@@ -363,7 +363,8 @@ ClangTidyASTConsumerFactory::CreateASTCo
 
   std::unique_ptr Profiling;
   if (Context.getEnableProfiling()) {
-Profiling = llvm::make_unique();
+Profiling = llvm::make_unique(
+Context.getProfileStorageParams());
 FinderOptions.CheckProfiling.emplace(Profiling->Records);
   }
 
@@ -492,7 +493,7 @@ void runClangTidy(clang::tidy::ClangTidy
   const CompilationDatabase ,
   ArrayRef InputFiles,
   llvm::IntrusiveRefCntPtr BaseFS,
-  bool EnableCheckProfile) {
+  bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
 
@@ -533,6 +534,7 @@ void runClangTidy(clang::tidy::ClangTidy
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
   Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
   Context.setEnableProfiling(EnableCheckProfile);
+  Context.setProfileStoragePrefix(StoreCheckProfile);
 
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
 

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=334101=334100=334101=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Wed Jun  6 08:07:51 2018
@@ -227,11 +227,15 @@ getCheckOptions(const ClangTidyOptions &
 ///
 /// \param EnableCheckProfile If provided, it enables check profile collection
 /// in MatchFinder, and will contain the result of the profile.
+/// \param StoreCheckProfile If provided, and EnableCheckProfile is true,
+/// the profile will not be output to stderr, but will instead be 

[PATCH] D47821: [clangd] Make workspace/symbols actually rank its results.

2018-06-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clangd/FindSymbols.cpp:159
+else
+  return;
+Relevance.merge(Sym);

Should we add a log statement here? IMO, this rarely happens? If it happens, it 
means that the fuzzy matcher algorithms used by index and clangd side have 
disagreement.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47821



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


[PATCH] D45927: [clang-tidy] [modernize-use-auto] Correct way to calculate a type name length for multi-token types

2018-06-06 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


https://reviews.llvm.org/D45927



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


[PATCH] D46602: [clang-tidy] Store checks profiling info as JSON files

2018-06-06 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D46602#1123631, @alexfh wrote:

> LG


Thank you for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D46602



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


[PATCH] D46602: [clang-tidy] Store checks profiling info as JSON files

2018-06-06 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


Repository:
  rL LLVM

https://reviews.llvm.org/D46602



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


[PATCH] D47720: [DebugInfo] Inline for without DebugLocation

2018-06-06 Thread Anastasis via Phabricator via cfe-commits
gramanas updated this revision to Diff 150135.
gramanas added a comment.

make code more readable


Repository:
  rC Clang

https://reviews.llvm.org/D47720

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/debug-info-inline-for.c


Index: test/CodeGen/debug-info-inline-for.c
===
--- /dev/null
+++ test/CodeGen/debug-info-inline-for.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// Check that clang emits Debug location in the phi instruction
+
+int func(int n) {
+  int a;
+  for(a = 10; a>0 && n++; a--);
+  return n;
+}
+
+// CHECK: land.end:
+// CHECK-NEXT: {{.*}} = phi i1 {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+
+// CHECK: ![[DbgLoc]] = !DILocation(line: 0
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3428,6 +3428,12 @@
   // Insert an entry into the phi node for the edge with the value of RHSCond.
   PN->addIncoming(RHSCond, RHSBlock);
 
+  // Artificial location to preserve the scope information
+  {
+auto NL = ApplyDebugLocation::CreateArtificial(CGF);
+PN->setDebugLoc(Builder.getCurrentDebugLocation());
+  }
+
   // ZExt result to int.
   return Builder.CreateZExtOrBitCast(PN, ResTy, "land.ext");
 }


Index: test/CodeGen/debug-info-inline-for.c
===
--- /dev/null
+++ test/CodeGen/debug-info-inline-for.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// Check that clang emits Debug location in the phi instruction
+
+int func(int n) {
+  int a;
+  for(a = 10; a>0 && n++; a--);
+  return n;
+}
+
+// CHECK: land.end:
+// CHECK-NEXT: {{.*}} = phi i1 {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+
+// CHECK: ![[DbgLoc]] = !DILocation(line: 0
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3428,6 +3428,12 @@
   // Insert an entry into the phi node for the edge with the value of RHSCond.
   PN->addIncoming(RHSCond, RHSBlock);
 
+  // Artificial location to preserve the scope information
+  {
+auto NL = ApplyDebugLocation::CreateArtificial(CGF);
+PN->setDebugLoc(Builder.getCurrentDebugLocation());
+  }
+
   // ZExt result to int.
   return Builder.CreateZExtOrBitCast(PN, ResTy, "land.ext");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47097: [DebugInfo] Preserve scope in auto generated StoreInst

2018-06-06 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1949
 
+  // Set artificial debug location in order to preserve the scope
+  auto DL = ApplyDebugLocation::CreateArtificial(*this);

Can you make that comment elaborate more about why this is being done? For 
example, you could add an "otherwise mem2reg will ..."

Also please note that all comments in LLVM need to be full sentences with a "." 
at the end :-)


Repository:
  rC Clang

https://reviews.llvm.org/D47097



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


[PATCH] D47375: [Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.

2018-06-06 Thread pierre gousseau via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334096: [Driver] Add flag --dependent-lib=... 
when enabling asan or ubsan on PS4. (authored by pgousseau, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47375?vs=150124=150130#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47375

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
  cfe/trunk/lib/Driver/ToolChains/PS4CPU.h
  cfe/trunk/test/Driver/fsanitize.c
  cfe/trunk/test/Driver/sanitizer-ld.c


Index: cfe/trunk/lib/Driver/ToolChains/PS4CPU.h
===
--- cfe/trunk/lib/Driver/ToolChains/PS4CPU.h
+++ cfe/trunk/lib/Driver/ToolChains/PS4CPU.h
@@ -23,6 +23,8 @@
 void addProfileRTArgs(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addSanitizerArgs(const ToolChain , llvm::opt::ArgStringList );
+
 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
 public:
   Assemble(const ToolChain )
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3687,9 +3687,11 @@
   if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
 ABICompatArg->render(Args, CmdArgs);
 
-  // Add runtime flag for PS4 when PGO or Coverage are enabled.
-  if (RawTriple.isPS4CPU())
+  // Add runtime flag for PS4 when PGO, coverage, or sanitizers are enabled.
+  if (RawTriple.isPS4CPU()) {
 PS4cpu::addProfileRTArgs(getToolChain(), Args, CmdArgs);
+PS4cpu::addSanitizerArgs(getToolChain(), CmdArgs);
+  }
 
   // Pass options for controlling the default header search paths.
   if (Args.hasArg(options::OPT_nostdinc)) {
Index: cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
+++ cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
@@ -76,6 +76,15 @@
   }
 }
 
+void tools::PS4cpu::addSanitizerArgs(const ToolChain ,
+ ArgStringList ) {
+  const SanitizerArgs  = TC.getSanitizerArgs();
+  if (SanArgs.needsUbsanRt())
+CmdArgs.push_back("--dependent-lib=libSceDbgUBSanitizer_stub_weak.a");
+  if (SanArgs.needsAsanRt())
+CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
+}
+
 static void ConstructPS4LinkJob(const Tool , Compilation ,
 const JobAction , const InputInfo ,
 const InputInfoList ,
Index: cfe/trunk/test/Driver/sanitizer-ld.c
===
--- cfe/trunk/test/Driver/sanitizer-ld.c
+++ cfe/trunk/test/Driver/sanitizer-ld.c
@@ -646,20 +646,25 @@
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
+// CHECK-UBSAN-PS4: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
 
 // RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-PS4 %s
+// CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
 // CHECK-ASAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-AUBSAN-PS4 %s
+// CHECK-AUBSAN-PS4-NOT: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
+// CHECK-AUBSAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
+// CHECK-AUBSAN-PS4-NOT: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
 // CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -621,6 +621,8 @@
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-PS4
 // Make sure there are no *.{o,bc} or -l passed before the ASan library.
 // CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
+// CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
+// CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 

r334096 - [Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.

2018-06-06 Thread Pierre Gousseau via cfe-commits
Author: pgousseau
Date: Wed Jun  6 07:04:15 2018
New Revision: 334096

URL: http://llvm.org/viewvc/llvm-project?rev=334096=rev
Log:
[Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.

NFC for targets other than PS4.

Simplify users' workflow when enabling asan or ubsan and calling the linker 
separately.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
cfe/trunk/lib/Driver/ToolChains/PS4CPU.h
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=334096=334095=334096=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jun  6 07:04:15 2018
@@ -3687,9 +3687,11 @@ void Clang::ConstructJob(Compilation ,
   if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
 ABICompatArg->render(Args, CmdArgs);
 
-  // Add runtime flag for PS4 when PGO or Coverage are enabled.
-  if (RawTriple.isPS4CPU())
+  // Add runtime flag for PS4 when PGO, coverage, or sanitizers are enabled.
+  if (RawTriple.isPS4CPU()) {
 PS4cpu::addProfileRTArgs(getToolChain(), Args, CmdArgs);
+PS4cpu::addSanitizerArgs(getToolChain(), CmdArgs);
+  }
 
   // Pass options for controlling the default header search paths.
   if (Args.hasArg(options::OPT_nostdinc)) {

Modified: cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp?rev=334096=334095=334096=diff
==
--- cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp Wed Jun  6 07:04:15 2018
@@ -76,6 +76,15 @@ static void AddPS4SanitizerArgs(const To
   }
 }
 
+void tools::PS4cpu::addSanitizerArgs(const ToolChain ,
+ ArgStringList ) {
+  const SanitizerArgs  = TC.getSanitizerArgs();
+  if (SanArgs.needsUbsanRt())
+CmdArgs.push_back("--dependent-lib=libSceDbgUBSanitizer_stub_weak.a");
+  if (SanArgs.needsAsanRt())
+CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
+}
+
 static void ConstructPS4LinkJob(const Tool , Compilation ,
 const JobAction , const InputInfo ,
 const InputInfoList ,

Modified: cfe/trunk/lib/Driver/ToolChains/PS4CPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/PS4CPU.h?rev=334096=334095=334096=diff
==
--- cfe/trunk/lib/Driver/ToolChains/PS4CPU.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/PS4CPU.h Wed Jun  6 07:04:15 2018
@@ -23,6 +23,8 @@ namespace PS4cpu {
 void addProfileRTArgs(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addSanitizerArgs(const ToolChain , llvm::opt::ArgStringList );
+
 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
 public:
   Assemble(const ToolChain )

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=334096=334095=334096=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Wed Jun  6 07:04:15 2018
@@ -621,6 +621,8 @@
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-PS4
 // Make sure there are no *.{o,bc} or -l passed before the ASan library.
 // CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
+// CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
+// CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-MINIMAL

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=334096=334095=334096=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Wed Jun  6 07:04:15 2018
@@ -646,6 +646,7 @@
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
+// CHECK-UBSAN-PS4: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-UBSAN-PS4: 

[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-06-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

@tra Thank you for your comments and help with the patch.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47375: [Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.

2018-06-06 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau updated this revision to Diff 150124.
pgousseau added a comment.

Updated patch with requested changes.


https://reviews.llvm.org/D47375

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/PS4CPU.cpp
  lib/Driver/ToolChains/PS4CPU.h
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -646,20 +646,25 @@
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
+// CHECK-UBSAN-PS4: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
 
 // RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-PS4 %s
+// CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
 // CHECK-ASAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-AUBSAN-PS4 %s
+// CHECK-AUBSAN-PS4-NOT: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
+// CHECK-AUBSAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
+// CHECK-AUBSAN-PS4-NOT: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
 // CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -621,6 +621,8 @@
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-PS4
 // Make sure there are no *.{o,bc} or -l passed before the ASan library.
 // CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
+// CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a
+// CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-MINIMAL
Index: lib/Driver/ToolChains/PS4CPU.h
===
--- lib/Driver/ToolChains/PS4CPU.h
+++ lib/Driver/ToolChains/PS4CPU.h
@@ -23,6 +23,8 @@
 void addProfileRTArgs(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
+void addSanitizerArgs(const ToolChain , llvm::opt::ArgStringList );
+
 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
 public:
   Assemble(const ToolChain )
Index: lib/Driver/ToolChains/PS4CPU.cpp
===
--- lib/Driver/ToolChains/PS4CPU.cpp
+++ lib/Driver/ToolChains/PS4CPU.cpp
@@ -76,6 +76,15 @@
   }
 }
 
+void tools::PS4cpu::addSanitizerArgs(const ToolChain ,
+ ArgStringList ) {
+  const SanitizerArgs  = TC.getSanitizerArgs();
+  if (SanArgs.needsUbsanRt())
+CmdArgs.push_back("--dependent-lib=libSceDbgUBSanitizer_stub_weak.a");
+  if (SanArgs.needsAsanRt())
+CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
+}
+
 static void ConstructPS4LinkJob(const Tool , Compilation ,
 const JobAction , const InputInfo ,
 const InputInfoList ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3687,9 +3687,11 @@
   if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
 ABICompatArg->render(Args, CmdArgs);
 
-  // Add runtime flag for PS4 when PGO or Coverage are enabled.
-  if (RawTriple.isPS4CPU())
+  // Add runtime flag for PS4 when PGO, coverage, or sanitizers are enabled.
+  if (RawTriple.isPS4CPU()) {
 PS4cpu::addProfileRTArgs(getToolChain(), Args, CmdArgs);
+PS4cpu::addSanitizerArgs(getToolChain(), CmdArgs);
+  }
 
   // Pass options for controlling the default header search paths.
   if (Args.hasArg(options::OPT_nostdinc)) {


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -646,20 +646,25 @@
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
+// CHECK-UBSAN-PS4: --dependent-lib=libSceDbgUBSanitizer_stub_weak.a
 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // 

[PATCH] D47097: [DebugInfo] Preserve scope in auto generated StoreInst

2018-06-06 Thread Anastasis via Phabricator via cfe-commits
gramanas added a comment.

What about this? Ping!


Repository:
  rC Clang

https://reviews.llvm.org/D47097



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


[clang-tools-extra] r334093 - Add semicolon to recent MSVC fix.

2018-06-06 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Jun  6 06:28:49 2018
New Revision: 334093

URL: http://llvm.org/viewvc/llvm-project?rev=334093=rev
Log:
Add semicolon to recent MSVC fix.

Modified:
clang-tools-extra/trunk/clangd/Quality.cpp

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=334093=334092=334093=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Wed Jun  6 06:28:49 2018
@@ -90,7 +90,7 @@ categorize(const index::SymbolInfo ) {
 case index::SymbolKind::Unknown:
   return SymbolQualitySignals::Unknown;
   }
-  llvm_unreachable("Unknown index::SymbolKind")
+  llvm_unreachable("Unknown index::SymbolKind");
 }
 
 void SymbolQualitySignals::merge(const CodeCompletionResult ) {


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


[PATCH] D47519: [clang-format] Detect amp type as TT_PointerOrReference in function annotations

2018-06-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1566
 
-if (PrevToken->is(tok::coloncolon))
+if (PrevToken->isOneOf(tok::coloncolon, tok::kw_const))
   return TT_PointerOrReference;

I'd also check for `volatile` here, for example for (+ add it as test):
```
auto x() volatile& noexcept -> bool {}
```



Comment at: lib/Format/TokenAnnotator.cpp:1590
+  tok::kw_typeof, tok::kw_decltype, TT_FunctionDeclarationName,
+  TT_StartOfName, TT_OverloadedOperator))
 return TT_PointerOrReference;

Sorry, I don't follow which of the added tests exercise which of the added 
cases. Could you please elaborate?



Comment at: unittests/Format/FormatTest.cpp:6164
+  verifyGoogleFormat("template \n"
+ "auto operator+()  {}");
 }

Do you have a real-world example of this kind of macro? I'd leave it off if not.


Repository:
  rC Clang

https://reviews.llvm.org/D47519



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


[clang-tools-extra] r334091 - Fix MSVC 'implicit double to float truncation and 'not all control paths return a value' warnings. NFCI.

2018-06-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jun  6 05:48:27 2018
New Revision: 334091

URL: http://llvm.org/viewvc/llvm-project?rev=334091=rev
Log:
Fix MSVC 'implicit double to float truncation and 'not all control paths return 
a value' warnings. NFCI.

Modified:
clang-tools-extra/trunk/clangd/Quality.cpp

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=334091=334090=334091=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Wed Jun  6 05:48:27 2018
@@ -90,6 +90,7 @@ categorize(const index::SymbolInfo ) {
 case index::SymbolKind::Unknown:
   return SymbolQualitySignals::Unknown;
   }
+  llvm_unreachable("Unknown index::SymbolKind")
 }
 
 void SymbolQualitySignals::merge(const CodeCompletionResult ) {
@@ -128,13 +129,13 @@ float SymbolQualitySignals::evaluate() c
 case Type:
 case Function:
 case Variable:
-  Score *= 1.1;
+  Score *= 1.1f;
   break;
 case Namespace:
-  Score *= 0.8;
+  Score *= 0.8f;
   break;
 case Macro:
-  Score *= 0.2;
+  Score *= 0.2f;
   break;
 case Unknown:
   break;


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


[clang-tools-extra] r334089 - [clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is the full identifier name.

2018-06-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jun  6 05:38:37 2018
New Revision: 334089

URL: http://llvm.org/viewvc/llvm-project?rev=334089=rev
Log:
[clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is 
the full identifier name.

Summary: Fix a couple of bugs in tests an in Quality to keep tests passing.

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
clang-tools-extra/trunk/clangd/FuzzyMatch.h
clang-tools-extra/trunk/clangd/Quality.cpp
clang-tools-extra/trunk/clangd/Quality.h
clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=334089=334088=334089=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Wed Jun  6 05:38:37 2018
@@ -101,7 +101,13 @@ Optional FuzzyMatcher::match(Stri
Scores[PatN][WordN][Match].Score);
   if (isAwful(Best))
 return None;
-  return ScoreScale * std::min(PerfectBonus * PatN, std::max(0, Best));
+  float Score =
+  ScoreScale * std::min(PerfectBonus * PatN, std::max(0, Best));
+  // If the pattern is as long as the word, we have an exact string match,
+  // since every pattern character must match something.
+  if (WordN == PatN)
+Score *= 2; // May not be perfect 2 if case differs in a significant way.
+  return Score;
 }
 
 // Segmentation of words and patterns.

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.h?rev=334089=334088=334089=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.h (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.h Wed Jun  6 05:38:37 2018
@@ -31,7 +31,9 @@ public:
   // Characters beyond MaxPat are ignored.
   FuzzyMatcher(llvm::StringRef Pattern);
 
-  // If Word matches the pattern, return a score in [0,1] (higher is better).
+  // If Word matches the pattern, return a score indicating the quality match.
+  // Scores usually fall in a [0,1] range, with 1 being a very good score.
+  // "Super" scores in (1,2] are possible if the pattern is the full word.
   // Characters beyond MaxWord are ignored.
   llvm::Optional match(llvm::StringRef Word);
 

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=334089=334088=334089=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Wed Jun  6 05:38:37 2018
@@ -131,6 +131,8 @@ float SymbolQualitySignals::evaluate() c
   Score *= 1.1;
   break;
 case Namespace:
+  Score *= 0.8;
+  break;
 case Macro:
   Score *= 0.2;
   break;

Modified: clang-tools-extra/trunk/clangd/Quality.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.h?rev=334089=334088=334089=diff
==
--- clang-tools-extra/trunk/clangd/Quality.h (original)
+++ clang-tools-extra/trunk/clangd/Quality.h Wed Jun  6 05:38:37 2018
@@ -70,7 +70,7 @@ llvm::raw_ostream <<(llvm::raw_
 
 /// Attributes of a symbol-query pair that affect how much we like it.
 struct SymbolRelevanceSignals {
-  /// 0-1 fuzzy-match score for unqualified name. Must be explicitly assigned.
+  /// 0-1+ fuzzy-match score for unqualified name. Must be explicitly assigned.
   float NameMatch = 1;
   bool Forbidden = false; // Unavailable (e.g const) or inaccessible (private).
   /// Proximity between best declaration and the query. [0-1], 1 is closest.

Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=334089=334088=334089=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Wed Jun  6 
05:38:37 2018
@@ -273,10 +273,10 @@ TEST_F(WorkspaceSymbolsTest, WithLimit)
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("foo"),
-  ElementsAre(AllOf(Named("foo"), InContainer(""),
-WithKind(SymbolKind::Variable)),
-  AllOf(Named("foo2"), InContainer(""),
-WithKind(SymbolKind::Variable;
+   

[PATCH] D47815: [clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is the full identifier name.

2018-06-06 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334089: [clangd] Boost fuzzy match score by 2x (so a maximum 
of 2) when the query is… (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47815?vs=150117=150118#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47815

Files:
  clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
  clang-tools-extra/trunk/clangd/FuzzyMatch.h
  clang-tools-extra/trunk/clangd/Quality.cpp
  clang-tools-extra/trunk/clangd/Quality.h
  clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
  clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
@@ -273,10 +273,10 @@
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("foo"),
-  ElementsAre(AllOf(Named("foo"), InContainer(""),
-WithKind(SymbolKind::Variable)),
-  AllOf(Named("foo2"), InContainer(""),
-WithKind(SymbolKind::Variable;
+  UnorderedElementsAre(AllOf(Named("foo"), InContainer(""),
+ WithKind(SymbolKind::Variable)),
+   AllOf(Named("foo2"), InContainer(""),
+ WithKind(SymbolKind::Variable;
 
   Limit = 1;
   EXPECT_THAT(getSymbols("foo"),
Index: clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
@@ -46,10 +46,14 @@
 
 struct MatchesMatcher : public testing::MatcherInterface {
   ExpectedMatch Candidate;
-  MatchesMatcher(ExpectedMatch Candidate) : Candidate(std::move(Candidate)) {}
+  Optional Score;
+  MatchesMatcher(ExpectedMatch Candidate, Optional Score)
+  : Candidate(std::move(Candidate)), Score(Score) {}
 
   void DescribeTo(::std::ostream *OS) const override {
 raw_os_ostream(*OS) << "Matches " << Candidate;
+if (Score)
+  *OS << " with score " << *Score;
   }
 
   bool MatchAndExplain(StringRef Pattern,
@@ -60,14 +64,15 @@
 FuzzyMatcher Matcher(Pattern);
 auto Result = Matcher.match(Candidate.Word);
 auto AnnotatedMatch = Matcher.dumpLast(*OS << "\n");
-return Result && Candidate.accepts(AnnotatedMatch);
+return Result && Candidate.accepts(AnnotatedMatch) &&
+   (!Score || testing::Value(*Result, testing::FloatEq(*Score)));
   }
 };
 
-// Accepts patterns that match a given word.
+// Accepts patterns that match a given word, optionally requiring a score.
 // Dumps the debug tables on match failure.
-testing::Matcher matches(StringRef M) {
-  return testing::MakeMatcher(new MatchesMatcher(M));
+testing::Matcher matches(StringRef M, Optional Score = {}) {
+  return testing::MakeMatcher(new MatchesMatcher(M, Score));
 }
 
 TEST(FuzzyMatch, Matches) {
@@ -239,7 +244,7 @@
   ranks("[onMess]age", "[onmess]age", "[on]This[M]ega[Es]cape[s]"));
   EXPECT_THAT("CC", ranks("[C]amel[C]ase", "[c]amel[C]ase"));
   EXPECT_THAT("cC", ranks("[c]amel[C]ase", "[C]amel[C]ase"));
-  EXPECT_THAT("p", ranks("[p]arse", "[p]osix", "[p]afdsa", "[p]ath", "[p]"));
+  EXPECT_THAT("p", ranks("[p]", "[p]arse", "[p]osix", "[p]afdsa", "[p]ath"));
   EXPECT_THAT("pa", ranks("[pa]rse", "[pa]th", "[pa]fdsa"));
   EXPECT_THAT("log", ranks("[log]", "Scroll[Log]icalPosition"));
   EXPECT_THAT("e", ranks("[e]lse", "Abstract[E]lement"));
@@ -262,6 +267,15 @@
  "[c]ss.co[lo]rDecorator[s].[e]nable"));
 }
 
+// Verify some bounds so we know scores fall in the right range.
+// Testing exact scores is fragile, so we prefer Ranking tests.
+TEST(FuzzyMatch, Scoring) {
+  EXPECT_THAT("abs", matches("[a]x[b]y[s]z", 0.f));
+  EXPECT_THAT("abs", matches("[abs]l", 1.f));
+  EXPECT_THAT("abs", matches("[abs]", 2.f));
+  EXPECT_THAT("Abs", matches("[abs]", 2.f));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
===
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
@@ -101,7 +101,13 @@
Scores[PatN][WordN][Match].Score);
   if (isAwful(Best))
 return None;
-  return ScoreScale * std::min(PerfectBonus * PatN, std::max(0, Best));
+  float Score =
+  ScoreScale * std::min(PerfectBonus * PatN, std::max(0, Best));
+  // If the pattern is as long as the word, we have an exact string match,
+  // since every pattern character must match 

[PATCH] D47815: [clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is the full identifier name.

2018-06-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 150117.
sammccall added a comment.

Explain WordN == PatN criterion for an exact match.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47815

Files:
  clangd/FuzzyMatch.cpp
  clangd/FuzzyMatch.h
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/FuzzyMatchTests.cpp

Index: unittests/clangd/FuzzyMatchTests.cpp
===
--- unittests/clangd/FuzzyMatchTests.cpp
+++ unittests/clangd/FuzzyMatchTests.cpp
@@ -46,10 +46,14 @@
 
 struct MatchesMatcher : public testing::MatcherInterface {
   ExpectedMatch Candidate;
-  MatchesMatcher(ExpectedMatch Candidate) : Candidate(std::move(Candidate)) {}
+  Optional Score;
+  MatchesMatcher(ExpectedMatch Candidate, Optional Score)
+  : Candidate(std::move(Candidate)), Score(Score) {}
 
   void DescribeTo(::std::ostream *OS) const override {
 raw_os_ostream(*OS) << "Matches " << Candidate;
+if (Score)
+  *OS << " with score " << *Score;
   }
 
   bool MatchAndExplain(StringRef Pattern,
@@ -60,14 +64,15 @@
 FuzzyMatcher Matcher(Pattern);
 auto Result = Matcher.match(Candidate.Word);
 auto AnnotatedMatch = Matcher.dumpLast(*OS << "\n");
-return Result && Candidate.accepts(AnnotatedMatch);
+return Result && Candidate.accepts(AnnotatedMatch) &&
+   (!Score || testing::Value(*Result, testing::FloatEq(*Score)));
   }
 };
 
-// Accepts patterns that match a given word.
+// Accepts patterns that match a given word, optionally requiring a score.
 // Dumps the debug tables on match failure.
-testing::Matcher matches(StringRef M) {
-  return testing::MakeMatcher(new MatchesMatcher(M));
+testing::Matcher matches(StringRef M, Optional Score = {}) {
+  return testing::MakeMatcher(new MatchesMatcher(M, Score));
 }
 
 TEST(FuzzyMatch, Matches) {
@@ -239,7 +244,7 @@
   ranks("[onMess]age", "[onmess]age", "[on]This[M]ega[Es]cape[s]"));
   EXPECT_THAT("CC", ranks("[C]amel[C]ase", "[c]amel[C]ase"));
   EXPECT_THAT("cC", ranks("[c]amel[C]ase", "[C]amel[C]ase"));
-  EXPECT_THAT("p", ranks("[p]arse", "[p]osix", "[p]afdsa", "[p]ath", "[p]"));
+  EXPECT_THAT("p", ranks("[p]", "[p]arse", "[p]osix", "[p]afdsa", "[p]ath"));
   EXPECT_THAT("pa", ranks("[pa]rse", "[pa]th", "[pa]fdsa"));
   EXPECT_THAT("log", ranks("[log]", "Scroll[Log]icalPosition"));
   EXPECT_THAT("e", ranks("[e]lse", "Abstract[E]lement"));
@@ -262,6 +267,15 @@
  "[c]ss.co[lo]rDecorator[s].[e]nable"));
 }
 
+// Verify some bounds so we know scores fall in the right range.
+// Testing exact scores is fragile, so we prefer Ranking tests.
+TEST(FuzzyMatch, Scoring) {
+  EXPECT_THAT("abs", matches("[a]x[b]y[s]z", 0.f));
+  EXPECT_THAT("abs", matches("[abs]l", 1.f));
+  EXPECT_THAT("abs", matches("[abs]", 2.f));
+  EXPECT_THAT("aBs", matches("[abs]", 2.f));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -273,10 +273,10 @@
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("foo"),
-  ElementsAre(AllOf(Named("foo"), InContainer(""),
-WithKind(SymbolKind::Variable)),
-  AllOf(Named("foo2"), InContainer(""),
-WithKind(SymbolKind::Variable;
+  UnorderedElementsAre(AllOf(Named("foo"), InContainer(""),
+ WithKind(SymbolKind::Variable)),
+   AllOf(Named("foo2"), InContainer(""),
+ WithKind(SymbolKind::Variable;
 
   Limit = 1;
   EXPECT_THAT(getSymbols("foo"),
Index: clangd/Quality.h
===
--- clangd/Quality.h
+++ clangd/Quality.h
@@ -70,7 +70,7 @@
 
 /// Attributes of a symbol-query pair that affect how much we like it.
 struct SymbolRelevanceSignals {
-  /// 0-1 fuzzy-match score for unqualified name. Must be explicitly assigned.
+  /// 0-1+ fuzzy-match score for unqualified name. Must be explicitly assigned.
   float NameMatch = 1;
   bool Forbidden = false; // Unavailable (e.g const) or inaccessible (private).
   /// Proximity between best declaration and the query. [0-1], 1 is closest.
Index: clangd/Quality.cpp
===
--- clangd/Quality.cpp
+++ clangd/Quality.cpp
@@ -131,6 +131,8 @@
   Score *= 1.1;
   break;
 case Namespace:
+  Score *= 0.8;
+  break;
 case Macro:
   Score *= 0.2;
   break;
Index: clangd/FuzzyMatch.h
===
--- clangd/FuzzyMatch.h
+++ clangd/FuzzyMatch.h
@@ -31,7 +31,9 @@
   // Characters beyond MaxPat are 

[PATCH] D47815: [clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is the full identifier name.

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

lg


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47815



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


[PATCH] D47707: [clangd] Downrank symbols with reserved names (score *= 0.1)

2018-06-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 150115.
sammccall added a comment.

Add test that _f isn't a reserved name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47707

Files:
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/QualityTests.cpp

Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -28,33 +28,36 @@
 
 TEST(QualityTests, SymbolQualitySignalExtraction) {
   auto Header = TestTU::withHeaderCode(R"cpp(
-int x;
+int _X;
 
 [[deprecated]]
-int f() { return x; }
+int _f() { return _X; }
   )cpp");
   auto Symbols = Header.headerSymbols();
   auto AST = Header.build();
 
   SymbolQualitySignals Quality;
-  Quality.merge(findSymbol(Symbols, "x"));
+  Quality.merge(findSymbol(Symbols, "_X"));
   EXPECT_FALSE(Quality.Deprecated);
+  EXPECT_TRUE(Quality.ReservedName);
   EXPECT_EQ(Quality.SemaCCPriority, SymbolQualitySignals().SemaCCPriority);
   EXPECT_EQ(Quality.References, SymbolQualitySignals().References);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Variable);
 
-  Symbol F = findSymbol(Symbols, "f");
+  Symbol F = findSymbol(Symbols, "_f");
   F.References = 24; // TestTU doesn't count references, so fake it.
   Quality = {};
   Quality.merge(F);
   EXPECT_FALSE(Quality.Deprecated); // FIXME: Include deprecated bit in index.
+  EXPECT_FALSE(Quality.ReservedName);
   EXPECT_EQ(Quality.SemaCCPriority, SymbolQualitySignals().SemaCCPriority);
   EXPECT_EQ(Quality.References, 24u);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
 
   Quality = {};
-  Quality.merge(CodeCompletionResult((AST, "f"), /*Priority=*/42));
+  Quality.merge(CodeCompletionResult((AST, "_f"), /*Priority=*/42));
   EXPECT_TRUE(Quality.Deprecated);
+  EXPECT_FALSE(Quality.ReservedName);
   EXPECT_EQ(Quality.SemaCCPriority, 42u);
   EXPECT_EQ(Quality.References, SymbolQualitySignals().References);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
@@ -115,6 +118,10 @@
   Deprecated.Deprecated = true;
   EXPECT_LT(Deprecated.evaluate(), Default.evaluate());
 
+  SymbolQualitySignals ReservedName;
+  ReservedName.ReservedName = true;
+  EXPECT_LT(ReservedName.evaluate(), Default.evaluate());
+
   SymbolQualitySignals WithReferences, ManyReferences;
   WithReferences.References = 10;
   ManyReferences.References = 1000;
Index: clangd/Quality.h
===
--- clangd/Quality.h
+++ clangd/Quality.h
@@ -48,6 +48,8 @@
// FIXME: this is actually a mix of symbol
//quality and relevance. Untangle this.
   bool Deprecated = false;
+  bool ReservedName = false; // __foo, _Foo are usually implementation details.
+ // FIXME: make these findable once user types _.
   unsigned References = 0;
 
   enum SymbolCategory {
Index: clangd/Quality.cpp
===
--- clangd/Quality.cpp
+++ clangd/Quality.cpp
@@ -9,6 +9,7 @@
 #include "Quality.h"
 #include "index/Index.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
@@ -19,6 +20,11 @@
 namespace clang {
 namespace clangd {
 using namespace llvm;
+static bool IsReserved(StringRef Name) {
+  // FIXME: Should we exclude _Bool and others recognized by the standard?
+  return Name.size() >= 2 && Name[0] == '_' &&
+ (isUppercase(Name[1]) || Name[1] == '_');
+}
 
 static bool hasDeclInMainFile(const Decl ) {
   auto  = D.getASTContext().getSourceManager();
@@ -101,11 +107,18 @@
 Category = categorize(*SemaCCResult.Declaration);
   else if (SemaCCResult.Kind == CodeCompletionResult::RK_Macro)
 Category = Macro;
+
+  if (SemaCCResult.Declaration) {
+if (auto *ID = SemaCCResult.Declaration->getIdentifier())
+  ReservedName = ReservedName || IsReserved(ID->getName());
+  } else if (SemaCCResult.Kind == CodeCompletionResult::RK_Macro)
+ReservedName = ReservedName || IsReserved(SemaCCResult.Macro->getName());
 }
 
 void SymbolQualitySignals::merge(const Symbol ) {
   References = std::max(IndexResult.References, References);
   Category = categorize(IndexResult.SymInfo);
+  ReservedName = ReservedName || IsReserved(IndexResult.Name);
 }
 
 float SymbolQualitySignals::evaluate() const {
@@ -123,6 +136,8 @@
 
   if (Deprecated)
 Score *= 0.1f;
+  if (ReservedName)
+Score *= 0.1f;
 
   switch (Category) {
 case Type:
@@ -147,6 +162,7 @@
 OS << formatv("\tSemaCCPriority: {0}\n", S.SemaCCPriority);
   OS << formatv("\tReferences: {0}\n", S.References);
   OS << formatv("\tDeprecated: {0}\n", S.Deprecated);
+  OS << formatv("\tReserved name: {0}\n", S.ReservedName);
   OS << formatv("\tCategory: {0}\n", 

[PATCH] D47821: [clangd] Make workspace/symbols actually rank its results.

2018-06-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov.

The index doesn't actually return results in ranked order.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47821

Files:
  clangd/FindSymbols.cpp
  unittests/clangd/FindSymbolsTests.cpp

Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -264,24 +264,34 @@
   EXPECT_THAT(getSymbols("ns::Color4::White"), ElementsAre(Named("White")));
 }
 
+TEST_F(WorkspaceSymbolsTest, Ranking) {
+  addFile("foo.h", R"cpp(
+  namespace ns{}
+  function func();
+  )cpp");
+  addFile("foo.cpp", R"cpp(
+  #include "foo.h"
+  )cpp");
+  EXPECT_THAT(getSymbols("::"), ElementsAre(Named("func"), Named("ns")));
+}
+
 TEST_F(WorkspaceSymbolsTest, WithLimit) {
   addFile("foo.h", R"cpp(
   int foo;
   int foo2;
   )cpp");
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
+  // Foo is higher ranked because of exact name match.
   EXPECT_THAT(getSymbols("foo"),
   ElementsAre(AllOf(Named("foo"), InContainer(""),
 WithKind(SymbolKind::Variable)),
   AllOf(Named("foo2"), InContainer(""),
 WithKind(SymbolKind::Variable;
 
   Limit = 1;
-  EXPECT_THAT(getSymbols("foo"),
-  ElementsAre(AnyOf((Named("foo"), InContainer("")),
-AllOf(Named("foo2"), InContainer("");
+  EXPECT_THAT(getSymbols("foo"), ElementsAre(Named("foo")));
 }
 
 } // namespace clangd
Index: clangd/FindSymbols.cpp
===
--- clangd/FindSymbols.cpp
+++ clangd/FindSymbols.cpp
@@ -9,12 +9,16 @@
 #include "FindSymbols.h"
 
 #include "Logger.h"
+#include "FuzzyMatch.h"
 #include "SourceCode.h"
+#include "Quality.h"
 #include "index/Index.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 
+#define DEBUG_TYPE "FindSymbols"
+
 namespace clang {
 namespace clangd {
 
@@ -79,6 +83,15 @@
   llvm_unreachable("invalid symbol kind");
 }
 
+using ScoredSymbolInfo = std::pair;
+struct ScoredSymbolGreater {
+  bool operator()(const ScoredSymbolInfo , const ScoredSymbolInfo ) {
+if (L.first != R.first)
+  return L.first > R.first;
+return L.second.name < R.second.name; // Earlier name is better.
+  }
+};
+
 } // namespace
 
 llvm::Expected>
@@ -101,7 +114,9 @@
 Req.Scopes = {Names.first};
   if (Limit)
 Req.MaxCandidateCount = Limit;
-  Index->fuzzyFind(Req, [](const Symbol ) {
+  TopN Top(Req.MaxCandidateCount);
+  FuzzyMatcher Filter(Req.Query);
+  Index->fuzzyFind(Req, [, ](const Symbol ) {
 // Prefer the definition over e.g. a function declaration in a header
 auto  = Sym.Definition ? Sym.Definition : Sym.CanonicalDeclaration;
 auto Uri = URI::parse(CD.FileURI);
@@ -132,8 +147,27 @@
 std::string Scope = Sym.Scope;
 StringRef ScopeRef = Scope;
 ScopeRef.consume_back("::");
-Result.push_back({Sym.Name, SK, L, ScopeRef});
+SymbolInformation Info = {Sym.Name, SK, L, ScopeRef};
+
+SymbolQualitySignals Quality;
+Quality.merge(Sym);
+SymbolRelevanceSignals Relevance;
+Relevance.Query = SymbolRelevanceSignals::Generic;
+if (auto NameMatch = Filter.match(Sym.Name))
+  Relevance.NameMatch = *NameMatch;
+else
+  return;
+Relevance.merge(Sym);
+auto Score =
+evaluateSymbolAndRelevance(Quality.evaluate(), Relevance.evaluate());
+LLVM_DEBUG(llvm::dbgs() << "FindSymbols: " << Sym.Scope << Sym.Name << " = "
+<< Score << "\n"
+<< Quality << Relevance << "\n");
+
+Top.push({Score, std::move(Info)});
   });
+  for (auto  : std::move(Top).items())
+Result.push_back(std::move(R.second));
   return Result;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-06 Thread Jonas Toth via cfe-commits
Hmm. SVN does not want  me to commit anything :/

I will retry later today, but maybe i cant commit.


Best, Jonas


Am 06.06.2018 um 10:47 schrieb Aaron Ballman:
> On Wed, Jun 6, 2018 at 4:40 AM Jonas Toth via Phabricator
>  wrote:
>> JonasToth added a comment.
>>
>> @shuaiwang I can commit it in 2 hours for you if you want, after my lecture.
> That's sooner than my "I can commit next week." :-D
>
> ~Aaron
>
>>
>> Repository:
>>   rCTE Clang Tools Extra
>>
>> https://reviews.llvm.org/D45679
>>
>>
>>

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


[PATCH] D47375: [Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.

2018-06-06 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment.

I have a minor nit + what Paul mentioned (missing a `-NOT` check). Otherwise 
LGTM.




Comment at: lib/Driver/ToolChains/Clang.cpp:3690
 
-  // Add runtime flag for PS4 when PGO or Coverage are enabled.
-  if (RawTriple.isPS4CPU())
+  // Add runtime flag for PS4 when PGO or Coverage or sanitizers are enabled.
+  if (RawTriple.isPS4CPU()) {

Nit: `PGO, coverage, or sanitizers`


Repository:
  rC Clang

https://reviews.llvm.org/D47375



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


[PATCH] D47733: [CUDA][HIP] Set kernel calling convention before arrange function

2018-06-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 150106.
yaxunl added a comment.

Revised by Artem's comments.


https://reviews.llvm.org/D47733

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenCUDA/kernel-args.cu

Index: test/CodeGenCUDA/kernel-args.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args.cu
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck -check-prefix=AMDGCN %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda- -fcuda-is-device -emit-llvm %s -o - | FileCheck -check-prefix=NVPTX %s
+#include "Inputs/cuda.h"
+
+struct A {
+  int a[32];
+};
+
+// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A %x.coerce)
+// NVPTX: define void @_Z6kernel1A(%struct.A* byval align 4 %x)
+__global__ void kernel(A x) {
+}
+
+class Kernel {
+public:
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A %x.coerce)
+  // NVPTX: define void @_ZN6Kernel12memberKernelE1A(%struct.A* byval align 4 %x)
+  static __global__ void memberKernel(A x){}
+  template static __global__ void templateMemberKernel(T x) {}
+};
+
+
+template 
+__global__ void templateKernel(T x) {}
+
+void launch(void*);
+
+void test() {
+  Kernel K;
+  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A %x.coerce)
+  // NVPTX: define void @_Z14templateKernelI1AEvT_(%struct.A* byval align 4 %x)
+  launch((void*)templateKernel);
+
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A %x.coerce)
+  // NVPTX: define void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A* byval align 4 %x)
+  launch((void*)Kernel::templateMemberKernel);
+}
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -302,7 +302,7 @@
   /// as 'used', and having internal linkage.
   virtual bool shouldEmitStaticExternCAliases() const { return true; }
 
-  virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {}
+  virtual void setCUDAKernelCallingConvention(const FunctionType *) const {}
 };
 
 } // namespace CodeGen
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7646,7 +7646,7 @@
 llvm::Function *BlockInvokeFunc,
 llvm::Value *BlockLiteral) const override;
   bool shouldEmitStaticExternCAliases() const override;
-  void setCUDAKernelCallingConvention(llvm::Function *F) const override;
+  void setCUDAKernelCallingConvention(const FunctionType *) const override;
 };
 }
 
@@ -7783,8 +7783,9 @@
 }
 
 void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention(
-llvm::Function *F) const {
-  F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+const FunctionType *) const {
+  FT = getABIInfo().getContext().adjustFunctionType(
+  FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
 }
 
 //===--===//
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3671,8 +3671,6 @@
 
   MaybeHandleStaticInExternC(D, Fn);
 
-  if (D->hasAttr())
-getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn);
 
   maybeSetTrivialComdat(*D, *Fn);
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -255,6 +255,16 @@
   FTP->getCanonicalTypeUnqualified().getAs(), MD);
 }
 
+/// Set calling convention for CUDA/HIP kernel.
+static void setCUDAKernelCallingConvention(CanQualType , CodeGenModule ,
+   const FunctionDecl *FD) {
+  if (FD->hasAttr()) {
+const FunctionType *FT = FTy->getAs();
+CGM.getTargetCodeGenInfo().setCUDAKernelCallingConvention(FT);
+FTy = FT->getCanonicalTypeUnqualified();
+  }
+}
+
 /// Arrange the argument and result information for a declaration or
 /// definition of the given C++ non-static member function.  The
 /// member function must be an ordinary function, i.e. not a
@@ -264,7 +274,9 @@
   assert(!isa(MD) && "wrong method for constructors!");
   assert(!isa(MD) && "wrong method for destructors!");
 
-  CanQual prototype = GetFormalType(MD);
+  CanQualType FT = GetFormalType(MD).getAs();
+  setCUDAKernelCallingConvention(FT, CGM, MD);
+  auto prototype = FT.getAs();
 
   if (MD->isInstance()) {
 // The abstract case is perfectly fine.
@@ -424,6 +436,7 @@
   CanQualType FTy = FD->getType()->getCanonicalTypeUnqualified();
 
   assert(isa(FTy));
+  setCUDAKernelCallingConvention(FTy, CGM, FD);
 
   // When declaring a function 

  1   2   >