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

2018-02-14 Thread Sam McCall via cfe-commits
On Wed, Feb 14, 2018 at 10:45 AM Ilya Biryukov  wrote:

> 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)
>
Do you use tracing often? Can you describe your workflow?

(Less concerned about discoverability - this was always a hidden flag
anyway)


> 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=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=325096=325097=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=325096=325097=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] D43108: Support for the mno-stack-arg-probe flag

2018-02-14 Thread Ruslan Nikolaev via Phabricator via cfe-commits
nruslan added a comment.

@hans: I responded to the comments and also updated diff for clang with new 
changes.


https://reviews.llvm.org/D43108



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


[PATCH] D10831: Attach attribute "trap-func-name" to IR function

2018-02-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

AMDGPUAnnotateKernelFeatures::addFeatureAttributes looks for an llvm.trap 
instruction and adds attribute "amdgpu-queue-ptr" to the function if it finds 
one.

Other than that, it looks like your idea would work too.


Repository:
  rL LLVM

https://reviews.llvm.org/D10831



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


[PATCH] D43108: Support for the mno-stack-arg-probe flag

2018-02-14 Thread Ruslan Nikolaev via Phabricator via cfe-commits
nruslan added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:4038
+  if (Args.hasArg(options::OPT_mno_stack_arg_probe))
+CmdArgs.push_back("-mno-stack-arg-probe");
+

hans wrote:
> I think you can just do
> 
> ```
> Args.AddLastArg(CmdArgs, options::OPT_mno_stack_arg_probe)
> ```
> 
> which avoids the if-statement and having to spell out the flag.
I added mstack_arg_probe also, and this check now contains two options. I am 
not sure how AddLastArg behaves in this case (especially because only one 
attribute needs to be defined: mno-stack-arg-probe, and a positive case is the 
default). I found some other examples similar to this one, and they used hasArg 
with two options.


https://reviews.llvm.org/D43108



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


[PATCH] D43108: Support for the mno-stack-arg-probe flag

2018-02-14 Thread Ruslan Nikolaev via Phabricator via cfe-commits
nruslan updated this revision to Diff 134377.
nruslan marked 3 inline comments as done.
nruslan added a comment.

Added mstack-arg-probe, tests, and changes related to other comments of the 
reviewers


https://reviews.llvm.org/D43108

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/stack-arg-probe.c
  test/Driver/stack-arg-probe.c

Index: test/Driver/stack-arg-probe.c
===
--- /dev/null
+++ test/Driver/stack-arg-probe.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=STACKPROBE
+// RUN: %clang -### -mno-stack-arg-probe -mstack-arg-probe %s 2>&1 | FileCheck %s -check-prefix=STACKPROBE
+// RUN: %clang -### -mstack-arg-probe -mno-stack-arg-probe %s 2>&1 | FileCheck %s -check-prefix=NO-STACKPROBE
+// REQUIRES: clang-driver
+
+// NO-STACKPROBE: -mno-stack-arg-probe
+// STACKPROBE-NOT: -mno-stack-arg-probe
Index: test/CodeGen/stack-arg-probe.c
===
--- /dev/null
+++ test/CodeGen/stack-arg-probe.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple=i686-windows-msvc -emit-llvm -o - -mno-stack-arg-probe | FileCheck %s -check-prefix=NO-STACKPROBE
+// RUN: %clang_cc1 %s -triple=i686-windows-msvc -emit-llvm -o - | FileCheck %s -check-prefix=STACKPROBE
+
+// NO-STACKPROBE: attributes #{{[0-9]+}} = {{{.*}} "no-stack-arg-probe"
+// STACKPROBE-NOT: attributes #{{[0-9]+}} = {{{.*}} "no-stack-arg-probe"
+
+void test1() {
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -914,6 +914,8 @@
 Opts.StackProbeSize = StackProbeSize;
   }
 
+  Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe);
+
   if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
 StringRef Name = A->getValue();
 unsigned Method = llvm::StringSwitch(Name)
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4034,6 +4034,10 @@
   CmdArgs.push_back("-mstack-probe-size=0");
   }
 
+  if (!Args.hasFlag(options::OPT_mstack_arg_probe,
+options::OPT_mno_stack_arg_probe, true))
+CmdArgs.push_back(Args.MakeArgString("-mno-stack-arg-probe"));
+
   if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it,
options::OPT_mno_restrict_it)) {
 if (A->getOption().matches(options::OPT_mrestrict_it)) {
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2355,16 +2355,15 @@
   }
 };
 
-static void addStackProbeSizeTargetAttribute(const Decl *D,
- llvm::GlobalValue *GV,
- CodeGen::CodeGenModule ) {
-  if (D && isa(D)) {
-if (CGM.getCodeGenOpts().StackProbeSize != 4096) {
-  llvm::Function *Fn = cast(GV);
+static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+  CodeGen::CodeGenModule ) {
+  if (llvm::Function *Fn = dyn_cast_or_null(GV)) {
 
+if (CGM.getCodeGenOpts().StackProbeSize != 4096)
   Fn->addFnAttr("stack-probe-size",
 llvm::utostr(CGM.getCodeGenOpts().StackProbeSize));
-}
+if (CGM.getCodeGenOpts().NoStackArgProbe)
+  Fn->addFnAttr("no-stack-arg-probe");
   }
 }
 
@@ -2374,7 +2373,7 @@
   X86_32TargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition);
   if (!IsForDefinition)
 return;
-  addStackProbeSizeTargetAttribute(D, GV, CGM);
+  addStackProbeTargetAttributes(D, GV, CGM);
 }
 
 class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -2436,7 +2435,7 @@
 }
   }
 
-  addStackProbeSizeTargetAttribute(D, GV, CGM);
+  addStackProbeTargetAttributes(D, GV, CGM);
 }
 }
 
@@ -5622,7 +5621,7 @@
   ARMTargetCodeGenInfo::setTargetAttributes(D, GV, CGM, IsForDefinition);
   if (!IsForDefinition)
 return;
-  addStackProbeSizeTargetAttribute(D, GV, CGM);
+  addStackProbeTargetAttributes(D, GV, CGM);
 }
 }
 
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -223,6 +223,7 @@
 ///< alignment, if not 0.
 VALUE_CODEGENOPT(StackProbeSize, 32, 4096) ///< Overrides default stack
///< probe size, even if 0.
+CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
 

[PATCH] D43062: [analyzer] Support CXXTemporaryObjectExpr constructors that have destructors.

2018-02-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325211: [analyzer] Inline constructors for destroyable 
temporaries. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43062?vs=133475=134368#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43062

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/test/Analysis/temporaries.cpp

Index: cfe/trunk/test/Analysis/temporaries.cpp
===
--- cfe/trunk/test/Analysis/temporaries.cpp
+++ cfe/trunk/test/Analysis/temporaries.cpp
@@ -607,22 +607,37 @@
   clang_analyzer_eval(c3.getY() == 2); // expected-warning{{TRUE}}
 
   C c4 = returnTemporaryWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c4.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c4.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c4.getX() == 1);
+  clang_analyzer_eval(c4.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
   C c5 = returnTemporaryWithAnotherFunctionWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getX() == 1);
+  clang_analyzer_eval(c5.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
   C c6 = returnTemporaryWithCopyConstructionWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getX() == 1);
+  clang_analyzer_eval(c5.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
 #if __cplusplus >= 201103L
 
@@ -683,10 +698,84 @@
   // expected-warning@-6{{UNKNOWN}}
 #endif
 
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
   D d3 = returnTemporaryWithCopyConstructionWithVariableAndNonTrivialCopy();
-  clang_analyzer_eval(d3.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(d3.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(d3.getX() == 1);
+  clang_analyzer_eval(d3.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 }
 } // namespace test_return_temporary
+
+
+namespace test_temporary_object_expr_without_dtor {
+class C {
+  int x;
+public:
+  C(int x) : x(x) {}
+  int getX() const { return x; }
+};
+
+void test() {
+  clang_analyzer_eval(C(3).getX() == 3); // expected-warning{{TRUE}}
+};
+}
+
+namespace test_temporary_object_expr_with_dtor {
+class C {
+  int x;
+
+public:
+  C(int x) : x(x) {}
+  ~C() {}
+  int getX() const { return x; }
+};
+
+void test(int coin) {
+  clang_analyzer_eval(C(3).getX() == 3);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+
+  const C  = coin ? C(1) : C(2);
+  if (coin) {
+clang_analyzer_eval(c1.getX() == 1);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  } else {
+clang_analyzer_eval(c1.getX() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  }
+
+  C c2 = coin ? C(1) : C(2);
+  if (coin) {
+clang_analyzer_eval(c2.getX() == 1);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  } else {
+clang_analyzer_eval(c2.getX() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  }
+}
+
+} // namespace test_temporary_object_expr
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -148,6 +148,9 @@
 // construction context that'd give us the right temporary expression.
 

r325211 - [analyzer] Inline constructors for destroyable temporaries.

2018-02-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 14 19:26:43 2018
New Revision: 325211

URL: http://llvm.org/viewvc/llvm-project?rev=325211=rev
Log:
[analyzer] Inline constructors for destroyable temporaries.

Since r325210, in cfg-temporary-dtors mode, we can rely on the CFG to tell us
that we're indeed constructing a temporary, so we can trivially construct a
temporary region and inline the constructor.

Much like r325202, this is only done under the off-by-default
cfg-temporary-dtors flag because the temporary destructor, even if available,
will not be inlined and won't have the correct object value (target region).
Unless this is fixed, it is quite unsafe to inline the constructor.

If the temporary is lifetime-extended, the destructor would be an automatic
destructor, which would be evaluated with a "correct" target region - modulo
the series of incorrect relocations performed during the lifetime extension.
It means that at least, values within the object are guaranteed to be properly
escaped or invalidated.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=325211=325210=325211=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Wed Feb 14 19:26:43 2018
@@ -148,6 +148,9 @@ ExprEngine::getRegionForConstructedObjec
 // construction context that'd give us the right temporary expression.
 CallOpts.IsTemporaryCtorOrDtor = true;
 return MRMgr.getCXXTempObjectRegion(CE, LCtx);
+  } else if (auto *BTE = dyn_cast(TriggerStmt)) {
+CallOpts.IsTemporaryCtorOrDtor = true;
+return MRMgr.getCXXTempObjectRegion(CE, LCtx);
   }
   // TODO: Consider other directly initialized elements.
 } else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {

Modified: cfe/trunk/test/Analysis/temporaries.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/temporaries.cpp?rev=325211=325210=325211=diff
==
--- cfe/trunk/test/Analysis/temporaries.cpp (original)
+++ cfe/trunk/test/Analysis/temporaries.cpp Wed Feb 14 19:26:43 2018
@@ -607,22 +607,37 @@ void test() {
   clang_analyzer_eval(c3.getY() == 2); // expected-warning{{TRUE}}
 
   C c4 = returnTemporaryWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c4.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c4.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c4.getX() == 1);
+  clang_analyzer_eval(c4.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
   C c5 = returnTemporaryWithAnotherFunctionWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getX() == 1);
+  clang_analyzer_eval(c5.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
   C c6 = returnTemporaryWithCopyConstructionWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getX() == 1);
+  clang_analyzer_eval(c5.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
 #if __cplusplus >= 201103L
 
@@ -683,10 +698,84 @@ void test() {
   // expected-warning@-6{{UNKNOWN}}
 #endif
 
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
   D d3 = returnTemporaryWithCopyConstructionWithVariableAndNonTrivialCopy();
-  clang_analyzer_eval(d3.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(d3.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(d3.getX() == 1);
+  clang_analyzer_eval(d3.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // 

[PATCH] D43056: [CFG] [analyzer] Add construction context for CXXBindTemporaryExpr.

2018-02-14 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325210: [CFG] Provide construction contexts for temproary 
objects. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43056?vs=133341=134366#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43056

Files:
  cfe/trunk/lib/Analysis/CFG.cpp
  cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
  cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
  cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
===
--- cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
+++ cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
@@ -49,7 +49,8 @@
 // CHECK-NEXT:   3: a
 // CHECK-NEXT:   4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
 // CHECK-NEXT:   5: const A  = a;
-// CHECK-NEXT:   6: A() (CXXConstructExpr, class A)
+// WARNINGS-NEXT:   6: A() (CXXConstructExpr, class A)
+// ANALYZER-NEXT:   6: A() (CXXConstructExpr, [B1.7], class A)
 // CHECK-NEXT:   7: [B1.6] (BindTemporary)
 // CHECK-NEXT:   8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
 // CHECK-NEXT:   9: [B1.8]
Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -w %s > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 class C {
@@ -8,6 +8,7 @@
   C(int, int);
 
   static C get();
+  operator bool() const;
 };
 
 typedef __typeof(sizeof(int)) size_t;
@@ -226,7 +227,7 @@
 
 } // end namespace ctor_initializers
 
-namespace return_stmt {
+namespace return_stmt_without_dtor {
 
 // CHECK: C returnVariable()
 // CHECK:  1:  (CXXConstructExpr, [B1.2], class C)
@@ -315,4 +316,140 @@
   return C(C::get());
 }
 
-} // end namespace return_stmt
+} // end namespace return_stmt_without_dtor
+
+namespace return_stmt_with_dtor {
+
+class D {
+public:
+  D();
+  ~D();
+};
+
+// CHECK:  return_stmt_with_dtor::D returnTemporary()
+// CHECK:  1: return_stmt_with_dtor::D() (CXXConstructExpr, [B1.2], class return_stmt_with_dtor::D)
+// CHECK-NEXT: 2: [B1.1] (BindTemporary)
+// CHECK-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class return_stmt_with_dtor::D)
+// CHECK-NEXT: 4: [B1.3]
+// CHECK-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.7], class return_stmt_with_dtor::D)
+// CHECK-NEXT: 6: ~return_stmt_with_dtor::D() (Temporary object destructor)
+// CHECK-NEXT: 7: return [B1.5];
+D returnTemporary() {
+  return D();
+}
+
+} // end namespace return_stmt_with_dtor
+
+namespace temporary_object_expr_without_dtors {
+
+// TODO: Should provide construction context for the constructor,
+// even if there is no specific trigger statement here.
+// CHECK: void simpleTemporary()
+// CHECK   1: C() (CXXConstructExpr, class C)
+void simpleTemporary() {
+  C();
+}
+
+// TODO: Should provide construction context for the constructor,
+// CHECK: void temporaryInCondition()
+// CHECK:  1: C() (CXXConstructExpr, class C)
+// CHECK-NEXT: 2: [B2.1] (ImplicitCastExpr, NoOp, const class C)
+// CHECK-NEXT: 3: [B2.2].operator bool
+// CHECK-NEXT: 4: [B2.2]
+// CHECK-NEXT: 5: [B2.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK-NEXT: T: if [B2.5]
+void temporaryInCondition() {
+  if (C());
+}
+
+} // end namespace temporary_object_expr_without_dtors
+
+namespace temporary_object_expr_with_dtors {
+
+class D {
+public:
+  D();
+  D(int);
+  ~D();
+
+  static D get();
+
+  operator bool() const;
+};
+
+// CHECK: void simpleTemporary()
+// CHECK:  1: temporary_object_expr_with_dtors::D() (CXXConstructExpr, [B1.2], class temporary_object_expr_with_dtors::D)
+// CHECK-NEXT: 2: [B1.1] (BindTemporary)
+// CHECK-NEXT: 3: ~temporary_object_expr_with_dtors::D() (Temporary object destructor)
+void simpleTemporary() {
+  D();
+}
+
+// CHECK:  void temporaryInCondition()
+// CHECK:  1: temporary_object_expr_with_dtors::D() (CXXConstructExpr, [B2.2], class temporary_object_expr_with_dtors::D)
+// CHECK-NEXT: 2: [B2.1] (BindTemporary)
+// CHECK-NEXT: 3: [B2.2] (ImplicitCastExpr, NoOp, const class temporary_object_expr_with_dtors::D)
+// CHECK-NEXT: 4: [B2.3].operator bool
+// CHECK-NEXT: 5: [B2.3]
+// CHECK-NEXT: 6: [B2.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK-NEXT: 7: 

r325210 - [CFG] Provide construction contexts for temproary objects.

2018-02-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 14 19:13:36 2018
New Revision: 325210

URL: http://llvm.org/viewvc/llvm-project?rev=325210=rev
Log:
[CFG] Provide construction contexts for temproary objects.

Constructors of C++ temporary objects that have destructors now can be queried
to discover that they're indeed constructing temporary objects.

The respective CXXBindTemporaryExpr, which is also repsonsible for destroying
the temporary at the end of full-expression, is now available at the
construction site in the CFG. This is all the context we need to provide for
temporary objects that are not lifetime extended. For lifetime-extended
temporaries, more context is necessary.

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

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=325210=325209=325210=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Feb 14 19:13:36 2018
@@ -3923,6 +3923,8 @@ CFGBlock *CFGBuilder::VisitCXXBindTempor
 autoCreateBlock();
 appendStmt(Block, E);
 
+EnterConstructionContextIfNecessary(E, E->getSubExpr());
+
 // We do not want to propagate the AlwaysAdd property.
 asc = asc.withAlwaysAdd(false);
   }
@@ -3992,7 +3994,7 @@ CFGBlock *CFGBuilder::VisitCXXFunctional
 CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
   AddStmtChoice asc) {
   autoCreateBlock();
-  appendStmt(Block, C);
+  appendConstructor(Block, C);
   return VisitChildren(C);
 }
 

Modified: cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp?rev=325210=325209=325210=diff
==
--- cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp (original)
+++ cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp Wed Feb 14 19:13:36 
2018
@@ -49,7 +49,8 @@ extern const bool UV;
 // CHECK-NEXT:   3: a
 // CHECK-NEXT:   4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
 // CHECK-NEXT:   5: const A  = a;
-// CHECK-NEXT:   6: A() (CXXConstructExpr, class A)
+// WARNINGS-NEXT:   6: A() (CXXConstructExpr, class A)
+// ANALYZER-NEXT:   6: A() (CXXConstructExpr, [B1.7], class A)
 // CHECK-NEXT:   7: [B1.6] (BindTemporary)
 // CHECK-NEXT:   8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
 // CHECK-NEXT:   9: [B1.8]

Modified: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-rich-constructors.cpp?rev=325210=325209=325210=diff
==
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp Wed Feb 14 19:13:36 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple 
x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > 
%t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple 
x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -w 
%s > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 class C {
@@ -8,6 +8,7 @@ public:
   C(int, int);
 
   static C get();
+  operator bool() const;
 };
 
 typedef __typeof(sizeof(int)) size_t;
@@ -226,7 +227,7 @@ public:
 
 } // end namespace ctor_initializers
 
-namespace return_stmt {
+namespace return_stmt_without_dtor {
 
 // CHECK: C returnVariable()
 // CHECK:  1:  (CXXConstructExpr, [B1.2], class C)
@@ -315,4 +316,140 @@ C returnChainOfCopies() {
   return C(C::get());
 }
 
-} // end namespace return_stmt
+} // end namespace return_stmt_without_dtor
+
+namespace return_stmt_with_dtor {
+
+class D {
+public:
+  D();
+  ~D();
+};
+
+// CHECK:  return_stmt_with_dtor::D returnTemporary()
+// CHECK:  1: return_stmt_with_dtor::D() (CXXConstructExpr, [B1.2], 
class return_stmt_with_dtor::D)
+// CHECK-NEXT: 2: [B1.1] (BindTemporary)
+// CHECK-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class 
return_stmt_with_dtor::D)
+// CHECK-NEXT: 4: [B1.3]
+// CHECK-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.7], class 
return_stmt_with_dtor::D)
+// CHECK-NEXT: 6: ~return_stmt_with_dtor::D() (Temporary object destructor)
+// CHECK-NEXT: 7: return [B1.5];
+D returnTemporary() {
+  return D();
+}
+
+} // end namespace return_stmt_with_dtor
+
+namespace temporary_object_expr_without_dtors {
+
+// TODO: Should provide construction context for the constructor,
+// even if there is no specific trigger statement here.
+// CHECK: void 

[PATCH] D43056: [CFG] [analyzer] Add construction context for CXXBindTemporaryExpr.

2018-02-14 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325210: [CFG] Provide construction contexts for temproary 
objects. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43056

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/auto-obj-dtors-cfg-output.cpp
  test/Analysis/cfg-rich-constructors.cpp
  test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -216,7 +216,8 @@
 // CHECK:   [B2 (ENTRY)]
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B1.3]
@@ -275,7 +276,8 @@
 // CHECK:   [B2 (ENTRY)]
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B1.3]
@@ -290,13 +292,15 @@
 // CHECK:   [B2 (ENTRY)]
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2].operator int
 // CHECK: 4: [B1.2]
 // CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
 // CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
-// CHECK: 7: B() (CXXConstructExpr, class B)
+// WARNINGS: 7: B() (CXXConstructExpr, class B)
+// ANALYZER: 7: B() (CXXConstructExpr, [B1.8], class B)
 // CHECK: 8: [B1.7] (BindTemporary)
 // CHECK: 9: [B1.8].operator int
 // CHECK:10: [B1.8]
@@ -308,13 +312,15 @@
 // CHECK:16: ~A() (Temporary object destructor)
 // CHECK:17: foo
 // CHECK:18: [B1.17] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
-// CHECK:19: A() (CXXConstructExpr, class A)
+// WARNINGS:19: A() (CXXConstructExpr, class A)
+// ANALYZER:19: A() (CXXConstructExpr, [B1.20], class A)
 // CHECK:20: [B1.19] (BindTemporary)
 // CHECK:21: [B1.20].operator int
 // CHECK:22: [B1.20]
 // CHECK:23: [B1.22] (ImplicitCastExpr, UserDefinedConversion, int)
 // CHECK:24: int([B1.23]) (CXXFunctionalCastExpr, NoOp, int)
-// CHECK:25: B() (CXXConstructExpr, class B)
+// WARNINGS:25: B() (CXXConstructExpr, class B)
+// ANALYZER:25: B() (CXXConstructExpr, [B1.26], class B)
 // CHECK:26: [B1.25] (BindTemporary)
 // CHECK:27: [B1.26].operator int
 // CHECK:28: [B1.26]
@@ -347,7 +353,8 @@
 // CHECK: Preds (2): B4 B5
 // CHECK: Succs (2): B2 B1
 // CHECK:   [B4]
-// CHECK: 1: B() (CXXConstructExpr, class B)
+// WARNINGS: 1: B() (CXXConstructExpr, class B)
+// ANALYZER: 1: B() (CXXConstructExpr, [B4.2], class B)
 // CHECK: 2: [B4.1] (BindTemporary)
 // CHECK: 3: [B4.2].operator bool
 // CHECK: 4: [B4.2]
@@ -358,7 +365,8 @@
 // CHECK: 1: ~A() (Temporary object destructor)
 // CHECK: 2: foo
 // CHECK: 3: [B5.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
-// CHECK: 4: A() (CXXConstructExpr, class A)
+// WARNINGS: 4: A() (CXXConstructExpr, class A)
+// ANALYZER: 4: A() (CXXConstructExpr, [B5.5], class A)
 // CHECK: 5: [B5.4] (BindTemporary)
 // CHECK: 6: [B5.5].operator bool
 // CHECK: 7: [B5.5]
@@ -377,15 +385,17 @@
 // CHECK: Preds (2): B8 B9
 // CHECK: Succs (2): B6 B5
 // CHECK:   [B8]
-// CHECK: 1: B() (CXXConstructExpr, class B)
+// WARNINGS: 1: B() (CXXConstructExpr, class B)
+// ANALYZER: 1: B() (CXXConstructExpr, [B8.2], class B)
 // CHECK: 2: [B8.1] (BindTemporary)
 // CHECK: 3: [B8.2].operator bool
 // CHECK: 4: [B8.2]
 // CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
 // CHECK: Preds (1): B9
 // CHECK: Succs (1): B7
 // CHECK:   [B9]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B9.2], class A)
 // CHECK: 2: [B9.1] (BindTemporary)
 // CHECK: 3: [B9.2].operator bool
 // CHECK: 4: [B9.2]
@@ -413,7 +423,8 @@
 // CHECK: Preds (2): B4 B5
 // CHECK: Succs (2): B2 B1
 // CHECK:   [B4]
-// CHECK: 1: B() (CXXConstructExpr, class B)
+// WARNINGS: 1: B() (CXXConstructExpr, class B)
+// ANALYZER: 1: B() (CXXConstructExpr, [B4.2], 

Re: [PATCH] D10831: Attach attribute "trap-func-name" to IR function

2018-02-14 Thread Eric Christopher via cfe-commits
It could, but then you'd need to change every front end to have the same
sort of behavior, maybe you want to configure it differently, etc.

That said, I really have no strong opinions here :)

-eric

On Wed, Feb 14, 2018 at 6:51 PM Peter Collingbourne via Phabricator <
revi...@reviews.llvm.org> wrote:

> pcc added a comment.
> Herald added subscribers: llvm-commits, mehdi_amini.
>
> Maybe I'm missing something, but I don't see why we need this attribute.
> Couldn't clang have been changed to implement `-ftrap-function` by
> generating a call to the trap function instead of emitting an `llvm.trap`
> intrinsic call?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D10831
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42875: [CFG] [analyzer] Add construction context for ReturnStmt.

2018-02-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

https://reviews.llvm.org/rC325202 is attached to this revision accidentally; it 
should have been attached to https://reviews.llvm.org/D42876.


Repository:
  rL LLVM

https://reviews.llvm.org/D42875



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


[PATCH] D42991: [analyzer] Use EvalCallOptions for destructors as well.

2018-02-14 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325209: [analyzer] Decide on inlining destructors via 
EvalCallOptions. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42991?vs=133299=134364#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42991

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/test/Analysis/new.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -84,16 +84,8 @@
 }
 
 
-/// Returns a region representing the first element of a (possibly
-/// multi-dimensional) array, for the purposes of element construction or
-/// destruction.
-///
-/// On return, \p Ty will be set to the base type of the array.
-///
-/// If the type is not an array type at all, the original value is returned.
-/// Otherwise the "IsArray" flag is set.
-static SVal makeZeroElementRegion(ProgramStateRef State, SVal LValue,
-  QualType , bool ) {
+SVal ExprEngine::makeZeroElementRegion(ProgramStateRef State, SVal LValue,
+   QualType , bool ) {
   SValBuilder  = State->getStateManager().getSValBuilder();
   ASTContext  = SVB.getContext();
 
@@ -131,7 +123,7 @@
 if (CNE->isArray()) {
   // TODO: In fact, we need to call the constructor for every
   // allocated element, not just the first one!
-  CallOpts.IsArrayConstructorOrDestructor = true;
+  CallOpts.IsArrayCtorOrDtor = true;
   return getStoreManager().GetElementZeroRegion(
   MR, CNE->getType()->getPointeeType());
 }
@@ -143,7 +135,7 @@
 SVal LValue = State->getLValue(Var, LCtx);
 QualType Ty = Var->getType();
 LValue = makeZeroElementRegion(State, LValue, Ty,
-   CallOpts.IsArrayConstructorOrDestructor);
+   CallOpts.IsArrayCtorOrDtor);
 return LValue.getAsRegion();
   } else if (auto *RS = dyn_cast(TriggerStmt)) {
 // TODO: We should construct into a CXXBindTemporaryExpr or a
@@ -154,7 +146,7 @@
 // function, we should be able to take the call-site CFG element,
 // and it should contain (but right now it wouldn't) some sort of
 // construction context that'd give us the right temporary expression.
-CallOpts.IsConstructorIntoTemporary = true;
+CallOpts.IsTemporaryCtorOrDtor = true;
 return MRMgr.getCXXTempObjectRegion(CE, LCtx);
   }
   // TODO: Consider other directly initialized elements.
@@ -177,7 +169,7 @@
 
   QualType Ty = Field->getType();
   FieldVal = makeZeroElementRegion(State, FieldVal, Ty,
-   CallOpts.IsArrayConstructorOrDestructor);
+   CallOpts.IsArrayCtorOrDtor);
   return FieldVal.getAsRegion();
 }
 
@@ -187,7 +179,7 @@
   }
   // If we couldn't find an existing region to construct into, assume we're
   // constructing a temporary. Notify the caller of our failure.
-  CallOpts.IsConstructorWithImproperlyModeledTargetRegion = true;
+  CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion = true;
   return MRMgr.getCXXTempObjectRegion(CE, LCtx);
 }
 
@@ -273,7 +265,7 @@
 if (dyn_cast_or_null(LCtx->getParentMap().getParent(CE))) {
   MemRegionManager  = getSValBuilder().getRegionManager();
   Target = MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  CallOpts.IsConstructorWithImproperlyModeledTargetRegion = true;
+  CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion = true;
   break;
 }
 // FALLTHROUGH
@@ -343,7 +335,7 @@
 
   if (CE->getConstructor()->isTrivial() &&
   CE->getConstructor()->isCopyOrMoveConstructor() &&
-  !CallOpts.IsArrayConstructorOrDestructor) {
+  !CallOpts.IsArrayCtorOrDtor) {
 // FIXME: Handle other kinds of trivial constructors as well.
 for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E = DstPreCall.end();
  I != E; ++I)
@@ -400,23 +392,11 @@
 const Stmt *S,
 bool IsBaseDtor,
 ExplodedNode *Pred,
-ExplodedNodeSet ) {
+ExplodedNodeSet ,
+const EvalCallOptions ) {
   const LocationContext *LCtx = 

r325209 - [analyzer] Decide on inlining destructors via EvalCallOptions.

2018-02-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 14 18:51:58 2018
New Revision: 325209

URL: http://llvm.org/viewvc/llvm-project?rev=325209=rev
Log:
[analyzer] Decide on inlining destructors via EvalCallOptions.

EvalCallOptions were introduced in r324018 for allowing various parts of
ExprEngine to notify the inlining mechanism, while preparing for evaluating a
function call, of possible difficulties with evaluating the call that they
foresee. Then mayInlineCall() would still be a single place for making the
decision.

Use that mechanism for destructors as well - pass the necessary flags from the
CFG-element-specific destructor handlers.

Part of this patch accidentally leaked into r324018, which led into a change in
tests; this change is reverted now, because even though the change looked
correct, the underlying behavior wasn't. Both of these commits were not intended
to introduce any function changes otherwise.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/new.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=325209=325208=325209=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
Feb 14 18:51:58 2018
@@ -55,6 +55,20 @@ public:
 Inline_Minimal = 0x1
   };
 
+  /// Hints for figuring out of a call should be inlined during evalCall().
+  struct EvalCallOptions {
+/// This call is a constructor or a destructor for which we do not 
currently
+/// compute the this-region correctly.
+bool IsCtorOrDtorWithImproperlyModeledTargetRegion = false;
+/// This call is a constructor or a destructor for a single element within
+/// an array, a part of array construction or destruction.
+bool IsArrayCtorOrDtor = false;
+/// This call is a constructor or a destructor of a temporary value.
+bool IsTemporaryCtorOrDtor = false;
+
+EvalCallOptions() {}
+  };
+
 private:
   AnalysisManager 
   
@@ -449,7 +463,8 @@ public:
 
   void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest,
   const Stmt *S, bool IsBaseDtor,
-  ExplodedNode *Pred, ExplodedNodeSet );
+  ExplodedNode *Pred, ExplodedNodeSet ,
+  const EvalCallOptions );
 
   void VisitCXXNewAllocatorCall(const CXXNewExpr *CNE,
 ExplodedNode *Pred,
@@ -568,14 +583,6 @@ public:
   const LocationContext *LCtx,
   ProgramStateRef State);
 
-  struct EvalCallOptions {
-bool IsConstructorWithImproperlyModeledTargetRegion = false;
-bool IsArrayConstructorOrDestructor = false;
-bool IsConstructorIntoTemporary = false;
-
-EvalCallOptions() {}
-  };
-
   /// Evaluate a call, running pre- and post-call checks and allowing checkers
   /// to be responsible for handling the evaluation of the call itself.
   void evalCall(ExplodedNodeSet , ExplodedNode *Pred,
@@ -659,6 +666,17 @@ private:
 const Expr 
*InitWithAdjustments,
 const Expr *Result = nullptr);
 
+  /// Returns a region representing the first element of a (possibly
+  /// multi-dimensional) array, for the purposes of element construction or
+  /// destruction.
+  ///
+  /// On return, \p Ty will be set to the base type of the array.
+  ///
+  /// If the type is not an array type at all, the original value is returned.
+  /// Otherwise the "IsArray" flag is set.
+  static SVal makeZeroElementRegion(ProgramStateRef State, SVal LValue,
+QualType , bool );
+
   /// For a DeclStmt or CXXInitCtorInitializer, walk backward in the current 
CFG
   /// block to find the constructor expression that directly constructed into
   /// the storage for this statement. Returns null if the constructor for this

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=325209=325208=325209=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Feb 14 18:51:58 2018
@@ -802,8 +802,15 @@ void ExprEngine::ProcessAutomaticObjDtor
 varType = cast(Region)->getValueType();
   }
 
+  // FIXME: We need 

[PATCH] D10831: Attach attribute "trap-func-name" to IR function

2018-02-14 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.
Herald added subscribers: llvm-commits, mehdi_amini.

Maybe I'm missing something, but I don't see why we need this attribute. 
Couldn't clang have been changed to implement `-ftrap-function` by generating a 
call to the trap function instead of emitting an `llvm.trap` intrinsic call?


Repository:
  rL LLVM

https://reviews.llvm.org/D10831



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


[PATCH] D42876: [analyzer] Support returning objects by value.

2018-02-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Committed this but put a wrong phabricator link in the commit message, sorry >_<
https://reviews.llvm.org/rC325202


https://reviews.llvm.org/D42876



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


[libcxx] r325205 - Fix test failure on compilers w/o deduction guides

2018-02-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb 14 18:41:19 2018
New Revision: 325205

URL: http://llvm.org/viewvc/llvm-project?rev=325205=rev
Log:
Fix test failure on compilers w/o deduction guides

Modified:

libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp
libcxx/trunk/utils/libcxx/test/config.py

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp?rev=325205=325204=325205=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp
 Wed Feb 14 18:41:19 2018
@@ -9,8 +9,7 @@
 
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8, clang-3.9, clang-4.0
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
+// XFAIL: libcpp-no-deduction-guides
 
 // template
 //   basic_string(InputIterator begin, InputIterator end,

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=325205=325204=325205=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Wed Feb 14 18:41:19 2018
@@ -463,7 +463,8 @@ class Configuration(object):
 if '__cpp_structured_bindings' not in macros:
 self.config.available_features.add('libcpp-no-structured-bindings')
 
-if '__cpp_deduction_guides' not in macros:
+if '__cpp_deduction_guides' not in macros or \
+int(macros['__cpp_deduction_guides']) < 201611:
 self.config.available_features.add('libcpp-no-deduction-guides')
 
 if self.is_windows:


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


r325203 - Reapply r325193

2018-02-14 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Wed Feb 14 18:37:04 2018
New Revision: 325203

URL: http://llvm.org/viewvc/llvm-project?rev=325203=rev
Log:
Reapply r325193

Added:
cfe/trunk/test/Driver/amdgpu-macros.cl
  - copied unchanged from r325199, cfe/trunk/test/Driver/amdgpu-macros.cl
Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=325203=325202=325203=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Feb 14 18:37:04 2018
@@ -161,7 +161,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "tahiti";
 
-switch (parseAMDGCNName(CPU)) {
+switch (parseAMDGCNName(CPU).Kind) {
 case GK_GFX6:
 case GK_GFX7:
   break;
@@ -184,7 +184,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "r600";
 
-switch (parseR600Name(CPU)) {
+switch (parseR600Name(CPU).Kind) {
 case GK_R600:
 case GK_R700:
 case GK_EVERGREEN:
@@ -229,36 +229,36 @@ void AMDGPUTargetInfo::adjustTargetOptio
 }
 
 constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::InvalidGPU;
-constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::R600Names[];
-constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::AMDGCNNames[];
-AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseR600Name(StringRef Name) {
+constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::R600Names[];
+constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::AMDGCNNames[];
+AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseR600Name(StringRef Name) {
   const auto *Result = llvm::find_if(
-  R600Names, [Name](const NameGPUKind ) { return Kind.Name == Name; 
});
+  R600Names, [Name](const GPUInfo ) { return GPU.Name == Name; });
 
   if (Result == std::end(R600Names))
-return GK_NONE;
-  return Result->Kind;
+return InvalidGPU;
+  return *Result;
 }
 
-AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
+AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
   const auto *Result =
-  llvm::find_if(AMDGCNNames, [Name](const NameGPUKind ) {
-return Kind.Name == Name;
+  llvm::find_if(AMDGCNNames, [Name](const GPUInfo ) {
+return GPU.Name == Name;
   });
 
   if (Result == std::end(AMDGCNNames))
-return GK_NONE;
-  return Result->Kind;
+return InvalidGPU;
+  return *Result;
 }
 
 void AMDGPUTargetInfo::fillValidCPUList(
 SmallVectorImpl ) const {
   if (getTriple().getArch() == llvm::Triple::amdgcn)
-llvm::for_each(AMDGCNNames, [](const NameGPUKind ) {
-   Values.emplace_back(Kind.Name);});
+llvm::for_each(AMDGCNNames, [](const GPUInfo ) {
+   Values.emplace_back(GPU.Name);});
   else
-llvm::for_each(R600Names, [](const NameGPUKind ) {
-   Values.emplace_back(Kind.Name);});
+llvm::for_each(R600Names, [](const GPUInfo ) {
+   Values.emplace_back(GPU.Name);});
 }
 
 void AMDGPUTargetInfo::setAddressSpaceMap(bool DefaultIsPrivate) {
@@ -273,17 +273,17 @@ void AMDGPUTargetInfo::setAddressSpaceMa
 
 AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple ,
const TargetOptions )
-: TargetInfo(Triple),
-  GPU(isAMDGCN(Triple) ? GK_GFX6 : parseR600Name(Opts.CPU)),
-  hasFP64(false), hasFMAF(false), hasLDEXPF(false),
-  AS(isGenericZero(Triple)) {
+  : TargetInfo(Triple),
+GPU(isAMDGCN(Triple) ? AMDGCNNames[0] : parseR600Name(Opts.CPU)),
+hasFP64(false), hasFMAF(false), hasLDEXPF(false),
+AS(isGenericZero(Triple)) {
   if (getTriple().getArch() == llvm::Triple::amdgcn) {
 hasFP64 = true;
 hasFMAF = true;
 hasLDEXPF = true;
   }
   if (getTriple().getArch() == llvm::Triple::r600) {
-if (GPU == GK_EVERGREEN_DOUBLE_OPS || GPU == GK_CAYMAN) {
+if (GPU.Kind == GK_EVERGREEN_DOUBLE_OPS || GPU.Kind == GK_CAYMAN) {
   hasFMAF = true;
 }
   }
@@ -324,11 +324,17 @@ ArrayRef AMDGPUTargetInfo
 
 void AMDGPUTargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  Builder.defineMacro("__AMD__");
+  Builder.defineMacro("__AMDGPU__");
+
   if (getTriple().getArch() == llvm::Triple::amdgcn)
 Builder.defineMacro("__AMDGCN__");
   else
 Builder.defineMacro("__R600__");
 
+  if (GPU.Kind != GK_NONE)
+Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));
+
   if (hasFMAF)
 Builder.defineMacro("__HAS_FMAF__");
   if (hasLDEXPF)

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=325203=325202=325203=diff
==
--- 

Re: r325195 - Add missing definition for class static after r325193.

2018-02-14 Thread Konstantin Zhuravlyov via cfe-commits
I did not see this. I will reapply the patch. Sorry for the noise.

From: cfe-commits  on behalf of Richard 
Smith via cfe-commits 
Sent: Wednesday, February 14, 2018 8:01 PM
To: cfe-commits@lists.llvm.org
Subject: r325195 - Add missing definition for class static after r325193.

Author: rsmith
Date: Wed Feb 14 17:01:06 2018
New Revision: 325195

URL: http://llvm.org/viewvc/llvm-project?rev=325195=rev
Log:
Add missing definition for class static after r325193.

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=325195=325194=325195=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Feb 14 17:01:06 2018
@@ -228,7 +228,7 @@ void AMDGPUTargetInfo::adjustTargetOptio
 TargetOpts.Features.push_back("+fp64-fp16-denormals");
 }

-
+constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::InvalidGPU;
 constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::R600Names[];
 constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::AMDGCNNames[];
 AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseR600Name(StringRef Name) {


___
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] D43094: AMDGPU: Enable PIC by default for amdgcn

2018-02-14 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325196: AMDGPU: Enable PIC by default for amdgcn (authored 
by kzhuravl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43094?vs=133520=134342#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43094

Files:
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl


Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -864,6 +864,10 @@
 }
   }
 
+  // AMDGPU-specific defaults for PIC.
+  if (Triple.getArch() == llvm::Triple::amdgcn)
+PIC = true;
+
   // The last argument relating to either PIC or PIE wins, and no
   // other argument is used. If the last argument is any flavor of the
   // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE
Index: cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
===
--- cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
+++ cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck 
%s
+// RUN: %clang -### -target amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck 
%s
+// RUN: %clang -### -target amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck 
%s
+
+// CHECK: clang{{.*}} "-mrelocation-model" "pic" "-pic-level" "1"


Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -864,6 +864,10 @@
 }
   }
 
+  // AMDGPU-specific defaults for PIC.
+  if (Triple.getArch() == llvm::Triple::amdgcn)
+PIC = true;
+
   // The last argument relating to either PIC or PIE wins, and no
   // other argument is used. If the last argument is any flavor of the
   // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE
Index: cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
===
--- cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
+++ cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck %s
+
+// CHECK: clang{{.*}} "-mrelocation-model" "pic" "-pic-level" "1"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325202 - [analyzer] Allow inlining constructors into return values.

2018-02-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 14 18:32:32 2018
New Revision: 325202

URL: http://llvm.org/viewvc/llvm-project?rev=325202=rev
Log:
[analyzer] Allow inlining constructors into return values.

This only affects the cfg-temporary-dtors mode - in this mode we begin inlining
constructors that are constructing function return values. These constructors
have a correct construction context since r324952.

Because temporary destructors are not only never inlined, but also don't have
the correct target region yet, this change is not entirely safe. But this
will be fixed in the subsequent commits, while this stays off behind the
cfg-temporary-dtors flag.

Lifetime extension for return values is still not modeled correctly.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=325202=325201=325202=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
Feb 14 18:32:32 2018
@@ -571,6 +571,7 @@ public:
   struct EvalCallOptions {
 bool IsConstructorWithImproperlyModeledTargetRegion = false;
 bool IsArrayConstructorOrDestructor = false;
+bool IsConstructorIntoTemporary = false;
 
 EvalCallOptions() {}
   };

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=325202=325201=325202=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Wed Feb 14 18:32:32 2018
@@ -113,6 +113,7 @@ ExprEngine::getRegionForConstructedObjec
   EvalCallOptions ) {
   const LocationContext *LCtx = Pred->getLocationContext();
   ProgramStateRef State = Pred->getState();
+  MemRegionManager  = getSValBuilder().getRegionManager();
 
   // See if we're constructing an existing region by looking at the
   // current construction context.
@@ -144,6 +145,17 @@ ExprEngine::getRegionForConstructedObjec
 LValue = makeZeroElementRegion(State, LValue, Ty,

CallOpts.IsArrayConstructorOrDestructor);
 return LValue.getAsRegion();
+  } else if (auto *RS = dyn_cast(TriggerStmt)) {
+// TODO: We should construct into a CXXBindTemporaryExpr or a
+// MaterializeTemporaryExpr around the call-expression on the previous
+// stack frame. Currently we re-bind the temporary to the correct 
region
+// later, but that's not semantically correct. This of course does not
+// apply when we're in the top frame. But if we are in an inlined
+// function, we should be able to take the call-site CFG element,
+// and it should contain (but right now it wouldn't) some sort of
+// construction context that'd give us the right temporary expression.
+CallOpts.IsConstructorIntoTemporary = true;
+return MRMgr.getCXXTempObjectRegion(CE, LCtx);
   }
   // TODO: Consider other directly initialized elements.
 } else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {
@@ -176,7 +188,6 @@ ExprEngine::getRegionForConstructedObjec
   // If we couldn't find an existing region to construct into, assume we're
   // constructing a temporary. Notify the caller of our failure.
   CallOpts.IsConstructorWithImproperlyModeledTargetRegion = true;
-  MemRegionManager  = getSValBuilder().getRegionManager();
   return MRMgr.getCXXTempObjectRegion(CE, LCtx);
 }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=325202=325201=325202=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Wed Feb 14 
18:32:32 2018
@@ -670,11 +670,19 @@ ExprEngine::mayInlineCallKind(const Call
 if (!Opts.mayInlineCXXMemberFunction(CIMK_Destructors))
   return CIP_DisallowedAlways;
 
-// FIXME: This is a hack. We don't handle temporary destructors
-// right now, so we shouldn't inline their constructors.
-if (CtorExpr->getConstructionKind() == CXXConstructExpr::CK_Complete)
+if 

r325201 - [analyzer] NFC: Remove dead checks when computing DeclStmt construction region.

2018-02-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 14 18:30:20 2018
New Revision: 325201

URL: http://llvm.org/viewvc/llvm-project?rev=325201=rev
Log:
[analyzer] NFC: Remove dead checks when computing DeclStmt construction region.

In CFG, every DeclStmt has exactly one decl, which is always a variable.

It is also pointless to check that the initializer is the constructor because
that's how construction contexts work now.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=325201=325200=325201=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Wed Feb 14 18:30:20 2018
@@ -138,15 +138,12 @@ ExprEngine::getRegionForConstructedObjec
   }
 }
   } else if (auto *DS = dyn_cast(TriggerStmt)) {
-if (const auto *Var = dyn_cast(DS->getSingleDecl())) {
-  if (Var->getInit() && Var->getInit()->IgnoreImplicit() == CE) {
-SVal LValue = State->getLValue(Var, LCtx);
-QualType Ty = Var->getType();
-LValue = makeZeroElementRegion(
-State, LValue, Ty, CallOpts.IsArrayConstructorOrDestructor);
-return LValue.getAsRegion();
-  }
-}
+const auto *Var = cast(DS->getSingleDecl());
+SVal LValue = State->getLValue(Var, LCtx);
+QualType Ty = Var->getType();
+LValue = makeZeroElementRegion(State, LValue, Ty,
+   
CallOpts.IsArrayConstructorOrDestructor);
+return LValue.getAsRegion();
   }
   // TODO: Consider other directly initialized elements.
 } else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {


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


r325200 - Revert r325193 as it breaks buildbots

2018-02-14 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Wed Feb 14 18:27:45 2018
New Revision: 325200

URL: http://llvm.org/viewvc/llvm-project?rev=325200=rev
Log:
Revert r325193 as it breaks buildbots

Removed:
cfe/trunk/test/Driver/amdgpu-macros.cl
Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=325200=325199=325200=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Feb 14 18:27:45 2018
@@ -161,7 +161,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "tahiti";
 
-switch (parseAMDGCNName(CPU).Kind) {
+switch (parseAMDGCNName(CPU)) {
 case GK_GFX6:
 case GK_GFX7:
   break;
@@ -184,7 +184,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "r600";
 
-switch (parseR600Name(CPU).Kind) {
+switch (parseR600Name(CPU)) {
 case GK_R600:
 case GK_R700:
 case GK_EVERGREEN:
@@ -229,36 +229,36 @@ void AMDGPUTargetInfo::adjustTargetOptio
 }
 
 constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::InvalidGPU;
-constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::R600Names[];
-constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::AMDGCNNames[];
-AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseR600Name(StringRef Name) {
+constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::R600Names[];
+constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::AMDGCNNames[];
+AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseR600Name(StringRef Name) {
   const auto *Result = llvm::find_if(
-  R600Names, [Name](const GPUInfo ) { return GPU.Name == Name; });
+  R600Names, [Name](const NameGPUKind ) { return Kind.Name == Name; 
});
 
   if (Result == std::end(R600Names))
-return InvalidGPU;
-  return *Result;
+return GK_NONE;
+  return Result->Kind;
 }
 
-AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
+AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
   const auto *Result =
-  llvm::find_if(AMDGCNNames, [Name](const GPUInfo ) {
-return GPU.Name == Name;
+  llvm::find_if(AMDGCNNames, [Name](const NameGPUKind ) {
+return Kind.Name == Name;
   });
 
   if (Result == std::end(AMDGCNNames))
-return InvalidGPU;
-  return *Result;
+return GK_NONE;
+  return Result->Kind;
 }
 
 void AMDGPUTargetInfo::fillValidCPUList(
 SmallVectorImpl ) const {
   if (getTriple().getArch() == llvm::Triple::amdgcn)
-llvm::for_each(AMDGCNNames, [](const GPUInfo ) {
-   Values.emplace_back(GPU.Name);});
+llvm::for_each(AMDGCNNames, [](const NameGPUKind ) {
+   Values.emplace_back(Kind.Name);});
   else
-llvm::for_each(R600Names, [](const GPUInfo ) {
-   Values.emplace_back(GPU.Name);});
+llvm::for_each(R600Names, [](const NameGPUKind ) {
+   Values.emplace_back(Kind.Name);});
 }
 
 void AMDGPUTargetInfo::setAddressSpaceMap(bool DefaultIsPrivate) {
@@ -273,17 +273,17 @@ void AMDGPUTargetInfo::setAddressSpaceMa
 
 AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple ,
const TargetOptions )
-  : TargetInfo(Triple),
-GPU(isAMDGCN(Triple) ? AMDGCNNames[0] : parseR600Name(Opts.CPU)),
-hasFP64(false), hasFMAF(false), hasLDEXPF(false),
-AS(isGenericZero(Triple)) {
+: TargetInfo(Triple),
+  GPU(isAMDGCN(Triple) ? GK_GFX6 : parseR600Name(Opts.CPU)),
+  hasFP64(false), hasFMAF(false), hasLDEXPF(false),
+  AS(isGenericZero(Triple)) {
   if (getTriple().getArch() == llvm::Triple::amdgcn) {
 hasFP64 = true;
 hasFMAF = true;
 hasLDEXPF = true;
   }
   if (getTriple().getArch() == llvm::Triple::r600) {
-if (GPU.Kind == GK_EVERGREEN_DOUBLE_OPS || GPU.Kind == GK_CAYMAN) {
+if (GPU == GK_EVERGREEN_DOUBLE_OPS || GPU == GK_CAYMAN) {
   hasFMAF = true;
 }
   }
@@ -324,17 +324,11 @@ ArrayRef AMDGPUTargetInfo
 
 void AMDGPUTargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
-  Builder.defineMacro("__AMD__");
-  Builder.defineMacro("__AMDGPU__");
-
   if (getTriple().getArch() == llvm::Triple::amdgcn)
 Builder.defineMacro("__AMDGCN__");
   else
 Builder.defineMacro("__R600__");
 
-  if (GPU.Kind != GK_NONE)
-Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));
-
   if (hasFMAF)
 Builder.defineMacro("__HAS_FMAF__");
   if (hasLDEXPF)

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=325200=325199=325200=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original)
+++ 

[PATCH] D43104: [analyzer] Find correct region for simple temporary destructor calls and inline them if possible.

2018-02-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 134351.
NoQ added a comment.

Whoops - recall that we still need to cleanup the temporaries map even, now 
that we know that we cannot assert that it's already empty. Clean up the map 
and enable the assertion that becomes tautological until the respective FIXME 
is fixed.


https://reviews.llvm.org/D43104

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/analyzer-config.cpp
  test/Analysis/temp-obj-dtors-option.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -779,3 +779,116 @@
 }
 
 } // namespace test_temporary_object_expr
+
+namespace test_match_constructors_and_destructors {
+class C {
+public:
+  int , 
+  C(int &_x, int &_y) : x(_x), y(_y) { ++x; }
+  C(const C ): x(c.x), y(c.y) { ++x; }
+  ~C() { ++y; }
+};
+
+void test_simple_temporary() {
+  int x = 0, y = 0;
+  {
+const C  = C(x, y);
+  }
+  // One constructor and one destructor.
+  clang_analyzer_eval(x == 1);
+  clang_analyzer_eval(y == 1);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
+}
+
+void test_simple_temporary_with_copy() {
+  int x = 0, y = 0;
+  {
+C c = C(x, y);
+  }
+  // Two constructors (temporary object expr and copy) and two destructors.
+  clang_analyzer_eval(x == 2);
+  clang_analyzer_eval(y == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
+}
+
+void test_ternary_temporary(int coin) {
+  int x = 0, y = 0, z = 0, w = 0;
+  {
+const C  = coin ? C(x, y) : C(z, w);
+  }
+  // This time each branch contains an additional elidable copy constructor.
+  if (coin) {
+clang_analyzer_eval(x == 2);
+clang_analyzer_eval(y == 2);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(w == 0); // expected-warning{{TRUE}}
+
+  } else {
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 2);
+clang_analyzer_eval(w == 2);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+  }
+}
+
+void test_ternary_temporary_with_copy(int coin) {
+  int x = 0, y = 0, z = 0, w = 0;
+  {
+C c = coin ? C(x, y) : C(z, w);
+  }
+  // Temporary expression, elidable copy within branch,
+  // constructor for variable - 3 total.
+  if (coin) {
+clang_analyzer_eval(x == 3);
+clang_analyzer_eval(y == 3);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(w == 0); // expected-warning{{TRUE}}
+
+  } else {
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 3);
+clang_analyzer_eval(w == 3);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+  }
+}
+} // namespace test_match_constructors_and_destructors
Index: test/Analysis/temp-obj-dtors-option.cpp
===
--- /dev/null
+++ test/Analysis/temp-obj-dtors-option.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=false -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -DINLINE -verify %s
+
+void clang_analyzer_eval(bool);
+
+struct S {
+  int 
+
+  S(int ) : x(x) { ++x; }
+  ~S() { --x; }
+};
+
+void foo() {
+  int x = 0;
+  S(x).x += 1;
+  clang_analyzer_eval(x == 1);
+#ifdef INLINE
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+}
Index: test/Analysis/analyzer-config.cpp

[PATCH] D42876: [analyzer] Support returning objects by value.

2018-02-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 134346.
NoQ added a comment.

Update the comment with some thoughts from 
http://lists.llvm.org/pipermail/cfe-dev/2018-February/056898.html


https://reviews.llvm.org/D42876

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -1,9 +1,10 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++03 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++11 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=false -verify -w -std=c++03 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=false -verify -w -std=c++11 %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true %s -std=c++11
 
 extern bool clang_analyzer_eval(bool);
 extern bool clang_analyzer_warnIfReached();
+void clang_analyzer_checkInlined(bool);
 
 struct Trivial {
   Trivial(int x) : value(x) {}
@@ -422,6 +423,10 @@
   struct CtorWithNoReturnDtor {
 CtorWithNoReturnDtor() = default;
 
+CtorWithNoReturnDtor(int x) {
+  clang_analyzer_checkInlined(false); // no-warning
+}
+
 ~CtorWithNoReturnDtor() __attribute__((noreturn));
   };
 
@@ -439,6 +444,12 @@
 clang_analyzer_warnIfReached();  // no-warning
   }
 
+#if __cplusplus >= 201103L
+  CtorWithNoReturnDtor returnNoReturnDtor() {
+return {1}; // no-crash
+  }
+#endif
+
 #endif // TEMPORARY_DTORS
 }
 
@@ -530,3 +541,152 @@
   Sub(i).m();
 }
 }
+
+namespace test_return_temporary {
+class C {
+  int x, y;
+
+public:
+  C(int x, int y) : x(x), y(y) {}
+  int getX() const { return x; }
+  int getY() const { return y; }
+  ~C() {}
+};
+
+class D: public C {
+public:
+  D() : C(1, 2) {}
+  D(const D ): C(d.getX(), d.getY()) {}
+};
+
+C returnTemporaryWithVariable() { C c(1, 2); return c; }
+C returnTemporaryWithAnotherFunctionWithVariable() {
+  return returnTemporaryWithVariable();
+}
+C returnTemporaryWithCopyConstructionWithVariable() {
+  return C(returnTemporaryWithVariable());
+}
+
+C returnTemporaryWithConstruction() { return C(1, 2); }
+C returnTemporaryWithAnotherFunctionWithConstruction() {
+  return returnTemporaryWithConstruction();
+}
+C returnTemporaryWithCopyConstructionWithConstruction() {
+  return C(returnTemporaryWithConstruction());
+}
+
+D returnTemporaryWithVariableAndNonTrivialCopy() { D d; return d; }
+D returnTemporaryWithAnotherFunctionWithVariableAndNonTrivialCopy() {
+  return returnTemporaryWithVariableAndNonTrivialCopy();
+}
+D returnTemporaryWithCopyConstructionWithVariableAndNonTrivialCopy() {
+  return D(returnTemporaryWithVariableAndNonTrivialCopy());
+}
+
+#if __cplusplus >= 201103L
+C returnTemporaryWithBraces() { return {1, 2}; }
+C returnTemporaryWithAnotherFunctionWithBraces() {
+  return returnTemporaryWithBraces();
+}
+C returnTemporaryWithCopyConstructionWithBraces() {
+  return C(returnTemporaryWithBraces());
+}
+#endif // C++11
+
+void test() {
+  C c1 = returnTemporaryWithVariable();
+  clang_analyzer_eval(c1.getX() == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(c1.getY() == 2); // expected-warning{{TRUE}}
+
+  C c2 = returnTemporaryWithAnotherFunctionWithVariable();
+  clang_analyzer_eval(c2.getX() == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(c2.getY() == 2); // expected-warning{{TRUE}}
+
+  C c3 = returnTemporaryWithCopyConstructionWithVariable();
+  clang_analyzer_eval(c3.getX() == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(c3.getY() == 2); // expected-warning{{TRUE}}
+
+  C c4 = returnTemporaryWithConstruction();
+  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
+  // in the inlined function is supported.
+  clang_analyzer_eval(c4.getX() == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c4.getY() == 2); // expected-warning{{UNKNOWN}}
+
+  C c5 = returnTemporaryWithAnotherFunctionWithConstruction();
+  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
+  // in the inlined function is supported.
+  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+
+  C c6 = returnTemporaryWithCopyConstructionWithConstruction();
+  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
+  // in the inlined function is supported.
+  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+
+#if __cplusplus >= 201103L
+
+  C c7 = 

[PATCH] D43104: [analyzer] Find correct region for simple temporary destructor calls and inline them if possible.

2018-02-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 134341.
NoQ added a comment.

All right, so the assertion that we actually destroy all temporaries in our 
`InitializedTemporaries` map is still violated quite often -  every time we do 
any sort of lifetime extension, we're actually calling the destructor on a 
different object, because `createTemporaryRegionIfNeeded()` has moved the 
object to a different place. I made a large brain dump on this matter in 
http://lists.llvm.org/pipermail/cfe-dev/2018-February/056898.html . For now it 
means that the assertion is still not going in. I added it in a commented-out 
form. In fact, @klimek has tried that long before me, and failed in a similar 
manner. If only i added the assertion in the right place (not in 
`processCallExit`, but in `processEndOfFunction`, which is also called for the 
top frame), i would have seen it earlier :) So i've reinvented quite a bit of a 
wheel here.

- Move the assertion to the right place and disable it, explaining that 
lifetime extension is broken.
- Move the similar operator-new assertion to the right place as well, while 
we're at it.
- Add a flag to disable inlining of temporary destructors, which is different 
from having them at all. It's on by default but does nothing until 
`cfg-temporary-dtors` are also enabled.
- Add a test for that flag. This flag cannot be tested in `analyzer-config.cpp` 
because it is never read unless `cfg-temporary-dtors` takes a non-default 
value, so `ConfigDumper` doesn't see it.


https://reviews.llvm.org/D43104

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/analyzer-config.cpp
  test/Analysis/temp-obj-dtors-option.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -779,3 +779,116 @@
 }
 
 } // namespace test_temporary_object_expr
+
+namespace test_match_constructors_and_destructors {
+class C {
+public:
+  int , 
+  C(int &_x, int &_y) : x(_x), y(_y) { ++x; }
+  C(const C ): x(c.x), y(c.y) { ++x; }
+  ~C() { ++y; }
+};
+
+void test_simple_temporary() {
+  int x = 0, y = 0;
+  {
+const C  = C(x, y);
+  }
+  // One constructor and one destructor.
+  clang_analyzer_eval(x == 1);
+  clang_analyzer_eval(y == 1);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
+}
+
+void test_simple_temporary_with_copy() {
+  int x = 0, y = 0;
+  {
+C c = C(x, y);
+  }
+  // Two constructors (temporary object expr and copy) and two destructors.
+  clang_analyzer_eval(x == 2);
+  clang_analyzer_eval(y == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
+}
+
+void test_ternary_temporary(int coin) {
+  int x = 0, y = 0, z = 0, w = 0;
+  {
+const C  = coin ? C(x, y) : C(z, w);
+  }
+  // This time each branch contains an additional elidable copy constructor.
+  if (coin) {
+clang_analyzer_eval(x == 2);
+clang_analyzer_eval(y == 2);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(w == 0); // expected-warning{{TRUE}}
+
+  } else {
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 2);
+clang_analyzer_eval(w == 2);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+  }
+}
+
+void test_ternary_temporary_with_copy(int coin) {
+  int x = 0, y = 0, z = 0, w = 0;
+  {
+C c = coin ? C(x, y) : C(z, w);
+  }
+  // Temporary expression, elidable copy within branch,
+  // constructor for variable - 3 total.
+  if (coin) {
+clang_analyzer_eval(x == 3);
+clang_analyzer_eval(y == 3);
+#ifdef TEMPORARY_DTORS
+// expected-warning@-3{{TRUE}}
+// expected-warning@-3{{TRUE}}
+#else
+// expected-warning@-6{{UNKNOWN}}
+// expected-warning@-6{{UNKNOWN}}
+#endif
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(w == 0); // expected-warning{{TRUE}}
+
+  } else {
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // 

r325196 - AMDGPU: Enable PIC by default for amdgcn

2018-02-14 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Wed Feb 14 17:01:53 2018
New Revision: 325196

URL: http://llvm.org/viewvc/llvm-project?rev=325196=rev
Log:
AMDGPU: Enable PIC by default for amdgcn

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

Added:
cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=325196=325195=325196=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Feb 14 17:01:53 2018
@@ -864,6 +864,10 @@ tools::ParsePICArgs(const ToolChain 
 }
   }
 
+  // AMDGPU-specific defaults for PIC.
+  if (Triple.getArch() == llvm::Triple::amdgcn)
+PIC = true;
+
   // The last argument relating to either PIC or PIE wins, and no
   // other argument is used. If the last argument is any flavor of the
   // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE

Added: cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl?rev=325196=auto
==
--- cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl (added)
+++ cfe/trunk/test/Driver/amdgcn-toolchain-pic.cl Wed Feb 14 17:01:53 2018
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck 
%s
+// RUN: %clang -### -target amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck 
%s
+// RUN: %clang -### -target amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck 
%s
+
+// CHECK: clang{{.*}} "-mrelocation-model" "pic" "-pic-level" "1"


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


r325195 - Add missing definition for class static after r325193.

2018-02-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 14 17:01:06 2018
New Revision: 325195

URL: http://llvm.org/viewvc/llvm-project?rev=325195=rev
Log:
Add missing definition for class static after r325193.

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=325195=325194=325195=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Feb 14 17:01:06 2018
@@ -228,7 +228,7 @@ void AMDGPUTargetInfo::adjustTargetOptio
 TargetOpts.Features.push_back("+fp64-fp16-denormals");
 }
 
-
+constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::InvalidGPU;
 constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::R600Names[];
 constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::AMDGCNNames[];
 AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseR600Name(StringRef Name) {


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


[PATCH] D43320: Allow dllimport non-type template arguments in C++17

2018-02-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:10166-10182
+EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
+Info.IsNonTypeTemplateArgument = true;
+LValue LV;
+if (!EvaluateLValue(this, LV, Info) || Result.HasSideEffects ||
+!CheckLValueConstantExpression(
+Info, getExprLoc(), Ctx.getLValueReferenceType(getType()), LV))
+  return false;

rsmith wrote:
> Neither `EM_ConstantFold` nor `EM_IgnoreSideEffects` seem like the right 
> evaluation modes to be using to evaluate a non-type template argument. I 
> would expect `EM_ConstantExpression` to be used for both cases.
Oh, I see, we're allowing side-effects here and then issuing a constant-folding 
warning elsewhere if there actually were any. *sigh*

I would expect we can get away with not doing that for template arguments. It'd 
be worth testing whether GCC actually allows constant folding there, or 
requires a real constant expression.



Comment at: clang/lib/Sema/SemaOverload.cpp:5401
 
-  if ((T->isReferenceType()
-   ? !Result.get()->EvaluateAsLValue(Eval, S.Context)
-   : !Result.get()->EvaluateAsRValue(Eval, S.Context)) ||
+  if (!Result.get()->EvaluateAsNonTypeTemplateArgument(Eval, T, S.Context) ||
   (RequireInt && !Eval.Val.isInt())) {

Don't we get here for `CCEKind`s other than the non-type template argument case?


https://reviews.llvm.org/D43320



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


[PATCH] D43320: Allow dllimport non-type template arguments in C++17

2018-02-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:10166-10182
+EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
+Info.IsNonTypeTemplateArgument = true;
+LValue LV;
+if (!EvaluateLValue(this, LV, Info) || Result.HasSideEffects ||
+!CheckLValueConstantExpression(
+Info, getExprLoc(), Ctx.getLValueReferenceType(getType()), LV))
+  return false;

Neither `EM_ConstantFold` nor `EM_IgnoreSideEffects` seem like the right 
evaluation modes to be using to evaluate a non-type template argument. I would 
expect `EM_ConstantExpression` to be used for both cases.


https://reviews.llvm.org/D43320



___
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
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325193: AMDGPU: Cleanup most of the macros (authored by 
kzhuravl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D36802?vs=134335=134336#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36802

Files:
  cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
  cfe/trunk/lib/Basic/Targets/AMDGPU.h
  cfe/trunk/test/Driver/amdgpu-macros.cl

Index: cfe/trunk/test/Driver/amdgpu-macros.cl
===
--- cfe/trunk/test/Driver/amdgpu-macros.cl
+++ cfe/trunk/test/Driver/amdgpu-macros.cl
@@ -0,0 +1,107 @@
+// Check that appropriate macros are defined for every supported AMDGPU
+// "-target" and "-mcpu" options.
+
+//
+// R600-based processors.
+//
+
+// RUN: %clang -E -dM -target r600 -mcpu=r600 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv630 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv635 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s
+// RUN: %clang -E -dM -target r600 -mcpu=r630 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R630 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rs780 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rs880 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv610 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv620 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv670 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV670 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv710 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV710 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv730 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV730 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv740 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV770 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv770 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV770 %s
+// RUN: %clang -E -dM -target r600 -mcpu=cedar %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CEDAR %s
+// RUN: %clang -E -dM -target r600 -mcpu=palm %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CEDAR %s
+// RUN: %clang -E -dM -target r600 -mcpu=cypress %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CYPRESS %s
+// RUN: %clang -E -dM -target r600 -mcpu=hemlock %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CYPRESS %s
+// RUN: %clang -E -dM -target r600 -mcpu=juniper %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,JUNIPER %s
+// RUN: %clang -E -dM -target r600 -mcpu=redwood %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,REDWOOD %s
+// RUN: %clang -E -dM -target r600 -mcpu=sumo %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,SUMO %s
+// RUN: %clang -E -dM -target r600 -mcpu=sumo2 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,SUMO %s
+// RUN: %clang -E -dM -target r600 -mcpu=barts %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,BARTS %s
+// RUN: %clang -E -dM -target r600 -mcpu=caicos %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CAICOS %s
+// RUN: %clang -E -dM -target r600 -mcpu=turks %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,TURKS %s
+// RUN: %clang -E -dM -target r600 -mcpu=aruba %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CAYMAN %s
+// RUN: %clang -E -dM -target r600 -mcpu=cayman %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CAYMAN %s
+
+// ARCH-R600-DAG: #define __AMD__ 1
+// ARCH-R600-DAG: #define __AMDGPU__ 1
+// ARCH-R600-DAG: #define __R600__ 1
+
+// R600:#define __r600__ 1
+// R630:#define __r630__ 1
+// RS880:   #define __rs880__ 1
+// RV670:   #define __rv670__ 1
+// RV710:   #define __rv710__ 1
+// RV730:   #define __rv730__ 1
+// RV770:   #define __rv770__ 1
+// CEDAR:   #define __cedar__ 1
+// CYPRESS: #define __cypress__ 1
+// JUNIPER: #define __juniper__ 1
+// REDWOOD: #define __redwood__ 1
+// SUMO:#define __sumo__ 1
+// BARTS:   #define __barts__ 1
+// CAICOS:  #define __caicos__ 1
+// TURKS:   #define __turks__ 1
+// CAYMAN:  #define __cayman__ 1
+
+//
+// AMDGCN-based processors.
+//
+
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx600 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX600 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=tahiti %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX600 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx601 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=hainan %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=oland %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=pitcairn %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=verde %s 2>&1 | FileCheck 

r325193 - AMDGPU: Cleanup most of the macros

2018-02-14 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Wed Feb 14 16:20:26 2018
New Revision: 325193

URL: http://llvm.org/viewvc/llvm-project?rev=325193=rev
Log:
AMDGPU: Cleanup most of the macros

- Insert __AMD__ macro
- Insert __AMDGPU__ macro
- Insert __devicename__ macro
- Add missing tests for arch macros

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

Added:
cfe/trunk/test/Driver/amdgpu-macros.cl
Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=325193=325192=325193=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Feb 14 16:20:26 2018
@@ -161,7 +161,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "tahiti";
 
-switch (parseAMDGCNName(CPU)) {
+switch (parseAMDGCNName(CPU).Kind) {
 case GK_GFX6:
 case GK_GFX7:
   break;
@@ -184,7 +184,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "r600";
 
-switch (parseR600Name(CPU)) {
+switch (parseR600Name(CPU).Kind) {
 case GK_R600:
 case GK_R700:
 case GK_EVERGREEN:
@@ -229,36 +229,36 @@ void AMDGPUTargetInfo::adjustTargetOptio
 }
 
 
-constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::R600Names[];
-constexpr AMDGPUTargetInfo::NameGPUKind AMDGPUTargetInfo::AMDGCNNames[];
-AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseR600Name(StringRef Name) {
+constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::R600Names[];
+constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::AMDGCNNames[];
+AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseR600Name(StringRef Name) {
   const auto *Result = llvm::find_if(
-  R600Names, [Name](const NameGPUKind ) { return Kind.Name == Name; 
});
+  R600Names, [Name](const GPUInfo ) { return GPU.Name == Name; });
 
   if (Result == std::end(R600Names))
-return GK_NONE;
-  return Result->Kind;
+return InvalidGPU;
+  return *Result;
 }
 
-AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
+AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
   const auto *Result =
-  llvm::find_if(AMDGCNNames, [Name](const NameGPUKind ) {
-return Kind.Name == Name;
+  llvm::find_if(AMDGCNNames, [Name](const GPUInfo ) {
+return GPU.Name == Name;
   });
 
   if (Result == std::end(AMDGCNNames))
-return GK_NONE;
-  return Result->Kind;
+return InvalidGPU;
+  return *Result;
 }
 
 void AMDGPUTargetInfo::fillValidCPUList(
 SmallVectorImpl ) const {
   if (getTriple().getArch() == llvm::Triple::amdgcn)
-llvm::for_each(AMDGCNNames, [](const NameGPUKind ) {
-   Values.emplace_back(Kind.Name);});
+llvm::for_each(AMDGCNNames, [](const GPUInfo ) {
+   Values.emplace_back(GPU.Name);});
   else
-llvm::for_each(R600Names, [](const NameGPUKind ) {
-   Values.emplace_back(Kind.Name);});
+llvm::for_each(R600Names, [](const GPUInfo ) {
+   Values.emplace_back(GPU.Name);});
 }
 
 void AMDGPUTargetInfo::setAddressSpaceMap(bool DefaultIsPrivate) {
@@ -273,17 +273,17 @@ void AMDGPUTargetInfo::setAddressSpaceMa
 
 AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple ,
const TargetOptions )
-: TargetInfo(Triple),
-  GPU(isAMDGCN(Triple) ? GK_GFX6 : parseR600Name(Opts.CPU)),
-  hasFP64(false), hasFMAF(false), hasLDEXPF(false),
-  AS(isGenericZero(Triple)) {
+  : TargetInfo(Triple),
+GPU(isAMDGCN(Triple) ? AMDGCNNames[0] : parseR600Name(Opts.CPU)),
+hasFP64(false), hasFMAF(false), hasLDEXPF(false),
+AS(isGenericZero(Triple)) {
   if (getTriple().getArch() == llvm::Triple::amdgcn) {
 hasFP64 = true;
 hasFMAF = true;
 hasLDEXPF = true;
   }
   if (getTriple().getArch() == llvm::Triple::r600) {
-if (GPU == GK_EVERGREEN_DOUBLE_OPS || GPU == GK_CAYMAN) {
+if (GPU.Kind == GK_EVERGREEN_DOUBLE_OPS || GPU.Kind == GK_CAYMAN) {
   hasFMAF = true;
 }
   }
@@ -324,11 +324,17 @@ ArrayRef AMDGPUTargetInfo
 
 void AMDGPUTargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
+  Builder.defineMacro("__AMD__");
+  Builder.defineMacro("__AMDGPU__");
+
   if (getTriple().getArch() == llvm::Triple::amdgcn)
 Builder.defineMacro("__AMDGCN__");
   else
 Builder.defineMacro("__R600__");
 
+  if (GPU.Kind != GK_NONE)
+Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));
+
   if (hasFMAF)
 Builder.defineMacro("__HAS_FMAF__");
   if (hasLDEXPF)

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=325193=325192=325193=diff

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

2018-02-14 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM


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] D36802: AMDGPU: Cleanup most of the macros

2018-02-14 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl updated this revision to Diff 134335.
kzhuravl edited the summary of this revision.
kzhuravl added a comment.

Address review feedback.


https://reviews.llvm.org/D36802

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  test/Driver/amdgpu-macros.cl

Index: test/Driver/amdgpu-macros.cl
===
--- test/Driver/amdgpu-macros.cl
+++ test/Driver/amdgpu-macros.cl
@@ -0,0 +1,107 @@
+// Check that appropriate macros are defined for every supported AMDGPU
+// "-target" and "-mcpu" options.
+
+//
+// R600-based processors.
+//
+
+// RUN: %clang -E -dM -target r600 -mcpu=r600 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv630 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv635 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R600 %s
+// RUN: %clang -E -dM -target r600 -mcpu=r630 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,R630 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rs780 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rs880 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv610 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv620 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RS880 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv670 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV670 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv710 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV710 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv730 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV730 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv740 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV770 %s
+// RUN: %clang -E -dM -target r600 -mcpu=rv770 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,RV770 %s
+// RUN: %clang -E -dM -target r600 -mcpu=cedar %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CEDAR %s
+// RUN: %clang -E -dM -target r600 -mcpu=palm %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CEDAR %s
+// RUN: %clang -E -dM -target r600 -mcpu=cypress %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CYPRESS %s
+// RUN: %clang -E -dM -target r600 -mcpu=hemlock %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CYPRESS %s
+// RUN: %clang -E -dM -target r600 -mcpu=juniper %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,JUNIPER %s
+// RUN: %clang -E -dM -target r600 -mcpu=redwood %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,REDWOOD %s
+// RUN: %clang -E -dM -target r600 -mcpu=sumo %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,SUMO %s
+// RUN: %clang -E -dM -target r600 -mcpu=sumo2 %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,SUMO %s
+// RUN: %clang -E -dM -target r600 -mcpu=barts %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,BARTS %s
+// RUN: %clang -E -dM -target r600 -mcpu=caicos %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CAICOS %s
+// RUN: %clang -E -dM -target r600 -mcpu=turks %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,TURKS %s
+// RUN: %clang -E -dM -target r600 -mcpu=aruba %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CAYMAN %s
+// RUN: %clang -E -dM -target r600 -mcpu=cayman %s 2>&1 | FileCheck --check-prefixes=ARCH-R600,CAYMAN %s
+
+// ARCH-R600-DAG: #define __AMD__ 1
+// ARCH-R600-DAG: #define __AMDGPU__ 1
+// ARCH-R600-DAG: #define __R600__ 1
+
+// R600:#define __r600__ 1
+// R630:#define __r630__ 1
+// RS880:   #define __rs880__ 1
+// RV670:   #define __rv670__ 1
+// RV710:   #define __rv710__ 1
+// RV730:   #define __rv730__ 1
+// RV770:   #define __rv770__ 1
+// CEDAR:   #define __cedar__ 1
+// CYPRESS: #define __cypress__ 1
+// JUNIPER: #define __juniper__ 1
+// REDWOOD: #define __redwood__ 1
+// SUMO:#define __sumo__ 1
+// BARTS:   #define __barts__ 1
+// CAICOS:  #define __caicos__ 1
+// TURKS:   #define __turks__ 1
+// CAYMAN:  #define __cayman__ 1
+
+//
+// AMDGCN-based processors.
+//
+
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx600 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX600 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=tahiti %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX600 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx601 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=hainan %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=oland %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=pitcairn %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=verde %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX601 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx700 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX700 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=kaveri %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,GFX700 %s
+// RUN: 

[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:23
+def warn_return_std_move : Warning<
+  "adding 'std::move' here would select a better conversion sequence">,
+  InGroup, DefaultIgnore;

Can we say something like "local variable '%0' will be copied despite being 
%select{returned|thrown}1 by name; call 'std::move' explicitly to avoid the 
copy"? (Would that be accurate, given the implementation of the warning?)

Ideally, we'd move the "call 'std::move' explicitly" hint to a separate note 
diagnostic and include a FixItHint on that diagnostic to insert the call to 
`std::move`.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:27
+def warn_return_std_move_in_cxx11 : Warning<
+  "adding 'std::move' here would have selected a better conversion sequence 
prior to CWG 1579">,
+  InGroup, DefaultIgnore;

I think the wording of this diagnostic could be improved too. It's very 
language-lawyer-friendly right now. Here's one possible starting point for 
alternative wording (though I think maybe we can do better):

"ISO C++11, prior to the resolution of defect reports, would have made a copy 
of local variable '%0' despite it being returned by name due to a type mismatch 
with the return value%diff{ ($ vs $)|}1, 2"

... plus a "note: call 'std::move' explicitly to avoid a copy when using older 
compilers" or similar, with a fixit.


Repository:
  rC Clang

https://reviews.llvm.org/D43322



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


[PATCH] D43148: Adding msan support for FreeBSD

2018-02-14 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 134331.

https://reviews.llvm.org/D43148

Files:
  lib/Driver/ToolChains/FreeBSD.cpp


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -397,5 +424,7 @@
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
+  if (IsX86_64)
+Res |= SanitizerKind::Memory;
   return Res;
 }


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -397,5 +424,7 @@
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
+  if (IsX86_64)
+Res |= SanitizerKind::Memory;
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-14 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds two new diagnostics, which are off by default:

**-Wreturn-std-move**

Diagnose cases of `return x` or `throw x`, where `x` is the name of a local 
variable or parameter, in which a copy is made.
The user probably expected a move, but they're not getting a move, perhaps 
because the type of "x" is different from the return type of the function. A 
place where this comes up in the wild is `stdext::inplace_function` 
which implements conversion via a conversion operator rather than a converting 
constructor; see https://github.com/WG21-SG14/SG14/issues/125#issue-297201412
Another place where this has come up in the wild, but where the fix ended up 
being different, was

  try { ... } catch (ExceptionType ex) {
  throw ex;
  }

where the appropriate fix in that case was to replace `throw ex;` with 
`throw;`, and incidentally to catch by reference instead of by value. (But one 
could contrive a scenario where the slicing was intentional, in which case 
throw-by-move would have been the appropriate fix after all.)

**-Wreturn-std-move-in-c++11**

Diagnose cases of "return x;" or "throw x;" which in this version of Clang *do* 
produce moves, but which prior to Clang 3.9 / GCC 5.1 produced copies instead. 
This is useful in codebases which care about portability to those older 
compilers.
The name "-in-c++11" is not technically correct; what caused the 
version-to-version change in behavior here was actually CWG 1579, not C++14. So 
I'm using the CWG issue number in the diagnostic but "C++11" in the name of the 
option. I think it's likely that codebases that need portability to GCC 
4.9-and-earlier may understand "C++11" as a colloquialism for "older compilers."

**Discussion**

I fully expect there to be lots of discussion on this patch, and for my first 
draft to be missing lots of pieces. I do hope that we can hammer it into a 
shape suitable for upstreaming, but milestone number 1 is just to get it out 
there for people to use on their own codebases.

Notice that this patch is kind of a belated negative-space version of Richard 
Trieu's `-Wpessimizing-move`. That diagnostic warns about cases of `return 
std::move(x)` that should be `return x` for speed. These diagnostics warn about 
cases of `return x` that should be `return std::move(x)` for speed. (The two 
diagnostics' bailiwicks do not overlap.)


Repository:
  rC Clang

https://reviews.llvm.org/D43322

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/warn-return-std-move.cpp

Index: test/SemaCXX/warn-return-std-move.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-return-std-move.cpp
@@ -0,0 +1,262 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -verify %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &(T &);
+}
+}
+
+struct Instrument {
+Instrument() {}
+Instrument(Instrument&&) { /* MOVE */ }
+Instrument(const Instrument&) { /* COPY */ }
+};
+struct ConvertFromBase { Instrument i; };
+struct ConvertFromDerived { Instrument i; };
+struct Base {
+Instrument i;
+operator ConvertFromBase() const& { return ConvertFromBase{i}; }
+operator ConvertFromBase() && { return ConvertFromBase{std::move(i)}; }
+};
+struct Derived : public Base {
+operator ConvertFromDerived() const& { return ConvertFromDerived{i}; }
+operator ConvertFromDerived() && { return ConvertFromDerived{std::move(i)}; }
+};
+struct ConstructFromBase {
+Instrument i;
+ConstructFromBase(const Base& b): i(b.i) {}
+ConstructFromBase(Base&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromDerived {
+Instrument i;
+ConstructFromDerived(const Derived& d): i(d.i) {}
+ConstructFromDerived(Derived&& d): i(std::move(d.i)) {}
+};
+
+struct TrivialInstrument {
+int i = 42;
+};
+struct ConvertFromTrivialBase { TrivialInstrument i; };
+struct ConvertFromTrivialDerived { TrivialInstrument i; };
+struct TrivialBase {
+TrivialInstrument i;
+operator ConvertFromTrivialBase() const& { return ConvertFromTrivialBase{i}; }
+operator ConvertFromTrivialBase() && { return ConvertFromTrivialBase{std::move(i)}; }
+};
+struct TrivialDerived : public TrivialBase {
+operator ConvertFromTrivialDerived() const& { return ConvertFromTrivialDerived{i}; }
+operator ConvertFromTrivialDerived() && { return ConvertFromTrivialDerived{std::move(i)}; }
+};
+struct ConstructFromTrivialBase {
+  

[PATCH] D43148: Adding msan support for FreeBSD

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



Comment at: FreeBSD.cpp:397
 Res |= SanitizerKind::FuzzerNoLink;
+if (IsX86_64)
+Res |= SanitizerKind::Memory;

I would keep it in a dedicated `if (IsX86_64)` (similar to NetBSD). Otherwise 
it looks fine.


Repository:
  rC Clang

https://reviews.llvm.org/D43148



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


[PATCH] D43321: Improve documentation for attribute artificial

2018-02-14 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325186: Improve documentation for attribute artificial 
(authored by erichkeane, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43321

Files:
  include/clang/Basic/AttrDocs.td


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3277,9 +3277,9 @@
 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.
-
-.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html
+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.
   }];
 }


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3277,9 +3277,9 @@
 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.
-
-.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html
+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.
   }];
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43105: [RISCV] Enable __int128_t and uint128_t through clang flag

2018-02-14 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: lib/Basic/Targets/RISCV.h:85
+  bool hasInt128Type(const LangOptions ) const override {
+return Opts.UseInt128;
+  }

kito-cheng wrote:
> efriedma wrote:
> > Maybe make this a cross-platform flag, rather than riscv-specific?
> +1, then we can make all other 32 bits target to able easier support float128 
> too :)
OK... so we can move the option check to the TargetInfo class, and the 
target-specific implementation overrides it as needed.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


r325186 - Improve documentation for attribute artificial

2018-02-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Feb 14 15:00:31 2018
New Revision: 325186

URL: http://llvm.org/viewvc/llvm-project?rev=325186=rev
Log:
Improve documentation for attribute artificial

This patch is related to https://reviews.llvm.org/rC325081

The patch improves documentation for the attribute and removes reference to GCC 
documentation.

Patch By: Elizabeth Andrews (eandrews)
Differential Revision: https://reviews.llvm.org/D43321

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=325186=325185=325186=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Feb 14 15:00:31 2018
@@ -3277,9 +3277,9 @@ or `msvc documentation 

[PATCH] D43321: Improve documentation for attribute artificial

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, thanks!


https://reviews.llvm.org/D43321



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


[PATCH] D43321: Improve documentation for attribute artificial

2018-02-14 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: rsmith, aaron.ballman, erichkeane.

This patch is related to https://reviews.llvm.org/rC325081

The patch improves documentation for the attribute and removes reference to GCC 
documentation.


https://reviews.llvm.org/D43321

Files:
  include/clang/Basic/AttrDocs.td


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3277,9 +3277,9 @@
 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.
-
-.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html
+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.
   }];
 }


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3277,9 +3277,9 @@
 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.
-
-.. _GCC: https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Function-Attributes.html
+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.
   }];
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42611: [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

2018-02-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll:59
+  ; Check that the call was devirtualized.
+  ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
+  %1 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable5, i32 8, 
metadata !"_ZTS1A")

pcc wrote:
> Move this to before line 71.
done in r325184


Repository:
  rC Clang

https://reviews.llvm.org/D42611



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


[PATCH] D43320: Allow dllimport non-type template arguments in C++17

2018-02-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: rsmith.

When the C++ committee changed the wording around non-type template
arguments, they naively thought that every global declarations address
would be a constant expression, but this is not the case.  There is no
PE/COFF relocation that allows using the address of a dllimport global
in another global. Therefore, we do not consider them constexpr, because
users expect that constexpr globals do not require dynamic
initialization.

However, there's nothing that prevents us from doing template
instantiation with dllimported non-type template parameters, so we
should allow it. That's what this patch does.

Fixes PR35772.

At first I tried to implement this as another evaluation mode
'EM_NonTypeTemplateArgument', but I would need rvalue and lvalue
varaints in order to preserve existing behavior around side effects.


https://reviews.llvm.org/D43320

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/dllimport-constexpr.cpp
  clang/test/SemaCXX/dllimport-memptr.cpp

Index: clang/test/SemaCXX/dllimport-memptr.cpp
===
--- clang/test/SemaCXX/dllimport-memptr.cpp
+++ clang/test/SemaCXX/dllimport-memptr.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -verify -std=c++17 %s
 
 // expected-no-diagnostics
 
Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++14 %s -verify -fms-extensions -triple x86_64-windows-msvc
+// RUN: %clang_cc1 -std=c++17 %s -verify -fms-extensions -triple x86_64-windows-msvc
+
+__declspec(dllimport) void imported_func();
+__declspec(dllimport) int imported_int;
+struct Foo {
+  void __declspec(dllimport) imported_method();
+};
+
+// Instantiation is OK.
+template  struct TemplateFnPtr {
+  static void getit() { FP(); }
+};
+template  struct TemplateFnRef {
+  static void getit() { FP(); }
+};
+void instantiate1() {
+  TemplateFnPtr<_func>::getit();
+  TemplateFnRef::getit();
+}
+
+// Check variable template instantiation.
+template  struct TemplateIntPtr {
+  static int getit() { return *GI; }
+};
+template  struct TemplateIntRef {
+  static int getit() { return GI; }
+};
+int instantiate2() {
+  int r = 0;
+  r += TemplateIntPtr<_int>::getit();
+  r += TemplateIntRef::getit();
+  return r;
+}
+
+// Member pointer instantiation.
+template  struct TemplateMemPtr { };
+TemplateMemPtr<::imported_method> instantiate_mp;
+
+// constexpr initialization doesn't work for dllimport things.
+// expected-error@+1{{must be initialized by a constant expression}}
+constexpr void (*constexpr_import_func)() = _func;
+// expected-error@+1{{must be initialized by a constant expression}}
+constexpr int *constexpr_import_int = _int;
+// expected-error@+1{{must be initialized by a constant expression}}
+constexpr void (Foo::*constexpr_memptr)() = ::imported_method;
+
+// We make dynamic initializers for 'const' globals, but not constexpr ones.
+void (*const const_import_func)() = _func;
+int *const const_import_int = _int;
+void (Foo::*const const_memptr)() = ::imported_method;
+
+// Check that using a non-type template parameter for constexpr global
+// initialization is correctly diagnosed during template instantiation.
+template  struct StaticConstexpr {
+  // expected-error@+1{{must be initialized by a constant expression}}
+  static constexpr void (*g_fp)() = FP;
+};
+void instantiate3() {
+  // expected-note@+1 {{requested here}}
+  StaticConstexpr::g_fp();
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5398,9 +5398,7 @@
   Expr::EvalResult Eval;
   Eval.Diag = 
 
-  if ((T->isReferenceType()
-   ? !Result.get()->EvaluateAsLValue(Eval, S.Context)
-   : !Result.get()->EvaluateAsRValue(Eval, S.Context)) ||
+  if (!Result.get()->EvaluateAsNonTypeTemplateArgument(Eval, T, S.Context) ||
   (RequireInt && !Eval.Val.isInt())) {
 // The expression can't be folded, so we can't keep it at this position in
 // the AST.
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -582,6 +582,9 @@
 /// we will evaluate.
 unsigned StepsLeft;
 
+/// True if we are evaluating for a non-type template argument.
+bool IsNonTypeTemplateArgument = false;
+
 /// BottomFrame - The frame in which evaluation started. This must be
 /// initialized after CurrentCall and CallStackDepth.
 CallStackFrame BottomFrame;
@@ -738,6 +741,14 @@
   return 

r325184 - Moved CHECK in test closer to source code

2018-02-14 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Feb 14 14:52:49 2018
New Revision: 325184

URL: http://llvm.org/viewvc/llvm-project?rev=325184=rev
Log:
Moved CHECK in test closer to source code

Modified:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=325184=325183=325184=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Wed Feb 14 
14:52:49 2018
@@ -54,8 +54,6 @@ entry:
   %0 = bitcast %struct.A* %obj to i8**
   %vtable5 = load i8*, i8** %0
 
-  ; Check that the call was devirtualized.
-  ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
   %1 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable5, i32 8, 
metadata !"_ZTS1A")
   %2 = extractvalue { i8*, i1 } %1, 1
   br i1 %2, label %cont, label %trap
@@ -67,6 +65,9 @@ trap:
 cont:
   %3 = extractvalue { i8*, i1 } %1, 0
   %4 = bitcast i8* %3 to i32 (%struct.A*, i32)*
+
+  ; Check that the call was devirtualized.
+  ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
   %call = tail call i32 %4(%struct.A* nonnull %obj, i32 %a)
   %vtable16 = load i8*, i8** %0
   %5 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable16, i32 0, 
metadata !"_ZTS1A")


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


[PATCH] D42611: [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

2018-02-14 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325182: [ThinLTO/CFI] Include TYPE_ID summaries into 
GLOBALVAL_SUMMARY_BLOCK (authored by vitalybuka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42611?vs=134317=134321#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42611

Files:
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
  cfe/trunk/test/CodeGen/thinlto-distributed.ll
  llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
  llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
  llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp

Index: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
===
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
@@ -671,7 +671,6 @@
 
   /// Mapping from type identifiers to summary information for that type
   /// identifier.
-  // FIXME: Add bitcode read/write support for this field.
   std::map TypeIdMap;
 
   /// Mapping from original ID to GUID. If original ID can map to multiple
Index: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
===
--- llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
+++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
@@ -263,6 +263,11 @@
   FS_PERMODULE_RELBF = 19,
   // Index-wide flags
   FS_FLAGS = 20,
+  // Maps type identifier to summary information for that type identifier.
+  // TYPE_ID: [typeid, kind, bitwidth, align, size, bitmask, inlinebits,
+  //   n x (typeid, kind, name, numrba,
+  //numrba x (numarg, numarg x arg, kind, info, byte, bit))]
+  FS_TYPE_ID = 21,
 };
 
 enum MetadataCodes {
Index: llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
===
--- llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
+++ llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
@@ -22,8 +22,9 @@
 ; COMBINED:   
 ; COMBINED: 
+; COMBINED: 
 ; COMBINED:   
 
 ; COMBINED:   blob data = 'foobar'
+; COMBINED-NEXT:blob data = 'foobartypeid1'
 ; COMBINED-NEXT: 
Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5071,6 +5071,56 @@
   return Ret;
 }
 
+static void
+parseWholeProgramDevirtResolutionByArg(ArrayRef Record, size_t ,
+   WholeProgramDevirtResolution ) {
+  uint64_t ArgNum = Record[Slot++];
+  WholeProgramDevirtResolution::ByArg  =
+  Wpd.ResByArg[{Record.begin() + Slot, Record.begin() + Slot + ArgNum}];
+  Slot += ArgNum;
+
+  B.TheKind =
+  static_cast(Record[Slot++]);
+  B.Info = Record[Slot++];
+  B.Byte = Record[Slot++];
+  B.Bit = Record[Slot++];
+}
+
+static void parseWholeProgramDevirtResolution(ArrayRef Record,
+  StringRef Strtab, size_t ,
+  TypeIdSummary ) {
+  uint64_t Id = Record[Slot++];
+  WholeProgramDevirtResolution  = TypeId.WPDRes[Id];
+
+  Wpd.TheKind = static_cast(Record[Slot++]);
+  Wpd.SingleImplName = {Strtab.data() + Record[Slot],
+static_cast(Record[Slot + 1])};
+  Slot += 2;
+
+  uint64_t ResByArgNum = Record[Slot++];
+  for (uint64_t I = 0; I != ResByArgNum; ++I)
+parseWholeProgramDevirtResolutionByArg(Record, Slot, Wpd);
+}
+
+static void parseTypeIdSummaryRecord(ArrayRef Record,
+ StringRef Strtab,
+ ModuleSummaryIndex ) {
+  size_t Slot = 0;
+  TypeIdSummary  = TheIndex.getOrInsertTypeIdSummary(
+  {Strtab.data() + Record[Slot], static_cast(Record[Slot + 1])});
+  Slot += 2;
+
+  TypeId.TTRes.TheKind = static_cast(Record[Slot++]);
+  TypeId.TTRes.SizeM1BitWidth = Record[Slot++];
+  TypeId.TTRes.AlignLog2 = Record[Slot++];
+  TypeId.TTRes.SizeM1 = Record[Slot++];
+  TypeId.TTRes.BitMask = Record[Slot++];
+  TypeId.TTRes.InlineBits = Record[Slot++];
+
+  while (Slot < Record.size())
+parseWholeProgramDevirtResolution(Record, Strtab, Slot, TypeId);
+}
+
 // Eagerly parse the entire summary block. This populates the GlobalValueSummary
 // objects in the index.
 Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
@@ -5388,13 +5438,18 @@
 {Strtab.data() + Record[I], static_cast(Record[I + 1])});
   break;
 }
+
 case bitc::FS_CFI_FUNCTION_DECLS: {
   std::set  = TheIndex.cfiFunctionDecls();
   for (unsigned I = 0; I != Record.size(); I += 2)
 CfiFunctionDecls.insert(
 

[PATCH] D42611: [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

2018-02-14 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325182: [ThinLTO/CFI] Include TYPE_ID summaries into 
GLOBALVAL_SUMMARY_BLOCK (authored by vitalybuka, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42611?vs=134317=134320#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42611

Files:
  test/CMakeLists.txt
  test/CodeGen/thinlto-distributed-cfi-devirt.ll
  test/CodeGen/thinlto-distributed-cfi.ll
  test/CodeGen/thinlto-distributed.ll

Index: test/CodeGen/thinlto-distributed.ll
===
--- test/CodeGen/thinlto-distributed.ll
+++ test/CodeGen/thinlto-distributed.ll
@@ -0,0 +1,21 @@
+; REQUIRES: x86-registered-target
+
+; Trivial test for distributes ThinLTO
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,main,px
+
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-grtev4-linux-gnu"
+
+define i32 @main() {
+entry:
+  ret i32 0
+}
Index: test/CodeGen/thinlto-distributed-cfi-devirt.ll
===
--- test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -0,0 +1,101 @@
+; REQUIRES: x86-registered-target
+
+; Backend test for distribute ThinLTO with CFI.
+; It additionally enables -fwhole-program-vtables to get more information in
+; TYPE_IDs of GLOBALVAL_SUMMARY_BLOCK.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,_ZN1A1nEi,p \
+; RUN:   -r=%t.o,_ZN1B1fEi,p \
+; RUN:   -r=%t.o,_ZN1C1fEi,p \
+; RUN:   -r=%t.o,_ZTV1B, \
+; RUN:   -r=%t.o,_ZTV1C, \
+; RUN:   -r=%t.o,_ZN1A1nEi, \
+; RUN:   -r=%t.o,_ZN1B1fEi, \
+; RUN:   -r=%t.o,_ZN1C1fEi, \
+; RUN:   -r=%t.o,_ZTV1B,px \
+; RUN:   -r=%t.o,_ZTV1C,px
+
+; Ensure that typeids are in the index.
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s
+; CHECK-LABEL: 
+; CHECK-LABEL: 
+; CHECK-LABEL: ___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325182 - [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

2018-02-14 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Feb 14 14:41:15 2018
New Revision: 325182

URL: http://llvm.org/viewvc/llvm-project?rev=325182=rev
Log:
[ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

Summary:
TypeID summaries are used by CFI and need to be serialized by ThinLTO
indexing for later use by LTO Backend.

Reviewers: tejohnson, pcc

Subscribers: mehdi_amini, inglorion, eraman, hiraditya, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
cfe/trunk/test/CodeGen/thinlto-distributed.ll
Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=325182=325181=325182=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Feb 14 14:41:15 2018
@@ -96,6 +96,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-bcanalyzer
 llvm-cat
 llvm-dis
+llvm-lto2
 llvm-modextract
 llvm-nm
 llvm-objdump

Added: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=325182=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Wed Feb 14 
14:41:15 2018
@@ -0,0 +1,101 @@
+; REQUIRES: x86-registered-target
+
+; Backend test for distribute ThinLTO with CFI.
+; It additionally enables -fwhole-program-vtables to get more information in
+; TYPE_IDs of GLOBALVAL_SUMMARY_BLOCK.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,_ZN1A1nEi,p \
+; RUN:   -r=%t.o,_ZN1B1fEi,p \
+; RUN:   -r=%t.o,_ZN1C1fEi,p \
+; RUN:   -r=%t.o,_ZTV1B, \
+; RUN:   -r=%t.o,_ZTV1C, \
+; RUN:   -r=%t.o,_ZN1A1nEi, \
+; RUN:   -r=%t.o,_ZN1B1fEi, \
+; RUN:   -r=%t.o,_ZN1C1fEi, \
+; RUN:   -r=%t.o,_ZTV1B,px \
+; RUN:   -r=%t.o,_ZTV1C,px
+
+; Ensure that typeids are in the index.
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s
+; CHECK-LABEL: 
+; CHECK-LABEL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll?rev=325182=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll Wed Feb 14 14:41:15 2018
@@ -0,0 +1,67 @@
+; REQUIRES: x86-registered-target
+
+; Backend test for distribute ThinLTO with CFI.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,_ZTV1B, \
+; RUN:   -r=%t.o,_ZN1B1fEi, \
+; RUN:   -r=%t.o,_ZTV1B,px
+
+; Check that typeids are in the index.
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s
+; CHECK-LABEL: 
+; CHECK-LABEL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed.ll?rev=325182=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed.ll Wed Feb 14 14:41:15 2018
@@ -0,0 +1,21 @@
+; REQUIRES: x86-registered-target
+
+; Trivial test for distributes ThinLTO
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,main,px
+
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-grtev4-linux-gnu"
+
+define i32 @main() {
+entry:
+  ret i32 0
+}


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


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

2018-02-14 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.

For now seems reasonable to fix amdgpu as PIC. If/when other clients of amdgpu 
have tool chains defined then can switch to controling in the toolchain 
isPICDefault() function.


https://reviews.llvm.org/D43094



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


[PATCH] D35894: [clangd] Code hover for Clangd

2018-02-14 Thread Simon Marchi via Phabricator via cfe-commits
simark added inline comments.



Comment at: unittests/clangd/XRefsTests.cpp:561
+
+EXPECT_EQ(H.contents.value, Test.expectedHover.str()) << Test.input;
+  }

Note that I used `.str()` here to make the output of failing tests readable and 
useful.  By default, gtest tries to print StringRef as if it was a container.  
I tried to make add a `PrintTo` function to specify how it should be printed, 
but couldn't get it to work (to have it called by the compiler), so I settled 
for this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894



___
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 Tony Tye via Phabricator via cfe-commits
t-tye requested changes to this revision.
t-tye added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Basic/Targets/AMDGPU.cpp:362
+Builder.defineMacro(Twine("__") + Twine(GPUName));
+Builder.defineMacro(Twine("__") + Twine(GPUName) + Twine("__"));
+  }

b-sumner wrote:
> At the meeting we discussed defining every alias of the given GPU, rather 
> than only the mcpu name.   Were we going to proceed with that?
Subsequent discussion settled on only defining the canonical names. If it was 
useful to also have the alternative names a header file could be provided that 
defines those names in response to the canonical names being defined.



Comment at: lib/Basic/Targets/AMDGPU.cpp:336
+  if (GPU.Kind != GK_NONE) {
+Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName));
+Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));

Subsequent discussion decided to drop this macro.


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 Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

It looks good to me, I can land this for you.


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] D35894: [clangd] Code hover for Clangd

2018-02-14 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 134306.
simark added a comment.

Generate Hover by pretty-printing the AST

This new version of the patch generates the hover by pretty-printing the AST.
The unit tests are updated accordingly.  There are some inconsistencies in how
things are printed.  For example, I find it a bit annoying that we print empty
curly braces after class names (e.g. "class Foo {}").  Also, namespace and
enums are printed with a newline between the two braces.  These are things that
could get fixed by doing changes to the clang AST printer.

The hover.test test now uses a more readable format.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/XRefs.cpp
  clangd/XRefs.h
  test/clangd/hover.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -257,6 +257,311 @@
SourceAnnotations.range()}));
 }
 
+TEST(Hover, All) {
+  struct OneTest {
+StringRef input;
+StringRef expectedHover;
+  };
+
+  OneTest Tests[] = {
+  {
+  R"cpp(// Local variable
+int main() {
+  int bonjour;
+  ^bonjour = 2;
+  int test1 = bonjour;
+}
+  )cpp",
+  "Declared in function main\n\nint bonjour",
+  },
+  {
+  R"cpp(// Local variable in method
+struct s {
+  void method() {
+int bonjour;
+^bonjour = 2;
+  }
+};
+  )cpp",
+  "Declared in function s::method\n\nint bonjour",
+  },
+  {
+  R"cpp(// Struct
+namespace ns1 {
+  struct MyClass {};
+} // namespace ns1
+int main() {
+  ns1::My^Class* Params;
+}
+  )cpp",
+  "Declared in namespace ns1\n\nstruct MyClass {}",
+  },
+  {
+  R"cpp(// Class
+namespace ns1 {
+  class MyClass {};
+} // namespace ns1
+int main() {
+  ns1::My^Class* Params;
+}
+  )cpp",
+  "Declared in namespace ns1\n\nclass MyClass {}",
+  },
+  {
+  R"cpp(// Union
+namespace ns1 {
+  union MyUnion { int x; int y; };
+} // namespace ns1
+int main() {
+  ns1::My^Union Params;
+}
+  )cpp",
+  "Declared in namespace ns1\n\nunion MyUnion {}",
+  },
+  {
+  R"cpp(// Function definition via pointer
+int foo(int) {}
+int main() {
+  auto *X = &^foo;
+}
+  )cpp",
+  "Declared in global namespace\n\nint foo(int)",
+  },
+  {
+  R"cpp(// Function declaration via call
+int foo(int);
+int main() {
+  return ^foo(42);
+}
+  )cpp",
+  "Declared in global namespace\n\nint foo(int)",
+  },
+  {
+  R"cpp(// Field
+struct Foo { int x; };
+int main() {
+  Foo bar;
+  bar.^x;
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Field with initialization
+struct Foo { int x = 5; };
+int main() {
+  Foo bar;
+  bar.^x;
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x = 5",
+  },
+  {
+  R"cpp(// Static field
+struct Foo { static int x; };
+int main() {
+  Foo::^x;
+}
+  )cpp",
+  "Declared in struct Foo\n\nstatic int x",
+  },
+  {
+  R"cpp(// Field, member initializer
+struct Foo {
+  int x;
+  Foo() : ^x(0) {}
+};
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Field, GNU old-style field designator
+struct Foo { int x; };
+int main() {
+  Foo bar = { ^x : 1 };
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Field, field designator
+struct Foo { int x; };
+int main() {
+  Foo bar = { .^x = 2 };
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Method call
+struct Foo { int x(); };
+int main() {
+  

[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 134305.
MaskRay marked 2 inline comments as done.
MaskRay added a comment.

Add an option `Suggest`.

Only suggest P0214 alternatives if it is true.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics-ppc.cpp
  test/clang-tidy/readability-simd-intrinsics-x86.cpp

Index: test/clang-tidy/readability-simd-intrinsics-x86.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics-x86.cpp
@@ -0,0 +1,26 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: readability-simd-intrinsics.Suggest, value: 1} \
+// RUN:  ]}' -- -target x86_64 -std=c++11
+
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
Index: test/clang-tidy/readability-simd-intrinsics-ppc.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics-ppc.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: readability-simd-intrinsics.Suggest, value: 1} \
+// RUN:  ]}' -- -target ppc64le -maltivec -std=c++11
+
+vector int vec_add(vector int, vector int);
+
+void PPC() {
+  vector int i0, i1;
+
+  vec_add(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,40 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+If the option ``UseStdExperimental`` is set to non-zero, for
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b); // x86
+  vec_add(a, b);   // Power
+
+the check suggests an alternative:
+
+.. code-block::
+
+  operator+ on std::experimental::simd objects
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+Options
+---
+
+.. option:: Suggest
+
+   If this option is set to non-zero (default is `0`), the check will suggest P0214 alternatives, otherwise it only points out the intrinsic function is non-portable.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  

[PATCH] D42606: [Coroutines] Use allocator overload when available

2018-02-14 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 134304.
modocache added a comment.

Thanks for the review, @GorNishanov, and for pointing out that part of the 
standard! I added a reference to the implicit object parameter, as well as some 
tests for that behavior. And thanks for pointing out the flaw in 
https://reviews.llvm.org/D41820 -- I'll submit a separate diff to forward the 
implicit object parameter to promise type constructors.


Repository:
  rC Clang

https://reviews.llvm.org/D42606

Files:
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-alloc.cpp
  test/CodeGenCoroutines/coro-gro-nrvo.cpp
  test/CodeGenCoroutines/coro-params.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -781,6 +781,102 @@
 }
 template coro dependent_uses_nothrow_new(good_promise_13);
 
+struct good_promise_custom_new_operator {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void unhandled_exception();
+  void *operator new(unsigned long, double, float, int);
+};
+
+coro
+good_coroutine_calls_custom_new_operator(double, float, int) {
+  co_return;
+}
+
+struct coroutine_nonstatic_member_struct;
+
+struct good_promise_nonstatic_member_custom_new_operator {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void unhandled_exception();
+  void *operator new(unsigned long, coroutine_nonstatic_member_struct &, double);
+};
+
+struct bad_promise_nonstatic_member_mismatched_custom_new_operator {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void unhandled_exception();
+  // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
+  void *operator new(unsigned long, double);
+};
+
+struct coroutine_nonstatic_member_struct {
+  coro
+  good_coroutine_calls_nonstatic_member_custom_new_operator(double) {
+co_return;
+  }
+
+  coro
+  bad_coroutine_calls_nonstatic_member_mistmatched_custom_new_operator(double) {
+// expected-error@-1 {{no matching function for call to 'operator new'}}
+co_return;
+  }
+};
+
+struct bad_promise_mismatched_custom_new_operator {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void unhandled_exception();
+  // expected-note@+1 {{candidate function not viable: requires 4 arguments, but 1 was provided}}
+  void *operator new(unsigned long, double, float, int);
+};
+
+coro
+bad_coroutine_calls_mismatched_custom_new_operator(double) {
+  // expected-error@-1 {{no matching function for call to 'operator new'}}
+  co_return;
+}
+
+struct bad_promise_throwing_custom_new_operator {
+  static coro get_return_object_on_allocation_failure();
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void unhandled_exception();
+  // expected-error@+1 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}}
+  void *operator new(unsigned long, double, float, int);
+};
+
+coro
+bad_coroutine_calls_throwing_custom_new_operator(double, float, int) {
+  // expected-note@-1 {{call to 'operator new' implicitly required by coroutine function here}}
+  co_return;
+}
+
+struct good_promise_noexcept_custom_new_operator {
+  static coro get_return_object_on_allocation_failure();
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void unhandled_exception();
+  void *operator new(unsigned long, double, float, int) noexcept;
+};
+
+coro
+good_coroutine_calls_noexcept_custom_new_operator(double, float, int) {
+  co_return;
+}
+
 struct mismatch_gro_type_tag1 {};
 template<>
 struct std::experimental::coroutine_traits {
Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -69,12 +69,12 @@
   // CHECK: store i32 %val, i32* %[[ValAddr:.+]]
 
   // CHECK: call i8* @llvm.coro.begin(
-  // CHECK-NEXT: call void @_ZN8MoveOnlyC1EOS_(%struct.MoveOnly* %[[MoCopy]], %struct.MoveOnly* dereferenceable(4) %[[MoParam]])
+  // CHECK: call void @_ZN8MoveOnlyC1EOS_(%struct.MoveOnly* %[[MoCopy]], %struct.MoveOnly* dereferenceable(4) %[[MoParam]])
   // CHECK-NEXT: call void @_ZN11MoveAndCopyC1EOS_(%struct.MoveAndCopy* %[[McCopy]], %struct.MoveAndCopy* dereferenceable(4) %[[McParam]]) #
   // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_typeC1Ev(
 
   // CHECK: call void 

r325175 - [Debug] Annotate compiler generated range-for loop variables.

2018-02-14 Thread Matt Davis via cfe-commits
Author: mattd
Date: Wed Feb 14 13:22:11 2018
New Revision: 325175

URL: http://llvm.org/viewvc/llvm-project?rev=325175=rev
Log:
[Debug] Annotate compiler generated range-for loop variables.

Summary:
This change aims to simplify debugging by annotating the range-for loop 
artificial variables (range, begin, end) with the scope depth. 


Reviewers: rsmith, dblaikie

Reviewed By: dblaikie

Subscribers: dblaikie, cfe-commits

Tags: #debug-info

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

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

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=325175=325174=325175=diff
==
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Wed Feb 14 13:22:11 2018
@@ -259,6 +259,9 @@ public:
   Scope *getTemplateParamParent() { return TemplateParamParent; }
   const Scope *getTemplateParamParent() const { return TemplateParamParent; }
 
+  /// Returns the depth of this scope. The translation-unit has scope depth 0.
+  unsigned getDepth() const { return Depth; }
+
   /// Returns the number of function prototype scopes in this scope
   /// chain.
   unsigned getFunctionPrototypeDepth() const {

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=325175=325174=325175=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Feb 14 13:22:11 2018
@@ -2025,7 +2025,7 @@ void NoteForRangeBeginEndFunction(Sema &
 
 /// Build a variable declaration for a for-range statement.
 VarDecl *BuildForRangeVarDecl(Sema , SourceLocation Loc,
-  QualType Type, const char *Name) {
+  QualType Type, StringRef Name) {
   DeclContext *DC = SemaRef.CurContext;
   IdentifierInfo *II = ().get(Name);
   TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
@@ -2094,10 +2094,12 @@ StmtResult Sema::ActOnCXXForRangeStmt(Sc
   }
 
   // Build  auto && __range = range-init
+  // Divide by 2, since the variables are in the inner scope (loop body).
+  const auto DepthStr = std::to_string(S->getDepth() / 2);
   SourceLocation RangeLoc = Range->getLocStart();
   VarDecl *RangeVar = BuildForRangeVarDecl(*this, RangeLoc,
Context.getAutoRRefDeductType(),
-   "__range");
+   std::string("__range") + DepthStr);
   if (FinishForRangeVarDecl(*this, RangeVar, Range, RangeLoc,
 diag::err_for_range_deduction_failure)) {
 LoopVar->setInvalidDecl();
@@ -2340,10 +2342,12 @@ Sema::BuildCXXForRangeStmt(SourceLocatio
   return StmtError();
 
 // Build auto __begin = begin-expr, __end = end-expr.
+// Divide by 2, since the variables are in the inner scope (loop body).
+const auto DepthStr = std::to_string(S->getDepth() / 2);
 VarDecl *BeginVar = BuildForRangeVarDecl(*this, ColonLoc, AutoType,
- "__begin");
+ std::string("__begin") + 
DepthStr);
 VarDecl *EndVar = BuildForRangeVarDecl(*this, ColonLoc, AutoType,
-   "__end");
+   std::string("__end") + DepthStr);
 
 // Build begin-expr and end-expr and attach to __begin and __end variables.
 ExprResult BeginExpr, EndExpr;

Added: cfe/trunk/test/CodeGenCXX/debug-info-range-for-var-names.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-range-for-var-names.cpp?rev=325175=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-range-for-var-names.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-range-for-var-names.cpp Wed Feb 14 
13:22:11 2018
@@ -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: 

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

2018-02-14 Thread Matt Davis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325175: [Debug] Annotate compiler generated range-for loop 
variables. (authored by mattd, committed by ).

Repository:
  rC Clang

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: include/clang/Sema/Scope.h
===
--- include/clang/Sema/Scope.h
+++ include/clang/Sema/Scope.h
@@ -259,6 +259,9 @@
   Scope *getTemplateParamParent() { return TemplateParamParent; }
   const Scope *getTemplateParamParent() const { return TemplateParamParent; }
 
+  /// Returns the depth of this scope. The translation-unit has scope depth 0.
+  unsigned getDepth() const { return Depth; }
+
   /// Returns the number of function prototype scopes in this scope
   /// chain.
   unsigned getFunctionPrototypeDepth() const {
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,16 +86,16 @@
   //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;
 }
 
 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: 

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=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=325170=325171=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 ,
 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


[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  : AST.getInclusionLocations()) {
+Range R = IncludeLoc.first;
+Position Pos = sourceLocToPosition(SourceMgr, SourceLocationBeg);
+
+if (R.contains(Pos))
+  

[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] 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] 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] 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 ,
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: 

[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("~");
 
   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("~");
 
   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 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 ,
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: 

[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 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


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=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=325158=325159=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=325158=325159=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=325158=325159=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] 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=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


[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] 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] 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] 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] 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 ,
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] 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 

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=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=325155=325156=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 ) {
-  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=325155=325156=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


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=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=325153=325154=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=325153=325154=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=325153=325154=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=325153=325154=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.CXX17; // expected-note {{module imported here}}

[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


[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 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] 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] 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


[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=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=325146=325147=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] 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 ) {
 return format(Code, 0, Code.size(), Style);
   }
 
+  static void verifyFormat(llvm::StringRef Code, const FormatStyle ) {
+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;
   BindingIncrease = 10;

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 >
Cc: cfe-commits >
Subject: Re: r325081 - Implement function attribute artificial

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

URL: http://llvm.org/viewvc/llvm-project?rev=325081=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=325080=325081=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=325080=325081=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=325080=325081=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: 

[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


[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) 

[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=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 

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=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: 

[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


[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] 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 , const ArgList ,
+   ArgStringList ) {
+  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 , const ArgList ,
+ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-pthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+} 
+
 void freebsd::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
@@ -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 , const ArgList ,
+   ArgStringList ) {
+  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 , const ArgList ,
+ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-pthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+} 
+
 void freebsd::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
@@ -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] 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 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] 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] 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 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] 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] 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


  1   2   >