Re: r323998 - PR36157: When injecting an implicit function declaration in C89, find the right

2018-02-14 Thread Hans Wennborg via cfe-commits
Merged to 6.0 in r325104 as suggested in PR36368.

On Thu, Feb 1, 2018 at 9:01 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Feb  1 12:01:49 2018
> New Revision: 323998
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323998&view=rev
> Log:
> PR36157: When injecting an implicit function declaration in C89, find the 
> right
> DeclContext rather than injecting it wherever we happen to be.
>
> This avoids creating functions whose DeclContext is a struct or similar.
>
> Added:
> cfe/trunk/test/Sema/cxx-as-c.c
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Sema/bitfield.c
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=323998&r1=323997&r2=323998&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Feb  1 12:01:49 2018
> @@ -12910,10 +12910,20 @@ void Sema::ActOnFinishDelayedAttribute(S
>  /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
>  NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
>IdentifierInfo &II, Scope *S) {
> +  // Find the scope in which the identifier is injected and the corresponding
> +  // DeclContext.
> +  // FIXME: C89 does not say what happens if there is no enclosing block 
> scope.
> +  // In that case, we inject the declaration into the translation unit scope
> +  // instead.
>Scope *BlockScope = S;
>while (!BlockScope->isCompoundStmtScope() && BlockScope->getParent())
>  BlockScope = BlockScope->getParent();
>
> +  Scope *ContextScope = BlockScope;
> +  while (!ContextScope->getEntity())
> +ContextScope = ContextScope->getParent();
> +  ContextRAII SavedContext(*this, ContextScope->getEntity());
> +
>// Before we produce a declaration for an implicitly defined
>// function, see whether there was a locally-scoped declaration of
>// this name as a function or variable. If so, use that
>
> Modified: cfe/trunk/test/Sema/bitfield.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/bitfield.c?rev=323998&r1=323997&r2=323998&view=diff
> ==
> --- cfe/trunk/test/Sema/bitfield.c (original)
> +++ cfe/trunk/test/Sema/bitfield.c Thu Feb  1 12:01:49 2018
> @@ -82,3 +82,7 @@ typedef __typeof__(+(t5.n--)) Unsigned;
>  struct Test6 {
>: 0.0; // expected-error{{type name requires a specifier or qualifier}}
>  };
> +
> +struct PR36157 {
> +  int n : 1 ? 1 : implicitly_declare_function(); // expected-warning 
> {{invalid in C99}}
> +};
>
> Added: cfe/trunk/test/Sema/cxx-as-c.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/cxx-as-c.c?rev=323998&view=auto
> ==
> --- cfe/trunk/test/Sema/cxx-as-c.c (added)
> +++ cfe/trunk/test/Sema/cxx-as-c.c Thu Feb  1 12:01:49 2018
> @@ -0,0 +1,9 @@
> +// RUN: %clang_cc1 %s -verify
> +
> +// PR36157
> +struct Foo {
> +  Foo(int n) : n_(n) {} // expected-error 1+{{}} expected-warning 1+{{}}
> +private:
> +  int n;
> +};
> +int main() { Foo f; } // expected-error 1+{{}}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread David CARLIER via Phabricator via cfe-commits
devnexen created this revision.
devnexen added reviewers: vitalybuka, krytarowski.
devnexen created this object with visibility "All Users".
Herald added subscribers: cfe-commits, dberris, emaste.

Similarly to the GNU driver version, adding proper compile and linker flags.


Repository:
  rC Clang

https://reviews.llvm.org/D43279

Files:
  FreeBSD.cpp


Index: FreeBSD.cpp
===
--- FreeBSD.cpp
+++ FreeBSD.cpp
@@ -117,6 +117,30 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain &TC, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+} 
+
 void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -235,6 +259,7 @@
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -249,6 +274,8 @@
 }
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+if (NeedsXRayDeps)
+  linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
 // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
 // the default system libraries. Just mimic this for now.
 if (Args.hasArg(options::OPT_pg))


Index: FreeBSD.cpp
===
--- FreeBSD.cpp
+++ FreeBSD.cpp
@@ -117,6 +117,30 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain &TC, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+} 
+
 void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -235,6 +259,7 @@
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -249,6 +274,8 @@
 }
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+if (NeedsXRayDeps)
+  linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
 // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
 // the default system libraries. Just mimic this for now.
 if (Args.hasArg(options::OPT_pg))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

Counterpart of the compiler-rt work here https://reviews.llvm.org/D43278


Repository:
  rC Clang

https://reviews.llvm.org/D43279



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


[PATCH] D43227: [clangd] Make functions of ClangdServer callback-based

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D43227#1006584, @sammccall wrote:

> I wonder whether we want to introduce `using Callback = 
> UniqueFunction` for readability at some point...


I agree that's a good idea, will come up with a CL doing that.




Comment at: clangd/ClangdServer.cpp:209
+  auto Action = [Contents, Pos, TaggedFS,
+ PCHs](Path File, decltype(Callback) Callback,
+   llvm::Expected IP) {

sammccall wrote:
> ioeric wrote:
> > ilya-biryukov wrote:
> > > ioeric wrote:
> > > > nit: I'd probably use a different name than `Callback` for this 
> > > > parameter for clarity.
> > > I actually think we should keep it this way. It's a bit tricky to grasp, 
> > > but it has two important advantages:
> > >   - Makes referencing `Callback` from outer scope impossible
> > >   - saves us from coming up with names for that superficial variable, 
> > > i.e. should it be called `InnerCallback`, `Callback2`, `C` or something 
> > > else?
> > > 
> > > Is it that too confusing or do you feel we can keep it?
> > > Makes referencing Callback from outer scope impossible. 
> > For lambdas, I think we should rely on captures for this instead of the 
> > parameter names.
> > >saves us from coming up with names for that superficial variable, i.e. 
> > >should it be called InnerCallback, Callback2, C or something else?
> > I thought this is a common practice with llvm coding style :P I would vote 
> > for `C` :) 
> > 
> > > Is it that too confusing or do you feel we can keep it?
> > It is a bit confusing when I first looked at it, but nothing is *too* 
> > confusing as long as the code is correct ;) I just think it would make the 
> > code easier to read.
> I agree with you both :-)
> Conceptually, this *is* a capture - BindWithForward simulates move-capture 
> that C++11 doesn't have native syntax for. So the same name seems appropriate 
> to me - you want shadowing  for the same reasons you want captures to shadow.
I'll leave as is in this review, we have other callsites, doing the same thing, 
that we don't touch here. If we decide to change it, we should change all of 
them in one go.
I'm not opposed to the change, but like the current style a bit more.



Comment at: unittests/clangd/SyncAPI.cpp:69
+  llvm::Expected> Result = Tagged();
+  (void)(bool)Result; // Expected has to be checked.
+  Server.signatureHelp(File, Pos, capture(Result), OverridenContents);

sammccall wrote:
> ioeric wrote:
> > ilya-biryukov wrote:
> > > ioeric wrote:
> > > > I'd expect this to be checked by callers. Would `return 
> > > > std::move(Result);` work?
> > > The reason why we need it is because `capture(Result)` writes return 
> > > value of the callback to the `Result` variable. But we have to first 
> > > check the default-constructed value that was there **before** calling 
> > > `Server.signatureHelp`
> > I think we should probably fix the behavior of `capture` since this changes 
> > the behavior of `llvm::Expected` in user code - the check is there to make 
> > sure users always check the status. But here we always do this for users.
> +1
> 
> I suggested `capture(T&)` was the right API because I thought it'd be used 
> directly by test code (but we wrap it here) and because I thought T would be 
> default-constructible without problems (but it's not).
> 
> I'd suggest changing to `capture(Optional&)` instead, so the caller can 
> just create an empty optional. That makes the callsites here slightly less 
> obscure.
The users still have to check the returned value. We only check the 
**default-constructed** value. After `capture()` runs `Result` is reassigned 
and now has to be checked again (and this should be done by the users).
Replaced with `capture(Optional&)` to make it absolutely clear we're doing 
the right thing there.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43227



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


[PATCH] D43227: [clangd] Make functions of ClangdServer callback-based

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 134169.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Use llvm::Optional<> in capture() helper to avoid confusion with 
llvm::Expected.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43227

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -10,6 +10,7 @@
 #include "ClangdUnit.h"
 #include "Compiler.h"
 #include "Matchers.h"
+#include "SyncAPI.h"
 #include "TestFS.h"
 #include "XRefs.h"
 #include "clang/Frontend/CompilerInvocation.h"
@@ -249,7 +250,8 @@
   FS.Files[FooCpp] = "";
 
   Server.addDocument(FooCpp, SourceAnnotations.code());
-  auto Locations = Server.findDefinitions(FooCpp, SourceAnnotations.point());
+  auto Locations =
+  runFindDefinitions(Server, FooCpp, SourceAnnotations.point());
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
 
   EXPECT_THAT(Locations->Value,
Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -22,6 +22,22 @@
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
 clangd::CodeCompleteOptions Opts,
 llvm::Optional OverridenContents = llvm::None);
+
+llvm::Expected>
+runSignatureHelp(ClangdServer &Server, PathRef File, Position Pos,
+ llvm::Optional OverridenContents = llvm::None);
+
+llvm::Expected>>
+runFindDefinitions(ClangdServer &Server, PathRef File, Position Pos);
+
+llvm::Expected>>
+runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
+
+llvm::Expected>
+runRename(ClangdServer &Server, PathRef File, Position Pos, StringRef NewName);
+
+std::string runDumpAST(ClangdServer &Server, PathRef File);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -17,7 +17,9 @@
 ///T Result;
 ///someAsyncFunc(Param1, Param2, /*Callback=*/capture(Result));
 template  struct CaptureProxy {
-  CaptureProxy(T &Target) : Target(&Target) {}
+  CaptureProxy(llvm::Optional &Target) : Target(&Target) {
+assert(!Target.hasValue());
+  }
 
   CaptureProxy(const CaptureProxy &) = delete;
   CaptureProxy &operator=(const CaptureProxy &) = delete;
@@ -39,27 +41,63 @@
 if (!Target)
   return;
 assert(Future.valid() && "conversion to callback was not called");
-*Target = Future.get();
+assert(!Target->hasValue());
+Target->emplace(Future.get());
   }
 
 private:
-  T *Target;
+  llvm::Optional *Target;
   std::promise Promise;
   std::future Future;
 };
 
-template  CaptureProxy capture(T &Target) {
+template  CaptureProxy capture(llvm::Optional &Target) {
   return CaptureProxy(Target);
 }
 } // namespace
 
 Tagged
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
 clangd::CodeCompleteOptions Opts,
 llvm::Optional OverridenContents) {
-  Tagged Result;
+  llvm::Optional> Result;
   Server.codeComplete(File, Pos, Opts, capture(Result), OverridenContents);
-  return Result;
+  return std::move(*Result);
+}
+
+llvm::Expected>
+runSignatureHelp(ClangdServer &Server, PathRef File, Position Pos,
+ llvm::Optional OverridenContents) {
+  llvm::Optional>> Result;
+  Server.signatureHelp(File, Pos, capture(Result), OverridenContents);
+  return std::move(*Result);
+}
+
+llvm::Expected>>
+runFindDefinitions(ClangdServer &Server, PathRef File, Position Pos) {
+  llvm::Optional>>> Result;
+  Server.findDefinitions(File, Pos, capture(Result));
+  return std::move(*Result);
+}
+
+llvm::Expected>>
+runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos) {
+  llvm::Optional>>> Result;
+  Server.findDocumentHighlights(File, Pos, capture(Result));
+  return std::move(*Result);
+}
+
+llvm::Expected>
+runRename(ClangdServer &Server, PathRef File, Position Pos, StringRef NewName) {
+  llvm::Optional>> Result;
+  Server.rename(File, Pos, NewName, capture(Result));
+  return std::move(*Result);
+}
+
+std::string runDumpAST(ClangdServer &Server, PathRef File) {
+  llvm::Optional Result;
+  Server.dumpAST(File, capture(Result));
+  return std::move(*Result);
 }
 
 } // namespace clangd
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -626,7 +626,7 @@
   Annotations Test(Text);
   Ser

[PATCH] D41880: Adding nocf_check attribute for cf-protection fine tuning

2018-02-14 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon marked 6 inline comments as done.
oren_ben_simhon added inline comments.



Comment at: include/clang/Basic/Attr.td:2089
+def AnyX86NoCfCheck : InheritableAttr, TargetSpecificAttr{
+  let Spellings = [GCC<"nocf_check">];
+  let Documentation = [AnyX86NoCfCheckDocs];

aaron.ballman wrote:
> This attribute doesn't appear to be supported by GCC. Did you mean to use the 
> Clang spelling instead?
Attribute documentation can be found here:
https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes




Comment at: lib/Sema/SemaDeclAttr.cpp:2007
+
+bool Sema::CheckAttrNoArgs(const AttributeList &Attr) {
+  if (!checkAttributeNumArgs(*this, Attr, 0)) {

craig.topper wrote:
> Wy did this get renamed?
To reuse existing code. The same check is performed in several attributes so 
instead of writing this block for every attribute i only call this function.



Comment at: lib/Sema/SemaDeclAttr.cpp:2016
 
-bool Sema::CheckNoCallerSavedRegsAttr(const AttributeList &Attr) {
+bool Sema::CheckAttrTarget(const AttributeList &Attr) {
   // Check whether the attribute is valid on the current target.

craig.topper wrote:
> Why did this get renamed?
To remove multiple code fragments. Same as CheckAttrNoArgs.


Repository:
  rL LLVM

https://reviews.llvm.org/D41880



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


Re: [clang-tools-extra] r325097 - [clangd] Configure clangd tracing with CLANGD_TRACE env instead of -trace flag

2018-02-14 Thread Ilya Biryukov via cfe-commits
Personally, I'm not a big fan of environment variables. There are harder to
discover than command-line flags and I still have to change editor config
often to switch between different builds of clangd.
I know it may sound weird, but maybe we could have both the flag and the
environment variables? (flag taking the precedence if both are specified)


On Wed, Feb 14, 2018 at 4:22 AM Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Tue Feb 13 19:20:07 2018
> New Revision: 325097
>
> URL: http://llvm.org/viewvc/llvm-project?rev=325097&view=rev
> Log:
> [clangd] Configure clangd tracing with CLANGD_TRACE env instead of -trace
> flag
>
> Modified:
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
> clang-tools-extra/trunk/test/clangd/trace.test
>
> Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=325097&r1=325096&r2=325097&view=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
> +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Tue Feb 13 19:20:07
> 2018
> @@ -17,6 +17,7 @@
>  #include "llvm/Support/Path.h"
>  #include "llvm/Support/Program.h"
>  #include "llvm/Support/raw_ostream.h"
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -123,12 +124,6 @@ static llvm::cl::opt InputMirrorFi
>  "Mirror all LSP input to the specified file. Useful for
> debugging."),
>  llvm::cl::init(""), llvm::cl::Hidden);
>
> -static llvm::cl::opt TraceFile(
> -"trace",
> -llvm::cl::desc(
> -"Trace internal events and timestamps in chrome://tracing JSON
> format"),
> -llvm::cl::init(""), llvm::cl::Hidden);
> -
>  static llvm::cl::opt EnableIndexBasedCompletion(
>  "enable-index-based-completion",
>  llvm::cl::desc(
> @@ -176,15 +171,18 @@ int main(int argc, char *argv[]) {
>  }
>}
>
> -  // Setup tracing facilities.
> +  // Setup tracing facilities if CLANGD_TRACE is set. In practice
> enabling a
> +  // trace flag in your editor's config is annoying, launching with
> +  // `CLANGD_TRACE=trace.json vim` is easier.
>llvm::Optional TraceStream;
>std::unique_ptr Tracer;
> -  if (!TraceFile.empty()) {
> +  if (auto *TraceFile = getenv("CLANGD_TRACE")) {
>  std::error_code EC;
>  TraceStream.emplace(TraceFile, /*ref*/ EC, llvm::sys::fs::F_RW);
>  if (EC) {
> -  TraceFile.reset();
> -  llvm::errs() << "Error while opening trace file: " << EC.message();
> +  TraceStream.reset();
> +  llvm::errs() << "Error while opening trace file " << TraceFile <<
> ": "
> +   << EC.message();
>  } else {
>Tracer = trace::createJSONTracer(*TraceStream, PrettyPrint);
>  }
>
> Modified: clang-tools-extra/trunk/test/clangd/trace.test
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/trace.test?rev=325097&r1=325096&r2=325097&view=diff
>
> ==
> --- clang-tools-extra/trunk/test/clangd/trace.test (original)
> +++ clang-tools-extra/trunk/test/clangd/trace.test Tue Feb 13 19:20:07 2018
> @@ -1,4 +1,4 @@
> -# RUN: clangd -lit-test -trace %t < %s && FileCheck %s < %t
> +# RUN: CLANGD_TRACE=%t clangd -lit-test < %s && FileCheck %s < %t
>
>  
> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
>  ---
>  
> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"void
> main() {}"}}}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


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


[PATCH] D41880: Adding nocf_check attribute for cf-protection fine tuning

2018-02-14 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon updated this revision to Diff 134175.
oren_ben_simhon added a comment.

Implemented comments posted until 2/14 (Thanks Aaron and Craig)


Repository:
  rL LLVM

https://reviews.llvm.org/D41880

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/attributes.c
  test/CodeGen/cetintrin.c
  test/CodeGen/x86-cf-protection.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-nocf_check.c

Index: test/Sema/attr-nocf_check.c
===
--- /dev/null
+++ test/Sema/attr-nocf_check.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+// Function pointer definition.
+typedef void (*FuncPointerWithNoCfCheck)(void) __attribute__((nocf_check)); // no-warning
+typedef void (*FuncPointer)(void);
+
+// Allow function declaration and definition mismatch.
+void __attribute__((nocf_check)) testNoCfCheck();   // no-warning
+void testNoCfCheck(){}; // no-warning
+
+// No variable or parameter declaration
+__attribute__((nocf_check)) int i;// expected-warning {{'nocf_check' attribute only applies to functions and function pointers}}
+void testNoCfCheckImpl(double __attribute__((nocf_check)) i) {} // expected-warning {{'nocf_check' attribute only applies to functions and function pointers}}
+
+// Allow attributed function pointers as well as casting between attributed
+// and non-attributed function pointers.
+void testNoCfCheckMismatch(FuncPointer f) {
+  FuncPointerWithNoCfCheck fNoCfCheck = f; // no-warning
+  (*fNoCfCheck)();   // no-warning
+  f = fNoCfCheck;// no-warning
+}
+
+// 'nocf_check' Attribute has no parameters.
+int testNoCfCheckParams() __attribute__((nocf_check(1))); // expected-error {{'nocf_check' attribute takes no arguments}}
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 66 attributes:
+// CHECK: #pragma clang attribute supports 67 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -12,6 +12,7 @@
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
 // CHECK-NEXT: Annotate ()
+// CHECK-NEXT: AnyX86NoCfCheck (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: CXX11NoReturn (SubjectMatchRule_function)
Index: test/CodeGen/x86-cf-protection.c
===
--- test/CodeGen/x86-cf-protection.c
+++ test/CodeGen/x86-cf-protection.c
@@ -1,5 +1,5 @@
-// RUN: not %clang_cc1 -fsyntax-only -S -emit-llvm -o %t -triple i386-unknown-unknown -fcf-protection=return %s 2>&1 | FileCheck %s --check-prefix=RETURN
-// RUN: not %clang_cc1 -fsyntax-only -S -emit-llvm -o %t -triple i386-unknown-unknown -fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=BRANCH
+// RUN: not %clang_cc1 -fsyntax-only -S -o %t -triple i386-unknown-unknown -fcf-protection=return %s 2>&1 | FileCheck %s --check-prefix=RETURN
+// RUN: not %clang_cc1 -fsyntax-only -S -o %t -triple i386-unknown-unknown -fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=BRANCH
 
 // RETURN: error: option 'cf-protection=return' cannot be specified without '-mshstk'
 // BRANCH: error: option 'cf-protection=branch' cannot be specified without '-mibt'
Index: test/CodeGen/cetintrin.c
===
--- test/CodeGen/cetintrin.c
+++ test/CodeGen/cetintrin.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +shstk  -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=X86_64
+// RUN: %clang_cc1 -ffreestanding %s -triple=

[PATCH] D43120: [clang-tidy] New checker for exceptions that are created but not thrown

2018-02-14 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 134174.
Szelethus added a comment.

Renamed the checker from `misc-throw-keyword-missing` to 
`bugprone-throw-keyword-missing`.


https://reviews.llvm.org/D43120

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
  clang-tidy/bugprone/ThrowKeywordMissingCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-throw-keyword-missing.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-throw-keyword-missing.cpp

Index: test/clang-tidy/bugprone-throw-keyword-missing.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-throw-keyword-missing.cpp
@@ -0,0 +1,167 @@
+// RUN: %check_clang_tidy %s bugprone-throw-keyword-missing %t
+
+namespace std {
+
+// std::string declaration (taken from test/clang-tidy/readability-redundant-string-cstr-msvc.cpp).
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const basic_string &);
+  // MSVC headers define two constructors instead of using optional arguments.
+  basic_string(const C *);
+  basic_string(const C *, const A &);
+  ~basic_string();
+};
+typedef basic_string string;
+typedef basic_string wstring;
+
+// std::exception and std::runtime_error declaration.
+struct exception {
+  exception();
+  exception(const exception &other);
+  virtual ~exception();
+};
+
+struct runtime_error : public exception {
+  explicit runtime_error(const std::string &what_arg);
+};
+
+} // namespace std
+
+// The usage of this class should never emit a warning.
+struct RegularClass {};
+
+// Class name contains the substring "exception", in certain cases using this class should emit a warning.
+struct RegularException {
+  RegularException() {}
+
+  // Constructors with a single argument are treated differently (cxxFunctionalCastExpr).
+  RegularException(int) {}
+};
+
+// --
+
+void stdExceptionNotTrownTest(int i) {
+  if (i < 0)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception object created but not thrown; did you mean 'throw {{.*}}'? [bugprone-throw-keyword-missing]
+std::exception();
+
+  if (i > 0)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception
+std::runtime_error("Unexpected argument");
+}
+
+void stdExceptionThrownTest(int i) {
+  if (i < 0)
+throw std::exception();
+
+  if (i > 0)
+throw std::runtime_error("Unexpected argument");
+}
+
+void regularClassNotThrownTest(int i) {
+  if (i < 0)
+RegularClass();
+}
+
+void regularClassThrownTest(int i) {
+  if (i < 0)
+throw RegularClass();
+}
+
+void nameContainsExceptionNotThrownTest(int i) {
+  if (i < 0)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception
+RegularException();
+
+  if (i > 0)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception
+RegularException(5);
+}
+
+void nameContainsExceptionThrownTest(int i) {
+  if (i < 0)
+throw RegularException();
+
+  if (i > 0)
+throw RegularException(5);
+}
+
+template 
+void f(int i, Exception excToBeThrown) {}
+
+void funcCallWithTempExcTest() {
+  f(5, RegularException());
+}
+
+// Global variable initilization test.
+RegularException exc = RegularException();
+RegularException *excptr = new RegularException();
+
+void localVariableInitTest() {
+  RegularException exc = RegularException();
+  RegularException *excptr = new RegularException();
+}
+
+class CtorInitializerListTest {
+  RegularException exc;
+
+  CtorInitializerListTest() : exc(RegularException()) {}
+
+  CtorInitializerListTest(int) try : exc(RegularException()) {
+// Constructor body
+  } catch (...) {
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception
+RegularException();
+  }
+
+  CtorInitializerListTest(float);
+};
+
+CtorInitializerListTest::CtorInitializerListTest(float) try : exc(RegularException()) {
+  // Constructor body
+} catch (...) {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: suspicious exception
+  RegularException();
+}
+
+RegularException funcReturningExceptionTest(int i) {
+  return RegularException();
+}
+
+void returnedValueTest() {
+  funcReturningExceptionTest(3);
+}
+
+struct ClassBracedInitListTest {
+  ClassBracedInitListTest(RegularException exc) {}
+};
+
+void foo(RegularException, ClassBracedInitListTest) {}
+
+void bracedInitListTest() {
+  RegularException exc{};
+  ClassBracedInitListTest test = {RegularException()};
+  foo({}, {RegularException()});
+}
+
+typedef std::exception ERROR_BASE;
+class RegularError : public ERROR_BASE {};
+
+void typedefTest() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: suspicious exception
+  RegularError();
+}
+
+struct ExceptionRAII {
+  ExceptionRAII() {}
+  ~ExceptionRAII() {}
+};
+
+void exceptionRAIITest() {
+  ExceptionRAII E;
+}
Index: docs/clang-tidy/checks/list.rst
=

[PATCH] D43120: [clang-tidy] New checker for exceptions that are created but not thrown

2018-02-14 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Just noticed that I can't mark your inline comment as done, since the file got 
renamed. The typo is also fixed (Classname -> Class name).


https://reviews.llvm.org/D43120



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


[PATCH] D43227: [clangd] Make functions of ClangdServer callback-based

2018-02-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.

lg




Comment at: clangd/ClangdServer.cpp:209
+  auto Action = [Contents, Pos, TaggedFS,
+ PCHs](Path File, decltype(Callback) Callback,
+   llvm::Expected IP) {

ilya-biryukov wrote:
> sammccall wrote:
> > ioeric wrote:
> > > ilya-biryukov wrote:
> > > > ioeric wrote:
> > > > > nit: I'd probably use a different name than `Callback` for this 
> > > > > parameter for clarity.
> > > > I actually think we should keep it this way. It's a bit tricky to 
> > > > grasp, but it has two important advantages:
> > > >   - Makes referencing `Callback` from outer scope impossible
> > > >   - saves us from coming up with names for that superficial variable, 
> > > > i.e. should it be called `InnerCallback`, `Callback2`, `C` or something 
> > > > else?
> > > > 
> > > > Is it that too confusing or do you feel we can keep it?
> > > > Makes referencing Callback from outer scope impossible. 
> > > For lambdas, I think we should rely on captures for this instead of the 
> > > parameter names.
> > > >saves us from coming up with names for that superficial variable, i.e. 
> > > >should it be called InnerCallback, Callback2, C or something else?
> > > I thought this is a common practice with llvm coding style :P I would 
> > > vote for `C` :) 
> > > 
> > > > Is it that too confusing or do you feel we can keep it?
> > > It is a bit confusing when I first looked at it, but nothing is *too* 
> > > confusing as long as the code is correct ;) I just think it would make 
> > > the code easier to read.
> > I agree with you both :-)
> > Conceptually, this *is* a capture - BindWithForward simulates move-capture 
> > that C++11 doesn't have native syntax for. So the same name seems 
> > appropriate to me - you want shadowing  for the same reasons you want 
> > captures to shadow.
> I'll leave as is in this review, we have other callsites, doing the same 
> thing, that we don't touch here. If we decide to change it, we should change 
> all of them in one go.
> I'm not opposed to the change, but like the current style a bit more.
Feel free to land without changing this; this is a nit anyway ;)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43227



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


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D43279



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


[PATCH] D43230: [clangd] Explicitly initialize all primitive fields in Protocol.h

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 134179.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Removed initializers for Optional<> fields, they are not problematic
- Remove ctor from Position, initialize on per-field basis instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43230

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdUnit.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/SourceCodeTests.cpp

Index: unittests/clangd/SourceCodeTests.cpp
===
--- unittests/clangd/SourceCodeTests.cpp
+++ unittests/clangd/SourceCodeTests.cpp
@@ -23,32 +23,40 @@
 1:0 = 8
 2:0 = 16)";
 
+/// A helper to make tests easier to read.
+Position position(int line, int character) {
+  Position Pos;
+  Pos.line = line;
+  Pos.character = character;
+  return Pos;
+}
+
 TEST(SourceCodeTests, PositionToOffset) {
   // line out of bounds
-  EXPECT_EQ(0u, positionToOffset(File, Position{-1, 2}));
+  EXPECT_EQ(0u, positionToOffset(File, position(-1, 2)));
   // first line
-  EXPECT_EQ(0u, positionToOffset(File, Position{0, -1})); // out of range
-  EXPECT_EQ(0u, positionToOffset(File, Position{0, 0})); // first character
-  EXPECT_EQ(3u, positionToOffset(File, Position{0, 3})); // middle character
-  EXPECT_EQ(6u, positionToOffset(File, Position{0, 6})); // last character
-  EXPECT_EQ(7u, positionToOffset(File, Position{0, 7})); // the newline itself
-  EXPECT_EQ(8u, positionToOffset(File, Position{0, 8})); // out of range
+  EXPECT_EQ(0u, positionToOffset(File, position(0, -1))); // out of range
+  EXPECT_EQ(0u, positionToOffset(File, position(0, 0)));  // first character
+  EXPECT_EQ(3u, positionToOffset(File, position(0, 3)));  // middle character
+  EXPECT_EQ(6u, positionToOffset(File, position(0, 6)));  // last character
+  EXPECT_EQ(7u, positionToOffset(File, position(0, 7)));  // the newline itself
+  EXPECT_EQ(8u, positionToOffset(File, position(0, 8)));  // out of range
   // middle line
-  EXPECT_EQ(8u, positionToOffset(File, Position{1, -1})); // out of range
-  EXPECT_EQ(8u, positionToOffset(File, Position{1, 0})); // first character
-  EXPECT_EQ(11u, positionToOffset(File, Position{1, 3})); // middle character
-  EXPECT_EQ(14u, positionToOffset(File, Position{1, 6})); // last character
-  EXPECT_EQ(15u, positionToOffset(File, Position{1, 7})); // the newline itself
-  EXPECT_EQ(16u, positionToOffset(File, Position{1, 8})); // out of range
+  EXPECT_EQ(8u, positionToOffset(File, position(1, -1))); // out of range
+  EXPECT_EQ(8u, positionToOffset(File, position(1, 0)));  // first character
+  EXPECT_EQ(11u, positionToOffset(File, position(1, 3))); // middle character
+  EXPECT_EQ(14u, positionToOffset(File, position(1, 6))); // last character
+  EXPECT_EQ(15u, positionToOffset(File, position(1, 7))); // the newline itself
+  EXPECT_EQ(16u, positionToOffset(File, position(1, 8))); // out of range
   // last line
-  EXPECT_EQ(16u, positionToOffset(File, Position{2, -1})); // out of range
-  EXPECT_EQ(16u, positionToOffset(File, Position{2, 0})); // first character
-  EXPECT_EQ(19u, positionToOffset(File, Position{2, 3})); // middle character
-  EXPECT_EQ(23u, positionToOffset(File, Position{2, 7})); // last character
-  EXPECT_EQ(24u, positionToOffset(File, Position{2, 8})); // EOF
-  EXPECT_EQ(24u, positionToOffset(File, Position{2, 9})); // out of range
+  EXPECT_EQ(16u, positionToOffset(File, position(2, -1))); // out of range
+  EXPECT_EQ(16u, positionToOffset(File, position(2, 0)));  // first character
+  EXPECT_EQ(19u, positionToOffset(File, position(2, 3)));  // middle character
+  EXPECT_EQ(23u, positionToOffset(File, position(2, 7)));  // last character
+  EXPECT_EQ(24u, positionToOffset(File, position(2, 8)));  // EOF
+  EXPECT_EQ(24u, positionToOffset(File, position(2, 9)));  // out of range
   // line out of bounds
-  EXPECT_EQ(24u, positionToOffset(File, Position{3, 1}));
+  EXPECT_EQ(24u, positionToOffset(File, position(3, 1)));
 }
 
 TEST(SourceCodeTests, OffsetToPosition) {
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -280,15 +280,13 @@
   // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
-  EXPECT_EQ(runCodeComplete(Server, FooCpp, Position{0, 0}, CCOpts).Tag,
-FS.Tag);
+  EXPECT_EQ(runCodeComplete(Server, FooCpp, Position(), CCOpts).Tag, FS.Tag);
   EXPECT_EQ(DiagConsumer.lastVFSTag(), FS.Tag);
 
   FS.Tag = "321";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(DiagConsumer.lastVFSTag(), FS.Tag);
-  EXPECT_EQ(runCodeComplete(Server, FooCpp, Position{0, 0}, CCOpts).Tag,
-FS.Tag);
+  EXPECT_EQ(runCodeComplete(Server, FooCpp, Position(), CCOpts).Tag, FS.Tag);
 }
 
 // Only enable this test on Unix
@@ -451,16 +449,16 @@
   Server.a

[PATCH] D43124: [clang-format] Improve ObjC headers detection

2018-02-14 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak updated this revision to Diff 134180.
jolesiak added a comment.
This revision is now accepted and ready to land.

Added support for ObjC characteristic keywords starting a new line.


Repository:
  rC Clang

https://reviews.llvm.org/D43124

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -113,10 +113,6 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
-  ASSERT_TRUE((bool)Style);
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
-
   Style =
   getStyle("{}", "a.h", "none", "typedef NS_ENUM(NSInteger, Foo) {};\n");
   ASSERT_TRUE((bool)Style);
@@ -126,10 +122,6 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
-  ASSERT_TRUE((bool)Style);
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
-
   Style =
   getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
   ASSERT_TRUE((bool)Style);
@@ -154,6 +146,23 @@
"inline void Foo() { int foo[] = {1, 2, 3}; }\n");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  // ObjC characteristic types.
+  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "NSObject *Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "NSSet *Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 }
 
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1440,7 +1440,9 @@
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
+"NSBundle",
 "NSCache",
+"NSCalendar",
 "NSCharacterSet",
 "NSCountedSet",
 "NSData",
@@ -1466,6 +1468,7 @@
 "NSMutableString",
 "NSNumber",
 "NSNumberFormatter",
+"NSObject",
 "NSOrderedSet",
 "NSPoint",
 "NSPointerArray",
@@ -1475,17 +1478,19 @@
 "NSSet",
 "NSSize",
 "NSString",
+"NSTimeZone",
 "NSUInteger",
 "NSURL",
 "NSURLComponents",
 "NSURLQueryItem",
 "NSUUID",
+"NSValue",
 };
 
 for (auto &Line : AnnotatedLines) {
-  for (FormatToken *FormatTok = Line->First->Next; FormatTok;
+  for (FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
-if ((FormatTok->Previous->is(tok::at) &&
+if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
  (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
   FormatTok->isObjCAtKeyword(tok::objc_implementation) ||
   FormatTok->isObjCAtKeyword(tok::objc_protocol) ||


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -113,10 +113,6 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
-  ASSERT_TRUE((bool)Style);
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
-
   Style =
   getStyle("{}", "a.h", "none", "typedef NS_ENUM(NSInteger, Foo) {};\n");
   ASSERT_TRUE((bool)Style);
@@ -126,10 +122,6 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
-  ASSERT_TRUE((bool)Style);
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
-
   Style =
   getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
   ASSERT_TRUE((bool)Style);
@@ -154,6 +146,23 @@
"inline void Foo() { int foo[] = {1, 2, 3}; }\n");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  // ObjC characteristic types.
+  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none

[PATCH] D43230: [clangd] Explicitly initialize all primitive fields in Protocol.h

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D43230#1006498, @ioeric wrote:

> I think it would probably depend on whether we could find a sensible default 
> value for a field (e.g. is 0 a better default value than UINT_MAX for line 
> number?) and whether we expect users to always initialize a field (e.g. would 
> it be better to pollute the field instead of providing a default value so 
> that uninitialized values would be caught more easily).


Yeah, it arguable whether 0 is the right default, but at least it's consistent 
with what compiler uses for zero-initialization, i.e. when you 
default-initialize builtin types explicitly (e.g. `int b = int();` or `int b = 
*(new int)`).
For things like `FileChangeType` we choose `1`, because it's the lowest 
acceptable value, but I'm not sure that's the right default value, merely a 
random valid enum value.




Comment at: clangd/Protocol.h:80
 struct Position {
+  Position() = default;
+  Position(int line, int character) : line(line), character(character) {}

sammccall wrote:
> I'd lean to making callers initialize field-by-field here rather than provide 
> constructors.
> It's not terrible here (you can get it wrong, but only one way), but it's a 
> pattern that doesn't scale so well I think.
As discussed offline, removed the ctor from Position and initialized everything 
on per-field basis.

It strikes me that this should be decided on per-struct basis. For things like 
position per-field init seems preferable to avoid accidentally confusing lines 
and chars.
On the other hand, for `Range` it seems totally fine to have a constructor, 
it's almost impossible to write `Range{end, begin}`, the ordering of ctor 
params is very natural.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43230



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


[clang-tools-extra] r325113 - [clangd] Explicitly initialize all primitive fields in Protocol.h

2018-02-14 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 14 02:52:04 2018
New Revision: 325113

URL: http://llvm.org/viewvc/llvm-project?rev=325113&view=rev
Log:
[clangd] Explicitly initialize all primitive fields in Protocol.h

Summary:
Some of the existing structs had primimtive fields that were
not explicitly initialized on construction.
After this commit every struct consistently sets a defined value for
every field when default-initialized.

Reviewers: hokein, ioeric, sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits, jkorous-apple

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=325113&r1=325112&r2=325113&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Feb 14 02:52:04 2018
@@ -275,16 +275,13 @@ void ClangdLSPServer::onCodeAction(CodeA
 }
 
 void ClangdLSPServer::onCompletion(TextDocumentPositionParams &Params) {
-  Server.codeComplete(Params.textDocument.uri.file,
-  Position{Params.position.line, 
Params.position.character},
-  CCOpts,
+  Server.codeComplete(Params.textDocument.uri.file, Params.position, CCOpts,
   [](Tagged List) { reply(List.Value); });
 }
 
 void ClangdLSPServer::onSignatureHelp(TextDocumentPositionParams &Params) {
-  auto SignatureHelp = Server.signatureHelp(
-  Params.textDocument.uri.file,
-  Position{Params.position.line, Params.position.character});
+  auto SignatureHelp =
+  Server.signatureHelp(Params.textDocument.uri.file, Params.position);
   if (!SignatureHelp)
 return replyError(ErrorCode::InvalidParams,
   llvm::toString(SignatureHelp.takeError()));
@@ -292,9 +289,8 @@ void ClangdLSPServer::onSignatureHelp(Te
 }
 
 void ClangdLSPServer::onGoToDefinition(TextDocumentPositionParams &Params) {
-  auto Items = Server.findDefinitions(
-  Params.textDocument.uri.file,
-  Position{Params.position.line, Params.position.character});
+  auto Items =
+  Server.findDefinitions(Params.textDocument.uri.file, Params.position);
   if (!Items)
 return replyError(ErrorCode::InvalidParams,
   llvm::toString(Items.takeError()));
@@ -307,9 +303,8 @@ void ClangdLSPServer::onSwitchSourceHead
 }
 
 void ClangdLSPServer::onDocumentHighlight(TextDocumentPositionParams &Params) {
-  auto Highlights = Server.findDocumentHighlights(
-  Params.textDocument.uri.file,
-  Position{Params.position.line, Params.position.character});
+  auto Highlights = Server.findDocumentHighlights(Params.textDocument.uri.file,
+  Params.position);
 
   if (!Highlights) {
 replyError(ErrorCode::InternalError,

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=325113&r1=325112&r2=325113&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Feb 14 02:52:04 2018
@@ -136,10 +136,16 @@ bool locationInRange(SourceLocation L, C
 // Note that clang also uses closed source ranges, which this can't handle!
 Range toRange(CharSourceRange R, const SourceManager &M) {
   // Clang is 1-based, LSP uses 0-based indexes.
-  return {{static_cast(M.getSpellingLineNumber(R.getBegin())) - 1,
-   static_cast(M.getSpellingColumnNumber(R.getBegin())) - 1},
-  {static_cast(M.getSpellingLineNumber(R.getEnd())) - 1,
-   static_cast(M.getSpellingColumnNumber(R.getEnd())) - 1}};
+  Position Begin;
+  Begin.line = static_cast(M.getSpellingLineNumber(R.getBegin())) - 1;
+  Begin.character =
+  static_cast(M.getSpellingColumnNumber(R.getBegin())) - 1;
+
+  Position End;
+  End.line = static_cast(M.getSpellingLineNumber(R.getEnd())) - 1;
+  End.character = static_cast(M.getSpellingColumnNumber(R.getEnd())) - 1;
+
+  return {Begin, End};
 }
 
 // Clang diags have a location (shown as ^) and 0 or more ranges ().
@@ -534,8 +540,11 @@ SourceLocation clangd::getBeginningOfIde
   // token. If so, Take the beginning of this token.
   // (It should be the same identifier because you can't have two adjacent
   // identifiers without another token in between.)
-  SourceLocation PeekBeforeLocation = getMacroArgExpandedLocation(
-  SourceMgr, F

[PATCH] D43230: [clangd] Explicitly initialize all primitive fields in Protocol.h

2018-02-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325113: [clangd] Explicitly initialize all primitive fields 
in Protocol.h (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43230

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/SourceCode.cpp
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
  clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp
@@ -23,32 +23,40 @@
 1:0 = 8
 2:0 = 16)";
 
+/// A helper to make tests easier to read.
+Position position(int line, int character) {
+  Position Pos;
+  Pos.line = line;
+  Pos.character = character;
+  return Pos;
+}
+
 TEST(SourceCodeTests, PositionToOffset) {
   // line out of bounds
-  EXPECT_EQ(0u, positionToOffset(File, Position{-1, 2}));
+  EXPECT_EQ(0u, positionToOffset(File, position(-1, 2)));
   // first line
-  EXPECT_EQ(0u, positionToOffset(File, Position{0, -1})); // out of range
-  EXPECT_EQ(0u, positionToOffset(File, Position{0, 0})); // first character
-  EXPECT_EQ(3u, positionToOffset(File, Position{0, 3})); // middle character
-  EXPECT_EQ(6u, positionToOffset(File, Position{0, 6})); // last character
-  EXPECT_EQ(7u, positionToOffset(File, Position{0, 7})); // the newline itself
-  EXPECT_EQ(8u, positionToOffset(File, Position{0, 8})); // out of range
+  EXPECT_EQ(0u, positionToOffset(File, position(0, -1))); // out of range
+  EXPECT_EQ(0u, positionToOffset(File, position(0, 0)));  // first character
+  EXPECT_EQ(3u, positionToOffset(File, position(0, 3)));  // middle character
+  EXPECT_EQ(6u, positionToOffset(File, position(0, 6)));  // last character
+  EXPECT_EQ(7u, positionToOffset(File, position(0, 7)));  // the newline itself
+  EXPECT_EQ(8u, positionToOffset(File, position(0, 8)));  // out of range
   // middle line
-  EXPECT_EQ(8u, positionToOffset(File, Position{1, -1})); // out of range
-  EXPECT_EQ(8u, positionToOffset(File, Position{1, 0})); // first character
-  EXPECT_EQ(11u, positionToOffset(File, Position{1, 3})); // middle character
-  EXPECT_EQ(14u, positionToOffset(File, Position{1, 6})); // last character
-  EXPECT_EQ(15u, positionToOffset(File, Position{1, 7})); // the newline itself
-  EXPECT_EQ(16u, positionToOffset(File, Position{1, 8})); // out of range
+  EXPECT_EQ(8u, positionToOffset(File, position(1, -1))); // out of range
+  EXPECT_EQ(8u, positionToOffset(File, position(1, 0)));  // first character
+  EXPECT_EQ(11u, positionToOffset(File, position(1, 3))); // middle character
+  EXPECT_EQ(14u, positionToOffset(File, position(1, 6))); // last character
+  EXPECT_EQ(15u, positionToOffset(File, position(1, 7))); // the newline itself
+  EXPECT_EQ(16u, positionToOffset(File, position(1, 8))); // out of range
   // last line
-  EXPECT_EQ(16u, positionToOffset(File, Position{2, -1})); // out of range
-  EXPECT_EQ(16u, positionToOffset(File, Position{2, 0})); // first character
-  EXPECT_EQ(19u, positionToOffset(File, Position{2, 3})); // middle character
-  EXPECT_EQ(23u, positionToOffset(File, Position{2, 7})); // last character
-  EXPECT_EQ(24u, positionToOffset(File, Position{2, 8})); // EOF
-  EXPECT_EQ(24u, positionToOffset(File, Position{2, 9})); // out of range
+  EXPECT_EQ(16u, positionToOffset(File, position(2, -1))); // out of range
+  EXPECT_EQ(16u, positionToOffset(File, position(2, 0)));  // first character
+  EXPECT_EQ(19u, positionToOffset(File, position(2, 3)));  // middle character
+  EXPECT_EQ(23u, positionToOffset(File, position(2, 7)));  // last character
+  EXPECT_EQ(24u, positionToOffset(File, position(2, 8)));  // EOF
+  EXPECT_EQ(24u, positionToOffset(File, position(2, 9)));  // out of range
   // line out of bounds
-  EXPECT_EQ(24u, positionToOffset(File, Position{3, 1}));
+  EXPECT_EQ(24u, positionToOffset(File, position(3, 1)));
 }
 
 TEST(SourceCodeTests, OffsetToPosition) {
Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -280,15 +280,13 @@
   // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
-  EXPECT_EQ(runCodeComplete(Server, FooCpp, Position{0, 0}, CCOpts).Tag,
-FS.Tag);
+  EXPECT_EQ(runCodeComplete(Server, FooCpp, Position(), CCOpts).Tag, FS.Tag);
   EXPECT_EQ(DiagConsumer.lastVFSTag(), FS.Tag);
 
   FS.Tag = "321";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(DiagConsumer.lastVFSTag(), FS.Tag

[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-02-14 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov created this revision.
dfukalov added reviewers: b-sumner, arsenm.
dfukalov added a project: AMDGPU.
Herald added subscribers: cfe-commits, t-tye, tpr, dstuttard, yaxunl, nhaehnle, 
wdng, kzhuravl.

1. removed addrspace 3 specifications from builtins description strings since 
it's not target addrspaces
2. added custom processing for these builtins


Repository:
  rC Clang

https://reviews.llvm.org/D43281

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


Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -91,18 +91,18 @@
 
 // CHECK-LABEL: @test_ds_fadd
 // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fadd(__attribute__((address_space(3))) float *out, float src) {
+void test_ds_fadd(local float *out, float src) {
   *out = __builtin_amdgcn_ds_fadd(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmin
 // CHECK: call float @llvm.amdgcn.ds.fmin(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fmin(__attribute__((address_space(3))) float *out, float src) {
+void test_ds_fmin(local float *out, float src) {
   *out = __builtin_amdgcn_ds_fmin(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmax
 // CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fmax(__attribute__((address_space(3))) float *out, float src) {
+void test_ds_fmax(local float *out, float src) {
   *out = __builtin_amdgcn_ds_fmax(out, src, 0, 0, false);
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9860,6 +9860,29 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_ds_fadd:
+  case AMDGPU::BI__builtin_amdgcn_ds_fmin:
+  case AMDGPU::BI__builtin_amdgcn_ds_fmax: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 5; ++I)
+  Args.push_back(EmitScalarExpr(E->getArg(I)));
+Intrinsic::ID ID;
+switch (BuiltinID) {
+case AMDGPU::BI__builtin_amdgcn_ds_fadd:
+  ID = Intrinsic::amdgcn_ds_fadd;
+  break;
+case AMDGPU::BI__builtin_amdgcn_ds_fmin:
+  ID = Intrinsic::amdgcn_ds_fmin;
+  break;
+case AMDGPU::BI__builtin_amdgcn_ds_fmax:
+  ID = Intrinsic::amdgcn_ds_fmax;
+  break;
+default:
+  llvm_unreachable("Unknown BuiltinID");
+}
+Value *F = CGM.getIntrinsic(ID);
+return Builder.CreateCall(F, Args);
+  }
 
   // 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
@@ -93,9 +93,9 @@
 BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
 BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
 BUILTIN(__builtin_amdgcn_fmed3f, "", "nc")
-BUILTIN(__builtin_amdgcn_ds_fadd, "ff*3fiib", "n")
-BUILTIN(__builtin_amdgcn_ds_fmin, "ff*3fiib", "n")
-BUILTIN(__builtin_amdgcn_ds_fmax, "ff*3fiib", "n")
+BUILTIN(__builtin_amdgcn_ds_fadd, "ff*fiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_fmin, "ff*fiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_fmax, "ff*fiIiIb", "n")
 
 
//===--===//
 // VI+ only builtins.


Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -91,18 +91,18 @@
 
 // CHECK-LABEL: @test_ds_fadd
 // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false)
-void test_ds_fadd(__attribute__((address_space(3))) float *out, float src) {
+void test_ds_fadd(local float *out, float src) {
   *out = __builtin_amdgcn_ds_fadd(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmin
 // CHECK: call float @llvm.amdgcn.ds.fmin(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false)
-void test_ds_fmin(__attribute__((address_space(3))) float *out, float src) {
+void test_ds_fmin(local float *out, float src) {
   *out = __builtin_amdgcn_ds_fmin(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmax
 // CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false)
-void test_ds_fmax(__attribute__((address_space(3))) float *out, float src) {
+void test_ds_fmax(local float *out, float src) {
   *out = __builtin_amdgcn_ds_fmax(out, src, 0, 0, false);
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9860,6 +9860,29 @@
  

r325116 - [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl

2018-02-14 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Wed Feb 14 03:18:00 2018
New Revision: 325116

URL: http://llvm.org/viewvc/llvm-project?rev=325116&view=rev
Log:
[ASTImporter] Fix lexical DC for templated decls; support 
VarTemplatePartialSpecDecl

Also minor refactoring in related functions was done.

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


Added:
cfe/trunk/test/ASTMerge/var-cpp/
cfe/trunk/test/ASTMerge/var-cpp/Inputs/
cfe/trunk/test/ASTMerge/var-cpp/Inputs/var1.cpp
cfe/trunk/test/ASTMerge/var-cpp/test.cpp
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=325116&r1=325115&r2=325116&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Feb 14 03:18:00 2018
@@ -23,7 +23,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include 
 
 namespace clang {
   class ASTNodeImporter : public TypeVisitor,
@@ -1335,6 +1334,21 @@ bool ASTNodeImporter::ImportTemplateArgu
   return false;
 }
 
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo(
+const TemplateArgumentListInfo &From, TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(
+  From.getLAngleLoc(), From.getRAngleLoc(), From.arguments(), Result);
+}
+
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo<
+ASTTemplateArgumentListInfo>(const ASTTemplateArgumentListInfo &From,
+ TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(From.LAngleLoc, From.RAngleLoc,
+From.arguments(), Result);
+}
+
 bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, 
 RecordDecl *ToRecord, bool Complain) {
   // Eliminate a potential failure point where we attempt to re-import
@@ -1655,10 +1669,8 @@ Decl *ASTNodeImporter::VisitTypedefNameD
   SourceLocation StartL = Importer.Import(D->getLocStart());
   TypedefNameDecl *ToTypedef;
   if (IsAlias)
-ToTypedef = TypeAliasDecl::Create(Importer.getToContext(), DC,
-  StartL, Loc,
-  Name.getAsIdentifierInfo(),
-  TInfo);
+ToTypedef = TypeAliasDecl::Create(Importer.getToContext(), DC, StartL, Loc,
+  Name.getAsIdentifierInfo(), TInfo);
   else
 ToTypedef = TypedefDecl::Create(Importer.getToContext(), DC,
 StartL, Loc,
@@ -1668,7 +1680,11 @@ Decl *ASTNodeImporter::VisitTypedefNameD
   ToTypedef->setAccess(D->getAccess());
   ToTypedef->setLexicalDeclContext(LexicalDC);
   Importer.Imported(D, ToTypedef);
-  LexicalDC->addDeclInternal(ToTypedef);
+
+  // Templated declarations should not appear in DeclContext.
+  TypeAliasDecl *FromAlias = IsAlias ? cast(D) : nullptr;
+  if (!FromAlias || !FromAlias->getDescribedAliasTemplate())
+LexicalDC->addDeclInternal(ToTypedef);
 
   return ToTypedef;
 }
@@ -1686,11 +1702,11 @@ Decl *ASTNodeImporter::VisitTypeAliasTem
   DeclContext *DC, *LexicalDC;
   DeclarationName Name;
   SourceLocation Loc;
-  NamedDecl *ToD;
-  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+  NamedDecl *FoundD;
+  if (ImportDeclParts(D, DC, LexicalDC, Name, FoundD, Loc))
 return nullptr;
-  if (ToD)
-return ToD;
+  if (FoundD)
+return FoundD;
 
   // If this typedef is not in block scope, determine whether we've
   // seen a typedef with the same name (that we can merge with) or any
@@ -1723,7 +1739,7 @@ Decl *ASTNodeImporter::VisitTypeAliasTem
   if (!Params)
 return nullptr;
 
-  NamedDecl *TemplDecl = cast_or_null(
+  auto *TemplDecl = cast_or_null(
 Importer.Import(D->getTemplatedDecl()));
   if (!TemplDecl)
 return nullptr;
@@ -1731,11 +1747,13 @@ Decl *ASTNodeImporter::VisitTypeAliasTem
   TypeAliasTemplateDecl *ToAlias = TypeAliasTemplateDecl::Create(
 Importer.getToContext(), DC, Loc, Name, Params, TemplDecl);
 
+  TemplDecl->setDescribedAliasTemplate(ToAlias);
+
   ToAlias->setAccess(D->getAccess());
   ToAlias->setLexicalDeclContext(LexicalDC);
   Importer.Imported(D, ToAlias);
   LexicalDC->addDeclInternal(ToAlias);
-  return ToD;
+  return ToAlias;
 }
 
 Decl *ASTNodeImporter::VisitLabelDecl(LabelDecl *D) {
@@ -2155,12 +2173,9 @@ bool ASTNodeImporter::ImportTemplateInfo
 
 TemplateArgumentListInfo ToTAInfo;
 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
-if (FromTAArgsAsWritten) {
-  if (ImportTemplateArgumentListInfo(
-  FromTAArgsAsWritten->LAngleLoc, FromTAArgsAsWritten->RAngleLoc,
-  FromTAArgsAsWritten->arguments(), ToTAInfo))
+  

[PATCH] D43012: [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl

2018-02-14 Thread Aleksei Sidorin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325116: [ASTImporter] Fix lexical DC for templated decls; 
support… (authored by a.sidorin, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43012?vs=133626&id=134187#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43012

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/test/ASTMerge/var-cpp/Inputs/var1.cpp
  cfe/trunk/test/ASTMerge/var-cpp/test.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/test/ASTMerge/var-cpp/Inputs/var1.cpp
===
--- cfe/trunk/test/ASTMerge/var-cpp/Inputs/var1.cpp
+++ cfe/trunk/test/ASTMerge/var-cpp/Inputs/var1.cpp
@@ -0,0 +1,17 @@
+
+template 
+constexpr T my_pi = T(3.1415926535897932385L);  // variable template
+
+template <> constexpr char my_pi = '3';   // variable template specialization
+
+template 
+struct Wrapper {
+  template  static constexpr U my_const = U(1);
+   // Variable template partial specialization with member variable.
+  template  static constexpr U *my_const = (U *)(0);
+};
+
+constexpr char a[] = "hello";
+
+template <> template <>
+constexpr const char *Wrapper::my_const = a;
Index: cfe/trunk/test/ASTMerge/var-cpp/test.cpp
===
--- cfe/trunk/test/ASTMerge/var-cpp/test.cpp
+++ cfe/trunk/test/ASTMerge/var-cpp/test.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -std=c++17 -o %t.1.ast %S/Inputs/var1.cpp
+// RUN: %clang_cc1 -std=c++17 -ast-merge %t.1.ast -fsyntax-only %s 2>&1
+
+static_assert(my_pi == (double)3.1415926535897932385L);
+static_assert(my_pi == '3');
+
+static_assert(Wrapper::my_const == 1.f);
+static_assert(Wrapper::my_const == nullptr);
+static_assert(Wrapper::my_const == a);
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include 
 
 namespace clang {
   class ASTNodeImporter : public TypeVisitor,
@@ -1335,6 +1334,21 @@
   return false;
 }
 
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo(
+const TemplateArgumentListInfo &From, TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(
+  From.getLAngleLoc(), From.getRAngleLoc(), From.arguments(), Result);
+}
+
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo<
+ASTTemplateArgumentListInfo>(const ASTTemplateArgumentListInfo &From,
+ TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(From.LAngleLoc, From.RAngleLoc,
+From.arguments(), Result);
+}
+
 bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, 
 RecordDecl *ToRecord, bool Complain) {
   // Eliminate a potential failure point where we attempt to re-import
@@ -1655,10 +1669,8 @@
   SourceLocation StartL = Importer.Import(D->getLocStart());
   TypedefNameDecl *ToTypedef;
   if (IsAlias)
-ToTypedef = TypeAliasDecl::Create(Importer.getToContext(), DC,
-  StartL, Loc,
-  Name.getAsIdentifierInfo(),
-  TInfo);
+ToTypedef = TypeAliasDecl::Create(Importer.getToContext(), DC, StartL, Loc,
+  Name.getAsIdentifierInfo(), TInfo);
   else
 ToTypedef = TypedefDecl::Create(Importer.getToContext(), DC,
 StartL, Loc,
@@ -1668,7 +1680,11 @@
   ToTypedef->setAccess(D->getAccess());
   ToTypedef->setLexicalDeclContext(LexicalDC);
   Importer.Imported(D, ToTypedef);
-  LexicalDC->addDeclInternal(ToTypedef);
+
+  // Templated declarations should not appear in DeclContext.
+  TypeAliasDecl *FromAlias = IsAlias ? cast(D) : nullptr;
+  if (!FromAlias || !FromAlias->getDescribedAliasTemplate())
+LexicalDC->addDeclInternal(ToTypedef);
 
   return ToTypedef;
 }
@@ -1686,11 +1702,11 @@
   DeclContext *DC, *LexicalDC;
   DeclarationName Name;
   SourceLocation Loc;
-  NamedDecl *ToD;
-  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+  NamedDecl *FoundD;
+  if (ImportDeclParts(D, DC, LexicalDC, Name, FoundD, Loc))
 return nullptr;
-  if (ToD)
-return ToD;
+  if (FoundD)
+return FoundD;
 
   // If this typedef is not in block scope, determine whether we've
   // seen a typedef with the same name (that we can merge with) or any
@@ -1723,19 +1739,21 @@
   if (!Params)
 return nullptr;
 
-  NamedDecl *TemplDecl = cast_or_null(
+  auto *TemplDecl = cast_or_null(
 Importer.Import(D->getTemplatedDecl()));
   if (!TemplDecl)
 return nullptr;
 
   TypeAliasTemplat

[PATCH] D42969: [Sema] Fix decltype of static data members

2018-02-14 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325117: [Sema] Fix decltype of static data members (authored 
by miyuki, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42969

Files:
  lib/Sema/SemaType.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp


Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
@@ -12,13 +12,18 @@
 
 const int&& foo();
 int i;
-struct A { double x; };
+struct A {
+  double x;
+  static int y;
+};
 const A* a = new A();
 
 static_assert(is_same::value, "");
 static_assert(is_same::value, "");
 static_assert(is_samex), double>::value, "");
 static_assert(is_samex)), const double&>::value, "");
+static_assert(is_samey), int>::value, "");
+static_assert(is_samey)), int&>::value, "");
 static_assert(is_same(i)), int&&>::value, "");
 
 int f0(int); // expected-note{{possible target}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7868,8 +7868,9 @@
 if (const ValueDecl *VD = dyn_cast(DRE->getDecl()))
   return VD->getType();
   } else if (const MemberExpr *ME = dyn_cast(E)) {
-if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl()))
-  return FD->getType();
+if (const ValueDecl *VD = ME->getMemberDecl())
+  if (isa(VD) || isa(VD))
+return VD->getType();
   } else if (const ObjCIvarRefExpr *IR = dyn_cast(E)) {
 return IR->getDecl()->getType();
   } else if (const ObjCPropertyRefExpr *PR = dyn_cast(E)) 
{


Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
@@ -12,13 +12,18 @@
 
 const int&& foo();
 int i;
-struct A { double x; };
+struct A {
+  double x;
+  static int y;
+};
 const A* a = new A();
 
 static_assert(is_same::value, "");
 static_assert(is_same::value, "");
 static_assert(is_samex), double>::value, "");
 static_assert(is_samex)), const double&>::value, "");
+static_assert(is_samey), int>::value, "");
+static_assert(is_samey)), int&>::value, "");
 static_assert(is_same(i)), int&&>::value, "");
 
 int f0(int); // expected-note{{possible target}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7868,8 +7868,9 @@
 if (const ValueDecl *VD = dyn_cast(DRE->getDecl()))
   return VD->getType();
   } else if (const MemberExpr *ME = dyn_cast(E)) {
-if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl()))
-  return FD->getType();
+if (const ValueDecl *VD = ME->getMemberDecl())
+  if (isa(VD) || isa(VD))
+return VD->getType();
   } else if (const ObjCIvarRefExpr *IR = dyn_cast(E)) {
 return IR->getDecl()->getType();
   } else if (const ObjCPropertyRefExpr *PR = dyn_cast(E)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325118 - Quick fix for 325116 buildbots: move template specialization into namespace

2018-02-14 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Wed Feb 14 03:39:33 2018
New Revision: 325118

URL: http://llvm.org/viewvc/llvm-project?rev=325118&view=rev
Log:
Quick fix for 325116 buildbots: move template specialization into namespace


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

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=325118&r1=325117&r2=325118&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Feb 14 03:39:33 2018
@@ -360,8 +360,37 @@ namespace clang {
 // Importing overrides.
 void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod);
   };
+
+
+template 
+bool ASTNodeImporter::ImportTemplateArgumentListInfo(
+SourceLocation FromLAngleLoc, SourceLocation FromRAngleLoc,
+const InContainerTy &Container, TemplateArgumentListInfo &Result) {
+  TemplateArgumentListInfo ToTAInfo(Importer.Import(FromLAngleLoc),
+Importer.Import(FromRAngleLoc));
+  if (ImportTemplateArgumentListInfo(Container, ToTAInfo))
+return true;
+  Result = ToTAInfo;
+  return false;
+}
+
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo(
+const TemplateArgumentListInfo &From, TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(
+  From.getLAngleLoc(), From.getRAngleLoc(), From.arguments(), Result);
+}
+
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo<
+ASTTemplateArgumentListInfo>(const ASTTemplateArgumentListInfo &From,
+ TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(From.LAngleLoc, From.RAngleLoc,
+From.arguments(), Result);
 }
 
+} // end namespace clang
+
 //
 // Import Types
 //
@@ -1322,33 +1351,6 @@ bool ASTNodeImporter::ImportTemplateArgu
   return false;
 }
 
-template 
-bool ASTNodeImporter::ImportTemplateArgumentListInfo(
-SourceLocation FromLAngleLoc, SourceLocation FromRAngleLoc,
-const InContainerTy &Container, TemplateArgumentListInfo &Result) {
-  TemplateArgumentListInfo ToTAInfo(Importer.Import(FromLAngleLoc),
-Importer.Import(FromRAngleLoc));
-  if (ImportTemplateArgumentListInfo(Container, ToTAInfo))
-return true;
-  Result = ToTAInfo;
-  return false;
-}
-
-template <>
-bool ASTNodeImporter::ImportTemplateArgumentListInfo(
-const TemplateArgumentListInfo &From, TemplateArgumentListInfo &Result) {
-  return ImportTemplateArgumentListInfo(
-  From.getLAngleLoc(), From.getRAngleLoc(), From.arguments(), Result);
-}
-
-template <>
-bool ASTNodeImporter::ImportTemplateArgumentListInfo<
-ASTTemplateArgumentListInfo>(const ASTTemplateArgumentListInfo &From,
- TemplateArgumentListInfo &Result) {
-  return ImportTemplateArgumentListInfo(From.LAngleLoc, From.RAngleLoc,
-From.arguments(), Result);
-}
-
 bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, 
 RecordDecl *ToRecord, bool Complain) {
   // Eliminate a potential failure point where we attempt to re-import


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


[PATCH] D43246: [clangd] Assert path is absolute when assigning to URIForFile.

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 134194.
ilya-biryukov added a comment.

- Remove URIForFile::setFile(), rely on copy and move constructors instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43246

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/XRefs.cpp

Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -149,7 +149,7 @@
 }
   }
 
-  L.uri.file = FilePath.str();
+  L.uri = URIForFile(FilePath.str());
   L.range = R;
   return L;
 }
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -25,6 +25,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
 
 #include "JSONExpr.h"
+#include "Path.h"
 #include "URI.h"
 #include "llvm/ADT/Optional.h"
 #include 
@@ -49,21 +50,29 @@
 };
 
 struct URIForFile {
-  std::string file;
+  URIForFile() = default;
+  explicit URIForFile(Path AbsPath);
 
-  std::string uri() const { return URI::createFile(file).toString(); }
+  /// Retrieves absolute path to the file.
+  PathRef getFile() const { return File; }
+
+  explicit operator bool() const { return !File.empty(); }
+  std::string uri() const { return URI::createFile(File).toString(); }
 
   friend bool operator==(const URIForFile &LHS, const URIForFile &RHS) {
-return LHS.file == RHS.file;
+return LHS.File == RHS.File;
   }
 
   friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS) {
 return !(LHS == RHS);
   }
 
   friend bool operator<(const URIForFile &LHS, const URIForFile &RHS) {
-return LHS.file < RHS.file;
+return LHS.File < RHS.File;
   }
+
+private:
+  Path File;
 };
 
 /// Serialize/deserialize \p URIForFile to/from a string URI.
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -12,8 +12,8 @@
 //===--===//
 
 #include "Protocol.h"
-#include "URI.h"
 #include "Logger.h"
+#include "URI.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Format.h"
@@ -24,6 +24,11 @@
 namespace clang {
 namespace clangd {
 
+URIForFile::URIForFile(Path AbsPath) {
+  assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative");
+  File = std::move(AbsPath);
+}
+
 bool fromJSON(const json::Expr &E, URIForFile &R) {
   if (auto S = E.asString()) {
 auto U = URI::parse(*S);
@@ -40,15 +45,13 @@
   log(llvm::toString(Path.takeError()));
   return false;
 }
-R.file = *Path;
+R = URIForFile(*Path);
 return true;
   }
   return false;
 }
 
-json::Expr toJSON(const URIForFile &U) {
-  return U.uri();
-}
+json::Expr toJSON(const URIForFile &U) { return U.uri(); }
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
   return OS << U.uri();
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -116,8 +116,8 @@
  {"commands", {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},
  }},
 );
-  if (Params.rootUri && !Params.rootUri->file.empty())
-Server.setRootPath(Params.rootUri->file);
+  if (Params.rootUri && *Params.rootUri)
+Server.setRootPath(Params.rootUri->getFile());
   else if (Params.rootPath && !Params.rootPath->empty())
 Server.setRootPath(*Params.rootPath);
 }
@@ -132,17 +132,18 @@
 
 void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams &Params) {
   if (Params.metadata && !Params.metadata->extraFlags.empty())
-CDB.setExtraFlagsForFile(Params.textDocument.uri.file,
+CDB.setExtraFlagsForFile(Params.textDocument.uri.getFile(),
  std::move(Params.metadata->extraFlags));
-  Server.addDocument(Params.textDocument.uri.file, Params.textDocument.text);
+  Server.addDocument(Params.textDocument.uri.getFile(),
+ Params.textDocument.text);
 }
 
 void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams &Params) {
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
   // We only support full syncing right now.
-  Server.addDocument(Params.textDocument.uri.file,
+  Server.addDocument(Params.textDocument.uri.getFile(),
  Params.contentChanges[0].text);
 }
 
@@ -180,7 +181,7 @@
 }
 
 void ClangdLSPServer::onRename(RenameParams &Params) {
-  auto File = Params.textDocument.uri.file;
+  auto File = Params.textDocument.uri.getFile();
   auto Code = Server.getDocument(File);
   if (!Code)
 return replyError(ErrorCode::InvalidParams,
@@ -200,12 +201,12 @@
 }
 
 void ClangdLSPServer::onDocumentDidClose(DidCloseTextDocumentParams &Params) {
-  

[PATCH] D43246: [clangd] Assert path is absolute when assigning to URIForFile.

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D43246#1006525, @ioeric wrote:

> I think another option to prevent the bug in r325029 from happening would be 
> providing a canonical approach for retrieving (absolute) paths from 
> `FileManager`. We already have code in symbol collector that does this, and 
> we have similar code in XRefs.cpp now. We should probably move them to 
> `clangd/Path.h` and share the code?


I agree with you, we should do this.
But this change is not a mitigation for r325029 specifically. URIForFile would 
still be tremendously easy to misuse in other cases as well.




Comment at: clangd/Protocol.h:52
 
 struct URIForFile {
+  URIForFile() = default;

sammccall wrote:
> I don't like how the API changes here take us further away from the other 
> structs in this file.
> Why does this one enforce invariants, when the others don't?
> 
> If we do want to make this more "safe", I'd suggest making it look more like 
> a URI string (since that's what its protocol role is), like:
> 
> ```
> class LSPURI {
>   LSPURI(StringRef URI) { assert if bad }
>   static LSPURI ForFile(StringRef AbsPath) { assert if bad }
>   operator string() { return URI::createFile(File).toString(); }
>   StringRef file() { return AbsFile; }
>   operator bool() { return !File.empty(); } 
>   // move/copy constructor/assignment defaulted
> 
>  private:
>   string AbsFile;
> }
> ```
> 
> But the approach Eric suggested does seem promising: more consistent with how 
> we handle invariants in protocol structs.
I've updated `URIForFile` to follow the interface you proposed. (Instead of 
`operator string()` we have `uri()`, but everything else is there). Haven't 
changed the name yet, happy to do it to.

> Why does this one enforce invariants, when the others don't?
It seems useful to catch misbehaving code as early as possible. What are the 
other invariants that could be useful?

> But the approach Eric suggested does seem promising: more consistent with how 
> we handle invariants in protocol structs.
I agree with Eric's approach, I wasn't trying to fix that specific bug with 
this commit.

I'm trying to argue that we should check for non-absolute paths as early as 
possible and fail with assertions to make writing code easier in the future. Do 
you agree that would be useful or make we shouldn't do it?




Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43246



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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D39571#1006667, @simark wrote:

>   It seems to me like
>
> changes in command line arguments (adding -DMACRO=1) are not taken into 
> account
>  when changing configuration.


It looks like a bug in the preamble handling. (It does not check if macros were 
redefined).
You can workaround that by making sure the preamble ends before your code 
starts (preamble only captures preprocessor directives, so any C++ decl will 
end it):

Annotations SourceAnnotations(R"cpp(
  int avoid_preamble;
  
  #ifndef MACRO
  $before[[static void bob() {}]]
  #else
  $after[[static void bob() {}]]
  #endif
  /// 
  )cpp"






Comment at: unittests/clangd/XRefsTests.cpp:260
 
+TEST(DidChangeConfiguration, DifferentDeclaration) {
+  Annotations SourceAnnotations(R"cpp(

I'd move it to `ClangdTests.cpp`, generic `ClangdServer` tests usually go 
there. It's fine to `#include "Annotations.h"` there, too, even though it 
hasn't been used before.




Comment at: unittests/clangd/XRefsTests.cpp:271
+
+  MockCompilationDatabase CDB(/*UseRelPaths=*/true);
+  MockFSProvider FS;

Specifying `/*UseRelPath=*/true` is not necessary for this test, default value 
should do.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39571



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


[PATCH] D43246: [clangd] Assert path is absolute when assigning to URIForFile.

2018-02-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Protocol.h:52
 
 struct URIForFile {
+  URIForFile() = default;

ilya-biryukov wrote:
> sammccall wrote:
> > I don't like how the API changes here take us further away from the other 
> > structs in this file.
> > Why does this one enforce invariants, when the others don't?
> > 
> > If we do want to make this more "safe", I'd suggest making it look more 
> > like a URI string (since that's what its protocol role is), like:
> > 
> > ```
> > class LSPURI {
> >   LSPURI(StringRef URI) { assert if bad }
> >   static LSPURI ForFile(StringRef AbsPath) { assert if bad }
> >   operator string() { return URI::createFile(File).toString(); }
> >   StringRef file() { return AbsFile; }
> >   operator bool() { return !File.empty(); } 
> >   // move/copy constructor/assignment defaulted
> > 
> >  private:
> >   string AbsFile;
> > }
> > ```
> > 
> > But the approach Eric suggested does seem promising: more consistent with 
> > how we handle invariants in protocol structs.
> I've updated `URIForFile` to follow the interface you proposed. (Instead of 
> `operator string()` we have `uri()`, but everything else is there). Haven't 
> changed the name yet, happy to do it to.
> 
> > Why does this one enforce invariants, when the others don't?
> It seems useful to catch misbehaving code as early as possible. What are the 
> other invariants that could be useful?
> 
> > But the approach Eric suggested does seem promising: more consistent with 
> > how we handle invariants in protocol structs.
> I agree with Eric's approach, I wasn't trying to fix that specific bug with 
> this commit.
> 
> I'm trying to argue that we should check for non-absolute paths as early as 
> possible and fail with assertions to make writing code easier in the future. 
> Do you agree that would be useful or make we shouldn't do it?
> 
> 
I agree that this change would help debugging, so I don't really have 
objection. I'll leave approval to Sam though, as he had some suggestions.

I wonder if we want to make the assertion more aggressive. Currently, this only 
helps with assertion on. Would it make sense to also check this in production 
code and provide useful error message so that it would be easier for us to spot 
the problem when users report a bug? 



Comment at: clangd/Protocol.h:57
+  /// Retrieves absolute path to the file.
+  PathRef getFile() const { return File; }
+

nit: I like `file()` that Sam suggested a bit more. 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43246



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


[PATCH] D43120: [clang-tidy] New checker for exceptions that are created but not thrown

2018-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


https://reviews.llvm.org/D43120



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


r325120 - [AST] Refine the condition for element-dependent array fillers

2018-02-14 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Wed Feb 14 05:10:35 2018
New Revision: 325120

URL: http://llvm.org/viewvc/llvm-project?rev=325120&view=rev
Log:
[AST] Refine the condition for element-dependent array fillers

This patch fixes clang to not consider braced initializers for
aggregate elements of arrays to be potentially dependent on the
indices of the initialized elements. Resolves bug 18978:
initialize a large static array = clang oom?
https://bugs.llvm.org/show_bug.cgi?id=18978

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

Added:
cfe/trunk/test/SemaCXX/large-array-init.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=325120&r1=325119&r2=325120&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 14 05:10:35 2018
@@ -48,6 +48,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "exprconstant"
+
 using namespace clang;
 using llvm::APSInt;
 using llvm::APFloat;
@@ -6780,6 +6782,22 @@ static bool EvaluateArray(const Expr *E,
   return ArrayExprEvaluator(Info, This, Result).Visit(E);
 }
 
+// Return true iff the given array filler may depend on the element index.
+static bool MaybeElementDependentArrayFiller(const Expr *FillerExpr) {
+  // For now, just whitelist non-class value-initialization and initialization
+  // lists comprised of them.
+  if (isa(FillerExpr))
+return false;
+  if (const InitListExpr *ILE = dyn_cast(FillerExpr)) {
+for (unsigned I = 0, E = ILE->getNumInits(); I != E; ++I) {
+  if (MaybeElementDependentArrayFiller(ILE->getInit(I)))
+return true;
+}
+return false;
+  }
+  return true;
+}
+
 bool ArrayExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(E->getType());
   if (!CAT)
@@ -6809,10 +6827,13 @@ bool ArrayExprEvaluator::VisitInitListEx
   const Expr *FillerExpr = E->hasArrayFiller() ? E->getArrayFiller() : nullptr;
 
   // If the initializer might depend on the array index, run it for each
-  // array element. For now, just whitelist non-class value-initialization.
-  if (NumEltsToInit != NumElts && !isa(FillerExpr))
+  // array element.
+  if (NumEltsToInit != NumElts && MaybeElementDependentArrayFiller(FillerExpr))
 NumEltsToInit = NumElts;
 
+  DEBUG(llvm::dbgs() << "The number of elements to initialize: " <<
+NumEltsToInit << ".\n");
+
   Result = APValue(APValue::UninitArray(), NumEltsToInit, NumElts);
 
   // If the array was previously zero-initialized, preserve the

Added: cfe/trunk/test/SemaCXX/large-array-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/large-array-init.cpp?rev=325120&view=auto
==
--- cfe/trunk/test/SemaCXX/large-array-init.cpp (added)
+++ cfe/trunk/test/SemaCXX/large-array-init.cpp Wed Feb 14 05:10:35 2018
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -S -o %t.ll -mllvm -debug-only=exprconstant %s 2>&1 | \
+// RUN: FileCheck %s
+
+struct S { int i; };
+
+static struct S arr[1] = {{ 0 }};
+// CHECK: The number of elements to initialize: 1.
+
+struct S *foo() { return arr; }


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


[PATCH] D43187: [AST] Refine the condition for element-dependent array fillers

2018-02-14 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325120: [AST] Refine the condition for element-dependent 
array fillers (authored by kosarev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43187?vs=133846&id=134200#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43187

Files:
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/test/SemaCXX/large-array-init.cpp


Index: cfe/trunk/test/SemaCXX/large-array-init.cpp
===
--- cfe/trunk/test/SemaCXX/large-array-init.cpp
+++ cfe/trunk/test/SemaCXX/large-array-init.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -S -o %t.ll -mllvm -debug-only=exprconstant %s 2>&1 | \
+// RUN: FileCheck %s
+
+struct S { int i; };
+
+static struct S arr[1] = {{ 0 }};
+// CHECK: The number of elements to initialize: 1.
+
+struct S *foo() { return arr; }
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -48,6 +48,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "exprconstant"
+
 using namespace clang;
 using llvm::APSInt;
 using llvm::APFloat;
@@ -6780,6 +6782,22 @@
   return ArrayExprEvaluator(Info, This, Result).Visit(E);
 }
 
+// Return true iff the given array filler may depend on the element index.
+static bool MaybeElementDependentArrayFiller(const Expr *FillerExpr) {
+  // For now, just whitelist non-class value-initialization and initialization
+  // lists comprised of them.
+  if (isa(FillerExpr))
+return false;
+  if (const InitListExpr *ILE = dyn_cast(FillerExpr)) {
+for (unsigned I = 0, E = ILE->getNumInits(); I != E; ++I) {
+  if (MaybeElementDependentArrayFiller(ILE->getInit(I)))
+return true;
+}
+return false;
+  }
+  return true;
+}
+
 bool ArrayExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(E->getType());
   if (!CAT)
@@ -6809,10 +6827,13 @@
   const Expr *FillerExpr = E->hasArrayFiller() ? E->getArrayFiller() : nullptr;
 
   // If the initializer might depend on the array index, run it for each
-  // array element. For now, just whitelist non-class value-initialization.
-  if (NumEltsToInit != NumElts && !isa(FillerExpr))
+  // array element.
+  if (NumEltsToInit != NumElts && MaybeElementDependentArrayFiller(FillerExpr))
 NumEltsToInit = NumElts;
 
+  DEBUG(llvm::dbgs() << "The number of elements to initialize: " <<
+NumEltsToInit << ".\n");
+
   Result = APValue(APValue::UninitArray(), NumEltsToInit, NumElts);
 
   // If the array was previously zero-initialized, preserve the


Index: cfe/trunk/test/SemaCXX/large-array-init.cpp
===
--- cfe/trunk/test/SemaCXX/large-array-init.cpp
+++ cfe/trunk/test/SemaCXX/large-array-init.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -S -o %t.ll -mllvm -debug-only=exprconstant %s 2>&1 | \
+// RUN: FileCheck %s
+
+struct S { int i; };
+
+static struct S arr[1] = {{ 0 }};
+// CHECK: The number of elements to initialize: 1.
+
+struct S *foo() { return arr; }
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -48,6 +48,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "exprconstant"
+
 using namespace clang;
 using llvm::APSInt;
 using llvm::APFloat;
@@ -6780,6 +6782,22 @@
   return ArrayExprEvaluator(Info, This, Result).Visit(E);
 }
 
+// Return true iff the given array filler may depend on the element index.
+static bool MaybeElementDependentArrayFiller(const Expr *FillerExpr) {
+  // For now, just whitelist non-class value-initialization and initialization
+  // lists comprised of them.
+  if (isa(FillerExpr))
+return false;
+  if (const InitListExpr *ILE = dyn_cast(FillerExpr)) {
+for (unsigned I = 0, E = ILE->getNumInits(); I != E; ++I) {
+  if (MaybeElementDependentArrayFiller(ILE->getInit(I)))
+return true;
+}
+return false;
+  }
+  return true;
+}
+
 bool ArrayExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(E->getType());
   if (!CAT)
@@ -6809,10 +6827,13 @@
   const Expr *FillerExpr = E->hasArrayFiller() ? E->getArrayFiller() : nullptr;
 
   // If the initializer might depend on the array index, run it for each
-  // array element. For now, just whitelist non-class value-initialization.
-  if (NumEltsToInit != NumElts && !isa(FillerExpr))
+  // array element.
+  if (NumEltsToInit != NumElts && MaybeElementDependentArrayFiller(FillerExpr))
 NumEltsToInit = NumElts;
 
+  DEBUG(llvm::dbgs() << "The number of elements to initialize: " <<
+NumEltsToInit << ".\n");
+
   Result = APValue(APValue::UninitArray(), NumEltsToInit, 

[PATCH] D43272: [clangd] Fix tracing now that spans lifetimes can overlap on a thread.

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

LG with a few NITs.




Comment at: clangd/Trace.cpp:133
+std::atomic EndTime; // Filled in by endSpan().
+std::string Name;
+const uint64_t TID;

Maybe make all fields except `EndTime` const?



Comment at: clangd/Trace.h:46
+  // The Context returned by beginSpan is active, but Args is not ready.
+  virtual void endSpan() {};
 

It feels awkward that `endSpan()` does not have any parameters explicitly 
connecting it to `beginSpan()`.
We could change `beginSpan()` to return a callback that would be called when 
`Span` ends instead, that would make the connection clear, albeit it's not very 
useful for `JSONTracer`.

Not sure we should change it, just thinking out loud :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43272



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


r325123 - [AST] Fix passing large-array-init.cpp on builds without asserts

2018-02-14 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Wed Feb 14 05:27:48 2018
New Revision: 325123

URL: http://llvm.org/viewvc/llvm-project?rev=325123&view=rev
Log:
[AST] Fix passing large-array-init.cpp on builds without asserts

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

Modified:
cfe/trunk/test/SemaCXX/large-array-init.cpp

Modified: cfe/trunk/test/SemaCXX/large-array-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/large-array-init.cpp?rev=325123&r1=325122&r2=325123&view=diff
==
--- cfe/trunk/test/SemaCXX/large-array-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/large-array-init.cpp Wed Feb 14 05:27:48 2018
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -S -o %t.ll -mllvm -debug-only=exprconstant %s 2>&1 | \
 // RUN: FileCheck %s
+// REQUIRES: asserts
 
 struct S { int i; };
 


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


[PATCH] D43089: clang: Add ARCTargetInfo

2018-02-14 Thread Tatyana Krasnukha via Phabricator via cfe-commits
tatyana-krasnukha added a comment.

Sorry, =default is not applicable in these cases, of course.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:8123
+public:
+  ARCABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+

tatyana-krasnukha wrote:
> Better use '= default' instead of {}
> And you even may use inheriting constructor here
Here should be inheriting of base class constructor:
```
using DefaultABIInfo::DefaultABIInfo;
```


https://reviews.llvm.org/D43089



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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2018-02-14 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

In https://reviews.llvm.org/D39571#1007291, @ilya-biryukov wrote:

> It looks like a bug in the preamble handling. (It does not check if macros 
> were redefined).
>  You can workaround that by making sure the preamble ends before your code 
> starts (preamble only captures preprocessor directives, so any C++ decl will 
> end it):
>
> Annotations SourceAnnotations(R"cpp(
>   int avoid_preamble;
>  
>   #ifndef MACRO
>   $before[[static void bob() {}]]
>   #else
>   $after[[static void bob() {}]]
>   #endif
>   /// 
>   )cpp"
>


Ah ok, indeed this test now works when I add this.

The other test I am working on (at the bottom of the file) acts weird, even if 
I add `int avoid_preamble`.  The idea of the test is:

1. Set -DWITH_ERROR=1 in the compile commands database
2. Add the document, expect one error diagnostic
3. Unset WITH_ERROR in the compile commands database
4. Reparse the file, expect no error diagnostic

If I do it in this order, I get one diagnostic both times, when I don't expect 
one the second time the file is parsed.  But if I do it the other way (first 
parse with no errors, second parse with an error), it works fine.




Comment at: unittests/clangd/XRefsTests.cpp:260
 
+TEST(DidChangeConfiguration, DifferentDeclaration) {
+  Annotations SourceAnnotations(R"cpp(

ilya-biryukov wrote:
> I'd move it to `ClangdTests.cpp`, generic `ClangdServer` tests usually go 
> there. It's fine to `#include "Annotations.h"` there, too, even though it 
> hasn't been used before.
> 
Ok.  I put it there for rapid prototyping, but I also though it didn't really 
belong there.



Comment at: unittests/clangd/XRefsTests.cpp:271
+
+  MockCompilationDatabase CDB(/*UseRelPaths=*/true);
+  MockFSProvider FS;

ilya-biryukov wrote:
> Specifying `/*UseRelPath=*/true` is not necessary for this test, default 
> value should do.
Ok.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39571



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


[PATCH] D41880: Adding nocf_check attribute for cf-protection fine tuning

2018-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

One thing I notice is that GCC trunk requires passing the `-fcf-protection` 
flag in order to enable the attribute. Do we wish to do the same?




Comment at: include/clang/Basic/Attr.td:2089
+def AnyX86NoCfCheck : InheritableAttr, TargetSpecificAttr{
+  let Spellings = [GCC<"nocf_check">];
+  let Documentation = [AnyX86NoCfCheckDocs];

oren_ben_simhon wrote:
> aaron.ballman wrote:
> > This attribute doesn't appear to be supported by GCC. Did you mean to use 
> > the Clang spelling instead?
> Attribute documentation can be found here:
> https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes
> 
Ah, it was hiding in there -- my apologies!



Comment at: lib/Sema/SemaDeclAttr.cpp:1990
 
-bool Sema::CheckNoReturnAttr(const AttributeList &Attrs) {
-  if (!checkAttributeNumArgs(*this, Attrs, 0)) {
-Attrs.setInvalid();
+static void handleNoCfCheckAttr(Sema &S, Decl *D, const AttributeList &attr) {
+  if (S.CheckAttrTarget(attr) || S.CheckAttrNoArgs(attr))

aaron.ballman wrote:
> `attr` doesn't follow the proper naming conventions.
Please don't name the parameter variable after a type -- that can confuse some 
editors.



Comment at: lib/Sema/SemaDeclAttr.cpp:2007
+
+bool Sema::CheckAttrNoArgs(const AttributeList &Attr) {
+  if (!checkAttributeNumArgs(*this, Attr, 0)) {

oren_ben_simhon wrote:
> craig.topper wrote:
> > Wy did this get renamed?
> To reuse existing code. The same check is performed in several attributes so 
> instead of writing this block for every attribute i only call this function.
I think this may be the wrong approach -- this code seems like it should be 
handled automatically in `handleCommonAttributeFeatures()`. We already check 
whether the attribute appertains to its subjects and other table-gennable 
predicate checks, and this seems like it would be another instance of that kind 
of situation.

I think you need to retain this function (because it's called for type 
attributes, which don't have automated checking yet), but call it from 
`handleCommonAttributeFeatures()` rather than call it manually.



Comment at: lib/Sema/SemaDeclAttr.cpp:1968-1969
 
-  if (S.CheckNoReturnAttr(Attrs))
+  if (S.CheckAttrNoArgs(Attrs))
 return;
 

I think this can be removed entirely -- it should be handled automatically by 
the common handler (double-check that there's test coverage for it).



Comment at: lib/Sema/SemaDeclAttr.cpp:1983
 const AttributeList &Attr) {
-  if (S.CheckNoCallerSavedRegsAttr(Attr))
+  if (S.CheckAttrTarget(Attr) || S.CheckAttrNoArgs(Attr))
 return;

I think you can drop the `CheckAttrNoArgs()` call from here as well. And once 
`CheckAttrTarget()` is moved to the common handler, this function can also be 
replaced by a call to `handleSimpleAttribute<>()`



Comment at: lib/Sema/SemaDeclAttr.cpp:1990
 
-bool Sema::CheckNoReturnAttr(const AttributeList &Attrs) {
-  if (!checkAttributeNumArgs(*this, Attrs, 0)) {
-Attrs.setInvalid();
+static void handleNoCfCheckAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  if (S.CheckAttrTarget(Attr))

Once you move the target check into the common predicate function, this 
function can go away and you can use  `handleSimpleAttribute<>()` instead.



Comment at: test/Sema/attr-nocf_check.c:18-20
+  FuncPointerWithNoCfCheck fNoCfCheck = f; // no-warning
+  (*fNoCfCheck)();   // no-warning
+  f = fNoCfCheck;// no-warning

These are an error in GCC and I think we should match that behavior. 
https://godbolt.org/g/r3pf4X


Repository:
  rL LLVM

https://reviews.llvm.org/D41880



___
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

2018-02-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: unittests/clangd/XRefsTests.cpp:53
 
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(

malaperle wrote:
> ilya-biryukov wrote:
> > NIT: remove this class, use `IgnoreDiagnostics` from `Compiler.h` instead.
> It looks like IgnoreDiagnostics from Compiler.h implements DiagnosticConsumer 
> from Compiler.h, and not DiagnosticsConsumer from ClangdServer.h so that 
> wouldn't work.
You're right, I got confused, sorry. Disregard my comment.



Comment at: unittests/clangd/XRefsTests.cpp:245
+  const char *SourceContents = R"cpp(
+  #include "$2^invalid.h"
+  #include "^foo.h"

malaperle wrote:
> ilya-biryukov wrote:
> > Could we also add tests for corner cases: cursor before opening quote, 
> > cursor after the closing quote, cursor in the middle of `#include` token? 
> > (we shouldn't navigate anywhere in the middle of the #include token)
> > cursor before opening quote, cursor after the closing quote
> 
> I assume we don't want to navigate anywhere for these positions? I don't have 
> an opinion.
> 
> > (we shouldn't navigate anywhere in the middle of the #include token)
> 
> It did in CDT and I thought it worked nicely as it made it easier to click on 
> it. You can hold ctrl on the whole line and it underlined it (well except 
> trailing comments). But clients don't handle the spaces nicely (underline 
> between #include and file name) so I thought I'd work on the client first 
> before making the server do it. Anyhow, for now it shouldn't navigate indeed.
> > cursor before opening quote, cursor after the closing quote
>I assume we don't want to navigate anywhere for these positions? I don't have 
>an opinion.
I'd say we should navigate when the cursor is right before the opening quote. 
For the closing quote I don't have any opinions either :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38639



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


[PATCH] D36492: [time-report] Add preprocessor timer

2018-02-14 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added inline comments.



Comment at: include/clang/Lex/PreprocessorOptions.h:165
 public:
-  PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+  PreprocessorOptions() : PPTimer("preprocessor", "Preprocessing"),
+  UsePredefines(true),

modocache wrote:
> eduardo-elizondo wrote:
> > Should this be named "Lexing Time" or "Lexing" instead of "Preprocessing"?
> Good idea! Now that the timer's being started up in the `Preprocessor::Lex` 
> method, it probably should be named "Lexing". Alternatively, I could move 
> this into, say,` Lexer::Lex`. I guess there's not much of a distinction in 
> Clang between "lexing" and "preprocessing."
> 
> I had originally picked this name because that's what appears in `gcc 
> -ftime-report`, but I guess we don't need to keep the names the same.
Preprocessing does not means lexing. It includes much more, for example, file 
inclusion, include pathes elaboration, macros expansion, etc. We could merge 
all these parts or we could output the info for evey single piece. In any case 
I think we need a group of timers related to frontend (or maybe several groups: 
for pp, parser, Sema, codegen...). And maybe we need special switches to 
disable/enable the groups (-ftime-report could be used as some super switch for 
all of them). As result we need some repository of the timers and most probably 
this repository should be kept in PreprocessorOpts.

If there are no objections I can take this job on me and come up with new more 
general version of the patch. If it's OK then I'd like to collect the proposes 
about the required details of the time profile: what exactly we'd like to see 
in output? We have gcc output as an initial example but maybe we need more (or 
less) details?



Comment at: lib/Lex/Preprocessor.cpp:746
 void Preprocessor::Lex(Token &Result) {
+  llvm::TimeRegion(PPOpts->getTimer());
+

vsk wrote:
> MatzeB wrote:
> > modocache wrote:
> > > erik.pilkington wrote:
> > > > Doesn't this just start a timer and immediately end the timer? 
> > > > Shouldn't we do: `llvm::TimeRegion LexTime(PPOpts->getTimer())` so that 
> > > > the dtor gets called when this function returns and we track the time 
> > > > spent in this function?
> > > > 
> > > > Also: this is a pretty hot function, and it looks like TimeRegion does 
> > > > some non-trivial work if time is being tracked. Have you tried testing 
> > > > this on a big c++ file with and without this patch and seeing what the 
> > > > difference in compile time looks like?
> > > Ah, yes you're right! Sorry about that. Actually keeping the timer alive 
> > > for the duration of the method also reveals that the method is called 
> > > recursively, which causes an assert, because timers can't be started 
> > > twice.
> > > 
> > > Another spot in Clang works around this with a "reference counted" timer: 
> > > https://github.com/llvm-mirror/clang/blob/6ac9c51ede0a50cca13dd4ac03562c036f7a3f48/lib/CodeGen/CodeGenAction.cpp#L130-L134.
> > >  I have a more generic version of this "reference counting timer" that 
> > > I've been using for some of the other timers I've been adding; maybe I'll 
> > > use it here as well.
> > FWIF: I share Eriks concerns about compiletime. Timers are enabled in 
> > optimized builds, and querying them is not free. So putting one into a 
> > function that is called a lot and is time critical seems like a bad idea 
> > (do benchmarking to prove or disprove this!).
> The  timer is not started or queried unless -ftime-report is enabled. In the 
> common case the overhead amounts to one extra null-check. And when we're 
> collecting timing information, some performance degradation (say, within 5%) 
> should be acceptable. I agree that we should get a sense for what the 
> overhead is, but am not convinced that this should be a blocking issue.
Here we have more than "one extra null-check": we're dealing with 
constructor/destructor as well (and it's for every Lex()). I agree that it 
should be acceptable for us but we have to profile it (maybe we should not 
profile Lex() but something above it). 



https://reviews.llvm.org/D36492



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


[PATCH] D42545: [Sema] Classify conversions from enum to float as narrowing

2018-02-14 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping


https://reviews.llvm.org/D42545



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


[PATCH] D42693: [libcxx] Handle invalid escaped characters in POSIX regex

2018-02-14 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping


https://reviews.llvm.org/D42693



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


r325117 - [Sema] Fix decltype of static data members

2018-02-14 Thread Mikhail Maltsev via cfe-commits
Author: miyuki
Date: Wed Feb 14 03:34:25 2018
New Revision: 325117

URL: http://llvm.org/viewvc/llvm-project?rev=325117&view=rev
Log:
[Sema] Fix decltype of static data members

Summary:
According to the C++11 standard [dcl.type.simple]p4:
  The type denoted by decltype(e) is defined as follows:
  - if e is an unparenthesized id-expression or an unparenthesized
class member access (5.2.5), decltype(e) is the type of the entity
named by e.

Currently Clang handles the 'member access' case incorrectly for
static data members (decltype returns T& instead of T). This patch
fixes the issue.

Reviewers: faisalv, rsmith, rogfer01

Reviewed By: rogfer01

Subscribers: rogfer01, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=325117&r1=325116&r2=325117&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 14 03:34:25 2018
@@ -7868,8 +7868,9 @@ static QualType getDecltypeForExpr(Sema
 if (const ValueDecl *VD = dyn_cast(DRE->getDecl()))
   return VD->getType();
   } else if (const MemberExpr *ME = dyn_cast(E)) {
-if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl()))
-  return FD->getType();
+if (const ValueDecl *VD = ME->getMemberDecl())
+  if (isa(VD) || isa(VD))
+return VD->getType();
   } else if (const ObjCIvarRefExpr *IR = dyn_cast(E)) {
 return IR->getDecl()->getType();
   } else if (const ObjCPropertyRefExpr *PR = dyn_cast(E)) 
{

Modified: 
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp?rev=325117&r1=325116&r2=325117&view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp 
(original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp 
Wed Feb 14 03:34:25 2018
@@ -12,13 +12,18 @@ struct is_same {
 
 const int&& foo();
 int i;
-struct A { double x; };
+struct A {
+  double x;
+  static int y;
+};
 const A* a = new A();
 
 static_assert(is_same::value, "");
 static_assert(is_same::value, "");
 static_assert(is_samex), double>::value, "");
 static_assert(is_samex)), const double&>::value, "");
+static_assert(is_samey), int>::value, "");
+static_assert(is_samey)), int&>::value, "");
 static_assert(is_same(i)), int&&>::value, "");
 
 int f0(int); // expected-note{{possible target}}


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


[libcxx] r325087 - Fix incorrect indentation.

2018-02-14 Thread Bruce Mitchener via cfe-commits
Author: brucem
Date: Tue Feb 13 16:29:38 2018
New Revision: 325087

URL: http://llvm.org/viewvc/llvm-project?rev=325087&view=rev
Log:
Fix incorrect indentation.

Reviewers: mclow.lists

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/ios

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=325087&r1=325086&r2=325087&view=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Tue Feb 13 16:29:38 2018
@@ -670,7 +670,7 @@ protected:
 void set_rdbuf(basic_streambuf* __sb);
 private:
 basic_ostream* __tie_;
- mutable int_type __fill_;
+mutable int_type __fill_;
 };
 
 template 


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


[PATCH] D43290: clang-format: tweak formatting of variable initialization blocks

2018-02-14 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Typz added reviewers: krasimir, djasper, klimek.

This patch changes the behavior of PenaltyBreakBeforeFirstCallParameter
so that is does not apply when the brace comes after an assignment.

This way, variable initialization is wrapped more like an initializer
than like a function call, which seems more consistent with user
expectations.

With PenaltyBreakBeforeFirstCallParameter=200, this gives the following
code: (with Cpp11BracedListStyle=false)

Before :

  const std::unordered_map Something::MyHashTable =
  { { "a", 0 },
{ "b", 1 },
{ "c", 2 } };

After :

  const std::unordered_set Something::MyUnorderedSet = {
{ "a", 0 },
{ "b", 1 },
{ "c", 2 }
  };


Repository:
  rC Clang

https://reviews.llvm.org/D43290

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6650,6 +6650,15 @@
"};");
   verifyFormat("#define A {a, a},");
 
+  // Avoid breaking between equal sign and opening brace
+  FormatStyle avoidBreakingFirstArgument = getLLVMStyle();
+  avoidBreakingFirstArgument.PenaltyBreakBeforeFirstCallParameter = 200;
+  verifyFormat("const std::unordered_map MyHashTable = {\n"
+   "{\"a\", 0},\n"
+   "{\"b\", 1},\n"
+   "{\"c\", 2}};",
+   avoidBreakingFirstArgument);
+
   // Binpacking only if there is no trailing comma
   verifyFormat("const Aa a = {aa, bb,\n"
"  cc, dd};",
@@ -6806,6 +6815,15 @@
   verifyFormat("vector foo = { ::SomeGlobalFunction() };", ExtraSpaces);
   verifyFormat("const struct A a = { .a = 1, .b = 2 };", ExtraSpaces);
   verifyFormat("const struct A a = { [0] = 1, [1] = 2 };", ExtraSpaces);
+
+  // Avoid breaking between equal sign and opening brace
+  ExtraSpaces.PenaltyBreakBeforeFirstCallParameter = 200;
+  verifyFormat("const std::unordered_map MyHashTable = {\n"
+   "  { \"a\", 0 },\n"
+   "  { \"b\", 1 },\n"
+   "  { \"c\", 2 }\n"
+   "};",
+   ExtraSpaces);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
@@ -6867,6 +6885,14 @@
" 3, cc};",
getLLVMStyleWithColumns(60));
 
+  // Do not break between equal and opening brace.
+  FormatStyle avoidBreakingFirstArgument = getLLVMStyleWithColumns(43);
+  avoidBreakingFirstArgument.PenaltyBreakBeforeFirstCallParameter = 200;
+  avoidBreakingFirstArgument.ColumnLimit = 43;
+  verifyFormat("vector aa = {\n"
+   "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};",
+   avoidBreakingFirstArgument);
+
   // Trailing commas.
   verifyFormat("vector x = {\n"
"1, 1, 1, 1, 1, 1, 1, 1,\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2180,6 +2180,8 @@
   if (Left.opensScope()) {
 if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign)
   return 0;
+if (Left.Previous && Left.Previous->is(tok::equal))
+  return 19;
 return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter
: 19;
   }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6650,6 +6650,15 @@
"};");
   verifyFormat("#define A {a, a},");
 
+  // Avoid breaking between equal sign and opening brace
+  FormatStyle avoidBreakingFirstArgument = getLLVMStyle();
+  avoidBreakingFirstArgument.PenaltyBreakBeforeFirstCallParameter = 200;
+  verifyFormat("const std::unordered_map MyHashTable = {\n"
+   "{\"a\", 0},\n"
+   "{\"b\", 1},\n"
+   "{\"c\", 2}};",
+   avoidBreakingFirstArgument);
+
   // Binpacking only if there is no trailing comma
   verifyFormat("const Aa a = {aa, bb,\n"
"  cc, dd};",
@@ -6806,6 +6815,15 @@
   verifyFormat("vector foo = { ::SomeGlobalFunction() };", ExtraSpaces);
   verifyFormat("const struct A a = { .a = 1, .b = 2 };", ExtraSpaces);
   verifyFormat("const struct A a = { [0] = 1, [1] = 2 };", ExtraSpaces);
+
+  // Avoid breaking between equal sign and opening brace
+  ExtraSpaces.Pe

[clang-tools-extra] r325132 - [clangd] Fix data race in ClangdThreadingTest.StressTest

2018-02-14 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 14 07:19:20 2018
New Revision: 325132

URL: http://llvm.org/viewvc/llvm-project?rev=325132&view=rev
Log:
[clangd] Fix data race in ClangdThreadingTest.StressTest

Prior to this patch, same instance of VFS was shared for concurrent
processing of the files in ClangdThreadingTest.StressTest.

It caused a data race as the same instance of InMemoryFileSystem was
mutated from multiple threads using setCurrentWorkingDirectory().

Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=325132&r1=325131&r2=325132&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Wed Feb 14 
07:19:20 2018
@@ -76,22 +76,6 @@ private:
   VFSTag LastVFSTag = VFSTag();
 };
 
-class ConstantFSProvider : public FileSystemProvider {
-public:
-  ConstantFSProvider(IntrusiveRefCntPtr FS,
- VFSTag Tag = VFSTag())
-  : FS(std::move(FS)), Tag(std::move(Tag)) {}
-
-  Tagged>
-  getTaggedFileSystem(PathRef File) override {
-return make_tagged(FS, Tag);
-  }
-
-private:
-  IntrusiveRefCntPtr FS;
-  VFSTag Tag;
-};
-
 /// Replaces all patterns of the form 0x123abc with spaces
 std::string replacePtrsInDump(std::string const &Dump) {
   llvm::Regex RE("0x[0-9a-fA-F]+");
@@ -500,11 +484,10 @@ int d;
 FilePaths.push_back(getVirtualTestFilePath(std::string("Foo") +
std::to_string(I) + ".cpp"));
   // Mark all of those files as existing.
-  llvm::StringMap FileContents;
+  MockFSProvider FS;
   for (auto &&FilePath : FilePaths)
-FileContents[FilePath] = "";
+FS.Files[FilePath] = "";
 
-  ConstantFSProvider FS(buildTestFS(FileContents));
 
   struct FileStat {
 unsigned HitsWithoutErrors = 0;


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


r325133 - Revert r324991 "Fix for PR32992. Static const classes not exported."

2018-02-14 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb 14 07:19:46 2018
New Revision: 325133

URL: http://llvm.org/viewvc/llvm-project?rev=325133&view=rev
Log:
Revert r324991 "Fix for PR32992. Static const classes not exported."

This broke the Chromium build on Windows; see https://crbug.com/812231

> Fix for PR32992. Static const classes not exported.
>
> Patch by zahiraam!
>
> Differential Revision: https://reviews.llvm.org/D42968

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=325133&r1=325132&r2=325133&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Feb 14 07:19:46 2018
@@ -5476,7 +5476,7 @@ static void CheckAbstractClassUsage(Abst
   }
 }
 
-static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
+static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class) {
   Attr *ClassAttr = getDLLAttr(Class);
   if (!ClassAttr)
 return;
@@ -5491,16 +5491,6 @@ static void ReferenceDllExportedMembers(
 return;
 
   for (Decl *Member : Class->decls()) {
-// Defined static variables that are members of an exported base
-// class must be marked export too. Push them to implicit instantiation
-// queue.
-auto *VD = dyn_cast(Member);
-if (VD && Member->getAttr() &&
-VD->getStorageClass() == SC_Static &&
-TSK == TSK_ImplicitInstantiation)
-  S.PendingLocalImplicitInstantiations.push_back(
-  std::make_pair(VD, VD->getLocation()));
-
 auto *MD = dyn_cast(Member);
 if (!MD)
   continue;
@@ -10912,12 +10902,12 @@ void Sema::ActOnFinishCXXNonNestedClass(
 
 void Sema::referenceDLLExportedClassMethods() {
   if (!DelayedDllExportClasses.empty()) {
-// Calling ReferenceDllExportedMembers might cause the current function to
+// Calling ReferenceDllExportedMethods might cause the current function to
 // be called again, so use a local copy of DelayedDllExportClasses.
 SmallVector WorkList;
 std::swap(DelayedDllExportClasses, WorkList);
 for (CXXRecordDecl *Class : WorkList)
-  ReferenceDllExportedMembers(*this, Class);
+  ReferenceDllExportedMethods(*this, Class);
   }
 }
 

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=325133&r1=325132&r2=325133&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Wed Feb 14 07:19:46 2018
@@ -28,7 +28,6 @@ struct External { int v; };
 
 // The vftable for struct W is comdat largest because we have RTTI.
 // M32-DAG: $"\01??_7W@@6B@" = comdat largest
-// M32-DAG: $"\01?smember@?$Base@H@PR32992@@0HA" = comdat any
 
 
 
//===--===//
@@ -978,21 +977,3 @@ class __declspec(dllexport) ACE_Service_
 // MSVC2015-DAG: define weak_odr dllexport 
{{.+}}ACE_Service_Object@@Q{{.+}}@$$Q
 // The declarations should not be exported.
 // MSVC2013-NOT: define weak_odr dllexport 
{{.+}}ACE_Service_Object@@Q{{.+}}@$$Q
-
-namespace PR32992 {
-// Static data members of a instantiated base class should be exported.
-template 
-class Base {
-  virtual void myfunc() {}
-  static int smember;
-};
-// MS-DAG:  @"\01?smember@?$Base@H@PR32992@@0HA" = weak_odr dllexport global 
i32 77, comdat, align 4
-template  int Base::smember = 77;
-template 
-class __declspec(dllexport) Derived2 : Base {
-  void myfunc() {}
-};
-class Derived : public Derived2 {
-  void myfunc() {}
-};
-}  // namespace PR32992


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


[PATCH] D43204: [OpenMP] Fix trailing space when printing pragmas

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

LG


https://reviews.llvm.org/D43204



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


Re: r324991 - Fix for PR32992. Static const classes not exported.

2018-02-14 Thread Hans Wennborg via cfe-commits
I ended up having to revert this in r325133 as it broke the Chromium
build. Please see
https://bugs.chromium.org/p/chromium/issues/detail?id=812231#c1 for a
reproducer.

On Tue, Feb 13, 2018 at 10:19 AM, Hans Wennborg via cfe-commits
 wrote:
> Author: hans
> Date: Tue Feb 13 01:19:43 2018
> New Revision: 324991
>
> URL: http://llvm.org/viewvc/llvm-project?rev=324991&view=rev
> Log:
> Fix for PR32992. Static const classes not exported.
>
> Patch by zahiraam!
>
> Differential Revision: https://reviews.llvm.org/D42968
>
> Modified:
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/CodeGenCXX/dllexport.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=324991&r1=324990&r2=324991&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Feb 13 01:19:43 2018
> @@ -5476,7 +5476,7 @@ static void CheckAbstractClassUsage(Abst
>}
>  }
>
> -static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class) {
> +static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
>Attr *ClassAttr = getDLLAttr(Class);
>if (!ClassAttr)
>  return;
> @@ -5491,6 +5491,16 @@ static void ReferenceDllExportedMethods(
>  return;
>
>for (Decl *Member : Class->decls()) {
> +// Defined static variables that are members of an exported base
> +// class must be marked export too. Push them to implicit instantiation
> +// queue.
> +auto *VD = dyn_cast(Member);
> +if (VD && Member->getAttr() &&
> +VD->getStorageClass() == SC_Static &&
> +TSK == TSK_ImplicitInstantiation)
> +  S.PendingLocalImplicitInstantiations.push_back(
> +  std::make_pair(VD, VD->getLocation()));
> +
>  auto *MD = dyn_cast(Member);
>  if (!MD)
>continue;
> @@ -10902,12 +10912,12 @@ void Sema::ActOnFinishCXXNonNestedClass(
>
>  void Sema::referenceDLLExportedClassMethods() {
>if (!DelayedDllExportClasses.empty()) {
> -// Calling ReferenceDllExportedMethods might cause the current function 
> to
> +// Calling ReferenceDllExportedMembers might cause the current function 
> to
>  // be called again, so use a local copy of DelayedDllExportClasses.
>  SmallVector WorkList;
>  std::swap(DelayedDllExportClasses, WorkList);
>  for (CXXRecordDecl *Class : WorkList)
> -  ReferenceDllExportedMethods(*this, Class);
> +  ReferenceDllExportedMembers(*this, Class);
>}
>  }
>
>
> Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=324991&r1=324990&r2=324991&view=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Tue Feb 13 01:19:43 2018
> @@ -28,6 +28,7 @@ struct External { int v; };
>
>  // The vftable for struct W is comdat largest because we have RTTI.
>  // M32-DAG: $"\01??_7W@@6B@" = comdat largest
> +// M32-DAG: $"\01?smember@?$Base@H@PR32992@@0HA" = comdat any
>
>
>  
> //===--===//
> @@ -977,3 +978,21 @@ class __declspec(dllexport) ACE_Service_
>  // MSVC2015-DAG: define weak_odr dllexport 
> {{.+}}ACE_Service_Object@@Q{{.+}}@$$Q
>  // The declarations should not be exported.
>  // MSVC2013-NOT: define weak_odr dllexport 
> {{.+}}ACE_Service_Object@@Q{{.+}}@$$Q
> +
> +namespace PR32992 {
> +// Static data members of a instantiated base class should be exported.
> +template 
> +class Base {
> +  virtual void myfunc() {}
> +  static int smember;
> +};
> +// MS-DAG:  @"\01?smember@?$Base@H@PR32992@@0HA" = weak_odr dllexport global 
> i32 77, comdat, align 4
> +template  int Base::smember = 77;
> +template 
> +class __declspec(dllexport) Derived2 : Base {
> +  void myfunc() {}
> +};
> +class Derived : public Derived2 {
> +  void myfunc() {}
> +};
> +}  // namespace PR32992
>
>
> ___
> 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] D40925: Add option -fkeep-static-consts

2018-02-14 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

I think we can use CodeGenModule::addUsedGlobal for this purpose. I noticed 
this is what attribute 'used' calls. I need to look into it though.


https://reviews.llvm.org/D40925



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


[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-02-14 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:9866
+  case AMDGPU::BI__builtin_amdgcn_ds_fmax: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 5; ++I)

Can the pointer argument address space be checked here?


Repository:
  rC Clang

https://reviews.llvm.org/D43281



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


[PATCH] D36492: [time-report] Add preprocessor timer

2018-02-14 Thread Brian Gesiak via Phabricator via cfe-commits
modocache abandoned this revision.
modocache added inline comments.



Comment at: include/clang/Lex/PreprocessorOptions.h:165
 public:
-  PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+  PreprocessorOptions() : PPTimer("preprocessor", "Preprocessing"),
+  UsePredefines(true),

avt77 wrote:
> modocache wrote:
> > eduardo-elizondo wrote:
> > > Should this be named "Lexing Time" or "Lexing" instead of "Preprocessing"?
> > Good idea! Now that the timer's being started up in the `Preprocessor::Lex` 
> > method, it probably should be named "Lexing". Alternatively, I could move 
> > this into, say,` Lexer::Lex`. I guess there's not much of a distinction in 
> > Clang between "lexing" and "preprocessing."
> > 
> > I had originally picked this name because that's what appears in `gcc 
> > -ftime-report`, but I guess we don't need to keep the names the same.
> Preprocessing does not means lexing. It includes much more, for example, file 
> inclusion, include pathes elaboration, macros expansion, etc. We could merge 
> all these parts or we could output the info for evey single piece. In any 
> case I think we need a group of timers related to frontend (or maybe several 
> groups: for pp, parser, Sema, codegen...). And maybe we need special switches 
> to disable/enable the groups (-ftime-report could be used as some super 
> switch for all of them). As result we need some repository of the timers and 
> most probably this repository should be kept in PreprocessorOpts.
> 
> If there are no objections I can take this job on me and come up with new 
> more general version of the patch. If it's OK then I'd like to collect the 
> proposes about the required details of the time profile: what exactly we'd 
> like to see in output? We have gcc output as an initial example but maybe we 
> need more (or less) details?
> If there are no objections I can take this job on me and come up with new 
> more general version of the patch. If it's OK then I'd like to collect the 
> proposes about the required details of the time profile: what exactly we'd 
> like to see in output? We have gcc output as an initial example but maybe we 
> need more (or less) details?

Yes, absolutely! This sounds fantastic, thank you for doing this work.

I'll abandon this diff so it doesn't clog up anyone else's review queues. 
Thanks again!


https://reviews.llvm.org/D36492



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


r325136 - [CUDA] Allow external variables in separate compilation

2018-02-14 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Feb 14 08:04:03 2018
New Revision: 325136

URL: http://llvm.org/viewvc/llvm-project?rev=325136&view=rev
Log:
[CUDA] Allow external variables in separate compilation

According to the CUDA Programming Guide this is prohibited in
whole program compilation mode. This makes sense because external
references cannot be satisfied in that mode anyway. However,
such variables are allowed in separate compilation mode which
is a valid use case.

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

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCUDA/extern-shared.cu

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325136&r1=325135&r2=325136&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Feb 14 08:04:03 2018
@@ -4112,7 +4112,8 @@ static void handleSharedAttr(Sema &S, De
   auto *VD = cast(D);
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
-  if (VD->hasExternalStorage() && !isa(VD->getType())) {
+  if (!S.getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
+  !isa(VD->getType())) {
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }

Modified: cfe/trunk/test/SemaCUDA/extern-shared.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/extern-shared.cu?rev=325136&r1=325135&r2=325136&view=diff
==
--- cfe/trunk/test/SemaCUDA/extern-shared.cu (original)
+++ cfe/trunk/test/SemaCUDA/extern-shared.cu Wed Feb 14 08:04:03 2018
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
 
+// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
+// These declarations are fine in separate compilation mode:
+// rdc-no-diagnostics
+
 #include "Inputs/cuda.h"
 
 __device__ void foo() {


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


[PATCH] D42923: [CUDA] Allow external variables in separate compilation

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325136: [CUDA] Allow external variables in separate 
compilation (authored by Hahnfeld, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42923?vs=132866&id=134230#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42923

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCUDA/extern-shared.cu


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4112,7 +4112,8 @@
   auto *VD = cast(D);
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
-  if (VD->hasExternalStorage() && !isa(VD->getType())) {
+  if (!S.getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
+  !isa(VD->getType())) {
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }
Index: test/SemaCUDA/extern-shared.cu
===
--- test/SemaCUDA/extern-shared.cu
+++ test/SemaCUDA/extern-shared.cu
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
 
+// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
+// These declarations are fine in separate compilation mode:
+// rdc-no-diagnostics
+
 #include "Inputs/cuda.h"
 
 __device__ void foo() {


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4112,7 +4112,8 @@
   auto *VD = cast(D);
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
-  if (VD->hasExternalStorage() && !isa(VD->getType())) {
+  if (!S.getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
+  !isa(VD->getType())) {
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }
Index: test/SemaCUDA/extern-shared.cu
===
--- test/SemaCUDA/extern-shared.cu
+++ test/SemaCUDA/extern-shared.cu
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
 
+// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
+// These declarations are fine in separate compilation mode:
+// rdc-no-diagnostics
+
 #include "Inputs/cuda.h"
 
 __device__ void foo() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42923: [CUDA] Allow external variables in separate compilation

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325136: [CUDA] Allow external variables in separate 
compilation (authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42923?vs=132866&id=134231#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42923

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/SemaCUDA/extern-shared.cu


Index: cfe/trunk/test/SemaCUDA/extern-shared.cu
===
--- cfe/trunk/test/SemaCUDA/extern-shared.cu
+++ cfe/trunk/test/SemaCUDA/extern-shared.cu
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
 
+// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
+// These declarations are fine in separate compilation mode:
+// rdc-no-diagnostics
+
 #include "Inputs/cuda.h"
 
 __device__ void foo() {
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -4112,7 +4112,8 @@
   auto *VD = cast(D);
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
-  if (VD->hasExternalStorage() && !isa(VD->getType())) {
+  if (!S.getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
+  !isa(VD->getType())) {
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }


Index: cfe/trunk/test/SemaCUDA/extern-shared.cu
===
--- cfe/trunk/test/SemaCUDA/extern-shared.cu
+++ cfe/trunk/test/SemaCUDA/extern-shared.cu
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
 
+// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
+// These declarations are fine in separate compilation mode:
+// rdc-no-diagnostics
+
 #include "Inputs/cuda.h"
 
 __device__ void foo() {
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -4112,7 +4112,8 @@
   auto *VD = cast(D);
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
-  if (VD->hasExternalStorage() && !isa(VD->getType())) {
+  if (!S.getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
+  !isa(VD->getType())) {
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43294: [clang-format] Recognize percents as format specifiers in protos

2018-02-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added a reviewer: djasper.
Herald added subscribers: cfe-commits, klimek.

Frequently, a percent in protos denotes a formatting specifier for string 
replacement.
Thus it is desirable to keep the percent together with what follows after it.


Repository:
  rC Clang

https://reviews.llvm.org/D43294

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -386,5 +386,9 @@
"  }\n"
"}");
 }
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+  verifyFormat("key: %d");
+}
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -432,5 +432,11 @@
"};");
 }
 
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+  verifyFormat("option (MyProto.options) = {\n"
+   "  key: %lld\n"
+   "};");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,9 @@
 if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) 
&&
 Right.isOneOf(tok::l_brace, tok::less))
   return !Style.Cpp11BracedListStyle;
+// A percent is probably part of a formatting specification, such as %lld.
+if (Left.is(tok::percent))
+  return false;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -386,5 +386,9 @@
"  }\n"
"}");
 }
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+  verifyFormat("key: %d");
+}
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -432,5 +432,11 @@
"};");
 }
 
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+  verifyFormat("option (MyProto.options) = {\n"
+   "  key: %lld\n"
+   "};");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,9 @@
 if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&
 Right.isOneOf(tok::l_brace, tok::less))
   return !Style.Cpp11BracedListStyle;
+// A percent is probably part of a formatting specification, such as %lld.
+if (Left.is(tok::percent))
+  return false;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 134235.
gtbercea added a comment.

Move unix specific test to new file.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c
  test/Driver/unix-openmp-offload-gpu.c


Index: test/Driver/unix-openmp-offload-gpu.c
===
--- /dev/null
+++ test/Driver/unix-openmp-offload-gpu.c
@@ -0,0 +1,21 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+// REQUIRES: linux
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=/tmp
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_60.bc
Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,14 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   env LIBRARY_PATH=""
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: Expect degraded performance on the target device due to 
missing 'libomptarget-nvptx-sm_20.bc' in LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -529,6 +529,36 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+if (char *env = ::getenv("LIBRARY_PATH")) {
+  StringRef CompilerPath = env;
+  while (!CompilerPath.empty()) {
+std::pair Split =
+CompilerPath.split(llvm::sys::EnvPathSeparator);
+LibraryPaths.push_back(Split.first);
+CompilerPath = Split.second;
+  }
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (std::string LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::remark_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -196,6 +196,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def remark_drv_omp_offload_target_missingbcruntime : Warning<
+  "Expect degraded performance on the target device due to missing '%0' in 
LIBRARY_PATH.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/unix-openmp-offload-gpu.c
===
--- /dev/null
+++ test/Driver/unix-openmp-offload-gpu.c
@@ -0,0 +1,21 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+// REQUIRES: linux
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// ###

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: test/Driver/unix-openmp-offload-gpu.c:15
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=/tmp

I don't see how that solves the problem of using `/tmp`?!?


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: test/Driver/openmp-offload-gpu.c:150
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   LIBRARY_PATH=/tmp %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \

Hahnfeld wrote:
> This should not be in `/tmp` but probably `%T`.
I don't think this would have worked since I need to create a file with a 
specific name in a folder somewhere and the separator is OS specific. I moved 
the test to a new file where I limit OS to linux.


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 134238.
gtbercea added a comment.

Fix tmp folder name.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c
  test/Driver/unix-openmp-offload-gpu.c


Index: test/Driver/unix-openmp-offload-gpu.c
===
--- /dev/null
+++ test/Driver/unix-openmp-offload-gpu.c
@@ -0,0 +1,21 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+// REQUIRES: linux
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch %t-dir/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=%t-dir
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_60.bc
Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,14 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   env LIBRARY_PATH=""
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: Expect degraded performance on the target device due to 
missing 'libomptarget-nvptx-sm_20.bc' in LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -529,6 +529,36 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+if (char *env = ::getenv("LIBRARY_PATH")) {
+  StringRef CompilerPath = env;
+  while (!CompilerPath.empty()) {
+std::pair Split =
+CompilerPath.split(llvm::sys::EnvPathSeparator);
+LibraryPaths.push_back(Split.first);
+CompilerPath = Split.second;
+  }
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (std::string LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::remark_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -196,6 +196,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def remark_drv_omp_offload_target_missingbcruntime : Warning<
+  "Expect degraded performance on the target device due to missing '%0' in 
LIBRARY_PATH.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/unix-openmp-offload-gpu.c
===
--- /dev/null
+++ test/Driver/unix-openmp-offload-gpu.c
@@ -0,0 +1,21 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+// REQUIRES: linux
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// ###

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: test/Driver/openmp-offload-gpu.c:150
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   LIBRARY_PATH=/tmp %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \

gtbercea wrote:
> Hahnfeld wrote:
> > This should not be in `/tmp` but probably `%T`.
> I don't think this would have worked since I need to create a file with a 
> specific name in a folder somewhere and the separator is OS specific. I moved 
> the test to a new file where I limit OS to linux.
I'm pretty sure `lit` takes care of this, there are a lot of other tests that 
do so.



Comment at: test/Driver/unix-openmp-offload-gpu.c:15
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=/tmp

Hahnfeld wrote:
> I don't see how that solves the problem of using `/tmp`?!?
(Interesting that this works with `%t`, the documentation mentions `%T` for a 
directory. But as other test cases do the same...)


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


RE: r325081 - Implement function attribute artificial

2018-02-14 Thread Keane, Erich via cfe-commits
Thanks for your comments Richard, I’ve added the author to this email so that 
she can take a look.

From: Richard Smith [mailto:rich...@metafoo.co.uk]
Sent: Tuesday, February 13, 2018 5:39 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r325081 - Implement function attribute artificial

On 13 February 2018 at 16:14, Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Tue Feb 13 16:14:07 2018
New Revision: 325081

URL: http://llvm.org/viewvc/llvm-project?rev=325081&view=rev
Log:
Implement function attribute artificial

Added support in clang for GCC function attribute 'artificial'. This attribute
is used to control stepping behavior of debugger with respect to inline
functions.

Patch By: Elizabeth Andrews (eandrews)

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


Added:
cfe/trunk/test/CodeGen/artificial.c
cfe/trunk/test/Sema/artificial.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 13 16:14:07 2018
@@ -111,6 +111,9 @@ def SharedVar : SubsetSubjecthasGlobalStorage()}], "global variables">;

+def InlineFunction : SubsetSubjectisInlineSpecified()}], "inline functions">;
+
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
 // type to be a class, not a definition. This makes it impossible to create an
 // attribute subject which accepts a Decl. Normally, this is not a problem,
@@ -588,6 +591,12 @@ def AlwaysInline : InheritableAttr {
   let Documentation = [Undocumented];
 }

+def Artificial : InheritableAttr {
+  let Spellings = [GCC<"artificial">];
+  let Subjects = SubjectList<[InlineFunction], WarnDiag>;
+  let Documentation = [ArtificialDocs];
+}
+
 def XRayInstrument : InheritableAttr {
   let Spellings = [Clang<"xray_always_instrument">,
Clang<"xray_never_instrument">];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Feb 13 16:14:07 2018
@@ -3273,3 +3273,13 @@ For more information see
 or `msvc documentation `_.
 }];
 }
+
+def ArtificialDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``artificial`` attribute is used with inline functions to treat the inline
+function as a unit while debugging. For more information see GCC_ 
documentation.

I find this to be hard to understand. What does "treat the inline function as a 
unit" actually mean? How about something like:

The ``artificial`` attribute can be applied to an inline function. If such a 
function is inlined, the attribute indicates that debuggers should associate 
the resulting instructions with the call site, rather than with the 
corresponding line within the inlined callee.

+
+.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html

If you still want to reference the GCC documentation, could you pick a newer 
version? :)

+  }];
+}

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 13 16:14:07 2018
@@ -3235,7 +3235,7 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);

-  if (!HasDecl || D->isImplicit()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 13 16:14:07 2018
@@ -6057,6 +6057,9 @@ static void ProcessDeclAttribute(Sema &S
   case AttributeList::AT_AlwaysInline:
 handleAlwaysInlineAttr(S, D, Attr);
 break;
+  case AttributeList::AT_Artificial:
+handleSimpleAttribute(S, D, Attr);
+break;
 

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: test/Driver/unix-openmp-offload-gpu.c:15
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=/tmp

Hahnfeld wrote:
> Hahnfeld wrote:
> > I don't see how that solves the problem of using `/tmp`?!?
> (Interesting that this works with `%t`, the documentation mentions `%T` for a 
> directory. But as other test cases do the same...)
%T works too I just tried it. Any preference as to which one to use?


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D43089: clang: Add ARCTargetInfo

2018-02-14 Thread Pete Couperus via Phabricator via cfe-commits
petecoup added a comment.

Hi Tatyana,

Thanks for taking a look here, and sorry for the delay.
I tried to follow the other target's usage patterns here.
I'm happy to update/change this...I'll add a couple of clang reviewers here to 
weigh in?


https://reviews.llvm.org/D43089



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


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: FreeBSD.cpp:139
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");

`-pthread`?


Repository:
  rC Clang

https://reviews.llvm.org/D43279



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


[PATCH] D43204: [OpenMP] Fix trailing space when printing pragmas

2018-02-14 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D43204#1007502, @ABataev wrote:

> LG


Alexey: Thanks for accepting. I do not have commit privileges. Would
you please commit for me?


https://reviews.llvm.org/D43204



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


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread David CARLIER via Phabricator via cfe-commits
devnexen added inline comments.



Comment at: FreeBSD.cpp:139
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");

krytarowski wrote:
> `-pthread`?
Did not seem needed maybe it s different for NetBSD ?


Repository:
  rC Clang

https://reviews.llvm.org/D43279



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


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: FreeBSD.cpp:139
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");

devnexen wrote:
> krytarowski wrote:
> > `-pthread`?
> Did not seem needed maybe it s different for NetBSD ?
```
   -pthread
   Adds support for multithreading with the pthreads library.  This
   option sets flags for both the preprocessor and linker.
```

From gcc(1). `-lpthread` looks like an alias, but `-pthread` is preferred. A 
system library does not need to be called `libpthread.so` or so, and it's not 
named this way on FreeBSD.


Repository:
  rC Clang

https://reviews.llvm.org/D43279



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


[PATCH] D36802: AMDGPU: Cleanup most of the macros

2018-02-14 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Ping.


https://reviews.llvm.org/D36802



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


[PATCH] D43279: Add Xray instrumentation compile-time/link-time support to FreeBSD

2018-02-14 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 134244.
devnexen added a comment.

Changing to pthread flag.


https://reviews.llvm.org/D43279

Files:
  lib/Driver/ToolChains/FreeBSD.cpp


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -117,6 +117,30 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain &TC, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-pthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+} 
+
 void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -235,6 +259,7 @@
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -249,6 +274,8 @@
 }
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+if (NeedsXRayDeps)
+  linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
 // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
 // the default system libraries. Just mimic this for now.
 if (Args.hasArg(options::OPT_pg))


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -117,6 +117,30 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
+  if (Args.hasFlag(options::OPT_fxray_instrument,
+   options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain &TC, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-pthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+} 
+
 void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -235,6 +259,7 @@
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -249,6 +274,8 @@
 }
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+if (NeedsXRayDeps)
+  linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
 // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
 // the default system libraries. Just mimic this for now.
 if (Args.hasArg(options::OPT_pg))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43294: [clang-format] Recognize percents as format specifiers in protos

2018-02-14 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Ok.. I guess ;)


Repository:
  rC Clang

https://reviews.llvm.org/D43294



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


[PATCH] D43290: clang-format: tweak formatting of variable initialization blocks

2018-02-14 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

What you are doing makes sense to me. My only hesitation is whether we should 
maybe completely disallow breaking between = and { when Cpp11BracedListStyle is 
false instead of solving this via penalties. Specifically,

 | 80 column limit
  SomethingReallyLong =
  { { a, b, c },
{ a, b, c } };

Might not be as good as

 | 80 column limit
  SomethingReallyLong<
  SomethingReallyLong> = {
{ a, b, c },
{ a, b, c }
  };

in this mode.




Comment at: unittests/Format/FormatTest.cpp:6889
+  // Do not break between equal and opening brace.
+  FormatStyle avoidBreakingFirstArgument = getLLVMStyleWithColumns(43);
+  avoidBreakingFirstArgument.PenaltyBreakBeforeFirstCallParameter = 200;

Upper camel case for variable names according to LLVM style.


Repository:
  rC Clang

https://reviews.llvm.org/D43290



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


r325145 - [OpenMP] Fix trailing space when printing pragmas, by Joel. E. Denny

2018-02-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 14 09:38:47 2018
New Revision: 325145

URL: http://llvm.org/viewvc/llvm-project?rev=325145&view=rev
Log:
[OpenMP] Fix trailing space when printing pragmas, by Joel. E. Denny

Summary:
-ast-print prints omp pragmas with a trailing space.  While this
behavior is likely of little concern to most users, surely it's
unintentional, and it's annoying for some source-level work I'm
pursuing.  This patch focuses on omp pragmas, but it also fixes
init_seg and loop hint pragmas because they share implementation.

The testing strategy here is to add usually just one '{{$}}' per
relevant -ast-print test file.  This seems to achieve good code
coverage.  However, this strategy is probably easy to forget as the
tests evolve.  That's probably fine as this fix is far from critical.
The main goal of the testing is to aid the initial review.

This patch also adds a fixme for "#pragma unroll", which prints as
"#pragma unroll (enable)", which is invalid syntax.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/test/Misc/ast-print-pragmas.cpp
cfe/trunk/test/OpenMP/atomic_ast_print.cpp
cfe/trunk/test/OpenMP/barrier_ast_print.cpp
cfe/trunk/test/OpenMP/cancel_ast_print.cpp
cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp
cfe/trunk/test/OpenMP/critical_ast_print.cpp
cfe/trunk/test/OpenMP/declare_reduction_ast_print.c
cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp
cfe/trunk/test/OpenMP/declare_simd_ast_print.c
cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp
cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp
cfe/trunk/test/OpenMP/flush_ast_print.cpp
cfe/trunk/test/OpenMP/for_ast_print.cpp
cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/master_ast_print.cpp
cfe/trunk/test/OpenMP/ordered_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp
cfe/trunk/test/OpenMP/sections_ast_print.cpp
cfe/trunk/test/OpenMP/simd_ast_print.cpp
cfe/trunk/test/OpenMP/single_ast_print.cpp
cfe/trunk/test/OpenMP/target_ast_print.cpp
cfe/trunk/test/OpenMP/target_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_ast_print.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_is_device_ptr_ast_print.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_simd_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_update_ast_print.cpp
cfe/trunk/test/OpenMP/task_ast_print.cpp
cfe/trunk/test/OpenMP/taskgroup_ast_print.cpp
cfe/trunk/test/OpenMP/taskloop_ast_print.cpp
cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp
cfe/trunk/test/OpenMP/taskwait_ast_print.cpp
cfe/trunk/test/OpenMP/taskyield_ast_print.cpp
cfe/trunk/test/OpenMP/teams_ast_print.cpp
cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp
cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp
cfe/trunk/test/PCH/pragma-loop.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/

[PATCH] D43204: [OpenMP] Fix trailing space when printing pragmas

2018-02-14 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325145: [OpenMP] Fix trailing space when printing pragmas, 
by Joel. E. Denny (authored by ABataev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43204?vs=133910&id=134249#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43204

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/test/Misc/ast-print-pragmas.cpp
  cfe/trunk/test/OpenMP/atomic_ast_print.cpp
  cfe/trunk/test/OpenMP/barrier_ast_print.cpp
  cfe/trunk/test/OpenMP/cancel_ast_print.cpp
  cfe/trunk/test/OpenMP/cancellation_point_ast_print.cpp
  cfe/trunk/test/OpenMP/critical_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_reduction_ast_print.c
  cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_simd_ast_print.c
  cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/flush_ast_print.cpp
  cfe/trunk/test/OpenMP/for_ast_print.cpp
  cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/master_ast_print.cpp
  cfe/trunk/test/OpenMP/ordered_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp
  cfe/trunk/test/OpenMP/sections_ast_print.cpp
  cfe/trunk/test/OpenMP/simd_ast_print.cpp
  cfe/trunk/test/OpenMP/single_ast_print.cpp
  cfe/trunk/test/OpenMP/target_ast_print.cpp
  cfe/trunk/test/OpenMP/target_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_ast_print.cpp
  
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp
  
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_simd_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_teams_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_update_ast_print.cpp
  cfe/trunk/test/OpenMP/task_ast_print.cpp
  cfe/trunk/test/OpenMP/taskgroup_ast_print.cpp
  cfe/trunk/test/OpenMP/taskloop_ast_print.cpp
  cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/taskwait_ast_print.cpp
  cfe/trunk/test/OpenMP/taskyield_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_distribute_parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp
  cfe/trunk/test/PCH/pragma-loop.cpp
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -1368,7 +1368,7 @@
   "OS << \"" << Prefix << Spelling;
 
 if (Variety == "Pragma") {
-  OS << " \";\n";
+  OS << "\";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
   OS << "OS << \"\\n\";";
   OS << "break;\n";
Index: cfe/trunk/lib/AST/StmtPrinter.cpp
===
--- cfe/trunk/lib/AST/StmtPrinter.cpp
+++ cfe/trunk/lib/AST/StmtPrinter.cpp
@@ -1030,36 +1030,36 @@
   for (ArrayRef::iterator I = Clauses.begin(), E = Clauses.end();
I != E; ++I)
 if (*I && !(*I)->isImplicit()) {
-  Printer.Visit(*I);
   OS << ' ';
+  Printer.Visit(*I);
 }
   OS

[PATCH] D43204: [OpenMP] Fix trailing space when printing pragmas

2018-02-14 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325145: [OpenMP] Fix trailing space when printing pragmas, 
by Joel. E. Denny (authored by ABataev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43204

Files:
  include/clang/Basic/Attr.td
  lib/AST/StmtPrinter.cpp
  test/Misc/ast-print-pragmas.cpp
  test/OpenMP/atomic_ast_print.cpp
  test/OpenMP/barrier_ast_print.cpp
  test/OpenMP/cancel_ast_print.cpp
  test/OpenMP/cancellation_point_ast_print.cpp
  test/OpenMP/critical_ast_print.cpp
  test/OpenMP/declare_reduction_ast_print.c
  test/OpenMP/declare_reduction_ast_print.cpp
  test/OpenMP/declare_simd_ast_print.c
  test/OpenMP/declare_simd_ast_print.cpp
  test/OpenMP/declare_target_ast_print.cpp
  test/OpenMP/distribute_ast_print.cpp
  test/OpenMP/distribute_dist_schedule_ast_print.cpp
  test/OpenMP/distribute_parallel_for_ast_print.cpp
  test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
  test/OpenMP/distribute_simd_ast_print.cpp
  test/OpenMP/flush_ast_print.cpp
  test/OpenMP/for_ast_print.cpp
  test/OpenMP/for_simd_ast_print.cpp
  test/OpenMP/master_ast_print.cpp
  test/OpenMP/ordered_ast_print.cpp
  test/OpenMP/parallel_ast_print.cpp
  test/OpenMP/parallel_for_ast_print.cpp
  test/OpenMP/parallel_for_simd_ast_print.cpp
  test/OpenMP/parallel_sections_ast_print.cpp
  test/OpenMP/sections_ast_print.cpp
  test/OpenMP/simd_ast_print.cpp
  test/OpenMP/single_ast_print.cpp
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_data_ast_print.cpp
  test/OpenMP/target_data_use_device_ptr_ast_print.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_is_device_ptr_ast_print.cpp
  test/OpenMP/target_parallel_ast_print.cpp
  test/OpenMP/target_parallel_for_ast_print.cpp
  test/OpenMP/target_parallel_for_is_device_ptr_ast_print.cpp
  test/OpenMP/target_parallel_for_simd_ast_print.cpp
  test/OpenMP/target_parallel_for_simd_is_device_ptr_ast_print.cpp
  test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
  test/OpenMP/target_simd_ast_print.cpp
  test/OpenMP/target_teams_ast_print.cpp
  test/OpenMP/target_teams_distribute_ast_print.cpp
  test/OpenMP/target_teams_distribute_parallel_for_ast_print.cpp
  test/OpenMP/target_teams_distribute_parallel_for_is_device_ptr_ast_print.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp
  
test/OpenMP/target_teams_distribute_parallel_for_simd_is_device_ptr_ast_print.cpp
  test/OpenMP/target_teams_distribute_simd_ast_print.cpp
  test/OpenMP/target_teams_distribute_simd_is_device_ptr_ast_print.cpp
  test/OpenMP/target_teams_is_device_ptr_ast_print.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/task_ast_print.cpp
  test/OpenMP/taskgroup_ast_print.cpp
  test/OpenMP/taskloop_ast_print.cpp
  test/OpenMP/taskloop_simd_ast_print.cpp
  test/OpenMP/taskwait_ast_print.cpp
  test/OpenMP/taskyield_ast_print.cpp
  test/OpenMP/teams_ast_print.cpp
  test/OpenMP/teams_distribute_ast_print.cpp
  test/OpenMP/teams_distribute_parallel_for_ast_print.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
  test/OpenMP/teams_distribute_simd_ast_print.cpp
  test/OpenMP/threadprivate_ast_print.cpp
  test/PCH/pragma-loop.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1368,7 +1368,7 @@
   "OS << \"" << Prefix << Spelling;
 
 if (Variety == "Pragma") {
-  OS << " \";\n";
+  OS << "\";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
   OS << "OS << \"\\n\";";
   OS << "break;\n";
Index: test/Misc/ast-print-pragmas.cpp
===
--- test/Misc/ast-print-pragmas.cpp
+++ test/Misc/ast-print-pragmas.cpp
@@ -4,7 +4,7 @@
 // FIXME: A bug in ParsedAttributes causes the order of the attributes to be
 // reversed. The checks are consequently in the reverse order below.
 
-// CHECK: #pragma clang loop interleave_count(8)
+// CHECK: #pragma clang loop interleave_count(8){{$}}
 // CHECK-NEXT: #pragma clang loop vectorize_width(4)
 
 void test(int *List, int Length) {
@@ -61,7 +61,7 @@
 
 #ifdef MS_EXT
 #pragma init_seg(compiler)
-// MS-EXT: #pragma init_seg (.CRT$XCC)
+// MS-EXT: #pragma init_seg (.CRT$XCC){{$}}
 // MS-EXT-NEXT: int x = 3 __declspec(thread);
 int __declspec(thread) x = 3;
 #endif //MS_EXT
Index: test/OpenMP/parallel_for_ast_print.cpp
===
--- test/OpenMP/parallel_for_ast_print.cpp
+++ test/OpenMP/parallel_for_ast_print.cpp
@@ -39,7 +39,7 @@
   }
 };
 
-// CHECK: #pragma omp parallel for private(this->a) private(this->a) private(T::a)
+// CHECK: #pragma omp parallel for private(this->a) private(this->a) private(T::a){{$}}
 // CHECK: #pragma omp parallel for private(this->a) pr

[PATCH] D43094: AMDGPU: Enable PIC by default for amdgcn

2018-02-14 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Ping.


https://reviews.llvm.org/D43094



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


RE: r325081 - Implement function attribute artificial

2018-02-14 Thread Andrews, Elizabeth via cfe-commits
Thanks Richard. I’ll update the documentation and submit a new patch for review.

Elizabeth

From: Keane, Erich
Sent: Wednesday, February 14, 2018 11:33 AM
To: Richard Smith ; Andrews, Elizabeth 

Cc: cfe-commits 
Subject: RE: r325081 - Implement function attribute artificial

Thanks for your comments Richard, I’ve added the author to this email so that 
she can take a look.

From: Richard Smith [mailto:rich...@metafoo.co.uk]
Sent: Tuesday, February 13, 2018 5:39 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r325081 - Implement function attribute artificial

On 13 February 2018 at 16:14, Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Tue Feb 13 16:14:07 2018
New Revision: 325081

URL: http://llvm.org/viewvc/llvm-project?rev=325081&view=rev
Log:
Implement function attribute artificial

Added support in clang for GCC function attribute 'artificial'. This attribute
is used to control stepping behavior of debugger with respect to inline
functions.

Patch By: Elizabeth Andrews (eandrews)

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


Added:
cfe/trunk/test/CodeGen/artificial.c
cfe/trunk/test/Sema/artificial.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 13 16:14:07 2018
@@ -111,6 +111,9 @@ def SharedVar : SubsetSubjecthasGlobalStorage()}], "global variables">;

+def InlineFunction : SubsetSubjectisInlineSpecified()}], "inline functions">;
+
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
 // type to be a class, not a definition. This makes it impossible to create an
 // attribute subject which accepts a Decl. Normally, this is not a problem,
@@ -588,6 +591,12 @@ def AlwaysInline : InheritableAttr {
   let Documentation = [Undocumented];
 }

+def Artificial : InheritableAttr {
+  let Spellings = [GCC<"artificial">];
+  let Subjects = SubjectList<[InlineFunction], WarnDiag>;
+  let Documentation = [ArtificialDocs];
+}
+
 def XRayInstrument : InheritableAttr {
   let Spellings = [Clang<"xray_always_instrument">,
Clang<"xray_never_instrument">];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Feb 13 16:14:07 2018
@@ -3273,3 +3273,13 @@ For more information see
 or `msvc documentation `_.
 }];
 }
+
+def ArtificialDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``artificial`` attribute is used with inline functions to treat the inline
+function as a unit while debugging. For more information see GCC_ 
documentation.

I find this to be hard to understand. What does "treat the inline function as a 
unit" actually mean? How about something like:

The ``artificial`` attribute can be applied to an inline function. If such a 
function is inlined, the attribute indicates that debuggers should associate 
the resulting instructions with the call site, rather than with the 
corresponding line within the inlined callee.

+
+.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html

If you still want to reference the GCC documentation, could you pick a newer 
version? :)

+  }];
+}

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 13 16:14:07 2018
@@ -3235,7 +3235,7 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);

-  if (!HasDecl || D->isImplicit()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325081&r1=325080&r2=325081&view=diff
==
--- cfe/trunk/lib/Se

[PATCH] D43298: [clang-format] Support repeated field lists in protos

2018-02-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

This patch adds support for list initialization of proto repeated fields:

  keys: [1, 2, 3]


Repository:
  rC Clang

https://reviews.llvm.org/D43298

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -31,14 +31,18 @@
 return *Result;
   }
 
-  static std::string format(llvm::StringRef Code) {
-FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
-Style.ColumnLimit = 60; // To make writing tests easier.
+  static std::string format(llvm::StringRef Code, const FormatStyle &Style) {
 return format(Code, 0, Code.size(), Style);
   }
 
+  static void verifyFormat(llvm::StringRef Code, const FormatStyle &Style) {
+EXPECT_EQ(Code.str(), format(test::messUp(Code), Style));
+  }
+
   static void verifyFormat(llvm::StringRef Code) {
-EXPECT_EQ(Code.str(), format(test::messUp(Code)));
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+Style.ColumnLimit = 60; // To make writing tests easier.
+verifyFormat(Code, Style);
   }
 };
 
@@ -386,5 +390,43 @@
"  }\n"
"}");
 }
+
+TEST_F(FormatTestTextProto, FormatsRepeatedListInitializers) {
+  verifyFormat("keys: []");
+  verifyFormat("keys: [ 1 ]");
+  verifyFormat("keys: [ 'ala', 'bala' ]");
+  verifyFormat("keys:\n"
+   "[ 'ala', 'bala', 'porto', 'kala', 'too', 'long', 'ng' ]");
+  verifyFormat("key: item\n"
+   "keys: [\n"
+   "  'ala',\n"
+   "  'bala',\n"
+   "  'porto',\n"
+   "  'kala',\n"
+   "  'too',\n"
+   "  'long',\n"
+   "  'long',\n"
+   "  'long'\n"
+   "]\n"
+   "key: item\n"
+   "msg {\n"
+   "  key: item\n"
+   "  keys: [\n"
+   "'ala',\n"
+   "'bala',\n"
+   "'porto',\n"
+   "'kala',\n"
+   "'too',\n"
+   "'long',\n"
+   "'long'\n"
+   "  ]\n"
+   "}\n"
+   "key: value"
+   );
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+  Style.ColumnLimit = 60; // To make writing tests easier.
+  Style.Cpp11BracedListStyle = true;
+  verifyFormat("keys: [1]", Style);
+}
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -432,5 +432,35 @@
"};");
 }
 
+TEST_F(FormatTestProto, FormatsRepeatedListInitializersInOptions) {
+  verifyFormat("option (MyProto.options) = {\n"
+   "  key: item\n"
+   "  keys: [\n"
+   "'ala',\n"
+   "'bala',\n"
+   "'porto',\n"
+   "'kala',\n"
+   "'too',\n"
+   "'long',\n"
+   "'long',\n"
+   "'long'\n"
+   "  ]\n"
+   "  key: [ item ]\n"
+   "  msg {\n"
+   "key: item\n"
+   "keys: [\n"
+   "  'ala',\n"
+   "  'bala',\n"
+   "  'porto',\n"
+   "  'kala',\n"
+   "  'too',\n"
+   "  'long',\n"
+   "  'long'\n"
+   "]\n"
+   "  }\n"
+   "  key: value\n"
+   "};");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -383,11 +383,18 @@
 //   }
 // }
 //
-// In the first case we want to spread the contents inside the square
-// braces; in the second we want to keep them inline.
+// or repeated fields (in options):
+//
+// option (Aaa.options) = {
+//   keys: [ 1, 2, 3 ]
+// }
+//
+// In the first and the third case we want to spread the contents inside
+// the square braces; in the second we want to keep them inline.
 Left->Type = TT_ArrayInitializerLSquare;
 if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
-tok::equal)) {
+tok::equal) &&
+!Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
   Left->Type = TT_ProtoExtensionLSquare;
   BindingInc

[libcxx] r325147 - Add a catch for std::length_error for the case where the string can't handle 2GB. (like say 32-bit big-endian)

2018-02-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb 14 10:05:25 2018
New Revision: 325147

URL: http://llvm.org/viewvc/llvm-project?rev=325147&view=rev
Log:
Add a catch for std::length_error for the case where the string can't handle 
2GB. (like say 32-bit big-endian)


Modified:

libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp?rev=325147&r1=325146&r2=325147&view=diff
==
--- 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
 Wed Feb 14 10:05:25 2018
@@ -32,12 +32,13 @@ int main()
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try {
 #endif
-   std::string str(2147483648, 'a');
-   SB sb;
-   sb.str(str);
-   assert(sb.pubpbase() <= sb.pubpptr());
+std::string str(2147483648, 'a');
+SB sb;
+sb.str(str);
+assert(sb.pubpbase() <= sb.pubpptr());
 #ifndef TEST_HAS_NO_EXCEPTIONS
-   }
-   catch (const std::bad_alloc &) {}
+}
+catch (const std::length_error &) {} // maybe the string can't take 2GB
+catch (const std::bad_alloc&) {} // maybe we don't have enough RAM
 #endif
 }


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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: test/Driver/unix-openmp-offload-gpu.c:15
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch /tmp/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=/tmp

gtbercea wrote:
> Hahnfeld wrote:
> > Hahnfeld wrote:
> > > I don't see how that solves the problem of using `/tmp`?!?
> > (Interesting that this works with `%t`, the documentation mentions `%T` for 
> > a directory. But as other test cases do the same...)
> %T works too I just tried it. Any preference as to which one to use?
No not really. The Clang tests aren't consistent so I don't think it matters...


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D43089: clang: Add ARCTargetInfo

2018-02-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8185
+unsigned FreeRegs) const {
+  // TODO: C++ ABI?
+  unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;

Please do go ahead and add the right logic for the C++ ABI in both this and the 
return-type classification.


https://reviews.llvm.org/D43089



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


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-14 Thread Matt Davis via Phabricator via cfe-commits
mattd updated this revision to Diff 134263.
mattd added a comment.

- Added a division by 2 instead of the shift, it reads clearer.
- Updated the associated comment, reflecting that we divide by two because the 
variables we are annotating are within the inner scope of the ranged-based for 
loop.


https://reviews.llvm.org/D42813

Files:
  include/clang/Sema/Scope.h
  lib/Sema/SemaStmt.cpp
  test/CodeGenCXX/debug-for-range-scope-hints.cpp
  test/CodeGenCXX/debug-info-scope.cpp
  test/CodeGenCXX/vla.cpp

Index: test/CodeGenCXX/vla.cpp
===
--- test/CodeGenCXX/vla.cpp
+++ test/CodeGenCXX/vla.cpp
@@ -68,8 +68,8 @@
 void test2(int b) {
   // CHECK-LABEL: define void {{.*}}test2{{.*}}(i32 %b)
   int varr[b];
-  // AMD: %__end = alloca i32*, align 8, addrspace(5)
-  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end to i32**
+  // AMD: %__end1 = alloca i32*, align 8, addrspace(5)
+  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end1 to i32**
   // get the address of %b by checking the first store that stores it 
   //CHECK: store i32 %b, i32* [[PTR_B:%.*]]
 
@@ -86,7 +86,7 @@
   //CHECK: [[VLA_SIZEOF:%.*]] = mul nuw i64 4, [[VLA_NUM_ELEMENTS_PRE]]
   //CHECK-NEXT: [[VLA_NUM_ELEMENTS_POST:%.*]] = udiv i64 [[VLA_SIZEOF]], 4
   //CHECK-NEXT: [[VLA_END_PTR:%.*]] = getelementptr inbounds i32, i32* {{%.*}}, i64 [[VLA_NUM_ELEMENTS_POST]]
-  //X64-NEXT: store i32* [[VLA_END_PTR]], i32** %__end
+  //X64-NEXT: store i32* [[VLA_END_PTR]], i32** %__end1
   //AMD-NEXT: store i32* [[VLA_END_PTR]], i32** [[END]]
   for (int d : varr) 0;
 }
@@ -94,8 +94,8 @@
 void test3(int b, int c) {
   // CHECK-LABEL: define void {{.*}}test3{{.*}}(i32 %b, i32 %c)
   int varr[b][c];
-  // AMD: %__end = alloca i32*, align 8, addrspace(5)
-  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end to i32**
+  // AMD: %__end1 = alloca i32*, align 8, addrspace(5)
+  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end1 to i32**
   // get the address of %b by checking the first store that stores it 
   //CHECK: store i32 %b, i32* [[PTR_B:%.*]]
   //CHECK-NEXT: store i32 %c, i32* [[PTR_C:%.*]]
Index: test/CodeGenCXX/debug-info-scope.cpp
===
--- test/CodeGenCXX/debug-info-scope.cpp
+++ test/CodeGenCXX/debug-info-scope.cpp
@@ -58,7 +58,7 @@
   }
 
   int x[] = {1, 2};
-  // CHECK: = !DILocalVariable(name: "__range"
+  // CHECK: = !DILocalVariable(name: "__range1"
   // CHECK-SAME:   scope: [[RANGE_FOR:![0-9]*]]
   // CHECK-NOT:line:
   // CHECK-SAME:   ){{$}}
Index: test/CodeGenCXX/debug-for-range-scope-hints.cpp
===
--- test/CodeGenCXX/debug-for-range-scope-hints.cpp
+++ test/CodeGenCXX/debug-for-range-scope-hints.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+struct vec {
+  using itr = int*;
+  itr begin() { return nullptr; }
+  itr end() { return nullptr; }
+};
+
+void test() {
+  vec as, bs, cs;
+
+  for (auto a : as)
+for (auto b : bs)
+  for (auto c : cs) {
+  }
+}
+
+// CHECK: define void @_Z4testv()
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE3:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN3:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END3:[0-9]+]]
+// CHECK: ![[RANGE1]] = !DILocalVariable(name: "__range1", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[BEGIN1]] = !DILocalVariable(name: "__begin1", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[END1]] = !DILocalVariable(name: "__end1",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[RANGE2]] = !DILocalVariable(name: "__range2",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[BEGIN2]] = !DILocalVariable(name: "__begin2", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[END2]] = !DILocalVariable(name: "__end2",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[RANGE3]] = !DILocalVariable(name: "__range3",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[BEGIN3]] = !DILocalVariable(name: "__begin3", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[END3]] = !DILocalVariable(name: "__end3", {{.*}}, flags: DIFlagArtificial)
Index: lib/Sema/SemaStmt.cpp

[PATCH] D43303: [Format] Fix for bug 35641

2018-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: rsmith, djasper.
kadircet added a project: clang.
Herald added a subscriber: cfe-commits.

Bug was caused due to comments at the start of scope. For a code like:

  int func() { //
int b;
int c;
  }

the comment at the first line gets IndentAndNestingLevel (1,1) whereas 
the following declarations get only (0,1) which prevents them from insertion
of a new scope. So, I changed the AlignTokenSequence to look at previous 
*non-comment* token when deciding whether to introduce a new scope into
stack or not.


Repository:
  rC Clang

https://reviews.llvm.org/D43303

Files:
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9449,6 +9449,14 @@
   "});\n",
   Alignment);
   Alignment.PointerAlignment = FormatStyle::PAS_Right;
+
+  // Bug 35641
+  Alignment.AlignConsecutiveDeclarations = true;
+  verifyFormat("int func() { //\n"
+   "  int b;\n"
+   "  int c;\n"
+   "}",
+   Alignment);
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -255,8 +255,14 @@
 Changes[ScopeStack.back()].indentAndNestingLevel())
   ScopeStack.pop_back();
 
+// Compare current token to previous non-comment token to ensure whether
+// it is in a deeper scope or not.
+unsigned PreviousNonComment = i - 1;
+while (PreviousNonComment > Start &&
+   Changes[PreviousNonComment].Tok->is(tok::comment))
+  PreviousNonComment--;
 if (i != Start && Changes[i].indentAndNestingLevel() >
-  Changes[i - 1].indentAndNestingLevel())
+  Changes[PreviousNonComment].indentAndNestingLevel())
   ScopeStack.push_back(i);
 
 bool InsideNestedScope = ScopeStack.size() != 0;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9449,6 +9449,14 @@
   "});\n",
   Alignment);
   Alignment.PointerAlignment = FormatStyle::PAS_Right;
+
+  // Bug 35641
+  Alignment.AlignConsecutiveDeclarations = true;
+  verifyFormat("int func() { //\n"
+   "  int b;\n"
+   "  int c;\n"
+   "}",
+   Alignment);
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -255,8 +255,14 @@
 Changes[ScopeStack.back()].indentAndNestingLevel())
   ScopeStack.pop_back();
 
+// Compare current token to previous non-comment token to ensure whether
+// it is in a deeper scope or not.
+unsigned PreviousNonComment = i - 1;
+while (PreviousNonComment > Start &&
+   Changes[PreviousNonComment].Tok->is(tok::comment))
+  PreviousNonComment--;
 if (i != Start && Changes[i].indentAndNestingLevel() >
-  Changes[i - 1].indentAndNestingLevel())
+  Changes[PreviousNonComment].indentAndNestingLevel())
   ScopeStack.push_back(i);
 
 bool InsideNestedScope = ScopeStack.size() != 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Seems good, thanks :)




Comment at: test/CodeGenCXX/debug-for-range-scope-hints.cpp:1
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+

maybe this test should be called debug-info-range-for-var-names? Just a 
thought. (debug-info seems to be the usual prefix here, and range-for is a 
common shortening of "range-based-for" I think (maybe I'm wrong & other tests 
don't use that naming?)? & 'hints' seems a bit vague as to what the test is 
about - when it's specifically about naming the variables)



Comment at: test/CodeGenCXX/debug-for-range-scope-hints.cpp:28-36
+// CHECK: ![[RANGE1]] = !DILocalVariable(name: "__range1", {{.*}}, flags: 
DIFlagArtificial)
+// CHECK: ![[BEGIN1]] = !DILocalVariable(name: "__begin1", {{.*}}, flags: 
DIFlagArtificial)
+// CHECK: ![[END1]] = !DILocalVariable(name: "__end1",  {{.*}}, flags: 
DIFlagArtificial)
+// CHECK: ![[RANGE2]] = !DILocalVariable(name: "__range2",  {{.*}}, flags: 
DIFlagArtificial)
+// CHECK: ![[BEGIN2]] = !DILocalVariable(name: "__begin2", {{.*}}, flags: 
DIFlagArtificial)
+// CHECK: ![[END2]] = !DILocalVariable(name: "__end2",  {{.*}}, flags: 
DIFlagArtificial)
+// CHECK: ![[RANGE3]] = !DILocalVariable(name: "__range3",  {{.*}}, flags: 
DIFlagArtificial)

I'd drop the ", {{.*}}, flags: DIFlagArtificial)" from these lines - since the 
name's the only bit that's really interesting to this test.


https://reviews.llvm.org/D42813



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


r325154 - [Modules] Add more language features to be used with requires-declaration

2018-02-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Feb 14 11:01:03 2018
New Revision: 325154

URL: http://llvm.org/viewvc/llvm-project?rev=325154&view=rev
Log:
[Modules] Add more language features to be used with requires-declaration

Features added: c99, c11, c17, cplusplus14 and cplusplus17.

rdar://problem/36328787
rdar://problem/36668431

Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
cfe/trunk/test/Modules/requires.m

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Wed Feb 14 11:01:03 2018
@@ -430,6 +430,21 @@ cplusplus
 cplusplus11
   C++11 support is available.
 
+cplusplus14
+  C++14 support is available.
+
+cplusplus17
+  C++17 support is available.
+
+c99
+  C99 support is available.
+
+c11
+  C11 support is available.
+
+c17
+  C17 support is available.
+
 freestanding
   A freestanding environment is available.
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Wed Feb 14 11:01:03 2018
@@ -78,6 +78,11 @@ static bool hasFeature(StringRef Feature
 .Case("coroutines", LangOpts.CoroutinesTS)
 .Case("cplusplus", LangOpts.CPlusPlus)
 .Case("cplusplus11", LangOpts.CPlusPlus11)
+.Case("cplusplus14", LangOpts.CPlusPlus14)
+.Case("cplusplus17", LangOpts.CPlusPlus17)
+.Case("c99", LangOpts.C99)
+.Case("c11", LangOpts.C11)
+.Case("c17", LangOpts.C17)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC1)

Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map 
(original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map Wed Feb 
14 11:01:03 2018
@@ -37,4 +37,22 @@ framework module DependsOnModule {
   export *
 }
   }
+  explicit module CXX11 {
+requires cplusplus11
+  }
+  explicit module CXX14 {
+requires cplusplus14
+  }
+  explicit module CXX17 {
+requires cplusplus17
+  }
+  explicit module C99 {
+requires c99
+  }
+  explicit module C11 {
+requires c11
+  }
+  explicit module C17 {
+requires c17
+  }
 }

Modified: cfe/trunk/test/Modules/requires.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires.m?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/test/Modules/requires.m (original)
+++ cfe/trunk/test/Modules/requires.m Wed Feb 14 11:01:03 2018
@@ -1,6 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify 
-fmodule-feature custom_req1
-
+// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -std=c89 
-DTEST_C_FEATURES
+#ifndef TEST_C_FEATURES
 // expected-error@DependsOnModule.framework/module.map:7 {{module 
'DependsOnModule.CXX' requires feature 'cplusplus'}}
 @import DependsOnModule.CXX; // expected-note {{module imported here}}
 @import DependsOnModule.NotCXX;
@@ -15,3 +16,17 @@
 @import RequiresWithMissingHeader.HeaderBefore; // expected-note {{module 
imported here}}
 // expected-er...@module.map:* {{module 
'RequiresWithMissingHeader.HeaderAfter' requires feature 'missing'}}
 @import RequiresWithMissingHeader.HeaderAfter; // expected-note {{module 
imported here}}
+// expected-error@DependsOnModule.framework/module.map:40 {{module 
'DependsOnModule.CXX11' requires feature 'cplusplus11'}}
+@import DependsOnModule.CXX11; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:43 {{module 
'DependsOnModule.CXX14' requires feature 'cplusplus14'}}
+@import DependsOnModule.CXX14; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:46 {{module 
'DependsOnModule.CXX17' requires feature 'cplusplus17'}}
+@import DependsOnModule.C

r325156 - Update for llvm change. NFC.

2018-02-14 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 14 11:11:37 2018
New Revision: 325156

URL: http://llvm.org/viewvc/llvm-project?rev=325156&view=rev
Log:
Update for llvm change. NFC.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=325156&r1=325155&r2=325156&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Feb 14 11:11:37 2018
@@ -1122,7 +1122,7 @@ static void runThinLTOBackend(ModuleSumm
 break;
   case Backend_EmitBC:
 Conf.PreCodeGenModuleHook = [&](size_t Task, const Module &Mod) {
-  WriteBitcodeToFile(M, *OS, CGOpts.EmitLLVMUseLists);
+  WriteBitcodeToFile(*M, *OS, CGOpts.EmitLLVMUseLists);
   return false;
 };
 break;
@@ -1252,7 +1252,7 @@ void clang::EmbedBitcode(llvm::Module *M
   // If the input is LLVM Assembly, bitcode is produced by serializing
   // the module. Use-lists order need to be perserved in this case.
   llvm::raw_string_ostream OS(Data);
-  llvm::WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ true);
+  llvm::WriteBitcodeToFile(*M, OS, /* ShouldPreserveUseListOrder */ true);
   ModuleData =
   ArrayRef((const uint8_t *)OS.str().data(), OS.str().size());
 } else

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=325156&r1=325155&r2=325156&view=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Wed Feb 14 
11:11:37 2018
@@ -563,7 +563,7 @@ public:
   errs() << "error: unable to open temporary file.\n";
   return true;
 }
-WriteBitcodeToFile(AuxModule.get(), BitcodeFile);
+WriteBitcodeToFile(*AuxModule, BitcodeFile);
   }
 
   bool Failed = sys::ExecuteAndWait(ClangBinary.get(), ClangArgs);


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


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-14 Thread Matt Davis via Phabricator via cfe-commits
mattd updated this revision to Diff 134272.
mattd added a comment.

Thanks @dblaikie!  I renamed the test, and cleaned up per your suggestion.  I 
originally regex'd the debug-info lines so that the test would verify that the 
names were artificial; however, being that we already match them as metadata 
earlier, it's not really that necessary; we are only testing name strings 
anyways.  Thanks again for the suggestion.


https://reviews.llvm.org/D42813

Files:
  include/clang/Sema/Scope.h
  lib/Sema/SemaStmt.cpp
  test/CodeGenCXX/debug-info-range-for-var-names.cpp
  test/CodeGenCXX/debug-info-scope.cpp
  test/CodeGenCXX/vla.cpp

Index: test/CodeGenCXX/vla.cpp
===
--- test/CodeGenCXX/vla.cpp
+++ test/CodeGenCXX/vla.cpp
@@ -68,8 +68,8 @@
 void test2(int b) {
   // CHECK-LABEL: define void {{.*}}test2{{.*}}(i32 %b)
   int varr[b];
-  // AMD: %__end = alloca i32*, align 8, addrspace(5)
-  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end to i32**
+  // AMD: %__end1 = alloca i32*, align 8, addrspace(5)
+  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end1 to i32**
   // get the address of %b by checking the first store that stores it 
   //CHECK: store i32 %b, i32* [[PTR_B:%.*]]
 
@@ -86,7 +86,7 @@
   //CHECK: [[VLA_SIZEOF:%.*]] = mul nuw i64 4, [[VLA_NUM_ELEMENTS_PRE]]
   //CHECK-NEXT: [[VLA_NUM_ELEMENTS_POST:%.*]] = udiv i64 [[VLA_SIZEOF]], 4
   //CHECK-NEXT: [[VLA_END_PTR:%.*]] = getelementptr inbounds i32, i32* {{%.*}}, i64 [[VLA_NUM_ELEMENTS_POST]]
-  //X64-NEXT: store i32* [[VLA_END_PTR]], i32** %__end
+  //X64-NEXT: store i32* [[VLA_END_PTR]], i32** %__end1
   //AMD-NEXT: store i32* [[VLA_END_PTR]], i32** [[END]]
   for (int d : varr) 0;
 }
@@ -94,8 +94,8 @@
 void test3(int b, int c) {
   // CHECK-LABEL: define void {{.*}}test3{{.*}}(i32 %b, i32 %c)
   int varr[b][c];
-  // AMD: %__end = alloca i32*, align 8, addrspace(5)
-  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end to i32**
+  // AMD: %__end1 = alloca i32*, align 8, addrspace(5)
+  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end1 to i32**
   // get the address of %b by checking the first store that stores it 
   //CHECK: store i32 %b, i32* [[PTR_B:%.*]]
   //CHECK-NEXT: store i32 %c, i32* [[PTR_C:%.*]]
Index: test/CodeGenCXX/debug-info-scope.cpp
===
--- test/CodeGenCXX/debug-info-scope.cpp
+++ test/CodeGenCXX/debug-info-scope.cpp
@@ -58,7 +58,7 @@
   }
 
   int x[] = {1, 2};
-  // CHECK: = !DILocalVariable(name: "__range"
+  // CHECK: = !DILocalVariable(name: "__range1"
   // CHECK-SAME:   scope: [[RANGE_FOR:![0-9]*]]
   // CHECK-NOT:line:
   // CHECK-SAME:   ){{$}}
Index: test/CodeGenCXX/debug-info-range-for-var-names.cpp
===
--- test/CodeGenCXX/debug-info-range-for-var-names.cpp
+++ test/CodeGenCXX/debug-info-range-for-var-names.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+struct vec {
+  using itr = int*;
+  itr begin() { return nullptr; }
+  itr end() { return nullptr; }
+};
+
+void test() {
+  vec as, bs, cs;
+
+  for (auto a : as)
+for (auto b : bs)
+  for (auto c : cs) {
+  }
+}
+
+// CHECK: define void @_Z4testv()
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE3:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN3:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END3:[0-9]+]]
+// CHECK: ![[RANGE1]] = !DILocalVariable(name: "__range1",
+// CHECK: ![[BEGIN1]] = !DILocalVariable(name: "__begin1",
+// CHECK: ![[END1]] = !DILocalVariable(name: "__end1",
+// CHECK: ![[RANGE2]] = !DILocalVariable(name: "__range2",
+// CHECK: ![[BEGIN2]] = !DILocalVariable(name: "__begin2",
+// CHECK: ![[END2]] = !DILocalVariable(name: "__end2",
+// CHECK: ![[RANGE3]] = !DILocalVariable(name: "__range3",
+// CHECK: ![[BEGIN3]] = !DILocalVariable(name: "__begin3",
+// CHECK: ![[END3]] = !DILocalVariable(name: "__end3",
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2025,7 +2025,7 @@
 
 /// Build a variable declaration for a for-range statement.
 VarDecl *BuildForR

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 134278.
gtbercea added a comment.

Use %T.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c
  test/Driver/unix-openmp-offload-gpu.c


Index: test/Driver/unix-openmp-offload-gpu.c
===
--- /dev/null
+++ test/Driver/unix-openmp-offload-gpu.c
@@ -0,0 +1,21 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+// REQUIRES: linux
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch %T/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=%T
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_60.bc
Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,14 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   env LIBRARY_PATH=""
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: Expect degraded performance on the target device due to 
missing 'libomptarget-nvptx-sm_20.bc' in LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -529,6 +529,36 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+if (char *env = ::getenv("LIBRARY_PATH")) {
+  StringRef CompilerPath = env;
+  while (!CompilerPath.empty()) {
+std::pair Split =
+CompilerPath.split(llvm::sys::EnvPathSeparator);
+LibraryPaths.push_back(Split.first);
+CompilerPath = Split.second;
+  }
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (std::string LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::remark_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -196,6 +196,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def remark_drv_omp_offload_target_missingbcruntime : Warning<
+  "Expect degraded performance on the target device due to missing '%0' in 
LIBRARY_PATH.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/unix-openmp-offload-gpu.c
===
--- /dev/null
+++ test/Driver/unix-openmp-offload-gpu.c
@@ -0,0 +1,21 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+// REQUIRES: linux
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// 

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

I'm still not sure we can't run this test on Windows. I think lots of other 
tests use `touch`, even some specific to Windows...


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In https://reviews.llvm.org/D42813#1007865, @mattd wrote:

> Thanks @dblaikie!  I renamed the test, and cleaned up per your suggestion.  I 
> originally regex'd the debug-info lines so that the test would verify that 
> the names were artificial; however, being that we already match them as 
> metadata earlier, it's not really that necessary; we are only testing name 
> strings anyways.  Thanks again for the suggestion.


Great - can you commit this yourself or would you like me to do it for you?


https://reviews.llvm.org/D42813



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


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-14 Thread Matt Davis via Phabricator via cfe-commits
mattd added a comment.

> Great - can you commit this yourself or would you like me to do it for you?

I've got it.  Thanks!


https://reviews.llvm.org/D42813



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


[PATCH] D43277: limits: Use `false` instead of `type(0)`.

2018-02-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I see no benefit to this change.  `bool(0)` is `false`.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43277



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


[PATCH] D43294: [clang-format] Recognize percents as format specifiers in protos

2018-02-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325159: [clang-format] Recognize percents as format 
specifiers in protos (authored by krasimir, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43294?vs=134232&id=134286#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43294

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,9 @@
 if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) 
&&
 Right.isOneOf(tok::l_brace, tok::less))
   return !Style.Cpp11BracedListStyle;
+// A percent is probably part of a formatting specification, such as %lld.
+if (Left.is(tok::percent))
+  return false;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -386,5 +386,9 @@
"  }\n"
"}");
 }
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+  verifyFormat("key: %d");
+}
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -432,5 +432,11 @@
"};");
 }
 
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+  verifyFormat("option (MyProto.options) = {\n"
+   "  key: %lld\n"
+   "};");
+}
+
 } // end namespace tooling
 } // end namespace clang


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,9 @@
 if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&
 Right.isOneOf(tok::l_brace, tok::less))
   return !Style.Cpp11BracedListStyle;
+// A percent is probably part of a formatting specification, such as %lld.
+if (Left.is(tok::percent))
+  return false;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -386,5 +386,9 @@
"  }\n"
"}");
 }
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+  verifyFormat("key: %d");
+}
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -432,5 +432,11 @@
"};");
 }
 
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+  verifyFormat("option (MyProto.options) = {\n"
+   "  key: %lld\n"
+   "};");
+}
+
 } // end namespace tooling
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325159 - [clang-format] Recognize percents as format specifiers in protos

2018-02-14 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Feb 14 11:47:58 2018
New Revision: 325159

URL: http://llvm.org/viewvc/llvm-project?rev=325159&view=rev
Log:
[clang-format] Recognize percents as format specifiers in protos

Summary:
Frequently, a percent in protos denotes a formatting specifier for string 
replacement.
Thus it is desirable to keep the percent together with what follows after it.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=325159&r1=325158&r2=325159&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Feb 14 11:47:58 2018
@@ -2425,6 +2425,9 @@ bool TokenAnnotator::spaceRequiredBefore
 if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) 
&&
 Right.isOneOf(tok::l_brace, tok::less))
   return !Style.Cpp11BracedListStyle;
+// A percent is probably part of a formatting specification, such as %lld.
+if (Left.is(tok::percent))
+  return false;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=325159&r1=325158&r2=325159&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Wed Feb 14 11:47:58 2018
@@ -432,5 +432,11 @@ TEST_F(FormatTestProto, FormatsOptionsEx
"};");
 }
 
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+  verifyFormat("option (MyProto.options) = {\n"
+   "  key: %lld\n"
+   "};");
+}
+
 } // end namespace tooling
 } // end namespace clang

Modified: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTextProto.cpp?rev=325159&r1=325158&r2=325159&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp Wed Feb 14 11:47:58 2018
@@ -386,5 +386,9 @@ TEST_F(FormatTestTextProto, FormatsExten
"  }\n"
"}");
 }
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+  verifyFormat("key: %d");
+}
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

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

In https://reviews.llvm.org/D43197#1007918, @Hahnfeld wrote:

> I'm still not sure we can't run this test on Windows. I think lots of other 
> tests use `touch`, even some specific to Windows...


Let me know what you'd like me to do. I can add the test back. I do see other 
tests not worrying about this so maybe I can do the same here...


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D43197#1007963, @gtbercea wrote:

> In https://reviews.llvm.org/D43197#1007918, @Hahnfeld wrote:
>
> > I'm still not sure we can't run this test on Windows. I think lots of other 
> > tests use `touch`, even some specific to Windows...
>
>
> Let me know what you'd like me to do. I can add the test back. I do see other 
> tests not worrying about this so maybe I can do the same here...


To make it clear, I think doing all checks in `openmp-offload-gpu.c` increases 
coverage and will work as other tests show.


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 134292.
gtbercea added a comment.

Revert.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch %T/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=%T
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_60.bc
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   env LIBRARY_PATH=""
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: Expect degraded performance on the target device due to 
missing 'libomptarget-nvptx-sm_20.bc' in LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -529,6 +529,36 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+if (char *env = ::getenv("LIBRARY_PATH")) {
+  StringRef CompilerPath = env;
+  while (!CompilerPath.empty()) {
+std::pair Split =
+CompilerPath.split(llvm::sys::EnvPathSeparator);
+LibraryPaths.push_back(Split.first);
+CompilerPath = Split.second;
+  }
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (std::string LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::remark_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -196,6 +196,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def remark_drv_omp_offload_target_missingbcruntime : Warning<
+  "Expect degraded performance on the target device due to missing '%0' in 
LIBRARY_PATH.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch %T/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=%T
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps \
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mli

[PATCH] D43312: [clang-format] fix handling of consecutive unary operators

2018-02-14 Thread Kevin Lee via Phabricator via cfe-commits
kevinl created this revision.
kevinl added a reviewer: djasper.
Herald added subscribers: cfe-commits, klimek.

C++ code that used to be formatted as `if (! + object) {` is now formatted as 
`if (!+object) {`
(we have a particular object in our codebase where unary `operator+` is 
overloaded to return the underlying value, which in this case is a `bool`)

We still preserve the TypeScript behavior where `!` is a trailing non-null 
operator. (This is already tested by an existing unit test in 
`FormatTestJS.cpp`)

It doesn't appear like handling of consecutive unary operators are tested in 
general? So I added another test for completeness


Repository:
  rC Clang

https://reviews.llvm.org/D43312

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5655,6 +5655,8 @@
   verifyFormat("(a->f())++;");
   verifyFormat("a[42]++;");
   verifyFormat("if (!(a->f())) {\n}");
+  verifyFormat("if (!+i) {\n}");
+  verifyFormat("~&a;");
 
   verifyFormat("a-- > b;");
   verifyFormat("b ? -a : c;");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1493,7 +1493,8 @@
   return TT_UnaryOperator;
 
 if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator) &&
-!PrevToken->is(tok::exclaim))
+!(PrevToken->is(tok::exclaim) &&
+  Style.Language == FormatStyle::LK_JavaScript))
   // There aren't any trailing unary operators except for TypeScript's
   // non-null operator (!). Thus, this must be squence of leading 
operators.
   return TT_UnaryOperator;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5655,6 +5655,8 @@
   verifyFormat("(a->f())++;");
   verifyFormat("a[42]++;");
   verifyFormat("if (!(a->f())) {\n}");
+  verifyFormat("if (!+i) {\n}");
+  verifyFormat("~&a;");
 
   verifyFormat("a-- > b;");
   verifyFormat("b ? -a : c;");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1493,7 +1493,8 @@
   return TT_UnaryOperator;
 
 if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator) &&
-!PrevToken->is(tok::exclaim))
+!(PrevToken->is(tok::exclaim) &&
+  Style.Language == FormatStyle::LK_JavaScript))
   // There aren't any trailing unary operators except for TypeScript's
   // non-null operator (!). Thus, this must be squence of leading operators.
   return TT_UnaryOperator;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-02-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 134295.
gtbercea added a comment.

Fix test.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,24 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch %T/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=%T %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_60.bc
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: Expect degraded performance on the target device due to 
missing 'libomptarget-nvptx-sm_20.bc' in LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -529,6 +529,36 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+if (char *env = ::getenv("LIBRARY_PATH")) {
+  StringRef CompilerPath = env;
+  while (!CompilerPath.empty()) {
+std::pair Split =
+CompilerPath.split(llvm::sys::EnvPathSeparator);
+LibraryPaths.push_back(Split.first);
+CompilerPath = Split.second;
+  }
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (std::string LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::remark_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -196,6 +196,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def remark_drv_omp_offload_target_missingbcruntime : Warning<
+  "Expect degraded performance on the target device due to missing '%0' in 
LIBRARY_PATH.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,24 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create a bogus
+/// bitcode library that will be found via the LIBRARY_PATH.
+// RUN:   touch %T/libomptarget-nvptx-sm_60.bc
+// RUN:   env LIBRARY_PATH=%T %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_60 -fopenmp-relocatable-target -save-temps \
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_60.bc
+

[PATCH] D43184: [WIP] [ItaniunCXXABI] Add an option for loading the type info vtable with dllimport

2018-02-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D43184#1005258, @rnk wrote:

> Do you think we should do something like local vftables for itanium instead? 
> Can we assume all methods in the vtable will be exported by the DLL exporting 
> the class?


Will this actually ever be needed for other vtables than 
cxxabi::class_type_info and the others from 
ItaniumRTTIBuilder::BuildVTablePointer? In what other cases are the vtables 
referred to from a statically initialized global? And for these vtables - 
there's no declaration of them at all within most translation units, so that'd 
require hardcoding all the content of these vtables in ItaniumRTTIBuilder.


Repository:
  rC Clang

https://reviews.llvm.org/D43184



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


[PATCH] D43232: clang-format: use AfterControlStatement to format ObjC control blocks

2018-02-14 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton requested changes to this revision.
benhamilton added a comment.
This revision now requires changes to proceed.

Thanks! Can you add a test for this, please?


Repository:
  rC Clang

https://reviews.llvm.org/D43232



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


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2018-02-14 Thread Joris Aerts via Phabricator via cfe-commits
jorisa added a comment.

This is also a highly anticipated feature for us!


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



___
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

2018-02-14 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 134296.
malaperle added a comment.

Fix some NITs, add more tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38639

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -257,6 +257,89 @@
SourceAnnotations.range()}));
 }
 
+TEST(GoToInclude, All) {
+  MockFSProvider FS;
+  IgnoreDiagnostics DiagConsumer;
+  MockCompilationDatabase CDB;
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true);
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const char *SourceContents = R"cpp(
+  #include ^"$2^foo.h$3^"
+  #include "$4^invalid.h"
+  int b = a;
+  // test
+  int foo;
+  #in$5^clude "$6^foo.h"$7^
+  )cpp";
+  Annotations SourceAnnoations(SourceContents);
+  FS.Files[FooCpp] = SourceAnnoations.code();
+  auto FooH = getVirtualTestFilePath("foo.h");
+
+  const char *HeaderContents = R"cpp([[]]int a;)cpp";
+  Annotations HeaderAnnoations(HeaderContents);
+  FS.Files[FooH] = HeaderAnnoations.code();
+
+  Server.addDocument(FooH, HeaderAnnoations.code());
+  Server.addDocument(FooCpp, SourceAnnoations.code());
+
+  // Test include in preamble.
+  auto ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point());
+  ASSERT_TRUE(!!ExpectedLocations);
+  std::vector Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+  ASSERT_EQ(Locations[0].uri.file, FooH);
+  ASSERT_EQ(Locations[0].range, HeaderAnnoations.range());
+
+  // Test include in preamble, last char.
+  ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point("2"));
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+  ASSERT_EQ(Locations[0].uri.file, FooH);
+  ASSERT_EQ(Locations[0].range, HeaderAnnoations.range());
+
+  ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point("3"));
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+  ASSERT_EQ(Locations[0].uri.file, FooH);
+  ASSERT_EQ(Locations[0].range, HeaderAnnoations.range());
+
+  // Test include outside of preamble.
+  ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point("6"));
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+  ASSERT_EQ(Locations[0].uri.file, FooH);
+  ASSERT_EQ(Locations[0].range, HeaderAnnoations.range());
+
+  // Test a few positions that do not result in Locations.
+  ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point("4"));
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(Locations.empty());
+
+  ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point("5"));
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(Locations.empty());
+
+  ExpectedLocations =
+  Server.findDefinitions(FooCpp, SourceAnnoations.point("7"));
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(Locations.empty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -8,6 +8,7 @@
 //===-===//
 #include "XRefs.h"
 #include "Logger.h"
+#include "SourceCode.h"
 #include "URI.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexingAction.h"
@@ -130,12 +131,8 @@
 return llvm::None;
   SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(), 0,
  SourceMgr, LangOpts);
-  Position Begin;
-  Begin.line = SourceMgr.getSpellingLineNumber(LocStart) - 1;
-  Begin.character = SourceMgr.getSpellingColumnNumber(LocStart) - 1;
-  Position End;
-  End.line = SourceMgr.getSpellingLineNumber(LocEnd) - 1;
-  End.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
+  Position Begin = sourceLocToPosition(SourceMgr, LocStart);
+  Position End = sourceLocToPosition(SourceMgr, LocEnd);
   Range R = {Begin, End};
   Location L;
 
@@ -193,6 +190,15 @@
   Result.push_back(*L);
   }
 
+  /// Process targets for paths inside #include directive.
+  for (auto &IncludeLoc : AST.getInclusionLocations()) {
+Range R = IncludeLoc.first;
+Position Pos = sourceLocToPosition(SourceMgr, SourceLocationBeg);
+
+if (R.contains(Pos))
+  Result

r325171 - Clean up -fdiscard-value-name handling

2018-02-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb 14 12:56:52 2018
New Revision: 325171

URL: http://llvm.org/viewvc/llvm-project?rev=325171&view=rev
Log:
Clean up -fdiscard-value-name handling

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=325171&r1=325170&r2=325171&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb 14 12:56:52 2018
@@ -3281,11 +3281,8 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-disable-llvm-verifier");
 
   // Discard value names in assert builds unless otherwise specified.
-  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
- options::OPT_fno_discard_value_names)) {
-if (A->getOption().matches(options::OPT_fdiscard_value_names))
-  CmdArgs.push_back("-discard-value-names");
-  } else if (!IsAssertBuild)
+  if (Args.hasFlag(options::OPT_fdiscard_value_names,
+   options::OPT_fno_discard_value_names, !IsAssertBuild))
 CmdArgs.push_back("-discard-value-names");
 
   // Set the main file name, so that debug info works even with


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


  1   2   >