[PATCH] D31538: [analyzer] MisusedMovedObjectChecker: Fix a false positive on state-resetting a base-class sub-object.

2017-10-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

I think there was only one comment but that is already addressed in a dependent 
revision. So I think this one is good as is.


https://reviews.llvm.org/D31538



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


[PATCH] D38688: Misc redundant expressions checker updated for macros

2017-10-09 Thread Barancsuk Lilla via Phabricator via cfe-commits
barancsuk created this revision.
barancsuk added a project: clang-tools-extra.

Redundant Expression Checker is updated to be able to detect expressions that 
contain macro constants. Also, other small details are modified to improve the 
current implementation.

The improvements in detail are as follows:

**1.)** Binary and ternary operator expressions containing two constants, with 
at least one of them from a macro, are detected and tested for redundancy.

Macro expressions are treated somewhat differently from other expressions, 
because the particular values of macros can vary across builds. They can be 
considered correct and intentional, even if macro values equal, produce ranges 
that exclude each other or fully overlap, etc. The correctness of a macro 
expression is decided based on solely the operators involved in the expression.

Examples:

The following expression is always redundant, independently of the macro 
values, because the subexpression containing the larger constant can be 
eliminated without changing the meaning of the expression:

  (X < MACRO && X < OTHER_MACRO)

On the contrary, the following expression is considered meaningful, because 
some macro values (e.g.:  MACRO = 3, OTHER_MACRO = 2) produce a valid interval:

  (X < MACRO && X > OTHER_MACRO)

**2.) **The code structure is slightly modified: typos are corrected, comments 
are added and some functions are renamed to improve comprehensibility, both in 
the checker and the test file. A few test cases are moved to another function.

**3.)** The checker is now able to detect redundant CXXFunctionalCastExprs as 
well (it matched only CStyleCastExprs before). A corresponding test case is 
added.


https://reviews.llvm.org/D38688

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.h
  docs/clang-tidy/checks/misc-redundant-expression.rst
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -15,69 +15,71 @@
 extern int bar(int x);
 extern int bat(int x, int y);
 
-int Test(int X, int Y) {
+int TestSimpleEquivalent(int X, int Y) {
   if (X - X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent [misc-redundant-expression]
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent [misc-redundant-expression]
   if (X / X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X % X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X & X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X | X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X ^ X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X < X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X <= X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X > X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X >= X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X && X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
   if (X || X) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X != (((X return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
 
   if (X + 1 == X + 1) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are eq

[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/Function.h:36
+  template 
+  UniqueFunction(Callable Func)
+  : CallablePtr(llvm::make_unique<

sammccall wrote:
> Do you want this constructor to be explicit?
> 
> If not, I think you should be able to simplify the callsites in ClangdServer.h
Thanks for spotting this.
I think implicit works fine here. `std::function` also has implicit 
constructors. Simplified the callsites.





Comment at: clangd/Function.h:117
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.

sammccall wrote:
> I find these "first arg" APIs a bit awkward, and can lead to writing 
> confusing APIs for easier binding. Not sure there's a good alternative, 
> though.
Yeah. Works just like `std::bind`, though. And I would be very happy to remove 
that particular function altogether when we'll be able to use lambda 
initializer in LLVM codebase.


https://reviews.llvm.org/D38627



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


[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118204.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

Addressed review comments.

- Added a file comment.
- Simplified callsites of UniqueFunction in ClangdServer.h
- Properly forward UniqueFunction's constructor argument.
- Updates to comments.


https://reviews.llvm.org/D38627

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Function.h

Index: clangd/Function.h
===
--- /dev/null
+++ clangd/Function.h
@@ -0,0 +1,136 @@
+//===--- Function.h - Utility callable wrappers  -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file provides an analogue to std::function that supports move semantics.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A move-only type-erasing function wrapper. Similar to `std::function`, but
+/// allows to store move-only callables.
+template  class UniqueFunction;
+
+template  class UniqueFunction {
+public:
+  UniqueFunction() = default;
+  UniqueFunction(std::nullptr_t) : UniqueFunction(){};
+
+  UniqueFunction(UniqueFunction const &) = delete;
+  UniqueFunction &operator=(UniqueFunction const &) = delete;
+
+  UniqueFunction(UniqueFunction &&) noexcept = default;
+  UniqueFunction &operator=(UniqueFunction &&) noexcept = default;
+
+  template 
+  UniqueFunction(Callable &&Func)
+  : CallablePtr(llvm::make_unique<
+FunctionCallImpl::type>>(
+std::forward(Func))) {}
+
+  operator bool() { return CallablePtr; }
+
+  Ret operator()(Args... As) {
+assert(CallablePtr);
+CallablePtr->Call(std::forward(As)...);
+  }
+
+private:
+  class FunctionCallBase {
+  public:
+virtual ~FunctionCallBase() = default;
+virtual Ret Call(Args... As) = 0;
+  };
+
+  template 
+  class FunctionCallImpl final : public FunctionCallBase {
+static_assert(
+std::is_same::type>::value,
+"FunctionCallImpl must be instanstiated with std::decay'ed types");
+
+  public:
+FunctionCallImpl(Callable Func) : Func(std::move(Func)) {}
+
+Ret Call(Args... As) override { return Func(std::forward(As)...); }
+
+  private:
+Callable Func;
+  };
+
+  std::unique_ptr CallablePtr;
+};
+
+/// Stores a callable object (Func) and arguments (Args) and allows to call the
+/// callable with provided arguments later using `operator ()`. The arguments
+/// are std::forward'ed into the callable in the body of `operator()`. Therefore
+/// `operator()` can only be called once, as some of the arguments could be
+/// std::move'ed into the callable on first call.
+template  struct ForwardBinder {
+  using Tuple = std::tuple::type,
+   typename std::decay::type...>;
+  Tuple FuncWithArguments;
+#ifndef NDEBUG
+  bool WasCalled = false;
+#endif
+
+public:
+  ForwardBinder(Tuple FuncWithArguments)
+  : FuncWithArguments(std::move(FuncWithArguments)) {}
+
+private:
+  template 
+  auto CallImpl(llvm::integer_sequence Seq,
+RestArgs &&... Rest)
+  -> decltype(std::get<0>(this->FuncWithArguments)(
+  std::forward(std::get(this->FuncWithArguments))...,
+  std::forward(Rest)...)) {
+return std::get<0>(this->FuncWithArguments)(
+std::forward(std::get(this->FuncWithArguments))...,
+std::forward(Rest)...);
+  }
+
+public:
+  template 
+  auto operator()(RestArgs &&... Rest)
+  -> decltype(CallImpl(llvm::index_sequence_for(),
+   std::forward(Rest)...)) {
+
+#ifndef NDEBUG
+assert(!WasCalled && "Can only call result of BindWithForward once.");
+WasCalled = true;
+#endif
+return CallImpl(llvm::index_sequence_for(),
+std::forward(Rest)...);
+  }
+};
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.
+/// Similar to std::bind, but also works with move-only \p F and \p As.
+///
+/// The returned object must be called no more than once, as \p As are
+/// std::forwarded'ed (therefore can be moved) into \p F during the call.
+template 
+ForwardBinder BindWithForward(Func F, Args &&... As) {
+  return ForwardBinder(
+  std::make_tuple(std::forward(F), std::forward(As)...));
+}
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -20,6 +20,7 @@
 #i

[PATCH] D38617: Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added reviewers: bkramer, klimek.
ilya-biryukov added a comment.

Adding more reviewers, in case someone will have time to look at that :-)


https://reviews.llvm.org/D38617



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


[PATCH] D38402: [clang-refactor] Apply source replacements

2017-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: include/clang/Frontend/CommandLineSourceLoc.h:57
+  std::string FileName;
+  std::pair Begin;
+  std::pair End;

Add a comment documenting what the first element and second element of the pair 
represent for (? If I understand correctly).



Comment at: include/clang/Frontend/CommandLineSourceLoc.h:60
+
+  /// Returns a parsed source range from a string or None if the string is
+  /// invalid.

Would be clearer to document the valid format of the `Str`. 



Comment at: test/Refactor/tool-apply-replacements.cpp:3
+// RUN: cp %s %t.cp.cpp
+// RUN: clang-refactor local-rename -selection=%t.cp.cpp:6:7 -new-name=test 
%t.cp.cpp --
+// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp

Maybe add one more case for testing `-selection=%t.cp.cpp:6:7-6:15`.



Comment at: tools/clang-refactor/ClangRefactor.cpp:309
 public:
   void handleError(llvm::Error Err) {
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";

Add `override`.



Comment at: tools/clang-refactor/ClangRefactor.cpp:313
 
-  // FIXME: Consume atomic changes and apply them to files.
+  void handle(AtomicChanges Changes) {
+SourceChanges.insert(SourceChanges.begin(), Changes.begin(), 
Changes.end());

The same, `override`.



Comment at: tools/clang-refactor/ClangRefactor.cpp:412
+  if (!BufferErr) {
+llvm::errs() << "error: failed to open" << File << " for rewriting\n";
+return true;

nit: missing a blank after `open`.


Repository:
  rL LLVM

https://reviews.llvm.org/D38402



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


[PATCH] D38639: [clangd] #include statements support for Open definition

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.

Looking forward to getting this change! I miss this as well.
Please take a look at my comments, though. I think we might want to use a 
different API to implement this.




Comment at: clangd/ClangdServer.cpp:292
+  std::shared_ptr StalePreamble =
+  Resources->getPossiblyStalePreamble();
+  if (StalePreamble)

We can't use `getPossiblyStalePreamble()`, we want latest state of the 
`Preamble`. Use `getPreamble` instead.



Comment at: clangd/ClangdServer.cpp:294
+  if (StalePreamble)
+IncludeMap = StalePreamble->IncludeMap;
+  Resources->getAST().get()->runUnderLock(

We don't need to copy the whole map here, better add a method to `PreambleData` 
that does actual lookups for the source range.



Comment at: clangd/ClangdUnit.cpp:103
 
+  void AfterExecute(CompilerInstance &CI) override {
+const SourceManager &SM = CI.getSourceManager();

There's a much better public API to get all includes that were encountered by 
the `Preprocessor`: we need to override `PPCallbacks ::InclusionDirective`.


`PrecompiledPreamble` does not currently expose this callbacks, but could you 
add to `PreambleCallbacks` in a separate commit?




Comment at: clangd/ClangdUnit.cpp:151
   std::vector TopLevelDeclIDs;
+  std::map IncludeMap;
 };

Please use our descriptive `Path` typedef.



Comment at: clangd/ClangdUnit.cpp:834
+
+for (auto it = IncludeMap.begin(); it != IncludeMap.end(); ++it) {
+  SourceLocation L = it->first;

Can we mix in the results from includes outside `DeclarationLocationsFinder`?



Comment at: clangd/ClangdUnit.h:136
   std::vector Diags;
+  std::map IncludeMap;
 };

`std::unordered_map` is a better fit here, why not use it?



Comment at: clangd/ClangdUnit.h:136
   std::vector Diags;
+  std::map IncludeMap;
 };

ilya-biryukov wrote:
> `std::unordered_map` is a better fit here, why not use it?
Using `SourceLocation` after `SourceManager` owning them dies is somewhat hacky.

Please store clangd's `Range`s instead. You can get the ranges via 
`PPCallbacks` method `InclusionDirective`, it has a parameter `CharSourceRange 
FilenameRange`, exactly what we need here.




Comment at: unittests/clangd/ClangdTests.cpp:991
+  #include "foo.h"
+  #include "invalid.h"
+  int b = a;

Some includes may come outside of preamble, I would expect current 
implementation to fail for this case:

```
#include  // <-- works here 
// preamble ends here
int main() {

  #include "my_include.h" // <-- does not work here
}
```




https://reviews.llvm.org/D38639



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


Re: Patch to Bugzilla 31373

2017-10-09 Thread Chad Rosier via cfe-commits

Hi Erik,

You might consider posting your patch to Phabricator.  You'll likely get 
more feedback/traction there..


https://llvm.org/docs/Phabricator.html

 Chad


On 10/6/2017 8:15 AM, Erik Viktorsson via cfe-commits wrote:


Committing a patch to Bugzilla 31373 



A novice programmer so hopefully it complies with the coding policy.

I had to disable an assert in lib/CodeGen/CGExpr.cpp since it requires 
that all expressions are marked as Used or referenced, which is not 
possible if we want the ShouldDiagnoseUnusedDecl to return true (thus 
trigger the warn_unused_variable  warning).


The reason I removed the assert statement is because it causes five 
tests to fail. These test are the following:


·clang -cc1 -triple i386-unknown-unknown -mllvm -inline-threshold=1024 
-O3 -emit-llvm temp-order.cpp


·clang -cc1 -debug-info-kind=limited -std=c++11 -emit-llvm 
debug-info-scope.cpp


·clang -cc1 -std=c++1z -triple x86_64-apple-macosx10.7.0 -emit-llvm 
cxx1z-init-statement.cpp


·clang -cc1 -triple x86_64-apple-darwin10 -emit-llvm condition.cpp

·clang -cc1 -emit-llvm cxx-condition.cpp

/E



___
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] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.

This effectively reverts SVN r204290 and r204292 (back when this code was part 
of libcxxabi).

According to SVN r204290, the primary architecture using the 
DW_CFA_GNU_args_size opcode is VAX.

However, clang also produces it on X86 when it has done 
X86CallFrameOptimization, which gets done much more frequently if the stack is 
aligned to 4 bytes (which is the default when targeting windows).

This issue can be tested by building code for x86 linux (at least for 32 bit) 
with clang with -mstack-alignment=4.

I'm not sure if this code should be handled differently for VAX with some 
ifdef, or what the correct interpretation of this opcode is. I ran into this 
issue while trying to use libunwind for 32 bit windows (where clang uses a 4 
byte stack alignment by default), found this commit, and noticed I got it 
working by reverting it. And later noticed I could reproduce the same issue on 
32 bit x86 linux as well, by forcing -mstack-alignment=4.


https://reviews.llvm.org/D38680

Files:
  src/UnwindCursor.hpp
  src/libunwind.cpp


Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -182,8 +182,16 @@
 co->setReg(regNum, (pint_t)value);
 // specical case altering IP to re-find info (being called by personality
 // function)
-if (regNum == UNW_REG_IP)
+if (regNum == UNW_REG_IP) {
+  unw_proc_info_t info;
+  co->getInfo(&info);
+  pint_t orgArgSize = (pint_t)info.gp;
+  uint64_t orgFuncStart = info.start_ip;
   co->setInfoBasedOnIPRegister(false);
+  // and adjust REG_SP if there was a DW_CFA_GNU_args_size
+  if ((orgFuncStart == info.start_ip) && (orgArgSize != 0))
+co->setReg(UNW_REG_SP, co->getReg(UNW_REG_SP) + orgArgSize);
+}
 return UNW_ESUCCESS;
   }
   return UNW_EBADREG;
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -1356,8 +1356,6 @@
 this->setInfoBasedOnIPRegister(true);
 if (_unwindInfoMissing)
   return UNW_STEP_END;
-if (_info.gp)
-  setReg(UNW_REG_SP, getReg(UNW_REG_SP) + _info.gp);
   }
 
   return result;


Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -182,8 +182,16 @@
 co->setReg(regNum, (pint_t)value);
 // specical case altering IP to re-find info (being called by personality
 // function)
-if (regNum == UNW_REG_IP)
+if (regNum == UNW_REG_IP) {
+  unw_proc_info_t info;
+  co->getInfo(&info);
+  pint_t orgArgSize = (pint_t)info.gp;
+  uint64_t orgFuncStart = info.start_ip;
   co->setInfoBasedOnIPRegister(false);
+  // and adjust REG_SP if there was a DW_CFA_GNU_args_size
+  if ((orgFuncStart == info.start_ip) && (orgArgSize != 0))
+co->setReg(UNW_REG_SP, co->getReg(UNW_REG_SP) + orgArgSize);
+}
 return UNW_ESUCCESS;
   }
   return UNW_EBADREG;
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -1356,8 +1356,6 @@
 this->setInfoBasedOnIPRegister(true);
 if (_unwindInfoMissing)
   return UNW_STEP_END;
-if (_info.gp)
-  setReg(UNW_REG_SP, getReg(UNW_REG_SP) + _info.gp);
   }
 
   return result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r314571 - [Analyzer] Synthesize function body for std::call_once

2017-10-09 Thread Alexander Kornienko via cfe-commits
Bugzilla is not accessible, so here's a reduced test case:
$ cat test-clang__BodyFarm__getBody.cc
namespace std {
template 
void call_once(d, e);
}
void g();
void f() {
  std::call_once(g, false);
}
$ clang-tidy -checks=-*,clang-analyzer* test-clang__BodyFarm__getBody.cc --
-std=c++11 -w
*** SIGSEGV; stack trace: ***
PC: @  0x2f96e3a  (unknown)  clang::DeclContext::lookup()
@  0x532bb51   1152  FailureSignalHandler()
@ 0x7f42b341f9a0  (unknown)  (unknown)
@  0x2ae74c5576  (anonymous
namespace)::ASTMaker::findMemberField()
@  0x2ae59fc704  create_call_once()
@  0x2ae5040784  clang::BodyFarm::getBody()
@  0x2ac67af144  clang::AnalysisDeclContext::getBody()
@  0x1c499fa128
 clang::ento::AnyFunctionCall::getRuntimeDefinition()
@  0x1cc6146320
 clang::ento::ExprEngine::defaultEvalCall()
@  0x1c61033464
 clang::ento::CheckerManager::runCheckersForEvalCall()
@  0x1cc4fc9352  clang::ento::ExprEngine::evalCall()
@  0x1cc4e8c432
 clang::ento::ExprEngine::VisitCallExpr()
@  0x1c7da94   4000  clang::ento::ExprEngine::Visit()
@  0x1c7a821496  clang::ento::ExprEngine::ProcessStmt()
@  0x1c7a4da240
 clang::ento::ExprEngine::processCFGElement()
@  0x1ca8ed6128
 clang::ento::CoreEngine::HandlePostStmt()
@  0x1ca87d6496
 clang::ento::CoreEngine::dispatchWorkItem()
@  0x1ca8338544
 clang::ento::CoreEngine::ExecuteWorkList()
@   0xf954d5 80
 clang::ento::ExprEngine::ExecuteWorkList()
@   0xf3c612   1056  (anonymous
namespace)::AnalysisConsumer::ActionExprEngine()
@   0xf3c3d1 80  (anonymous
namespace)::AnalysisConsumer::RunPathSensitiveChecks()
@   0xf3c095288  (anonymous
namespace)::AnalysisConsumer::HandleCode()
@   0xf2f6e3416  (anonymous
namespace)::AnalysisConsumer::HandleDeclsCallGraph()
@   0xf2d967336  (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit()
@  0x1366eae 80
 clang::MultiplexConsumer::HandleTranslationUnit()
@  0x1dc6ae6288  clang::ParseAST()
@  0x135475a 80
 clang::ASTFrontendAction::ExecuteAction()
@  0x13541f0112  clang::FrontendAction::Execute()
@  0x1169822496
 clang::CompilerInstance::ExecuteAction()
@  0x1032ba2464
 clang::tooling::FrontendActionFactory::runInvocation()
@  0x1032a43160
 clang::tooling::ToolInvocation::runInvocation()
@  0x1031306   1840  clang::tooling::ToolInvocation::run()
@  0x1033c30   1664  clang::tooling::ClangTool::run()

On Sat, Oct 7, 2017 at 12:56 PM, Alexander Kornienko 
wrote:

> This revision might be the cause of https://bugs.llvm.org/show_
> bug.cgi?id=34869. I'm still working on a reduced test case.
>
> On Sat, Sep 30, 2017 at 2:03 AM, George Karpenkov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: george.karpenkov
>> Date: Fri Sep 29 17:03:22 2017
>> New Revision: 314571
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=314571&view=rev
>> Log:
>> [Analyzer] Synthesize function body for std::call_once
>>
>> Differential Revision: https://reviews.llvm.org/D37840
>>
>> Added:
>> cfe/trunk/test/Analysis/call_once.cpp
>> Modified:
>> cfe/trunk/lib/Analysis/BodyFarm.cpp
>>
>> Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/
>> BodyFarm.cpp?rev=314571&r1=314570&r2=314571&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
>> +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 29 17:03:22 2017
>> @@ -14,11 +14,18 @@
>>
>>  #include "BodyFarm.h"
>>  #include "clang/AST/ASTContext.h"
>> +#include "clang/AST/CXXInheritance.h"
>>  #include "clang/AST/Decl.h"
>>  #include "clang/AST/Expr.h"
>> +#include "clang/AST/ExprCXX.h"
>>  #include "clang/AST/ExprObjC.h"
>> +#include "clang/AST/NestedNameSpecifier.h"
>>  #include "clang/Analysis/CodeInjector.h"
>> +#include "clang/Basic/OperatorKinds.h"
>>  #include "llvm/ADT/StringSwitch.h"
>> +#include "llvm/Support/Debug.h"
>> +
>> +#define DEBUG_TYPE "body-farm"
>>
>>  using namespace clang;
>>
>> @@ -55,7 +62,9 @@ public:
>>CompoundStmt *makeCompound(ArrayRef);
>>
>>/// Create a new DeclRefExpr for the referenced variable.
>> -  DeclRefExpr *makeDeclRefExpr(const VarDecl *D);
>> +  DeclRefExpr *makeDeclRefExpr(const VarDecl *D,
>> +   bool RefersToEnclosingVariableOrCapture
>> = false,
>> +   bool GetNonReferenceType = false);
>>
>>/// Create a new UnaryOperator repr

[PATCH] D38674: [analyzer] MisusedMovedObjectChecker: More precise warning message

2017-10-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D38674



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


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118205.
ilya-biryukov added a comment.

- Included more cases into a qualifiers-as-written.cpp test.


https://reviews.llvm.org/D38538

Files:
  include/clang/AST/QualTypeNames.h
  include/clang/Tooling/Core/QualTypeNames.h
  lib/AST/CMakeLists.txt
  lib/AST/QualTypeNames.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/QualTypeNames.cpp
  test/CodeCompletion/call.cpp
  test/CodeCompletion/qualifiers-as-written.cpp
  test/CodeCompletion/uninstantiated_params.cpp
  test/Index/complete-cxx-inline-methods.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/QualTypeNames.h"
+#include "clang/AST/QualTypeNames.h"
 #include "TestVisitor.h"
 using namespace clang;
 
Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -25,7 +25,7 @@
 
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
-// CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
+// CHECK:  CXXMethod:{ResultType Vec &}{TypedText operator=}{LeftParen (}{Placeholder const Vec &}{RightParen )} (79)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
Index: test/CodeCompletion/uninstantiated_params.cpp
===
--- test/CodeCompletion/uninstantiated_params.cpp
+++ test/CodeCompletion/uninstantiated_params.cpp
@@ -9,5 +9,5 @@
   unique_ptr x;
   x.
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
-  // CHECK-CC1: [#void#]reset({#<#unique_ptr::pointer ptr = pointer()#>#})
+  // CHECK-CC1: [#void#]reset({#<#pointer ptr = pointer()#>#})
 }
Index: test/CodeCompletion/qualifiers-as-written.cpp
===
--- /dev/null
+++ test/CodeCompletion/qualifiers-as-written.cpp
@@ -0,0 +1,30 @@
+struct foo {
+  typedef int type;
+
+  type method(type, foo::type, ::foo::type, ::foo::foo::type);
+};
+
+namespace ns {
+  struct bar {
+  };
+
+  struct baz {
+  };
+
+  int func(foo::type a, bar b, baz c);
+}
+
+typedef ns::bar bar;
+
+int func(foo a, bar b, ns::bar c, ns::baz d);
+using ns::func;
+
+void test() {
+  foo().method(0, 0, 0, 0);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:9 %s -o - | FileCheck %s --check-prefix=CHECK-1
+  // CHECK-1: COMPLETION: method : [#type#]method(<#type#>, <#foo::type#>, <#::foo::type#>, <#::foo::foo::type#>)
+  f
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:26:3 %s -o - | FileCheck %s --check-prefix=CHECK-2
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar c#>, <#ns::baz d#>
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz c#>
+}
Index: test/CodeCompletion/call.cpp
===
--- test/CodeCompletion/call.cpp
+++ test/CodeCompletion/call.cpp
@@ -19,10 +19,10 @@
   f(Y(), 0, 0);
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1: f(N::Y y, <#int ZZ#>)
+  // CHECK-CC1: f(Y y, <#int ZZ#>)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
   // CHECK-CC1-NEXT: f(float x, <#float y#>)
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-  // CHECK-CC2-NOT: f(N::Y y, int ZZ)
+  // CHECK-CC2-NOT: f(Y y, int ZZ)
   // CHECK-CC2: f(int i, int j, <#int k#>)
 }
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -3,7 +3,6 @@
 add_clang_library(clangToolingCore
   Lookup.cpp
   Replacement.cpp
-  QualTypeNames.cpp
   Diagnostic.cpp
 
   LINK_LIBS
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/QualTypeNames.h"
 #include "clang/Basic/Char

[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/CodeCompletion/call.cpp:22
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1: f(N::Y y, <#int ZZ#>)
+  // CHECK-CC1: f(Y y, <#int ZZ#>)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)

arphaman wrote:
> Could we also test a similar class to `Y` that's not typedefed, so you'd see 
> `f(N::Y)`?
Not sure if you expect this to behave differently, but I've updated 
`qualifiers-as-written.cpp` to include a similar case. You could take a look 
and validate whether it matches your expected behavior.

The general idea is to not add extra qualification in completion items, where 
possible, and prefer to show what was written in the source code.
This is what currently happens for all names that had name-qualifiers. However, 
before this patch, unqualified names would printed with an added name 
qualifiers.

This sometimes led to really bad results. One example is vector's `push_back` 
that roughly gets printed as (libstdc++ version) `push_back(std::vector>::value_type _Value)`. Whereas in the source code it's just 
`push_back(value_type _Value)`.




https://reviews.llvm.org/D38538



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


[PATCH] D37970: [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

This looks useful, thanks!


https://reviews.llvm.org/D37970



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


[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file

2017-10-09 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D37299



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


[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

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

In https://reviews.llvm.org/D38675#891750, @danielmarjamaki wrote:

> > However, the checker seems to work with a low false positive rate.  (<15 on 
> > the LLVM, 6 effectively different)
>
> This does not sound like a low false positive rate to me. Could you describe 
> what the false positives are? Is it possible to fix them?


Note that the unique findings are 6. I think there are non-alpha checks with 
more false positives.


https://reviews.llvm.org/D38675



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


[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.

2017-10-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

LGTM!


https://reviews.llvm.org/D31541



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


[PATCH] D38596: Implement attribute target multiversioning

2017-10-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: rsmith.
erichkeane added a comment.

In https://reviews.llvm.org/D38596#891603, @aaron.ballman wrote:

> The attribute and sema bits look good to me, but I agree that you might want 
> Richard's opinions before committing.


Oh, definitely!  I actually put this up for @echristo to take a look at as a 
sanity check.  I realized it was a big patch so didn't want to spam a bunch of 
people.  @rsmith was definitely on the list!  I'll get this last const-auto fix 
(FWIW, I'm seeing the benefits now of for (X: Xs) being the same as for (const 
auto &&X : Xs)...) and add him and @rnk to start doing this as a 'final' review.

Thank you very much @echristo, @hfinkel  and @aaron.ballman !


https://reviews.llvm.org/D38596



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


[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants

2017-10-09 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl updated this revision to Diff 118182.
r.stahl marked an inline comment as done.
r.stahl edited the summary of this revision.
r.stahl added a comment.
Herald added a subscriber: szepet.

addressed review comments. updated summary.


https://reviews.llvm.org/D37478

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/pointer-arithmetic.c


Index: test/Analysis/pointer-arithmetic.c
===
--- test/Analysis/pointer-arithmetic.c
+++ test/Analysis/pointer-arithmetic.c
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  // This is a special case where pointer arithmetic is not calculated to
+  // preserve useful warnings on dereferences of null pointers.
+  int *p = 0;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -922,6 +922,10 @@
   if (rhs.isZeroConstant())
 return lhs;
 
+  // Perserve the null pointer so that it can be found by the DerefChecker.
+  if (lhs.isZeroConstant())
+return lhs;
+
   // We are dealing with pointer arithmetic.
 
   // Handle pointer arithmetic on constant values.
@@ -937,6 +941,8 @@
 
   // Offset the increment by the pointer size.
   llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
+  QualType pointeeType = resultTy->getPointeeType();
+  Multiplicand = 
getContext().getTypeSizeInChars(pointeeType).getQuantity();
   rightI *= Multiplicand;
 
   // Compute the adjusted pointer.


Index: test/Analysis/pointer-arithmetic.c
===
--- test/Analysis/pointer-arithmetic.c
+++ test/Analysis/pointer-arithmetic.c
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  // This is a special case where pointer arithmetic is not calculated to
+  // preserve useful warnings on dereferences of null pointers.
+  int *p = 0;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -922,6 +922,10 @@
   if (rhs.isZeroConstant())
 return lhs;
 
+  // Perserve the null pointer so that it can be found by the DerefChecker.
+  if (lhs.isZeroConstant())
+return lhs;
+
   // We are dealing with pointer arithmetic.
 
   // Handle pointer arithmetic on constant values.
@@ -937,6 +941,8 @@
 
   // Offset the increment by the pointer size.
   llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
+  QualType pointeeType = resultTy->getPointeeType();
+  Multiplicand = getContext().getTypeSizeInChars(pointeeType).getQuantity();
   rightI *= Multiplicand;
 
   // Compute the adjusted pointer.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-09 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 118210.
bader edited the summary of this revision.
bader added a comment.

Fix parsing of function declarations with empty parameter list initializers.
This change should fix the failure caught by the buildbot.
Sorry for the long delay.


https://reviews.llvm.org/D33681

Files:
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/function-no-args.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: test/SemaOpenCL/function-no-args.cl
===
--- test/SemaOpenCL/function-no-args.cl
+++ test/SemaOpenCL/function-no-args.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
+// expected-no-diagnostics
+
+global int gi;
+int my_func();
+int my_func() {
+  gi = 2;
+  return gi;
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
+&& !LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -5989,7 +5989,8 @@
 else if (RequiresArg)
   Diag(Tok, diag::err_argument_required_after_attribute);
 
-HasProto = ParamInfo.size() || getLangOpts().CPlusPlus;
+HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
+|| getLangOpts().OpenCL;
 
 // If we have the closing ')', eat it.
 Tracker.consumeClose();


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: test/SemaOpenCL/function-no-args.cl
===
--- test/SemaOpenCL/function-no-args.cl
+++ test/SemaOpenCL/function-no-args.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
+// expected-no-diagnostics
+
+global int gi;
+int my_func();
+int my_func() {
+  gi = 2;
+  return gi;
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
+&& !LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/

[PATCH] D38628: Remove unneeded typename from test

2017-10-09 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 updated this revision to Diff 118183.
rogfer01 added a comment.

- Remove another instance of this issue


https://reviews.llvm.org/D38628

Files:
  test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
  test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp


Index: test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
===
--- test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
+++ test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
@@ -28,5 +28,5 @@
 
 int main() {
 using V = std::variant;
-typename std::variant_alternative<4, V>::type foo;  // 
expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
+std::variant_alternative<4, V>::type foo;  // expected-error@variant:* 
{{Index out of bounds in std::variant_alternative<>}}
 }
Index: test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
===
--- test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
+++ test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
@@ -18,5 +18,5 @@
 int main()
 {
 typedef std::pair T;
-typename std::tuple_element<2, T>::type foo; // expected-error@utility:* 
{{Index out of bounds in std::tuple_element>}}
+std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index 
out of bounds in std::tuple_element>}}
 }


Index: test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
===
--- test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
+++ test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
@@ -28,5 +28,5 @@
 
 int main() {
 using V = std::variant;
-typename std::variant_alternative<4, V>::type foo;  // expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
+std::variant_alternative<4, V>::type foo;  // expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
 }
Index: test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
===
--- test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
+++ test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
@@ -18,5 +18,5 @@
 int main()
 {
 typedef std::pair T;
-typename std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index out of bounds in std::tuple_element>}}
+std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index out of bounds in std::tuple_element>}}
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118184.
ilya-biryukov added a comment.

- Use proper types (Args&&) when forwarding arguments.


https://reviews.llvm.org/D38627

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Function.h

Index: clangd/Function.h
===
--- /dev/null
+++ clangd/Function.h
@@ -0,0 +1,132 @@
+//===--- Function.h - Utility callable wrappers  -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A move-only type-erasing function wrapper. Similar to `std::function`, but
+/// allows to store move-only callables.
+template  class UniqueFunction;
+
+template  class UniqueFunction {
+public:
+  UniqueFunction() = default;
+  UniqueFunction(std::nullptr_t) : UniqueFunction(){};
+
+  UniqueFunction(UniqueFunction const &) = delete;
+  UniqueFunction &operator=(UniqueFunction const &) = delete;
+
+  UniqueFunction(UniqueFunction &&) noexcept = default;
+  UniqueFunction &operator=(UniqueFunction &&) noexcept = default;
+
+  template 
+  UniqueFunction(Callable Func)
+  : CallablePtr(llvm::make_unique<
+FunctionCallImpl::type>>(
+std::forward(Func))) {}
+
+  operator bool() { return CallablePtr; }
+
+  Ret operator()(Args... As) {
+assert(CallablePtr);
+CallablePtr->Call(std::forward(As)...);
+  }
+
+private:
+  class FunctionCallBase {
+  public:
+virtual ~FunctionCallBase() = default;
+virtual Ret Call(Args... As) = 0;
+  };
+
+  template 
+  class FunctionCallImpl final : public FunctionCallBase {
+static_assert(
+std::is_same::type>::value,
+"FunctionCallImpl must be instanstiated with std::decay'ed types");
+
+  public:
+FunctionCallImpl(Callable Func) : Func(std::move(Func)) {}
+
+Ret Call(Args... As) override { return Func(std::forward(As)...); }
+
+  private:
+Callable Func;
+  };
+
+  std::unique_ptr CallablePtr;
+};
+
+/// Stores a callable object (Func) and arguments (Args) and allows to call the
+/// callable with provided arguments later using `operator ()`. The arguments
+/// are std::forward'ed into the callable in the body of `operator()`. Therefore
+/// `operator()` can only be called once, as some of the arguments could be
+/// std::move'ed into the callable on first call.
+template  struct ForwardBinder {
+  using Tuple = std::tuple::type,
+   typename std::decay::type...>;
+  Tuple FuncWithArguments;
+#ifndef NDEBUG
+  bool WasCalled = false;
+#endif
+
+public:
+  ForwardBinder(Tuple FuncWithArguments)
+  : FuncWithArguments(std::move(FuncWithArguments)) {}
+
+private:
+  template 
+  auto CallImpl(llvm::integer_sequence Seq,
+RestArgs &&... Rest)
+  -> decltype(std::get<0>(this->FuncWithArguments)(
+  std::forward(std::get(this->FuncWithArguments))...,
+  std::forward(Rest)...)) {
+return std::get<0>(this->FuncWithArguments)(
+std::forward(std::get(this->FuncWithArguments))...,
+std::forward(Rest)...);
+  }
+
+public:
+  template 
+  auto operator()(RestArgs &&... Rest)
+  -> decltype(CallImpl(llvm::index_sequence_for(),
+   std::forward(Rest)...)) {
+
+#ifndef NDEBUG
+assert(!WasCalled && "Can only call result of BindWithForward once.");
+WasCalled = true;
+#endif
+return CallImpl(llvm::index_sequence_for(),
+std::forward(Rest)...);
+  }
+};
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.
+/// Similar to std::bind, but also works with move-only \p F and \p As.
+///
+/// The returned object can only be called once, as \p As are std::forwarded'ed
+/// (therefore can be std::move`d) into \p F for the call.
+template 
+ForwardBinder BindWithForward(Func F, Args &&... As) {
+  return ForwardBinder(
+  std::make_tuple(std::forward(F), std::forward(As)...));
+}
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringRef.h"
 
 #include "ClangdUnit.h"
+#include "Function.h"
 #include "Protocol.h"
 
 #include 
@@ -132,9 +133,8 @@
 
 {
   std::lock_guard Lock(Mutex);
-  RequestQueue.push_front(std::async(std::launch::deferred,
- std::forward(F),
- std::forward(As)..

[PATCH] D38683: [X86][AVX512] lowering broadcastm intrinsic - clang part

2017-10-09 Thread jina via Phabricator via cfe-commits
jina.nahias created this revision.

https://reviews.llvm.org/D38683

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx512cdintrin.h
  lib/Headers/avx512vlcdintrin.h
  test/CodeGen/avx512cdintrin.c
  test/CodeGen/avx512vlcd-builtins.c

Index: test/CodeGen/avx512vlcd-builtins.c
===
--- test/CodeGen/avx512vlcd-builtins.c
+++ test/CodeGen/avx512vlcd-builtins.c
@@ -3,28 +3,56 @@
 
 #include 
 
-__m128i test_mm_broadcastmb_epi64(__mmask8 __A) {
+__m128i test_mm_broadcastmb_epi64(__m128i a,__m128i b) {
   // CHECK-LABEL: @test_mm_broadcastmb_epi64
-  // CHECK: @llvm.x86.avx512.broadcastmb.128
-  return _mm_broadcastmb_epi64(__A); 
+  // CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8 x i32> 
+  // CHECK: bitcast <8 x i1> %{{.*}} to i8
+  // CHECK: zext i8 %{{.*}} to i64
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
+  return _mm_broadcastmb_epi64(_mm_cmpeq_epi32_mask (a, b)); 
 }
 
-__m256i test_mm256_broadcastmb_epi64(__mmask8 __A) {
+__m256i test_mm256_broadcastmb_epi64(__m256i a, __m256i b) {
   // CHECK-LABEL: @test_mm256_broadcastmb_epi64
-  // CHECK: @llvm.x86.avx512.broadcastmb.256
-  return _mm256_broadcastmb_epi64(__A); 
-}
-
-__m128i test_mm_broadcastmw_epi32(__mmask16 __A) {
+  // CHECK: icmp eq <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8 x i32> 
+  // CHECK: bitcast <8 x i1> %{{.*}} to i8
+  // CHECK: zext i8 %{{.*}} to i64
+  // CHECK: insertelement <4 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, i32 1
+  // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, i32 2
+  // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, i32 3
+  return _mm256_broadcastmb_epi64(_mm256_cmpeq_epi64_mask ( a, b)); 
+}
+
+__m128i test_mm_broadcastmw_epi32(__m512i a, __m512i b) {
   // CHECK-LABEL: @test_mm_broadcastmw_epi32
-  // CHECK: @llvm.x86.avx512.broadcastmw.128
-  return _mm_broadcastmw_epi32(__A); 
+  // CHECK: icmp eq <16 x i32> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: zext i16 %{{.*}} to i32
+  // CHECK: insertelement <4 x i32> undef, i32 %{{.*}}, i32 0
+  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 1
+  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 2
+  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 3
+  return _mm_broadcastmw_epi32(_mm512_cmpeq_epi32_mask ( a, b));
 }
 
-__m256i test_mm256_broadcastmw_epi32(__mmask16 __A) {
+__m256i test_mm256_broadcastmw_epi32(__m512i a, __m512i b) {
   // CHECK-LABEL: @test_mm256_broadcastmw_epi32
-  // CHECK: @llvm.x86.avx512.broadcastmw.256
-  return _mm256_broadcastmw_epi32(__A); 
+  // CHECK: icmp eq <16 x i32> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: zext i16 %{{.*}} to i32
+  // CHECK: insertelement <8 x i32> undef, i32 %{{.*}}, i32 0
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 1
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 2
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 3
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 4
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 5
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 6
+  // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 7
+  return _mm256_broadcastmw_epi32(_mm512_cmpeq_epi32_mask ( a, b)); 
 }
 
 __m128i test_mm_conflict_epi64(__m128i __A) {
Index: test/CodeGen/avx512cdintrin.c
===
--- test/CodeGen/avx512cdintrin.c
+++ test/CodeGen/avx512cdintrin.c
@@ -68,14 +68,40 @@
   return _mm512_maskz_lzcnt_epi64(__U,__A); 
 }
 
-__m512i test_mm512_broadcastmb_epi64(__mmask8 __A) {
+__m512i test_mm512_broadcastmb_epi64(__m512i a, __m512i b) {
   // CHECK-LABEL: @test_mm512_broadcastmb_epi64
-  // CHECK: @llvm.x86.avx512.broadcastmb.512
-  return _mm512_broadcastmb_epi64(__A); 
+  // CHECK: icmp eq <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: zext i8 %{{.*}} to i64
+  // CHECK: insertelement <8 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 1
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 2
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 3
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 4
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 5
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 6
+  // CHECK: insertelement <8 x i64> %{{.*}}, i64 %{{.*}}, i32 7
+  return _mm512_broadcastmb_epi64(_mm512_cmpeq_epu64_mask ( a, b)); 
 }
 
-__m512i test_mm512_broadcastmw_epi32(__mmask16 __A) {
+__m512i test_mm512_broadcastmw_epi32(__m512i a, __m512i b) {
   // CHECK-LABEL: @test_mm512_broadcastmw_epi32
-  // CHECK: @

[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-10-09 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi added a comment.

Any feedback is appreciated!


https://reviews.llvm.org/D30946



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


[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-09 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot added a comment.

I worked on a similar bug as 31161, and then found this one, it should be same 
as in comment7.
What is the current status of the work on that bug?


https://reviews.llvm.org/D38656



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


[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-09 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:3223-3224
+  // crash later.
+  llvm::IntegerType *ResultTy =
+ dyn_cast(Result->getType());
+  if ((ResultTy->getBitWidth() > 1) &&

Is this clang-format'd ?



Comment at: lib/CodeGen/CGExprScalar.cpp:3224
+  llvm::IntegerType *ResultTy =
+ dyn_cast(Result->getType());
+  if ((ResultTy->getBitWidth() > 1) &&

You are unconditionally dereferencing the result of a dyn_cast. You are either 
missing a null-check or this should be a cast<>



Comment at: lib/CodeGen/CGExprScalar.cpp:3225-3226
+ dyn_cast(Result->getType());
+  if ((ResultTy->getBitWidth() > 1) &&
+  (E->getType() == CGF.getContext().BoolTy))
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());

Extra parens.


https://reviews.llvm.org/D38656



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


[PATCH] D38617: Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

A testcase would be nice, but this can go in to unblock things.


https://reviews.llvm.org/D38617



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


[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part

2017-10-09 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman added a comment.

Please add depended parent. 
LGTM After the parent commit (LLVM side).


https://reviews.llvm.org/D38672



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


[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315210: [clangd] Added move-only function helpers. (authored 
by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38627

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/Function.h

Index: clang-tools-extra/trunk/clangd/Function.h
===
--- clang-tools-extra/trunk/clangd/Function.h
+++ clang-tools-extra/trunk/clangd/Function.h
@@ -0,0 +1,136 @@
+//===--- Function.h - Utility callable wrappers  -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file provides an analogue to std::function that supports move semantics.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A move-only type-erasing function wrapper. Similar to `std::function`, but
+/// allows to store move-only callables.
+template  class UniqueFunction;
+
+template  class UniqueFunction {
+public:
+  UniqueFunction() = default;
+  UniqueFunction(std::nullptr_t) : UniqueFunction(){};
+
+  UniqueFunction(UniqueFunction const &) = delete;
+  UniqueFunction &operator=(UniqueFunction const &) = delete;
+
+  UniqueFunction(UniqueFunction &&) noexcept = default;
+  UniqueFunction &operator=(UniqueFunction &&) noexcept = default;
+
+  template 
+  UniqueFunction(Callable &&Func)
+  : CallablePtr(llvm::make_unique<
+FunctionCallImpl::type>>(
+std::forward(Func))) {}
+
+  operator bool() { return CallablePtr; }
+
+  Ret operator()(Args... As) {
+assert(CallablePtr);
+CallablePtr->Call(std::forward(As)...);
+  }
+
+private:
+  class FunctionCallBase {
+  public:
+virtual ~FunctionCallBase() = default;
+virtual Ret Call(Args... As) = 0;
+  };
+
+  template 
+  class FunctionCallImpl final : public FunctionCallBase {
+static_assert(
+std::is_same::type>::value,
+"FunctionCallImpl must be instanstiated with std::decay'ed types");
+
+  public:
+FunctionCallImpl(Callable Func) : Func(std::move(Func)) {}
+
+Ret Call(Args... As) override { return Func(std::forward(As)...); }
+
+  private:
+Callable Func;
+  };
+
+  std::unique_ptr CallablePtr;
+};
+
+/// Stores a callable object (Func) and arguments (Args) and allows to call the
+/// callable with provided arguments later using `operator ()`. The arguments
+/// are std::forward'ed into the callable in the body of `operator()`. Therefore
+/// `operator()` can only be called once, as some of the arguments could be
+/// std::move'ed into the callable on first call.
+template  struct ForwardBinder {
+  using Tuple = std::tuple::type,
+   typename std::decay::type...>;
+  Tuple FuncWithArguments;
+#ifndef NDEBUG
+  bool WasCalled = false;
+#endif
+
+public:
+  ForwardBinder(Tuple FuncWithArguments)
+  : FuncWithArguments(std::move(FuncWithArguments)) {}
+
+private:
+  template 
+  auto CallImpl(llvm::integer_sequence Seq,
+RestArgs &&... Rest)
+  -> decltype(std::get<0>(this->FuncWithArguments)(
+  std::forward(std::get(this->FuncWithArguments))...,
+  std::forward(Rest)...)) {
+return std::get<0>(this->FuncWithArguments)(
+std::forward(std::get(this->FuncWithArguments))...,
+std::forward(Rest)...);
+  }
+
+public:
+  template 
+  auto operator()(RestArgs &&... Rest)
+  -> decltype(CallImpl(llvm::index_sequence_for(),
+   std::forward(Rest)...)) {
+
+#ifndef NDEBUG
+assert(!WasCalled && "Can only call result of BindWithForward once.");
+WasCalled = true;
+#endif
+return CallImpl(llvm::index_sequence_for(),
+std::forward(Rest)...);
+  }
+};
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.
+/// Similar to std::bind, but also works with move-only \p F and \p As.
+///
+/// The returned object must be called no more than once, as \p As are
+/// std::forwarded'ed (therefore can be moved) into \p F during the call.
+template 
+ForwardBinder BindWithForward(Func F, Args &&... As) {
+  return ForwardBinder(
+  std::make_tuple(std::forward(F), std::forward(As)...));
+}
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/c

[clang-tools-extra] r315210 - [clangd] Added move-only function helpers.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:26:26 2017
New Revision: 315210

URL: http://llvm.org/viewvc/llvm-project?rev=315210&view=rev
Log:
[clangd] Added move-only function helpers.

Summary:
They are now used in ClangdScheduler instead of deferred std::async
computations.
The results of `std::async` are much less effective and do not provide
a good abstraction for similar purposes, i.e. for storing additional callbacks
to clangd async tasks. The actual callback API will follow a bit later.

Reviewers: klimek, bkramer, sammccall, krasimir

Reviewed By: sammccall

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clangd/Function.h
Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=315210&r1=315209&r2=315210&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Oct  9 09:26:26 2017
@@ -99,7 +99,7 @@ ClangdScheduler::ClangdScheduler(unsigne
   for (unsigned I = 0; I < AsyncThreadsCount; ++I) {
 Workers.push_back(std::thread([this]() {
   while (true) {
-std::future Request;
+UniqueFunction Request;
 
 // Pick request from the queue
 {
@@ -120,7 +120,7 @@ ClangdScheduler::ClangdScheduler(unsigne
   RequestQueue.pop_front();
 } // unlock Mutex
 
-Request.get();
+Request();
   }
 }));
   }

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=315210&r1=315209&r2=315210&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Oct  9 09:26:26 2017
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringRef.h"
 
 #include "ClangdUnit.h"
+#include "Function.h"
 #include "Protocol.h"
 
 #include 
@@ -132,9 +133,8 @@ public:
 
 {
   std::lock_guard Lock(Mutex);
-  RequestQueue.push_front(std::async(std::launch::deferred,
- std::forward(F),
- std::forward(As)...));
+  RequestQueue.push_front(
+  BindWithForward(std::forward(F), std::forward(As)...));
 }
 RequestCV.notify_one();
   }
@@ -149,9 +149,8 @@ public:
 
 {
   std::lock_guard Lock(Mutex);
-  RequestQueue.push_back(std::async(std::launch::deferred,
-std::forward(F),
-std::forward(As)...));
+  RequestQueue.push_back(
+  BindWithForward(std::forward(F), std::forward(As)...));
 }
 RequestCV.notify_one();
   }
@@ -167,7 +166,7 @@ private:
   bool Done = false;
   /// A queue of requests. Elements of this vector are async computations (i.e.
   /// results of calling std::async(std::launch::deferred, ...)).
-  std::deque> RequestQueue;
+  std::deque> RequestQueue;
   /// Condition variable to wake up worker threads.
   std::condition_variable RequestCV;
 };

Added: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315210&view=auto
==
--- clang-tools-extra/trunk/clangd/Function.h (added)
+++ clang-tools-extra/trunk/clangd/Function.h Mon Oct  9 09:26:26 2017
@@ -0,0 +1,136 @@
+//===--- Function.h - Utility callable wrappers  -*- 
C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file provides an analogue to std::function that supports move 
semantics.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A move-only type-erasing function wrapper. Similar to `std::function`, but
+/// allows to store move-only callables.
+template  class UniqueFunction;
+
+template  class UniqueFunction {
+public:
+  UniqueFunction() = default;
+  UniqueFunction(std::nullptr_t) : UniqueFunction(){};
+
+  UniqueFunction(UniqueFunction const &) = delete;
+  UniqueFunction &operator=(UniqueFunction const &) = delete;
+
+  UniqueFunction(UniqueFunction &&) noexcept = default;
+  UniqueFunction &operator=(UniqueFunction &&) no

[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part

2017-10-09 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman accepted this revision.
m_zuckerman added a comment.
This revision is now accepted and ready to land.

after LLVM-SIDE


https://reviews.llvm.org/D38672



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


[PATCH] D38596: Implement attribute target multiversioning

2017-10-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 118218.
erichkeane added reviewers: rnk, rsmith.
erichkeane added a comment.

1 more const-auto.  Also noticed I'd missed that removing the 'default' caused 
the function to fallthrough, so I added llvm_unreachable to the bottom.


https://reviews.llvm.org/D38596

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/attr-target-multiversion.c
  test/CodeGenCXX/attr-target-multiversion.cpp
  test/Sema/attr-target-multiversion.c
  test/SemaCXX/attr-target-multiversion.cpp

Index: test/SemaCXX/attr-target-multiversion.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-target-multiversion.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+struct S {
+  __attribute__((target("arch=sandybridge")))
+  void mv(){}
+  __attribute__((target("arch=ivybridge")))
+  void mv(){}
+  __attribute__((target("default")))
+  void mv(){}
+
+  // NOTE: Virtual functions aren't implement for multiversioning in GCC either,
+  // so this is a 'TBD' feature.
+  // expected-error@+2 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  __attribute__((target("arch=sandybridge")))
+  virtual void mv_2(){}
+  // expected-error@+4 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-3 {{previous definition is here}}
+  __attribute__((target("arch=ivybridge")))
+  virtual void mv_2(){}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-7 {{previous definition is here}}
+  __attribute__((target("default")))
+  virtual void mv_2(){}
+};
+
+// Note: Template attribute 'target' isn't implemented in GCC either, and would
+// end up causing some nasty issues attempting it, so ensure that it still gives
+// the same errors as without the attribute.
+
+template
+__attribute__((target("arch=sandybridge")))
+void mv_temp(){}
+
+template
+__attribute__((target("arch=ivybridge")))
+//expected-error@+2 {{redefinition of}}
+//expected-note@-5{{previous definition is here}}
+void mv_temp(){}
+
+template
+__attribute__((target("default")))
+void mv_temp(){}
+
+void foo() {
+  //expected-error@+2{{no matching function for call to}}
+  //expected-note@-8{{candidate template ignored}}
+  mv_temp();
+}
Index: test/Sema/attr-target-multiversion.c
===
--- /dev/null
+++ test/Sema/attr-target-multiversion.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_DEFAULT %s
+
+#if defined(CHECK_DEFAULT)
+__attribute__((target("arch=sandybridge")))
+//expected-error@+1 {{function multiversioning with 'target' requires a 'default' implementation}}
+void no_default(){}
+__attribute__((target("arch=ivybridge")))
+void no_default(){}
+#else
+// Only multiversioning causes issues with redeclaration changing 'target'.
+__attribute__((target("arch=sandybridge")))
+void fine_since_no_mv();
+void fine_since_no_mv();
+
+void also_fine_since_no_mv();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv();
+
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+void also_fine_since_no_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void mv(){}
+__attribute__((target("arch=ivybridge")))
+void mv(){}
+__attribute__((target("default")))
+void mv(){}
+
+void redecl_causes_mv();
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-4 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv2();
+void redecl_causes_mv2();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-2 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_without_attr();
+__attribute__((target("arch=ivybridge")))
+void redecl_without_attr();
+// expected-error@+2 {{function redeclaration is missing 'target' attribute

[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/Function.h:9
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H

Maybe add a file comment "provides analogues to std::function that supports 
move semantics"?



Comment at: clangd/Function.h:36
+  template 
+  UniqueFunction(Callable Func)
+  : CallablePtr(llvm::make_unique<

Do you want this constructor to be explicit?

If not, I think you should be able to simplify the callsites in ClangdServer.h



Comment at: clangd/Function.h:77
+/// `operator()` can only be called once, as some of the arguments could be
+/// std::move'ed into the callable on first call.
+template  struct ForwardBinder {

nit: just 'moved'? std::move is just a cast...



Comment at: clangd/Function.h:117
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.

I find these "first arg" APIs a bit awkward, and can lead to writing confusing 
APIs for easier binding. Not sure there's a good alternative, though.



Comment at: clangd/Function.h:121
+///
+/// The returned object can only be called once, as \p As are std::forwarded'ed
+/// (therefore can be std::move`d) into \p F for the call.

nit: can -> must?


https://reviews.llvm.org/D38627



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


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118185.
ilya-biryukov added a comment.
Herald added a subscriber: mgorny.

- Restore qualifiers for types of EnumConstantDecl.


https://reviews.llvm.org/D38538

Files:
  include/clang/AST/QualTypeNames.h
  include/clang/Tooling/Core/QualTypeNames.h
  lib/AST/CMakeLists.txt
  lib/AST/QualTypeNames.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/QualTypeNames.cpp
  test/CodeCompletion/call.cpp
  test/CodeCompletion/qualifiers-as-written.cpp
  test/CodeCompletion/uninstantiated_params.cpp
  test/Index/complete-cxx-inline-methods.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/QualTypeNames.h"
+#include "clang/AST/QualTypeNames.h"
 #include "TestVisitor.h"
 using namespace clang;
 
Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -25,7 +25,7 @@
 
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
-// CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
+// CHECK:  CXXMethod:{ResultType Vec &}{TypedText operator=}{LeftParen (}{Placeholder const Vec &}{RightParen )} (79)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
Index: test/CodeCompletion/uninstantiated_params.cpp
===
--- test/CodeCompletion/uninstantiated_params.cpp
+++ test/CodeCompletion/uninstantiated_params.cpp
@@ -9,5 +9,5 @@
   unique_ptr x;
   x.
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
-  // CHECK-CC1: [#void#]reset({#<#unique_ptr::pointer ptr = pointer()#>#})
+  // CHECK-CC1: [#void#]reset({#<#pointer ptr = pointer()#>#})
 }
Index: test/CodeCompletion/qualifiers-as-written.cpp
===
--- /dev/null
+++ test/CodeCompletion/qualifiers-as-written.cpp
@@ -0,0 +1,11 @@
+struct foo {
+  typedef int type;
+
+  type method(type, foo::type, ::foo::type, ::foo::foo::type);
+};
+
+void test() {
+  foo().
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:9 %s -o - | FileCheck %s
+  // CHECK: COMPLETION: method : [#type#]method(<#type#>, <#foo::type#>, <#::foo::type#>, <#::foo::foo::type#>)
+}
Index: test/CodeCompletion/call.cpp
===
--- test/CodeCompletion/call.cpp
+++ test/CodeCompletion/call.cpp
@@ -19,10 +19,10 @@
   f(Y(), 0, 0);
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1: f(N::Y y, <#int ZZ#>)
+  // CHECK-CC1: f(Y y, <#int ZZ#>)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
   // CHECK-CC1-NEXT: f(float x, <#float y#>)
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-  // CHECK-CC2-NOT: f(N::Y y, int ZZ)
+  // CHECK-CC2-NOT: f(Y y, int ZZ)
   // CHECK-CC2: f(int i, int j, <#int k#>)
 }
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -3,7 +3,6 @@
 add_clang_library(clangToolingCore
   Lookup.cpp
   Replacement.cpp
-  QualTypeNames.cpp
   Diagnostic.cpp
 
   LINK_LIBS
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/QualTypeNames.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
@@ -1495,6 +1496,7 @@
   Policy.AnonymousTagLocations = false;
   Policy.SuppressStrongLifetime = true;
   Policy.SuppressUnwrittenScope = true;
+  Policy.SuppressScope = true;
   return Policy;
 }
 
@@ -2137,9 +2139,10 @@
   T = Method->getSendResultType(BaseType);
 else
   T = Method->getReturnType();
-  } else if (const EnumConstantDecl *Enumerator = dyn_cast(ND))
+  } else if (const EnumConstantDecl *Enumerator = dy

r315212 - Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:52:12 2017
New Revision: 315212

URL: http://llvm.org/viewvc/llvm-project?rev=315212&view=rev
Log:
Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

Summary:
It was previsouly set only in ASTUnit, but it should be set for all client of
PrecompiledPreamble.

Reviewers: erikjv, bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=315212&r1=315211&r2=315212&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Oct  9 09:52:12 2017
@@ -1698,7 +1698,6 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
-  PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0;
   PPOpts.SingleFileParseMode = SingleFileParse;
   
   // Override the resources path.

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=315212&r1=315211&r2=315212&view=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Mon Oct  9 09:52:12 2017
@@ -234,6 +234,8 @@ llvm::ErrorOr Preco
   FrontendOpts.OutputFile = PreamblePCHFile->getFilePath();
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
   PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+  // Inform preprocessor to record conditional stack when building the 
preamble.
+  PreprocessorOpts.GeneratePreamble = true;
 
   // Create the compiler instance to use for building the precompiled preamble.
   std::unique_ptr Clang(


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


[PATCH] D38617: Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315212: Set PreprocessorOpts.GeneratePreamble=true in 
PrecompiledPreamble. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38617

Files:
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1698,7 +1698,6 @@
   PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
-  PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0;
   PPOpts.SingleFileParseMode = SingleFileParse;
   
   // Override the resources path.
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -234,6 +234,8 @@
   FrontendOpts.OutputFile = PreamblePCHFile->getFilePath();
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
   PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+  // Inform preprocessor to record conditional stack when building the 
preamble.
+  PreprocessorOpts.GeneratePreamble = true;
 
   // Create the compiler instance to use for building the precompiled preamble.
   std::unique_ptr Clang(


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1698,7 +1698,6 @@
   PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
-  PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0;
   PPOpts.SingleFileParseMode = SingleFileParse;
   
   // Override the resources path.
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -234,6 +234,8 @@
   FrontendOpts.OutputFile = PreamblePCHFile->getFilePath();
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
   PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+  // Inform preprocessor to record conditional stack when building the preamble.
+  PreprocessorOpts.GeneratePreamble = true;
 
   // Create the compiler instance to use for building the precompiled preamble.
   std::unique_ptr Clang(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

2017-10-09 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a reviewer: danielmarjamaki.
danielmarjamaki added a comment.

> However, the checker seems to work with a low false positive rate.  (<15 on 
> the LLVM, 6 effectively different)

This does not sound like a low false positive rate to me. Could you describe 
what the false positives are? Is it possible to fix them?

> Is it enough or should I check it on other open source projects?

you should check a number of different projects. There might be idioms/usages 
in other projects that are not seen in LLVM.

However I don't know what other open source C++11 projects there are.

But I have a script that runs clang on various Debian projects and I can run 
that and provide you with the results.


https://reviews.llvm.org/D38675



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


[clang-tools-extra] r315213 - [clangd] Added a test for r315212.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:53:00 2017
New Revision: 315213

URL: http://llvm.org/viewvc/llvm-project?rev=315213&view=rev
Log:
[clangd] Added a test for r315212.

Added:
clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test

Added: clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test?rev=315213&view=auto
==
--- clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test (added)
+++ clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test Mon Oct  9 
09:53:00 2017
@@ -0,0 +1,15 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 206
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#ifndef
 FOO\n#define FOO\nint a;\n#else\nint a = b;#endif\n\n\n"}}}
+# CHECK: 
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///main.cpp","diagnostics":[]}}
+
+Content-Length: 58
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown","params":null}


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


[PATCH] D38617: Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D38617#892092, @bkramer wrote:

> A testcase would be nice, but this can go in to unblock things.


Thanks for reviewing this!
Added a test case to clangd in https://reviews.llvm.org/rL315213.


Repository:
  rL LLVM

https://reviews.llvm.org/D38617



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


[PATCH] D38629: [clangd] Added a callback-based codeComplete in clangd.

2017-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm missing some context for this one:

- what's the goal? Make the code read more naturally, change the async model, 
or something else?
- what's the end state for codeComplete specifically? will we switch to the new 
overload and delete the other, or is makeFutureAPIFromCallback here to stay?


https://reviews.llvm.org/D38629



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


[PATCH] D38126: Make TBAA information to be part of LValueBaseInfo

2017-10-09 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 118200.
kosarev added a comment.

Removed the extra ###include##.


https://reviews.llvm.org/D38126

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/CodeGenTBAA.h

Index: lib/CodeGen/CodeGenTBAA.h
===
--- lib/CodeGen/CodeGenTBAA.h
+++ lib/CodeGen/CodeGenTBAA.h
@@ -47,6 +47,20 @@
 : TBAAAccessInfo(/* AccessType= */ nullptr)
   {}
 
+  bool operator==(const TBAAAccessInfo &Other) const {
+return BaseType == Other.BaseType &&
+   AccessType == Other.AccessType &&
+   Offset == Other.Offset;
+  }
+
+  bool operator!=(const TBAAAccessInfo &Other) const {
+return !(*this == Other);
+  }
+
+  explicit operator bool() const {
+return *this != TBAAAccessInfo();
+  }
+
   /// BaseType - The base/leading access type. May be null if this access
   /// descriptor represents an access that is not considered to be an access
   /// to an aggregate or union member.
@@ -136,6 +150,19 @@
   /// getMayAliasAccessInfo - Get TBAA information that represents may-alias
   /// accesses.
   TBAAAccessInfo getMayAliasAccessInfo();
+
+  /// isMayAliasAccessInfo - Test for the may-alias TBAA access descriptor.
+  bool isMayAliasAccessInfo(TBAAAccessInfo Info);
+
+  /// mergeTBAAInfoForCast - Get merged TBAA information for the purpose of
+  /// type casts.
+  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+  TBAAAccessInfo TargetInfo);
+
+  /// mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the
+  /// purpose of conditional operator.
+  TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA,
+ TBAAAccessInfo InfoB);
 };
 
 }  // end namespace CodeGen
@@ -166,9 +193,7 @@
 
   static bool isEqual(const clang::CodeGen::TBAAAccessInfo &LHS,
   const clang::CodeGen::TBAAAccessInfo &RHS) {
-return LHS.BaseType == RHS.BaseType &&
-   LHS.AccessType == RHS.AccessType &&
-   LHS.Offset == RHS.Offset;
+return LHS == RHS;
   }
 };
 
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -88,18 +88,45 @@
   return false;
 }
 
+/// Check if the given type is a valid base type to be used in access tags.
+static bool isValidBaseType(QualType QTy) {
+  if (QTy->isReferenceType())
+return false;
+  if (const RecordType *TTy = QTy->getAs()) {
+const RecordDecl *RD = TTy->getDecl()->getDefinition();
+// Incomplete types are not valid base access types.
+if (!RD)
+  return false;
+if (RD->hasFlexibleArrayMember())
+  return false;
+// RD can be struct, union, class, interface or enum.
+// For now, we only handle struct and class.
+if (RD->isStruct() || RD->isClass())
+  return true;
+  }
+  return false;
+}
+
 llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
   // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
   if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
 return nullptr;
 
+  // In some cases, such as dereferencing a structure member, the final access
+  // type may well itself be an aggregate. Since it is possible to dereference
+  // a member of that aggregate, this function shall be able to generate
+  // descriptors for any object types, including aggregate ones, without
+  // falling back to returning the "omnipotent char" type node.
+  // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function.
+  if (isValidBaseType(QTy))
+return getBaseTypeInfo(QTy);
+
   // If the type has the may_alias attribute (even on a typedef), it is
   // effectively in the general char alias class.
   if (TypeHasMayAlias(QTy))
 return getChar();
 
   const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
-
   if (llvm::MDNode *N = MetadataCache[Ty])
 return N;
 
@@ -232,20 +259,6 @@
   return StructMetadataCache[Ty] = nullptr;
 }
 
-/// Check if the given type is a valid base type to be used in access tags.
-static bool isValidBaseType(QualType QTy) {
-  if (const RecordType *TTy = QTy->getAs()) {
-const RecordDecl *RD = TTy->getDecl()->getDefinition();
-if (RD->hasFlexibleArrayMember())
-  return false;
-// RD can be struct, union, class, interface or enum.
-// For now, we only handle struct and class.
-if (RD->isStruct() || RD->isClass())
-  return true;
-  }
-  return false;
-}
-
 llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(Qual

[clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:58:16 2017
New Revision: 315214

URL: http://llvm.org/viewvc/llvm-project?rev=315214&view=rev
Log:
[clangd] Added a command-line arg to mirror clangd input into a file.

Summary: The arg is useful for debugging and creating test cases.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315214&r1=315213&r2=315214&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 09:58:16 
2017
@@ -37,6 +37,14 @@ void JSONOutput::log(const Twine &Messag
   Logs.flush();
 }
 
+void JSONOutput::mirrorInput(const Twine &Message) {
+  if (!InputMirror)
+return;
+
+  *InputMirror << Message;
+  InputMirror->flush();
+}
+
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
+  Out.mirrorInput(Line);
+  // Mirror '\n' that gets consumed by std::getline, but is not included in
+  // the resulting Line.
+  // Note that '\r' is part of Line, so we don't need to mirror it
+  // separately.
+  if (!In.eof())
+Out.mirrorInput("\n");
+
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message ("
-  + std::to_string(ContentLength)
-  + ") was ignored.\n");
+  "The previous value for this message (" +
+  std::to_string(ContentLength) + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
+  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only "
-+ std::to_string(In.gcount())
-+ " bytes of expected "
-+ std::to_string(ContentLength)
-+ ".\n");
+Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
+" bytes of expected " + std::to_string(ContentLength) + ".\n");
 break;
   }
 
@@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log( "Warning: Missing Content-Length header, or message has zero "
-   "length.\n" );
+  Out.log("Warning: Missing Content-Length header, or message has zero "
+  "length.\n");
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315214&r1=315213&r2=315214&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 09:58:16 2017
@@ -24,8 +24,9 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
-  : Outs(Outs), Logs(Logs) {}
+  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
+ llvm::raw_ostream *InputMirror = nullptr)
+  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine &Message);
@@ -33,9 +34,15 @@ public:
   /// Write to the logging stream.
   void log(const Twine &Message) override;
 
+  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
+  /// null.
+  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
+  void mirrorInput(const Twine &Message);
+
 private:
   llvm::raw_ostream &Outs;
   llvm::raw_ostream &Logs;
+  llvm::raw_ostream *InputMirror;
 
   std::mu

[PATCH] D37970: [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315214: [clangd] Added a command-line arg to mirror clangd 
input into a file. (authored by ibiryukov).

Changed prior to commit:
  https://reviews.llvm.org/D37970?vs=115628&id=118223#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37970

Files:
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
  clang-tools-extra/trunk/test/clangd/input-mirror.test

Index: clang-tools-extra/trunk/test/clangd/input-mirror.test
===
--- clang-tools-extra/trunk/test/clangd/input-mirror.test
+++ clang-tools-extra/trunk/test/clangd/input-mirror.test
@@ -0,0 +1,154 @@
+# RUN: clangd -run-synchronously -input-mirror-file %t < %s
+# Note that we have to use '-Z' as -input-mirror-file does not have a newline at the end of file.
+# RUN: diff -Z %t %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":0}}}
+# Go to local variable
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":1}}}
+# Go to local variable, end of token
+
+Content-Length: 214
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":2},"contentChanges":[{"text":"struct Foo {\nint x;\n};\nint main() {\n  Foo bar = { x : 1 };\n}\n"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":14}}}
+# Go to field, GNU old-style field designator 
+
+Content-Length: 215
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":3},"contentChanges":[{"text":"struct Foo {\nint x;\n};\nint main() {\n  Foo baz = { .x = 2 };\n}\n"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":15}}}
+# Go to field, field designator 
+
+Content-Length: 187
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":4},"contentChanges":[{"text":"int main() {\n   main();\n   return 0;\n}"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":3}}}
+# Go to function declaration, function call 
+
+Content-Length: 208
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"struct Foo {\n};\nint main() {\n   Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":3}}}
+# Go to struct declaration, new struct instance 
+
+Content-Length: 231
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"namespace n1 {\nstruct Foo {\n};\n}\nint main() {\n   n1::Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":4}}}
+# Go to struct declaration, new struct instance, qualified name 
+
+Content-Length: 215
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":6},"contentChanges":[{"text":"struct Foo {\n  int x;\n};\nint main() {\n   Foo bar;\n   bar.x;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":7}}}
+# Go to field declaration, field reference 
+
+Content-Length: 220
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":7},"contentChanges":[{"text":"struct Foo {\n  void x();\n};\nint main() {\n   Foo bar;\n   bar.x();\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"

[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/CodeCompletion/enum-switch-case-qualified.cpp:25
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: Blue : [#M::N::C::Color#]N::C::Blue
-// CHECK-CC1-NEXT: Green : [#M::N::C::Color#]N::C::Green
-// CHECK-CC1-NEXT: Indigo : [#M::N::C::Color#]N::C::Indigo
-// CHECK-CC1-NEXT: Orange : [#M::N::C::Color#]N::C::Orange
-// CHECK-CC1-NEXT: Red : [#M::N::C::Color#]N::C::Red
-// CHECK-CC1-NEXT: Violet : [#M::N::C::Color#]N::C::Violet
-// CHECK-CC1: Yellow : [#M::N::C::Color#]N::C::Yellow
+// CHECK-CC1: Blue : [#Color#]N::C::Blue
+// CHECK-CC1-NEXT: Green : [#Color#]N::C::Green

arphaman wrote:
> ilya-biryukov wrote:
> > This may be a somewhat unwanted part of this change.
> > Enum type is now written without qualifier here. I would argue that's ok, 
> > since the actual enum values are always properly qualified (they have to 
> > be, as they are actually inserted by completion) and those qualifiers 
> > provide all the necessary context for the user.
> I'm not 100% comfortable with making this kind of change right now. I'll try 
> to investigate what's best for our users.
I changed code to keep qualifiers for enums as is.
(This required moving some code from `libTooling` to `AST` in order to reuse 
it, I'll create a separate review for that if you're ok with the overall 
change).


https://reviews.llvm.org/D38538



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


[PATCH] D38629: [clangd] Added a callback-based codeComplete in clangd.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118225.
ilya-biryukov added a comment.

- Added a deprecation notice to function description.


https://reviews.llvm.org/D38629

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h

Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -233,6 +233,9 @@
   /// and AST and rebuild them from scratch.
   std::future forceReparse(PathRef File);
 
+  /// DEPRECATED. Please use a callback-based version, this API is deprecated
+  /// and will soon be removed.
+  ///
   /// Run code completion for \p File at \p Pos.
   ///
   /// Request is processed asynchronously. You can use the returned future to
@@ -252,6 +255,14 @@
llvm::Optional OverridenContents = llvm::None,
IntrusiveRefCntPtr *UsedFS = nullptr);
 
+  /// A version of `codeComplete` that runs \p Callback on the processing thread
+  /// when codeComplete results become available.
+  void codeComplete(
+  UniqueFunction>)> Callback,
+  PathRef File, Position Pos,
+  llvm::Optional OverridenContents = llvm::None,
+  IntrusiveRefCntPtr *UsedFS = nullptr);
+
   /// Provide signature help for \p File at \p Pos. If \p OverridenContents is
   /// not None, they will used only for signature help, i.e. no diagnostics
   /// update will be scheduled and a draft for \p File will not be updated. If
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -48,6 +48,25 @@
   return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
 }
 
+template 
+std::future makeFutureAPIFromCallback(
+ClangdServer *Server,
+void (ClangdServer::*CallbackFunPtr)(UniqueFunction, Args...),
+Args... As) {
+  std::promise ResultPromise;
+  std::future ResultFuture = ResultPromise.get_future();
+
+  auto Callback = [](std::promise ResultPromise, Ret Result) -> void {
+ResultPromise.set_value(std::move(Result));
+  };
+
+  (Server->*CallbackFunPtr)(
+  BindWithForward(std::move(Callback), std::move(ResultPromise)),
+  std::forward(As)...);
+
+  return ResultFuture;
+}
+
 } // namespace
 
 size_t clangd::positionToOffset(StringRef Code, Position P) {
@@ -198,6 +217,17 @@
 ClangdServer::codeComplete(PathRef File, Position Pos,
llvm::Optional OverridenContents,
IntrusiveRefCntPtr *UsedFS) {
+  return makeFutureAPIFromCallback(this, &ClangdServer::codeComplete, File, Pos,
+   OverridenContents, UsedFS);
+}
+
+void ClangdServer::codeComplete(
+UniqueFunction>)> Callback,
+PathRef File, Position Pos, llvm::Optional OverridenContents,
+IntrusiveRefCntPtr *UsedFS) {
+  using CallbackType =
+  UniqueFunction>)>;
+
   std::string Contents;
   if (OverridenContents) {
 Contents = *OverridenContents;
@@ -216,36 +246,33 @@
   std::shared_ptr Resources = Units.getFile(File);
   assert(Resources && "Calling completion on non-added file");
 
-  using PackagedTask =
-  std::packaged_task>()>;
-
   // Remember the current Preamble and use it when async task starts executing.
   // At the point when async task starts executing, we may have a different
   // Preamble in Resources. However, we assume the Preamble that we obtain here
   // is reusable in completion more often.
   std::shared_ptr Preamble =
   Resources->getPossiblyStalePreamble();
-  // A task that will be run asynchronously.
-  PackagedTask Task([=]() mutable { // 'mutable' to reassign Preamble variable.
-if (!Preamble) {
-  // Maybe we built some preamble before processing this request.
-  Preamble = Resources->getPossiblyStalePreamble();
-}
-// FIXME(ibiryukov): even if Preamble is non-null, we may want to check
-// both the old and the new version in case only one of them matches.
-
-std::vector Result = clangd::codeComplete(
-File, Resources->getCompileCommand(),
-Preamble ? &Preamble->Preamble : nullptr, Contents, Pos, TaggedFS.Value,
-PCHs, SnippetCompletions, Logger);
-return make_tagged(std::move(Result), std::move(TaggedFS.Tag));
-  });
 
-  auto Future = Task.get_future();
-  // FIXME(ibiryukov): to reduce overhead for wrapping the same callable
-  // multiple times, ClangdScheduler should return future<> itself.
-  WorkScheduler.addToFront([](PackagedTask Task) { Task(); }, std::move(Task));
-  return Future;
+  // A task that will be run asynchronously.
+  auto Task =
+  // 'mutable' to reassign Preamble variable.
+  [=](CallbackType Callback) mutable {
+if (!Preamble) {
+  // Maybe we built some preamble before processing this request.
+  Preamble = Resources->getPossiblyStalePreamble();
+}
+// FIXME(ibiryukov): even if Preamble is non-null, we may want to check
+// both the old and 

[PATCH] D38629: [clangd] Added a callback-based codeComplete in clangd.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

We had a discussion with @sammccall  offline, probably

> - what's the goal? Make the code read more naturally, change the async model, 
> or something else?

Callback API is more flexible (if `std::future` that we use had `then`, they'd 
be equivalent).
We have internal clients that want to be notified about results of code 
completion without

> - what's the end state for codeComplete specifically? will we switch to the 
> new overload and delete the other, or is `makeFutureAPIFromCallback` here to 
> stay?

I think the way to go would be exactly that, switch to the new API and remove 
the older one. There are usages in tests, `ClangdLSPServer` and in our internal 
client, but I'll remove them with a separate commit later.
Added a deprecation notice for the API.


https://reviews.llvm.org/D38629



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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple updated this revision to Diff 118231.
jkorous-apple added a comment.

clang-format


https://reviews.llvm.org/D38643

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/array-type.cpp


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << "s";
+break;
+  case ArrayType::Star:
+Out << "*";
+break;
+  case ArrayType::Normal:
+Out << "n";
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << "s";
+break;
+  case ArrayType::Star:
+Out << "*";
+break;
+  case ArrayType::Normal:
+Out << "n";
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38674: [analyzer] MisusedMovedObjectChecker: More precise warning message

2017-10-09 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

LGTM


https://reviews.llvm.org/D38674



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.

This builds on some parts from https://reviews.llvm.org/D33601 - some of them 
were commented on before. This patch contains comments and explanations about 
those non-obvious parts.


https://reviews.llvm.org/D38679

Files:
  docs/index.rst
  src/AddressSpace.hpp
  src/UnwindRegistersRestore.S
  src/assembly.h
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -37,6 +37,8 @@
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
+#elif defined(_WIN32)
+  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/assembly.h
===
--- src/assembly.h
+++ src/assembly.h
@@ -26,6 +26,14 @@
 
 #if defined(__APPLE__)
 #define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+// In the COFF object file format, there's no attributes for a global,
+// non-static symbol to make it somehow hidden. So on windows, we don't
+// want to set this at all. To avoid conditionals in
+// DEFINE_LIBUNWIND_PRIVATE_FUNCTION below, make it .globl (which it already
+// is, defined in the same DEFINE_LIBUNWIND_PRIVATE_FUNCTION macro; the
+// duplicate .globl directives are harmless).
+#define HIDDEN_DIRECTIVE .globl
 #else
 #define HIDDEN_DIRECTIVE .hidden
 #endif
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -26,7 +26,12 @@
 #  + return address+
 #  +---+   <-- SP
 #  +   +
+#if !defined(_WIN32)
   movl   4(%esp), %eax
+#else
+  # On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,41 @@
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), &needed))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)&pinh->FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +518,7 @@
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, &dyldInfo)) {
 if (dyldInfo.dli_sname != NULL) {
Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -50,6 +50,7 @@
 LinuxARM 

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: src/AddressSpace.hpp:388-389
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;

".eh_frame" is 9 characters, right? I thought mingw linkers took sections with 
long names and moved them to an extended symbol table. Does that not apply to 
.eh_frame?


https://reviews.llvm.org/D38679



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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lib/Index/USRGeneration.cpp:819
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";

Nit: I don't think you really need the 2nd const here and in the next if.


https://reviews.llvm.org/D38643



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


[PATCH] D38694: [ASTImporter] Support importing CXXUnresolvedConstructExpr and UnresolvedLookupExpr

2017-10-09 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.

This patch adds support for importing two different kind of C++ AST Node.
Note: This solution is based on 
https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L7605
 .


https://reviews.llvm.org/D38694

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -457,7 +457,6 @@
   vaArgExpr();
 }
 
-
 TEST(ImportType, ImportAtomicType) {
   MatchVerifier Verifier;
   EXPECT_TRUE(testImport("void declToImport() { typedef _Atomic(int) a_int; }",
@@ -502,5 +501,39 @@
  has(cxxDependentScopeMemberExpr();
 }
 
+TEST(ImportExpr, ImportUnresolvedLookupExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("template int foo();"
+ "template  void declToImport() {"
+ "  ::foo;"
+ "  ::template foo;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(
+ compoundStmt(has(unresolvedLookupExpr();
+}
+
+TEST(ImportExpr, ImportCXXUnresolvedConstructExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("template  class C { T t; };"
+ "template  void declToImport() {"
+ "C d;"
+ "d.t = T()"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(has(
+ binaryOperator(has(cxxUnresolvedConstructExpr()));
+  EXPECT_TRUE(
+  testImport("template  class C { T t; };"
+ "template  void declToImport() {"
+ "C d;"
+ "(&d)->t = T()"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(has(
+ binaryOperator(has(cxxUnresolvedConstructExpr()));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -273,6 +273,8 @@
 Expr *VisitCXXConstructExpr(CXXConstructExpr *E);
 Expr *VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
 Expr *VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+Expr *VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *CE);
+Expr *VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
@@ -5464,6 +5466,80 @@
   MemberNameInfo, ResInfo);
 }
 
+Expr *ASTNodeImporter::VisitCXXUnresolvedConstructExpr(
+CXXUnresolvedConstructExpr *CE) {
+
+  unsigned NumArgs = CE->arg_size();
+
+  llvm::SmallVector ToArgs(NumArgs);
+
+  for (unsigned ai = 0, ae = NumArgs; ai != ae; ++ai) {
+Expr *FromArg = CE->getArg(ai);
+Expr *ToArg = Importer.Import(FromArg);
+if (!ToArg)
+  return nullptr;
+ToArgs[ai] = ToArg;
+  }
+
+  Expr **ToArgs_Copied = new (Importer.getToContext()) Expr *[NumArgs];
+
+  for (unsigned ai = 0, ae = NumArgs; ai != ae; ++ai)
+ToArgs_Copied[ai] = ToArgs[ai];
+
+  return CXXUnresolvedConstructExpr::Create(
+  Importer.getToContext(), Importer.Import(CE->getTypeSourceInfo()),
+  Importer.Import(CE->getLParenLoc()),
+  llvm::makeArrayRef(ToArgs_Copied, NumArgs),
+  Importer.Import(CE->getRParenLoc()));
+}
+
+Expr *ASTNodeImporter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+  CXXRecordDecl *NamingClass =
+  cast_or_null(Importer.Import(E->getNamingClass()));
+  if (E->getNamingClass() && !NamingClass)
+return nullptr;
+
+  DeclarationName Name = Importer.Import(E->getName());
+  if (E->getName().isEmpty() && Name.isEmpty())
+return nullptr;
+  DeclarationNameInfo NameInfo(Name, Importer.Import(E->getNameLoc()));
+  // Import additional name location/type info.
+  ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+  UnresolvedSet<8> ToDecls;
+  for (Decl *D : E->decls()) {
+if (NamedDecl *To = cast_or_null(Importer.Import(D)))
+  ToDecls.addDecl(To);
+else
+  return nullptr;
+  }
+
+  TemplateArgumentListInfo ToTAInfo;
+  TemplateArgumentListInfo *ResInfo = nullptr;
+  if (E->hasExplicitTemplateArgs()) {
+for (const auto &FromLoc : E->template_arguments()) {
+  bool Error = false;
+  TemplateArgumentLoc ToTALoc = ImportTemplateArgumentLoc(FromLoc, Error);
+  if (Error)
+return nullptr;
+  ToTAInfo.addArgument(ToTALoc);
+}
+ResInfo = &ToTAInfo;
+  }
+
+  if (

[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Index/USRGeneration.cpp:820
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";
+  switch (AT->getSizeModifier()) {

You might also want to use the character literals for one char strings for 
efficiency.


https://reviews.llvm.org/D38643



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


r315219 - AMDGPU: Fix missing declaration for __builtin_amdgcn_dispatch_ptr

2017-10-09 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Oct  9 10:44:18 2017
New Revision: 315219

URL: http://llvm.org/viewvc/llvm-project?rev=315219&view=rev
Log:
AMDGPU: Fix missing declaration for __builtin_amdgcn_dispatch_ptr

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=315219&r1=315218&r2=315219&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon Oct  9 10:44:18 2017
@@ -21,6 +21,7 @@
 // SI+ only builtins.
 
//===--===//
 
+BUILTIN(__builtin_amdgcn_dispatch_ptr, "Uc*2", "nc")
 BUILTIN(__builtin_amdgcn_kernarg_segment_ptr, "Uc*2", "nc")
 BUILTIN(__builtin_amdgcn_implicitarg_ptr, "Uc*2", "nc")
 

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=315219&r1=315218&r2=315219&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Mon Oct  9 10:44:18 2017
@@ -421,6 +421,13 @@ void test_read_exec(global ulong* out) {
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_dispatch_ptr
+// CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
+void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
+{
+  *out = __builtin_amdgcn_dispatch_ptr();
+}
+
 // CHECK-LABEL: @test_kernarg_segment_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
 void test_kernarg_segment_ptr(__attribute__((address_space(2))) unsigned char 
** out)


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


[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-09 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot updated this revision to Diff 118236.
Carrot marked 3 inline comments as done.

https://reviews.llvm.org/D38656

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ppc-vector-compare.cc


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, 
E->getType(),
   E->getExprLoc());
 }


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(),
   E->getExprLoc());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r315194 - Make SourceLocation, QualType and friends have constexpr constructors.

2017-10-09 Thread Galina Kistanova via cfe-commits
Hello Benjamin,

I look s like this commit broke build on one of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5327

. . .
FAILED:
tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.obj

C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS
-DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Itools\clang\lib\Serialization
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include
/DWIN32 /D_WINDOWS   /WX /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast
/W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351
-wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
-wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706
-wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091
-wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1/EHs-c-
/GR- /showIncludes
/Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
/Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\clangSerialization.pdb
/FS -c
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
error C2220: warning treated as error - no 'object' file generated
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
warning C4709: comma operator within array index expression

Please have a look?

Thanks

Galina

On Sun, Oct 8, 2017 at 1:53 PM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Sun Oct  8 13:53:36 2017
> New Revision: 315194
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315194&view=rev
> Log:
> Make SourceLocation, QualType and friends have constexpr constructors.
>
> No functionality change intended.
>
> Modified:
> cfe/trunk/include/clang/AST/CharUnits.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/Basic/SourceLocation.h
>
> Modified: cfe/trunk/include/clang/AST/CharUnits.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/CharUnits.h?rev=315194&r1=315193&r2=315194&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/CharUnits.h (original)
> +++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct  8 13:53:36 2017
> @@ -40,14 +40,14 @@ namespace clang {
>typedef int64_t QuantityType;
>
>  private:
> -  QuantityType Quantity;
> +  QuantityType Quantity = 0;
>
>explicit CharUnits(QuantityType C) : Quantity(C) {}
>
>  public:
>
>/// CharUnits - A default constructor.
> -  CharUnits() : Quantity(0) {}
> +  CharUnits() = default;
>
>/// Zero - Construct a CharUnits quantity of zero.
>static CharUnits Zero() {
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Type.h?rev=315194&r1=315193&r2=315194&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Sun Oct  8 13:53:36 2017
> @@ -162,8 +162,6 @@ public:
>  FastMask = (1 << FastWidth) - 1
>};
>
> -  Qualifiers() : Mask(0) {}
> -
>/// Returns the common set of qualifiers while removing them from
>/// the given sets.
>static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
> {
> @@ -539,7 +537,7 @@ private:
>
>// bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
>//   |C R V|U|GCAttr|Lifetime|AddressSpace|
> -  uint32_t Mask;
> +  uint32_t Mask = 0;
>
>static const uint32_t UMask = 0x8;
>static const uint32_t UShift = 3;
> @@ -634,7 +632,7 @@ class QualType {
>
>friend class QualifierCollector;
>  public:
> -  QualType() {}
> +  QualType() = default;
>
>QualType(const Type *Ptr, unsigned Quals)
>  : Value(Ptr, Quals) {}
>
> Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/SourceLocation.h?rev=315194&r1=315193&r2=315194&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
> +++ cfe/trunk/include/

[PATCH] D38695: [CodeGen] Do not construct complete LValue base info in trivial cases

2017-10-09 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

Besides obvious code simplification, avoiding explicit creation of 
LValueBaseInfo objects makes it easier to make TBAA information to be part of 
such objects.

This is part of https://reviews.llvm.org/D38126 reworked to be a separate patch 
to simplify review.


Repository:
  rL LLVM

https://reviews.llvm.org/D38695

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1911,15 +1911,26 @@
   //======//
 
   LValue MakeAddrLValue(Address Addr, QualType T,
-LValueBaseInfo BaseInfo =
-LValueBaseInfo(AlignmentSource::Type)) {
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Addr, T, getContext(),
+LValueBaseInfo(Source, false),
+CGM.getTBAAAccessInfo(T));
+  }
+
+  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo) {
 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
 CGM.getTBAAAccessInfo(T));
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-LValueBaseInfo BaseInfo =
-LValueBaseInfo(AlignmentSource::Type)) {
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
+LValueBaseInfo(Source, false),
+CGM.getTBAAAccessInfo(T));
+  }
+
+  LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
+LValueBaseInfo BaseInfo) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
 BaseInfo, CGM.getTBAAAccessInfo(T));
   }
@@ -3058,8 +3069,15 @@
   /// the LLVM value representation.
   llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
 SourceLocation Loc,
-LValueBaseInfo BaseInfo =
-LValueBaseInfo(AlignmentSource::Type),
+AlignmentSource Source = AlignmentSource::Type,
+bool isNontemporal = false) {
+return EmitLoadOfScalar(Addr, Volatile, Ty, Loc,
+LValueBaseInfo(Source, false),
+CGM.getTBAAAccessInfo(Ty), isNontemporal);
+  }
+
+  llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
+SourceLocation Loc, LValueBaseInfo BaseInfo,
 bool isNontemporal = false) {
 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc, BaseInfo,
 CGM.getTBAAAccessInfo(Ty), isNontemporal);
@@ -3081,8 +3099,14 @@
   /// the LLVM value representation.
   void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
  bool Volatile, QualType Ty,
- LValueBaseInfo BaseInfo =
- LValueBaseInfo(AlignmentSource::Type),
+ AlignmentSource Source = AlignmentSource::Type,
+ bool isInit = false, bool isNontemporal = false) {
+EmitStoreOfScalar(Value, Addr, Volatile, Ty, LValueBaseInfo(Source, false),
+  CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal);
+  }
+
+  void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
+ bool Volatile, QualType Ty, LValueBaseInfo BaseInfo,
  bool isInit = false, bool isNontemporal = false) {
 EmitStoreOfScalar(Value, Addr, Volatile, Ty, BaseInfo,
   CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal);
Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -392,15 +392,14 @@
   continue;
 }
 
-LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
-LValue ArgLVal =
-CGF.MakeAddrLValue(LocalAddr, Args[Cnt]->getType(), BaseInfo);
+LValue ArgLVal = CGF.MakeAddrLValue(LocalAddr, Args[Cnt]->getType(),
+AlignmentSource::Decl);
 if (FD->hasCapturedVLAType()) {
   if (FO.UIntPtrCastRequired) {
 ArgLVal = CGF.MakeAddrLValue(castValueFromUintptr(CGF, FD->getType(),
   Args[Cnt]->getName(),
   ArgLVal),
-   

[PATCH] D38126: Make TBAA information to be part of LValueBaseInfo

2017-10-09 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Please take a look at https://reviews.llvm.org/D38695, if you want this by 
smaller pieces. Thanks.


https://reviews.llvm.org/D38126



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


[PATCH] D38646: [MS] Raise the default value of _MSC_VER to 1910, which is in VS 2017

2017-10-09 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

FYI: 1910 was the value for VS 2017 RTM. 1911 is the value for VS 2017 15.3, 
the first toolset update. 1912 will be the value for VS 2017 15.5, the second 
toolset update.


Repository:
  rL LLVM

https://reviews.llvm.org/D38646



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


Re: r315194 - Make SourceLocation, QualType and friends have constexpr constructors.

2017-10-09 Thread Benjamin Kramer via cfe-commits
Looks like a bug in the compiler, the warning doesn't make any sense.
Does creating a FileID() variable and passing that instead work?

On Mon, Oct 9, 2017 at 8:02 PM, Galina Kistanova  wrote:
> Hello Benjamin,
>
> I look s like this commit broke build on one of our builders:
>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5327
>
> . . .
> FAILED:
> tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.obj
> C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS
> -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
> -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Itools\clang\lib\Serialization
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include
> -Itools\clang\include -Iinclude
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include
> /DWIN32 /D_WINDOWS   /WX /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4
> -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351
> -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
> -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706
> -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091
> -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1/EHs-c-
> /GR- /showIncludes
> /Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
> /Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\clangSerialization.pdb
> /FS -c
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
> error C2220: warning treated as error - no 'object' file generated
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
> warning C4709: comma operator within array index expression
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Sun, Oct 8, 2017 at 1:53 PM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> Author: d0k
>> Date: Sun Oct  8 13:53:36 2017
>> New Revision: 315194
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315194&view=rev
>> Log:
>> Make SourceLocation, QualType and friends have constexpr constructors.
>>
>> No functionality change intended.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/CharUnits.h
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/Basic/SourceLocation.h
>>
>> Modified: cfe/trunk/include/clang/AST/CharUnits.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=315194&r1=315193&r2=315194&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/CharUnits.h (original)
>> +++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct  8 13:53:36 2017
>> @@ -40,14 +40,14 @@ namespace clang {
>>typedef int64_t QuantityType;
>>
>>  private:
>> -  QuantityType Quantity;
>> +  QuantityType Quantity = 0;
>>
>>explicit CharUnits(QuantityType C) : Quantity(C) {}
>>
>>  public:
>>
>>/// CharUnits - A default constructor.
>> -  CharUnits() : Quantity(0) {}
>> +  CharUnits() = default;
>>
>>/// Zero - Construct a CharUnits quantity of zero.
>>static CharUnits Zero() {
>>
>> Modified: cfe/trunk/include/clang/AST/Type.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=315194&r1=315193&r2=315194&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Type.h (original)
>> +++ cfe/trunk/include/clang/AST/Type.h Sun Oct  8 13:53:36 2017
>> @@ -162,8 +162,6 @@ public:
>>  FastMask = (1 << FastWidth) - 1
>>};
>>
>> -  Qualifiers() : Mask(0) {}
>> -
>>/// Returns the common set of qualifiers while removing them from
>>/// the given sets.
>>static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
>> {
>> @@ -539,7 +537,7 @@ private:
>>
>>// bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
>>//   |C R V|U|GCAttr|Lifetime|AddressSpace|
>> -  uint32_t Mask;
>> +  uint32_t Mask = 0;
>>
>>static const uint32_t UMask = 0x8;
>>static const uint32_t UShift = 3;
>> @@ -634,7 +632,7 @@ class QualType {
>>
>>friend class QualifierCollector;
>>  public:
>> -  QualType() {}
>> +  QualType() = default;
>>
>>QualType(const Type *Ptr, unsigned Quals)
>>  : Value(Ptr, Quals) {}
>>
>> Modified: cfe/trunk/include/clang/Basic/Sour

[PATCH] D38698: AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, kzhuravl.

https://reviews.llvm.org/D38698

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn.cl


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -421,6 +421,18 @@
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_read_exec_lo(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_LO:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_lo(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_lo();
+}
+
+// CHECK-LABEL: @test_read_exec_hi(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_HI:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_hi(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_hi();
+}
+
 // CHECK-LABEL: @test_dispatch_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
@@ -499,3 +511,5 @@
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
+// CHECK-DAG: ![[EXEC_LO]] = !{!"exec_lo"}
+// CHECK-DAG: ![[EXEC_HI]] = !{!"exec_hi"}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9103,6 +9103,15 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
+StringRef RegName = BuiltinID == AMDGPU::BI__builtin_amdgcn_read_exec_lo ?
+  "exec_lo" : "exec_hi";
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int32Ty, Int32Ty, true, RegName));
+CI->setConvergent();
+return CI;
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -121,6 +121,8 @@
 // Special builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc")
 
 
//===--===//
 // R600-NI only builtins.


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -421,6 +421,18 @@
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) #[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_read_exec_lo(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_LO:[0-9]+]]) #[[READ_EXEC_ATTRS]]
+void test_read_exec_lo(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_lo();
+}
+
+// CHECK-LABEL: @test_read_exec_hi(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_HI:[0-9]+]]) #[[READ_EXEC_ATTRS]]
+void test_read_exec_hi(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_hi();
+}
+
 // CHECK-LABEL: @test_dispatch_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
@@ -499,3 +511,5 @@
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
+// CHECK-DAG: ![[EXEC_LO]] = !{!"exec_lo"}
+// CHECK-DAG: ![[EXEC_HI]] = !{!"exec_hi"}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9103,6 +9103,15 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
+StringRef RegName = BuiltinID == AMDGPU::BI__builtin_amdgcn_read_exec_lo ?
+  "exec_lo" : "exec_hi";
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int32Ty, Int32Ty, true, RegName));
+CI->setConvergent();
+return CI;
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -121,6 +121,8 @@
 // Special builtins.
 //===--===//
 BUILTIN(__builtin_amdgcn_read_exec, "LU

[PATCH] D38700: [Sema][Crash] Correctly handle an non-dependent noexcept expr in function template

2017-10-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

It seems that all of the other templated cases are handled correctly,
however the function template case was not correctly handled.  This
patch recovers from this condition by setting the function to noexcept
after diagnosing.  Previously it simply set NoexceptExpr to null,
which caused an Assert when this was evaluated during substitution.


https://reviews.llvm.org/D38700

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/except/except.spec/p1.cpp


Index: test/CXX/except/except.spec/p1.cpp
===
--- test/CXX/except/except.spec/p1.cpp
+++ test/CXX/except/except.spec/p1.cpp
@@ -86,3 +86,12 @@
 f<0>(); // expected-note{{in instantiation of function template 
specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant 
expression}}
+  template  T f() noexcept(a++){ return {};}
+  void g(){
+f();
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -14858,10 +14858,16 @@
 return;
   }
 
-  if (!NoexceptExpr->isValueDependent())
-NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
- diag::err_noexcept_needs_constant_expression,
- /*AllowFold*/ false).get();
+  if (!NoexceptExpr->isValueDependent()) {
+ExprResult Result = VerifyIntegerConstantExpression(
+NoexceptExpr, nullptr, 
diag::err_noexcept_needs_constant_expression,
+/*AllowFold*/ false);
+if (Result.isInvalid()) {
+  ESI.Type = EST_BasicNoexcept;
+  return;
+}
+NoexceptExpr = Result.get();
+  }
   ESI.NoexceptExpr = NoexceptExpr;
 }
 return;


Index: test/CXX/except/except.spec/p1.cpp
===
--- test/CXX/except/except.spec/p1.cpp
+++ test/CXX/except/except.spec/p1.cpp
@@ -86,3 +86,12 @@
 f<0>(); // expected-note{{in instantiation of function template specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant expression}}
+  template  T f() noexcept(a++){ return {};}
+  void g(){
+f();
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -14858,10 +14858,16 @@
 return;
   }
 
-  if (!NoexceptExpr->isValueDependent())
-NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
- diag::err_noexcept_needs_constant_expression,
- /*AllowFold*/ false).get();
+  if (!NoexceptExpr->isValueDependent()) {
+ExprResult Result = VerifyIntegerConstantExpression(
+NoexceptExpr, nullptr, diag::err_noexcept_needs_constant_expression,
+/*AllowFold*/ false);
+if (Result.isInvalid()) {
+  ESI.Type = EST_BasicNoexcept;
+  return;
+}
+NoexceptExpr = Result.get();
+  }
   ESI.NoexceptExpr = NoexceptExpr;
 }
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] r315228 - Make ptx barrier work irrespective of the cl_mem_fence_flags

2017-10-09 Thread Jeroen Ketema via cfe-commits
Author: jketema
Date: Mon Oct  9 11:36:48 2017
New Revision: 315228

URL: http://llvm.org/viewvc/llvm-project?rev=315228&view=rev
Log:
Make ptx barrier work irrespective of the cl_mem_fence_flags

This generates a "bar.sync 0” instruction, which not only causes the
threads to wait, but does acts as a memory fence, as required by
OpenCL. The fence does not differentiate between local and global
memory. Unfortunately, there is no similar instruction which does
not include a memory fence. Hence, we cannot optimize the case
where neither CLK_LOCAL_MEM_FENCE nor CLK_GLOBAL_MEM_FENCE is
passed.

Modified:
libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl

Modified: libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl?rev=315228&r1=315227&r2=315228&view=diff
==
--- libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl (original)
+++ libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl Mon Oct  9 
11:36:48 2017
@@ -1,8 +1,6 @@
 #include 
 
 _CLC_DEF void barrier(cl_mem_fence_flags flags) {
-  if (flags & CLK_LOCAL_MEM_FENCE) {
-__syncthreads();
-  }
+  __syncthreads();
 }
 


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


Re: [clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Hi,

On Mon, Oct 9, 2017 at 9:58 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Mon Oct  9 09:58:16 2017
> New Revision: 315214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315214&view=rev
> Log:
> [clangd] Added a command-line arg to mirror clangd input into a file.
>
> Summary: The arg is useful for debugging and creating test cases.
>
> Reviewers: bkramer, krasimir
>
> Reviewed By: bkramer
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D37970
>
> Added:
> clang-tools-extra/trunk/test/clangd/input-mirror.test
> Modified:
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315214&r1=315213&r2=315214&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 09:58:16 
> 2017
> @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine &Messag
>Logs.flush();
>  }
>
> +void JSONOutput::mirrorInput(const Twine &Message) {
> +  if (!InputMirror)
> +return;
> +
> +  *InputMirror << Message;
> +  InputMirror->flush();
> +}
> +
>  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
>Output.log("Method ignored.\n");
>// Return that this method is unsupported.
> @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
>  continue;
>}
>
> +  Out.mirrorInput(Line);
> +  // Mirror '\n' that gets consumed by std::getline, but is not included 
> in
> +  // the resulting Line.
> +  // Note that '\r' is part of Line, so we don't need to mirror it
> +  // separately.
> +  if (!In.eof())
> +Out.mirrorInput("\n");
> +
>llvm::StringRef LineRef(Line);
>
>// We allow YAML-style comments in headers. Technically this isn't part
> @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
>if (LineRef.consume_front("Content-Length: ")) {
>  if (ContentLength != 0) {
>Out.log("Warning: Duplicate Content-Length header received. "
> -  "The previous value for this message ("
> -  + std::to_string(ContentLength)
> -  + ") was ignored.\n");
> +  "The previous value for this message (" +
> +  std::to_string(ContentLength) + ") was ignored.\n");
>  }
>
>  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
>// parser.
>std::vector JSON(ContentLength + 1, '\0');
>In.read(JSON.data(), ContentLength);
> +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
>
>// If the stream is aborted before we read ContentLength bytes, In
>// will have eofbit and failbit set.
>if (!In) {
> -Out.log("Input was aborted. Read only "
> -+ std::to_string(In.gcount())
> -+ " bytes of expected "
> -+ std::to_string(ContentLength)
> -+ ".\n");
> +Out.log("Input was aborted. Read only " + 
> std::to_string(In.gcount()) +
> +" bytes of expected " + std::to_string(ContentLength) + 
> ".\n");
>  break;
>}
>
> @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
>if (IsDone)
>  break;
>  } else {
> -  Out.log( "Warning: Missing Content-Length header, or message has zero "
> -   "length.\n" );
> +  Out.log("Warning: Missing Content-Length header, or message has zero "
> +  "length.\n");
>  }
>}
>  }
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315214&r1=315213&r2=315214&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 09:58:16 
> 2017
> @@ -24,8 +24,9 @@ namespace clangd {
>  /// them.
>  class JSONOutput : public Logger {
>  public:
> -  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
> -  : Outs(Outs), Logs(Logs) {}
> +  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
> + llvm::raw_ostream *InputMirror = nullptr)
> +  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
>
>/// Emit a JSONRPC message.
>void writeMessage(const Twine &Message);
> @@ -33,9 +34,15 @@ public:
>/// Write to the logging stream.
>void log(const Twine &Message) override;
>
> +  /// Mi

[PATCH] D38646: [MS] Raise the default value of _MSC_VER to 1910, which is in VS 2017

2017-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D38646#892246, @STL_MSFT wrote:

> FYI: 1910 was the value for VS 2017 RTM. 1911 is the value for VS 2017 15.3, 
> the first toolset update. 1912 will be the value for VS 2017 15.5, the second 
> toolset update.


Yep. The initial draft of this patch had the wrong commit message, but 
everything is fixed in the committed version.

I had 1910 installed on my machine locally, and spent this morning untangling 
that. Apparently now you have to install updates through the VS "Tools -> 
Extesions & Updates -> mumble" menu. Downloading and running the VS update 3 
installer isn't enough.


Repository:
  rL LLVM

https://reviews.llvm.org/D38646



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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple updated this revision to Diff 118247.
jkorous-apple added a comment.

Single char constants don't need to be c-strings.


https://reviews.llvm.org/D38643

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/array-type.cpp


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315231 - Testing commit access.

2017-10-09 Thread Hamza Sood via cfe-commits
Author: hamzasood
Date: Mon Oct  9 12:07:09 2017
New Revision: 315231

URL: http://llvm.org/viewvc/llvm-project?rev=315231&view=rev
Log:
Testing commit access.

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

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=315231&r1=315230&r2=315231&view=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Mon Oct  9 12:07:09 2017
@@ -28,7 +28,7 @@ Compilation::Compilation(const Driver &D
 : TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u),
   Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false),
   ContainsError(ContainsError) {
-  // The offloading host toolchain is the default tool chain.
+  // The offloading host toolchain is the default toolchain.
   OrderedOffloadingToolchains.insert(
   std::make_pair(Action::OFK_Host, &DefaultToolChain));
 }


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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/AddressSpace.hpp:388-389
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;

rnk wrote:
> ".eh_frame" is 9 characters, right? I thought mingw linkers took sections 
> with long names and moved them to an extended symbol table. Does that not 
> apply to .eh_frame?
Yes, they do, so this actually only matches `.eh_fram`. I didn't yet look at 
how to navigate the IMAGE_*_HEADERS structs to find the coresponding full long 
name.


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

Would it work to implement the win32 side of this via `SymFromAddr`?



Comment at: src/UnwindRegistersRestore.S:29
 #  +   +
+#if !defined(_WIN32)
   movl   4(%esp), %eax

Please invert the condition, and swap the if/else on this. That will make it 
more straightforward to adjust this for other platforms later.


https://reviews.llvm.org/D38679



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


[PATCH] D38522: [libc++] Support Microsoft ABI without vcruntime headers

2017-10-09 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

I spoke to @EricWF on IRC last week and got his approval to commit this without 
review if no one had gotten to it in a couple of days, so I'm going ahead with 
that.


https://reviews.llvm.org/D38522



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


[PATCH] D38522: [libc++] Support Microsoft ABI without vcruntime headers

2017-10-09 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315234: [libc++] Support Microsoft ABI without vcruntime 
headers (authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D38522?vs=117613&id=118251#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38522

Files:
  libcxx/trunk/CMakeLists.txt
  libcxx/trunk/docs/UsingLibcxx.rst
  libcxx/trunk/include/__config_site.in
  libcxx/trunk/include/exception
  libcxx/trunk/include/new
  libcxx/trunk/src/new.cpp
  libcxx/trunk/src/support/runtime/exception_msvc.ipp
  libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
  libcxx/trunk/utils/libcxx/test/config.py

Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -615,6 +615,7 @@
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
+config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
 
 if (LIBCXX_ABI_DEFINES)
   set(abi_defines)
Index: libcxx/trunk/utils/libcxx/test/config.py
===
--- libcxx/trunk/utils/libcxx/test/config.py
+++ libcxx/trunk/utils/libcxx/test/config.py
@@ -668,6 +668,9 @@
 self.config.available_features.add('libcpp-abi-version-v%s'
 % feature_macros[m])
 continue
+if m == '_LIBCPP_NO_VCRUNTIME':
+self.config.available_features.add('libcpp-no-vcruntime')
+continue
 assert m.startswith('_LIBCPP_HAS_') or m.startswith('_LIBCPP_ABI_')
 m = m.lower()[1:].replace('_', '-')
 self.config.available_features.add(m)
Index: libcxx/trunk/docs/UsingLibcxx.rst
===
--- libcxx/trunk/docs/UsingLibcxx.rst
+++ libcxx/trunk/docs/UsingLibcxx.rst
@@ -185,6 +185,26 @@
 * Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
   const callable.
 
+**_LIBCPP_NO_VCRUNTIME**:
+  Microsoft's C and C++ headers are fairly entangled, and some of their C++
+  headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets pulled
+  in from a lot of other headers and provides definitions which clash with
+  libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so
+  there's no way for libc++ to provide a compatible definition, since you can't
+  have multiple definitions).
+
+  By default, libc++ solves this problem by deferring to Microsoft's vcruntime
+  headers where needed. However, it may be undesirable to depend on vcruntime
+  headers, since they may not always be available in cross-compilation setups,
+  or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro
+  prevents libc++ from depending on vcruntime headers. Consequently, it also
+  prevents libc++ headers from being interoperable with vcruntime headers (from
+  the aforementioned clashes), so users of this macro are promising to not
+  attempt to combine libc++ headers with the problematic vcruntime headers. This
+  macro also currently prevents certain `operator new`/`operator delete`
+  replacement scenarios from working, e.g. replacing `operator new` and
+  expecting a non-replaced `operator new[]` to call the replaced `operator new`.
+
 C++17 Specific Configuration Macros
 ---
 **_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
Index: libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
===
--- libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
+++ libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
@@ -10,26 +10,32 @@
 
 #include 
 #include 
-#include  // for _CRTIMP2_PURE
 
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(_Out_ void*,
-  _In_ const void*);
+#if !defined(_CRTIMP2_PURE)
+#define _CRTIMP2_PURE __declspec(dllimport)
+#endif
+
+#if !defined(__CLRCALL_PURE_OR_CDECL)
+#define __CLRCALL_PURE_OR_CDECL __cdecl
+#endif
+
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(void*);
+_CRTIMP2_PURE v

[libcxx] r315234 - [libc++] Support Microsoft ABI without vcruntime headers

2017-10-09 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Oct  9 12:25:17 2017
New Revision: 315234

URL: http://llvm.org/viewvc/llvm-project?rev=315234&view=rev
Log:
[libc++] Support Microsoft ABI without vcruntime headers

The vcruntime headers are hairy and clash with both libc++ headers
themselves and other libraries. libc++ normally deals with the clashes
by deferring to the vcruntime headers and silencing its own definitions,
but for clients which don't want to depend on vcruntime headers, it's
desirable to support the opposite, i.e. have libc++ provide its own
definitions.

Certain operator new/delete replacement scenarios are not currently
supported in this mode, which requires some tests to be marked XFAIL.
The added documentation has more details.

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/__config_site.in
libcxx/trunk/include/exception
libcxx/trunk/include/new
libcxx/trunk/src/new.cpp
libcxx/trunk/src/support/runtime/exception_msvc.ipp
libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=315234&r1=315233&r2=315234&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Oct  9 12:25:17 2017
@@ -615,6 +615,7 @@ config_define_if(LIBCXX_HAS_PTHREAD_API
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API 
_LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY 
_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
+config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
 
 if (LIBCXX_ABI_DEFINES)
   set(abi_defines)

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=315234&r1=315233&r2=315234&view=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Mon Oct  9 12:25:17 2017
@@ -185,6 +185,26 @@ thread safety annotations.
 * Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
   const callable.
 
+**_LIBCPP_NO_VCRUNTIME**:
+  Microsoft's C and C++ headers are fairly entangled, and some of their C++
+  headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets 
pulled
+  in from a lot of other headers and provides definitions which clash with
+  libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so
+  there's no way for libc++ to provide a compatible definition, since you can't
+  have multiple definitions).
+
+  By default, libc++ solves this problem by deferring to Microsoft's vcruntime
+  headers where needed. However, it may be undesirable to depend on vcruntime
+  headers, since they may not always be available in cross-compilation setups,
+  or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro
+  prevents libc++ from depending on vcruntime headers. Consequently, it also
+  prevents libc++ headers from being interoperable with vcruntime headers (from
+  the aforementioned clashes), so users of this macro are promising to not
+  attempt to combine libc++ headers with the problematic vcruntime headers. 
This
+  macro also currently prevents certain `operator new`/`operator delete`
+  replacement scenarios from working, e.g. replacing `operator new` and
+  expecting a non-replaced `operator new[]` to call the replaced `operator 
new`.
+
 C++17 Specific Configuration Macros
 ---
 **_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:

Modified: libcxx/trunk/include/__config_site.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config_site.in?rev=315234&r1=315233&r2=315234&view=diff
==
--- libcxx/trunk/include/__config_site.in (original)
+++ libcxx/trunk/include/__config_site.in Mon Oct  9 12:25:17 2017
@@ -25,6 +25,7 @@
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
 #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
 #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+#cmakedefine _LIBCPP_NO_VCRUNTIME
 
 @_LIBCPP_ABI_DEFINES@
 

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=315234&r1=315233&r2=315234&view=diff
===

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

jroelofs wrote:
> Would it work to implement the win32 side of this via `SymFromAddr`?
Hmm, I guess that would work.



Comment at: src/UnwindRegistersRestore.S:29
 #  +   +
+#if !defined(_WIN32)
   movl   4(%esp), %eax

jroelofs wrote:
> Please invert the condition, and swap the if/else on this. That will make it 
> more straightforward to adjust this for other platforms later.
Ok, will do.


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: src/AddressSpace.hpp:388-389
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;

mstorsjo wrote:
> rnk wrote:
> > ".eh_frame" is 9 characters, right? I thought mingw linkers took sections 
> > with long names and moved them to an extended symbol table. Does that not 
> > apply to .eh_frame?
> Yes, they do, so this actually only matches `.eh_fram`. I didn't yet look at 
> how to navigate the IMAGE_*_HEADERS structs to find the coresponding full 
> long name.
Can you add a FIXME here? No need to read the long-form symbol table yet, I 
just want to document that we will need that for compatibility with ld.bfd.


https://reviews.llvm.org/D38679



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


[libclc] r315235 - Implement mem_fence on ptx

2017-10-09 Thread Jeroen Ketema via cfe-commits
Author: jketema
Date: Mon Oct  9 12:43:04 2017
New Revision: 315235

URL: http://llvm.org/viewvc/llvm-project?rev=315235&view=rev
Log:
Implement mem_fence on ptx

PTX does not differentiate between read and write fences. Hence, these a
lowered to a mem_fence call. The mem_fence function compiles to the
“member.cta” instruction, which commits all outstanding reads and writes
of a thread such that these become visible to all other threads in the same
CTA (i.e., work-group). The instruction does not differentiate between
global and local memory. Hence, the flags parameter is ignored, except
for deciding whether a “member.cta” instruction should be issued at all.

Reviewed-by: Jan Vesely 

Added:
libclc/trunk/ptx-nvidiacl/lib/mem_fence/
libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl
Modified:
libclc/trunk/ptx-nvidiacl/lib/SOURCES

Modified: libclc/trunk/ptx-nvidiacl/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx-nvidiacl/lib/SOURCES?rev=315235&r1=315234&r2=315235&view=diff
==
--- libclc/trunk/ptx-nvidiacl/lib/SOURCES (original)
+++ libclc/trunk/ptx-nvidiacl/lib/SOURCES Mon Oct  9 12:43:04 2017
@@ -1,3 +1,4 @@
+mem_fence/fence.cl
 synchronization/barrier.cl
 workitem/get_global_id.cl
 workitem/get_group_id.cl

Added: libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl?rev=315235&view=auto
==
--- libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl (added)
+++ libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl Mon Oct  9 12:43:04 2017
@@ -0,0 +1,15 @@
+#include 
+
+_CLC_DEF void mem_fence(cl_mem_fence_flags flags) {
+   if (flags & (CLK_GLOBAL_MEM_FENCE | CLK_LOCAL_MEM_FENCE))
+ __nvvm_membar_cta();
+}
+
+// We do not have separate mechanism for read and write fences.
+_CLC_DEF void read_mem_fence(cl_mem_fence_flags flags) {
+  mem_fence(flags);
+}
+
+_CLC_DEF void write_mem_fence(cl_mem_fence_flags flags) {
+  mem_fence(flags);
+}


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


r315236 - PR13575: Fix USR mangling for fixed-size arrays

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 12:51:33 2017
New Revision: 315236

URL: http://llvm.org/viewvc/llvm-project?rev=315236&view=rev
Log:
PR13575: Fix USR mangling for fixed-size arrays

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

Added:
cfe/trunk/test/Index/USR/
cfe/trunk/test/Index/USR/array-type.cpp
Modified:
cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=315236&r1=315235&r2=315236&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  9 12:51:33 2017
@@ -816,6 +816,25 @@ void USRGenerator::VisitType(QualType T)
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';

Added: cfe/trunk/test/Index/USR/array-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/array-type.cpp?rev=315236&view=auto
==
--- cfe/trunk/test/Index/USR/array-type.cpp (added)
+++ cfe/trunk/test/Index/USR/array-type.cpp Mon Oct  9 12:51:33 2017
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);


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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315236: PR13575: Fix USR mangling for fixed-size arrays 
(authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38643?vs=118247&id=118257#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38643

Files:
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/test/Index/USR/array-type.cpp


Index: cfe/trunk/test/Index/USR/array-type.cpp
===
--- cfe/trunk/test/Index/USR/array-type.cpp
+++ cfe/trunk/test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';


Index: cfe/trunk/test/Index/USR/array-type.cpp
===
--- cfe/trunk/test/Index/USR/array-type.cpp
+++ cfe/trunk/test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun, javed.absar.

Fixes https://bugs.llvm.org/show_bug.cgi?id=30565

@dcoughlin Any advice on how to handle different stdlib implementations?
Can we conjure a separate symbol instead of relying on a particular struct 
layout?
For now this implementation will simply not go inside a differently implemented 
`call_once`.


https://reviews.llvm.org/D38702

Files:
  lib/Analysis/BodyFarm.cpp
  test/Analysis/call_once.cpp


Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -362,6 +362,12 @@
 /* GetNonReferenceType=*/true);
 
   CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (FlagCXXDecl == nullptr) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
 
   // Note: here we are assuming libc++ implementation of call_once,
   // which has a struct with a field `__state_`.


Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -362,6 +362,12 @@
 /* GetNonReferenceType=*/true);
 
   CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (FlagCXXDecl == nullptr) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
 
   // Note: here we are assuming libc++ implementation of call_once,
   // which has a struct with a field `__state_`.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

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

Did you link the correct bug in the description? The one you linked was closed 
long ago.


https://reviews.llvm.org/D38702



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Ooops, updated to https://bugs.llvm.org/show_bug.cgi?id=34869


https://reviews.llvm.org/D38702



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


[PATCH] D38698: AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D38698



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


[PATCH] D38698: AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r315238


https://reviews.llvm.org/D38698



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


r315238 - AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Oct  9 13:06:37 2017
New Revision: 315238

URL: http://llvm.org/viewvc/llvm-project?rev=315238&view=rev
Log:
AMDGPU: Add read_exec_lo/hi builtins

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=315238&r1=315237&r2=315238&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon Oct  9 13:06:37 2017
@@ -121,6 +121,8 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h,
 // Special builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc")
 
 
//===--===//
 // R600-NI only builtins.

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=315238&r1=315237&r2=315238&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct  9 13:06:37 2017
@@ -9103,6 +9103,15 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
+StringRef RegName = BuiltinID == AMDGPU::BI__builtin_amdgcn_read_exec_lo ?
+  "exec_lo" : "exec_hi";
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int32Ty, Int32Ty, true, RegName));
+CI->setConvergent();
+return CI;
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=315238&r1=315237&r2=315238&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Mon Oct  9 13:06:37 2017
@@ -421,6 +421,18 @@ void test_read_exec(global ulong* out) {
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_read_exec_lo(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_LO:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_lo(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_lo();
+}
+
+// CHECK-LABEL: @test_read_exec_hi(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_HI:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_hi(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_hi();
+}
+
 // CHECK-LABEL: @test_dispatch_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
@@ -499,3 +511,5 @@ void test_s_getpc(global ulong* out)
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
+// CHECK-DAG: ![[EXEC_LO]] = !{!"exec_lo"}
+// CHECK-DAG: ![[EXEC_HI]] = !{!"exec_hi"}


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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-10-09 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 118261.
hamzasood added a comment.

- Updated lambda mangling to include explicit template parameters
- Allow explicit template parameter lists on lambdas pre-c++2a as an extension.
- Improved the somewhat fragile template depth handling.
- Reformatted some asserts.

Could you expand on your first point a bit more? Do you have an example that 
shows the issue?


https://reviews.llvm.org/D36527

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclTemplate.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp
  test/PCH/cxx11-lambdas.mm
  test/PCH/cxx1y-lambdas.mm
  test/PCH/cxx2a-template-lambdas.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  unittests/AST/StmtPrinterTest.cpp
  unittests/Tooling/RecursiveASTVisitorTest.cpp
  unittests/Tooling/TestVisitor.h
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -823,7 +823,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2";>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: unittests/Tooling/TestVisitor.h
===
--- unittests/Tooling/TestVisitor.h
+++ unittests/Tooling/TestVisitor.h
@@ -44,6 +44,8 @@
 Lang_CXX98,
 Lang_CXX11,
 Lang_CXX14,
+Lang_CXX17,
+Lang_CXX2a,
 Lang_OBJC,
 Lang_OBJCXX11,
 Lang_CXX = Lang_CXX98
@@ -60,6 +62,8 @@
   case Lang_CXX98: Args.push_back("-std=c++98"); break;
   case Lang_CXX11: Args.push_back("-std=c++11"); break;
   case Lang_CXX14: Args.push_back("-std=c++14"); break;
+  case Lang_CXX17: Args.push_back("-std=c++17"); break;
+  case Lang_CXX2a: Args.push_back("-std=c++2a"); break;
   case Lang_OBJC:
 Args.push_back("-ObjC");
 Args.push_back("-fobjc-runtime=macosx-10.12.0");
Index: unittests/Tooling/RecursiveASTVisitorTest.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ unittests/Tooling/RecursiveASTVisitorTest.cpp
@@ -79,6 +79,41 @@
   LambdaDefaultCaptureVisitor::Lang_CXX11));
 }
 
+// Matches (optional) explicit template parameters.
+class LambdaTemplateParametersVisitor
+  : public ExpectedLocationVisitor {
+public:
+  bool shouldVisitImplicitCode() const { return false; }
+
+  bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+  bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+  bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, VisitsLambdaExplicitTemplateParameters) {
+  LambdaTemplateParametersVisitor Visitor;
+  Visitor.ExpectMatch("T",  2, 15);
+  Visitor.ExpectMatch("I",  2, 24);
+  Visitor.ExpectMatch("TT", 2, 31);
+  EXPECT_TRUE(Visitor.runOver(
+  "void f() { \n"
+  "  auto l = [] class TT>(auto p) { }; \n"
+  "}",
+  LambdaTemplateParametersVisitor::Lang_CXX2a));
+}
+
 // Checks for lambda classes that are not marked as implicitly-generated.
 // (There should be none.)
 class ClassVisitor : public ExpectedLocationVisitor {
Index: unittests/AST/StmtPrinterTest.cpp
===
--- unittests/AST/StmtPrinterTest.cpp
+++ unittests/AST/StmtPrinterTest.cpp
@@ -67,9 +67,8 @@
 
 template 
 ::testing::AssertionResult
-PrintedStmtMatches(StringRef Code, const std::vector &Args,
-   const T &NodeMatch, StringRef ExpectedPrinted) {
-
+PrintedStmtMatchesInternal(StringRef Code, const std::vector &Args,
+   const T &NodeMatch, StringRef ExpectedPrinted) {
   PrintMatch Printer;
   MatchFinder Finder;
   Finder.addMatcher(NodeMatch, &Printer);
@@ -97,65 +96,52 @@
   return ::testing::AssertionSuccess();
 }
 
+enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX2a };
+
+DeclarationMatcher FunctionBodyMatcher(StringRef ContainingFunction) {
+  return functionDecl(hasName(ContainingFunction),
+  

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

mstorsjo wrote:
> jroelofs wrote:
> > Would it work to implement the win32 side of this via `SymFromAddr`?
> Hmm, I guess that would work.
... actually, I'm not sure how useful it is - it requires initializing the 
symbol handler with `SymInitialize` and point to a path to find the symbols. 
Plus that the symbol handler is single threaded and any calls to that would 
need to be guarded with a global mutex. So I think I'd defer that for now at 
least.


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 118263.
mstorsjo added a comment.

Added a fixme comment about the truncated section name, flipped the ifdef in 
the assembly source. Didn't implement findFunctionName.


https://reviews.llvm.org/D38679

Files:
  docs/index.rst
  src/AddressSpace.hpp
  src/UnwindRegistersRestore.S
  src/assembly.h
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -37,6 +37,8 @@
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
+#elif defined(_WIN32)
+  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/assembly.h
===
--- src/assembly.h
+++ src/assembly.h
@@ -26,6 +26,14 @@
 
 #if defined(__APPLE__)
 #define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+// In the COFF object file format, there's no attributes for a global,
+// non-static symbol to make it somehow hidden. So on windows, we don't
+// want to set this at all. To avoid conditionals in
+// DEFINE_LIBUNWIND_PRIVATE_FUNCTION below, make it .globl (which it already
+// is, defined in the same DEFINE_LIBUNWIND_PRIVATE_FUNCTION macro; the
+// duplicate .globl directives are harmless).
+#define HIDDEN_DIRECTIVE .globl
 #else
 #define HIDDEN_DIRECTIVE .hidden
 #endif
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -18,6 +18,10 @@
 #
 # void libunwind::Registers_x86::jumpto()
 #
+#if defined(_WIN32)
+# On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#else
 # On entry:
 #  +   +
 #  +---+
@@ -27,6 +31,7 @@
 #  +---+   <-- SP
 #  +   +
   movl   4(%esp), %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,43 @@
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), &needed))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)&pinh->FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+// FIXME: This section name actually is truncated, ideally we
+// should locate and check the full long name instead.
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +520,7 @@
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr,

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

mstorsjo wrote:
> mstorsjo wrote:
> > jroelofs wrote:
> > > Would it work to implement the win32 side of this via `SymFromAddr`?
> > Hmm, I guess that would work.
> ... actually, I'm not sure how useful it is - it requires initializing the 
> symbol handler with `SymInitialize` and point to a path to find the symbols. 
> Plus that the symbol handler is single threaded and any calls to that would 
> need to be guarded with a global mutex. So I think I'd defer that for now at 
> least.
alright, fine with me.


https://reviews.llvm.org/D38679



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


r315241 - PR13575: Fix test

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 13:17:28 2017
New Revision: 315241

URL: http://llvm.org/viewvc/llvm-project?rev=315241&view=rev
Log:
PR13575: Fix test

Ignore OS-specific mangled name.

Modified:
cfe/trunk/test/Index/USR/array-type.cpp

Modified: cfe/trunk/test/Index/USR/array-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/array-type.cpp?rev=315241&r1=315240&r2=315241&view=diff
==
--- cfe/trunk/test/Index/USR/array-type.cpp (original)
+++ cfe/trunk/test/Index/USR/array-type.cpp Mon Oct  9 13:17:28 2017
@@ -3,9 +3,9 @@
 // Function template specializations differing in array type parameter should 
have unique USRs.
 
 template void foo(buffer);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C#
 template<> void foo(char[16]);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C#
 template<> void foo(char[32]);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C#
 template<> void foo(char[64]);


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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: docs/index.rst:53
 NetBSD   x86_64   Clang, GCC   DWARF CFI
+Windows  i386 ClangDWARF CFI
 Any  i386, x86_64, ARMClangSjLj

FWIW, for this to actually work correct which this docs change claims, this 
also depends on D38680.


https://reviews.llvm.org/D38679



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


[clang-tools-extra] r315242 - Revert r315214 since diff -Z isn't portable, this is breaking:

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Oct  9 13:22:05 2017
New Revision: 315242

URL: http://llvm.org/viewvc/llvm-project?rev=315242&view=rev
Log:
Revert r315214 since diff -Z isn't portable, this is breaking:

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA


Removed:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315242&r1=315241&r2=315242&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 13:22:05 
2017
@@ -37,14 +37,6 @@ void JSONOutput::log(const Twine &Messag
   Logs.flush();
 }
 
-void JSONOutput::mirrorInput(const Twine &Message) {
-  if (!InputMirror)
-return;
-
-  *InputMirror << Message;
-  InputMirror->flush();
-}
-
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -155,14 +147,6 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
-  Out.mirrorInput(Line);
-  // Mirror '\n' that gets consumed by std::getline, but is not included in
-  // the resulting Line.
-  // Note that '\r' is part of Line, so we don't need to mirror it
-  // separately.
-  if (!In.eof())
-Out.mirrorInput("\n");
-
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -179,8 +163,9 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message (" +
-  std::to_string(ContentLength) + ") was ignored.\n");
+  "The previous value for this message ("
+  + std::to_string(ContentLength)
+  + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -200,13 +185,15 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
-  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
-" bytes of expected " + std::to_string(ContentLength) + ".\n");
+Out.log("Input was aborted. Read only "
++ std::to_string(In.gcount())
++ " bytes of expected "
++ std::to_string(ContentLength)
++ ".\n");
 break;
   }
 
@@ -222,8 +209,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log("Warning: Missing Content-Length header, or message has zero "
-  "length.\n");
+  Out.log( "Warning: Missing Content-Length header, or message has zero "
+   "length.\n" );
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315242&r1=315241&r2=315242&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 13:22:05 2017
@@ -24,9 +24,8 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
- llvm::raw_ostream *InputMirror = nullptr)
-  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
+  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
+  : Outs(Outs), Logs(Logs) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine &Message);
@@ -34,15 +33,9 @@ public:
   /// Write to the logging stream.
   void log(const Twine &Message) override;
 
-  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
-  /// null.
-  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
-  void mirrorInput(const Twine &Message);
-
 private:
   llvm::raw_ostream &Outs;
   llvm::raw_ostream &Logs;
-  llvm::raw_ostream *InputMirror;
 
   std::mutex StreamMutex;
 };

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#889842, @smeenai wrote:

> Does dlopen cause issues even with `RTLD_GLOBAL`?


From my testing, yes. Regardless, `RTLD_LOCAL` is how JNI libraries get loaded 
when `System.loadLibrary` is used, so the `strcmp` fallback is a requirement 
for that use case.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs resigned from this revision.
jroelofs added a comment.

I'm not sure I'm the right person to review this.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added a subscriber: mehdi_amini.

This makes sure that the FDE cache is thread safe.

This requires building with `_WIN32_WINNT >= 0x0600`.

The alternative would be to skip the FDE cache altogether if building without 
threads.


https://reviews.llvm.org/D38704

Files:
  src/UnwindCursor.hpp


Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -17,7 +17,11 @@
 #include 
 #include 
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 
+  #else
+#include 
+  #endif
 #endif
 #include 
 
@@ -36,6 +40,34 @@
 #include "Registers.hpp"
 #include "Unwind-EHABI.h"
 
+#if !defined(_LIBUNWIND_HAS_NO_THREADS) && defined(_WIN32)
+#define pthread_rwlock_t SRWLOCK
+#define PTHREAD_RWLOCK_INITIALIZER SRWLOCK_INIT
+// As long as these functions are only ever used with one lock,
+// we can get away with a global flag to decide which kind of
+// unlock to do.
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);
+  lockedForWrite = false;
+  return 0;
+}
+static int pthread_rwlock_wrlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockExclusive(lock);
+  lockedForWrite = true;
+  return 0;
+}
+static int pthread_rwlock_unlock(pthread_rwlock_t *lock) {
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {
+ReleaseSRWLockShared(lock);
+  }
+  return 0;
+}
+#endif
+
 namespace libunwind {
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)


Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -17,7 +17,11 @@
 #include 
 #include 
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 
+  #else
+#include 
+  #endif
 #endif
 #include 
 
@@ -36,6 +40,34 @@
 #include "Registers.hpp"
 #include "Unwind-EHABI.h"
 
+#if !defined(_LIBUNWIND_HAS_NO_THREADS) && defined(_WIN32)
+#define pthread_rwlock_t SRWLOCK
+#define PTHREAD_RWLOCK_INITIALIZER SRWLOCK_INIT
+// As long as these functions are only ever used with one lock,
+// we can get away with a global flag to decide which kind of
+// unlock to do.
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);
+  lockedForWrite = false;
+  return 0;
+}
+static int pthread_rwlock_wrlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockExclusive(lock);
+  lockedForWrite = true;
+  return 0;
+}
+static int pthread_rwlock_unlock(pthread_rwlock_t *lock) {
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {
+ReleaseSRWLockShared(lock);
+  }
+  return 0;
+}
+#endif
+
 namespace libunwind {
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.

https://reviews.llvm.org/D38707

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/func-type.cpp


Index: test/Index/USR/func-type.cpp
===
--- /dev/null
+++ test/Index/USR/func-type.cpp
@@ -0,0 +1,13 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures 
should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto &I : FT->param_types())
+  Out << '(';
+  for (const auto &I : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;


Index: test/Index/USR/func-type.cpp
===
--- /dev/null
+++ test/Index/USR/func-type.cpp
@@ -0,0 +1,13 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto &I : FT->param_types())
+  Out << '(';
+  for (const auto &I : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38704#892479, @zturner wrote:

> I'm a little nervous about re-inventing a poor man's version of a reader 
> writer lock.  Can we not just copy LLVM's?


I guess I could have a look to see how much extra either kitchen sink it would 
bring. Since it almost mapped 1:1 to the windows functions, I thought it 
wouldn't end up too large - unfortunately the return values and unlock 
functions made it a bit harder though.




Comment at: src/UnwindCursor.hpp:20
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 

zturner wrote:
> Maybe you want to check `_MSC_VER` here?  I think MinGW compilers will have 
> `pthread` support.
MinGW compilers can have optional pthread support (it's not a feature of the 
compiler itself but an extra library that one can choose to build), but not 
everybody wants to use it and at least I wouldn't want to use it as mandatory 
dependency for any C++ support based on libunwind.



Comment at: src/UnwindCursor.hpp:50
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);

zturner wrote:
> This doesn't seem like what you want.  a global `static` function / variable 
> in a header file is going to be duplicated in every translation unit.  i.e. 
> two translation units will have different copies of `lockedForWrite`.  Same 
> goes for the rest of the functions.
Oh, right - I would need to make it match the static class member `_lock` 
instead.



Comment at: src/UnwindCursor.hpp:61-64
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {

zturner wrote:
> Doesn't `lockedForWrite` need to be atomic?  If it is not atomic, there is no 
> guarantee that thread 2 will see the results of thread 1's modifications with 
> any kind of reasonable order.
I don't think it needs to be atomic, although the `rdlock` function perhaps 
shouldn't touch it at all. It only ever gets set to true once we have an 
exclusive lock, and in those cases gets set back to false before the exclusive 
lock gets released. So without touching it in the `rdlock` function, we only 
ever write to it while holding the exclusive write lock.


https://reviews.llvm.org/D38704



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


[PATCH] D38708: [AST] Flag the typo-corrected nodes for better tooling

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch adds a new boolean field to the `DeclRefExpr`, `MemberExpr`, 
`CXXCtorInitializer`, `ObjCIvarRefExpr`, `ObjCPropertyRefExpr` nodes which is 
set to true when these nodes have been produced during typo-correction.

This is useful for Clang-based tooling as it can distinguish between true 
references and the typo-corrected references. The initial tooling support uses 
the flag to prevent token annotation for typo-corrected references and to 
prevent finding typo-corrected references during single TU reference search.


Repository:
  rL LLVM

https://reviews.llvm.org/D38708

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/Stmt.h
  lib/AST/DeclCXX.cpp
  lib/AST/Expr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Index/typo-annotate-tokens.mm
  test/Index/typo-file-refs.cpp
  test/Index/typo-file-refs.m
  tools/libclang/CIndex.cpp
  tools/libclang/CIndexHigh.cpp
  tools/libclang/CursorVisitor.h

Index: tools/libclang/CursorVisitor.h
===
--- tools/libclang/CursorVisitor.h
+++ tools/libclang/CursorVisitor.h
@@ -96,6 +96,9 @@
   /// record entries.
   bool VisitDeclsOnly;
 
+  /// \brief Whether we should visit typo-corrected references.
+  bool VisitTypoCorrected = true;
+
   // FIXME: Eventually remove.  This part of a hack to support proper
   // iteration over all Decls contained lexically within an ObjC container.
   DeclContext::decl_iterator *DI_current;
@@ -187,6 +190,8 @@
 return VisitIncludedEntities;
   }
 
+  void setVisitTypoCorrected(bool V = true) { VisitTypoCorrected = V; }
+
   template
   bool visitPreprocessedEntities(InputIterator First, InputIterator Last,
  PreprocessingRecord &PPRec,
Index: tools/libclang/CIndexHigh.cpp
===
--- tools/libclang/CIndexHigh.cpp
+++ tools/libclang/CIndexHigh.cpp
@@ -169,7 +169,9 @@
 if (clang_isExpression(cursor.kind)) {
   if (cursor.kind == CXCursor_DeclRefExpr ||
   cursor.kind == CXCursor_MemberRefExpr) {
-// continue..
+// Avoid visiting typo-corrected references.
+if (cxcursor::getCursorExpr(cursor)->isTypoCorrected())
+  return CXChildVisit_Continue;
 
   } else if (cursor.kind == CXCursor_ObjCMessageExpr &&
  cxcursor::getSelectorIdentifierIndex(cursor) != -1) {
@@ -228,8 +230,11 @@
   Visitor);
 
   if (const DeclContext *DC = Dcl->getParentFunctionOrMethod()) {
-return clang_visitChildren(cxcursor::MakeCXCursor(cast(DC), TU),
-   findFileIdRefVisit, &data);
+CursorVisitor CursorVis(TU, findFileIdRefVisit, &data,
+/*VisitPreprocessorLast=*/false);
+// Don't include the typo-corrected references.
+CursorVis.setVisitTypoCorrected(false);
+return CursorVis.VisitChildren(cxcursor::MakeCXCursor(cast(DC), TU));
   }
 
   SourceRange Range(SM.getLocForStartOfFile(FID), SM.getLocForEndOfFile(FID));
@@ -239,6 +244,8 @@
   /*VisitIncludedEntities=*/false,
   Range,
   /*VisitDeclsOnly=*/true);
+  // Don't include the typo-corrected references.
+  FindIdRefsVisitor.setVisitTypoCorrected(false);
   return FindIdRefsVisitor.visitFileRegion();
 }
 
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -847,13 +847,15 @@
   // Visit the initializers in source order
   for (unsigned I = 0, N = WrittenInits.size(); I != N; ++I) {
 CXXCtorInitializer *Init = WrittenInits[I];
-if (Init->isAnyMemberInitializer()) {
-  if (Visit(MakeCursorMemberRef(Init->getAnyMember(),
-Init->getMemberLocation(), TU)))
-return true;
-} else if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo()) {
-  if (Visit(TInfo->getTypeLoc()))
-return true;
+if (VisitTypoCorrected | !Init->isTypoCorrected()) {
+  if (Init->isAnyMemberInitializer()) {
+if (Visit(MakeCursorMemberRef(Init->getAnyMember(),
+  Init->getMemberLocation(), TU)))
+  return true;
+  } else if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo()) {
+if (Visit(TInfo->getTypeLoc()))

[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38680#892487, @compnerd wrote:

> I think that the problem is that we are using the generic register name, but 
> we need to use the target specific register name.  On x86, EIP/ESP are 
> swapped.


You mean EBP/ESP? I think the code here does the right thing, with `UNW_REG_SP` 
always mapping to the actual ESP.

> We should also have a test case for this.  I had reduced this down to a 
> simpler test case of:
> 
>   void f(int,int,int,int,int,int,int,int,int);
>
>   int main() {
> try {
>   f(0,1,2,3,4,5,6,7,8);
> } catch (int) {
>   return 0;
> }
> return 1;
>   }
>

Oh, great if you can reproduce the issue with that! Feel free to try to dig 
into the issue and figure out a better fix then.


https://reviews.llvm.org/D38680



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


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Index/USRGeneration.cpp:757
   VisitType(FT->getReturnType());
-  for (const auto &I : FT->param_types())
+  Out << '(';
+  for (const auto &I : FT->param_types()) {

I believe you can drop the '(' and ')'. The '#' should be enough to prevent the 
USR collision.


https://reviews.llvm.org/D38707



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

> @dcoughlin Any advice on how to handle different stdlib implementations?
>  Can we conjure a separate symbol instead of relying on a particular struct 
> layout?
>  For now this implementation will simply not go inside a differently 
> implemented call_once.

I think that for now your solution is the best to avoid the crashes. Let's see 
what Alexander has to say about the standard library causing the crashes. 
Ideally, we don't want to fall down too hard on libstdc++.

If we really need to handle a variety of standard libraries (or versions of 
standard libraries) we'll probably want to to treat `std::call_once` more 
abstractly and write a checker that models its behavior instead of body farming 
it.




Comment at: lib/Analysis/BodyFarm.cpp:365
   CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (FlagCXXDecl == nullptr) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "

LLVM style is to write this null check as `if (!FlagCXXDecl)`.



Comment at: lib/Analysis/BodyFarm.cpp:369
+   << "Ignoring the call.\n");
+return nullptr;
+  }

This return will leak the allocated AST nodes (as will the return for 
`__state__` below). Can you hoist the validation checks to above the AST 
creation?


https://reviews.llvm.org/D38702



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

I'm also much out of my depth here, but I'm skeptical. You're changing the 
comments in the code from essentially saying "This workaround helps people with 
broken code" to essentially saying "This indispensable functionality helps 
people like me who use dlopen()."  Are you 100% sure that you're not just a 
person with broken code?

In other words, what did this guy from 2013 get wrong? -- or, if "he got 
nothing wrong", then why can't you just follow his advice to eliminate the 
duplicate typeinfos from your code? 
http://www.russellmcc.com/posts/2013-08-03-rtti.html


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


  1   2   >