clang_getIncudedFile python binding fix

2018-05-03 Thread József LÁZ via cfe-commits
Hi all,
I made fix in clang's python bindings. The binding for C api's 
clang_getIncludedFile was not implemented. The patch was made on trunk.
I believe this bugticket is related: https://bugs.llvm.org/show_bug.cgi?id=15223
Any thoughts?

József Láz

This message, including its attachments, is confidential and the property of 
NNG Llc. For more information please read NNG's email policy here:
https://www.nng.com/email-policy/
By responding to this email you accept the email policy.


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


[PATCH] D46382: [OpenCL] Factor out language version printing

2018-05-03 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: rivanvx.
Herald added a subscriber: cfe-commits.

Generate a printable OpenCL language version number in a single place
and select between the OpenCL C or OpenCL C++ version accordingly.


Repository:
  rC Clang

https://reviews.llvm.org/D46382

Files:
  include/clang/Basic/LangOptions.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParseDecl.cpp


Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -29,7 +29,6 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 
@@ -3806,11 +3805,8 @@
 Diag(Tok, DiagID)
   << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
   else if (DiagID == diag::err_opencl_unknown_type_specifier) {
-const int OpenCLVer = getLangOpts().OpenCLVersion;
-std::string VerSpec = llvm::to_string(OpenCLVer / 100) +
-  std::string (".") +
-  llvm::to_string((OpenCLVer % 100) / 10);
-Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;
+Diag(Tok, DiagID) << 
getLangOpts().getOpenCLVersionTuple().getAsString()
+  << PrevSpec << isStorageClass;
   } else
 Diag(Tok, DiagID) << PrevSpec;
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -76,7 +76,6 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Regex.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetOptions.h"
 #include 
@@ -2145,11 +2144,9 @@
   // this option was added for compatibility with OpenCL 1.0.
   if (Args.getLastArg(OPT_cl_strict_aliasing)
&& Opts.OpenCLVersion > 100) {
-std::string VerSpec = llvm::to_string(Opts.OpenCLVersion / 100) +
-  std::string(".") +
-  llvm::to_string((Opts.OpenCLVersion % 100) / 10);
 Diags.Report(diag::warn_option_invalid_ocl_version)
-  << VerSpec << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
+<< Opts.getOpenCLVersionTuple().getAsString()
+<< Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
   }
 
   // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
Index: lib/Basic/LangOptions.cpp
===
--- lib/Basic/LangOptions.cpp
+++ lib/Basic/LangOptions.cpp
@@ -43,3 +43,8 @@
   return true;
   return false;
 }
+
+VersionTuple LangOptions::getOpenCLVersionTuple() const {
+  const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  return VersionTuple(Ver / 100, (Ver % 100) / 10);
+}
Index: include/clang/Basic/LangOptions.h
===
--- include/clang/Basic/LangOptions.h
+++ include/clang/Basic/LangOptions.h
@@ -254,6 +254,9 @@
   bool assumeFunctionsAreConvergent() const {
 return (CUDA && CUDAIsDevice) || OpenCL;
   }
+
+  /// \brief Return the OpenCL C or C++ version as a VersionTuple.
+  VersionTuple getOpenCLVersionTuple() const;
 };
 
 /// \brief Floating point control options


Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -29,7 +29,6 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 
@@ -3806,11 +3805,8 @@
 Diag(Tok, DiagID)
   << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
   else if (DiagID == diag::err_opencl_unknown_type_specifier) {
-const int OpenCLVer = getLangOpts().OpenCLVersion;
-std::string VerSpec = llvm::to_string(OpenCLVer / 100) +
-  std::string (".") +
-  llvm::to_string((OpenCLVer % 100) / 10);
-Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;
+Diag(Tok, DiagID) << getLangOpts().getOpenCLVersionTuple().getAsString()
+  << PrevSpec << isStorageClass;
   } else
 Diag(Tok, DiagID) << PrevSpec;
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -76,7 +76,6 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Regex.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/Tar

[PATCH] D46383: implementing Cursor.get_included_file in python bindings

2018-05-03 Thread József Láz via Phabricator via cfe-commits
jlaz created this revision.
Herald added a subscriber: cfe-commits.

adding function: `Cursor.get_included_file` , so the C API's 
`clang_getIncludedFile` function is available on the python binding interface
also adding test to unittests


Repository:
  rC Clang

https://reviews.llvm.org/D46383

Files:
  bindings/python/clang/cindex.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
@@ -108,6 +108,18 @@
 for i in zip(inc, tu.get_includes()):
 eq(i[0], i[1])
 
+def test_inclusion_directive(self):
+src = os.path.join(kInputsDir, 'include.cpp')
+h1 = os.path.join(kInputsDir, "header1.h")
+h2 = os.path.join(kInputsDir, "header2.h")
+h3 = os.path.join(kInputsDir, "header3.h")
+inc = [h1, h3, h2, h3, h1]
+
+tu = TranslationUnit.from_source(src, 
options=TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD)
+inclusion_directive_files = [c.get_included_file().name for c in 
tu.cursor.get_children() if c.kind == CursorKind.INCLUSION_DIRECTIVE]
+for i in zip(inc, inclusion_directive_files):
+self.assert_normpaths_equal(i[0], i[1])
+
 def test_save(self):
 """Ensure TranslationUnit.save() works."""
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1511,6 +1511,12 @@
 another translation unit."""
 return conf.lib.clang_getCursorUSR(self)
 
+def get_included_file(self):
+"""Returns the File that is included by the current inclusion 
cursor."""
+assert self.kind == CursorKind.INCLUSION_DIRECTIVE
+
+return conf.lib.clang_getIncludedFile(self)
+
 @property
 def kind(self):
 """Return the kind of this cursor."""
@@ -3085,8 +3091,9 @@
 return "" % (self.name)
 
 @staticmethod
-def from_cursor_result(res, fn, args):
-assert isinstance(res, File)
+def from_result(res, fn, args):
+assert isinstance(res, c_object_p)
+res = File(res)
 
 # Copy a reference to the TranslationUnit to prevent premature GC.
 res._tu = args[0]._tu
@@ -3701,8 +3708,8 @@
 
   ("clang_getIncludedFile",
[Cursor],
-   File,
-   File.from_cursor_result),
+   c_object_p,
+   File.from_result),
 
   ("clang_getInclusions",
[TranslationUnit, callbacks['translation_unit_includes'], py_object]),


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
@@ -108,6 +108,18 @@
 for i in zip(inc, tu.get_includes()):
 eq(i[0], i[1])
 
+def test_inclusion_directive(self):
+src = os.path.join(kInputsDir, 'include.cpp')
+h1 = os.path.join(kInputsDir, "header1.h")
+h2 = os.path.join(kInputsDir, "header2.h")
+h3 = os.path.join(kInputsDir, "header3.h")
+inc = [h1, h3, h2, h3, h1]
+
+tu = TranslationUnit.from_source(src, options=TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD)
+inclusion_directive_files = [c.get_included_file().name for c in tu.cursor.get_children() if c.kind == CursorKind.INCLUSION_DIRECTIVE]
+for i in zip(inc, inclusion_directive_files):
+self.assert_normpaths_equal(i[0], i[1])
+
 def test_save(self):
 """Ensure TranslationUnit.save() works."""
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1511,6 +1511,12 @@
 another translation unit."""
 return conf.lib.clang_getCursorUSR(self)
 
+def get_included_file(self):
+"""Returns the File that is included by the current inclusion cursor."""
+assert self.kind == CursorKind.INCLUSION_DIRECTIVE
+
+return conf.lib.clang_getIncludedFile(self)
+
 @property
 def kind(self):
 """Return the kind of this cursor."""
@@ -3085,8 +3091,9 @@
 return "" % (self.name)
 
 @staticmethod
-def from_cursor_result(res, fn, args):
-assert isinstance(res, File)
+def from_result(res, fn, args):
+assert isinstance(res, c_object_p)
+res = File(res)
 
 # Copy a reference to the TranslationUnit to prevent premature GC.
 res._tu = args[0]._tu
@@ -3701,8 +3708,8 @@
 
   ("clang_getIncludedFile",
[Cursor],
-   File,
-   File.from_cursor_result),
+   c_object_p,
+   File.from_result),
 
   ("clang_getInclusions",
[TranslationUnit, callbacks['translation_unit_includes'], py_o

r331448 - Rename invariant.group.barrier to launder.invariant.group

2018-05-03 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu May  3 04:03:01 2018
New Revision: 331448

URL: http://llvm.org/viewvc/llvm-project?rev=331448&view=rev
Log:
Rename invariant.group.barrier to launder.invariant.group

Summary:
This is one of the initial commit of "RFC: Devirtualization v2" proposal:
https://docs.google.com/document/d/16GVtCpzK8sIHNc2qZz6RN8amICNBtvjWUod2SujZVEo/edit?usp=sharing

Reviewers: rsmith, amharc, kuhar, sanjoy

Subscribers: arsenm, nhaehnle, javed.absar, hiraditya, llvm-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=331448&r1=331447&r2=331448&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu May  3 04:03:01 2018
@@ -1276,7 +1276,7 @@ void CodeGenFunction::EmitCtorPrologue(c
 if (CGM.getCodeGenOpts().StrictVTablePointers &&
 CGM.getCodeGenOpts().OptimizationLevel > 0 &&
 isInitializerOfDynamicClass(*B))
-  CXXThisValue = Builder.CreateInvariantGroupBarrier(LoadCXXThis());
+  CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
 EmitBaseInitializer(*this, ClassDecl, *B, CtorType);
   }
 
@@ -1293,7 +1293,7 @@ void CodeGenFunction::EmitCtorPrologue(c
 if (CGM.getCodeGenOpts().StrictVTablePointers &&
 CGM.getCodeGenOpts().OptimizationLevel > 0 &&
 isInitializerOfDynamicClass(*B))
-  CXXThisValue = Builder.CreateInvariantGroupBarrier(LoadCXXThis());
+  CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
 EmitBaseInitializer(*this, ClassDecl, *B, CtorType);
   }
 
@@ -1477,11 +1477,11 @@ void CodeGenFunction::EmitDestructorBody
 
 // Initialize the vtable pointers before entering the body.
 if (!CanSkipVTablePointerInitialization(*this, Dtor)) {
-  // Insert the llvm.invariant.group.barrier intrinsic before initializing
+  // Insert the llvm.launder.invariant.group intrinsic before initializing
   // the vptrs to cancel any previous assumptions we might have made.
   if (CGM.getCodeGenOpts().StrictVTablePointers &&
   CGM.getCodeGenOpts().OptimizationLevel > 0)
-CXXThisValue = Builder.CreateInvariantGroupBarrier(LoadCXXThis());
+CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
   InitializeVTablePointers(Dtor->getParent());
 }
 

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=331448&r1=331447&r2=331448&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu May  3 04:03:01 2018
@@ -3850,7 +3850,7 @@ LValue CodeGenFunction::EmitLValueForFie
 hasAnyVptr(FieldType, getContext()))
   // Because unions can easily skip invariant.barriers, we need to add
   // a barrier every time CXXRecord field with vptr is referenced.
-  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),
+  addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
  addr.getAlignment());
   } else {
 // For structs, we GEP to the field that the record layout suggests.

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=331448&r1=331447&r2=331448&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu May  3 04:03:01 2018
@@ -1696,13 +1696,13 @@ llvm::Value *CodeGenFunction::EmitCXXNew
   llvm::Type *elementTy = ConvertTypeForMem(allocType);
   Address result = Builder.CreateElementBitCast(allocation, elementTy);
 
-  // Passing pointer through invariant.group.barrier to avoid propagation of
+  // Passing pointer through launder.invariant.group to avoid propagation of
   // vptrs information which may be included in previous type.
   // To not break LTO with different optimizations levels, we do it regardless
   // of optimization level.
   if (CGM.getCodeGenOpts().StrictVTablePointers &&
   allocator->isReservedGlobalPlacementOperator())
-result = Address(Builder.CreateInvariantGroupBarrier(result.getPointer()),
+result = Address(Builder.CreateLaunderInvariantGroup(result.getPointer()),
  result.getAlignment());
 
   EmitNewInitializer(*this, E, allocType, elementTy, result, numElements,

Modified: cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
URL: 
http://llvm.org

[PATCH] D32905: [Analyzer] Iterator Checker - Part 9: Evaluation of std::find-like calls

2018-05-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 144999.
baloghadamsoftware added a comment.

Rebased.


https://reviews.llvm.org/D32905

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -97,6 +97,125 @@
 *i2; // expected-warning{{Iterator accessed outside of its range}}
 }
 
+void good_find(std::vector &V, int e) {
+  auto first = std::find(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find(std::vector &V, int e) {
+  auto first = std::find(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_find_end(std::vector &V, std::vector &seq) {
+  auto last = std::find_end(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != last)
+*last; // no-warning
+}
+
+void bad_find_end(std::vector &V, std::vector &seq) {
+  auto last = std::find_end(V.begin(), V.end(), seq.begin(), seq.end());
+  *last; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_find_first_of(std::vector &V, std::vector &seq) {
+  auto first =
+  std::find_first_of(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find_first_of(std::vector &V, std::vector &seq) {
+  auto first = std::find_end(V.begin(), V.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+bool odd(int i) { return i % 2; }
+
+void good_find_if(std::vector &V) {
+  auto first = std::find_if(V.begin(), V.end(), odd);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if(std::vector &V, int e) {
+  auto first = std::find_if(V.begin(), V.end(), odd);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_find_if_not(std::vector &V) {
+  auto first = std::find_if_not(V.begin(), V.end(), odd);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if_not(std::vector &V, int e) {
+  auto first = std::find_if_not(V.begin(), V.end(), odd);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_lower_bound(std::vector &V, int e) {
+  auto first = std::lower_bound(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_lower_bound(std::vector &V, int e) {
+  auto first = std::lower_bound(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_upper_bound(std::vector &V, int e) {
+  auto last = std::lower_bound(V.begin(), V.end(), e);
+  if (V.end() != last)
+*last; // no-warning
+}
+
+void bad_upper_bound(std::vector &V, int e) {
+  auto last = std::lower_bound(V.begin(), V.end(), e);
+  *last; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_search(std::vector &V, std::vector &seq) {
+  auto first = std::search(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_search(std::vector &V, std::vector &seq) {
+  auto first = std::search(V.begin(), V.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_search_n(std::vector &V, std::vector &seq) {
+  auto nth = std::search_n(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != nth)
+*nth; // no-warning
+}
+
+void bad_search_n(std::vector &V, std::vector &seq) {
+  auto nth = std::search_n(V.begin(), V.end(), seq.begin(), seq.end());
+  *nth; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+template 
+InputIterator nonStdFind(InputIterator first, InputIterator last,
+ const T &val) {
+  for (auto i = first; i != last; ++i) {
+if (*i == val) {
+  return i;
+}
+  }
+  return last;
+}
+
+void good_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first; // no-warning
+}
+
 void tricky(std::vector &V, int e) {
   const auto first = V.begin();
   const auto comp1 = (first != V.end()), comp2 = (first == V.end());
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -714,12 +714,32 @@
 
   template 
   InputIterator find(InputIterator first, InputIterator last, const T &val);
-
+  template 
+  ForwardIterator1 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
+ForwardIterator2 first2, ForwardIterator2 last2);
   template 
   ForwardIterator1 find_first_of(ForwardIterator1 first1,

[PATCH] D46049: [OpenCL] Add constant address space to __func__ in AST

2018-05-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 145000.
Anastasia added a comment.

- Changed to adjust common function
- Enhanced CodeGen string literal case to also check the predefined expr


https://reviews.llvm.org/D46049

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/str_literals.cl
  test/SemaOpenCL/predefined-expr.cl

Index: test/SemaOpenCL/predefined-expr.cl
===
--- /dev/null
+++ test/SemaOpenCL/predefined-expr.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -cl-std=CL2.0
+
+void f() {
+  char *f1 = __func__;  //expected-error-re{{initializing '{{__generic char|char}} *' with an expression of type 'const __constant char *' changes address space of pointer}}
+  constant char *f2 = __func__; //expected-warning{{initializing '__constant char *' with an expression of type 'const __constant char [2]' discards qualifiers}}
+  constant const char *f3 = __func__;
+}
Index: test/CodeGenOpenCL/str_literals.cl
===
--- test/CodeGenOpenCL/str_literals.cl
+++ test/CodeGenOpenCL/str_literals.cl
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 %s -cl-opt-disable -emit-llvm -o - -ffake-address-space-map | FileCheck %s
 
-__constant char * __constant x = "hello world";
-__constant char * __constant y = "hello world";
+__constant char *__constant x = "hello world";
+__constant char *__constant y = "hello world";
 
-// CHECK: unnamed_addr addrspace(2) constant
+// CHECK: unnamed_addr addrspace(2) constant{{.*}}"hello world\00"
 // CHECK-NOT: addrspace(2) unnamed_addr constant
 // CHECK: @x = {{(dso_local )?}}addrspace(2) constant i8 addrspace(2)*
 // CHECK: @y = {{(dso_local )?}}addrspace(2) constant i8 addrspace(2)*
+// CHECK: unnamed_addr addrspace(2) constant{{.*}}"f\00"
+
+void f() {
+  //CHECK: store i8 addrspace(2)* {{.*}}, i8 addrspace(2)**
+  constant const char *f3 = __func__;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1551,17 +1551,14 @@
   if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
 CharTyConst.addConst();
 
+  CharTyConst = Context.adjustStringLiteralBaseType(CharTyConst);
+
   // Get an array type for the string, according to C99 6.4.5.  This includes
   // the nul terminator character as well as the string length for pascal
   // strings.
-  QualType StrTy = Context.getConstantArrayType(CharTyConst,
- llvm::APInt(32, Literal.GetNumStringChars()+1),
- ArrayType::Normal, 0);
-
-  // OpenCL v1.1 s6.5.3: a string literal is in the constant address space.
-  if (getLangOpts().OpenCL) {
-StrTy = Context.getAddrSpaceQualType(StrTy, LangAS::opencl_constant);
-  }
+  QualType StrTy = Context.getConstantArrayType(
+  CharTyConst, llvm::APInt(32, Literal.GetNumStringChars() + 1),
+  ArrayType::Normal, 0);
 
   // Pass &StringTokLocs[0], StringTokLocs.size() to factory!
   StringLiteral *Lit = StringLiteral::Create(Context, Literal.GetString(),
@@ -3042,16 +3039,17 @@
 
 llvm::APInt LengthI(32, Length + 1);
 if (IT == PredefinedExpr::LFunction) {
-  ResTy = Context.WideCharTy.withConst();
+  ResTy =
+  Context.adjustStringLiteralBaseType(Context.WideCharTy.withConst());
   SmallString<32> RawChars;
   ConvertUTF8ToWideString(Context.getTypeSizeInChars(ResTy).getQuantity(),
   Str, RawChars);
   ResTy = Context.getConstantArrayType(ResTy, LengthI, ArrayType::Normal,
/*IndexTypeQuals*/ 0);
   SL = StringLiteral::Create(Context, RawChars, StringLiteral::Wide,
  /*Pascal*/ false, ResTy, Loc);
 } else {
-  ResTy = Context.CharTy.withConst();
+  ResTy = Context.adjustStringLiteralBaseType(Context.CharTy.withConst());
   ResTy = Context.getConstantArrayType(ResTy, LengthI, ArrayType::Normal,
/*IndexTypeQuals*/ 0);
   SL = StringLiteral::Create(Context, Str, StringLiteral::Ascii,
@@ -3288,8 +3286,8 @@
   //   operator "" X ("n")
   unsigned Length = Literal.getUDSuffixOffset();
   QualType StrTy = Context.getConstantArrayType(
-  Context.CharTy.withConst(), llvm::APInt(32, Length + 1),
-  ArrayType::Normal, 0);
+  Context.adjustStringLiteralBaseType(Context.CharTy.withConst()),
+  llvm::APInt(32, Length + 1), ArrayType::Normal, 0);
   Expr *Lit = StringLiteral::Create(
   Context, StringRef(TokSpelling.data(), Length), StringLiteral::Ascii,
   /*Pascal*/false, StrTy, &TokLoc, 1);
@@ -13393,7 +13391,6 @@
   DiagKind = diag::err_typecheck_incompatible_address_space;
   break;
 
-
 } else if (lhq.getObjCLifetime() 

[PATCH] D45416: [AST, analyzer] Transform rvalue cast outputs to lvalues (fheinous-gnu-extensions)

2018-05-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin updated this revision to Diff 144998.
a.sidorin retitled this revision from "[analyzer] ExprEngine: model GCC inline 
asm rvalue cast outputs" to "[AST, analyzer] Transform rvalue cast outputs to 
lvalues (fheinous-gnu-extensions)".
a.sidorin edited the summary of this revision.
a.sidorin added a reviewer: rsmith.
a.sidorin added a comment.

Transform AST instead.
I don't remove analyzer guys from reviewers because the test is still for the 
analyzer.
@rsmith Feel free to correct me if I'm doing something wrong.


Repository:
  rC Clang

https://reviews.llvm.org/D45416

Files:
  lib/Sema/SemaStmtAsm.cpp
  test/Analysis/asm.cpp
  test/Analysis/cfg.cpp

Index: test/Analysis/cfg.cpp
===
--- test/Analysis/cfg.cpp
+++ test/Analysis/cfg.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -fheinous-gnu-extensions -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
 // RUN: FileCheck --input-file=%t -check-prefixes=CHECK,WARNINGS %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -fheinous-gnu-extensions -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
 // RUN: FileCheck --input-file=%t -check-prefixes=CHECK,ANALYZER %s
 
 // This file tests how we construct two different flavors of the Clang CFG -
@@ -84,6 +84,24 @@
   static_assert(1, "abc");
 }
 
+
+// CHECK-LABEL: void checkGCCAsmRValueOutput()
+// CHECK: [B2 (ENTRY)]
+// CHECK-NEXT: Succs (1): B1
+// CHECK: [B1]
+// CHECK-NEXT:   1: int arg
+// CHECK-NEXT:   2: arg
+// CHECK-NEXT:   3: (int)[B1.2] (CStyleCastExpr, NoOp, int)
+// CHECK-NEXT:   4: asm ("" : "=r" ([B1.3]));
+// CHECK-NEXT:   5: arg
+// CHECK-NEXT:   6: asm ("" : "=r" ([B1.5]));
+void checkGCCAsmRValueOutput() {
+  int arg;
+  __asm__("" : "=r"((int)arg));  // rvalue output operand
+  __asm__("" : "=r"(arg));   // lvalue output operand
+}
+
+
 // CHECK-LABEL: void F(EmptyE e)
 // CHECK: ENTRY
 // CHECK-NEXT: Succs (1): B1
Index: test/Analysis/asm.cpp
===
--- /dev/null
+++ test/Analysis/asm.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -fheinous-gnu-extensions -w %s -verify
+
+int clang_analyzer_eval(int);
+
+int global;
+void testRValueOutput() {
+  int &ref = global;
+  ref = 1;
+  __asm__("" : "=r"(((int)(global;  // don't crash on rvalue output operand
+  clang_analyzer_eval(global == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(ref == 1);// expected-warning{{UNKNOWN}}
+}
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -27,6 +27,58 @@
 using namespace clang;
 using namespace sema;
 
+/// Remove the upper-level LValueToRValue cast from an expression.
+static void removeLValueToRValueCast(Expr *E) {
+  Expr *Parent = E;
+  Expr *ExprUnderCast = nullptr;
+  SmallVector ParentsToUpdate;
+
+  while (true) {
+ParentsToUpdate.push_back(Parent);
+if (auto *ParenE = dyn_cast(Parent)) {
+  Parent = ParenE->getSubExpr();
+  continue;
+}
+
+Expr *Child = nullptr;
+CastExpr *ParentCast = dyn_cast(Parent);
+if (ParentCast)
+  Child = ParentCast->getSubExpr();
+else
+  return;
+
+if (auto *CastE = dyn_cast(Child))
+  if (CastE->getCastKind() == CK_LValueToRValue) {
+ExprUnderCast = CastE->getSubExpr();
+// LValueToRValue cast inside GCCAsmStmt requires an explicit cast.
+ParentCast->setSubExpr(ExprUnderCast);
+break;
+  }
+Parent = Child;
+  }
+
+  // Update parent expressions to have same ValueType as the underlying.
+  assert(ExprUnderCast &&
+ "Should be reachable only if LValueToRValue cast was found!");
+  auto ValueKind = ExprUnderCast->getValueKind();
+  for (Expr *E : ParentsToUpdate)
+E->setValueKind(ValueKind);
+}
+
+/// Emit a warning about usage of "noop"-like casts for lvalues (GNU extension)
+/// and fix the argument with removing LValueToRValue cast from the expression.
+static void emitAndFixInvalidAsmCastLValue(const Expr *LVal, Expr *BadArgument,
+   Sema &S) {
+  if (!S.getLangOpts().HeinousExtensions) {
+S.Diag(LVal->getLocStart(), diag::err_invalid_asm_cast_lvalue)
+<< BadArgument->getSourceRange();
+  } else {
+ 

Re: If I want to disable certain attributes, such as "swiftcall",isthere any way to do it now?

2018-05-03 Thread Aaron Ballman via cfe-commits
On Thu, May 3, 2018 at 1:25 AM, 朴素 <772847...@qq.com> wrote:
> hi, Aaron
>
>   The reason why i not use of TargetSpecificAttr is as follows.If I plan to
> support a new platform, I don't want to let users use certain attributes
> because of hardware or simply not want to. Yes, we can use
> TargetSpecificAttr, but if we use TargetSpecificAttr that we need to include
> platforms other than unsupported platforms, but we just need to exclude that
> platform, using TargetSpecificAttr may not be a good idea.

Okay, that makes sense to me. Your design seems like a reasonable one.

~Aaron

>
>
>
> -- 原始邮件 --
> 发件人: "Aaron Ballman";
> 发送时间: 2018年5月2日(星期三) 晚上10:05
> 收件人: "朴素"<772847...@qq.com>;
> 抄送: "cfe-commits";
> 主题: Re: If I want to disable certain attributes, such as "swiftcall",isthere
> any way to do it now?
>
> On Wed, May 2, 2018 at 4:59 AM, 朴素 <772847...@qq.com> wrote:
>> Thanks.
>>
>> If I remove some specific attributes, now I can think of the following
>> method.First of all, let me talk about my method.
>>
>> 1.Define target platforms that do not support attributes.such as def
>> TargetPower : TargetArch<["ppc", "ppc64", "ppc64le"]>;
>>
>> 2.Define TargetNotSupportedAttr class.such as class
>> TargetNotSupportedAttr ;
>
> Why not make use of TargetSpecificAttr to mark the attributes that are
> specific to a target rather than marking the attributes not supported
> by a target?
>
>> 3.Using this approach, we need to modify the
>> cfe-4.0.1.src/utils/TableGen/ClangAttrEmitter.cpp file.Modifying the code
>> in
>> the GenerateHasAttrSpellingStringSwitch function looks like this:
>>
>> if(Attr->isSubClassOf("TargetNotSupportedAttr")) {   // add
>>
>> #define GenerateTargetNotSupportedAttrChecks
>> GenerateTargetSpecificAttrChecks // add
>>
>> const Record *R = Attr->getValueAsDef("Target");   // add
>>
>> std::vector Arches =
>> R->getValueAsListOfStrings("Arches"); // add
>>
>> GenerateTargetNotSupportedAttrChecks(R, Arches, Test, nullptr);
>> // add
>>
>> TestStr = !Test.empty() ? Test + " ? "  + " 0 :" +
>> llvm::itostr(Version) : "0"; // add
>>
>> } else if (Attr->isSubClassOf("TargetSpecificAttr"))
>>
>> 4.And for classes that inherit from TargetNotSupportedAttr<> class, we
>> don’t
>> need to generate the attribute class, so add the following code in
>> EmitClangAttrClass
>>
>> if (R->getName() != "TargetSpecificAttr" &&
>>
>>   R->getName() != "TargetNotSupportedAttr” &&  //add
>>
>>   SuperName.empty())
>>
>> SuperName = R->getName();
>>
>>
>> If I use this method, is it correct?
>
> It seems like it would work, yes.
>
> ~Aaron
>
>>
>>
>>
>>
>> -- 原始邮件 --
>> 发件人: "Aaron Ballman";
>> 发送时间: 2018年4月29日(星期天) 凌晨3:07
>> 收件人: "朴素"<772847...@qq.com>;
>> 抄送: "cfe-commits";
>> 主题: Re: If I want to disable certain attributes, such as "swiftcall",
>> isthere any way to do it now?
>>
>> On Fri, Apr 27, 2018 at 11:23 PM, 朴素 via cfe-commits
>>  wrote:
>>>As the title says,thanks.
>>
>> You could build a custom clang with specific attributes removed, but
>> there are no compiler flags that allow you to disable arbitrary
>> attributes like swiftcall.
>>
>> ~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D45702#1085890, @shuaiwang wrote:

> In https://reviews.llvm.org/D45702#1085224, @aaron.ballman wrote:
>
> > > Have you run this over any large code bases to see whether the check 
> > > triggers in practice?
> >
> > I'm still curious about this, btw.
>
>
> Yes it triggers in Google's code base.


Were there any false positives that you saw?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



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


[PATCH] D41968: [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.

2018-05-03 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: chrib.

Sorry for the delay.

LGTM.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D41968



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


[PATCH] D46385: Fix test failure for missing _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS

2018-05-03 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik created this revision.
tzik added a reviewer: thakis.
Herald added subscribers: cfe-commits, christof.

This is a follow-up change to r331150. The CL moved the macro from individual
file to build file, but the macro is missed in a test config file.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D46385

Files:
  test/libcxxabi/test/config.py


Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -49,7 +49,10 @@
 self.config.available_features.add('libcxxabi-has-system-unwinder')
 
 def configure_compile_flags(self):
-self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
+self.cxx.compile_flags += [
+'-DLIBCXXABI_NO_TIMER',
+'-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS',
+]
 if self.get_lit_bool('enable_exceptions', True):
 self.cxx.compile_flags += ['-funwind-tables']
 else:


Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -49,7 +49,10 @@
 self.config.available_features.add('libcxxabi-has-system-unwinder')
 
 def configure_compile_flags(self):
-self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
+self.cxx.compile_flags += [
+'-DLIBCXXABI_NO_TIMER',
+'-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS',
+]
 if self.get_lit_bool('enable_exceptions', True):
 self.cxx.compile_flags += ['-funwind-tables']
 else:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


?????? If I want to disable certain attributes, such as"swiftcall",isthere any way to do it now?

2018-05-03 Thread ???? via cfe-commits
Thanks.




--  --
??: "Aaron Ballman";
: 2018??5??3??(??) 7:40
??: ""<772847...@qq.com>;
: "cfe-commits"; 
: Re: If I want to disable certain attributes, such as"swiftcall",isthere 
any way to do it now?



On Thu, May 3, 2018 at 1:25 AM,  <772847...@qq.com> wrote:
> hi, Aaron
>
>   The reason why i not use of TargetSpecificAttr is as follows.If I plan to
> support a new platform, I don't want to let users use certain attributes
> because of hardware or simply not want to. Yes, we can use
> TargetSpecificAttr, but if we use TargetSpecificAttr that we need to include
> platforms other than unsupported platforms, but we just need to exclude that
> platform, using TargetSpecificAttr may not be a good idea.

Okay, that makes sense to me. Your design seems like a reasonable one.

~Aaron

>
>
>
> --  --
> ??: "Aaron Ballman";
> : 2018??5??2??(??) 10:05
> ??: ""<772847...@qq.com>;
> : "cfe-commits";
> : Re: If I want to disable certain attributes, such as "swiftcall",isthere
> any way to do it now?
>
> On Wed, May 2, 2018 at 4:59 AM,  <772847...@qq.com> wrote:
>> Thanks.
>>
>> If I remove some specific attributes, now I can think of the following
>> method.First of all, let me talk about my method.
>>
>> 1.Define target platforms that do not support attributes.such as def
>> TargetPower : TargetArch<["ppc", "ppc64", "ppc64le"]>;
>>
>> 2.Define TargetNotSupportedAttr class.such as class
>> TargetNotSupportedAttr ;
>
> Why not make use of TargetSpecificAttr to mark the attributes that are
> specific to a target rather than marking the attributes not supported
> by a target?
>
>> 3.Using this approach, we need to modify the
>> cfe-4.0.1.src/utils/TableGen/ClangAttrEmitter.cpp file.Modifying the code
>> in
>> the GenerateHasAttrSpellingStringSwitch function looks like this:
>>
>> if(Attr->isSubClassOf("TargetNotSupportedAttr")) {   // add
>>
>> #define GenerateTargetNotSupportedAttrChecks
>> GenerateTargetSpecificAttrChecks // add
>>
>> const Record *R = Attr->getValueAsDef("Target");   // add
>>
>> std::vector Arches =
>> R->getValueAsListOfStrings("Arches"); // add
>>
>> GenerateTargetNotSupportedAttrChecks(R, Arches, Test, nullptr);
>> // add
>>
>> TestStr = !Test.empty() ? Test + " ? "  + " 0 :" +
>> llvm::itostr(Version) : "0"; // add
>>
>> } else if (Attr->isSubClassOf("TargetSpecificAttr"))
>>
>> 4.And for classes that inherit from TargetNotSupportedAttr<> class, we
>> don??t
>> need to generate the attribute class, so add the following code in
>> EmitClangAttrClass
>>
>> if (R->getName() != "TargetSpecificAttr" &&
>>
>>   R->getName() != "TargetNotSupportedAttr?? &&  //add
>>
>>   SuperName.empty())
>>
>> SuperName = R->getName();
>>
>>
>> If I use this method, is it correct?
>
> It seems like it would work, yes.
>
> ~Aaron
>
>>
>>
>>
>>
>> --  --
>> ??: "Aaron Ballman";
>> : 2018??4??29??(??) 3:07
>> ??: ""<772847...@qq.com>;
>> : "cfe-commits";
>> : Re: If I want to disable certain attributes, such as "swiftcall",
>> isthere any way to do it now?
>>
>> On Fri, Apr 27, 2018 at 11:23 PM,  via cfe-commits
>>  wrote:
>>>As the title says,thanks.
>>
>> You could build a custom clang with specific attributes removed, but
>> there are no compiler flags that allow you to disable arbitrary
>> attributes like swiftcall.
>>
>> ~Aaron___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331424 - [Sema] Do not match function type with const T in template argument deduction

2018-05-03 Thread Lei Liu via cfe-commits
Author: lliu0
Date: Wed May  2 18:43:23 2018
New Revision: 331424

URL: http://llvm.org/viewvc/llvm-project?rev=331424&view=rev
Log:
[Sema] Do not match function type with const T in template argument deduction

From http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584,
function type should not match cv-qualified type in template argument
deduction. This also matches what GCC and EDG do in template argument
deduction.

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


Added:
cfe/trunk/test/SemaTemplate/function-pointer-qualifier.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr15xx.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=331424&r1=331423&r2=331424&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed May  2 18:43:23 2018
@@ -1273,6 +1273,12 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   return Sema::TDK_Underqualified;
 }
 
+// Do not match a function type with a cv-qualified type.
+// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584
+if (Arg->isFunctionType() && Param.hasQualifiers()) {
+  return Sema::TDK_NonDeducedMismatch;
+}
+
 assert(TemplateTypeParm->getDepth() == Info.getDeducedDepth() &&
"saw template type parameter with wrong depth");
 assert(Arg != S.Context.OverloadTy && "Unresolved overloaded function");

Modified: cfe/trunk/test/CXX/drs/dr15xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr15xx.cpp?rev=331424&r1=331423&r2=331424&view=diff
==
--- cfe/trunk/test/CXX/drs/dr15xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr15xx.cpp Wed May  2 18:43:23 2018
@@ -357,6 +357,19 @@ auto DR1579_lambda_invalid = []() -> Gen
 };
 } // end namespace dr1579
 
+namespace dr1584 {
+  // Deducing function types from cv-qualified types
+  template void f(const T *); // expected-note {{candidate 
template ignored}}
+  template void g(T *, const T * = 0);
+  template void h(T *) { T::error; } // expected-error {{no 
members}}
+  template void h(const T *);
+  void i() {
+f(&i); // expected-error {{no matching function}}
+g(&i);
+h(&i); // expected-note {{here}}
+  }
+}
+
 namespace dr1589 {   // dr1589: 3.7 c++11
   // Ambiguous ranking of list-initialization sequences
 

Modified: cfe/trunk/test/CXX/drs/dr4xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr4xx.cpp?rev=331424&r1=331423&r2=331424&view=diff
==
--- cfe/trunk/test/CXX/drs/dr4xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr4xx.cpp Wed May  2 18:43:23 2018
@@ -796,24 +796,9 @@ namespace dr468 { // dr468: yes c++11
 }
 
 namespace dr469 { // dr469: no
-  // FIXME: The core issue here didn't really answer the question. We don't
-  // deduce 'const T' from a function or reference type in a class template...
-  template struct X; // expected-note 2{{here}}
+  template struct X; // expected-note {{here}}
   template struct X {};
   X x; // expected-error {{undefined}}
-  X y; // expected-error {{undefined}}
-
-  // ... but we do in a function template. GCC and EDG fail deduction of 'f'
-  // and the second 'h'.
-  template void f(const T *);
-  template void g(T *, const T * = 0);
-  template void h(T *) { T::error; }
-  template void h(const T *);
-  void i() {
-f(&i);
-g(&i);
-h(&i);
-  }
 }
 
 namespace dr470 { // dr470: yes

Added: cfe/trunk/test/SemaTemplate/function-pointer-qualifier.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/function-pointer-qualifier.cpp?rev=331424&view=auto
==
--- cfe/trunk/test/SemaTemplate/function-pointer-qualifier.cpp (added)
+++ cfe/trunk/test/SemaTemplate/function-pointer-qualifier.cpp Wed May  2 
18:43:23 2018
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template inline
+   void testparam(_Ty **, _Ty **)
+   {
+   }
+
+template inline
+   void testparam(_Ty *const *, _Ty **)
+   {
+   }
+
+template inline
+   void testparam(_Ty **, const _Ty **)
+   {
+   }
+
+template inline
+   void testparam(_Ty *const *, const _Ty **)
+   {
+   }
+
+void case0()
+{
+void (**p1)();
+void (**p2)();
+testparam(p1, p2);
+}


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


r331438 - Fix -Wunused-variable warning in Clang.cpp

2018-05-03 Thread Karl-Johan Karlsson via cfe-commits
Author: karka
Date: Wed May  2 22:53:29 2018
New Revision: 331438

URL: http://llvm.org/viewvc/llvm-project?rev=331438&view=rev
Log:
Fix -Wunused-variable warning in Clang.cpp

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=331438&r1=331437&r2=331438&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May  2 22:53:29 2018
@@ -1485,7 +1485,7 @@ void Clang::AddAArch64TargetArgs(const A
   CmdArgs.push_back("-aarch64-enable-global-merge=true");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_foutline)) {
+  if (Args.getLastArg(options::OPT_foutline)) {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-enable-machine-outliner");
   }


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


Re: clang_getIncudedFile python binding fix

2018-05-03 Thread Jonathan Coe via cfe-commits
This patch looks good to me - great work!

If you can upload it to https://reviews.llvm.org

then I can review and merge it for you once it's approved.

regards,

Jon

On 3 May 2018 at 08:55, József LÁZ via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi all,
>
> I made fix in clang’s python bindings. The binding for C api’s
> clang_getIncludedFile was not implemented. The patch was made on trunk.
>
> I believe this bugticket is related: https://bugs.llvm.org/show_
> bug.cgi?id=15223
>
> Any thoughts?
>
>
>
> József Láz
> --
> This message, including its attachments, is confidential and the property
> of NNG Llc. For more information please read NNG's email policy here:
> https://www.nng.com/email-policy/
> By responding to this email you accept the email policy.
>
> ___
> 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


[libcxxabi] r331450 - Fix test failure for missing _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS

2018-05-03 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu May  3 05:44:27 2018
New Revision: 331450

URL: http://llvm.org/viewvc/llvm-project?rev=331450&view=rev
Log:
Fix test failure for missing _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS

This is a follow-up change to r331150. The CL moved the macro from individual
file to build file, but the macro is missed in a test config file.

https://reviews.llvm.org/D46385
Patch from Taiju Tsuiki !

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=331450&r1=331449&r2=331450&view=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Thu May  3 05:44:27 2018
@@ -49,7 +49,10 @@ class Configuration(LibcxxConfiguration)
 self.config.available_features.add('libcxxabi-has-system-unwinder')
 
 def configure_compile_flags(self):
-self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
+self.cxx.compile_flags += [
+'-DLIBCXXABI_NO_TIMER',
+'-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS',
+]
 if self.get_lit_bool('enable_exceptions', True):
 self.cxx.compile_flags += ['-funwind-tables']
 else:


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


[PATCH] D46385: Fix test failure for missing _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS

2018-05-03 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r331450, thanks!


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D46385



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


[PATCH] D46386: Adding __atomic_fetch_min/max intrinsics to clang

2018-05-03 Thread Elena Demikhovsky via Phabricator via cfe-commits
delena created this revision.
delena added reviewers: igorb, t.p.northover, ABataev, jfb, rjmccall.
Herald added subscribers: cfe-commits, Anastasia.

Added __atomic_fetch_min, max, umin, umax intrinsics to clang.
These intrinsics work exactly as all other __atomic_fetch_* intrinsics and 
allow to create *atomicrmw* with ordering.
The similar set __sync_fetch_and_min* sets the sequentially-consistent  
ordering.

We use them for OpenCL 1.2, which supports atomic operations with "relaxed" 
ordering.


Repository:
  rC Clang

https://reviews.llvm.org/D46386

Files:
  include/clang/Basic/Builtins.def
  lib/AST/Expr.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -173,6 +173,7 @@
   __atomic_fetch_sub(P, 3, memory_order_seq_cst);
   __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
   __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+  __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
 
   __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
   __c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
@@ -456,6 +457,34 @@
   (void)__atomic_fetch_nand(p, val, memory_order_acq_rel);
   (void)__atomic_fetch_nand(p, val, memory_order_seq_cst);
 
+  (void)__atomic_fetch_min(p, val, memory_order_relaxed);
+  (void)__atomic_fetch_min(p, val, memory_order_acquire);
+  (void)__atomic_fetch_min(p, val, memory_order_consume);
+  (void)__atomic_fetch_min(p, val, memory_order_release);
+  (void)__atomic_fetch_min(p, val, memory_order_acq_rel);
+  (void)__atomic_fetch_min(p, val, memory_order_seq_cst);
+
+  (void)__atomic_fetch_max(p, val, memory_order_relaxed);
+  (void)__atomic_fetch_max(p, val, memory_order_acquire);
+  (void)__atomic_fetch_max(p, val, memory_order_consume);
+  (void)__atomic_fetch_max(p, val, memory_order_release);
+  (void)__atomic_fetch_max(p, val, memory_order_acq_rel);
+  (void)__atomic_fetch_max(p, val, memory_order_seq_cst);
+
+  (void)__atomic_fetch_umin(p, val, memory_order_relaxed);
+  (void)__atomic_fetch_umin(p, val, memory_order_acquire);
+  (void)__atomic_fetch_umin(p, val, memory_order_consume);
+  (void)__atomic_fetch_umin(p, val, memory_order_release);
+  (void)__atomic_fetch_umin(p, val, memory_order_acq_rel);
+  (void)__atomic_fetch_umin(p, val, memory_order_seq_cst);
+
+  (void)__atomic_fetch_umax(p, val, memory_order_relaxed);
+  (void)__atomic_fetch_umax(p, val, memory_order_acquire);
+  (void)__atomic_fetch_umax(p, val, memory_order_consume);
+  (void)__atomic_fetch_umax(p, val, memory_order_release);
+  (void)__atomic_fetch_umax(p, val, memory_order_acq_rel);
+  (void)__atomic_fetch_umax(p, val, memory_order_seq_cst);
+
   (void)__atomic_and_fetch(p, val, memory_order_relaxed);
   (void)__atomic_and_fetch(p, val, memory_order_acquire);
   (void)__atomic_and_fetch(p, val, memory_order_consume);
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3037,6 +3037,7 @@
  Op == AtomicExpr::AO__atomic_exchange_n ||
  Op == AtomicExpr::AO__atomic_compare_exchange_n;
   bool IsAddSub = false;
+  bool IsMinMax = false;
 
   switch (Op) {
   case AtomicExpr::AO__c11_atomic_init:
@@ -3090,6 +3091,14 @@
 Form = Arithmetic;
 break;
 
+  case AtomicExpr::AO__atomic_fetch_min:
+  case AtomicExpr::AO__atomic_fetch_max:
+  case AtomicExpr::AO__atomic_fetch_umin:
+  case AtomicExpr::AO__atomic_fetch_umax:
+IsMinMax = true;
+Form = Arithmetic;
+break;
+
   case AtomicExpr::AO__c11_atomic_exchange:
   case AtomicExpr::AO__opencl_atomic_exchange:
   case AtomicExpr::AO__atomic_exchange_n:
@@ -3172,12 +3181,13 @@
   // For an arithmetic operation, the implied arithmetic must be well-formed.
   if (Form == Arithmetic) {
 // gcc does not enforce these rules for GNU atomics, but we do so for sanity.
-if (IsAddSub && !ValType->isIntegerType() && !ValType->isPointerType()) {
+if ((IsAddSub || IsMinMax) && !ValType->isIntegerType()
+&& !ValType->isPointerType()) {
   Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic_int_or_ptr)
 << IsC11 << Ptr->getType() << Ptr->getSourceRange();
   return ExprError();
 }
-if (!IsAddSub && !ValType->isIntegerType()) {
+if (!IsAddSub && !IsMinMax && !ValType->isIntegerType()) {
   Diag(DRE->getLocStart(), diag::err_atomic_op_bitwise_needs_atomic_int)
 << IsC11 << Ptr->getType() << Ptr->getSourceRange();
   return ExprError();
Index: lib/CodeGen/CGAtomic.cpp
===
--- lib/Code

Re: [libcxxabi] r331150 - Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

2018-05-03 Thread Nico Weber via cfe-commits
r331450 should hopefully fix this.

On Tue, May 1, 2018 at 8:55 AM, Nico Weber  wrote:

> tzik, can you take a look what's up on those bots?
>
> On Tue, May 1, 2018, 5:48 AM Maxim Kuvyrkov 
> wrote:
>
>> Hi Nico,
>>
>> This broke armv7 and aarch64 bots:
>> - http://lab.llvm.org:8011/builders/libcxx-libcxxabi-
>> libunwind-armv7-linux/builds/87
>> - http://lab.llvm.org:8011/builders/libcxx-libcxxabi-
>> libunwind-aarch64-linux/builds/1304
>>
>> Would you please investigate?
>>
>> --
>> Maxim Kuvyrkov
>> www.linaro.org
>>
>>
>>
>> > On Apr 30, 2018, at 2:10 AM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >
>> > This should have said "Patch from Taiju Tsuiki ",
>> apologies.
>> >
>> > On Sun, Apr 29, 2018 at 7:05 PM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> > Author: nico
>> > Date: Sun Apr 29 16:05:11 2018
>> > New Revision: 331150
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=331150&view=rev
>> > Log:
>> > Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build
>> system
>> >
>> > _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS is currently used to
>> > bring back std::unexpected, which is removed in C++17, but still needed
>> > for libc++abi for backward compatibility.
>> >
>> > This macro used to define in cxa_exception.cpp only, but actually
>> > needed for all sources that touches exceptions.
>> > So, a build-system-level macro is better fit to define this macro.
>> >
>> > https://reviews.llvm.org/D46056
>> > Patch from Taiju Tsuiku !
>> >
>> > Modified:
>> > libcxxabi/trunk/CMakeLists.txt
>> > libcxxabi/trunk/src/cxa_exception.cpp
>> > libcxxabi/trunk/test/test_exception_storage.pass.cpp
>> >
>> > Modified: libcxxabi/trunk/CMakeLists.txt
>> > URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/
>> CMakeLists.txt?rev=331150&r1=331149&r2=331150&view=diff
>> > 
>> ==
>> > --- libcxxabi/trunk/CMakeLists.txt (original)
>> > +++ libcxxabi/trunk/CMakeLists.txt Sun Apr 29 16:05:11 2018
>> > @@ -387,6 +387,10 @@ endif()
>> >  # Prevent libc++abi from having library dependencies on libc++
>> >  add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE)
>> >
>> > +# Bring back `std::unexpected`, which is removed in C++17, to support
>> > +# pre-C++17.
>> > +add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS)
>> > +
>> >  if (MSVC)
>> >add_definitions(-D_CRT_SECURE_NO_WARNINGS)
>> >  endif()
>> >
>> > Modified: libcxxabi/trunk/src/cxa_exception.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
>> cxa_exception.cpp?rev=331150&r1=331149&r2=331150&view=diff
>> > 
>> ==
>> > --- libcxxabi/trunk/src/cxa_exception.cpp (original)
>> > +++ libcxxabi/trunk/src/cxa_exception.cpp Sun Apr 29 16:05:11 2018
>> > @@ -11,8 +11,6 @@
>> >  //
>> >  //===---
>> ---===//
>> >
>> > -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
>> > -
>> >  #include "cxxabi.h"
>> >
>> >  #include // for std::terminate
>> >
>> > Modified: libcxxabi/trunk/test/test_exception_storage.pass.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/
>> test_exception_storage.pass.cpp?rev=331150&r1=331149&r2=331150&view=diff
>> > 
>> ==
>> > --- libcxxabi/trunk/test/test_exception_storage.pass.cpp (original)
>> > +++ libcxxabi/trunk/test/test_exception_storage.pass.cpp Sun Apr 29
>> 16:05:11 2018
>> > @@ -7,11 +7,6 @@
>> >  //
>> >  //===---
>> ---===//
>> >
>> > -// FIXME: cxa_exception.hpp directly references `std::unexpected` and
>> friends.
>> > -// This breaks this test when compiled in C++17. For now fix this by
>> manually
>> > -// re-enabling the STL functions.
>> > -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
>> > -
>> >  #include 
>> >  #include 
>> >  #include 
>> >
>> >
>> > ___
>> > 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
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46370: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D46370



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

As Devin says (and as we discussed this with Anna Zaks) alpha checkers are 
still in development, so we don't want to expose them to the users, even very 
curious ones. For those who want to help with development of the alpha 
checkers, there's always a possibility to change one boolean literal in 
clang-tidy sources and build their own clang-tidy binary. Or one can use clang 
-analyze. Are there any use cases not covered by these two options?




Comment at: clang-tidy/ClangTidy.cpp:373-376
   // FIXME: Remove this option once clang's cfg-temporary-dtors option defaults
   // to true.
   AnalyzerOptions->Config["cfg-temporary-dtors"] =
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";

NoQ wrote:
> Btw this is already enabled by default.
Should we kill the flag completely?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2018-05-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 145008.
baloghadamsoftware added a comment.

Rebased, and minor modifications done according to the comments.


https://reviews.llvm.org/D32906

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/iterator-range.cpp
  test/Analysis/mismatched-iterator.cpp

Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -144,6 +144,19 @@
   v1.insert(i, n); // expected-warning{{Iterator access mismatched}}
 }
 
+template
+bool is_cend(Container cont, Iterator it) {
+  return it == cont.cend();
+}
+
+void good_empty(std::vector &v) {
+  is_cend(v, v.cbegin()); // no-warning
+}
+
+void bad_empty(std::vector &v1, std::vector &v2) {
+  is_cend(v1, v2.cbegin()); // expected-warning@149{{Iterator access mismatched}}
+}
+
 void good_move(std::vector &v1, std::vector &v2) {
   const auto i0 = ++v2.cbegin();
   v1 = std::move(v2);
Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -216,6 +216,11 @@
 *first; // no-warning
 }
 
+void bad_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
 void tricky(std::vector &V, int e) {
   const auto first = V.begin();
   const auto comp1 = (first != V.end()), comp2 = (first == V.end());
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -200,8 +200,8 @@
  check::PreStmt,
  check::PreStmt,
  check::PostStmt, check::Bind,
- check::LiveSymbols, check::DeadSymbols,
- eval::Assume, eval::Call> {
+ check::BeginFunction, check::LiveSymbols,
+ check::DeadSymbols, eval::Assume, eval::Call> {
   mutable IdentifierInfo *II_find = nullptr, *II_find_end = nullptr,
  *II_find_first_of = nullptr, *II_find_if = nullptr,
  *II_find_if_not = nullptr, *II_lower_bound = nullptr,
@@ -292,6 +292,7 @@
   void checkPreStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
   void checkPreStmt(const CXXOperatorCallExpr *COCE, CheckerContext &C) const;
   void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const;
+  void checkBeginFunction(CheckerContext &C) const;
   void checkPostStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
   void checkPostStmt(const DeclStmt *DS, CheckerContext &C) const;
   void checkPostStmt(const MaterializeTemporaryExpr *MTE,
@@ -783,6 +784,39 @@
   }
 }
 
+void IteratorChecker::checkBeginFunction(CheckerContext &C) const {
+  // Copy state of iterator arguments to iterator parameters
+  auto State = C.getState();
+  const auto *LCtx = C.getLocationContext();
+
+  const auto *Site = cast(LCtx)->getCallSite();
+  if (!Site)
+return;
+
+  const auto *FD = dyn_cast(LCtx->getDecl());
+  if (!FD)
+return;
+
+  const auto *CE = dyn_cast(Site);
+  if (!CE)
+return;
+
+  bool Change = false;
+  int idx = 0;
+  for (const auto *P : FD->parameters()) {
+auto Arg = State->getSVal(CE->getArg(idx++), LCtx->getParent());
+const auto *Pos = getIteratorPosition(State, Arg);
+if (!Pos)
+  continue;
+auto Param = State->getLValue(P, LCtx);
+State = setIteratorPosition(State, Param, *Pos);
+Change = true;
+  }
+  if (Change) {
+C.addTransition(State);
+  }
+}
+
 void IteratorChecker::checkPostStmt(const MaterializeTemporaryExpr *MTE,
 CheckerContext &C) const {
   /* Transfer iterator state to temporary objects */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

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

In https://reviews.llvm.org/D46159#1086322, @alexfh wrote:

>


How about `-enable-alpha-checks=yes-i-know-they-are-broken` ?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46183: [clangd] Incorporate #occurrences in scoring code complete results.

2018-05-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 145011.
sammccall added a comment.

Add completion test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46183

Files:
  clangd/CodeComplete.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -144,6 +144,10 @@
 Symbol var(StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
 }
+Symbol withReferences(int N, Symbol S) {
+  S.References = N;
+  return S;
+}
 
 TEST(CompletionTest, Limit) {
   clangd::CodeCompleteOptions Opts;
@@ -426,10 +430,18 @@
 TEST(CompletionTest, Scoped) {
   auto Results = completions(
   R"cpp(
-  namespace fake { int Babble, Ball; };
+  namespace fake { int BigBang, Ball; };
+  int main() { fake::bb^ }
+  ")cpp",
+  {var("fake::Babble")});
+  EXPECT_THAT(Results.items, ElementsAre(Named("BigBang"), Named("Babble")));
+  // With references signal, Babble is ranked higher.
+  Results = completions(
+  R"cpp(
+  namespace fake { int BigBang, Ball; };
   int main() { fake::bb^ }
   ")cpp",
-  {var("fake::BigBang")});
+  {withReferences(1, var("fake::Babble"))});
   EXPECT_THAT(Results.items, ElementsAre(Named("BigBang"), Named("Babble")));
 }
 
Index: clangd/index/MemIndex.cpp
===
--- clangd/index/MemIndex.cpp
+++ clangd/index/MemIndex.cpp
@@ -47,7 +47,7 @@
 continue;
 
   if (auto Score = Filter.match(Sym->Name)) {
-Top.emplace(-*Score, Sym);
+Top.emplace(-*Score * quality(*Sym), Sym);
 if (Top.size() > Req.MaxCandidateCount) {
   More = true;
   Top.pop();
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -199,6 +199,12 @@
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S);
 
+// Computes query-independent quality score for a Symbol.
+// This currently falls in the range [1, ln(#indexed documents)].
+// FIXME: this should probably be split into symbol -> signals
+//and signals -> score, so it can be reused for Sema completions.
+double quality(const Symbol &S);
+
 // An immutable symbol container that stores a set of symbols.
 // The container will maintain the lifetime of the symbols.
 class SymbolSlab {
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -48,6 +48,14 @@
   return OS << S.Scope << S.Name;
 }
 
+double quality(const Symbol &S) {
+  // This avoids a sharp gradient for tail symbols, and also neatly avoids the
+  // question of whether 0 references means a bad symbol or missing data.
+  if (S.References < 3)
+return 1;
+  return std::log(S.References);
+}
+
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
   auto It = std::lower_bound(Symbols.begin(), Symbols.end(), ID,
  [](const Symbol &S, const SymbolID &I) {
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -229,24 +229,27 @@
 
   // Computes the "symbol quality" score for this completion. Higher is better.
   float score() const {
-// For now we just use the Sema priority, mapping it onto a 0-1 interval.
-if (!SemaResult) // FIXME(sammccall): better scoring for index results.
-  return 0.3f;   // fixed mediocre score for index-only results.
-
-// Priority 80 is a really bad score.
-float Score = 1 - std::min(80, SemaResult->Priority) / 80;
-
-switch (static_cast(SemaResult->Availability)) {
-case CXAvailability_Available:
-  // No penalty.
-  break;
-case CXAvailability_Deprecated:
-  Score *= 0.1f;
-  break;
-case CXAvailability_NotAccessible:
-case CXAvailability_NotAvailable:
-  Score = 0;
-  break;
+float Score = 1;
+if (IndexResult)
+  Score *= quality(*IndexResult);
+if (SemaResult) {
+  // For now we just use the Sema priority, mapping it onto a 0-2 interval.
+  // That makes 1 neutral-ish, so we don't reward/penalize non-Sema results.
+  // Priority 80 is a really bad score.
+  Score *= 2 - std::min(80, SemaResult->Priority) / 40;
+
+  switch (static_cast(SemaResult->Availability)) {
+  case CXAvailability_Available:
+// No penalty.
+break;
+  case CXAvailability_Deprecated:
+Score *= 0.1f;
+break;
+  case CXAvailability_NotAccessible:
+  case CXAvailability_NotAvailable:
+Score = 0;
+break;
+  }
 }
 return Score;

[PATCH] D46183: [clangd] Incorporate #occurrences in scoring code complete results.

2018-05-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Added a test - it's kind of perfunctory, I really want to organize symbol 
scoring more thoroughly which will provide a better place to test well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46183



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


[PATCH] D46353: [ASTImporter] Extend lookup logic in class templates

2018-05-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Gabor,

Thank you for the patch. It looks mostly good, but I have a question: should we 
add this new declaration to the redeclaration chain like we do it for 
RecordDecls?


Repository:
  rC Clang

https://reviews.llvm.org/D46353



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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2018-05-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Rafael,

Could you please show the AST we get with `getDecomposedExpansionLoc()`? This 
change can be an item for a separate patch.


https://reviews.llvm.org/D26054



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


[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-05-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Peter! This looks almost OK, just some minor formatting issues.




Comment at: unittests/AST/ASTImporterTest.cpp:1509
+  MatchVerifier Verifier;
+  testImport("template  struct S {static T foo;};"
+ "template  void declToImport() {"

Please add spaces after and before `{}`.



Comment at: unittests/AST/ASTImporterTest.cpp:1510
+  testImport("template  struct S {static T foo;};"
+ "template  void declToImport() {"
+ "  (void) S::foo;"

Indentation is a bit off here and in the samples below.


https://reviews.llvm.org/D38845



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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2018-05-03 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added a comment.

It puts everything at the start of the marco expansion.

  `-FunctionDecl 0x12f5218 prev 0x12f4fa0  line:12:5 used 
foo 'int ()'
`-CompoundStmt 0x12f5600 
  |-DeclStmt 0x12f5508 
  | `-VarDecl 0x12f5470  col:15 used s 'struct S *' cinit
  |   `-ImplicitCastExpr 0x12f54f0  'struct S *' 
  | `-IntegerLiteral 0x12f54d0  'unsigned int' 2147516416
  `-ParenExpr 0x12f55e0  'int'
`-BinaryOperator 0x12f55b8  'int' '='
  |-MemberExpr 0x12f5560  'int' lvalue ->a 0x12f5378
  | `-ImplicitCastExpr 0x12f5548  'struct S *' 
  |   `-DeclRefExpr 0x12f5520  'struct S *' lvalue Var 0x12f5470 
's' 'struct S *'
  `-IntegerLiteral 0x12f5598  'int' 0


https://reviews.llvm.org/D26054



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


[PATCH] D44934: [analyzer] Improve the modeling of `memset()`.

2018-05-03 Thread Henry Wong via Phabricator via cfe-commits
MTC updated this revision to Diff 145019.
MTC added a comment.

- fix typos
- code refactoring, add auxiliary method `memsetAux()`
- according to a.sidorin's suggestions, remove the useless state splitting.
- make `StoreManager::overwriteRegion()` pure virtual


Repository:
  rC Clang

https://reviews.llvm.org/D44934

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/bstring.cpp
  test/Analysis/null-deref-ps-region.c
  test/Analysis/string.c

Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -1,7 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DSUPPRESS_OUT_OF_BOUND -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring.BufferOverlap,alpha.unix.cstring.NotNullTerminated,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
 
 //===--===
 // Declarations
@@ -1159,6 +1160,248 @@
   clang_analyzer_eval(str[1] == 'b'); // expected-warning{{UNKNOWN}}
 }
 
+//===--===
+// memset()
+//===--===
+
+void *memset( void *dest, int ch, size_t count );
+
+void* malloc(size_t size);
+void free(void*);
+
+void memset1_char_array_null() {
+  char str[] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  memset(str, '\0', 2);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{TRUE}}
+}
+
+void memset2_char_array_null() {
+  char str[] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  memset(str, '\0', strlen(str) + 1);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(str[2] == 0);  // expected-warning{{TRUE}}
+}
+
+void memset3_char_malloc_null() {
+  char *str = (char *)malloc(10 * sizeof(char));
+  memset(str + 1, '\0', 8);
+  clang_analyzer_eval(str[1] == 0); // expected-warning{{UNKNOWN}}
+  free(str);
+}
+
+void memset4_char_malloc_null() {
+  char *str = (char *)malloc(10 * sizeof(char));
+  //void *str = malloc(10 * sizeof(char));
+  memset(str, '\0', 10);
+  clang_analyzer_eval(str[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{TRUE}}
+  free(str);
+}
+
+#ifdef SUPPRESS_OUT_OF_BOUND
+void memset5_char_malloc_overflow_null() {
+  char *str = (char *)malloc(10 * sizeof(char));
+  memset(str, '\0', 12);
+  clang_analyzer_eval(str[1] == 0); // expected-warning{{UNKNOWN}}
+  free(str);
+}
+#endif
+
+void memset6_char_array_nonnull() {
+  char str[] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  memset(str, '0', 2);
+  clang_analyzer_eval(str[0] == 'a');// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{UNKNOWN}}
+}
+
+void memset7_char_array_nonnull() {
+  char str[5] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  memset(str, '0', 5);
+  clang_analyzer_eval(str[0] == '0');// expected-warning{{TRUE}}
+  clang_analyzer_eval(strlen(str) >= 5); // expected-warning{{TRUE}}
+}
+
+#ifdef SUPPRESS_OUT_OF_BOUND
+void memset8_char_array_

[clang-tools-extra] r331456 - [clang-tidy] Remove AnalyzeTemporaryDtors option.

2018-05-03 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  3 07:40:37 2018
New Revision: 331456

URL: http://llvm.org/viewvc/llvm-project?rev=331456&view=rev
Log:
[clang-tidy] Remove AnalyzeTemporaryDtors option.

Remove the `AnalyzeTemporaryDtors` option, since the corresponding
`cfg-temporary-dtors` option of the Static Analyzer defaults to `true` since
r326461.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.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/temporaries.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyOptionsTest.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=331456&r1=331455&r2=331456&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu May  3 07:40:37 2018
@@ -369,11 +369,6 @@ ClangTidyASTConsumerFactory::CreateASTCo
 Consumers.push_back(Finder->newASTConsumer());
 
   AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
-  // FIXME: Remove this option once clang's cfg-temporary-dtors option defaults
-  // to true.
-  AnalyzerOptions->Config["cfg-temporary-dtors"] =
-  Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
-
   AnalyzerOptions->CheckersControlList = getCheckersControlList(Context);
   if (!AnalyzerOptions->CheckersControlList.empty()) {
 setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=331456&r1=331455&r2=331456&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Thu May  3 07:40:37 
2018
@@ -86,7 +86,6 @@ template <> struct MappingTraitsOptions);
@@ -107,7 +106,6 @@ ClangTidyOptions ClangTidyOptions::getDe
   Options.WarningsAsErrors = "";
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
-  Options.AnalyzeTemporaryDtors = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
@@ -147,7 +145,6 @@ ClangTidyOptions::mergeWith(const ClangT
   mergeCommaSeparatedLists(Result.WarningsAsErrors, Other.WarningsAsErrors);
   overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
   overrideValue(Result.SystemHeaders, Other.SystemHeaders);
-  overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors);
   overrideValue(Result.FormatStyle, Other.FormatStyle);
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h?rev=331456&r1=331455&r2=331456&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h Thu May  3 07:40:37 
2018
@@ -74,9 +74,6 @@ struct ClangTidyOptions {
   /// \brief Output warnings from system headers matching \c HeaderFilterRegex.
   llvm::Optional SystemHeaders;
 
-  /// \brief Turns on temporary destructor-based analysis.
-  llvm::Optional AnalyzeTemporaryDtors;
-
   /// \brief Format code around applied fixes with clang-format using this
   /// style.
   ///

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=331456&r1=331455&r2=331456&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu May  3 
07:40:37 2018
@@ -41,7 +41,6 @@ Configuration files:
 Checks:  '-*,some-check'
 WarningsAsErrors: ''
 HeaderFilterRegex: ''
-AnalyzeTemporaryDtors: false
 FormatStyle: none
 User:user
 CheckOptions:
@@ -182,16 +181,6 @@ report to stderr.
 cl::init(false),
 cl::cat(ClangTidyCategory));
 
-static cl::opt AnalyzeTemporaryDtors("analyze-temporary-dtors",
-   cl::desc(R"(
-Enable temporary destructor-aware a

[PATCH] D46183: [clangd] Incorporate #occurrences in scoring code complete results.

2018-05-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 145021.
sammccall added a comment.

Fix tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46183

Files:
  clangd/CodeComplete.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -144,6 +144,13 @@
 Symbol var(StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
 }
+Symbol ns(StringRef Name) {
+  return sym(Name, index::SymbolKind::Namespace, "@N@\\0");
+}
+Symbol withReferences(int N, Symbol S) {
+  S.References = N;
+  return S;
+}
 
 TEST(CompletionTest, Limit) {
   clangd::CodeCompleteOptions Opts;
@@ -443,6 +450,14 @@
   UnorderedElementsAre(AllOf(Named("XYZ"), Filter("XYZ";
 }
 
+TEST(CompletionTest, ReferencesAffectRanking) {
+  auto Results = completions("int main() { abs^ }", {ns("absl"), func("abs")});
+  EXPECT_THAT(Results.items, HasSubsequence(Named("abs"), Named("absl")));
+  Results = completions("int main() { abs^ }",
+{withReferences(1, ns("absl")), func("abs")});
+  EXPECT_THAT(Results.items, HasSubsequence(Named("absl"), Named("abs")));
+}
+
 TEST(CompletionTest, GlobalQualified) {
   auto Results = completions(
   R"cpp(
Index: clangd/index/MemIndex.cpp
===
--- clangd/index/MemIndex.cpp
+++ clangd/index/MemIndex.cpp
@@ -47,7 +47,7 @@
 continue;
 
   if (auto Score = Filter.match(Sym->Name)) {
-Top.emplace(-*Score, Sym);
+Top.emplace(-*Score * quality(*Sym), Sym);
 if (Top.size() > Req.MaxCandidateCount) {
   More = true;
   Top.pop();
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -199,6 +199,12 @@
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S);
 
+// Computes query-independent quality score for a Symbol.
+// This currently falls in the range [1, ln(#indexed documents)].
+// FIXME: this should probably be split into symbol -> signals
+//and signals -> score, so it can be reused for Sema completions.
+double quality(const Symbol &S);
+
 // An immutable symbol container that stores a set of symbols.
 // The container will maintain the lifetime of the symbols.
 class SymbolSlab {
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -48,6 +48,14 @@
   return OS << S.Scope << S.Name;
 }
 
+double quality(const Symbol &S) {
+  // This avoids a sharp gradient for tail symbols, and also neatly avoids the
+  // question of whether 0 references means a bad symbol or missing data.
+  if (S.References < 3)
+return 1;
+  return std::log(S.References);
+}
+
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
   auto It = std::lower_bound(Symbols.begin(), Symbols.end(), ID,
  [](const Symbol &S, const SymbolID &I) {
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -229,24 +229,27 @@
 
   // Computes the "symbol quality" score for this completion. Higher is better.
   float score() const {
-// For now we just use the Sema priority, mapping it onto a 0-1 interval.
-if (!SemaResult) // FIXME(sammccall): better scoring for index results.
-  return 0.3f;   // fixed mediocre score for index-only results.
-
-// Priority 80 is a really bad score.
-float Score = 1 - std::min(80, SemaResult->Priority) / 80;
-
-switch (static_cast(SemaResult->Availability)) {
-case CXAvailability_Available:
-  // No penalty.
-  break;
-case CXAvailability_Deprecated:
-  Score *= 0.1f;
-  break;
-case CXAvailability_NotAccessible:
-case CXAvailability_NotAvailable:
-  Score = 0;
-  break;
+float Score = 1;
+if (IndexResult)
+  Score *= quality(*IndexResult);
+if (SemaResult) {
+  // For now we just use the Sema priority, mapping it onto a 0-2 interval.
+  // That makes 1 neutral-ish, so we don't reward/penalize non-Sema results.
+  // Priority 80 is a really bad score.
+  Score *= 2 - std::min(80, SemaResult->Priority) / 40;
+
+  switch (static_cast(SemaResult->Availability)) {
+  case CXAvailability_Available:
+// No penalty.
+break;
+  case CXAvailability_Deprecated:
+Score *= 0.1f;
+break;
+  case CXAvailability_NotAccessible:
+  case CXAvailability_NotAvailable:
+Score = 0;
+break;
+  }
 }
 return Score;
   }
___

[PATCH] D46393: Remove explicit cfg-temporary-dtors=true

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added a reviewer: NoQ.

Remove explicit -analyzer-config cfg-temporary-dtors=true in analyzer tests,
since this option defaults to true since r326461.


Repository:
  rC Clang

https://reviews.llvm.org/D46393

Files:
  test/Analysis/cfg-rich-constructors.cpp
  test/Analysis/cfg.cpp
  test/Analysis/dtor-cxx11.cpp
  test/Analysis/dtor.cpp
  test/Analysis/gtest.cpp
  test/Analysis/temp-obj-dtors-cfg-output.cpp
  test/Analysis/temp-obj-dtors-option.cpp


Index: test/Analysis/temp-obj-dtors-option.cpp
===
--- test/Analysis/temp-obj-dtors-option.cpp
+++ test/Analysis/temp-obj-dtors-option.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=false -verify 
%s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -DINLINE 
-verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config c++-temp-dtor-inlining=false -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config c++-temp-dtor-inlining=true -DINLINE -verify %s
 
 void clang_analyzer_eval(bool);
 
Index: test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -1,11 +1,11 @@
 // RUN: rm -f %t
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true,cfg-rich-constructors=false -std=c++98 %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-rich-constructors=false -std=c++98 %s > %t 2>&1
 // RUN: FileCheck --input-file=%t 
-check-prefixes=CHECK,CXX98,WARNINGS,CXX98-WARNINGS %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true,cfg-rich-constructors=false -std=c++11 %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-rich-constructors=false -std=c++11 %s > %t 2>&1
 // RUN: FileCheck --input-file=%t 
-check-prefixes=CHECK,CXX11,WARNINGS,CXX11-WARNINGS %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true,cfg-rich-constructors=true -std=c++98 %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-rich-constructors=true -std=c++98 %s > %t 2>&1
 // RUN: FileCheck --input-file=%t 
-check-prefixes=CHECK,CXX98,ANALYZER,CXX98-ANALYZER %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true,cfg-rich-constructors=true -std=c++11 %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-rich-constructors=true -std=c++11 %s > %t 2>&1
 // RUN: FileCheck --input-file=%t 
-check-prefixes=CHECK,CXX11,ANALYZER,CXX11-ANALYZER %s
 
 // This file tests how we construct two different flavors of the Clang CFG -
Index: test/Analysis/gtest.cpp
===
--- test/Analysis/gtest.cpp
+++ test/Analysis/gtest.cpp
@@ -1,6 +1,5 @@
 //RUN: %clang_analyze_cc1 -cc1 -std=c++11  
-analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection 
-analyzer-eagerly-assume %s -verify
 //RUN: %clang_analyze_cc1 -cc1 -std=c++11  
-analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection 
-analyzer-eagerly-assume -DGTEST_VERSION_1_8_AND_LATER=1 %s -verify
-//RUN: %clang_analyze_cc1 -cc1 -std=c++11  
-analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection 
-analyzer-eagerly-assume -analyzer-config cfg-temporary-dtors=true %s -verify
 
 void clang_analyzer_eval(int);
 void clang_analyzer_warnIfReached();
Index: test/Analysis/dtor.cpp
===
--- test/Analysis/dtor.cpp
+++ test/Analysis/dtor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection,cplusplus 
-analyzer-config c++-inlining=destructors,cfg-temporary-dtors=true 
-Wno-null-dereference -Wno-inaccessible-base -verify %s
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection,cplusplus 
-analyzer-config c++-inlining=destructors -Wno-null-dereference 
-Wno-inaccessible-base -verify %s
 
 void clang_analyzer_eval(bool);
 void clang_analyzer_checkInlined(bool);
Index: test/Analysis/dtor-cxx11.cpp
===
--- test/Analysis/dtor-cxx11.cpp
+++ test/Analysis/dtor-cxx11.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
cfg-temporary-dtors=true -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 
-anal

[PATCH] D46183: [clangd] Incorporate #occurrences in scoring code complete results.

2018-05-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46183



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


[PATCH] D46353: [ASTImporter] Extend lookup logic in class templates

2018-05-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> should we add this new declaration to the redeclaration chain like we do it 
> for RecordDecls?

I think, on a long term we should. Otherwise we could loose e.g. C++11 
attributes which are attached to the forward declaration only.
However, I'd do that as a separate commit, because that would require some 
independent changes and tests, also other decl kinds like 
ClassTemplateSepcializationDecl may be affected as well by that.


Repository:
  rC Clang

https://reviews.llvm.org/D46353



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> As Devin says (and as we discussed this with Anna Zaks) alpha checkers are 
> still in development, so we don't want to expose them to the users, even very 
> curious ones.

Then why do we make them available with `clang --analyze`? If the plan is not 
to expose them to the users at all, they should be removed from the codebase, 
as they are just sitting there bit-rotting.

Ideally, I see no problem exposing them to users. This will allow more users to 
run them on their codebases and submit issues or patches for the problems they 
find.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 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: clang-tidy/ClangTidy.cpp:373-376
   // FIXME: Remove this option once clang's cfg-temporary-dtors option defaults
   // to true.
   AnalyzerOptions->Config["cfg-temporary-dtors"] =
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";

alexfh wrote:
> NoQ wrote:
> > Btw this is already enabled by default.
> Should we kill the flag completely?
I've removed the clang-tidy configuration option in r331456.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[clang-tools-extra] r331457 - [clangd] Incorporate #occurrences in scoring code complete results.

2018-05-03 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu May  3 07:53:02 2018
New Revision: 331457

URL: http://llvm.org/viewvc/llvm-project?rev=331457&view=rev
Log:
[clangd] Incorporate #occurrences in scoring code complete results.

Summary: needs tests

Reviewers: ilya-biryukov

Subscribers: klimek, ioeric, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=331457&r1=331456&r2=331457&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu May  3 07:53:02 2018
@@ -229,24 +229,27 @@ struct CompletionCandidate {
 
   // Computes the "symbol quality" score for this completion. Higher is better.
   float score() const {
-// For now we just use the Sema priority, mapping it onto a 0-1 interval.
-if (!SemaResult) // FIXME(sammccall): better scoring for index results.
-  return 0.3f;   // fixed mediocre score for index-only results.
+float Score = 1;
+if (IndexResult)
+  Score *= quality(*IndexResult);
+if (SemaResult) {
+  // For now we just use the Sema priority, mapping it onto a 0-2 interval.
+  // That makes 1 neutral-ish, so we don't reward/penalize non-Sema 
results.
+  // Priority 80 is a really bad score.
+  Score *= 2 - std::min(80, SemaResult->Priority) / 40;
 
-// Priority 80 is a really bad score.
-float Score = 1 - std::min(80, SemaResult->Priority) / 80;
-
-switch (static_cast(SemaResult->Availability)) {
-case CXAvailability_Available:
-  // No penalty.
-  break;
-case CXAvailability_Deprecated:
-  Score *= 0.1f;
-  break;
-case CXAvailability_NotAccessible:
-case CXAvailability_NotAvailable:
-  Score = 0;
-  break;
+  switch (static_cast(SemaResult->Availability)) {
+  case CXAvailability_Available:
+// No penalty.
+break;
+  case CXAvailability_Deprecated:
+Score *= 0.1f;
+break;
+  case CXAvailability_NotAccessible:
+  case CXAvailability_NotAvailable:
+Score = 0;
+break;
+  }
 }
 return Score;
   }

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=331457&r1=331456&r2=331457&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu May  3 07:53:02 2018
@@ -48,6 +48,14 @@ raw_ostream &operator<<(raw_ostream &OS,
   return OS << S.Scope << S.Name;
 }
 
+double quality(const Symbol &S) {
+  // This avoids a sharp gradient for tail symbols, and also neatly avoids the
+  // question of whether 0 references means a bad symbol or missing data.
+  if (S.References < 3)
+return 1;
+  return std::log(S.References);
+}
+
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
   auto It = std::lower_bound(Symbols.begin(), Symbols.end(), ID,
  [](const Symbol &S, const SymbolID &I) {

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=331457&r1=331456&r2=331457&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu May  3 07:53:02 2018
@@ -199,6 +199,12 @@ struct Symbol {
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S);
 
+// Computes query-independent quality score for a Symbol.
+// This currently falls in the range [1, ln(#indexed documents)].
+// FIXME: this should probably be split into symbol -> signals
+//and signals -> score, so it can be reused for Sema completions.
+double quality(const Symbol &S);
+
 // An immutable symbol container that stores a set of symbols.
 // The container will maintain the lifetime of the symbols.
 class SymbolSlab {

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=331457&r1=331456&r2=331457&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Thu May  3 07:53:02 2018
@@ -47,7 +47,7 @@ bool M

[PATCH] D46183: [clangd] Incorporate #occurrences in scoring code complete results.

2018-05-03 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE331457: [clangd] Incorporate #occurrences in scoring code 
complete results. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46183?vs=145021&id=145024#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46183

Files:
  clangd/CodeComplete.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -229,24 +229,27 @@
 
   // Computes the "symbol quality" score for this completion. Higher is better.
   float score() const {
-// For now we just use the Sema priority, mapping it onto a 0-1 interval.
-if (!SemaResult) // FIXME(sammccall): better scoring for index results.
-  return 0.3f;   // fixed mediocre score for index-only results.
-
-// Priority 80 is a really bad score.
-float Score = 1 - std::min(80, SemaResult->Priority) / 80;
-
-switch (static_cast(SemaResult->Availability)) {
-case CXAvailability_Available:
-  // No penalty.
-  break;
-case CXAvailability_Deprecated:
-  Score *= 0.1f;
-  break;
-case CXAvailability_NotAccessible:
-case CXAvailability_NotAvailable:
-  Score = 0;
-  break;
+float Score = 1;
+if (IndexResult)
+  Score *= quality(*IndexResult);
+if (SemaResult) {
+  // For now we just use the Sema priority, mapping it onto a 0-2 interval.
+  // That makes 1 neutral-ish, so we don't reward/penalize non-Sema results.
+  // Priority 80 is a really bad score.
+  Score *= 2 - std::min(80, SemaResult->Priority) / 40;
+
+  switch (static_cast(SemaResult->Availability)) {
+  case CXAvailability_Available:
+// No penalty.
+break;
+  case CXAvailability_Deprecated:
+Score *= 0.1f;
+break;
+  case CXAvailability_NotAccessible:
+  case CXAvailability_NotAvailable:
+Score = 0;
+break;
+  }
 }
 return Score;
   }
Index: clangd/index/MemIndex.cpp
===
--- clangd/index/MemIndex.cpp
+++ clangd/index/MemIndex.cpp
@@ -47,7 +47,7 @@
 continue;
 
   if (auto Score = Filter.match(Sym->Name)) {
-Top.emplace(-*Score, Sym);
+Top.emplace(-*Score * quality(*Sym), Sym);
 if (Top.size() > Req.MaxCandidateCount) {
   More = true;
   Top.pop();
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -199,6 +199,12 @@
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S);
 
+// Computes query-independent quality score for a Symbol.
+// This currently falls in the range [1, ln(#indexed documents)].
+// FIXME: this should probably be split into symbol -> signals
+//and signals -> score, so it can be reused for Sema completions.
+double quality(const Symbol &S);
+
 // An immutable symbol container that stores a set of symbols.
 // The container will maintain the lifetime of the symbols.
 class SymbolSlab {
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -48,6 +48,14 @@
   return OS << S.Scope << S.Name;
 }
 
+double quality(const Symbol &S) {
+  // This avoids a sharp gradient for tail symbols, and also neatly avoids the
+  // question of whether 0 references means a bad symbol or missing data.
+  if (S.References < 3)
+return 1;
+  return std::log(S.References);
+}
+
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
   auto It = std::lower_bound(Symbols.begin(), Symbols.end(), ID,
  [](const Symbol &S, const SymbolID &I) {
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -144,6 +144,13 @@
 Symbol var(StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
 }
+Symbol ns(StringRef Name) {
+  return sym(Name, index::SymbolKind::Namespace, "@N@\\0");
+}
+Symbol withReferences(int N, Symbol S) {
+  S.References = N;
+  return S;
+}
 
 TEST(CompletionTest, Limit) {
   clangd::CodeCompleteOptions Opts;
@@ -443,6 +450,14 @@
   UnorderedElementsAre(AllOf(Named("XYZ"), Filter("XYZ";
 }
 
+TEST(CompletionTest, ReferencesAffectRanking) {
+  auto Results = completions("int main() { abs^ }", {ns("absl"), func("abs")});
+  EXPECT_THAT(Results.items, HasSubsequence(Named("abs"), Named("absl")));
+  Results = completions("int main() { abs^ }",
+{withReferences(1, ns("absl")), func("abs")})

[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:373-376
   // FIXME: Remove this option once clang's cfg-temporary-dtors option defaults
   // to true.
   AnalyzerOptions->Config["cfg-temporary-dtors"] =
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";

alexfh wrote:
> alexfh wrote:
> > NoQ wrote:
> > > Btw this is already enabled by default.
> > Should we kill the flag completely?
> I've removed the clang-tidy configuration option in r331456.
I didnt modify this line of code. Are you just wanting me to rebase?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D46159#1086332, @lebedev.ri wrote:

> In https://reviews.llvm.org/D46159#1086322, @alexfh wrote:
>
> >
>
>
> How about `-enable-alpha-checks=yes-i-know-they-are-broken` ?


A hidden flag with a scary name without any way to specify it in .clang-tidy 
configuration file would be the closest thing to consider.

But still, could you explain the use case and why a local modification of 
clang-tidy is not an option?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

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

In https://reviews.llvm.org/D46159#1086463, @pfultz2 wrote:

> > As Devin says (and as we discussed this with Anna Zaks) alpha checkers are 
> > still in development, so we don't want to expose them to the users, even 
> > very curious ones.
>
> Then why do we make them available with `clang --analyze`? If the plan is not 
> to expose them to the users at all, they should be removed from the codebase, 
> as they are just sitting there bit-rotting.
>
> Ideally, I see no problem exposing them to users. This will allow more users 
> to run them on their codebases and submit issues or patches for the problems 
> they find.


Just so i'm perfectly clear, i find this "they are not for common user, so 
let's not expose them at all" approach very Gnome-like, and not really 
appropriate for LLVM.
With that approach, there should also not be a 
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fexperimental-new-pass-manager
 and maybe some other flags.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> But still, could you explain the use case and why a local modification of 
> clang-tidy is not an option?

Because I would like to direct users to try an alpha check on thier local 
codebases without having to tell them to rebuild clang.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46374: Add support for ObjC property name to be a single acronym.

2018-05-03 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton requested changes to this revision.
benhamilton added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:222
+  [MatchedDecl](std::string const &s) {
+return s == MatchedDecl->getName();
+  })) {

`s` is a regular expression here, so you need to match it using `llvm::Regex`, 
not `==`.

Why not just update `validPropertyNameRegex()` to handle this case?




Comment at: test/clang-tidy/objc-property-declaration.m:24
 @property(assign, nonatomic) int enableGLAcceleration;
+@property(assign, nonatomic) int ID;
 @end

Please add a test for a built-in regex (4G) as well as a custom regex in the 
other test file.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46374



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D46159#1086479, @pfultz2 wrote:

> > But still, could you explain the use case and why a local modification of 
> > clang-tidy is not an option?
>
> Because I would like to direct users to try an alpha check on their local 
> codebases without having to tell them to rebuild clang.


Okay, let's go with a hidden flag (something explicit enough, e.g. 
`-allow-enabling-static-analyzer-alpha-checkers`)  and remove the clang-tidy 
configuration option (so that there's no way it can silently sit in the options 
file, and instead the flag has to be used in each clang-tidy invocation). IIUC, 
Devin was not completely opposed to this sort of a solution?




Comment at: clang-tidy/ClangTidy.cpp:373-376
   // FIXME: Remove this option once clang's cfg-temporary-dtors option defaults
   // to true.
   AnalyzerOptions->Config["cfg-temporary-dtors"] =
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";

pfultz2 wrote:
> alexfh wrote:
> > alexfh wrote:
> > > NoQ wrote:
> > > > Btw this is already enabled by default.
> > > Should we kill the flag completely?
> > I've removed the clang-tidy configuration option in r331456.
> I didnt modify this line of code. Are you just wanting me to rebase?
I was just answering NoQ's comment. Sorry for the off-topic.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D46159#1086487, @alexfh wrote:

> In https://reviews.llvm.org/D46159#1086479, @pfultz2 wrote:
>
> > > But still, could you explain the use case and why a local modification of 
> > > clang-tidy is not an option?
> >
> > Because I would like to direct users to try an alpha check on their local 
> > codebases without having to tell them to rebuild clang.
>
>
> Okay, let's go with a hidden flag (something explicit enough, e.g. 
> `-allow-enabling-static-analyzer-alpha-checkers`)


Or similar to what Roman suggested: 
`-allow-enabling-static-analyzer-alpha-checkers-yes-i-know-they-can-be-broken` 
;)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D46159#1086472, @lebedev.ri wrote:

> In https://reviews.llvm.org/D46159#1086463, @pfultz2 wrote:
>
> > > As Devin says (and as we discussed this with Anna Zaks) alpha checkers 
> > > are still in development, so we don't want to expose them to the users, 
> > > even very curious ones.
> >
> > Then why do we make them available with `clang --analyze`? If the plan is 
> > not to expose them to the users at all, they should be removed from the 
> > codebase, as they are just sitting there bit-rotting.
> >
> > Ideally, I see no problem exposing them to users. This will allow more 
> > users to run them on their codebases and submit issues or patches for the 
> > problems they find.
>
>
> Just so i'm perfectly clear, i find this "they are not for common user, so 
> let's not expose them at all" approach very Gnome-like, and not really 
> appropriate for LLVM.


I think the premise is a bit off the mark. It's not that these are not for the 
common user -- it's that they're simply not ready for users at all. Making it 
easier to expose does not seem like it serves users because those users expect 
exposed features to work. Yes, they're already exposed via the static analyzer, 
but I think that's what should be discussed -- some of these alpha checks have 
been there in an alpha state for years and I don't think that's a good design 
for a production tool. I'd rather discuss either improving those to make them 
production quality or removing them entirely, not making it *easier* to access 
them.

Making the flag sound scary doesn't suffice -- many users never see the flags 
because they're hidden away in a build script, but they definitely see the 
diagnostics and file bug reports.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Felix Bruns via Phabricator via cfe-commits
fxb created this revision.
fxb added reviewers: hans, erichkeane, thakis.
Herald added a subscriber: cfe-commits.

This replicates 'cl.exe' behavior and allows for both preprocessor output and
dependency information to be extraced with a single compiler invocation.

This is especially useful for compiler caching with tools like Mozilla's 
sccache.

See: https://github.com/mozilla/sccache/issues/246


Repository:
  rC Clang

https://reviews.llvm.org/D46394

Files:
  include/clang/Frontend/DependencyOutputOptions.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/HeaderIncludeGen.cpp
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -198,10 +198,8 @@
 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
 // RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
-// showIncludes_E: warning: argument unused during compilation: 
'--show-includes'
-
-// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E_And_P %s
-// showIncludes_E_And_P-NOT: warning: argument unused during compilation: 
'--show-includes'
+// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E %s
+// showIncludes_E-NOT: warning: argument unused during compilation: 
'--show-includes'
 
 // /source-charset: should warn on everything except UTF-8.
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck 
-check-prefix=source-charset-utf-16 %s
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -80,7 +80,9 @@
const DependencyOutputOptions &DepOpts,
bool ShowAllHeaders, StringRef OutputPath,
bool ShowDepth, bool MSStyle) {
-  raw_ostream *OutputFile = MSStyle ? &llvm::outs() : &llvm::errs();
+  raw_ostream *OutputFile = &llvm::errs();
+  if (MSStyle && !DepOpts.PrintShowIncludesToStderr)
+OutputFile = &llvm::outs();
   bool OwnsOutputFile = false;
 
   // Open the output file, if used.
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1131,6 +1131,12 @@
   Opts.HeaderIncludeOutputFile = Args.getLastArgValue(OPT_header_include_file);
   Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
   Opts.PrintShowIncludes = Args.hasArg(OPT_show_includes);
+  // Writing both /showIncludes and preprocessor output to stdout
+  // would produce interleaved output, so use stderr for /showIncludes.
+  // This behaves the same as cl.exe, when /E, /EP or /P are passed.
+  if (Opts.PrintShowIncludes &&
+  (Args.hasArg(options::OPT_E) || Args.hasArg(options::OPT_P)))
+Opts.PrintShowIncludesToStderr = true;
   Opts.DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
   Opts.ModuleDependencyOutputDir =
   Args.getLastArgValue(OPT_module_dependency_dir);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5077,13 +5077,8 @@
 CmdArgs.push_back("--dependent-lib=oldnames");
   }
 
-  // Both /showIncludes and /E (and /EP) write to stdout. Allowing both
-  // would produce interleaved output, so ignore /showIncludes in such cases.
-  if ((!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) ||
-  (Args.hasArg(options::OPT__SLASH_P) &&
-   Args.hasArg(options::OPT__SLASH_EP) && !Args.hasArg(options::OPT_E)))
-if (Arg *A = Args.getLastArg(options::OPT_show_includes))
-  A->render(Args, CmdArgs);
+  if (Arg *A = Args.getLastArg(options::OPT_show_includes))
+A->render(Args, CmdArgs);
 
   // This controls whether or not we emit RTTI data for polymorphic types.
   if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,
Index: include/clang/Frontend/DependencyOutputOptions.h
===
--- include/clang/Frontend/DependencyOutputOptions.h
+++ include/clang/Frontend/DependencyOutputOptions.h
@@ -29,6 +29,8 @@
  /// problems.
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency 
list
   unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info.
+  unsigned
+  PrintShowIncludesToStderr : 1; ///< Print /showIncludes output to stderr.
   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
 
   /// The form

[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Felix Bruns via Phabricator via cfe-commits
fxb added a comment.

This is my first patch to clang, so any feedback regarding implementation 
appreciated!

Also, let me know if you have any suggestions on how to add more extensive 
tests for this.


Repository:
  rC Clang

https://reviews.llvm.org/D46394



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:195
 
+/// This option Enables alpha checkers from the static analyzer, that are
+/// experimental. This option is set to false and not visible in help, because

This option enables...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


r331459 - Allow writing calling convention attributes on function types.

2018-05-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu May  3 08:33:50 2018
New Revision: 331459

URL: http://llvm.org/viewvc/llvm-project?rev=331459&view=rev
Log:
Allow writing calling convention attributes on function types.

Calling convention attributes notionally appertain to the function type -- they 
modify the mangling of the function, change the behavior of assignment 
operations, etc. This commit allows the calling convention attributes to be 
written in the type position as well as the declaration position.

Added:
cfe/trunk/test/SemaCXX/type-attrs.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=331459&r1=331458&r2=331459&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu May  3 08:33:50 2018
@@ -493,6 +493,11 @@ class InheritableAttr : Attr {
   bit InheritEvenIfAlreadyPresent = 0;
 }
 
+/// Some attributes, like calling conventions, can appear in either the
+/// declaration or the type position. These attributes are morally type
+/// attributes, but have historically been written on declarations.
+class DeclOrTypeAttr : InheritableAttr;
+
 /// A target-specific attribute.  This class is meant to be used as a mixin
 /// with InheritableAttr or Attr depending on the attribute's needs.
 class TargetSpecificAttr {
@@ -765,7 +770,7 @@ def CarriesDependency : InheritableParam
   let Documentation = [CarriesDependencyDocs];
 }
 
-def CDecl : InheritableAttr {
+def CDecl : DeclOrTypeAttr {
   let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [Undocumented];
@@ -1066,14 +1071,14 @@ def FallThrough : StmtAttr {
   let Documentation = [FallthroughDocs];
 }
 
-def FastCall : InheritableAttr {
+def FastCall : DeclOrTypeAttr {
   let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
Keyword<"_fastcall">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [FastCallDocs];
 }
 
-def RegCall : InheritableAttr {
+def RegCall : DeclOrTypeAttr {
   let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
   let Documentation = [RegCallDocs];
 }
@@ -1205,7 +1210,7 @@ def MayAlias : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def MSABI : InheritableAttr {
+def MSABI : DeclOrTypeAttr {
   let Spellings = [GCC<"ms_abi">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [MSABIDocs];
@@ -1689,13 +1694,13 @@ def Packed : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def IntelOclBicc : InheritableAttr {
+def IntelOclBicc : DeclOrTypeAttr {
   let Spellings = [Clang<"intel_ocl_bicc", 0>];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [Undocumented];
 }
 
-def Pcs : InheritableAttr {
+def Pcs : DeclOrTypeAttr {
   let Spellings = [GCC<"pcs">];
   let Args = [EnumArgument<"PCS", "PCSType",
["aapcs", "aapcs-vfp"],
@@ -1798,13 +1803,13 @@ def Sentinel : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def StdCall : InheritableAttr {
+def StdCall : DeclOrTypeAttr {
   let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [StdCallDocs];
 }
 
-def SwiftCall : InheritableAttr {
+def SwiftCall : DeclOrTypeAttr {
   let Spellings = [Clang<"swiftcall">];
 //  let Subjects = SubjectList<[Function]>;
   let Documentation = [SwiftCallDocs];
@@ -1831,38 +1836,38 @@ def Suppress : StmtAttr {
   let Documentation = [SuppressDocs];
 }
 
-def SysVABI : InheritableAttr {
+def SysVABI : DeclOrTypeAttr {
   let Spellings = [GCC<"sysv_abi">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [Undocumented];
 }
 
-def ThisCall : InheritableAttr {
+def ThisCall : DeclOrTypeAttr {
   let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
Keyword<"_thiscall">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [ThisCallDocs];
 }
 
-def VectorCall : InheritableAttr {
+def VectorCall : DeclOrTypeAttr {
   let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
Keyword<"_vectorcall">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [VectorCallDocs];
 }
 
-def Pascal : InheritableAttr {
+def Pascal : DeclOrTypeAttr {
   let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [Undocumented];
 }
 
-def PreserveMost : InheritableAttr {
+def PreserveMost : DeclOrTypeAttr {
   let Spellings = [Clang<"pre

[PATCH] D43750: Allow writing calling convention attributes on function types

2018-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In https://reviews.llvm.org/D43750#1085780, @rsmith wrote:

> I'm really sad about this; C++11 attributes were supposed to fix the 
> undisciplined "do what I mean" behavior of GNU attributes. But you're right, 
> these really are type attributes, and really should be permitted to appertain 
> to types. That we permit these to appertain to function declarations is the 
> mistake, but it's a mistake we need to make to match GCC, so while I'm sad 
> about it, I think this patch is the right thing.


Yeah, this situation doesn't make me overly happy but I think it's the best way 
for us to move forward. Hopefully, after enough time has passed, we can 
consider deprecating writing these attributes on declarations with the eventual 
goal of disallowing it.

Committed in r331459.


https://reviews.llvm.org/D43750



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


[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/Frontend/DependencyOutputOptions.h:31
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency 
list
   unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info.
+  unsigned

Doing these two as separate options is a touch annoying.  First, there is an 
extra state that ends up being possible but ignored.  I'd prefer making a 
"PrintShowIncludeDestination : 2" (name open for proper bikeshed) that contains 
an enum so that the states are explicit.  Something like:
None,
StdOut,
StdErr

That way, the 4th state is explicitly unused.



Comment at: test/Driver/cl-options.c:203
-
-// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E_And_P %s
-// showIncludes_E_And_P-NOT: warning: argument unused during compilation: 
'--show-includes'

I'm perhaps missing something here... why did "/EP /P /showIncludes" previously 
NOT warn?  


Repository:
  rC Clang

https://reviews.llvm.org/D46394



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


[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Felix Bruns via Phabricator via cfe-commits
fxb added inline comments.



Comment at: include/clang/Frontend/DependencyOutputOptions.h:31
   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency 
list
   unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info.
+  unsigned

erichkeane wrote:
> Doing these two as separate options is a touch annoying.  First, there is an 
> extra state that ends up being possible but ignored.  I'd prefer making a 
> "PrintShowIncludeDestination : 2" (name open for proper bikeshed) that 
> contains an enum so that the states are explicit.  Something like:
> None,
> StdOut,
> StdErr
> 
> That way, the 4th state is explicitly unused.
Yes, that definitely makes sense and is a lot nicer than having these two 
options, which I found quite ugly as well.

I will fix that and upload a new patch set.



Comment at: test/Driver/cl-options.c:203
-
-// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck 
-check-prefix=showIncludes_E_And_P %s
-// showIncludes_E_And_P-NOT: warning: argument unused during compilation: 
'--show-includes'

erichkeane wrote:
> I'm perhaps missing something here... why did "/EP /P /showIncludes" 
> previously NOT warn?  
/P will preprocess to a file, so it was compatible with /showIncludes, which 
was printed to stdout.

With this change all preprocessor options are now possible to use in 
combination with /showIncludes, since its output will be written to stderr, 
like cl.exe does.

I was actually not sure if I shall keep these tests at all after my change or 
just invert them, like I ended up doing here. There is probably a better way to 
actually test that /showIncludes output will end up on stderr, but with my 
limited experience I didn't figure that out yet. Let me know if you have any 
ideas how to improve these tests.


Repository:
  rC Clang

https://reviews.llvm.org/D46394



___
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-05-03 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: clang-tidy/modernize-use-auto-min-type-name-length.cpp:61-83
+long int li = static_cast(foo());
+// CHECK-FIXES-0-0: auto li = {{.*}}
+// CHECK-FIXES-0-5: auto li = {{.*}}
+// CHECK-FIXES-1-0: auto  li = {{.*}}
+// CHECK-FIXES-1-5: auto  li = {{.*}}
+long int *pli = static_cast(foo());
+// CHECK-FIXES-0-0: auto *pli = {{.*}}

These tests could be more useful, if they verified boundary values of the 
MinTypeNameLength, e.g. that `long int` is replaced with `auto` when the option 
is set to 8 and it stays `long int`with the option set to 9.

Please also add tests with template typenames: e.g. the lenght of `T <  int  >` 
should be considered 6 and the length of `T  <  const int >` is 12. I guess, 
the algorithm I proposed will be incorrect for pointer type arguments of 
templates (the length of `T` should be 7 regardless of `RemoveStars`), 
but this can be fixed by conditionally (on RemoveStars) trimming `*`s from the 
right of the type name and then treating them as punctuation. So instead of

```
  for (const unsigned char C : tooling::fixit::getText(SR, Context)) {
const CharType NextChar =
std::isalnum(C)
? Alpha
: (std::isspace(C) || (!RemoveStars && C == '*')) ? Space
  : Punctuation;
```

you could use something similar to

```
  StringRef Text = tooling::fixit::getText(SR, Context);
  if (RemoveStars)
Text = Text.rtrim(" \t\v\n\r*");
  for (const unsigned char C : Text) {
const CharType NextChar =
std::isalnum(C) ? Alpha : std::isspace(C) ? Space : Punctuation;
```


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] D46325: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer. 2nd try.

2018-05-03 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: clang-tidy/ClangTidy.cpp:536
+   DiagnosticConsumer *DiagConsumer) override {
+  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  return FrontendActionFactory::runInvocation(

I would add a comment that we only do this to define the analyzer-specific 
macro, not to actually use the analyzer frontend action.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46325



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> I think the premise is a bit off the mark. It's not that these are not for 
> the common user -- it's that they're simply not ready for users at all.

Then why was it merged into clang in the first place? It seems like the whole 
point of merging it into clang is to get user feedback.

Furthermore, I am trying to update the conversion checker to report more 
errors, and I would like it to be exposed to users so I can find or fix the FPs.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In https://reviews.llvm.org/D46159#1086553, @pfultz2 wrote:

> > I think the premise is a bit off the mark. It's not that these are not for 
> > the common user -- it's that they're simply not ready for users at all.
>
> Then why was it merged into clang in the first place? It seems like the whole 
> point of merging it into clang is to get user feedback.
>
> Furthermore, I am trying to update the conversion checker to report more 
> errors, and I would like it to be exposed to users so I can find or fix the 
> FPs.


If users cannot find / use it, you will not get any feedback. How can they be 
better checkers if no feedback received?

If nobody should use it, remove this "dead" code


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46159



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


[clang-tools-extra] r331460 - Add a trailing period in release notes.

2018-05-03 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  3 08:59:39 2018
New Revision: 331460

URL: http://llvm.org/viewvc/llvm-project?rev=331460&view=rev
Log:
Add a trailing period in release notes.

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=331460&r1=331459&r2=331460&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Thu May  3 08:59:39 2018
@@ -214,7 +214,7 @@ def add_release_notes(module_path, modul
   if not line.startswith(''):
 f.write("""
 - New :doc:`%s
-  ` check
+  ` check.
 
   FIXME: add release notes.
 """ % (check_name_dashes, check_name_dashes))


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


[clang-tools-extra] r331461 - Added trailing periods.

2018-05-03 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  3 09:01:49 2018
New Revision: 331461

URL: http://llvm.org/viewvc/llvm-project?rev=331461&view=rev
Log:
Added trailing periods.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=331461&r1=331460&r2=331461&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu May  3 09:01:49 2018
@@ -65,30 +65,30 @@ Improvements to clang-tidy
 - New module ``zircon`` for checks related to Fuchsia's Zircon kernel.
 
 - New :doc:`android-comparison-in-temp-failure-retry
-  ` check
+  ` check.
 
   Diagnoses comparisons that appear to be incorrectly placed in the argument to
   the ``TEMP_FAILURE_RETRY`` macro.
 
 - New :doc:`bugprone-parent-virtual-call
-  ` check
+  ` check.
 
   Detects and fixes calls to grand-...parent virtual methods instead of calls
   to overridden parent's virtual methods.
 
 - New :doc:`bugprone-throw-keyword-missing
-  ` check
+  ` check.
 
   Diagnoses when a temporary object that appears to be an exception is
   constructed but not thrown.
 
 - New :doc:`bugprone-unused-return-value
-  ` check
+  ` check.
 
   Warns on unused function return values.
 
 - New :doc:`cppcoreguidelines-avoid-goto
-  ` check
+  ` check.
 
   The usage of ``goto`` for control flow is error prone and should be replaced
   with looping constructs. Every backward jump is rejected. Forward jumps are
@@ -100,53 +100,53 @@ Improvements to clang-tidy
   added.
 
 - New :doc:`fuchsia-multiple-inheritance
-  ` check
+  ` check.
 
   Warns if a class inherits from multiple classes that are not pure virtual.
 
 - New :doc:`abseil-string-find-startswith
-  ` check
+  ` check.
 
   Checks whether a ``std::string::find()`` result is compared with 0, and
   suggests replacing with ``absl::StartsWith()``.
 
 - New :doc:`fuchsia-statically-constructed-objects
-  ` check
+  ` check.
 
   Warns if global, non-trivial objects with static storage are constructed,
   unless the object is statically initialized with a ``constexpr`` constructor
   or has no explicit constructor.
 
 - New :doc:`fuchsia-trailing-return
-  ` check
+  ` check.
 
   Functions that have trailing returns are disallowed, except for those
   using ``decltype`` specifiers and lambda with otherwise unutterable
   return types.
 
 - New :doc:`hicpp-multiway-paths-covered
-  ` check
+  ` check.
 
   Checks on ``switch`` and ``if`` - ``else if`` constructs that do not cover 
all possible code paths.
 
 - New :doc:`modernize-use-uncaught-exceptions
-  ` check
+  ` check.
 
   Finds and replaces deprecated uses of ``std::uncaught_exception`` to
   ``std::uncaught_exceptions``.
 
 - New :doc:`portability-simd-intrinsics
-  ` check
+  ` check.
 
   Warns or suggests alternatives if SIMD intrinsics are used which can be 
replaced by
   ``std::experimental::simd`` operations.
 
 - New :doc:`zircon-temporary-objects
-  ` check
+  ` check.
 
   Warns on construction of specific temporary objects in the Zircon kernel.
 
-- Adding the missing bitwise assignment operations to 
+- Added the missing bitwise assignment operations to
   :doc:`hicpp-signed-bitwise `.
 
 - New option `MinTypeNameLength` for :doc:`modernize-use-auto
@@ -156,8 +156,8 @@ Improvements to clang-tidy
   replace types with the name length >= 5 letters only (ex. ``double``,
   ``unsigned``).
 
-- Added `VariableThreshold` option to :doc:`readability-function-size
-  ` check
+- Add `VariableThreshold` option to :doc:`readability-function-size
+  ` check.
 
   Flags functions that have more than a specified number of variables declared
   in the body.


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


[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-03 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added a comment.

Maybe this is a user error of CrossTU, but it seemed to import a FuncDecl with 
attributes, causing the imported FuncDecl to have all those attributes twice. 
That's why I thought merging would maybe make sense. However I did not 
encounter any issue with the duplicate attributes. Only the wrong source 
locations produced odd crashes.

Thanks for the input, then I will prepare the full patch.


Repository:
  rC Clang

https://reviews.llvm.org/D46115



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


[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-05-03 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: clang-tidy/bugprone/InfiniteLoopCheck.h:37
+private:
+  bool updateSequence(Stmt *FunctionBody, ASTContext &ASTCtx);
+  const Stmt *PrevFunctionBody;

Why bool? The return value is not used anywhere.



Comment at: docs/ReleaseNotes.rst:68
+- New :doc:`bugprone-infinite-loop
+  ` 
check
+

There should be a trailing period in each of these `New ... check` items. I've 
updated the script in r331460 and the existing release notes in r331461. Please 
rebase.


https://reviews.llvm.org/D40937



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


[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2018-05-03 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

In https://reviews.llvm.org/D36610#1083952, @mikhail.ramalho wrote:

> Ping.


Given that richard smith is the only non-approver, and that he hasn't 
responded, and that I contributed this code, I'm going to make an executive 
decision and say that this is OK to submit.

We will roll back if there are problems.


https://reviews.llvm.org/D36610



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


[PATCH] D33844: [clang-tidy] terminating continue check

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

There are still outstanding comments.


https://reviews.llvm.org/D33844



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 updated this revision to Diff 145029.
pfultz2 added a comment.

Rename flag to `allow-enabling-alpha-checks` and removed the option from the 
clang-tidy file.


https://reviews.llvm.org/D46159

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/enable-alpha-checks.cpp

Index: test/clang-tidy/enable-alpha-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/enable-alpha-checks.cpp
@@ -0,0 +1,6 @@
+// Check if '-allow-enabling-alpha-checks' is visible for users
+// RUN: clang-tidy -help | not grep 'enable-alpha-checks'
+
+// Check if '-allow-enabling-alpha-checks' enables alpha checks.
+// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-alpha'
+// RUN: clang-tidy -checks=* -list-checks -allow-enabling-alpha-checks | grep 'clang-analyzer-alpha'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -192,6 +192,13 @@
cl::init(false),
cl::cat(ClangTidyCategory));
 
+/// This option allows enabling alpha checkers from the static analyzer, that
+/// are experimental. This option is set to false and not visible in help,
+/// because it is highly not recommended for users.
+static cl::opt AllowEnablingAlphaChecks("allow-enabling-alpha-checks",
+  cl::init(false), cl::Hidden,
+  cl::cat(ClangTidyCategory));
+
 static cl::opt ExportFixes("export-fixes", cl::desc(R"(
 YAML file to store suggested fixes in. The
 stored fixes can be applied to the input source
@@ -301,6 +308,7 @@
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
+  DefaultOptions.AllowEnablingAlphaChecks = AllowEnablingAlphaChecks;
   DefaultOptions.FormatStyle = FormatStyle;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
   // USERNAME is used on Windows.
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -77,6 +77,9 @@
   /// \brief Turns on temporary destructor-based analysis.
   llvm::Optional AnalyzeTemporaryDtors;
 
+  /// \brief Turns on experimental alpha checkers from the static analyzer.
+  llvm::Optional AllowEnablingAlphaChecks;
+
   /// \brief Format code around applied fixes with clang-format using this
   /// style.
   ///
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -108,6 +108,7 @@
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
   Options.AnalyzeTemporaryDtors = false;
+  Options.AllowEnablingAlphaChecks = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
@@ -148,6 +149,8 @@
   overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
   overrideValue(Result.SystemHeaders, Other.SystemHeaders);
   overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors);
+  overrideValue(Result.AllowEnablingAlphaChecks,
+Other.AllowEnablingAlphaChecks);
   overrideValue(Result.FormatStyle, Other.FormatStyle);
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -303,11 +303,12 @@
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(ClangTidyContext &Context) {
+static CheckersList getCheckersControlList(ClangTidyContext &Context,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto &RegisteredCheckers =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
@@ -374,7 +375,8 @@
   AnalyzerOptions->Config["cfg-temporary-dtors"] =
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
 
-  AnalyzerOptions->CheckersControlList = getCheckersControlList(Context);
+  AnalyzerOptions->CheckersControlList = getCheckersControlList(
+  Context, *Context.getOptions().AllowEnablingAlphaChecks);
   if (!AnalyzerOptions->CheckersControlList.empty()) {
 setStaticAnalyzer

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

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

It looks like you've missed some comments or uploaded a wrong patch.




Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:105
+const TypeVec throwsException(const FunctionDecl *Func) {
+  static thread_local llvm::SmallSet CallStack;
+

alexfh wrote:
> I don't think this is a good use case for a static local variable. If this 
> function needs a state, either pass it from the caller or create a utility 
> class/struct for it. You can leave a non-recursive entry point with the 
> current interface, if you like. For example:
> 
>   const TypeVec throwsException(const FunctionDecl *Func, 
> llvm::SmallSet *CallStack) { ... }
> 
>   const TypeVec throwsException(const FunctionDecl *Func) {
> llvm::SmallSet CallStack;
> return throwsException(Func, &CallStack);
>   }
>   
Still not addressed?



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:110
+
+  if (const auto *Body = Func->getBody()) {
+CallStack.insert(Func);

alexfh wrote:
> Please use the concrete type here, since it's not obvious from the context.
Still not addressed?



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:119
+  if (const auto *FPT = Func->getType()->getAs()) {
+for (const auto Ex : FPT->exceptions()) {
+  Result.push_back(&*Ex);

alexfh wrote:
> Please use the concrete type here.
Still not addressed?



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:120
+for (const auto Ex : FPT->exceptions()) {
+  Result.push_back(&*Ex);
+}

alexfh wrote:
> Ex.getTypePtrOrNull() / Ex.getTypePtr() would be easier to understand here.
Still not addressed?


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] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D46159#1086553, @pfultz2 wrote:

> > I think the premise is a bit off the mark. It's not that these are not for 
> > the common user -- it's that they're simply not ready for users at all.
>
> Then why was it merged into clang in the first place? It seems like the whole 
> point of merging it into clang is to get user feedback.


When something is merged into Clang trunk, the expectation is that it will be 
production quality or will be worked on rapidly to get it to production 
quality, which is somewhat orthogonal to getting user feedback. I don't know 
that I have the full history of all of the alpha checks so my generalization 
may be inaccurate, but it seems like some of these checks were accepted as a 
WIP and the "progress" stopped for a long time with no one volunteering to 
remove the features from the analyzer.

> Furthermore, I am trying to update the conversion checker to report more 
> errors, and I would like it to be exposed to users so I can find or fix the 
> FPs.

That does not require clang-tidy to surface the alpha checks, correct?


https://reviews.llvm.org/D46159



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


[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Felix Bruns via Phabricator via cfe-commits
fxb updated this revision to Diff 145030.
fxb added a comment.

Updated the code to use an enum called `ShowIncludesDestination`


https://reviews.llvm.org/D46394

Files:
  include/clang/Frontend/DependencyOutputOptions.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/HeaderIncludeGen.cpp
  test/Driver/cl-options.c

Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -198,10 +198,8 @@
 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
 // RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
-// showIncludes_E: warning: argument unused during compilation: '--show-includes'
-
-// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E_And_P %s
-// showIncludes_E_And_P-NOT: warning: argument unused during compilation: '--show-includes'
+// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
+// showIncludes_E-NOT: warning: argument unused during compilation: '--show-includes'
 
 // /source-charset: should warn on everything except UTF-8.
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -80,9 +80,23 @@
const DependencyOutputOptions &DepOpts,
bool ShowAllHeaders, StringRef OutputPath,
bool ShowDepth, bool MSStyle) {
-  raw_ostream *OutputFile = MSStyle ? &llvm::outs() : &llvm::errs();
+  raw_ostream *OutputFile = &llvm::errs();
   bool OwnsOutputFile = false;
 
+  // Choose output stream, when printing in cl.exe /showIncludes style.
+  if (MSStyle) {
+switch (DepOpts.ShowIncludesDestination) {
+default:
+  llvm_unreachable("Invalid destination for /showIncludes output!");
+case ShowIncludesDestination::Stderr:
+  OutputFile = &llvm::errs();
+  break;
+case ShowIncludesDestination::Stdout:
+  OutputFile = &llvm::outs();
+  break;
+}
+  }
+
   // Open the output file, if used.
   if (!OutputPath.empty()) {
 std::error_code EC;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1130,7 +1130,17 @@
   Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
   Opts.HeaderIncludeOutputFile = Args.getLastArgValue(OPT_header_include_file);
   Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
-  Opts.PrintShowIncludes = Args.hasArg(OPT_show_includes);
+  if (Args.hasArg(OPT_show_includes)) {
+// Writing both /showIncludes and preprocessor output to stdout
+// would produce interleaved output, so use stderr for /showIncludes.
+// This behaves the same as cl.exe, when /E, /EP or /P are passed.
+if (Args.hasArg(options::OPT_E) || Args.hasArg(options::OPT_P))
+  Opts.ShowIncludesDestination = ShowIncludesDestination::Stderr;
+else
+  Opts.ShowIncludesDestination = ShowIncludesDestination::Stdout;
+  } else {
+Opts.ShowIncludesDestination = ShowIncludesDestination::None;
+  }
   Opts.DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
   Opts.ModuleDependencyOutputDir =
   Args.getLastArgValue(OPT_module_dependency_dir);
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -462,7 +462,7 @@
/*ShowDepth=*/false);
   }
 
-  if (DepOpts.PrintShowIncludes) {
+  if (DepOpts.ShowIncludesDestination != ShowIncludesDestination::None) {
 AttachHeaderIncludeGen(*PP, DepOpts,
/*ShowAllHeaders=*/true, /*OutputPath=*/"",
/*ShowDepth=*/true, /*MSStyle=*/true);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5077,13 +5077,8 @@
 CmdArgs.push_back("--dependent-lib=oldnames");
   }
 
-  // Both /showIncludes and /E (and /EP) write to stdout. Allowing both
-  // would produce interleaved output, so ignore /showIncludes in such cases.
-  if ((!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) ||
-  (Args.hasArg(options::OPT__SLASH_P) &&
-   Args.hasArg(options::OPT__SLASH_EP) && !Args.hasArg(options::OPT_E)))
-if (Arg *A = Args.getLastArg(options::OPT_sho

[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This looks fine to me. Let me know if you need me to commit this for you.


https://reviews.llvm.org/D46394



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


[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Felix Bruns via Phabricator via cfe-commits
fxb added a comment.

@erichkeane That would be great! Thanks!


https://reviews.llvm.org/D46394



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> When something is merged into Clang trunk, the expectation is that it will be 
> production quality or will be worked on rapidly to get it to production 
> quality, which is somewhat orthogonal to getting user feedback. I don't know 
> that I have the full history of all of the alpha checks so my generalization 
> may be inaccurate, but it seems like some of these checks were accepted as a 
> WIP and the "progress" stopped for a long time with no one volunteering to 
> remove the features from the analyzer.

Some checkers work better than others, while some just need some simple fixes. 
Of course, no one will volunteer to fix or remove them if they aren't available 
to run.

> That does not require clang-tidy to surface the alpha checks, correct?

A good portion of users are using clang-tidy to run the static analyzer, and I 
would like it to be exposed to them.


https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:195
 
+/// This option Enables alpha checkers from the static analyzer, that are
+/// experimental. This option is set to false and not visible in help, because

xbolva00 wrote:
> This option enables...
> This option enables...
The current version is correct.


https://reviews.llvm.org/D46159



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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2018-05-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

I see,t hank you. Please feel free to submit a patch - it seems like you 
already have a nice test case that shows the difference between two import 
options.


https://reviews.llvm.org/D26054



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:195
 
+/// This option Enables alpha checkers from the static analyzer, that are
+/// experimental. This option is set to false and not visible in help, because

lebedev.ri wrote:
> xbolva00 wrote:
> > This option enables...
> > This option enables...
> The current version is correct.
There was "This option Enables.." when I commented it.


https://reviews.llvm.org/D46159



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


[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

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

In https://reviews.llvm.org/D46159#1086493, @aaron.ballman wrote:

> I think the premise is a bit off the mark. It's not that these are not for 
> the common user -- it's that they're simply not ready for users at all. 
> Making it easier to expose does not seem like it serves users because those 
> users expect exposed features to work.


That was also the sentiment static analyzer folks were voicing at some point. I 
also sympathize to the idea of testing checks and contributing fixes to them, 
but what the CSA maintainers seem to dislike is a stream of bugs for alpha 
checkers from users expecting of a certain level of support. So it's basically 
their decision whether they want to expose alpha checkers via clang frontend 
and/or via clang-tidy. I can only say whether I like the specific way it is 
done in clang-tidy.

> Making the flag sound scary doesn't suffice -- many users never see the flags 
> because they're hidden away in a build script, but they definitely see the 
> diagnostics and file bug reports.

"We've fixed the glitch" by making everyone wanting a bugzilla account send an 
email to a human. So only the users who pass this sort of a Turing test will 
file bugs ;)




Comment at: clang-tidy/ClangTidyOptions.h:80-82
+  /// \brief Turns on experimental alpha checkers from the static analyzer.
+  llvm::Optional AllowEnablingAlphaChecks;
+

Since this will only be configurable via a flag, this option will be global 
(i.e. not depend on the location of the file being analyzed). I'd suggest to 
remove this option altogether and use something else to pass it to 
ClangTidyASTConsumerFactory. It could be stashed into 
ClangTidyASTConsumerFactory and passed as a parameter of runClangTidy,  or it 
could live in ClangTidyContext.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:198
+/// because it is highly not recommended for users.
+static cl::opt AllowEnablingAlphaChecks("allow-enabling-alpha-checks",
+  cl::init(false), cl::Hidden,

s/checks/checkers/ (in the static analyzer's terminology)

I would also make it more explicit that these are static analyzer checkers. 
-allow-enabling-clang-static-analyzer-alpha-checkers or something like that.

The variable name could be AllowEnablingAnalyzerAlphaCheckers, for example.



Comment at: test/clang-tidy/enable-alpha-checks.cpp:2
+// Check if '-allow-enabling-alpha-checks' is visible for users
+// RUN: clang-tidy -help | not grep 'enable-alpha-checks'
+

grep 'allow-enabling-alpha-checks'


https://reviews.llvm.org/D46159



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


[PATCH] D46187: [Analyzer] getRegisteredCheckers(): handle debug checkers too.

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

What's the use case for debug CSA checkers in clang-tidy?


Repository:
  rC Clang

https://reviews.llvm.org/D46187



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


[PATCH] D45931: [ASTMatchers] Don't garble the profiling output when multiple TU's are processed

2018-05-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D45931#1084503, @lebedev.ri wrote:

> In https://reviews.llvm.org/D45931#1083192, @lebedev.ri wrote:
>
> > Thank you for looking at this.
> >
> > In https://reviews.llvm.org/D45931#1083184, @alexfh wrote:
> >
> > > From a user's perspective I'd probably prefer a different behavior of 
> > > checks profiling with multiple translation units: per-file table after 
> > > each file and an aggregate table at the end.
> >
> >
> > Is this a review note, or a general observation?
>


Why not both? ;)

>>> An independent improvement could be to support TSV/CSV output and/or 
>>> dumping to a file to spare the user from parsing the tables out of the 
>>> stdout/stderr.
>> 
>> Yes, and a script to merge those CSV's, would be nice.

I'd probably go with a set of features enough for various use cases:
0. don't add any profile merging logic to clang-tidy

1. dump profile after each TU to the screen in the current tabulated format
2. add a flag to specify a file name prefix to dump profile output for each 
file as CSV
3. (optional) add a script to merge profiles from CSV files and dump as CSV or 
tabulated (without a script this could be done in a spreadsheet)

WDYT?


Repository:
  rC Clang

https://reviews.llvm.org/D45931



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


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

2018-05-03 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

In https://reviews.llvm.org/D46013#1084440, @efriedma wrote:

> I'd like to see some tests for __attribute((packed)).


Thanks, indeed it does not work correctly on packed structures. Back to the 
drawing board ...


Repository:
  rC Clang

https://reviews.llvm.org/D46013



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


r331466 - [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:15:44 2018
New Revision: 331466

URL: http://llvm.org/viewvc/llvm-project?rev=331466&view=rev
Log:
[OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

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

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331466&r1=331465&r2=331466&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:15:44 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331466&r1=331465&r2=331466&view=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:15:44 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {

[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane requested changes to this revision.
erichkeane added a comment.
This revision now requires changes to proceed.

When building this, it didn't build since you'd reused the name.  I changed the 
variable to be named "Dest" instead of "Destination"

That said, the test suite now fails on Clang :: 
Frontend/print-header-includes.c'.

Please do a build with 'check-clang' to see why this no longer works.
Thanks!
-Erich


https://reviews.llvm.org/D46394



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


r331469 - [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:22:04 2018
New Revision: 331469

URL: http://llvm.org/viewvc/llvm-project?rev=331469&view=rev
Log:
[OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

Reviewed by: ABataev

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

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

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331469&r1=331468&r2=331469&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:22:04 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331469&r1=331468&r2=331469&view=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:22:04 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]

r331468 - Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"

2018-05-03 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Thu May  3 10:22:01 2018
New Revision: 331468

URL: http://llvm.org/viewvc/llvm-project?rev=331468&view=rev
Log:
Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"

Sorry, forgot to add commit log attributes.

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

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp?rev=331468&r1=331467&r2=331468&view=diff
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp Thu 
May  3 10:22:01 2018
@@ -216,8 +216,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -247,13 +247,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -335,8 +335,8 @@ int main() {
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]

Modified: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp?rev=331468&r1=331467&r2=331468&view=diff
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
 Thu May  3 10:22:01 2018
@@ -266,8 +266,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@ int main() {
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x 
i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@ int main() {
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-64-D

[PATCH] D46370: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG

2018-05-03 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331469: [OPENMP] Fix test typos: CHECK-DAG-N -> 
CHECK-N-DAG (authored by jdenny, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46370?vs=144949&id=145047#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46370

Files:
  test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  test/OpenMP/teams_distribute_firstprivate_codegen.cpp
  test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp

Index: test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
+++ test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
@@ -266,8 +266,8 @@
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -332,8 +332,8 @@
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -363,13 +363,13 @@
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -512,8 +512,8 @@
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]** [[TMP]],
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[TMP]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
Index: test/OpenMP/teams_distribute_firstprivate_codegen.cpp
===
--- test/OpenMP/teams_distribute_firstprivate_codegen.cpp
+++ test/OpenMP/teams_distribute_firstprivate_codegen.cpp
@@ -219,8 +219,8 @@
 // CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[SIVAR_ADDR]],
 
 // T_VAR and SIVAR
-// CHECK-DAG-64: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
-// CHECK-DAG-64: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_TVAR:%.+]] = bitcast i64* [[T_VAR_ADDR]] to i32*
+// CHECK-64-DAG: [[CONV_SIVAR:%.+]] = bitcast i64* [[SIVAR_ADDR]] to i32*
 
 // preparation vars
 // CHECK-DAG: [[VEC_ADDR_VAL:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x i{{[0-9]+}}]** [[VEC_ADDR]],
@@ -250,13 +250,13 @@
 // CHECK-DAG: call void @{{.+}}({{.+}} [[AGG_TMP2]])
 
 // CHECK: call void @__kmpc_for_static_init_4(
-// CHECK-DAG-32: {{.+}} = {{.+}} [[T_VAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_TVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[T_VAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_TVAR]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VEC_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[S_ARR_PRIV]]
 // CHECK-DAG: {{.+}} = {{.+}} [[VAR_PRIV]]
-// CHECK-DAG-32: {{.+}} = {{.+}} [[SIVAR_ADDR]]
-// CHECK-DAG-64: {{.+}} = {{.+}} [[CONV_SIVAR]]
+// CHECK-32-DAG: {{.+}} = {{.+}} [[SIVAR_ADDR]]
+// CHECK-64-DAG: {{.+}} = {{.+}} [[CONV_SIVAR]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -338,8 +338,8 @@
 // CHECK-DAG: store [[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]

[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-03 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 145049.
sepavloff marked an inline comment as done.
sepavloff added a comment.

Small simplification


Repository:
  rC Clang

https://reviews.llvm.org/D46241

Files:
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/cxx11-initializer-aggregate.cpp


Index: test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -51,3 +51,27 @@
   // meaningful.
   B b[30] = {};
 }
+
+namespace ZeroInit {
+  enum { Zero, One };
+  constexpr int zero() { return 0; }
+  constexpr int *null() { return nullptr; }
+  struct Filler {
+int x;
+Filler();
+  };
+
+  // These declarations, if implemented elementwise, require huge
+  // amout of memory and compiler time.
+  unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 };
+  unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero };
+  unsigned char data_3[1024][1024][1024] = {{{0}}};
+  unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() };
+  int *data_5[1024 * 1024 * 512] = { nullptr };
+  int *data_6[1024 * 1024 * 512] = { null() };
+
+
+  // This variable must be initialized elementwise.
+  Filler data_e1[1024] = {};
+  // CHECK: getelementptr inbounds {{.*}} @_ZN8ZeroInit7data_e1E
+}
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1392,20 +1392,43 @@
   return type;
 }
 
+/// Checks if the specified initializer is equivalent to zero initialization.
+static bool isZeroInitializer(ConstantEmitter &CE, const Expr *Init) {
+  QualType InitTy = Init->getType().getCanonicalType();
+  if (auto *E = dyn_cast_or_null(Init)) {
+CXXConstructorDecl *CD = E->getConstructor();
+return CD->isDefaultConstructor() && CD->isTrivial();
+  }
+  if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+  for (auto I : IL->inits())
+if (!isZeroInitializer(CE, I))
+  return false;
+  if (const Expr *Filler = IL->getArrayFiller()) {
+return isZeroInitializer(CE, Filler);
+  }
+  return true;
+}
+  } else if (!Init->isEvaluatable(CE.CGM.getContext())) {
+return false;
+  } else if (Init->isNullPointerConstant(CE.CGM.getContext(),
+ Expr::NPC_NeverValueDependent)) {
+return true;
+  } else {
+llvm::APSInt Value;
+if (Init->isIntegerConstantExpr(Value, CE.CGM.getContext()))
+  return Value.isNullValue();
+  }
+
+  return false;
+}
+
 llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) {
   // Make a quick check if variable can be default NULL initialized
   // and avoid going through rest of code which may do, for c++11,
   // initialization of memory to all NULLs.
-  if (!D.hasLocalStorage()) {
-QualType Ty = CGM.getContext().getBaseElementType(D.getType());
-if (Ty->isRecordType())
-  if (const CXXConstructExpr *E =
-  dyn_cast_or_null(D.getInit())) {
-const CXXConstructorDecl *CD = E->getConstructor();
-if (CD->isTrivial() && CD->isDefaultConstructor())
-  return CGM.EmitNullConstant(D.getType());
-  }
-  }
+  if (!D.hasLocalStorage() && isZeroInitializer(*this, D.getInit()))
+return CGM.EmitNullConstant(D.getType());
 
   QualType destType = D.getType();
 


Index: test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -51,3 +51,27 @@
   // meaningful.
   B b[30] = {};
 }
+
+namespace ZeroInit {
+  enum { Zero, One };
+  constexpr int zero() { return 0; }
+  constexpr int *null() { return nullptr; }
+  struct Filler {
+int x;
+Filler();
+  };
+
+  // These declarations, if implemented elementwise, require huge
+  // amout of memory and compiler time.
+  unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 };
+  unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero };
+  unsigned char data_3[1024][1024][1024] = {{{0}}};
+  unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() };
+  int *data_5[1024 * 1024 * 512] = { nullptr };
+  int *data_6[1024 * 1024 * 512] = { null() };
+
+
+  // This variable must be initialized elementwise.
+  Filler data_e1[1024] = {};
+  // CHECK: getelementptr inbounds {{.*}} @_ZN8ZeroInit7data_e1E
+}
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1392,20 +1392,43 @@
   return type;
 }
 
+/// Checks if the specified initializer is equivalent to zero initialization.
+static bool isZeroInitializer(ConstantEmitter &CE, const Expr *Init) {
+  QualType InitTy = Init->getType().getCanonicalType();
+  if (auto *E = 

[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D46159#1086627, @alexfh wrote:

> In https://reviews.llvm.org/D46159#1086493, @aaron.ballman wrote:
>
> > I think the premise is a bit off the mark. It's not that these are not for 
> > the common user -- it's that they're simply not ready for users at all. 
> > Making it easier to expose does not seem like it serves users because those 
> > users expect exposed features to work.
>
>
> That was also the sentiment static analyzer folks were voicing at some point. 
> I also sympathize to the idea of testing checks and contributing fixes to 
> them, but what the CSA maintainers seem to dislike is a stream of bugs for 
> alpha checkers from users expecting of a certain level of support. So it's 
> basically their decision whether they want to expose alpha checkers via clang 
> frontend and/or via clang-tidy. I can only say whether I like the specific 
> way it is done in clang-tidy.


If the static analyzer people desire this feature, that would sway my position 
on it, but it sounds like they're hesitant as well. However, I don't think 
clang-tidy is beholden either -- if we don't think this functionality should be 
exposed and can justify that position, that should carry weight as well. From a 
policy perspective, I would be fine with a policy for clang-tidy where we never 
expose an alpha checker from the static analyzer (or only expose checks on a 
case by case basis) because I don't mind users having to jump through hoops to 
get to experimental, unsupported functionality.

As for the way this is surfaced in clang-tidy, I'm also not keen on it but I 
don't have an improved suggestion to make yet. I primarily don't like the fact 
that, as a user, I enable checks by name but for some kinds of checks I have to 
*also* enable them via a secondary mechanism otherwise the name doesn't even 
exist. This strikes me as being a likely source of confusion where forgetting 
one flag causes behavioral differences the user doesn't expect.

>> Making the flag sound scary doesn't suffice -- many users never see the 
>> flags because they're hidden away in a build script, but they definitely see 
>> the diagnostics and file bug reports.
> 
> "We've fixed the glitch" by making everyone wanting a bugzilla account send 
> an email to a human. So only the users who pass this sort of a Turing test 
> will file bugs ;)

Which is an even worse user experience.


https://reviews.llvm.org/D46159



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


[PATCH] D46394: [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P

2018-05-03 Thread Felix Bruns via Phabricator via cfe-commits
fxb added a comment.

I'll have a look at these issues tomorrow and submit a new patch then.

Thanks for all your help so far!


https://reviews.llvm.org/D46394



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


[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-03 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked an inline comment as done.
sepavloff added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1403
+  if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+  for (auto I : IL->inits())

rjmccall wrote:
> Do you actually care if it's an array initialization instead of a struct/enum 
> initialization?
If this code is enabled for for records too, some tests start to fail. For 
instance, the code:
```
union { int i; double f; } u2 = { };
```
produces output:
```
%union.anon = type { double }
@u2 = global %union.anon zeroinitializer, align 4
```
while previously it produced:
```
@u2 = global { i32, [4 x i8] } { i32 0, [4 x i8] undef }, align 4
```
The latter looks more correct.



Comment at: lib/CodeGen/CGExprConstant.cpp:1413
+  } else if (!Init->isEvaluatable(CE.CGM.getContext())) {
+return false;
+  } else if (InitTy->hasPointerRepresentation()) {

rjmccall wrote:
> Aren't the null-pointer and integer-constant-expression checks below already 
> checking this?  Also, `isEvaluatable` actually computes the full value 
> internally (as an `APValue`), so if you're worried about the memory and 
> compile-time effects of producing such a value, you really shouldn't call it.
> 
> You could reasonably move this entire function to be a method on `Expr` that 
> takes an `ASTContext`.
Comment for `EvaluateAsRValue` says that it tries calculate expression 
agressively. Indeed, for the code:
```
  decltype(nullptr) null();
  int *p = null();
```
compiler ignores potential side effect of `null()` and removes the call, 
leaving only zero initialization. `isNullPointerConstant` behaves similarly.



Comment at: lib/CodeGen/CGExprConstant.cpp:1417
+if (Init->EvaluateAsRValue(ResVal, CE.CGM.getContext()))
+  return ResVal.Val.isLValue() && ResVal.Val.isNullPointer();
+  } else {

rjmccall wrote:
> There's a `isNullPointerConstant` method (you should use 
> `NPC_NeverValueDependent`).
It make code more readable. Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D46241



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


[PATCH] D46398: [ASTImporterTest] Fix potential use-after-free

2018-05-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: xazax.hun, martong, szepet, jingham.
Herald added subscribers: cfe-commits, rnkovacs.

`buildASTFromCodeWithArgs()` accepts `llvm::Twine` as `Code` argument. However, 
if the argument is not a C string or std::string, the argument is being copied 
into a temporary buffer in order to get a null-terminated string. This lead to 
a potential UAF. Fixing this via calling `.data()` on StringRef since our 
`Code` is always null-terminated.

The issue was introduced by me in https://reviews.llvm.org/D44079 (sorry) but 
was not noticed.


Repository:
  rC Clang

https://reviews.llvm.org/D46398

Files:
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -213,7 +213,7 @@
 TranslationUnitDecl *TUDecl = nullptr;
 TU(StringRef Code, StringRef FileName, ArgVector Args)
 : Code(Code), FileName(FileName),
-  Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
+  Unit(tooling::buildASTFromCodeWithArgs(this->Code.data(), Args,
  this->FileName)),
   TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {}
   };


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -213,7 +213,7 @@
 TranslationUnitDecl *TUDecl = nullptr;
 TU(StringRef Code, StringRef FileName, ArgVector Args)
 : Code(Code), FileName(FileName),
-  Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
+  Unit(tooling::buildASTFromCodeWithArgs(this->Code.data(), Args,
  this->FileName)),
   TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {}
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45931: [ASTMatchers] Don't garble the profiling output when multiple TU's are processed

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

In https://reviews.llvm.org/D45931#1086665, @alexfh wrote:

> In https://reviews.llvm.org/D45931#1084503, @lebedev.ri wrote:
>
> > In https://reviews.llvm.org/D45931#1083192, @lebedev.ri wrote:
> >
> > > Thank you for looking at this.
> > >
> > > In https://reviews.llvm.org/D45931#1083184, @alexfh wrote:
> > >
> > > > From a user's perspective I'd probably prefer a different behavior of 
> > > > checks profiling with multiple translation units: per-file table after 
> > > > each file and an aggregate table at the end.
> > >
> > >
> > > Is this a review note, or a general observation?
> >
>
>
> Why not both? ;)


Review latency, finite time amount, you name it :)

 An independent improvement could be to support TSV/CSV output and/or 
 dumping to a file to spare the user from parsing the tables out of the 
 stdout/stderr.
>>> 
>>> Yes, and a script to merge those CSV's, would be nice.
> 
> I'd probably go with a set of features enough for various use cases:
>  0. don't add any profile merging logic to clang-tidy
> 
> 1. dump profile after each TU to the screen in the current tabulated format
> 2. add a flag to specify a file name prefix to dump profile output for each 
> file as CSV
> 3. (optional) add a script to merge profiles from CSV files and dump as CSV 
> or tabulated (without a script this could be done in a spreadsheet)
> 
>   WDYT?




Repository:
  rC Clang

https://reviews.llvm.org/D45931



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


[PATCH] D46325: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer. 2nd try.

2018-05-03 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 145059.
zinovy.nis added a comment.

- Added comments on why setting `ProgramAction` explicitly.


https://reviews.llvm.org/D46325

Files:
  clang-tidy/ClangTidy.cpp
  test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp


Index: test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
===
--- test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
+++ test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -524,6 +524,18 @@
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
 FrontendAction *create() override { return new Action(&ConsumerFactory); }
 
+bool runInvocation(std::shared_ptr Invocation,
+   FileManager *Files,
+   std::shared_ptr PCHContainerOps,
+   DiagnosticConsumer *DiagConsumer) override {
+  // Explicitly set ProgramAction to RunAnalysis to make the preprocessor
+  // define __clang_analyzer__ macro. The frontend analyzer action will not
+  // be called here.
+  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  return FrontendActionFactory::runInvocation(
+  Invocation, Files, PCHContainerOps, DiagConsumer);
+}
+
   private:
 class Action : public ASTFrontendAction {
 public:


Index: test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
===
--- test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
+++ test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -524,6 +524,18 @@
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
 FrontendAction *create() override { return new Action(&ConsumerFactory); }
 
+bool runInvocation(std::shared_ptr Invocation,
+   FileManager *Files,
+   std::shared_ptr PCHContainerOps,
+   DiagnosticConsumer *DiagConsumer) override {
+  // Explicitly set ProgramAction to RunAnalysis to make the preprocessor
+  // define __clang_analyzer__ macro. The frontend analyzer action will not
+  // be called here.
+  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  return FrontendActionFactory::runInvocation(
+  Invocation, Files, PCHContainerOps, DiagConsumer);
+}
+
   private:
 class Action : public ASTFrontendAction {
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46325: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer. 2nd try.

2018-05-03 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. Thank you!


https://reviews.llvm.org/D46325



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


[PATCH] D46325: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer. 2nd try.

2018-05-03 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Thanks Alexander for your feedback!


https://reviews.llvm.org/D46325



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


[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment.

In https://reviews.llvm.org/D45702#1086250, @aaron.ballman wrote:

> In https://reviews.llvm.org/D45702#1085890, @shuaiwang wrote:
>
> > In https://reviews.llvm.org/D45702#1085224, @aaron.ballman wrote:
> >
> > > > Have you run this over any large code bases to see whether the check 
> > > > triggers in practice?
> > >
> > > I'm still curious about this, btw.
> >
> >
> > Yes it triggers in Google's code base.
>
>
> Were there any false positives that you saw?


From randomly checking several triggerings no I didn't find any false 
positives. I feel the check should be pretty safe in terms of false positives 
because we only trigger on configured types.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



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


[clang-tools-extra] r331474 - [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer

2018-05-03 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Thu May  3 11:26:39 2018
New Revision: 331474

URL: http://llvm.org/viewvc/llvm-project?rev=331474&view=rev
Log:
[clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility 
with clang static analyzer

This macro is widely used in many well-known projects, ex. Chromium.
But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered
as [[no-return]], and a lot of false-positive warnings about nullptr
dereferenced are emitted.

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


Added:

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

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=331474&r1=331473&r2=331474&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu May  3 11:26:39 2018
@@ -524,6 +524,18 @@ void runClangTidy(clang::tidy::ClangTidy
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
 FrontendAction *create() override { return new Action(&ConsumerFactory); }
 
+bool runInvocation(std::shared_ptr Invocation,
+   FileManager *Files,
+   std::shared_ptr PCHContainerOps,
+   DiagnosticConsumer *DiagConsumer) override {
+  // Explicitly set ProgramAction to RunAnalysis to make the preprocessor
+  // define __clang_analyzer__ macro. The frontend analyzer action will not
+  // be called here.
+  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  return FrontendActionFactory::runInvocation(
+  Invocation, Files, PCHContainerOps, DiagConsumer);
+}
+
   private:
 class Action : public ASTFrontendAction {
 public:

Added: 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp?rev=331474&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp 
(added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp 
Thu May  3 11:26:39 2018
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif


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


[PATCH] D46325: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer. 2nd try.

2018-05-03 Thread Zinovy Nis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331474: [clang-tidy] Define __clang_analyzer__ macro for 
clang-tidy for compatibility… (authored by zinovy.nis, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D46325?vs=145059&id=145060#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46325

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.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
@@ -524,6 +524,18 @@
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
 FrontendAction *create() override { return new Action(&ConsumerFactory); }
 
+bool runInvocation(std::shared_ptr Invocation,
+   FileManager *Files,
+   std::shared_ptr PCHContainerOps,
+   DiagnosticConsumer *DiagConsumer) override {
+  // Explicitly set ProgramAction to RunAnalysis to make the preprocessor
+  // define __clang_analyzer__ macro. The frontend analyzer action will not
+  // be called here.
+  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  return FrontendActionFactory::runInvocation(
+  Invocation, Files, PCHContainerOps, DiagConsumer);
+}
+
   private:
 class Action : public ASTFrontendAction {
 public:
Index: 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif


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
@@ -524,6 +524,18 @@
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
 FrontendAction *create() override { return new Action(&ConsumerFactory); }
 
+bool runInvocation(std::shared_ptr Invocation,
+   FileManager *Files,
+   std::shared_ptr PCHContainerOps,
+   DiagnosticConsumer *DiagConsumer) override {
+  // Explicitly set ProgramAction to RunAnalysis to make the preprocessor
+  // define __clang_analyzer__ macro. The frontend analyzer action will not
+  // be called here.
+  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  return FrontendActionFactory::runInvocation(
+  Invocation, Files, PCHContainerOps, DiagConsumer);
+}
+
   private:
 class Action : public ASTFrontendAction {
 public:
Index: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r331475 - Simplify test clang-tidy-__clang_analyzer__macro.cpp

2018-05-03 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Thu May  3 11:31:39 2018
New Revision: 331475

URL: http://llvm.org/viewvc/llvm-project?rev=331475&view=rev
Log:
Simplify test clang-tidy-__clang_analyzer__macro.cpp 


Modified:

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp?rev=331475&r1=331474&r2=331475&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp 
Thu May  3 11:31:39 2018
@@ -3,8 +3,3 @@
 #if !defined(__clang_analyzer__)
 #error __clang_analyzer__ is not defined
 #endif
-// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
-
-#if !defined(__clang_analyzer__)
-#error __clang_analyzer__ is not defined
-#endif


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


[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-05-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

> Note that this sort of attribute is stripped from template arguments in 
> template substitution, so there's a possibility that code templated over 
> vectors will produce inadequately-aligned objects.

I was wondering whether there is a warning clang issues when the aligned 
attribute is stripped. If it doesn't warn, should it? I recently came across a 
case where a 16-byte vector annotated with a 4-byte alignment was passed to 
std::swap, which caused a crash because the alignment was stripped and the x86 
backend decided to emit an 16-byte aligned load to load an unaligned vector.


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


[PATCH] D46386: Adding __atomic_fetch_min/max intrinsics to clang

2018-05-03 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:3098
+  case AtomicExpr::AO__atomic_fetch_umax:
+IsMinMax = true;
+Form = Arithmetic;

Should `__sync_fetch_and_min` and others also set `IsMinMax`?


Repository:
  rC Clang

https://reviews.llvm.org/D46386



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


[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-05-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think we should seriously consider making alignment attributes on typedefs 
(and maybe some other attributes like may_alias) actual type qualifiers that 
are preserved in the canonical type, mangled, and so on.  It would be an ABI 
break, but it'd also solve a lot of problems.


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-03 Thread Caroline Tice via Phabricator via cfe-commits
cmtice created this revision.
cmtice added a reviewer: pcc.
Herald added a subscriber: cfe-commits.

Currently LLVM CFI tries to use an implicit blacklist file, currently in 
/usr/lib64/clang//share.  If the file is not there, LLVM happily 
continues, which causes CFI to add checks to files/functions that are known to 
fail, generating binaries that fail.  This CL causes LLVM to die (I hope) if it 
can't find these implicit blacklist files.


Repository:
  rC Clang

https://reviews.llvm.org/D46403

Files:
  SanitizerArgs.cpp


Index: SanitizerArgs.cpp
===
--- SanitizerArgs.cpp
+++ SanitizerArgs.cpp
@@ -115,6 +115,8 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: SanitizerArgs.cpp
===
--- SanitizerArgs.cpp
+++ SanitizerArgs.cpp
@@ -115,6 +115,8 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >